I feel embarrassed asking this question, but I have been playing with this for a few hours and can’t seem to figure it out. What I am trying to do is very standard and I’m going to feel really dumb when someone tells me what I’m doing wrong.
I am trying to update the positions of about 15 colored spheres. I want to have a sphere for each possible Enum that I have declared in another class. Currently, I have created a class that extends Node that contains an EnumMap<MyEnum, Node>. I initialize this map by adding a Node with an attached Sphere Geometry for every possible Enum. In my Main class I do the following:
SphereMap sphereMap = new SphereMap(assetManager);
rootNode.attachChild(sphereMap);
This draws all of the spheres in their initial position to the screen just fine. The problem that I am having is moving the spheres once I have attached the SphereMap node to rootNode.
public void setSpherePosition(MyEnum myEnum, Vector3f position) {
int i = getChildIndex(sphereNodeMap.get(myEnum));
Node sphere = (Node)getChild(i);
sphere.setLocalTranslation(position);
}
Calls to this method does not change the position of the spheres and I can’t figure out why. I tried calling
this.updateGeometricState();
and that doesn’t change anything either. The only way I can get the spheres to move is to detach the SphereMap class from rootNode and reattach it which I assume is terribly costly. What am I doing wrong? Also, is the way I am going about this crazy, or standard?