Rotating nodes in simpleInitApp() does not work?

Hi again,

I’ve encountered another problem:
I am trying to write a procedural indoor level generator that dynamically creates simple level modules and places them adjacent to another, forming a random maze.

The problem that I have with that is, that I cannot rotate any Node that I created before or in the first update.
This is the code:

level module:
public class LevelModule extends Node {

private static final float w = 10f, h = 10f;
private LinkedList<LevelModuleConnector> connectors = new LinkedList<LevelModuleConnector>();
private Material wallMat, floorMat, ceilMat, debugMat;
private RigidBodyControl phys;

public LevelModule(AssetManager am) {
	[... init materials ...]
	addBlock(0f, 0f, w, w, WALL, NONE, NONE, NONE);
	//addBlock(w, 0f, w, w, CONN, WALL, NONE, WALL);
	addBlock(0f, -w, w, w, WALL, CONN, WALL, NONE);
	addBlock(-w, 0f, w, w, NONE, WALL, CONN, WALL);
	addBlock(0f, w, w, w, WALL, NONE, WALL, CONN);
	CollisionShape col = CollisionShapeFactory.createMeshShape(this);
	phys = new RigidBodyControl(col, 0f);

private enum Wall { wall, connect, none }
private static final Wall WALL = Wall.wall;
private static final Wall CONN = Wall.connect;
private static final Wall NONE = Wall.none;

private void addDebugMarker(LevelModuleConnector c){
	Box b = new Box(0.2f, 0.2f, 0.2f);
	Geometry g = new Geometry("conbox", b);

private void addConnector(Vector3f pos, Vector3f dir){
	LevelModuleConnector c = new LevelModuleConnector(this, pos, dir);

private void addBlock(float centerx, float centerz, float sizex, float sizez, 
		Wall weast, Wall wnorth, Wall wwest, Wall wsouth){
	[... creates a block with floor, ceiling and walls as quads wrapped in a geometry, adds them with this.attachChild(Geometry)  ...]

public void add(Node root, BulletAppState bullet){

public void remove(Node root, BulletAppState bullet){

public int getConnectorCount(){
	return connectors.size();


In simpleInitApp():
LevelModule m = new LevelModule(assetManager);
m.add(rootNode, bullet);
m.rotate(0, 1, 0); // this rotate has no effect on the actual rotation of m

in simpleUpdate(float tpf):
// b is a boolean initialized with true
b = false;
modules.getFirst().rotate(0, 1, 0); // this rotate does nothing either
// t is a float initialized with 0f
if(t < 2){
t += tpf;
if(t >= 2) modules.getFirst().rotate(0, 1, 0); // this rotate really rotates the module

Did I do something wrong? The tutorials all rotate nodes in simpleInitApp().

Thanks for your time <3

I’ve played a bit around with this and narrowed down the issue.
Any LevelModule that I create cannot be rotated or moved in the same update.
if I wait one update after I create the LevelModule and then rotate or move, it works.

This is kind of weird though, there has to be a way to rotate/move immediately after creation, right?

You have a physics control attached to the Node. And btw, extending Node is not good practice.

Oh, for some reason I thought that it is necessary to add the physics control to the node. thanks for the reply <3

Why is it bad practice to extend Node? If I dont do this I have to delegate the relevant methods of Node, which increases the size of the class, so I thought this would be the standard approach to this kind of problem :slight_smile:

Check our best practices document, one should generally prefer composition over extension, using Controls to extend the Spatial functionality in the case of jME. What you do at the moment is basically like extending JFrame to make your application class, it works but is not very good coding style.

ok I got it, thanks again :slight_smile: