PDA

View Full Version : Having a object move around the origin



Slong
11-15-2009, 09:08 PM
i drew a robot but i cant figure out how to make him "walk" around the origin. i know i need to use the gluttimerfunc to control the walking but not sure how to make the robot walk... figured rotation and translations are the only way but where do i start? ideas or examples would be nice i can post code if needed

marshats
11-17-2009, 05:37 PM
If you are asking about how to animate with glutTimer a previous post here (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=265986#Post2659 86) may help.

You would have to replace the display of the rectangle with your robot drawing and You would then put just after your first glPushMatrix for the robot draw code some code that responds to the changing gAngle value (in display()):


<your first glPushMAtrix>
glRotatef(gAngle,0.,0.,1.); //assuming you want to spin about the z-axis
glTranslate3f(radius,0,0);
<insert rest of your robot draw code>