Exemple #1
0
def init_test_object():
    global _test_object, _child1, _child2, _child3, _child4
    color = np.array(
        [[1.0, 0.0, 0.0, 1.0], [0.5, 0.0, 0.0, 1.0], [0.0, 1.0, 0.0, 1.0],
         [0.0, 0.5, 0.0, 1.0], [0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 0.5, 1.0]],
        c_float)
    long_rect = RectPrismMesh(0.5, 0.1, 0.1, face_colors=color)
    _child1 = WorldObject(long_rect)
    _child2 = WorldObject(long_rect)
    _child3 = WorldObject(long_rect)
    _child4 = WorldObject(long_rect)
    _child1.set_local_position((1.25, 0.0, 0.0))
    _child2.set_local_position((0.0, 1.25, 0.0))
    _child3.set_local_position((-1.25, 0.0, 0.0))
    _child4.set_local_position((0.0, -1.25, 0.0))
    _child1.set_local_rotation((0.0, 0.0, 0.0))
    _child2.set_local_rotation((0.0, 0.0, glm.radians(90.0)))
    _child3.set_local_rotation((0.0, 0.0, glm.radians(180.0)))
    _child4.set_local_rotation((0.0, 0.0, glm.radians(270.0)))
    cube = RectPrismMesh(0.5, 0.5, 0.5, face_colors=color)
    _test_object = WorldObject(cube)
    _test_object.set_render_mode(gl.GL_LINE_LOOP)
    _test_object.add_child(_child1)
    _test_object.add_child(_child2)
    _test_object.add_child(_child3)
    _test_object.add_child(_child4)
Exemple #2
0
    def handlePOLS(self, polys):
        """Handle the polygons.

        This method creates the actual object. It is assumed that the
        points have been read before and are stored in the TriMeshGeom.
        It is also assumed that a SRFS chunk was present and numsurfaces
        is initialized.
        """
        # Assume the mesh is a triangle mesh and initialize the TriMeshGeom
        # first. If this fails, use a PolyhedronGeom instead...
        if self._initTriMesh(polys):
            geom = self.trimeshgeom
        else:
            # Copy the vertices into the polyhedron geom...
            numverts = self.trimeshgeom.verts.size()
            self.polyhedrongeom.verts.resize(numverts)
            self.trimeshgeom.verts.copyValues(0, numverts,
                                              self.polyhedrongeom.verts, 0)
            del self.trimeshgeom
            # Initialize the polys...
            self._initPolyhedron(polys)
            geom = self.polyhedrongeom

        w = WorldObject(name="lwob", parent=self.parent)
        w.setNumMaterials(self.numsurfaces)
        w.geom = geom
        self.worldobj = w