Пример #1
0
def groundCreator():
	viz.startLayer(viz.QUADS)
	viz.texCoord(0,0) 
	viz.vertex(100, 0, -100)
	viz.texCoord(1,0) 
	viz.vertex(100, 0, 100)
	viz.texCoord(1,1) 
	viz.vertex(-100, 0, 100)
	viz.texCoord(0,1)  
	viz.vertex(-100, 0, -100)
	ground = viz.endLayer()

	AreaScale_f = [16, 16 ,1]

	matrix_area_f = vizmat.Transform()
	matrix_area_f.setScale(AreaScale_f)
	
	ground.texmat(matrix_area_f)

	wallTex = viz.addTexture('wallTex.jpg')
	wallTex.wrap(viz.WRAP_T,viz.REPEAT)
	wallTex.wrap(viz.WRAP_S,viz.REPEAT)

	ground.texture(wallTex)

	return ground
Пример #2
0
    def __init__(self):

        # base class constructor
        viz.EventClass.__init__(self)

        #self.addCoordinateAxes()

        # set up keyboard and timer callback methods
        self.callback(viz.TIMER_EVENT, self.onTimer)
        self.callback(viz.KEYDOWN_EVENT, self.onKeyDown)

        self.starttimer(1, (1 / 25.0), viz.FOREVER)
        #self.starttimer(2, (30), viz.FOREVER)
        #self.starttimer(1, (30), viz.FOREVER)

        self.timePassed = 0

        # car's x,z location in maze and its rotation angle
        self.theta = 0
        self.x = 0
        self.z = 0

        #cars velocity
        self.vx = 0
        self.vy = 0
        self.vz = 0

        self.v = 0

        #lighting codeeeee
        self.myLight = viz.addLight()
        self.myLight.enable()
        self.myLight.color(1, 1, 1)

        m = viz.Matrix()
        m.postAxisAngle(1, 0, 0, 90)
        self.myLight.setMatrix(m)

        self.mat = viz.Matrix()

        #load taxi
        c = viz.add('taxiNew.dae')
        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        c.setMatrix(m)

        self.car = viz.addGroup()
        c.setParent(self.car)

        # create ball and link it to car so the user can see where they are on the minimap
        self.circ2 = vizshape.addSphere(radius=15.0,
                                        slices=20,
                                        stacks=20,
                                        axis=vizshape.AXIS_Y)
        self.circ2.color(1, 1, 0)
        self.circ2.setParent(self.car)

        #create a rectangle over visible ground and add grass texture
        viz.startLayer(viz.QUADS)
        viz.texCoord(0, 16)
        viz.vertex(700, 0, -100)
        viz.texCoord(16, 16)
        viz.vertex(700, 0, 600)
        viz.texCoord(16, 0)
        viz.vertex(-100, 0, 600)
        viz.texCoord(0, 0)
        viz.vertex(-100, 0, -100)
        self.vertices = viz.endLayer()

        tex = viz.addTexture('grass.jpg')

        tex.wrap(viz.WRAP_S, viz.REPEAT)
        tex.wrap(viz.WRAP_T, viz.REPEAT)

        self.vertices.texture(tex)

        #load in models
        self.house1 = viz.add('house1\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(115, 0, 230)
        self.house1.setMatrix(m)

        self.house2 = viz.add('house2\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(15, 0, 30)
        self.house2.setMatrix(m)

        self.house3 = viz.add('house3\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 180)
        m.postTrans(20, 0, 35)
        self.house3.setMatrix(m)

        self.house4 = viz.add('house4\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(220, 0, 235)
        self.house4.setMatrix(m)

        self.house5 = viz.add('house5\model.dae')

        m = viz.Matrix()
        m.postTrans(375, 0, 355)
        self.house5.setMatrix(m)

        self.house6 = viz.add('house6\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(107, 0, 450)
        self.house6.setMatrix(m)

        self.house7 = viz.add('house2\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(255, 0, 205)
        self.house7.setMatrix(m)

        self.house8 = viz.add('house5\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 180)
        m.postTrans(200, 0, 50)
        self.house8.setMatrix(m)

        self.house9 = viz.add('house7\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(217, 0, 365)
        self.house9.setMatrix(m)

        self.house10 = viz.add('house8\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(400, 0, 550)
        self.house10.setMatrix(m)

        self.house11 = viz.add('house9\model.dae')

        m = viz.Matrix()
        m.postTrans(375, 0, 180)
        self.house11.setMatrix(m)

        self.pizza = viz.add('pizza\model.dae')

        m = viz.Matrix()
        #m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(300, 0, 550)
        self.pizza.setMatrix(m)

        self.diner = viz.add('diner\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(260, 0, 570)
        self.diner.setMatrix(m)

        self.stop = viz.add('stop\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(100, 1, 50)
        self.stop.setMatrix(m)

        self.stop2 = viz.add('stop\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, -90)
        m.postTrans(108, 1, 57)
        self.stop2.setMatrix(m)

        self.tree = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(50, 0, 40)
        m.postScale(3, 3, 3)
        self.tree.setMatrix(m)

        self.tree2 = viz.add('tree\model.dae')
        m = viz.Matrix()
        m.postTrans(190, 0, 190)
        m.postScale(2, 2, 2)
        self.tree2.setMatrix(m)

        self.tree3 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(120, 0, 90)
        m.postScale(2, 2, 2)
        self.tree3.setMatrix(m)

        self.tree4 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(70, 0, 40)
        m.postScale(3, 3, 3)
        self.tree4.setMatrix(m)

        self.tree5 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(65, 0, 50)
        m.postScale(2, 2, 2)
        self.tree5.setMatrix(m)

        self.tree6 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(30, 0, 60)
        m.postScale(3, 3, 3)
        self.tree6.setMatrix(m)

        self.tree7 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(25, 0, 40)
        m.postScale(4, 4, 4)
        self.tree7.setMatrix(m)

        self.tree8 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(10, 0, 15)
        m.postScale(4, 4, 4)
        self.tree8.setMatrix(m)

        self.tree9 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(65, 0, 200)
        m.postScale(2, 2, 2)
        self.tree9.setMatrix(m)

        self.tree10 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(40, 0, 140)
        m.postScale(4, 4, 4)
        self.tree10.setMatrix(m)

        self.tree11 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(35, 0, 150)
        m.postScale(3, 3, 3)
        self.tree11.setMatrix(m)

        self.tree13 = viz.add('tree\model.dae')
        m = viz.Matrix()
        m.postTrans(180, 0, 190)
        m.postScale(2, 2, 2)
        self.tree13.setMatrix(m)

        self.tree14 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(120, 0, 90)
        m.postScale(2, 2, 2)
        self.tree14.setMatrix(m)

        self.tree15 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(100, 0, 40)
        m.postScale(3, 3, 3)
        self.tree15.setMatrix(m)

        self.tree16 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(165, 0, 50)
        m.postScale(2, 2, 2)
        self.tree16.setMatrix(m)

        self.tree17 = viz.add('tree2\model.dae')

        m = viz.Matrix()
        m.postTrans(100, 0, 50)
        m.postScale(2, 2, 2)
        self.tree17.setMatrix(m)

        self.tree18 = viz.add('tree3\model.dae')

        m = viz.Matrix()
        m.postTrans(90, 0, 70)
        m.postScale(2, 2, 2)
        self.tree18.setMatrix(m)

        self.road = viz.add('Roads.dae')

        self.road.ambient(.5, .5, .5)
        self.myLight.ambient(.5, .5, .5)

        #add text telling player who needs a ride

        textScreen = viz.addText('Mike needs a ride to the diner!',
                                 viz.SCREEN,
                                 pos=[0, 0, 0])
        textScreen.color(viz.BLUE)
        textScreen.fontSize(60)

        self.circ = vizshape.addSphere(radius=15.0,
                                       slices=20,
                                       stacks=20,
                                       axis=vizshape.AXIS_Y)
        self.circ.color(1, 0, 0)
        m = viz.Matrix()
        m.postTrans(350, 100, 345)
        self.circ.setMatrix(m)
Пример #3
0
def RoomCreator(length, width, height, offset):
    Room = viz.addGroup()
    room = []
    viz.startLayer(viz.QUADS)
    viz.texCoord(0, 0)
    viz.vertex(width / 2, 0, -offset)
    viz.texCoord(1, 0)
    viz.vertex(width / 2, 0, (length - offset))
    viz.texCoord(1, 1)
    viz.vertex(width / 2, height, (length - offset))
    viz.texCoord(0, 1)
    viz.vertex(width / 2, height, -offset)
    Wall_01 = viz.endLayer()

    viz.startLayer(viz.QUADS)
    viz.texCoord(0, 0)
    viz.vertex(width / 2, 0, (length - offset))
    viz.texCoord(1, 0)
    viz.vertex(0.25, 0, (length - offset))
    viz.texCoord(1, 1)
    viz.vertex(0.25, height, (length - offset))
    viz.texCoord(0, 1)
    viz.vertex(width / 2, height, (length - offset))
    Wall_02_1 = viz.endLayer()

    viz.startLayer(viz.QUADS)
    viz.texCoord(0, 0)
    viz.vertex(0.25, 2.5, (length - offset))
    viz.texCoord(1, 0)
    viz.vertex(-0.25, 2.5, (length - offset))
    viz.texCoord(1, 1)
    viz.vertex(-0.25, height, (length - offset))
    viz.texCoord(0, 1)
    viz.vertex(0.25, height, (length - offset))
    Wall_02_2 = viz.endLayer()

    viz.startLayer(viz.QUADS)
    viz.texCoord(0, 0)
    viz.vertex(-0.25, 0, (length - offset))
    viz.texCoord(1, 0)
    viz.vertex(-width / 2, 0, (length - offset))
    viz.texCoord(1, 1)
    viz.vertex(-width / 2, height, (length - offset))
    viz.texCoord(0, 1)
    viz.vertex(-0.25, height, (length - offset))
    Wall_02_3 = viz.endLayer()

    viz.startLayer(viz.QUADS)
    viz.texCoord(0, 0)
    viz.vertex(-width / 2, 0, (length - offset))
    viz.texCoord(1, 0)
    viz.vertex(-width / 2, 0, -offset)
    viz.texCoord(1, 1)
    viz.vertex(-width / 2, height, -offset)
    viz.texCoord(0, 1)
    viz.vertex(-width / 2, height, (length - offset))
    Wall_03 = viz.endLayer()

    viz.startLayer(viz.QUADS)
    viz.texCoord(0, 0)
    viz.vertex(-width / 2, 0, -offset)
    viz.texCoord(1, 0)
    viz.vertex(width / 2, 0, -offset)
    viz.texCoord(1, 1)
    viz.vertex(width / 2, height, -offset)
    viz.texCoord(0, 1)
    viz.vertex(-width / 2, height, -offset)
    Wall_04 = viz.endLayer()

    viz.startLayer(viz.QUADS)
    viz.texCoord(0, 0)
    viz.vertex(width / 2, 0, -offset)
    viz.texCoord(1, 0)
    viz.vertex(width / 2, 0, (length - offset))
    viz.texCoord(1, 1)
    viz.vertex(-width / 2, 0, (length - offset))
    viz.texCoord(0, 1)
    viz.vertex(-width / 2, 0, -offset)
    Floor = viz.endLayer()

    viz.startLayer(viz.QUADS)
    viz.texCoord(0, 0)
    viz.vertex(width / 2, height, -offset)
    viz.texCoord(1, 0)
    viz.vertex(width / 2, height, (length - offset))
    viz.texCoord(1, 1)
    viz.vertex(-width / 2, height, (length - offset))
    viz.texCoord(0, 1)
    viz.vertex(-width / 2, height, -offset)
    Ceiling = viz.endLayer()

    WallScale_small = [1, .25, 1]
    WallScale_large = [1, .25, 1]
    WallScale_w2l = [.5, .25, 1]
    AreaScale = [1, 1, 1]

    matrix_s = vizmat.Transform()
    matrix_s.setScale(WallScale_small)

    matrix_l = vizmat.Transform()
    matrix_l.setScale(WallScale_large)

    matrix_w2l = vizmat.Transform()
    matrix_w2l.setScale(WallScale_w2l)

    matrix_w2s = vizmat.Transform()
    matrix_w2s.setScale([0.04, 0.04, 1])

    matrix_area = vizmat.Transform()
    matrix_area.setScale(AreaScale)

    Wall_01.texmat(matrix_s)
    Wall_02_1.texmat(matrix_w2l)
    Wall_02_2.texmat(matrix_w2s)
    Wall_02_3.texmat(matrix_w2l)
    Wall_03.texmat(matrix_s)
    Wall_04.texmat(matrix_l)

    Floor.texmat(matrix_area)
    Ceiling.texmat(matrix_area)

    wallTex = viz.addTexture('wallTex.jpg')
    wallTex.wrap(viz.WRAP_T, viz.REPEAT)
    wallTex.wrap(viz.WRAP_S, viz.REPEAT)

    wallTex_darker = viz.addTexture('wallTex_Dark.jpg')
    wallTex_darker.wrap(viz.WRAP_T, viz.REPEAT)
    wallTex_darker.wrap(viz.WRAP_S, viz.REPEAT)

    wallTex_bright = viz.addTexture('wallTex_Brightened.jpg')
    wallTex_bright.wrap(viz.WRAP_T, viz.REPEAT)
    wallTex_bright.wrap(viz.WRAP_S, viz.REPEAT)

    room.append(Wall_01)
    room.append(Wall_02_1)
    room.append(Wall_02_2)
    room.append(Wall_02_3)
    room.append(Wall_03)
    room.append(Wall_04)
    room.append(Floor)
    room.append(Ceiling)

    room[0].texture(wallTex)
    room[4].texture(wallTex)
    room[5].texture(wallTex)

    room[1].texture(wallTex_bright)
    room[2].texture(wallTex_bright)
    room[3].texture(wallTex_bright)

    room[6].texture(wallTex_darker)
    room[7].texture(wallTex_darker)

    for i in range(8):
        room[i].setParent(Room)

    return Room
Пример #4
0
def room(high, wide, dep):
    room = viz.addGroup()
    wall_positions = (([wide / 2, 0,
                        dep / 2], [wide / 2, 0,
                                   (-dep / 2)], [wide / 2, high, (-dep / 2)],
                       [wide / 2, high,
                        dep / 2]), ([wide / 2, 0,
                                     (-dep / 2)], [-wide / 2, 0, (-dep / 2)],
                                    [-wide / 2, high,
                                     (-dep / 2)], [wide / 2, high,
                                                   (-dep / 2)]),
                      ([-wide / 2, 0,
                        (-dep / 2)], [-wide / 2, 0,
                                      dep / 2], [-wide / 2, high, dep / 2],
                       [-wide / 2, high,
                        (-dep / 2)]), ([-wide / 2, 0,
                                        dep / 2], [wide / 2, 0, dep / 2],
                                       [wide / 2, high,
                                        dep / 2], [-wide / 2, high, dep / 2]),
                      ([wide / 2, high,
                        dep / 2], [wide / 2, high,
                                   (-dep / 2)], [-wide / 2, high, (-dep / 2)],
                       [-wide / 2, high,
                        dep / 2]), ([100, 0,
                                     -100], [100, 0,
                                             100], [-100, 0,
                                                    100], [-100, 0, -100]))
    coord = ([0, 0], [1, 0], [1, 1], [0, 1])

    WallScale_small = [1, .25, 1]
    WallScale_large = [1, .25, 1]
    AreaScale = [1, 1, 1]
    AreaScale_f = [16, 16, 1]

    matrix_s = vizmat.Transform()
    matrix_s.setScale(WallScale_small)

    matrix_l = vizmat.Transform()
    matrix_l.setScale(WallScale_large)

    matrix_area_f = vizmat.Transform()
    matrix_area_f.setScale(AreaScale_f)

    matrix_area = vizmat.Transform()
    matrix_area.setScale(AreaScale)

    wallTex = viz.addTexture('wallTex.jpg')
    wallTex.wrap(viz.WRAP_T, viz.REPEAT)
    wallTex.wrap(viz.WRAP_S, viz.REPEAT)

    wallTex_darker = viz.addTexture('wallTex_Dark.jpg')
    wallTex_darker.wrap(viz.WRAP_T, viz.REPEAT)
    wallTex_darker.wrap(viz.WRAP_S, viz.REPEAT)

    wallTex_bright = viz.addTexture('wallTex_Brightened.jpg')
    wallTex_bright.wrap(viz.WRAP_T, viz.REPEAT)
    wallTex_bright.wrap(viz.WRAP_S, viz.REPEAT)

    for i in range(6):
        viz.startLayer(viz.QUADS)
        for j in range(4):
            viz.texCoord(coord[j])
            viz.vertex(wall_positions[i][j])
        wall = viz.endLayer()

        if i < 4:
            if i % 2:
                wall.texmat(matrix_s)
            else:
                wall.texmat(matrix_l)

            if i == 3:
                wall.texture(wallTex_bright)
            else:
                wall.texture(wallTex)

        else:
            if i == 5:
                wall.texmat(matrix_area_f)
            else:
                wall.texmat(matrix_area)

            wall.texture(wallTex_darker)

        wall.setParent(room)

    return room