RenderWare V2.1

Previous Page Index Next Page

Coordinate Systems


RenderWare recognizes the following coordinate systems:

· Object Space

Each clump has a local coordinate system (or Object Space). This is the coordinate system in which geometry being added to a clump is specified. For example:

RwAddVertexToClump(Clump, 1.0, 1.0, 1.0);

adds a new vertex to Clump at (1.0, 1.0, 1.0) in the clump’s object space.

When constructing geometry using a script file or RenderWare’s "Object Builder" API functions, the coordinates specified are transformed by the current transform matrix (CTM) before being added to the clump.

· World Space

The coordinate system of a scene is known as the world coordinate system (or World Space). This is the coordinate system that is used for specifying the positions of lights and cameras.

RenderWare uses a right-handed world coordinate system. This has the same orientation as that given by taking the thumb, first and second fingers of your right hand as the X, Y and Z axes respectively. The positive X axis points to the right, the positive Y axis points up, whilst the positive Z axis points forwards (out of the screen).

· Camera Space

Each camera has a viewing coordinate system (or Camera Space). Camera space has its origin at the camera’s position. The positive Z axis of camera space is given by the view direction (or "Look At" vector). Unlike world space, camera space is left-handed. The units of camera space are the same as those of world space.

Camera space is primarily used in the API function RwVCMoveCamera() which moves the camera a certain number of units left, right, up, down, forwards or backwards relative to the current camera position.

· Device Space

The device coordinate system (or Device Space) is a two dimensional coordinate system. Its units are those of the display (screen or window) to which the camera’s image buffer is copied when RwShowCameraImage() is called. Device space is primarily used for specifying the position and extent of camera viewports. Device space is closely related to viewport space as described below.

· Viewport Space

The coordinate system of a camera’s viewport is the viewport coordinate system (or Viewport Space). Viewport space is used when picking, when damaging or undamaging the camera’s viewport, when specifying a portion of the viewport into which a backdrop should be copied and when rendering user-draws. The units of viewport space are the same as those of device space. The terms device space units and viewport space units will be used interchangeably throughout this document.

To convert a point in device space to the viewport space of a camera, simply subtract the X and Y coordinates of the camera’s viewport from the X and Y coordinates of the point. This conversion is often useful when attempting to pick an object under the mouse pointer. The mouse position will normally be returned to the application in device (screen or window) coordinates. However, viewport coordinates are needed for the pick operation and so the above conversion should be performed. This conversion is not necessary if the viewport’s origin is the same as the origin of device space (as is often the case).