Type issues with nodes and scenenodes walkign the skeleton

Tubez

01-04-2007 15:00:31

Dear all,

I have a rather complex entity that uses bones to do rudimentary damage visuals. Basically, when a part gets damaged I need to hide the geometry attached to a bone and unhide the geometry attached to another that shares its physical location.

It sounds simple enough, but i'm getting tangled up in static typing issues.

Let's walk over the skeleton:

skel = box1.getSkeleton()
for i in range( skel.numBones):
bone = skel.getBone(i)
for j in range(bone.numChildren()):
# Child bones, one per part than can be damaged
child = bone.getChild(j)
for k in range(child.numChildren()):
# Grandchild bones, one damaged and one undamaged
# These guys have geometry attached, should therefore be SceneNodes
print child.getChild(k)


getChild() returns a Node (not a SceneNode). So, while i can walk all through the tree, I cant setVisible on the geometry attached to it.

I understand that this is a generic problem of interfacing static and dynamic type systems. It's also very annoying :P
Possible solutions I see are either ensuring that the correct type is passed back from C++ using RTTI functions (e.g. dynamic_cast) or having pointer conversion functions (open to masive footshooting).

I'm not sure if there's something in py++ that makes this easy to resolve though!

andy

01-04-2007 15:28:12

Sounds like we should be handwrapping the function, doing a dynamic cast on it and returning the correct type...

We recently had to do this for the ResourceManager getbyName and getByHandle functions so I guess we'll have to do it for node (looks like it should really return a scenenode or a bone) -- and I'd rather do this "intentionally" in a wrapper than supply a pointer conversion function :)

If possible could you send through a simple test program that I can use..

Thanks
Andy

roman.yakovenko

01-04-2007 21:18:13

Sounds like we should be handwrapping the function, doing a dynamic cast on it and returning the correct type...

We recently had to do this for the ResourceManager getbyName and getByHandle functions so I guess we'll have to do it for node (looks like it should really return a scenenode or a bone) -- and I'd rather do this "intentionally" in a wrapper than supply a pointer conversion function :)


:-), Andy but this time I prefer we implement "generic solution". The one, that will allow us not to track changes in source code.