Noob questions

Been using panda3D for 5 months now but for some reason I don’t know the best ways to do the following:

  1. Get the ABSOLUTE position (and hpr) of a nodepath. I could traverse the parents or something like that but that seems dumb. There has to be a better way.
    EDIT: .getPos(render) works. Yay!

  2. Can I somehow “bake” in the scale of a nodepath? Here’s my problem… I have a nodepath that contains 2 children, one is a character mesh and one is a nameplate. I need the size of the nameplate to stay consitant even if the scale is changed. But the thing is that the nodepath and character mesh are abstracted away so the user will always say nodepath.setScale() instead of nodepath.model.setScale() (if the character mesh is = nodepath.model). Anyone get what I’m saying?

  3. Similarly, I need the nameplates to stay directly above the nodepath even if it’s “pitched” or “rolled”. It’s already billboarded but I guess I need to do something similar to #2

Thanks.

It sounds like you’re asking the scale of your nametag not to be affected by the scale of its parent.

You can achieve this with a CompassEffect, but you’re stretching the metaphor of the scene graph. It might be better to redesign your code so that you can just scale your character geometry directly.

Similarly, you can rotate just your character geometry, without rotating the node that contains both the character geometry and the nametag together. Then the nametag will always remain above your character even if it pitches.

David

Thanks. I’ll check out CompassEffect.

I knew of the possibility of transforming character mesh nodepath directly, but that’s sort of error prone. I’m designing a library addition to Panda3D and all characters created automatically have nametags associated with them. The nametags should always be of the same size between characters, no matter what their scale is.

char = CharacterPawn(…)
char.setPos(xyz)
char.CharacterModel.setScale(x) <-- Obviously somewhat confusing and inconvenient as opposed to
charl.setScale(x)

Only thing I can think of myself is overwriting the setScale method… But something tells me that’s not a good idea :stuck_out_tongue:

How about creating a nodepath for the position, attaching the nameplate and the character to it. You can scale the character as you want, the nameplate will stay the same. you just have to apply position, rotation changes to the parent nodepath, so the nameplate & character move together.