Commit 393092be by Kai Westerkamp

FIXED DRAWING CONVEX HULL

parent 72000d21
......@@ -5,7 +5,7 @@
int main(int argc, char *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:
//QLoggingCategory::setFilterRules("*.debug=false\n"
......
......@@ -215,44 +215,50 @@ void MainWidget::paintGL(){
//TODO schön machen
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->setUniformValue("wireframe",wireframe);
regularShader->setUniformValue("colorTexture",0);
regularShader->setUniformValue("LightPos",QVector3D(0,100,100));
regularShader->setUniformValue("LightPos",light);
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();
//============= Irregular Patches====================
subdivisionShader->bind();
subdivisionShader->setUniformValue("wireframe",wireframe);
subdivisionShader->setUniformValue("colorTexture",0);
subdivisionShader->setUniformValue("LightPos",QVector3D(0,100,100));
subdivisionShader->setUniformValue("subdiv",1);
subdivisionShader->setUniformValue("LightPos",light);
mesh->render(subdivisionShader,cam->getMatrix()*rot, m_projection,subdivLevel,false);
mesh->render(subdivisionShader,view, m_projection,subdivLevel,false);
if(subdivLevel>0){
glEnable (GL_BLEND);
glDepthMask(GL_FALSE);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
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);
glDepthMask(GL_TRUE);
}
subdivisionShader->release();
update();
}
......
......@@ -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;
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", QVector/3D(1.0f, 1.0f, 1.0f));
} else {
......@@ -466,6 +466,7 @@ void Mesh::renderMesh(QOpenGLShaderProgram *shader, int index, int subdivision,
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, entry->IB_regular_handle);
f->glPatchParameteri(GL_PATCH_VERTICES, 12);
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 {
if (!entry->indices_irregular.isEmpty()) {
......
......@@ -11,7 +11,6 @@ void main()
{
tcPosition[gl_InvocationID] = vPosition[gl_InvocationID];
float tesselation = 1.0;
gl_TessLevelOuter[0] = tesselation;
......
......@@ -10,7 +10,6 @@ uniform mat4x4 MV;
uniform mat4x4 MVP;
void main()
{
......
......@@ -11,12 +11,12 @@ void main()
{
tcPosition[gl_InvocationID] = vPosition[gl_InvocationID];
float tesselation = subdiv+1;
float tesselation = subdiv;
gl_TessLevelOuter[0] = 3 * tesselation;
gl_TessLevelOuter[1] = 3 * tesselation;
gl_TessLevelOuter[2] = 3 * tesselation;
gl_TessLevelOuter[0] = exp2(tesselation);
gl_TessLevelOuter[1] = exp2(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