Пример #1
0
 def create_stanchions(self):
     from pandac.PandaModules import GeomVertexReader, CollisionNode, CollisionTube
     self.stanchions = self.stage.findAllMatches('**/=Stanchion')
     for stanchion in self.stanchions:
         geomnode = stanchion.node()
         radius = float(stanchion.getTag('Stanchion'))
         geom = geomnode.getGeom(0)
         vdata = geom.getVertexData()
         for gp in range(geom.getNumPrimitives()):
             vreader = GeomVertexReader(vdata, 'vertex')
             prim = geom.getPrimitive(gp)
             prim = prim.decompose()
             for p in range(prim.getNumPrimitives()):
                 start = prim.getPrimitiveStart(p)
                 end = prim.getPrimitiveEnd(p)
                 vertices = []
                 for v in range(start, end):
                     vi = prim.getVertex(v)
                     vreader.setRow(vi)
                     vertex = vreader.getData3f()
                     vertices.append(vertex)
                 vertices.append(vertices[0])
                 for i in range(1, len(vertices)):
                     a, b = vertices[i - 1], vertices[i]
                     stanchion_np = stanchion.attachNewNode(
                         CollisionNode('stanchion'))
                     print 'creating cyl with radius %f from %s to %s' % (
                         radius, a, b)
                     stanchion_np.node().addSolid(
                         CollisionTube(a[0], a[1], a[2], b[0], b[1], b[2],
                                       radius))
                     stanchion_np.node().setFromCollideMask(OBSTACLE_MASK)
         geomnode.removeAllGeoms()
Пример #2
0
 def set_bar_height(self, height):
     """ Sets the height of the bar to the given value. The given height should be between 0 and 1. """
     reader = GeomVertexReader(self.bar_vdata, 'vertex')
     writer = GeomVertexWriter(self.bar_vdata, 'vertex')
     while not reader.isAtEnd():
         v = reader.getData3f()
         if v[2] > 0:
             writer.setData3f(v[0], v[1], height)
         else:
             writer.setData3f(
                 v)  # I have to call the writer setData method in any case
Пример #3
0
 def _set_z_on_shaft(self, z):
     for vdata in self.shaft_vdata:
         reader = GeomVertexReader(vdata, 'vertex')
         writer = GeomVertexWriter(vdata, 'vertex')
         while not reader.isAtEnd():
             v = reader.getData3f()
             if v[2] > 0:
                 writer.setData3f(v[0], v[1], z)
             else:
                 writer.setData3f(
                     v
                 )  # I have to call the writer setData method in any case
Пример #4
0
 def _set_threshold(self, vdata, t_value):
     reader = GeomVertexReader(vdata, 'vertex')
     writer = GeomVertexWriter(vdata, 'vertex')
     while not reader.isAtEnd():
         v = reader.getData3f()
         writer.setData3f(v[0], v[1], t_value + self.padding)