Got confused in cam frustum parameters~

er~ newbie has a new question :>)


I can understand far near as float format (simple distance) but What are meaning for the rest ?
I mean I’v googled the explanation of frustum , and I understand what are top,bottom,left,right plans.
but WHY in float ? and how to calculate these numbers ?

The answers to your questions are here:

They are floats because they express distances.
I.E. frustumRight is the distance from camera to right frustum plane.
For starters you will only need to use setFrustumFar.
But If you feel curious enough try setting the other frustums,one by one,and make your own observations.

1 Like

I’ve been using JME for many many years now and never once have I needed to do this.

What is it that you are actually trying to do?

i mostly use:

 * <code>setFrustumPerspective</code> defines the frustum for the camera.  This
 * frustum is defined by a viewing angle, aspect ratio, and near/far planes
 * @param fovY   Frame of view angle along the Y in degrees.
 * @param aspect Width:Height ratio
 * @param near   Near view plane distance
 * @param far    Far view plane distance
public void setFrustumPerspective(float fovY, float aspect, float near, float far)

i call it with:

float fov = 45;
float near = 250.0f;
float far = 100000f;
float aspect = (float) cam.getWidth() / cam.getHeight();
cam.setFrustumPerspective(fov, aspect, near, far);

if you inspect the method you can see how the values you have asked for are calculated and set.

1 Like

Well, actually I’m thinking about TWO functions:
If you guys ever played Paper Mario on WII , you may understand the necessity of switch between 3D and 2D.
I’m thinking a first person shooting game to be played like SFC contra :smiley:
For 2D here, it doesn’t mean just move the cam to the top and look down, you still have 3D effects.
I have to set cam to parallel mode( I think :slight_smile: ) and calculate the distance and on-screen size, thus a frustums parameters must be calculated and set.
Thinking abut 3D display (not VR or AR). To convert one 16:9 cam to a side-by-side 3D display, I need 2 8:9 cam each with a compressed 16:9 picture. (er ~ Do I explain clearly ?:laughing: ) How to set these parameters?

Note that for #1, the frustum is far, far simpler than for a perspective camera. All you need to do is set the camera to parallel mode and set the width/height appropriately. FoV angles and all that other jazz is irrelevant to a parallel camera. For #2 I can’t answer how you’d set up such a viewport off the top of my head.

For the first function you could use:

cam.setLocation(Vector3f.UNIT_Y);        //Top-Down View
//cam.setLocation(Vector3f.UNIT_Z);      //Side-Scroller View
Node characterNode=(Node) assetManager.loadModel("Models/Orc/Orc.j3o");
Quaternion quaternion=new Quaternion().fromAngleAxis(FastMath.PI/2,UNIT_Y);
characterNode.setLocalRotation(quaternion.inverse() );        //Top-Down View
//characterNode.setLocalRotation(quaternion);                 //Side-Scroller View

This is what you get for the Top-Down View:

And for the Side-Scroller View

You might also want to read the following topics:

1 Like


This method is used only for parallel projection. A plane can be defined by a normal vector and a constant. The constant is the shortest distance from the origin to the plane.
In the case of the frustum we know the normal, so we only need the distances to the planes.
That’s what those params are.

Use setfrustumPerspective if you don’t want parallel projection.

Thank you, nehon.

many many thanks Damien_M