Hi… I'm having a hard time setting up my camera…
import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.scene.CameraNode;
import com.jme.scene.Node;
import com.jme.scene.Spatial;
import com.jme.scene.shape.Box;
public class cameraRotationTrial extends SimpleGame {
private CameraNode box1;
private Node pivotNode;
public static void main(String args[]){
cameraRotationTrial app = new cameraRotationTrial();
app.setConfigShowMode(ConfigShowMode.AlwaysShow);
app.start();
}
protected void simpleInitGame(){
pivotNode = new Node();
Box box3 = new Box("box3",new Vector3f(0,0,0),1,1,1);
box3.setModelBound(new BoundingBox());
box3.setRandomColors();
box3.setLightCombineMode( Spatial.LightCombineMode.Off );
box3.updateModelBound();
box3.updateRenderState();
rootNode.attachChild(box3);
box1 = new CameraNode("CamNode",cam);
box1.setLocalTranslation(new Vector3f(0,0,-10));
box1.setModelBound(new BoundingBox());
box1.updateModelBound();
pivotNode.attachChild(box1);
pivotNode.updateRenderState();
Box box2 = new Box("box2", new Vector3f(0,0,10),1,1,1);
box2.setModelBound(new BoundingBox());
box2.updateModelBound();
pivotNode.attachChild(box2);
pivotNode.updateRenderState();
pivotNode.setLocalRotation(new Quaternion().fromAngleAxis(45 * FastMath.DEG_TO_RAD, new Vector3f(1,1,0)));
rootNode.attachChild(pivotNode);
rootNode.updateRenderState();
}
}
Here's my code... what this actually does is create a Camera node positioned Vector3f(0,0,10) and an imaginary box positioned opposite to it Vector3f(0,0,-10)... and then I put them into 1 node named pivotNode to ensure that my axis where the camera would orbit is the middle of the screen or Vector3f(0,0,0).... and then at this position I have put a Box which would be the subject of my camera...
the last of the code
pivotNode.setLocalRotation(new Quaternion().fromAngleAxis(45 * FastMath.DEG_TO_RAD, new Vector3f(1,1,0)));
does a rotation of the pivotNode, where the camera is included, with both 45 degrees pointing the camera to the NorthWest vertex of the box in the middle... my problem is what if I would want to rotate the pivotNode 45 degrees with regards to Vector3f.UNIT_X but 90 degrees with regards to Vector3f.UNIT_Y which would make the camera point to the Northwest side of the box in the middle
please help