Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void renderScene() {
- // ...
- //trimesh.draw();
- // get time passed
- system_clock::duration t = system_clock::now() - startTime;
- // bonus (make objects move)
- switch (modelType) {
- case ModelType::DELPHIN:
- // swim like a delphin
- glRotatef(t.count() * 0.00001, 1, 0, 0);
- glTranslatef(0, 2, 5);
- trimesh.draw();
- val += 0.01f;
- break;
- case ModelType::BRACH:
- // swim around the y-axis
- glRotatef(t.count() * 0.00001, 0, 1, 0);
- glTranslatef(0, 0, -5);
- glRotatef(-90, 0, 1, 0);
- glTranslatef(0, 0, 5);
- trimesh.draw();
- break;
- case ModelType::BALLON:
- // fly up, land, fly up again
- glTranslatef(0, 5 + cos(t.count() * 0.0000001) * 5, 0);
- trimesh.draw();
- break;
- case ModelType::FORD:
- // appear disappear
- glTranslatef(sin(t.count() * 0.00000001) * 5, 3.5f, tan(t.count() * 0.0000001) * 2);
- glRotatef(180, 0, 1, 0); // 3. rotate around y-axis (so that car looks in our direction)
- glRotatef(-90, 1, 0, 0); // 2. rotate around x-axis (so that car stands on wheels)
- glTranslatef(0, 0, 2); // 1. translate to origin
- trimesh.draw();
- break;
- case NONE:
- default:
- //std::cout << "Unknown model type -- do a normal draw() call" << std::endl;
- trimesh.draw();
- break;
- }
- // swap buffers
- glutSwapBuffers();
- // force rendering
- glutPostRedisplay();
- }
Advertisement
Add Comment
Please, Sign In to add comment