Exemplo n.º 1
0
    def __init__(self, mass, radius):
        import OBJ_Reader

        self.radius = radius
        self.mass = mass
        self.acceleration = vec4(0, 0, 0, 1)
        self.velocity = vec4(0, 0, 0, 1)
        self.position = vec4(0, 0, 0, 1)

        self.trans = mat4x4.make_identity()
        self.rotX = mat4x4.make_identity()
        self.rotY = mat4x4.make_identity()
        self.rotZ = mat4x4.make_identity()
        self.scale = mat4x4.mat_scale(self.radius)

        self.tris = list()
        reader = OBJ_Reader.ObjReader('models/Sphere.obj')
        for t in reader.triangles:
            v1 = vec4(t[0][0], t[0][1], t[0][2], 1)
            v2 = vec4(t[1][0], t[1][1], t[1][2], 1)
            v3 = vec4(t[2][0], t[2][1], t[2][2], 1)
            v1 = self.scale * v1
            v2 = self.scale * v2
            v3 = self.scale * v3
            self.tris.append(Triangle([v1, v2, v3], t[3]))
Exemplo n.º 2
0
    def __init__(self, engine, simSpeed, size, fps):
        self.engine = engine

        self.simSpeed = simSpeed

        self.projMat = mat4x4.make_identity()
        self.lightSource = vec4(5, 5, 10, 0)
        self.camera = vec4(0, 0, 0, 0)

        self.fps = fps
        self.deltaTime = 0
        self.lastTime = 0
        self.running = True

        pygame.init()
        self.size = size
        self.screen = pygame.display.set_mode(self.size)
        self.clock = pygame.time.Clock()
Exemplo n.º 3
0
    def __init__(self, engine, simSpeed, size, fps, seconds):
        self.engine = engine

        self.simSpeed = simSpeed
        self.fps = fps
        self.iterations = seconds * self.fps
        self.tick = (1 / fps) * simSpeed

        self.size = size

        self.projMat = mat4x4.make_identity()
        self.lightSource = vec4(5, 5, 10, 0)
        self.camera = vec4(0, 0, 0, 0)

        self.path = os.path.dirname(os.path.realpath(__file__))
        self.tempPath = os.path.join(self.path, 'temp')

        self.frameBuffer = np.zeros((self.size[1], self.size[0], 3), dtype=np.uint8)