Rotation and scaling are two separate operations but since both are fairly simple they will be combined into the same lesson.
Rotation:
To rotate the entire scene you can use a call to glRotate which has four parameters:
CALL glRotatef amt , X , Y , Z
The first parameter "amt" is the degrees of rotation you want to apply. The remaining three are used to specify which axis you want to rotate the scene around. Only one axis can be rotated at a time. Typically you will have three variables to keep track of each axis and then use a block of code such as this in your drawing routine:
In the following snippet uncomment one rotation variable at a time to see the triangle rotate around each of the axis’s. Or, uncomment all of them to see it go crazy.
OpenGL has a handy function for scaling the entire scene, glScalef.
CALL glScalef X , Y , Z
With this function you can expand or shrink the entire scene (actually the 3D matrix) along any or all of the three axis’s. If a value is set to 1, that axis will not be changed. Here we have the same old triangle but it has been expanded along the X axis and shrunk along the Y axis.
OpenGL 3D Graphics in Liberty BASIC
Lesson Three: Rotation and Scaling
by Robert McAllisterRotation and scaling are two separate operations but since both are fairly simple they will be combined into the same lesson.
Rotation:
To rotate the entire scene you can use a call to glRotate which has four parameters:CALL glRotatef amt , X , Y , ZThe first parameter "amt" is the degrees of rotation you want to apply. The remaining three are used to specify which axis you want to rotate the scene around. Only one axis can be rotated at a time. Typically you will have three variables to keep track of each axis and then use a block of code such as this in your drawing routine:In the following snippet uncomment one rotation variable at a time to see the triangle rotate around each of the axis’s. Or, uncomment all of them to see it go crazy.
You can also rotate an individual object using a little trigonometry.
Scaling:
OpenGL has a handy function for scaling the entire scene, glScalef.CALL glScalef X , Y , ZWith this function you can expand or shrink the entire scene (actually the 3D matrix) along any or all of the three axis’s. If a value is set to 1, that axis will not be changed. Here we have the same old triangle but it has been expanded along the X axis and shrunk along the Y axis.Scaling can also be accomplished with a scale factor. This can come in handy if you only want to change the size of one object in a scene.
In the next lesson we will learn what "Display lists" are.