Exemplo n.º 1
0
    def __init__(self, length=1., tickness=3.):
        GeomNode.__init__(self, "Basis")
        self.vertexData = GeomVertexData("Basis", GeomVertexFormat.getV3c4(),
                                         Geom.UHStatic)
        self.vertex = GeomVertexWriter(self.vertexData, 'vertex')
        self.color = GeomVertexWriter(self.vertexData, 'color')
        self.mesh = Geom(self.vertexData)
        self.lines = GeomLines(Geom.UHStatic)

        self.vertex.addData3f(0.0, 0.0, 0.0)
        self.color.addData4f(1.0, 0.0, 0.0, 1.0)
        self.vertex.addData3f(length, 0.0, 0.0)
        self.color.addData4f(1.0, 0.0, 0.0, 1.0)
        self.lines.add_vertices(0, 1)

        self.vertex.addData3f(0.0, 0.0, 0.0)
        self.color.addData4f(0.0, 1.0, 0.0, 1.0)
        self.vertex.addData3f(0.0, length, 0.0)
        self.color.addData4f(0.0, 1.0, 0.0, 1.0)
        self.lines.add_vertices(2, 3)

        self.vertex.addData3f(0.0, 0.0, 0.0)
        self.color.addData4f(0.0, 0.0, 1.0, 1.0)
        self.vertex.addData3f(0.0, 0.0, length)
        self.color.addData4f(0.0, 0.0, 1.0, 1.0)
        self.lines.add_vertices(4, 5)

        self.lines.closePrimitive()
        self.mesh.addPrimitive(self.lines)
        self.addGeom(self.mesh)

        NodePath(self).setRenderModeThickness(tickness)
        NodePath(self).setLightOff()
        NodePath(self).setColorOff()
        NodePath(self).set_bin('fixed', 9)
Exemplo n.º 2
0
    def __init__(self, base):
        # Load texture
        tex = Loader(base).loadTexture((Path(path.realpath(__file__)).parent.parent.parent / "res/images/checkerboard.png").absolute())
        tex.setMagfilter(SamplerState.FT_nearest)
        tex.setMinfilter(SamplerState.FT_nearest)

        # Set up vertex data
        vdata = GeomVertexData("floor_data", GeomVertexFormat.get_v3t2(), Geom.UHStatic)
        vdata.setNumRows(6)
        vertex = GeomVertexWriter(vdata, "vertex")
        texcoord = GeomVertexWriter(vdata, "texcoord")

        vertex.addData3(-5, -5, 0)
        texcoord.addData3(0, 0, 0)
        vertex.addData3(-5, 5, 0)
        texcoord.addData3(0, 10, 0)
        vertex.addData3(5, 5, 0)
        texcoord.addData3(10, 10, 0)

        vertex.addData3(5, 5, 0)
        texcoord.addData3(10, 10, 0)
        vertex.addData3(5, -5, 0)
        texcoord.addData3(10, 0, 0)
        vertex.addData3(-5, -5, 0)
        texcoord.addData3(0, 0, 0)

        # Create primitive
        prim = GeomTriangles(Geom.UHStatic)
        prim.addVertices(0, 1, 2)
        prim.addVertices(3, 4, 5)
        geom = Geom(vdata)
        geom.add_primitive(prim)

        # Initialize geometry node
        GeomNode.__init__(self, "floor")
        attrib = TextureAttrib.make(tex)
        state = RenderState.make(attrib)
        self.addGeom(geom, state)
Exemplo n.º 3
0
 def __init__(self, name):
     GeomNode.__init__(self, name)
Exemplo n.º 4
0
    def __init__(self,
                 x_extend=None,
                 y_extend=None,
                 x_size=1,
                 y_size=1,
                 z=-0.01,
                 tickness=1.,
                 name='Grid',
                 x_color=None,
                 y_color=None):
        GeomNode.__init__(self, name)
        if x_color is None:
            x_color = LVector4f(1.0, 1.0, 1.0, 1.0)

        if y_color is None:
            y_color = LVector4f(1.0, 1.0, 1.0, 1.0)

        if x_extend is None:
            x_extend = [0, 10]
        if y_extend is None:
            y_extend = [0, 10]

        self.vertexData = GeomVertexData("Chunk", GeomVertexFormat.getV3c4(),
                                         Geom.UHStatic)
        self.vertex = GeomVertexWriter(self.vertexData, 'vertex')
        self.color = GeomVertexWriter(self.vertexData, 'color')

        self.mesh = Geom(self.vertexData)
        self.lines = GeomLines(Geom.UHStatic)

        nb_lines_x = int((x_extend[1] - x_extend[0]) / x_size)
        nb_lines_y = int((y_extend[1] - y_extend[0]) / y_size)

        vertex_nb = 0
        for ix in range(nb_lines_x):
            for iy in range(nb_lines_y):
                x = x_extend[0] + ix * x_size
                y = y_extend[0] + iy * y_size

                self.vertex.addData3f(x, y, z)
                self.color.addData4f(x_color)

                self.vertex.addData3f(x + x_size, y, z)
                self.color.addData4f(x_color)

                self.vertex.addData3f(x, y, z)
                self.color.addData4f(y_color)

                self.vertex.addData3f(x, y + y_size, z)
                self.color.addData4f(y_color)

                self.lines.add_vertices(vertex_nb, vertex_nb + 1,
                                        vertex_nb + 2, vertex_nb + 3)
                vertex_nb += 4

        self.lines.closePrimitive()
        self.mesh.addPrimitive(self.lines)
        self.addGeom(self.mesh)

        NodePath(self).setRenderModeThickness(tickness)
        NodePath(self).setLightOff()
        NodePath(self).setColorOff()
        NodePath(self).set_bin('fixed', 8)
Exemplo n.º 5
0
	def __init__(self, name):
		GeomNode.__init__(self, name)