I was trying to get an object in the world that is viewed by two cameras to be only rendered by one. Looking in the reference, I found the Camera.setCameraMask() function, but I could not find a way to tell the node to be of this mask…
Basically I would like two cameras: one renders everything, and another renders everything except for one or two things…
(1) You should assign just one bit, a different bit, to each camera. Right now you have all bits on for base.cam, and all bits except one for your new camera. That’s confusing.
(2) nodePath.hide() is an overall operation. It always hides things from all cameras, regardless of their bitmasks. This is different from nodePath.hide(mask), which only hides things from the named camera. Note that nodePath.show(mask) does not counteract the effect of nodePath.hide()! The only thing that undoes an overall hide() is an overall show() (or an overall showThrough(), if you must).
Don’t call smiley.hide(). You can make smiley visible or invisible in each camera by calling smiley.hide(baseCamMask)/smiley.show(baseCamMask) or smiley.hide(newCamMask)/smiley.show(newCamMask).
If you really want to hide smiley for all cameras at once, and then show him one at a time in each camera, you could do smiley.hide(BitMask32.allOn()). This means “hide smiley for all camera bits” which is a different thing than “hide smiley overall”, because a later smiley.show(camMask) will then show smiley again for that camera.
Is there any reason why a call to Nodepath.hide() is different from Nodepath.hide(Bitmask32.allOn())? This just seems confusing, as they do the same thing, but if you want to utilize camera masks halfway through a project you have to go back and change all the hides/shows…
not a big deal now that I know, but maybe a manual page on hiding/showing or as part of some other page (maybe in the camera stuff?)
They don’t really do the same thing. hide() is meant to hide an object globally. Presumably, you do this when you want to take the object out of the scene or something. It always does this, whether or not you are using camera masks.
On the other hand, hide(mask) hides an object only from the named camera, but not globally. Not the same thing at all.
It’s true if you’ve already written a program with no intention of using camera masks, and then you go back and decide to use camera masks, you have to retrofit. But you’d have to do that anyway, and decide on a per-call basis whether each hide() is meant to hide the object globally, or only for a certain set of cameras.
A manual page all about this topic would be a welcome addition.