Wednesday, 10 August 2011

Moving the object

A simple update to the last post, how to add some movement to the object. Simple rotations are very easy to achieve by adding a rotation vector to the render() method after we have translated the position, but before we can do this we need a way to update the object when the drawing is complete, for this we can use the Application.Idle event. Create a float variable for the rotation, add this just before the public Form1() method. Create a new method for the Application.idle event wit the following syntax to update the rotation every time the application is idle, depending on the speed of your processor you may need to adjust the amount that you add onto the rotation each time. Modify the glControl1_Load() method to include the following: And also make the following modification to the render() method to include the rotation, for this example I am just rotating around the objects X, but this can be used to rotate around the Vector3.UnitY or vector3.UnitZ all all 3 with some simple changes. That's it very simple rotation of the cube with just a few very simple changes. Next we are going to add a texture to the cube.

No comments:

Post a Comment