Completed Lab 12.
This commit is contained in:
parent
c11fbbb5b0
commit
389c47b8b8
1 changed files with 15 additions and 5 deletions
|
@ -213,21 +213,31 @@ void render()
|
|||
// left: use p0 for position and q0 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
|
||||
MV->pushMatrix();
|
||||
glUniformMatrix4fv(progNormal->getUniform("MV"), 1, GL_FALSE, glm::value_ptr(MV->topMatrix()));
|
||||
MV->popMatrix();
|
||||
MV->translate(p0 - center);
|
||||
MV->multMatrix(R1);
|
||||
glUniformMatrix4fv(progNormal->getUniform("MV"), 1, GL_FALSE, glm::value_ptr(MV->topMatrix()));
|
||||
MV->popMatrix();
|
||||
bunny->draw(progNormal);
|
||||
|
||||
// RIGHT
|
||||
MV->pushMatrix();
|
||||
glUniformMatrix4fv(progNormal->getUniform("MV"), 1, GL_FALSE, glm::value_ptr(MV->topMatrix()));
|
||||
MV->translate(p1 - center);
|
||||
MV->multMatrix(R2);
|
||||
glUniformMatrix4fv(progNormal->getUniform("MV"), 1, GL_FALSE, glm::value_ptr(MV->topMatrix()));
|
||||
MV->popMatrix();
|
||||
bunny->draw(progNormal);
|
||||
bunny->draw(progNormal);
|
||||
|
||||
// INTERPOLATED
|
||||
MV->pushMatrix();
|
||||
glUniformMatrix4fv(progNormal->getUniform("MV"), 1, GL_FALSE, glm::value_ptr(MV->topMatrix()));
|
||||
MV->translate(((1 - alpha)*p0 + alpha*p1) - center);
|
||||
MV->multMatrix(R3);
|
||||
glUniformMatrix4fv(progNormal->getUniform("MV"), 1, GL_FALSE, glm::value_ptr(MV->topMatrix()));
|
||||
MV->popMatrix();
|
||||
bunny->draw(progNormal);
|
||||
|
||||
|
|
Reference in a new issue