Need help understanding relationship between model and camera

Hi,

I’m trying to understand the relationship between model position and camera position. To do this, I loaded a model that is at the coordinate origin and has a radius of 1. Then I move the camera to the point (0,2,0) on the y-axis. Why don’t I see the model? If I setPos(0,20,0) on the model, I see it. Why is that? The model is “rgbCube.egg” from the Panda3D example models.
Thanks in advance

This is because you move the camera to front and the model stays behind. Set the camera position to a negative Y value, point (0,-2,0).

In short, the camera is, in many ways, not all that special: it’s a node in the scene, just like any other–models included.

Now, it does have one peculiarity: its orientation influences what is rendered. Specifically–and presuming normal lens parameters–only what is “in front of” the camera is rendered. “In front of” here meaning: “Within something like a pyramid with its point at the camera, and its base facing along the camera’s y-axis.”

This means that when you moved the camera to (0, 2, 0), you moved it such that the origin was “behind” it, and thus not visible.

If, afterwards, you had turned the camera around (for example by calling “setH(180)” on the camera), then you should have seen your model, I imagine.

(Presuming that the model had a size that made it visible at that range–if it was too big then it might still have been invisible due to the camera being “inside” it.)

Thank you for your explanations. I did some more tests. Here’s an example in which I still don’t see the model:

from direct.showbase.ShowBase import ShowBase

class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)
        self.model = self.loader.loadModel("misc/rgbCube")
        self.model.reparentTo(self.render)
        self.camera.setPos(0, -2, 0) 

app = MyApp()
app.run()

But when I put the camera at position (0,2,0), turn it around and look back, I don’t see the model either:

from panda3d.core import Point3
from direct.showbase.ShowBase import ShowBase

class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)
        self.model = self.loader.loadModel("misc/rgbCube")
        self.model.reparentTo(self.render)
        self.camera.setPos(0, 2, 0)
        self.camera.lookAt(Point3(0, 0, 0))

app = MyApp()
app.run()

I don’t understand this. Or am I doing something wrong?

Try moving the camera further back, maybe the object will not get into the lens.

from direct.showbase.ShowBase import ShowBase

class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)
        self.disableMouse()
     
        self.model = self.loader.loadModel("misc/rgbCube")
        self.model.reparentTo(self.render)
        self.camera.setPos(0, -20, 0) 

app = MyApp()
app.run()

And yes, of course. It is important: self.disableMouse()

https://docs.panda3d.org/1.10/python/introduction/tutorial/using-intervals-to-move-the-panda

1 Like

Alright, thanks, disableMouse() solved the problem. It even works with the camera.setPos(0, -2, 0) command.

1 Like

I warm up this again. My camera is at point (0,0,0) and when I move the rgbCube-model to point (0,2,0) it becomes visible. Using the function getScale I get this result: “bsphere, c (0 2 0), r 0.866025” This means a surrounding sphere with a radius of 0.866 units. Therfore, I assumed that the model would be visible from a camera distance of minimal 0.87 units. However, it only becomes visible from a distance of at least 1.6 units. Why this? Do the corners of the cube sticking out from the sphere?

You don’t take into account the viewing angle, and possibly the clipping plane. You need to become familiar with the lens settings.

https://docs.panda3d.org/1.10/python/programming/camera-control/perspective-lenses

2 Likes