This section covers how to scale (enlarge or shrink) models and polygons.
To scale a model, use the scaleModel(...) function.
- Function Format -
Arguments:
To scale a polygon, use the scalePolygon(...) function.
- Function Format -
Arguments:
Let's place a sphere model and stretch it by a factor of 2 along the Z-axis. Write and run the following code:
import graphics3d.Graphics3DFramework;
import Graphics3D;
// Function called at the start of the program
void onStart ( int rendererID ) {
// Optional: Set window size and background color
setWindowSize( 800, 600 );
setBackgroundColor( 0, 0, 0, 255 );
// Create and place an axis model
int axis = newAxisModel( 3.0, 3.0, 3.0 );
mountModel( axis, rendererID );
// Create and place a sphere model
int sphere = newSphereModel( 1.0, 1.0, 1.0, 10, 7 );
mountModel( sphere, rendererID );
// Stretch the sphere 2x in the Z direction
scaleModel( sphere, 1.0, 1.0, 2.0 );
}
Sample.vcssl
When you run this program, a white sphere will appear on a black background. The sphere is stretched 2x in the Z direction.