
And how do I say that in Java?
Imagine an arrow pointing from the origin to an X-Y-Z coordinate. This arrow is called a vector. You will be using vectors to represent locations. Since a vector always starts at the origin, and the arrow points in the direction of the given (x,y,z) coordinates, a vector can also be used to specify a direction. Quite useful!
In your Java code, you use the com.jme3.math.Vector3f
class for this data type. A Vector3f
is an object with three float components, x
, y
, and z
. For example:
Vector3f v = new Vector3f( 2.0f , 3.0f , -4.0f );
Remember when we created the blue cube earlier and placed it in the middle of the scene? We positioned it at the location Vector3f.ZERO
. This built-in constant stands for a Vector3f(0f,0f,0f)
. The (0,0,0) coordinates vector represents the origin of the coordinate system, the middle of the scene.
Now that you know how to orient yourself in 3D space, we can apply this knowledge and transform our blue cube; let's position, resize, and turn it. In terms of 3D graphics, we say that we translate, scale, and rotate the object. In the next three sections, we look at each of the three transformations in detail, and learn the appropriate Java syntax.