Fit objects to window / Zoom All

Hi everyone, total noob here so show a little patience plz

I only recently started with Panda and as with any graphics engine I ever tried I have the same problem. The camera position. I always have to either experiment with the position or move it around in order to see the entirety of my objects.

I especially have this problem when it comes to large heightfield terrains (great post about it by astelix
https://discourse.panda3d.org/viewtopic.php?p=57392 ). I always have to zoom out to some extend and then play with pan and rotate to get the thing into view

So, is there a way in Panda for the camera to encompass all rendered objects? Something like a ‘fit objects to window’ or a ‘zoom to fit all’ kind of thing?

I already looked in the forum to no avail. Any help would be appreciated.

Thanks in advance,
Adam

Maybe you’re facing a scale problem and scaling your object down may help.
You can also try the out of body experience which is a good way to see what your cam is doing and compare it’s scale to your world.

base.oobe()

Thanks for the reply :smiley:

The thing is, that if I try scaling the heighfield get flattened immediately even when scaling to ‘1’ for all axes.

Is there some different way to scale for these objects?

Moreover, is there no way to say get the bounding box off all rendered geometries and position the camera to watch the whole thing in the window?

You can get the bounding volume of the scene via render.getBounds() or render.getTightBounds(), and compute yourself where the camera needs to be to view all of this. This is what happens in pview, for instance, when you press the ‘c’ key.

That’s kind of a weird thing to do in an application, though. Normally, in a game environment, you already know how big your scene is (since you created it) and you know where you want your camera to be (since that’s part of the scene).

David

Hi David,

Thanks so much for your answer, it seems to do the trick!

The thing is that I am playing around with heightfield terrains and models of different sizes and I just want to see how the thing ends up looking.

Therefore, I was looking for a sure way to see the whole thing every time without having to recalculate the position of the camera on my own and spend time either playing around with camera positions or repositioning in the rendered window.

Thanks a lot!!!
Adam