Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def load_model(self, filename, mass):
- model_np = self.loader.loadModel(filename)
- model_np.ls()
- def make_bullet(source_np):
- resulting_node_path = NodePath('Intermediary holding transform')
- resulting_node_path.setTransform(source_np.getTransform())
- source_node = source_np.node()
- if type(source_node) == GeomNode:
- body = BulletRigidBodyNode('BodyNode')
- shape = BulletConvexHullShape()
- for geom in source_node.getGeoms():
- geom = geom.decompose()
- shape.addGeom(geom)
- body.addShape(shape)
- body.setMass(mass)
- self.world.attachRigidBody(body)
- body_np = resulting_node_path.attachNewNode(body)
- geom_np = NodePath('MovedGeom')
- geom_np.attachNewNode(source_node)
- geom_np.reparentTo(body_np)
- else:
- for child in source_np.getChildren():
- child_result = make_bullet(child)
- child_result.reparentTo(resulting_node_path)
- return resulting_node_path
- return make_bullet(model_np)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement