Return to previous page | Return to menu | Go to next page


Move object

The library function “slTranslate” is used to move objects in the space with SGL.
By substituting the movement amount for each axis of XYZ from the local point as a parameter, the object can be displayed at any coordinates in 3D space.

[void slTranslate (FIXED tx, ty, tz);] The
object is moved to the specified coordinates and displayed.
For the parameter, substitute the movement amount for each axis of XYZ from the defined coordinates or the local point.

Listing 4-4 ​​below uses the library function “slTranslate” to achieve translation parallel to the X axis. Sin value is used to control the movement parameter. The change of the angle value tmp controls the change of the X coordinate value.
Translation by “slTranslate” is expressed by the following formula.

List 4-4 sample_4_3_3: Square polygon translation routine

Flow 4-3 sample_4_3_3: Square polygon parallel movement flowchart


Return to previous page | Return to menu | Go to next page