I’m following the tutorials but have problems with https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_main_event_loop
Exercise “Can you create two Geometries next to each other, and make one rotate twice as fast as the other? (use the tpf variable)”
I have created a second box but when I try to rotate it it rotates around zero instead of its own axle. Giving a impression of it orbiting around the first box.
How do I make it rotate around its own axle instead?
post your code
@rasmuseneman said:
I'm following the tutorials but have problems with https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_main_event_loop
Exercise "Can you create two Geometries next to each other, and make one rotate twice as fast as the other? (use the tpf variable)"
I have created a second box but when I try to rotate it it rotates around zero instead of its own axle. Giving a impression of it orbiting around the first box.
How do I make it rotate around its own axle instead?
Without code, just a wild guess:
you've changed the center of the Box mesh instead of the center of the geometry. Do not change the center of the box mesh... leave it at 0,0,0. Move the geometry instead.
I did:
[java]Box b2 = new Box(new Vector3f(3,0,0), 1, 1, 1);
player2 = new Geometry(“green cube”, b2);
Material mat2 = new Material(assetManager,
“Common/MatDefs/Misc/Unshaded.j3md”);
mat2.setColor(“Color”, ColorRGBA.Green);
player2.setMaterial(mat2);
rootNode.attachChild(player2);[/java]
Is it [java] player2.setLocalTranslation(3, 0, 0);[/java]
I shall use to change the center of the geometry?
It did work but, I don’t know if it were the “correct” way
You’ve put the triangles of your box relative to 3,0,0:
Box b2 = new Box(new Vector3f(3,0,0), 1, 1, 1);
But the object (the Geometry) is still at 0,0,0. So when you rotate it then it will rotate around 0,0,0.
Do what I said in the last post and it will fix things.
You also might consider reading:
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies
But the object (the Geometry) is still at 0,0,0. So when you rotate it then it will rotate around 0,0,0.
Yeah I got that and it was therefore I did [java]player2.setLocalTranslation(3, 0, 0);[/java] instead
Thanks for the slide, it were very informative and thanks for helping a newbie.