Hmmm, I guess I did get the order wrong, thought I had it right because the info cards appear in their correct positions when units are moving, but not when the camera is moving so I assumed controls were executed before simpleUpdate, but perhaps the info cards are not in the correct positions, it is only that the difference is not noticeable because the units are not moving very far from one frame to the next as Jayfella said.
Nonetheless this doesn’t explain why the info cards are one frame behind when moving the camera. The camera moves pretty fast, much faster than units otherwise moving the camera from one end of the map to the other would take too long. Because the camera moves so fast the fact that the info cards are one frame behind is noticeable.
basically I have an abstract control attached to a node and this hosts most of my camera related methods along with an input listener for moving/zooming the camera. Actually I have about ten cameras setup right now, not all of them are being used for direct viewing of the game world, those that are used for viewing the game world use CameraNodes to track the node the abstract control is attached to.
Whenever I want to move the game cameras I use an input listener setup in the camera’s abstract control so, for instance, when I press ‘w’ the node the control is attached to moves along the z-axis, of course the CameraNodes, setup with CameraControl.ControlDirection.SpatialToCamera, follow this node.
My info card update loop in the simpleUpdate() method does a few calculations, but the one pertinent to this issue is:
Camera.getScreenCoordinates(unit.getLocalTranslation(), Vector3f store);
The value returned from that method is used in placing the info card in screen space coordinates.
The units themselves generally don’t have any controllers attached to them, I’m using a custom class that extends the Node class for storing unit information and housing unit related methods. However, when a unit needs to animate, such as when moving, I attach a control to the unit which animates that unit frame by frame and is then detached when the control is no longer needed (this is a turn based strategy). Anyway when a unit is moving or stationary and the camera is stationary the info cards appear in the correct screen space coordinates. When I move the camera left, for example, the info cards appear slightly to the left of where they should be or apparently in the position they would be if the getScreenCoordinates() method were called before the camera’s new position was calculated in the input listener. When the camera stops moving the info cards pop back into their proper coordinates.
Edit: Okay, I get it, it’s not the input listener that’s causing the problem, it’s the CameraNode. A CameraNode is used so that a Camera can essentially be parented to a spatial or, in this case, a Node or vise versa. Looking at JME source it would appear that a CameraNode uses a CameraControl, abstract control, to achieve this. So the camera’s movement is being executed along with the abstract controls, not the input listeners.
This presents a problem then, if I use an abstract control to run my info card update loop I need to ensure that control runs after all other abstract controls. How would I ensure a particular abstract control is executed last?