Help!
I’m looking for a way to get a rotation value that is linearly proportional to the spatial’s actual rotation (without having to tack on some extra trigonometry every time.) I am new to the SDK so forgive me if I’ve missed something. This code sample should explain it. From the comments:
//Watch the output. Notice that the delta (right column) which should remain constant,
//does not. It changes sinusoidally from ~.05 to ~0.0 as it reaches the
//max angular deflection of 1.0/-1.0
Thank you. -Andrew
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.input.ChaseCamera;
import com.jme3.material.Material;
import com.jme3.math.;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.;
import com.jme3.scene.shape.Cylinder;
public class Main extends SimpleApplication {
Cylinder c;
Geometry geom;
float temp = 0;
public static void main(String[] args) {
Main app = new Main();
app.start();
}
public void simpleInitApp() {
c = new Cylinder(11,11,1,.1f,5,true,false);
geom = new Geometry("Cyclinder", c);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
geom.setMaterial(mat);
rootNode.attachChild(geom);
flyCam.setEnabled(false);
ChaseCamera chaseCam = new ChaseCamera(cam,geom,inputManager);
chaseCam.setInvertVerticalAxis(true);
}
//Watch the output. Notice that the delta (right column) which should remain constant,
//does not. It changes sinusoidally from ~.05 to ~0.0 as it reaches the
//max angular deflection of 1.0/-1.0
public void simpleUpdate(float tpf) {
geom.rotate(0, .1f, 0);
try {Thread.sleep(1000);} catch (InterruptedException ex) {}
float newAngle = geom.getWorldRotation().getY();
float delta = newAngle-temp;
System.out.println(newAngle+"\t"+delta);
temp = newAngle;
}
}