Hey everyone:
I am having trouble understanding how to rotate the camera.
I wrote this test code:
package jme3;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.scene.debug.Arrow;
public class CameraTest extends SimpleApplication {
@Override
public void simpleInitApp() {
Mesh m = new Arrow(Vector3f.UNIT_X);
Geometry geom = new Geometry("X",m);
geom.scale(20);
Material mat = new Material(assetManager,"Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Red);
geom.setMaterial(mat);
rootNode.attachChild(geom);
m = new Arrow(Vector3f.UNIT_Y);
geom = new Geometry("Y",m);
geom.scale(20);
mat = new Material(assetManager,"Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Green);
geom.setMaterial(mat);
rootNode.attachChild(geom);
m = new Arrow(Vector3f.UNIT_Z);
geom = new Geometry("Z",m);
geom.scale(20);
mat = new Material(assetManager,"Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
geom.setMaterial(mat);
rootNode.attachChild(geom);
cam.setLocation(new Vector3f(-10,-10,50));
cam.setRotation(new Quaternion().fromAngleAxis(1*FastMath.DEG_TO_RAD,Vector3f.UNIT_X));
}
public static void main(String[] args) {
CameraTest app = new CameraTest();
app.start();
}
}
If I don’t call cam.setRotation, I see this screen:
which makes sense to me.
If I call cam.setRotation, the screen becomes completely black. It should have only rotated 1 degree which should have been a very small change.
I must be misunderstanding something. I have searched the forum and read the pages about Quaternion, but it is not making sense to me.