I’d like to display an object in front of the camera and have that object move together with the camera. In other words, it always needs to be in front of the camera. I think I need to reparent it to the camera somehow.
Should I or shouldn’t I include reparentTo(self.render)?
BTW the model renders OK when I just add it without trying to reparent to the camera. The file is included in the proper folder, all that. In other words the following code works alright:
Notice the # in the reparentTo camera line. As it is now, the object will appear in front of the camera (it will not follow the camera of course). And as I walk close to the object it keeps disappearing.
Also, and this is a bit subtle, when you have an actor’s animation responsible for moving it in front of the camera, it’s true that Panda won’t necessarily make it visible when it gets there. The reason for this is complicated but has to do with the automatic bounding boxes that Panda uses to perform view-frustum culling.
To work around it, you have to tell Panda not to perform view-frustum culling on your actor. To do this, do:
I’d like to comment that it’s probably a poor practice to use an Actor’s animation to move it around. You’ll have your actors wandering away from the coords that they will report if you getPos(), and that can make coding any sorts of interaction very difficult. Also any collision nodes you reparent to them won’t move with them unless you reparent them to exposed joints. I’m sure there area a bunch of other issues that could crop up as well.
You’re much better off having the model stay in the same place relative to the root/origin in the animations, and then move the actor around with setPos() instead. It can sometimes be tricky to get the amount of movement to match the animation, but it’s worth the effort.
Good point. Thanks for this comment, something to keep in mind.
I didn’t play around with actors in this particular example. I wanted to display a menu not with just OnScreenImage, but make it more dynamic. The manu sort of slides in in the animation.
It works well, yet the quality of the image rendered is worse than the one displayed using OnscreenImage.