Having trouble exposing a joint and getting its position

My modeler created a level with joints in it where I’m supposed to put rocks. There are 35 joints and they are labeled r1-r35. I expose each joint in a loop and reparent a collision sphere to the nodepath that is returned by the exposeJoint call, so each sphere should be at the correct location. Instead, each sphere is at (0,0,0).

Anyone have any suggestions?


Here’s my code:

self.tube = Actor.Actor(“models/tubeStraight.egg”)
self.tube.reparentTo(render)

for i in range (1, 35):
rockJoint = self.tube.exposeJoint(None,“modelRoot”,“r” + str(i) )
rockSphere = CollisionSphere(0, 0, 0, 0.3)
rockSphereNodePath = rockJoint.attachNewNode(CollisionNode(‘rColNode’ + str(i) ))
rockSphereNodePath.node().addSolid(rockSphere)
rockSphereNodePath.show()


Any help ASAP would be appreciated. Thanks.

Have you bound and played an animation on your Actor? It doesn’t look like you have in your sample code, so you’ll be ending up with the default transforms on each joint. I’m not sure that this will be the correct transform until you start an animation playing.

But if your only purpose is to have a static place to put rocks, where these positions won’t be animated, then you don’t want to convert your level as an animated character (it’s often a bad idea to do this anyway for an entire scene), but rather as a static model. You can convert the model with “-trans all” on the maya2egg command line to prevent the transforms on your scene from being flattened out during conversion.

Then, rather than exposing joints, you would simply find the node you’re looking for:


rockJoint = model.find('**/r' + str(i))

David

so just to clarify, the command line would be

maya2egg -trans all tunnel.egg tunnel.mb ?

and once I have the new egg file, and I find each joint, will I be able to just use rockJoint.getPos() to find where I need to place my rock and collision sphere?

The command line would be:


maya2egg -trans all -o tunnel.egg tunnel.mb

Note the use of -o to introduce the name of the output file, tunnel.egg.

It’s also possible to use the eggImportOptions.mel melScript to assign a “dcs” flag to the nodes in question in lieu of using the “-trans all” option, but this is a bit more advanced and I’d recommend sticking with the simpler approach first.

It would be better simply to reparent the rock to the rockJoint itself, as you did in your above example; this obviates the need to set the position of each rock separately since it will inherit its parent’s position.

David