Exemple #1
0
    def __init__(self, position, scale=1, width=10, height=10):
        Object.__init__(self, position)

        self.scale = scale
        self.width = width
        self.height = height
        self.mesh = Mesh(self.Position)
        self.createVertices()
Exemple #2
0
    def __init__(self, engine, x, y, z, scale, color=None, rigidBody=False):
        self.scale = scale
        self.color = color
        faces = self.faces(scale, color)
        mesh = Mesh(engine, self, x, y, z, faces)

        Object3D.__init__(self, engine, x, y, z, mesh, rigidBody)
Exemple #3
0
    def __init__(self, engine, x, y, z, rigidBody=False):
        self.black = (0, 0, 0)
        self.white = (255, 255, 255)
        self.yellow = (255, 165, 0)
        faces = self.faces()
        mesh = Mesh(engine, x, y, z, faces)

        Object3D.__init__(self, engine, x, y, z, mesh, rigidBody)
Exemple #4
0
    def __init__(self, engine, x, y, z, color=None, rigidBody=False):
        self.color = color
        self.black = (0, 0, 0)
        self.blue = (176, 225, 230)

        faces = self.faces()
        mesh = Mesh(engine, x, y, z, faces)

        Object3D.__init__(self, engine, x, y, z, mesh, rigidBody)
Exemple #5
0
class Object:
    def __init__(self, position, rotation=Vector(0,0,0)):
        self.Position = position
        self.Rotation = rotation
        self.mesh = None

    def update(self):
        if (self.mesh != None):
            self.mesh.Position = self.Position
            self.mesh.Rotation = self.Rotation
            self.mesh.updateMesh()

    def draw(self, gameScreen):
        if (self.mesh != None):
            self.mesh.drawMesh(gameScreen)

    def loadMesh(self, mesh, scale=1, color=(255,0,255)):
        self.mesh = Mesh(self.Position)
        self.mesh.loadMesh(mesh, scale, color)
Exemple #6
0
class Terrain(Object):
    def __init__(self, position, scale=1, width=10, height=10):
        Object.__init__(self, position)

        self.scale = scale
        self.width = width
        self.height = height
        self.mesh = Mesh(self.Position)
        self.createVertices()

    def createVertices(self):
        self.mesh.verticesData = []
        self.mesh.triangles = []
        for x in range(self.width):
            for z in range(self.height):
                self.mesh.verticesData.append(
                    Vertex(
                        Vector(self.Position.x + x, self.Position.y,
                               self.Position.z + z)))

        i = 0
        for x in range(self.width - 1):
            for z in range(self.height):
                if (i + self.width + 1 < len(self.mesh.verticesData)):
                    self.mesh.createTriangle(i + 1, i, i + self.width)
                    self.mesh.createTriangle(i + 1, i + self.width,
                                             i + self.width + 1)

                i += 1

        self.mesh.scale = self.scale

    def setHeights(self, heights):
        for v, h in zip(range(len(self.mesh.verticesData)), heights):
            vertex = self.mesh.verticesData[v]
            vertex.Position.y = h

            self.mesh.verticesData[v] = vertex
Exemple #7
0
 def loadMesh(self, mesh, scale=1, color=(255,0,255)):
     self.mesh = Mesh(self.Position)
     self.mesh.loadMesh(mesh, scale, color)