Waypoint and Rotation
Hi,l
i like to move a Triangle from one waypoint to another, the triangle must allways 'face' in the direction they move.but my prog dont work :-(.
here my code:
CVector CalculateVelocity(CVector position, CVector next_waypoint)
{
CVector tmp;
tmp=next_waypoint-position;
tmp.Normalize();
direction = RAD2DEG(tmp.Angle(CVector(0,0,-1)));
return tmp;
}
render:
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glRotatef(-direction, 0.0, 1.0, 0.0);
glBegin(GL_TRIANGLES);
glColor3f(0.0f, 1.0f, 0.0f);glVertex3f(-1.0f, 0.0f, 0.0f);
glColor3f(1.0f, 0.0f, 0.0f);glVertex3f(0.0f, 0.0f, -1.0f);
glColor3f(0.0f, 0.0f, 1.0f);glVertex3f(1.0f, 0.0f, 0.0f);
glEnd();
glPopMatrix();
speed = 1.0f * timeElapsed;
position+=velocity*speed;
You can download the prog here
prima-tech.de/tmp/way.zip
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement