In jmonkey I have seen their first tutorial, it was moving a box on mouse movement, out of curiosity and as for playing with this new toy I have tried to move a Sphere using mouse movement. Since the functionality is almost same I have replaced Box with Sphere.
public void simpleInitApp() {
//Box b = new Box(Vector3f.ZERO, 1, 1, 1); //example
//Geometry geom = new Geometry("Box", b); //example
Sphere b = new Sphere(1,2,3, true,true);//(Vector3f.ZERO, 1, 1, 1);
Geometry geom = new Geometry("Sphere", b);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
geom.setMaterial(mat);
rootNode.attachChild(geom);
}
But it compile but does not work, it returns following run time error on that line where I have created an instance of Sphere:
java.lang.IllegalArgumentException: Negative capacity: -12
at java.nio.Buffer.<init>(Buffer.java:191)
at java.nio.ByteBuffer.<init>(ByteBuffer.java:276)
at java.nio.ByteBuffer.<init>(ByteBuffer.java:284)
at java.nio.MappedByteBuffer.<init>(MappedByteBuffer.java:89)
at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:118)
at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:306)
at com.jme3.util.BufferUtils.createFloatBuffer(BufferUtils.java:831)
at com.jme3.util.BufferUtils.createVector3Buffer(BufferUtils.java:252)
at com.jme3.scene.shape.Sphere.setGeometryData(Sphere.java:150)
at com.jme3.scene.shape.Sphere.updateGeometry(Sphere.java:395)
at com.jme3.scene.shape.Sphere.<init>(Sphere.java:121)
at mygame.Main.simpleInitApp(Main.java:27)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:225)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:722)
Jun 11, 2013 12:10:31 AM com.jme3.renderer.lwjgl.LwjglRenderer cleanup
INFO: Deleting objects and invalidating state
Jun 11, 2013 12:10:31 AM com.jme3.input.lwjgl.LwjglMouseInput destroy
INFO: Mouse destroyed.
Jun 11, 2013 12:10:31 AM com.jme3.input.lwjgl.LwjglKeyInput destroy
INFO: Keyboard destroyed.
Jun 11, 2013 12:10:31 AM com.jme3.system.lwjgl.LwjglAbstractDisplay deinitInThread
INFO: Display destroyed.
what can be done?