Commit 393092be by Kai Westerkamp

FIXED DRAWING CONVEX HULL

parent 72000d21
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
QLoggingCategory::setFilterRules("*.debug=false\n"); //QLoggingCategory::setFilterRules("*.debug=false\n");
// If you want to enable debug output for some categories use something like this: // If you want to enable debug output for some categories use something like this:
//QLoggingCategory::setFilterRules("*.debug=false\n" //QLoggingCategory::setFilterRules("*.debug=false\n"
......
...@@ -215,44 +215,50 @@ void MainWidget::paintGL(){ ...@@ -215,44 +215,50 @@ void MainWidget::paintGL(){
//TODO schön machen //TODO schön machen
rot.rotate(time/100.0*36/5,QVector3D(0,1,0)); rot.rotate(time/100.0*36/5,QVector3D(0,1,0));
} }
QMatrix4x4 view = cam->getMatrix()*rot;
QVector3D light = QVector3D(0,100,100);
//============= Regular Patches====================
regularShader->bind(); regularShader->bind();
regularShader->setUniformValue("wireframe",wireframe); regularShader->setUniformValue("wireframe",wireframe);
regularShader->setUniformValue("colorTexture",0); regularShader->setUniformValue("colorTexture",0);
regularShader->setUniformValue("LightPos",QVector3D(0,100,100)); regularShader->setUniformValue("LightPos",light);
regularShader->setUniformValue("subdiv",subdivLevel); regularShader->setUniformValue("subdiv",subdivLevel);
mesh->render(regularShader,cam->getMatrix()*rot, m_projection,subdivLevel,true); mesh->render(regularShader,view, m_projection,subdivLevel,true);
if(subdivLevel>0){
glEnable (GL_BLEND);
glDepthMask(GL_FALSE);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
regularShader->setUniformValue("wireframe",false);
regularShader->setUniformValue("subdiv",0);
mesh->render(regularShader,view, m_projection,0,true);
glDisable(GL_BLEND);
glDepthMask(GL_TRUE);
}
regularShader->release(); regularShader->release();
//============= Irregular Patches====================
subdivisionShader->bind(); subdivisionShader->bind();
subdivisionShader->setUniformValue("wireframe",wireframe); subdivisionShader->setUniformValue("wireframe",wireframe);
subdivisionShader->setUniformValue("colorTexture",0); subdivisionShader->setUniformValue("colorTexture",0);
subdivisionShader->setUniformValue("LightPos",QVector3D(0,100,100)); subdivisionShader->setUniformValue("LightPos",light);
subdivisionShader->setUniformValue("subdiv",1);
mesh->render(subdivisionShader,cam->getMatrix()*rot, m_projection,subdivLevel,false); mesh->render(subdivisionShader,view, m_projection,subdivLevel,false);
if(subdivLevel>0){ if(subdivLevel>0){
glEnable (GL_BLEND); glEnable (GL_BLEND);
glDepthMask(GL_FALSE); glDepthMask(GL_FALSE);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
subdivisionShader->setUniformValue("wireframe",false); subdivisionShader->setUniformValue("wireframe",false);
mesh->render(subdivisionShader,cam->getMatrix()*rot, m_projection,0,false); mesh->render(subdivisionShader,view, m_projection,0,false);
//mesh->render(subdivisionShader,view, m_projection,0,true);
glDisable(GL_BLEND); glDisable(GL_BLEND);
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
} }
subdivisionShader->release(); subdivisionShader->release();
update(); update();
} }
......
...@@ -437,7 +437,7 @@ void Mesh::renderMesh(QOpenGLShaderProgram *shader, int index, int subdivision, ...@@ -437,7 +437,7 @@ void Mesh::renderMesh(QOpenGLShaderProgram *shader, int index, int subdivision,
// qCDebug(log_mesh) << materials[MaterialIndex].Diffuse << materials[MaterialIndex].Specular << materials[MaterialIndex].Shininess << materials[MaterialIndex].hasTexture; // qCDebug(log_mesh) << materials[MaterialIndex].Diffuse << materials[MaterialIndex].Specular << materials[MaterialIndex].Shininess << materials[MaterialIndex].hasTexture;
if (regular ) { if (regular ) {
shader->setUniformValue("materialInfo.Diffuse", QVector3D(0.0f, 0.0f, 1.0f)); // shader->setUniformValue("materialInfo.Diffuse", QVector3D(0.0f, 0.0f, 1.0f));
shader->setUniformValue("materialInfo.Diffuse", QVector3D(243.0, 156.0, 18.0)/255.0); shader->setUniformValue("materialInfo.Diffuse", QVector3D(243.0, 156.0, 18.0)/255.0);
// shader->setUniformValue("materialInfo.Diffuse", QVector/3D(1.0f, 1.0f, 1.0f)); // shader->setUniformValue("materialInfo.Diffuse", QVector/3D(1.0f, 1.0f, 1.0f));
} else { } else {
...@@ -466,6 +466,7 @@ void Mesh::renderMesh(QOpenGLShaderProgram *shader, int index, int subdivision, ...@@ -466,6 +466,7 @@ void Mesh::renderMesh(QOpenGLShaderProgram *shader, int index, int subdivision,
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, entry->IB_regular_handle); f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, entry->IB_regular_handle);
f->glPatchParameteri(GL_PATCH_VERTICES, 12); f->glPatchParameteri(GL_PATCH_VERTICES, 12);
f->glDrawElements(GL_PATCHES, entry->indices_regular.size(), GL_UNSIGNED_INT, 0); f->glDrawElements(GL_PATCHES, entry->indices_regular.size(), GL_UNSIGNED_INT, 0);
//qCDebug(log_mesh)<<"Patches "<<entry->indices_regular.size()/12<<" Subdivision Level: "<< subdivision;
} }
} else { } else {
if (!entry->indices_irregular.isEmpty()) { if (!entry->indices_irregular.isEmpty()) {
......
...@@ -11,7 +11,6 @@ void main() ...@@ -11,7 +11,6 @@ void main()
{ {
tcPosition[gl_InvocationID] = vPosition[gl_InvocationID]; tcPosition[gl_InvocationID] = vPosition[gl_InvocationID];
float tesselation = 1.0; float tesselation = 1.0;
gl_TessLevelOuter[0] = tesselation; gl_TessLevelOuter[0] = tesselation;
......
...@@ -10,7 +10,6 @@ uniform mat4x4 MV; ...@@ -10,7 +10,6 @@ uniform mat4x4 MV;
uniform mat4x4 MVP; uniform mat4x4 MVP;
void main() void main()
{ {
......
...@@ -11,12 +11,12 @@ void main() ...@@ -11,12 +11,12 @@ void main()
{ {
tcPosition[gl_InvocationID] = vPosition[gl_InvocationID]; tcPosition[gl_InvocationID] = vPosition[gl_InvocationID];
float tesselation = subdiv+1; float tesselation = subdiv;
gl_TessLevelOuter[0] = 3 * tesselation; gl_TessLevelOuter[0] = exp2(tesselation);
gl_TessLevelOuter[1] = 3 * tesselation; gl_TessLevelOuter[1] = exp2(tesselation);
gl_TessLevelOuter[2] = 3 * tesselation; gl_TessLevelOuter[2] = exp2(tesselation);
gl_TessLevelInner[0] = 5 * tesselation; gl_TessLevelInner[0] = exp2(tesselation+1);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment