|
|
@@ -149,7 +149,8 @@ What happens in the code snippet? You use the `simpleInitApp()` method that was
|
|
|
** Position the box at (1,-1,1) using the setLocalTranslation() method.
|
|
|
** Wrap the Box shape into a Geometry.
|
|
|
** Create a blue material.
|
|
|
-** Apply the blue material to the Box Geometry.
|
|
|
+** Apply the blue material to the Box Geometry.
|
|
|
++
|
|
|
[source,java]
|
|
|
----
|
|
|
|
|
|
@@ -163,11 +164,13 @@ What happens in the code snippet? You use the `simpleInitApp()` method that was
|
|
|
|
|
|
|
|
|
. You create a second box Geometry.
|
|
|
++
|
|
|
** Create a second Box shape with the same size.
|
|
|
** Position the second box at (1,3,1). This is straight above the first box, with a gap of 2 world units inbetween.
|
|
|
** Wrap the Box shape into a Geometry.
|
|
|
** Create a red material.
|
|
|
** Apply the red material to the Box Geometry.
|
|
|
++
|
|
|
[source,java]
|
|
|
----
|
|
|
|
|
|
@@ -182,37 +185,41 @@ What happens in the code snippet? You use the `simpleInitApp()` method that was
|
|
|
|
|
|
|
|
|
. You create a pivot Node.
|
|
|
++
|
|
|
** Name the Node “pivot.
|
|
|
** By default the Node is positioned at (0,0,0).
|
|
|
** Attach the Node to the rootNode.
|
|
|
** The Node has no visible appearance in the scene.
|
|
|
++
|
|
|
[source,java]
|
|
|
----
|
|
|
|
|
|
Node pivot = new Node("pivot");
|
|
|
rootNode.attachChild(pivot);
|
|
|
----
|
|
|
-
|
|
|
++
|
|
|
If you run the application with only the code up to here, the scene appears empty. This is because a Node is invisible, and you have not yet attached any visible Geometries to the rootNode.
|
|
|
|
|
|
|
|
|
. Attach the two boxes to the pivot node.
|
|
|
++
|
|
|
[source,java]
|
|
|
----
|
|
|
|
|
|
pivot.attachChild(blue);
|
|
|
pivot.attachChild(red);
|
|
|
----
|
|
|
-
|
|
|
++
|
|
|
If you run the app with only the code up to here, you see two cubes: A red cube straight above a blue cube.
|
|
|
|
|
|
. Rotate the pivot node.
|
|
|
++
|
|
|
[source,java]
|
|
|
----
|
|
|
pivot.rotate( 0.4f , 0.4f , 0.0f );
|
|
|
----
|
|
|
-
|
|
|
- If you run the app now, you see two boxes on top of each other – both tilted at the same angle.
|
|
|
++
|
|
|
+If you run the app now, you see two boxes on top of each other – both tilted at the same angle.
|
|
|
|
|
|
|
|
|
|
|
|
@@ -357,7 +364,7 @@ To roll an object 180° around the z axis:
|
|
|
thing.rotate( 0f , 0f , 180*FastMath.DEG_TO_RAD );
|
|
|
----
|
|
|
|
|
|
- Tip: If your game idea calls for a serious amount of rotations, it is worth looking into <<jme3/quaternion#,quaternion>>s, a data structure that can combine and store rotations efficiently.
|
|
|
+Tip: If your game idea calls for a serious amount of rotations, it is worth looking into <<jme3/quaternion#,quaternions>>, a data structure that can combine and store rotations efficiently.
|
|
|
|
|
|
[source,java]
|
|
|
----
|