Completed Lab 12.
This commit is contained in:
parent
c11fbbb5b0
commit
389c47b8b8
1 changed files with 15 additions and 5 deletions
|
@ -213,20 +213,30 @@ void render()
|
||||||
// left: use p0 for position and q0 for orientation
|
// left: use p0 for position and q0 for orientation
|
||||||
// right: use p1 for position and q1 for orientation
|
// right: use p1 for position and q1 for orientation
|
||||||
|
|
||||||
|
glm::mat4 R1 = glm::toMat4(q0);
|
||||||
|
glm::mat4 R2 = glm::toMat4(q1);
|
||||||
|
glm::mat4 R3 = glm::toMat4(glm::normalize((1.0f - alpha)*q0 + alpha*q1));
|
||||||
|
|
||||||
// LEFT
|
// LEFT
|
||||||
MV->pushMatrix();
|
MV->pushMatrix();
|
||||||
|
MV->translate(p0 - center);
|
||||||
|
MV->multMatrix(R1);
|
||||||
glUniformMatrix4fv(progNormal->getUniform("MV"), 1, GL_FALSE, glm::value_ptr(MV->topMatrix()));
|
glUniformMatrix4fv(progNormal->getUniform("MV"), 1, GL_FALSE, glm::value_ptr(MV->topMatrix()));
|
||||||
MV->popMatrix();
|
MV->popMatrix();
|
||||||
bunny->draw(progNormal);
|
bunny->draw(progNormal);
|
||||||
|
|
||||||
// RIGHT
|
// RIGHT
|
||||||
MV->pushMatrix();
|
MV->pushMatrix();
|
||||||
|
MV->translate(p1 - center);
|
||||||
|
MV->multMatrix(R2);
|
||||||
glUniformMatrix4fv(progNormal->getUniform("MV"), 1, GL_FALSE, glm::value_ptr(MV->topMatrix()));
|
glUniformMatrix4fv(progNormal->getUniform("MV"), 1, GL_FALSE, glm::value_ptr(MV->topMatrix()));
|
||||||
MV->popMatrix();
|
MV->popMatrix();
|
||||||
bunny->draw(progNormal);
|
bunny->draw(progNormal);
|
||||||
|
|
||||||
// INTERPOLATED
|
// INTERPOLATED
|
||||||
MV->pushMatrix();
|
MV->pushMatrix();
|
||||||
|
MV->translate(((1 - alpha)*p0 + alpha*p1) - center);
|
||||||
|
MV->multMatrix(R3);
|
||||||
glUniformMatrix4fv(progNormal->getUniform("MV"), 1, GL_FALSE, glm::value_ptr(MV->topMatrix()));
|
glUniformMatrix4fv(progNormal->getUniform("MV"), 1, GL_FALSE, glm::value_ptr(MV->topMatrix()));
|
||||||
MV->popMatrix();
|
MV->popMatrix();
|
||||||
bunny->draw(progNormal);
|
bunny->draw(progNormal);
|
||||||
|
|
Reference in a new issue