128 CHAPTER 4: Turning On the Lights^
To Planet.m add the following initialization code at the very end of the init() method:
m_Angle=0.0;
m_RotationalIncrement=0.0;
m_Pos[0]=0.0;
m_Pos[1]=0.0;
m_Pos[2]=0.0;
And after the execute method, add the code in Listing 4-11, defining the new methods.
Listing 4-11. Modifications to Planet.m
-(void)getPositionX:(GLfloat *)x Y:(GLfloat *)y Z:(GLfloat *)z
{
*x=m_Pos[0];
*y=m_Pos[1];
*z=m_Pos[2];
}
-(void)setPositionX:(GLfloat)x Y:(GLfloat)y Z:(GLfloat)z
{
m_Pos[0]=x;
m_Pos[1]=y;
m_Pos[2]=z;
}
-(GLfloat)getRotation
{
return m_Angle;
}
-(void)setRotation:(GLfloat)angle
{
m_Angle=angle;
}
-(void)incrementRotation
{
m_Angle+=m_RotationalIncrement;
}
-(GLfloat)getRotationalIncrement
{
return m_RotationalIncrement;
}
-(void)setRotationalIncrement:(GLfloat)inc
{
m_RotationalIncrement=inc;
}