Moving Coordinate Systems

This section covers how to move coordinate systems.

The movement discussed here is based on the axes of the parent coordinate system. Movement relative to the coordinate system's own axes will be covered in the next section, "Walking Coordinate Systems".

- Table of Contents -

Moving a Coordinate System

To move a coordinate system, use the moveCoordinate(...) function.

- Function Format -

int moveCoordinate (
  int coordinateID,
  float dx, float dy, float dz
)

Arguments:

Example Program

Let's try creating a local coordinate system, placing it on top of the world coordinate system, and then moving it. To make the difference clearer, we'll place a small axis model on the local coordinate system, and a large one on the world coordinate system.

To help illustrate the difference between this and "walking" (covered in the next section), we'll first rotate the local coordinate system slightly around the Z-axis before moving it.

Try running 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 a local coordinate system
	int coord = newCoordinate( );

	// Mount the local coordinate system onto the world coordinate system
	mountCoordinate( coord, rendererID );

	// Rotate the local coordinate system slightly around the Z-axis
	rotCoordinateZ( coord, 0.3 );

	// Move the local coordinate system
	moveCoordinate( coord, 1.0, 0.0, 0.0 );

	// Place a small axis model on the local coordinate system
	int axis1 = newAxisModel( 1.5, 1.5, 1.5 );
	mountModel( axis1, rendererID, coord );

	// Place a large axis model on the world coordinate system
	int axis2 = newAxisModel( 3.0, 3.0, 3.0 );
	mountModel( axis2, rendererID );
}
Sample.vcssl

When you run this program, two axis models appear on a black screen. The larger one is placed on the world coordinate system, and the smaller one is placed on the local coordinate system.

The local coordinate system is displayed at a position offset by (1.0, 0.0, 0.0) -- as seen from the parent coordinate system's axes.

Execution Result
Execution Result
The small one appears slightly shifted in the direction of the X-axis of the larger one.