Trying to Understand setLocalTranslation

I’ve looked at forums, and can’t figure out how the tutorial is working.

Specifically, the hellophysics java tutorial:

http://www.hub.jmonkeyengine.org/wiki/doku.php/jme3:beginner:hello_physics?s[]=hellophysics



There is a loop that places the bricks:

for (int j = 0; j < 15; j++) {

for (int i = 0; i < 4; i++) {

Vector3f vt = new Vector3f(i * brickLength * 2 + startpt, brickHeight + height, 0);

makeBrick(vt);

}

startpt = -startpt;

height += 2 * brickHeight;

}



Then in makeBrick:



public void makeBrick(Vector3f ori) {

/** create a new brick /

Geometry box_geo = new Geometry(“brick”, brick);

box_geo.setMaterial(wall_mat);

PhysicsNode brickNode = new PhysicsNode(

box_geo, // geometry

boxCollisionShape, // collision shape

0.001f); // mass

/
* position the brick and activate shadows */

brickNode.setLocalTranslation(ori);

//brickNode.setShadowMode(ShadowMode.CastAndReceive);

rootNode.attachChild(brickNode);

getPhysicsSpace().add(brickNode);

}





Doesn’t setlocaltranslation work in X,Y,Z? The code implies (length, height, 0), which would seem to me to scatter the bricks across the floor, not stacked on top of each other.

The Y coordinate is actually height (goes up) while the Z coordinate is depth (goes into). That’s why they are stacked and not laid on the floor.

Yeah, +x is right, +y is up and +z is towards you. That means jme has a “right handed” coordinate system.

Okay. That all makes sense.

At the very beginning of the game, the bricks slide along the floor, like they either collided with each other, or collided with the floor. The placement math is such that the floor and brick share the same surface. How do I get the bricks to initialize at the exact location that I specify?

They dont slide, they just fall down a bit. That it seems to be sliding is a visual bug and has to do with the shadows and how they initialize.