I’m drawing the gun in front of the camera, so when walls are too close, it gets cut by the wall (as would be expected). How do I force it to be drawn on top of everything?
I’ve tried turning off the depthWrite, but since the model overlaps itself, the gun isn’t drawn correctly
This is the same with nodePath.setAttrib(DepthTestAttrib.make(RenderAttrib.MNone))and MAlways and MNotEqual
Is there a way to maintain the depth buffer order of the model (so it’s drawn right) and move that to the top?
So I looked into the display regions and copy pasta’d what they had.
# --- Create the display region for the weapons
dr2 = base.win.makeDisplayRegion(0, 1, 0, 1)
dr2.setClearDepthActive(True)
render2 = NodePath('render2')
cam2 = render2.attachNewNode(Camera('cam2'))
dr2.setCamera(cam2)
# --- Load Weapon Model
self.weapon = loader.loadModel("mp5")
self.weapon.reparentTo(render2)
If I just run the sample code by itself, everything works great. When I try to incorporate the code into my modules, I get an error creating the camera:
line 239, in createDisplayRegion
cam2 = render2.attachNewNode(Camera(‘cam2’))
TypeError: init() takes exactly 3 arguments (2 given)
I don’t understand why this error happens. The APIs for the camera class even describe creating a camera by passing a string…
At least in c++ you need to pass a Lens as the second parameter.
Dunno if it’s overhidden in the python layer, but by the error message I could guess it’s not (overhidden).
So you probably should try to pass a Lens in camera construction…
You guys sure replay fast.
The problem I was having with the creating a Camera was my fault. I had named my camera class ‘Camera’ so when I thought I was making a Camera node, I was actually making an object of my custom class.
Here’s the code that works for me, in case someone else sees this thread:
The only problem now is that the gun’s position is fixed (it doesn’t need to follow the player since it’s drawn on its own display region that sits on top of render), so the lighting never changes on it. Maybe I’ll fake this by adding the lighting to render2, and then moving the camera and the gun in the same way that I was moving it before. How taxing would it be to draw every light in both display regions? Does anyone have a better solution?