Multiple Camera views

Hello Community.



I want to program small sensors which observe the scene. Each Sensor shell have a com.jme3.renderer.Camera as field

I want to do a main camera view with all these sensor-cameras inside. This is my code (analoguosly to the tutorial):



[java]

public void setCamera(float x1, float x2, float y1, float y2){

this.sensorCam = new Camera(100,100);

this.sensorCam.setViewPort(x1, x2, y1, y2);

this.sensorCam.setLocation(position); //position is a 3fVector



Quaternion quaternion = new Quaternion();

quaternion.fromAngleAxis(FastMath.PI/2.0f, this.orientation); //orientation is a 3fVector

this.sensorCam.setRotation(quaternion);



ViewPort view = this.se.getRenderManager().createMainView(this.toString(), sensorCam); //se is a (extended) “SimpleApplication”

view.setClearFlags(true, true, true);

view.attachScene(this.se.getRootNode()); //getRootNode returns the rootNode of the game

}[/java]



The calls are inside the “simpleInitApp()” method These are the calls:

[java] sensor1.setCamera(0.8f, 1f, 0.8f, 1f);

sensor2.setCamera(0.8f, 1f, 0.5f, 0.7f);

sensor3.setCamera(0.8f, 1f, 0.2f, 0.4f);[/java]



The main view works and the viewports are inside at the right positions but the cameras are not working. They’re all black. Does anyone have an idea how to fix that? They’re also black when I change the position and orientation of the cameras…

fixed

For all people who have same problems.

  • now I create a new cam by cloning another… I dont think that this has fixed the problem
  • I now use the “lookAt” funktion.



    [java]

    this.sensorCam = se.getCamera().clone();

    this.sensorCam.setViewPort(x1, x2, y1, y2);

    this.sensorCam.setLocation(position); //position is a 3fVector



    this.sensorCam.lookAt(position.add(orientation), new Vector3f(0,1,0));



    ViewPort view = this.se.getRenderManager().createMainView(this.toString(), sensorCam); //se is a (extended) “SimpleApplication”

    view.setClearFlags(true, true, true);

    view.attachScene(this.se.getRootNode()); //getRootNode returns the rootNode of the game

    [/java]


  • In my code “position” is a Vector3f which should represent the absolute coordinate of the cameraposition in space
  • orientation is the direction in which the camera shell look. The orientation is a Vector3f RELATIVELY to “position”
  • The lookAt-methods needs an ABSOLUTE orientation point… so just add the ABSOLUTE position-point and the RELATIVE orientation point to get the ABSOLUTE orientation point
  • this is the easiest way to set the direction of the camera which I have found… so far, i wouldnt spent to much time for looking at the “Quaternions”



    I still does not understand what quaternions do… does “setRotation(Quaternion)” perform an ABSOLUTE camera movement or a movement relatively to the previous position?

Quaternions are a way of representing a direction in a way which allows linear interpolation.



the setRotation(Quaternion) methods does a ABSOLUTE setting of the direction/rotation.