Hi, please could you watch the following video test (at half video the shaking is zoomed in)
to see the problem and give me some hint?
http://www.youtube.com/watch?v=HSAP9vSwGeI
Consider that the video capture skipped many frames, so the shaking is more faster in realtime.
Some background, I recently completed my first storyboard and prototype for a
Star Blazers/Foundation like game based on JMonkey and Darkstar, the initial prototype is quite
done, but now with the navigation totally broken I am totally afflicted, it’s really a pain
I tried using ThirdPersonHandler, ChaserCamera and so on, they work as expected when
used inside realistic coordinate system, but it seems they don’t work well with the
proportional speed related to vessel’s size and realistic dimension of a star system I need.
I tried to interpolate with Timer, with no success. I tried to trunk the precision of float
coordinates at the same decimals of the unit size of the object, always without success.
Pratically I have a vessel of size 0.001 unit (and it is yet too much big), then I increase
the speed of the vessel from 0.000001 up to 1 unit and more.
When I track the object near to the origin (eg inside an ideal sphere of 50 unit radius),
the object shaking appears only at high speed.
More distant (eg inside an ideal sphere of 500 unit radius) I track the object,
more object shaking appears both at low speed and high speed.
I tried to increase proportionally the scale of my coordinate system
(so vessel size 1, maximum speed 1000, near radius=5000, far radius=500000), but with no
success.
So I noticed that if I rescale up only the vessel (eg vessel size 1 unit keeping unaltered
the coordinate system of near radius=50 and far radius=500 and maximum speed=1),
then shaking disappears… but if I scale up also the maximum speed to 1000 the shaking re-appears…
What could I do, apart completely redesigning my game idea, please can you help me?
P.S.
I am using StandardGame, then I use some gamestates which inject all geometries
inside different RenderPasses used as layers. When I move into the scene with
a flyby travel (no objects moving with the CameraNode) there are no shaking at all
and all works well
I'm not at all sure what this is caused by and I haven't yet started digging into RenderPasses, but as I'm using StandardGame as well, I've found that you need to be careful in what threads you do things (as it's multi-threaded).
Are you setting the new translations for the ship inside the OpenGL thread (in the update queue of the GameTaskQueueManager)?
Thank You. You put me on the right way
Before your message I was putting all translation into the Controller update.
So currently I moved all translation into the BasicGameState update, and the
shaking is noticeably decreasing, it persists but it means that the problem lays in the update.
Tumaini said:
Are you setting the new translations for the ship inside the OpenGL thread (in the update queue of the GameTaskQueueManager)?
No, I used only for initing some RenderPass
I'm glad you got it working better!
But aren't you updating your controllers in your game state update method?
Usually (if my understanding of it is correct) you use addController(Controller c) on a Spatial to set a Controller for that Spatial and then you call updateGeometricState for the rootNode (to which the Spatial is perhaps attached) which calls the update method on all controllers of attached Spatials/Nodes.
I'm not sure if it will make any difference, but you could try putting the translation updates in the GameTaskQueueManager update queue. If I've understood it right, your Spatial's translation should then be updated before the next render in the OpenGL thread, instead of them being asynchronous (which is what I thought might be your problem, but I'm not sure).
Tumaini said:
But aren't you updating your controllers in your game state update method?
Yes, I used the addController with its update (translation inside),
then in BasicGameState.update I called "updateGeometricState(tpf, true)"
and "updateWorldData(tpf)" on "rootNode"
Tumaini said:
I'm not sure if it will make any difference, but you could try putting the translation updates in the GameTaskQueueManager update queue. If I've understood it right, your Spatial's translation should then be updated before the next render in the OpenGL thread, instead of them being asynchronous (which is what I thought might be your problem, but I'm not sure).
Done, now the shaking is yet more decreased, but I am unsure of the position. Pratically
I placed this anonymous call at beginning of the BasicGameState.update:
@Override
public void update(final float tpf) {
[...]
GameTaskQueueManager.getManager().update(new Callable<Object>() {
public Object call() throws Exception {
MainGS.this.myShipNode.getLocalRotation().clone().getRotationColumn(2, MainGS.this.shipDirection);
MainGS.this.shipDirection.normalizeLocal();
//if (MainGS.this.updateTimePassed>.01F) {
MainGS.this.playerPosition.addLocal(MainGS.this.shipDirection.multLocal(
tpf*MainGS.this.speedcam
));
MainGS.this.cameraPosition = MainGS.this.playerPosition.clone().addLocal(
/*MainGS.this.xShip*/MainGS.this.xAxe,
/*MainGS.this.yShip*/MainGS.this.yAxe,
/*MainGS.this.zShip*/MainGS.this.zAxe);
MainGS.this.myShipNode.setLocalTranslation(MainGS.this.playerPosition);
MainGS.this.cameraNode.setLocalTranslation(MainGS.this.cameraPosition);
//MainGS.this.updateTimePassed=0;
//}
return null;
}
});
[...]
this.rootNode.updateGeometricState(tpf, true);
this.rootNode.updateWorldData(tpf);
}
EDIT:
I made a test using SimpleGame, but shaking persists.
So I attached the shipnode to the CameraNode: shaking disappeared!
and I noticed that only when lookat is invoked shaking re-appears...
Great that you got it working well!
How big a universe are you thinking of using?
The game I'm working on also involves travels through space so I've been through many pitfalls of this setting.
One of them that I just thought I'd make you aware of is the limits of accuracy in floats when you have huge coordinates. Things might start jumping around and disappear.
The solution we took was to let the player's ship be centered at 0,0,0 in JME coordinates at all times and move everything else around the ship accordingly. Coordinates are instead kept in doubles in a separate coordinate system and divided into limited areas with a limited coordinate space.
You might not get this problem if your universe isn't huge, but I thought I'd just warn you of it, if you might stumple upon it later.
Good luck!