Moving rootNode instead of camera

Hello,

I came across a problem with moving the camera (in a specific usecase), so I was wondering if it is reasonable to move rootNode instead.

So instead of moving the camera up when pressing w, I’d instead move the whole “world” down etc.

Does this make sense or is there a performance impact or any other problem?

If it is unclear what I mean, feel free to ask.

Many thanks
Zarim

In fact, it’s fairly common on large worlds because it mitigates some of the floating point issues for really large world positions (presuming the rest of the scene is always bit locally relative to the camera).

That being said, I wonder what the problem you are encountering is and if there isn’t a simpler solution.

Moving the root node instead of the camera is not free. By moving the root node every frame you will make JME recalculate all of the world transforms and world bounding shapes every frame. This is not necessarily a huge expense but it’s not free.

Even in games with large worlds, it’s common to have the camera move within some area and then scroll the world by ‘zones’ as the camera reaches some boundary… rather than move the root node all the time.

1 Like

Thanks for your quick answer.

The problem I am facing is that I want to have a fixed number of “zoom levels”. I want to switch between them using the mouse wheel.
At the same time I want smooth changes between the levels, so I thought of using a camera motion path.
But when I then try to move the camera with w,a,s,d, things get messy, because the MotionEvent and my custom control want to move the camNode at the same time (I hope this is somewhat understandable).

Probably there is nicer solution, but if it isn’t uncommon to move the world instead, I think I’ll stick with that idea.

Step 1: write your own camera control

Any real game will eventually write their own anyway. The included camera stuff is really only suitable for quick test apps and demos.

With your own, you will be able to do anything you want. Combine zoom levels and wasd movement in whatever way you desire.

…and no side effects down the road of moving your root node just to pretend to have zoom levels.

2 Likes

OK, thanks again for your time.
Gave me a good idea for what to do next :grinning:

1 Like