Japanese | English | Korean

Samples

Projection methods

Let's take a look at projection methods.
Two projection methods, parallel projection and perspective projection are available in MascotCapsule.

Table of contents






1. Parallel projection

Parallel projection is a projection method that projects the objects in the world as they are, onto the display screen. In parallel projection, the view volume in camera coordinate system is a rectangular solid. Therefore, the same-sized objects are projected in a same size, regardless of the distances of object positions from the camera. Also in parallel projection, the fixed distance from the camera to the near clipping plane is 0, and to the far clipping plane is 32767.

Use the setParallelSize( int width, int height ) method in the FigureLayout class to specify the parallel projection setting. In this method, width represents the projection plane's width, and height represents the projection plane's height, respectively.


Parallel projection



2. Perspective projection

In perspective projection, the view volume in camera coordinate system is a frustum (truncated pyramid). It is a projection method where perspective is conveyed through rendering the objects in the world larger when they are closer to the camera, and smaller when they are distant from the camera.

Use the setPerspective( int zNear, int zFar, int angle ) method in the FigureLayout class to specify the perspective projection setting. In this method, zNear represents the distance between the camera and near clipping plane, and zFar represents the distance between the camera and far clipping plane, respectively; and angle represents the angle of view. Only the objects or portions of objects inside the view frustum specified by these 3 variables will be rendered onto the display screen. Also, the view volume can be specified by providing the projection plane's width and height on the near clipping plane, instead of specifying the angle of view. In such cases, specify setPerspective( int zNear, int zFar, int width, int height ).

In perspective projection, rendering accuracy depends on the distance between the near clipping plane and far clipping plane. Rendering accuracy increases when this distance is smaller. Also, when the near clipping plane value is extremely small, rendering accuracy may decrease because the number of significant figures decreases. Therefore, it is recommended to specify a larger value (1.0 or larger) for the near clipping plane.


Perspective projection


3. Sample code

The following is the code that switches the projection method in the sample program.
The projection method is switched when the soft key is pressed.

/**
  * commandAction() method
  * Process when the soft key is pressed-down (changing the rendering parameter)
  */
public void commandAction( Command c, Displayable d ){
String label = c.getLabel();

/* Changing the projection method */
if( label.equals( commandLabels[ 0 ] ) ){
layout.setPerspective( 1024, 10000, 4096 * 30 / 360 );
}else if( label.equals( commandLabels[ 1 ] ) ){
layout.setParallelSize(
getWidth() * 4 , getHeight() * 4 );
}
}