How would I go about rendering certain models at with a different Field of View. Is there a way to have a model render through a second camera with an altered FoV? Also, I’d want it to be influenced by the lights attached to render. Is it possible to do this?
The manual explains enabling lights, and also changing the field-of-view. You can set a different field-of-view for each camera.
Is there a specific question you had about either of these?
I have a scene that has lights and is being viewed by a camera with a 75 degree FoV, but I’m wondering if there’s a way to render a certain model with a 54 degree FoV. is there a way to have a nodepath down render be viewed by a separate camera?
Not really, not within the same scene. You can have a separate DisplayRegion–a separate picture-in-picture window, or a side-by-side window–or a separate window altogether–that renders the entire scene in a different FOV. But you can’t just pick and choose the FOV on a per-model basis.
(Technically, actually, it would be possible to render one particular model with a different FOV. It would require layering DisplayRegions on top of one another, and setting camera mask bits to make the object in question appear only in the topmost DisplayRegion. But even trickery like this wouldn’t give you the effect you are hoping for: the object won’t appear to be positioned correctly within the scene, because when you widen the field-of-view, you change the position of objects within the frame. So it would just weirdly float around, without appearing to be a part of the scene at all.)
Actually, it might be possible, as the model will be parented to the camera, and I want it to be drawn in front of the rest of the world. What I’m trying to do is based off of what I know of the first-person view system in Valve’s Source engine, where the world is rendered at 75 degrees and the first person view models at 54 degrees. Would I be able to replicate this in Panda?
Yeah, this is kind of like a heads-up display for 2-d graphics, except the onscreen graphics are 3-d.
It’s just an overlayed DisplayRegion. You could do something like this:
drw = base.win.makeDisplayRegion(0.1, 0.4, 0.2, 0.6) drw.setClearDepthActive(True) weapons = NodePath('weapons') camw = weapons.attachNewNode(Camera('camw')) camw.node().getLens().setFov(54) drw.setCamera(camw)
This creates a new scene graph, called weapons, which you can parent stuff you like to. Anything you attach here will be drawn on top of the ordinary scene in render, and it will be placed relative to camw (which is to say, it will remain fixed relative to the main camera).
Thanks so much for the help. I have another question, however. I want the lights in render to affect weapons. Should I just apply the lights to both nodepaths or is there a better way to do this. Also, when I get lights working, then the model currently does not move, and so the lighting would be wrong. The only way I can think of is to make a second camera node(to parent the model and camera to) and copy the rotation and location settings from the primary camera node. This is the only way I could think of, but if there’s another more efficient way, then I would be happy to know.
Sure, to activate your lights on your weapons, you can just do:
Same as you would for render. It doesn’t matter that myLight is under the render scene graph instead of under the weapons scene graph; it can still illuminate the weapons if you turn it on.
As to the positioning of the lights, right. Your idea would work fine: by keeping the weapons camera slaved to the render camera, it would inherit the proper transform for the lights. That’s probably the best approach, and it isn’t very expensive at all.