so I played a dummy animation on my entire scene so I could expose joints where I want to place objects. It works great with both my rock class and my spike class, but when I try it with my Pit class, it doesn’t work.
Basically, i had my modeler place joints at the corners of the pit so I could create a collision polygon between those points. Exposing the joints seems to work, because when I print the joint I get a different NodePath. But all the positions are always at (0,0,0).
here’s my code:
def exposeJoints(self, task):
# for each rock, we need to expose the joint, and create a collision sphere at the pos of the joint
for i in range (1,744):
rockName = "Rocks1:r" + str(i)
self.rockJoint = self.tube.exposeJoint(None,"modelRoot",rockName )
self.rockModel = Actor.Actor("models/Ice2.egg", {'shatter' : "models/Ice2-Shatter"} )
self.rock = Rock(self.rockJoint, self.rockModel, i, self)
self.rocks[i] = self.rock
for i in range (1,13,4):
self.pitCorner1 = self.tube.exposeJoint(None, "modelRoot", 'hole'+str(i))
i = i+1
self.pitCorner2 = self.tube.exposeJoint(None, "modelRoot", 'hole'+str(i))
i = i+1
self.pitCorner3 = self.tube.exposeJoint(None, "modelRoot", 'hole'+str(i))
i = i+1
self.pitCorner4 = self.tube.exposeJoint(None, "modelRoot", 'hole'+str(i))
self.pit = Pit(self.pitCorner1, self.pitCorner2, self.pitCorner3, self.pitCorner4, self)
self.pits[i] = self.pit
And here’s my rock class:
class Rock(DirectObject):
def __init__(self, joint, model, num, w):
self.model = model
self.num = num
self.joint = joint
self.model.reparentTo(self.joint)
self.rockSphere = CollisionSphere(0, 0, 0, 1.7)
self.rockSphereNodePath = self.model.attachNewNode(CollisionNode('rock'+str(self.num) ) )
self.rockSphereNodePath.node().addSolid(self.rockSphere)
#self.rockSphereNodePath.show()
and finally my pit class:
class Pit(DirectObject):
def __init__(self, p1, p2, p3, p4, w):
pos1 = render.attachNewNode('pos1')
pos1.reparentTo(p1)
pos2 = render.attachNewNode('pos2')
pos2.reparentTo(p2)
pos3 = render.attachNewNode('pos3')
pos3.reparentTo(p3)
pos4 = render.attachNewNode('pos4')
pos4.reparentTo(p4)
print pos1
print pos2
print pos3
print pos4
self.collisionPoly = CollisionPolygon(pos1.getPos(), pos2.getPos(), pos3.getPos(), pos4.getPos())
self.collisionNodePath = render.attachNewNode(CollisionNode('pit'))
self.collisionNodePath.node().addSolid(self.collisionPoly)
self.collisionNodePath.show()
Any suggestions for saving the positions of the pit corner nodes? I think the reason the rocks and spikes work is that I have a concrete model to reparent to the exposed spike node, and in the pit example I do not. But I make a dummy node for each corner in the pit class, so I thought I covered this case.
Any help?
Thanks in advance,
Adam