Commit 21f7a420 by Kai Westerkamp

richtigen vertecies nehmen...

parent e56887c7
......@@ -127,9 +127,9 @@ void MainWidget::loadNewMesh(){
QString fn = QFileDialog::getOpenFileName(NULL, tr("Open Mesh..."),
QString("..\\Models"),
tr("*.md5mesh *.3ds *.md2 *.obj *.dae *.dxf *.mesh.xml *.blend *.b3d" ));
tr("*.md5mesh *.3ds *.md2 *.obj *.dae *.dxf *.mesh.xml *.blend *.b3d" ));
loadNewMesh(fn);
loadNewMesh(fn);
}
void MainWidget::loadNewMesh(QString path){
......@@ -158,7 +158,7 @@ void MainWidget::setdebugOutput(bool output){
void MainWidget::setRotation(bool started){
qDebug()<<"rotation"<<started;
this->rotation = started;
rotTime = QTime::currentTime();
rotTime = QTime::currentTime();
}
void MainWidget::setWireframe(bool active){
......@@ -193,11 +193,11 @@ QOpenGLShaderProgram* MainWidget::initShaderProgram(QString vertSource, QString
QOpenGLShader* MainWidget::initGLShader(QString scource, QOpenGLShader::ShaderType type){
QOpenGLShader *shader = new QOpenGLShader(type);
if(!shader->compileSourceFile(scource)){
qCritical()<<type<< "Shader"<<scource<<"failed"<< shader->log();
exit(5);
}
return shader;
if(!shader->compileSourceFile(scource)){
qCritical()<<type<< "Shader"<<scource<<"failed"<< shader->log();
exit(5);
}
return shader;
}
......@@ -213,17 +213,18 @@ void MainWidget::paintGL(){
rot.rotate(time/100.0*36/5,QVector3D(0,1,0));
}
if(subdivLevel>0){
regularShader->bind();
regularShader->setUniformValue("wireframe",wireframe);
regularShader->setUniformValue("colorTexture",0);
regularShader->setUniformValue("LightPos",QVector3D(0,100,100));
regularShader->setUniformValue("subdiv",subdivLevel);
regularShader->bind();
regularShader->setUniformValue("wireframe",wireframe);
regularShader->setUniformValue("colorTexture",0);
regularShader->setUniformValue("LightPos",QVector3D(0,100,100));
regularShader->setUniformValue("subdiv",subdivLevel);
mesh->render(regularShader,cam->getMatrix()*rot, m_projection,subdivLevel,true);
mesh->render(regularShader,cam->getMatrix()*rot, m_projection,subdivLevel,true);
regularShader->release();
regularShader->release();
}
subdevisionShader->bind();
......
......@@ -458,18 +458,22 @@ void Mesh::renderMesh(QOpenGLShaderProgram *shader, int index, int subdivision,
std::shared_ptr<SubdivEntry> entry = entries[index].buffers[subdivision];
// Draw Vertex Array
f->glBindBuffer(GL_ARRAY_BUFFER, entry->VB_handle);
f->glVertexAttribPointer(positionIndex, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
// qDebug()<<"Render"<<subdivision<<entry->indices;
if(regular){
f->glBindBuffer(GL_ARRAY_BUFFER, entries[index].buffers[subdivision-1]->VB_handle);
f->glVertexAttribPointer(positionIndex, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, entry->IB_Regular);
f->glPatchParameteri(GL_PATCH_VERTICES, 12);
f->glDrawElements(GL_PATCHES, entry->indicesRegular.size(), GL_UNSIGNED_INT, 0);
} else{
f->glBindBuffer(GL_ARRAY_BUFFER, entry->VB_handle);
f->glVertexAttribPointer(positionIndex, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, entry->IB_handle);
f->glPatchParameteri(GL_PATCH_VERTICES, 3);
f->glDrawElements(GL_PATCHES, entry->indices.size(), GL_UNSIGNED_INT, 0);
......
......@@ -12,7 +12,7 @@ void main()
tcPosition[gl_InvocationID] = vPosition[gl_InvocationID];
float tesselation = subdiv+6;
float tesselation = subdiv+15;
gl_TessLevelOuter[0] = tesselation;
gl_TessLevelOuter[1] = tesselation;
......
......@@ -59,11 +59,12 @@ void main()
vec3 newPos= a0*p0+a1*p1+a2*p2+a3*p3+a4*p4+a5*p5+a6*p6+a7*p7+a8*p8+a9*p9+a10*p10+a11*p11;
vec4 pos = vec4(newPos/12,1);
// vec3 d0 = gl_TessCoord.x * p3;
// vec3 d1 = gl_TessCoord.y * p6;
// vec3 d2 = gl_TessCoord.z * p7;
// pos = vec4((d0 + d1 + d2),1);
/*
vec3 d0 = gl_TessCoord.x * p3;
vec3 d1 = gl_TessCoord.y * p6;
vec3 d2 = gl_TessCoord.z * p7;
pos = vec4((d0 + d1 + d2),1);
*/
tePatchDistance = gl_TessCoord.xyz;
teCamPosition = vec4(MV*pos).xyz;
......
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