Hierarchical Transformation
SimpleCar
9797097777.cppSimpleRobot9161556913.cppSimpleSolar1208850020.cpp
//main.cpp ———————————————-
SimpleCar* car;
SimpleSolar* solar;
SimpleRobot* robot;
void init()
{
// 중간생략
car = new SimpleCar();
robot = new SimpleRobot();
solar = new SimpleSolar();
}
void display()
{
// 중간생략
MVP = Projection * View * World;
car->draw(&spMain, MVP);
solar->draw(&spMain, MVP);
robot->draw(&spMain, MVP);
}
void update()
{
// 중간생략
car->update((float)deltaTime);
robot->update((float)deltaTime);
solar->update((float)deltaTime);
glutPostRedisplay();
}
void specialkey(int key, int x, int y )
{
switch (key)
{
case GLUT_KEY_LEFT:
robot->setTheta(g_theta-=10.0f);
break;
case GLUT_KEY_RIGHT:
robot->setTheta(g_theta+=10.0f);
break;
// 중간생략
}
glutPostRedisplay();
}