Advertisement
Guest User

Untitled

a guest
Jan 12th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | None | 0 0
  1.     def load_model(self, filename, mass):
  2.         model_np = self.loader.loadModel(filename)
  3.         model_np.ls()
  4.  
  5.         def make_bullet(source_np):
  6.             resulting_node_path = NodePath('Intermediary holding transform')
  7.             resulting_node_path.setTransform(source_np.getTransform())
  8.             source_node = source_np.node()
  9.             if type(source_node) == GeomNode:
  10.                 body = BulletRigidBodyNode('BodyNode')
  11.                 shape = BulletConvexHullShape()
  12.                 for geom in source_node.getGeoms():
  13.                     geom = geom.decompose()
  14.                     shape.addGeom(geom)
  15.                 body.addShape(shape)
  16.                 body.setMass(mass)
  17.                 self.world.attachRigidBody(body)
  18.                 body_np = resulting_node_path.attachNewNode(body)
  19.                 geom_np = NodePath('MovedGeom')
  20.                 geom_np.attachNewNode(source_node)
  21.                 geom_np.reparentTo(body_np)
  22.             else:
  23.                 for child in source_np.getChildren():
  24.                     child_result = make_bullet(child)
  25.                     child_result.reparentTo(resulting_node_path)
  26.             return resulting_node_path
  27.  
  28.         return make_bullet(model_np)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement