Hierarchical Transformation
SimpleCar
SimpleRobot
6981026919.cpp
SimpleSolar
//main.cpp ———————————————-
SimpleCar* car;
SimpleSolar* solar;
SimpleRobot* robot;
SimpleMobile* mobile;
void init()
{
// 중간생략
car = new SimpleCar();
robot = new SimpleRobot();
solar = new SimpleSolar();
mobile = new SimpleMobile();
}
void display()
{
// 중간생략
car->draw(&spMain, Projection, View, World);
robot->draw(&spMain, Projection, View, World);
solar->draw(&spMain, Projection, View, World);
mobile->draw(&spMain, Projection, View, World);
}
void update()
{
// 중간생략
car->update((float)deltaTime);
robot->update((float)deltaTime);
solar->update((float)deltaTime);
mobile->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();
}