Beispiel #1
0
def main():
    sys.path.append(".")
    import DEBUG
    global Cam
    global Light

    #t = threading.Thread(target = ui)
    #t.start()

    sol = []

    Step = 2
    Size = 30
    for i in range(-Size, Size, Step):
        for j in range(-Size, Size, Step):
            sq1 = matrix.mat3x3([[i, j, 3], [i, j + Step, 3], [i + Step, j,
                                                               3]])
            """
            sq2 = matrix.mat3x3([
                [i,j+Step,1],
                [i+Step,j+Step,1],
                [i+Step,j,1]
            ])"""

            sol.append(sq1)
            #sol.append(sq2)

    MatGraph.MultiplyMeshAndMatrix(sol,
                                   matrix.RotationMatrix("X", math.pi / 2))

    global TranslationMatrix

    DEBUG.init()
    Graphics.initDisplayHandler(DEBUG.window, DEBUG.ScreenSize, 100,
                                15 * math.pi / 180)
    DEBUG.HandleWindowEvents()
    theta = 0
    phi = 0
    vtheta = 0
    #for p in sys.path:

    #Test2 = Load3DElement("GPlaneur/Tests/Graphipsa3D/MeshFiles/GAMIIIING.obj")

    #MatGraph.MultiplyMeshAndMatrix(Test,matrix.RotationMatrix("Y",theta))
    #MatGraph.MultiplyMeshAndMatrix(Test,matrix.RotationMatrix("X",math.pi/6))
    #MatGraph.MultiplyMeshAndMatrix(Test,matrix.RotationMatrix("Z",math.pi/6))

    #Test2 = Load3DElement("Tests/Graphipsa3D/MeshFiles/teapot.obj")

    Cam = vector([0, 0, 0])
    vUp = vector([0, 1, 0])
    vLookDir = vector([0, 0, 1])
    vTarget = vector([0, 0, 1])

    #print(pygame.display.Info())
    Step = 2
    Size = 60
    offset = 0
    LastCamPos = 0
    miniOffset = 0
    while DEBUG.ISRUNNING:

        #thetaa += math.pi/512

        #Cam.v[2] -= DEBUG.JoystickAxis[3]/16

        phi += DEBUG.JoystickAxis[1] / 32

        vForward = vector([(-vLookDir.v[0]) * DEBUG.JoystickAxis[3] / 1,
                           (-vLookDir.v[1]) * DEBUG.JoystickAxis[3] / 1,
                           (-vLookDir.v[2]) * DEBUG.JoystickAxis[3] / 1])

        Cam += vForward

        #print(Cam)
        #vTarget = ([0,0,1])
        vLookDir = vector([0, math.sin(phi), math.cos(phi)])
        #vLookDir = vector([-math.sin(theta),0,math.cos(theta)])
        #vLookDir = vector([1,0,0])

        vTarget = Cam + vLookDir

        subMat = PointAt(Cam, vTarget, vUp)

        mtView = LookAtMatrix(subMat)

        #print(vTarget)
        sol = []

        #print(offset)

        if Cam.v[2] > Size + offset - 60:

            offset = int(Cam.v[2])
            miniOffset = Cam.v[2] - offset

        for i in range(-30, 30, Step):
            for j in range(offset, Size + offset, Step):

                sq1 = matrix.mat3x3([[i, 6, j - miniOffset],
                                     [i + Step, 6, j - miniOffset],
                                     [i, 6, j + Step - miniOffset]])

                sol.append(sq1)

        #Tst2 = sol.copy()
        #MatGraph.MultiplyMeshAndMatrix(Tst2,matrix.RotationMatrix("X",math.pi/2))
        #MatGraph.AddMeshAndMatrix(Tst2,matrix.mat3x3([[0,3,0],[0,3,0],[0,3,0]]))
        #MatGraph.MultiplyMeshAndMatrix(Test,matrix.RotationMatrix("Y",-thetaa))
        #MatGraph.AddMeshAndMatrix(Test,TranslationMatrix)
        #MatGraph.MultiplyMeshAndMatrix(Test,matrix.RotationMatrix("X",thetaa))

        #MatGraph.MultiplyMeshAndMatrix(Test,matrix.RotationMatrix("X",math.pi/6))
        #MatGraph.MultiplyMeshAndMatrix(Test,matrix.RotationMatrix("Z",math.pi/6))

        #FillMesh(Test,(255,255,255),Cam,Light,matView)
        #FillMesh(Tst2,(0,255,0),Cam,Light,matView)

        FillMesh(sol, (255, 255, 255), Cam, Light, mtView)

        #DrawMesh(Test,(255,255,255))

        DEBUG.HandleWindowEvents()

    DEBUG.quit()
Beispiel #2
0
    #print(offset)

    if Cam.v[2] > Size + offset - 60:

        offset = int(Cam.v[2])
        miniOffset = Cam.v[2] - offset

    for i in range(-30, 30, Step):
        for j in range(offset, Size + offset, Step):

            sq1 = matrix.mat3x3([[i, 6, j - miniOffset],
                                 [i + Step, 6, j - miniOffset],
                                 [i, 6, j + Step - miniOffset]])

            sol.append(sq1)
    print()

    FillMesh(sol, (255, 255, 255), Cam, Light, mtView)


if __name__ == "__main__":
    import DEBUG
    Init()
    while DEBUG.ISRUNNING:

        Affichage(0, 0, 0)

        DEBUG.HandleWindowEvents()

    pygame.quit()