Standard Camera

Hi for my project i was using the standard camera included in panda3d and so far no issues. Everything does what i want, but now i wanted to add a lens to my camera, which is surprisingly a huge issue. When i try to apply it on the camera.node().setLens(lens) it just tells me i cannot put it on a ModelNode object. I dont understand why its not a Camera object in the first place, but when i try to make a new camera and put on the lens (also without) i just get a solid cyan screen (exact same camera xyzhpr as the one i used before which worked). This seems to be a much too basic error for it to not be my fault so if you guys need something else of my code just tell me.
This is my camera setup (i dont change the cameras properties except location anywhere else)

self.pivot = self.render.attachNewNode("Pivot")
camera.setPos(self.pivot, 0, 0, self.orbit)
camera.reparentTo(self.pivot)
camera.lookAt(0, 0, 5)

I set it up like this because i want the camera to move around this pivots rotation but even without that its always the same

In short, the “camera” variable of ShowBase isn’t actually the camera itself, but rather a parent-node of the camera. The actual camera is called “cam”.

That is, the hierarchy looks something like this:

render
   |___camera  <--Just a ModelNode
           |___cam  <--The actual camera itself

So, something like the following should work:
cam.node().setLens(lens)

1 Like

Hi Thaumaturge,
unfortunately that is not the solution either. When i try to use that it just gives a NameError cam not defined

Can you show more of your code then, please?

If the “camera” variable that you’re using is the one provided by ShowBase, and if you’re using it as you showed above, then “cam” should work in the same way.

I’m guessing, then, that there’s something about the structure of your code that I’m not aware of, and that’s preventing the solution give above from working.

I have still no idea how it works, but now i found through accident the self.camNode with which it works now. So i guess its the same as you said just with an already defined node for it

Pretty much: “camNode” is essentially what you get if you call “cam.node()”, I believe.

I see that you’re using “self.” now, which you weren’t using in your earlier code–did you perhaps just leave off “self.” when attempting to use “cam”?

Yes i didn’t include the self before so i guess both work then

1 Like