Example #1
0
    def __init__(self, frame_width, frame_height, tiles=50):
        self.tiles = min(50, max(10, tiles))
        self.frame_dim = [frame_width, frame_height]

        # Aspect ratio
        ar = frame_height / frame_width
        #aspect_ratio_tr = tr.scale(ar, 1, 0)
        self.dimensions = [ar * 0.95 * 2 * 4 / 5, 0.95 * 2 * 4 / 5]

        gpu_tiles = [
            es.toGPUShape(bs.createColorQuad(1, 0.91, 0.84)),
            es.toGPUShape(bs.createColorQuad(0.99, 0.84, 0.61))
        ]

        tiles = []
        count = 0

        for x in range(self.tiles):
            tiles.append([])
            for y in range(self.tiles):
                tiles[x].append(sg.SceneGraphNode(f'tile{x}_{y}'))
                tiles[x][y].transform = tr.matmul([
                    tr.scale(self.dimensions[0] / self.tiles,
                             self.dimensions[1] / self.tiles, 0),
                    tr.translate(-self.tiles / 2 + x + 0.5,
                                 self.tiles / 2 - y - 0.5, 0)
                ])
                tiles[x][y].childs += [gpu_tiles[(x + y) % 2]]

        board_TR = sg.SceneGraphNode('board_TR')
        for i in range(len(tiles)):
            board_TR.childs += tiles[i]

        self.model = board_TR
def crearfondoNoche():

	gpuGrayQuad = es.toGPUShape(bs.createColorQuad(0.1, 0.1, 0.1))
	gpuSkyQuad = es.toGPUShape(bs.create2ColorQuad(1,1,1, 0.1451, 0.1569, 0.3137))
	gpuGreenQuad = es.toGPUShape(bs.createColorQuad(0.3059,0.651,0.3294))
	gpuGrayCirc = es.toGPUShape(bs.create2ColorCircle([0.6941,0.7216,0.7218],[0.8784,0.8902,0.8902]))

	#Creamos el cielo con un degradado de blanco a azul cielo 
	cielo = sg.SceneGraphNode("cielo")
	cielo.transform = tr.matmul([tr.translate(0,0.5,0),tr.scale(6,1.75,1)])
	cielo.childs += [gpuSkyQuad]

	#Creamos el camino para el auto 
	asfalto = sg.SceneGraphNode("asfalto")
	asfalto.transform = tr.matmul([tr.translate(0,-0.75,0),tr.scale(6,0.5,1)])
	asfalto.childs += [gpuGrayQuad]

	#Se crea el pasto que se vera entre los arboles 
	pasto = sg.SceneGraphNode("pasto")
	pasto.transform = tr.matmul([tr.translate(0,-0.2,0) , tr.scale(6,0.7,1)])
	pasto.childs += [gpuGreenQuad]

	#Creamos una luna en la esquina de la pantalla
	luna = sg.SceneGraphNode("luna")
	luna.transform = tr.matmul([tr.translate(1,1,0), tr.uniformScale(0.3)])
	luna.childs += [gpuGrayCirc]

	fondo = sg.SceneGraphNode("fondo")
	fondo.childs += [cielo, asfalto, pasto, luna]

	return fondo
def crearfondoDia():

	gpuGrayQuad = es.toGPUShape(bs.createColorQuad(0.2, 0.2, 0.2))
	gpuSkyQuad = es.toGPUShape(bs.create2ColorQuad(1,1,1, 0.7373, 0.9961, 1))
	gpuGreenQuad = es.toGPUShape(bs.createColorQuad(0.6706,1,0.7137))
	gpuYellowCirc = es.toGPUShape(bs.create2ColorCircle([1,0.9961,0.4392],[1,1,1]))

	#Creamos el cielo con un degradado de blanco a celeste 
	cielo = sg.SceneGraphNode("cielo")
	cielo.transform = tr.matmul([tr.translate(0,0.5,0),tr.scale(6,1.75,1)])
	cielo.childs += [gpuSkyQuad]

	#Creamos el camino para el auto 
	asfalto = sg.SceneGraphNode("asfalto")
	asfalto.transform = tr.matmul([tr.translate(0,-0.75,0),tr.scale(6,0.5,1)])
	asfalto.childs += [gpuGrayQuad]

	#Se crea el pasto que se vera entre los arboles 
	pasto = sg.SceneGraphNode("pasto")
	pasto.transform = tr.matmul([tr.translate(0,-0.2,0) , tr.scale(6,0.7,1)])
	pasto.childs += [gpuGreenQuad]

	#Creamos un sol en la esquina de la pantalla
	sol = sg.SceneGraphNode("sol")
	sol.transform = tr.matmul([tr.translate(1,1,0), tr.uniformScale(0.3)])
	sol.childs += [gpuYellowCirc]

	fondo = sg.SceneGraphNode("fondo")
	fondo.childs += [cielo, asfalto, pasto, sol]



	return fondo
Example #4
0
    def __init__(self):
        # Figuras básicas
        gpu_body_quad = es.toGPUShape(bs.createColorQuad(1, 0.8,
                                                         0.8))  # rosado
        gpu_leg_quad = es.toGPUShape(bs.createColorQuad(1, 0.5,
                                                        1))  # rosado fuerte
        gpu_eye_quad = es.toGPUShape(bs.createColorQuad(1, 1, 1))  # blanco
        # ... triangulos

        body = sg.SceneGraphNode('body')
        body.transform = tr.uniformScale(1)
        body.childs += [gpu_body_quad]

        # Creamos las piernas
        leg = sg.SceneGraphNode('leg')  # pierna generica
        leg.transform = tr.scale(0.25, 0.25, 1)
        leg.childs += [gpu_leg_quad]

        # Izquierda
        leg_izq = sg.SceneGraphNode('legLeft')
        leg_izq.transform = tr.translate(-0.5, -0.5, 0)  # tr.matmul([])..
        leg_izq.childs += [leg]

        leg_der = sg.SceneGraphNode('legRight')
        leg_der.transform = tr.translate(0.5, -.5, 0)
        leg_der.childs += [leg]

        # Ojitos
        eye = sg.SceneGraphNode('eye')
        eye.transform = tr.scale(0.25, 0.25, 1)
        eye.childs += [gpu_eye_quad]

        eye_izq = sg.SceneGraphNode('eyeLeft')
        eye_izq.transform = tr.translate(-0.3, 0.5, 0)
        eye_izq.childs += [eye]

        eye_der = sg.SceneGraphNode('eyeRight')
        eye_der.transform = tr.translate(0.3, 0.5, 0)
        eye_der.childs += [eye]

        # Ensamblamos el mono
        mono = sg.SceneGraphNode('chansey')
        mono.transform = tr.matmul(
            [tr.scale(0.4, 0.4, 0),
             tr.translate(0, -1.25, 0)])
        mono.childs += [body, leg_izq, leg_der, eye_izq, eye_der]

        transform_mono = sg.SceneGraphNode('chanseyTR')
        transform_mono.childs += [mono]

        self.model = transform_mono
        self.pos = 0
        self.lives = 3
        self.killer_eggs = []
Example #5
0
    def __init__(self):
        # Figuras básicas
        gpu_black_back = es.toGPUShape(bs.createColorQuad(0, 0, 0))
        gpu_blue_mid = es.toGPUShape(bs.createColorQuad(0, 1, 0.9))
        gpu_white_sq = es.toGPUShape(bs.createColorQuad(1, 1, 1))
        #creamos un medidor de revoluciones
        back = sg.SceneGraphNode('back')  # cuarto de circulo generico
        back.transform = tr.scale(0.25, 1, 1)
        back.childs += [gpu_black_back]

        blue = sg.SceneGraphNode('blue')
        blue.transform = tr.scale(0.23, 0.98, 0)
        blue.childs += [gpu_blue_mid]

        white = sg.SceneGraphNode('white')
        white.transform = tr.scale(0.23, 0.18, 1)
        white.childs += [gpu_white_sq]

        white1 = sg.SceneGraphNode('white1')
        white1.transform = tr.translate(0, 0.4, 0)
        white1.childs += [white]

        white2 = sg.SceneGraphNode('white2')
        white2.transform = tr.translate(0, 0.2, 0)
        white2.childs += [white]

        white3 = sg.SceneGraphNode('white3')
        white3.transform = tr.translate(0, 0, 0)
        white3.childs += [white]

        white4 = sg.SceneGraphNode('white4')
        white4.transform = tr.translate(0, -0.2, 0)
        white4.childs += [white]

        white5 = sg.SceneGraphNode('white5')
        white5.transform = tr.translate(0, -0.4, 0)
        white5.childs += [white]
        # Ensamblamos el mono
        alt = sg.SceneGraphNode('alt')
        alt.transform = tr.matmul(
            [tr.translate(-0.53, -0.7, 0),
             tr.scale(0.35, 0.5, 1)])
        alt.childs += [back, blue, white1, white2, white3, white4, white5]

        translate_alt = sg.SceneGraphNode('altTR')
        translate_alt.childs += [alt]

        self.model = alt
        self.pos = 0
Example #6
0
    def __init__(self, width, height):
        # Frame dimensions
        self.width = width
        self.height = height
        self.alive = True

        self.g_over = None

        # Outer board dimensions
        self.dimensions = [
            0.5 * self.width * 9 / 16 * 16 / 9 * 2,
            0.5 * self.height * 2 * 4 / 5
        ]
        aspect_ratio_tr = tr.scale(self.height / self.width, 1, 0)

        gpu_bground = es.toGPUShape(bs.createColorQuad(0.05, 0.55, 0.23))

        bground = sg.SceneGraphNode('background')
        bground.transform = tr.matmul([
            aspect_ratio_tr,
            tr.scale(2 * self.width / self.height, 2 * 4 / 5, 0)
        ])
        bground.childs += [gpu_bground]

        bground_tr = sg.SceneGraphNode('background_TR')
        bground_tr.childs += [bground]

        self.model = bground_tr
Example #7
0
def create_enemy(bodyColor, wingColor):
    # Generate enemy model
    # bodyColor - tuple (r, g, b)
    # wingColor - tuple (r, g, b)
    # Body
    gpuBody = es.toGPUShape(bs.createColorQuad(*bodyColor))

    # Wing
    gpuWing = es.toGPUShape(enemy_wing_shape(*wingColor))

    enemyBody = sg.SceneGraphNode("body")
    enemyBody.childs = [gpuBody]

    enemyWing1 = sg.SceneGraphNode("wing1")
    enemyWing1.transform = tr.translate(0.5, 0, 0)
    enemyWing1.childs = [gpuWing]

    enemyWing2 = sg.SceneGraphNode("wing2")
    enemyWing2.transform = tr.matmul(
        [tr.translate(-0.5, 0, 0),
         tr.scale(-1, 1, 1)])
    enemyWing2.childs = [gpuWing]

    enemy = sg.SceneGraphNode("enemyModel")
    enemy.transform = tr.uniformScale(0.08)
    enemy.childs = [enemyBody, enemyWing1, enemyWing2]

    return enemy
def crearArbol():

    #Se crean las figuras que se utilizaran
    gpuGreenTriangle = es.toGPUShape(bs.create2ColorTriangle(0.0549, 0.4549, 0.41, 0, 0.8, 0))
    gpuBrownQuad = es.toGPUShape(bs.createColorQuad(0.502, 0.251, 0))


    #Aqui se crean las partes de la copa del pino 
    copa1 = sg.SceneGraphNode("copa1")
    copa1.transform = tr.uniformScale(0.5)
    copa1.childs += [gpuGreenTriangle]
     
    copa2 = sg.SceneGraphNode("copa2")
    copa2.transform = tr.matmul([tr.uniformScale(0.4), tr.translate(0,0.3,0)])
    copa2.childs += [gpuGreenTriangle]
 
    copa3 = sg.SceneGraphNode("copa3")
    copa3.transform = tr.matmul([tr.uniformScale(0.3), tr.translate(0,0.8,0)])
    copa3.childs += [gpuGreenTriangle]

    #Aqui se crea el tronco del arbol 
    tronco = sg.SceneGraphNode("tronco")
    tronco.transform = tr.matmul ([tr.scale(0.1,0.5,0), tr.translate(0, -0.4, 0)])
    tronco.childs += [gpuBrownQuad]

    #Se juntan las partes para crear el arbol 
    arbol = sg.SceneGraphNode("car")
    arbol.childs += [tronco, copa1, copa2, copa3]

    return arbol
Example #9
0
def create_hp_block():
    # Generate hp block on GPU
    gpuBlock = es.toGPUShape(bs.createColorQuad(0.9, 0.0, 0.1))

    hpBlock = sg.SceneGraphNode("HP Block")
    hpBlock.transform = tr.scale(0.05, 0.1, 1.0)
    hpBlock.childs = [gpuBlock]

    return hpBlock
Example #10
0
def create_shot(r, g, b):
    # r,g,b - Red, green and blue values of the shot color
    gpuShot = es.toGPUShape(bs.createColorQuad(r, g, b))

    shot = sg.SceneGraphNode("shot")
    shot.transform = tr.uniformScale(0.02)
    shot.childs = [gpuShot]

    return shot
Example #11
0
def createCannon():

    gpuGrayQuad = es.toGPUShape(bs.createColorQuad(0.8, 0.8, 0.8))
    gpuDarkQuad = es.toGPUShape(bs.createColorQuad(0.3, 0.3, 0.3))

    # A cannon is made of a tunnel section and a head
    tunnel = sg.SceneGraphNode("tunnel")
    tunnel.transform = tr.scale(0.1, 0.4, 1)
    tunnel.childs += [gpuGrayQuad]

    head = sg.SceneGraphNode("head")
    head.transform = tr.matmul([tr.translate(0, -0.2, 0), tr.uniformScale(0.15)])
    head.childs += [gpuDarkQuad]

    cannon = sg.SceneGraphNode("simpleCannon")
    cannon.childs += [tunnel]
    cannon.childs += [head]

    return cannon
Example #12
0
    def __init__(self):
        # Figuras básicas
        gpu_black_back = es.toGPUShape(bs.createColorQuad(0, 0, 0))
        gpu_white_mid = es.toGPUShape(bs.createColorQuad(1, 1, 1))
        gpu_black_line = es.toGPUShape(bs.createColorQuad(0, 0, 0))
        #creamos un medidor de revoluciones
        back = sg.SceneGraphNode('back')  # cuarto de circulo generico
        back.transform = tr.scale(1.25, 1, 1)
        back.childs += [gpu_black_back]

        white = sg.SceneGraphNode('white')
        white.transform = tr.scale(1.23, 0.98, 0)
        white.childs += [gpu_white_mid]

        line = sg.SceneGraphNode('line')
        line.transform = tr.scale(1., 0.02, 0)
        line.childs += [gpu_black_line]

        line1 = sg.SceneGraphNode('line1')
        line1.childs += [line]

        line2 = sg.SceneGraphNode('line2')
        line2.transform = tr.translate(0, 0.26, 0)
        line2.childs += [line]

        line3 = sg.SceneGraphNode('line3')
        line3.transform = tr.translate(0, -0.26, 0)
        line3.childs += [line]

        # Ensamblamos el mono
        cab = sg.SceneGraphNode('cab')
        cab.transform = tr.matmul(
            [tr.translate(0.2, -0.7, 0),
             tr.uniformScale(0.34)])
        cab.childs += [back, white, line1, line2, line3]

        translate_cab = sg.SceneGraphNode('cabTR')
        translate_cab.childs += [cab]

        self.model = cab
        self.pos = 0
Example #13
0
def createBullet(player = True):

    gpuVariantQuad = es.toGPUShape(bs.createColorQuad(int(player), 1, 0))

    littleBullet = sg.SceneGraphNode("littleBullet")
    littleBullet.transform = tr.matmul([tr.rotationZ(math.pi / 4), tr.uniformScale(0.05)])
    littleBullet.childs += [gpuVariantQuad]

    bullet = sg.SceneGraphNode("bullet")
    bullet.childs += [littleBullet]

    return bullet
Example #14
0
    def __init__(self):
        gpuBlackQuad = es.toGPUShape(bs.createColorQuad(0, 0, 0))

        plataform = sg.SceneGraphNode('plataform')
        plataform.transform = tr2.scale(0.5, 0.04, 1)
        plataform.childs += [gpuBlackQuad]

        plataform_tr = sg.SceneGraphNode('plataformTR')
        plataform_tr.childs += [plataform]

        self.model = plataform_tr
        self.pos_x = 0
        self.pos_y = -1
    def __init__(self):
        gpu_egg = es.toGPUShape(bs.createColorQuad(0.7, .7, .7))

        egg = sg.SceneGraphNode('egg')
        egg.transform = tr.scale(0.1, 0.2, 1)
        egg.childs += [gpu_egg]

        egg_tr = sg.SceneGraphNode('eggTR')
        egg_tr.childs += [egg]

        self.pos_y = 1
        self.pos_x = random.choice([-1, 0, 1])  # LOGICA
        self.model = egg_tr
Example #16
0
def createEnemyShot():
    gpuRedQuad = es.toGPUShape(bs.createColorQuad(1, 0, 0))

    # Creating a single enemy shot
    enemyShot = sg.SceneGraphNode("enemyShot")
    enemyShot.transform = tr.matmul([tr.translate(enemyShip.pos_x, enemyShip.pos_y, 0), tr.scale(0.1, 0.3, 0), tr.uniformScale(0.2)])
    enemyShot.childs += [gpuRedQuad]

    enemyShots = sg.SceneGraphNode("enemyShots")
    enemyShots.childs += [enemyShot]
    enemyShots.pos_x = enemyShip.pos_x
    enemyShots.pos_y = enemyShip.pos_y

    return enemyShots
Example #17
0
def createShot():
    gpuWhiteQuad = es.toGPUShape(bs.createColorQuad(1, 1, 1))

    # Creating a single shot
    shot = sg.SceneGraphNode("shot")
    shot.transform = tr.matmul([tr.translate(ship.pos_x, ship.pos_y, 0), tr.scale(0.1, 0.3, 0), tr.uniformScale(0.2)])
    shot.childs += [gpuWhiteQuad]

    shots = sg.SceneGraphNode("shots")
    shots.childs += [shot]
    shots.pos_x = ship.pos_x
    shots.pos_y = ship.pos_y

    return shots
Example #18
0
    def __init__(self):
        # Figuras básicas
        gpu_red = es.toGPUShape(bs.createColorQuad(1, 0, 0))
        gpu_grey = es.toGPUShape(bs.createColorQuad(0.7, 0.7, 0.7))
        gpu_dark_blue = es.toGPUShape(bs.createColorQuad(0., 0.1, 0.4))
        #creamos un medidor de revoluciones
        rojo = sg.SceneGraphNode('rojo')  # cuarto de circulo generico
        rojo.transform = tr.matmul(
            [tr.translate(0.3, 0, 0),
             tr.uniformScale(0.15)])
        rojo.childs += [gpu_red]

        dblue = sg.SceneGraphNode('dblue')
        dblue.transform = tr.matmul(
            [tr.translate(0.3, -0.3, 0),
             tr.uniformScale(0.15)])
        dblue.childs += [gpu_dark_blue]

        grey = sg.SceneGraphNode('grey')
        grey.transform = tr.matmul(
            [tr.translate(0, -0.3, 0),
             tr.uniformScale(0.15)])
        grey.childs += [gpu_grey]

        # Ensamblamos el mono
        bot = sg.SceneGraphNode('bot')
        bot.transform = tr.matmul(
            [tr.translate(0.65, -0.55, 0),
             tr.scale(0.7, 1, 1)])
        bot.childs += [rojo, dblue, grey]

        translate_bot = sg.SceneGraphNode('botTR')
        translate_bot.childs += [bot]

        self.model = bot
        self.pos = 0
Example #19
0
    def __init__(self):
        gpu_nube = es.toGPUShape(bs.createColorQuad(0.8, 0.8, 0.8))

        #creamos una base y altura aleatoria para las montañas
        base = random.uniform(0.1, 0.5)
        altura = random.uniform(0.1, 0.5)

        nube = sg.SceneGraphNode('nube')
        nube.transform = tr.scale(base, altura, 1)
        nube.childs += [gpu_nube]

        nube_tr = sg.SceneGraphNode('nubeTR')
        nube_tr.childs += [nube]

        self.pos_x = 2  # LOGICA
        self.pos_y = random.uniform(0.2, 1.)
        self.model = nube_tr
Example #20
0
    def __init__(self, r):
        gpu_barra = es.toGPUShape(bs.createColorQuad(0.5, 0.5, 0.5)) #creamos un cuadrado
        
        barra = sg.SceneGraphNode('barra') #generamos un nodo para el cuadrado
        barra.transform = tr.scale(0.7,0.1, 1) #lo escalamos al tamaño que queremos 
        barra.childs += [gpu_barra]

        transform_barra1 = sg.SceneGraphNode('barraTR')# generamos un nodo para el objeto barra
        transform_barra1.childs += [barra]

        self.model = transform_barra1
        self.pos_y = 1
        
        #con esto se lee el lo que traia el archivo structure.csv y coloca barras en los unos 
        if len(r)!=0:
            p=r.pop(0)
            if p[0]=="1":
                self.pos_x=-0.7
            if p[2]=="1":
                self.pos_x=0
            if p[4]=="1":
                self.pos_x=0.7   
        self.r=r
Example #21
0
    def __init__(self, tamaño):
        self.tamaño = tamaño

        # Figuras básicas
        gpu_esquina_quad = es.toGPUShape(bs.createColorQuad(0, 0, 0))  # negro
        gpu_grilla_quad = es.toGPUShape(bs.createColorQuad(0.9, 0.9,
                                                           0.9))  # gris
        gpu_gameover = es.toGPUShape(bs.createColorQuad(0, 0, 1))  # azul

        gameover = sg.SceneGraphNode('gameover')
        gameover.transform = tr.uniformScale(2)
        gameover.child = [gpu_gameover]

        esquina_vertical = sg.SceneGraphNode('esquinaVertical')
        esquina_vertical.transform = tr.scale(d * 4 / self.tamaño, 2, 1)
        esquina_vertical.childs += [gpu_esquina_quad]

        esquina_horizontal = sg.SceneGraphNode('esquinaHorizontal')
        esquina_horizontal.transform = tr.scale(2, d * 4 / self.tamaño, 1)
        esquina_horizontal.childs += [gpu_esquina_quad]

        esquina_der = sg.SceneGraphNode('esquinaDerecha')
        esquina_der.transform = tr.translate(1, 0, 0)
        esquina_der.childs += [esquina_vertical]

        esquina_izq = sg.SceneGraphNode('esquinaIzquierda')
        esquina_izq.transform = tr.translate(-1, 0, 0)
        esquina_izq.childs += [esquina_vertical]

        esquina_sup = sg.SceneGraphNode('esquinaIzquierda')
        esquina_sup.transform = tr.translate(0, 1, 0)
        esquina_sup.childs += [esquina_horizontal]

        esquina_inf = sg.SceneGraphNode('esquinaIzquierda')
        esquina_inf.transform = tr.translate(0, -1, 0)
        esquina_inf.childs += [esquina_horizontal]

        cuadrado = sg.SceneGraphNode('cuadrado')
        cuadrado.transform = tr.uniformScale(d * 2 / self.tamaño)
        cuadrado.childs += [gpu_grilla_quad]

        grilla = sg.SceneGraphNode('grilla')
        grilla.transform = tr.translate(-1 + d * 3 / self.tamaño,
                                        1 - d * 3 / self.tamaño, 1)
        grilla.childs += [cuadrado]

        fondo = sg.SceneGraphNode('fondo')

        baseName = "cuadrado"
        for i in range(math.ceil(tamaño / 2) - 1):
            for j in range(tamaño):
                if j % 2 == 0:
                    x = -1 + d * (3 / self.tamaño + 4 * i / self.tamaño)
                    y = -1 + d * (3 / self.tamaño + 2 * j / self.tamaño)
                else:
                    x = -1 + d * (5 / self.tamaño + 4 * i / self.tamaño)
                    y = -1 + d * (3 / self.tamaño + 2 * j / self.tamaño)
                newNode = sg.SceneGraphNode(baseName + str(i))
                newNode.transform = tr.translate(x, y, 1)
                newNode.childs += [cuadrado]
                fondo.childs += [newNode]

        fondo.childs += [esquina_der, esquina_izq, esquina_sup, esquina_inf]

        self.model = fondo
Example #22
0
def createCar(r, g, b, foc=False, turbo=False):

    if not foc:  #El proposito de este if es cambiar las luces delanteras del auto, de manera que si foc != False, los focos estan prendidos (amarillos)
        rf = 0.8
        gf = 0.8
        bf = 0.8
    else:  #Aqui se aplica el color amarillo para el caso de que foc no sea False
        rf = 0.9686
        gf = 0.9412
        bf = 0

    #Se crean las figuras que se utilizaran para la creacion del auto
    gpuBlackCirc = es.toGPUShape(bs.createCircle([0, 0, 0]))
    gpuWhiteCirc = es.toGPUShape(bs.createCircle([0.8, 0.8, 0.8]))
    gpuBlueQuad = es.toGPUShape(
        bs.createColorQuad(r, g, b)
    )  #Se dejan los colores como variables para que Don Pedro pueda elegir el color de auto que mas le gusta
    gpuFocQuad = es.toGPUShape(bs.createColorQuad(rf, gf, bf))
    gpuRedQuad = es.toGPUShape(bs.createColorQuad(1, 0, 0))
    gpuSBQuad = es.toGPUShape(bs.createColorQuad(0.5922, 0.9569, 1))

    #Se crea la parte interna de la rueda de color blanco
    little_wheel = sg.SceneGraphNode("little_wheel")
    little_wheel.transform = tr.uniformScale(0.08)
    little_wheel.childs += [gpuWhiteCirc]

    # Se crea la parte negra de la rueda (la más externa)
    big_wheel = sg.SceneGraphNode("big_wheel")
    big_wheel.transform = tr.uniformScale(0.2)
    big_wheel.childs += [gpuBlackCirc]

    #Se crea la rueda completa compuesta de las dos partes anteriores
    wheel = sg.SceneGraphNode("wheel")
    wheel.childs += [big_wheel, little_wheel]

    wheelRotation = sg.SceneGraphNode("wheelRotation")
    wheelRotation.childs += [wheel]

    # Se instalan las dos ruedas en el auto
    frontWheel = sg.SceneGraphNode("frontWheel")
    frontWheel.transform = tr.translate(0.5, -0.3, 0)
    frontWheel.childs += [wheelRotation]

    backWheel = sg.SceneGraphNode("backWheel")
    backWheel.transform = tr.translate(-0.5, -0.3, 0)
    backWheel.childs += [wheelRotation]

    # Se crear el chasis del auto
    chasis = sg.SceneGraphNode("chasis")
    chasis.transform = tr.scale(1.8, 0.5, 1)
    chasis.childs += [gpuBlueQuad]

    #Se crea el techo del auto
    techo = sg.SceneGraphNode("techo")
    techo.transform = tr.matmul(
        [tr.translate(0, 0.45, 0),
         tr.scale(1, 0.5, 1)])
    techo.childs += [gpuBlueQuad]

    #Se crea el foco trasero
    foco_tras = sg.SceneGraphNode("foco_tras")
    foco_tras.transform = tr.matmul(
        [tr.translate(-0.86, 0.21, 0),
         tr.scale(0.08, 0.08, 1)])
    foco_tras.childs += [gpuRedQuad]

    #Se crea el foco delantero
    foco_del = sg.SceneGraphNode("foco_del")
    foco_del.transform = tr.matmul(
        [tr.translate(0.86, 0.21, 0),
         tr.scale(0.08, 0.08, 1)])
    foco_del.childs += [gpuFocQuad]

    #Se crean las ventanas del auto
    vent_der = sg.SceneGraphNode("vent_der")
    vent_der.transform = tr.matmul(
        [tr.translate(0.23, 0.45, 0),
         tr.scale(0.38, 0.37, 1)])
    vent_der.childs += [gpuSBQuad]

    vent_izq = sg.SceneGraphNode("vent_izq")
    vent_izq.transform = tr.matmul(
        [tr.translate(-0.23, 0.45, 0),
         tr.scale(0.38, 0.37, 1)])
    vent_izq.childs += [gpuSBQuad]

    #Se creal auto compuesto de todas las partes anteriormente creadas
    car = sg.SceneGraphNode("car")
    car.childs += [
        chasis, techo, frontWheel, backWheel, foco_tras, foco_del, vent_der,
        vent_izq
    ]

    #Se traslada y escala el auto
    scaledCar = sg.SceneGraphNode("scaledCar")
    scaledCar.transform = tr.matmul(
        [tr.translate(0, -0.66, 0),
         tr.uniformScale(0.15)])
    scaledCar.childs += [car]

    #Se crean las figras que se utilizaran para el turbo
    gpuGrayOv = es.toGPUShape(bs.createSemiCircle([0.7, 0.7, 0.7]))
    gpuBlackC = es.toGPUShape(bs.createCircle([0.2, 0.2, 0.2]))
    gpuRYC = es.toGPUShape(
        bs.create2ColorCircle([1, 0, 0], [1, 0.9961, 0.4392]))

    #La base de la turbina
    base = sg.SceneGraphNode("base")
    base.transform = tr.matmul(
        [tr.rotationZ(-np.pi / 2),
         tr.scale(0.04, 0.17, 1)])
    base.childs += [gpuGrayOv]

    baseTr = sg.SceneGraphNode("baseTr")
    baseTr.transform = tr.translate(-0.07, -0.515, 0)
    baseTr.childs += [base]

    #Se crea la parte trasera de la turbina en conjunto con el "fuego" que lo impulsa
    fin = sg.SceneGraphNode("fin")
    fin.transform = tr.matmul(
        [tr.translate(-0.07, -0.515, 0),
         tr.scale(0.02, 0.04, 1)])
    fin.childs += [gpuBlackC]

    fuego = sg.SceneGraphNode("fuego")
    fuego.transform = tr.matmul(
        [tr.translate(-0.07, -0.515, 0),
         tr.scale(0.01, 0.03, 1)])
    fuego.childs = [gpuRYC]

    #Se crea la turbina
    turboT = sg.SceneGraphNode("turbo")
    turboT.childs += [baseTr, fin, fuego]

    #Creamos una figura que va a ir cambiando los childs dependiendo de si el turbo esta activo o no
    autoFinal = sg.SceneGraphNode("autoFinal")
    autoFinal.childs += []

    if turbo == False:  #en el caso de que el turbo este desactivado se crea solo el auto escalado y trasladado
        autoFinal.childs = [scaledCar]
    elif turbo == True:  #cuando la turbina esta activa el auto se compone de la turbina y el auto escalado
        autoFinal.childs = [turboT, scaledCar]
    else:
        autoFinal.childs = []

    return autoFinal
Example #23
0
def createShip():
    gpuWhiteQuad = es.toGPUShape(bs.createColorQuad(1, 1, 1))
    gpuGreyTriangle = es.toGPUShape(bs.createColorTriangle(0.5, 0.5, 0.5))
    gpuOrangeTriangle = es.toGPUShape(bs.createColorTriangle(1, 112 / 255, 40 / 255))
    gpuYellowTriangle = es.toGPUShape(bs.createColorTriangle(1, 1, 0))
    gpuRedTriangle = es.toGPUShape(bs.createColorTriangle(1, 0, 0))


    # Creating a single orange flame
    orangeFlame = sg.SceneGraphNode("orangeFlame")
    orangeFlame.transform = tr.matmul([tr.rotationZ(np.pi), tr.uniformScale(0.1)])
    orangeFlame.childs += [gpuOrangeTriangle]

    # Instanciating 6 orange flames, for the wings and back parts
    backLeftOrangeFlame = sg.SceneGraphNode("backLeftOrangeFlame")
    backLeftOrangeFlame.transform = tr.translate(-0.11,-0.55, 0.0 )
    backLeftOrangeFlame.childs += [orangeFlame]

    backRightOrangeFlame = sg.SceneGraphNode("backRightOrangeFlame")
    backRightOrangeFlame.transform = tr.translate(0.11, -0.55, 0.0)
    backRightOrangeFlame.childs += [orangeFlame]

    leftWingLeftOrangeFlame = sg.SceneGraphNode("leftWingLeftOrangeFlame")
    leftWingLeftOrangeFlame.transform = tr.matmul([tr.translate(-0.45, -0.07, 0.0), tr.uniformScale(0.5)])
    leftWingLeftOrangeFlame.childs += [orangeFlame]

    leftWingRightOrangeFlame = sg.SceneGraphNode("leftWingRightOrangeFlame")
    leftWingRightOrangeFlame.transform = tr.matmul([tr.translate(-0.3, -0.07, 0.0), tr.uniformScale(0.5)])
    leftWingRightOrangeFlame.childs += [orangeFlame]

    rightWingLeftOrangeFlame = sg.SceneGraphNode("rightWingLeftOrangeFlame")
    rightWingLeftOrangeFlame.transform = tr.matmul([tr.translate(0.3, -0.07, 0.0), tr.uniformScale(0.5)])
    rightWingLeftOrangeFlame.childs += [orangeFlame]

    rightWingRightOrangeFlame = sg.SceneGraphNode("rightWingRightOrangeFlame")
    rightWingRightOrangeFlame.transform = tr.matmul([tr.translate(0.45, -0.07, 0.0), tr.uniformScale(0.5)])
    rightWingRightOrangeFlame.childs += [orangeFlame]


    # Creating a single yellow flame
    yellowFlame = sg.SceneGraphNode("yellowFlame")
    yellowFlame.transform = tr.matmul([tr.rotationZ(np.pi), tr.uniformScale(0.2)])
    yellowFlame.childs += [gpuYellowTriangle]

    # Instanciating 6 yellow flames, for the wings and back parts
    backLeftYellowFlame = sg.SceneGraphNode("backLeftYellowFlame")
    backLeftYellowFlame.transform = tr.translate(-0.11, -0.6, 0.0)
    backLeftYellowFlame.childs += [yellowFlame]

    backRightYellowFlame = sg.SceneGraphNode("backRightYellowFlame")
    backRightYellowFlame.transform = tr.translate(0.11, -0.6, 0.0)
    backRightYellowFlame.childs += [yellowFlame]

    leftWingLeftYellowFlame = sg.SceneGraphNode("leftWingLeftYellowFlame")
    leftWingLeftYellowFlame.transform = tr.matmul([tr.translate(-0.45, -0.1, 0.0), tr.uniformScale(0.5)])
    leftWingLeftYellowFlame.childs += [yellowFlame]

    leftWingRightYellowFlame = sg.SceneGraphNode("leftWingRightYellowFlame")
    leftWingRightYellowFlame.transform = tr.matmul([tr.translate(-0.3, -0.1, 0.0), tr.uniformScale(0.5)])
    leftWingRightYellowFlame.childs += [yellowFlame]

    rightWingLeftYellowFlame = sg.SceneGraphNode("rightWingLeftYellowFlame")
    rightWingLeftYellowFlame.transform = tr.matmul([tr.translate(0.3, -0.1, 0.0), tr.uniformScale(0.5)])
    rightWingLeftYellowFlame.childs += [yellowFlame]

    rightWingRightYellowFlame = sg.SceneGraphNode("rightWingRightYellowFlame")
    rightWingRightYellowFlame.transform = tr.matmul([tr.translate(0.45, -0.1, 0.0), tr.uniformScale(0.5)])
    rightWingRightYellowFlame.childs += [yellowFlame]


    # Creating a single wing
    wing = sg.SceneGraphNode("wing")
    wing.transform = tr.matmul([tr.translate(0, 0.3, 0), tr.scale(1.1, 0.7, 1)])
    wing.childs += [gpuGreyTriangle]


    # Creating the upper part
    upper = sg.SceneGraphNode("upper")
    upper.transform = tr.matmul([tr.translate(0, 0.7, 0), tr.uniformScale(0.5)])
    upper.childs += [gpuRedTriangle]


    # Creating the chasis of the ship
    chasis = sg.SceneGraphNode("chasis")
    chasis.transform = tr.scale(0.5, 1, 1)
    chasis.childs += [gpuWhiteQuad]


    ship = sg.SceneGraphNode("ship")
    ship.transform = tr.matmul([tr.translate(0, -0.8, 0), tr.uniformScale(0.2)])
    ship.childs += [backLeftYellowFlame]
    ship.childs += [backRightYellowFlame]
    ship.childs += [leftWingLeftYellowFlame]
    ship.childs += [leftWingRightYellowFlame]
    ship.childs += [rightWingLeftYellowFlame]
    ship.childs += [rightWingRightYellowFlame]
    ship.childs += [backLeftOrangeFlame]
    ship.childs += [backRightOrangeFlame]
    ship.childs += [leftWingLeftOrangeFlame]
    ship.childs += [leftWingRightOrangeFlame]
    ship.childs += [rightWingLeftOrangeFlame]
    ship.childs += [rightWingRightOrangeFlame]
    ship.childs += [wing]
    ship.childs += [upper]
    ship.childs += [chasis]

    translatedShip = sg.SceneGraphNode("translatedShip")
    translatedShip.childs += [ship]
    translatedShip.pos_x = controller.x
    translatedShip.pos_y = controller.y

    return translatedShip
Example #24
0
def createEnemyShip():
    gpuGreenQuad = es.toGPUShape(bs.createColorQuad(0, 1, 0))
    gpuBlueTriangle = es.toGPUShape(bs.createColorTriangle(0, 0, 1))
    gpuGreyTriangle = es.toGPUShape(bs.createColorTriangle(0.5, 0.5, 0.5))
    gpuOrangeTriangle = es.toGPUShape(bs.createColorTriangle(1, 112 / 255, 40 / 255))
    gpuYellowTriangle = es.toGPUShape(bs.createColorTriangle(1, 1, 0))

    # Creating a single orange flame
    orangeFlame = sg.SceneGraphNode("orangeFlame")
    orangeFlame.transform = tr.matmul([tr.rotationZ(np.pi), tr.uniformScale(0.1)])
    orangeFlame.childs += [gpuOrangeTriangle]

    # Instanciating 2 orange flames, for the back part
    backLeftOrangeFlame = sg.SceneGraphNode("backLeftOrangeFlame")
    backLeftOrangeFlame.transform = tr.translate(-0.11, -0.35, 0.0)
    backLeftOrangeFlame.childs += [orangeFlame]

    backRightOrangeFlame = sg.SceneGraphNode("backRightOrangeFlame")
    backRightOrangeFlame.transform = tr.translate(0.11, -0.35, 0.0)
    backRightOrangeFlame.childs += [orangeFlame]


    # Creating a single yellow flame
    yellowFlame = sg.SceneGraphNode("yellowFlame")
    yellowFlame.transform = tr.matmul([tr.rotationZ(np.pi), tr.uniformScale(0.2)])
    yellowFlame.childs += [gpuYellowTriangle]

    # Instanciating 2 yellow flames, for the back part
    backLeftYellowFlame = sg.SceneGraphNode("backLeftYellowFlame")
    backLeftYellowFlame.transform = tr.translate(-0.11, -0.4, 0.0)
    backLeftYellowFlame.childs += [yellowFlame]

    backRightYellowFlame = sg.SceneGraphNode("backRightYellowFlame")
    backRightYellowFlame.transform = tr.translate(0.11, -0.4, 0.0)
    backRightYellowFlame.childs += [yellowFlame]


    # Creating the back part
    back = sg.SceneGraphNode("wing")
    back.transform = tr.uniformScale(0.7)
    back.childs += [gpuGreyTriangle]


    # Creating the upper part
    upper = sg.SceneGraphNode("upper")
    upper.transform = tr.matmul([tr.translate(0, 0.5, 0), tr.uniformScale(0.5)])
    upper.childs += [gpuBlueTriangle]


    # Creating the chasis of the ship
    chasis = sg.SceneGraphNode("chasis")
    chasis.transform = tr.uniformScale(0.5)
    chasis.childs += [gpuGreenQuad]


    enemyShip = sg.SceneGraphNode("enemyShip")
    enemyShip.transform = tr.matmul([tr.translate(0, 2, 0), tr.rotationZ(np.pi), tr.uniformScale(0.2)])
    enemyShip.childs += [backLeftYellowFlame]
    enemyShip.childs += [backRightYellowFlame]
    enemyShip.childs += [backLeftOrangeFlame]
    enemyShip.childs += [backRightOrangeFlame]
    enemyShip.childs += [back]
    enemyShip.childs += [upper]
    enemyShip.childs += [chasis]

    translatedEnemyShip = sg.SceneGraphNode("translatedEnemyShip")
    translatedEnemyShip.childs += [enemyShip]
    translatedEnemyShip.pos_x = 1
    translatedEnemyShip.pos_y = 2

    return translatedEnemyShip
def crearEntorno():

    gpuGreenTriangle = es.toGPUShape(
        bs.create2ColorTriangle(0.3059, 0.7804, 0, 0.6706, 1, 0.7137))
    gpuGrayQuad = es.toGPUShape(bs.createColorQuad(0.5, 0.5, 0.5))
    gpuGreenQuad = es.toGPUShape(bs.createColorQuad(0.3529, 1, 0.5659))

    #Se crea un pequeño pastito
    #pastito = sg.SceneGraphNode("pastito")
    #pastito.transform = tr.uniformScale(0.08)
    #pastito.childs += [gpuGreenTriangle]

    #pastitos = sg.SceneGraphNode("pastitos")
    #baseName="pastitos"

    #for i in range(-24,25): #se crea este for para hacer una fila de pastitos
    # A new node is only locating a scaledCar in the scene depending on index i
    #newNode = sg.SceneGraphNode(baseName + str(i))
    #newNode.transform = tr.translate(0.04 * i, 0, 0)
    #newNode.childs += [pastito]

    # Now this car is added to the 'cars' scene graph
    #pastitos.childs += [newNode]

    #pastitos2 = sg.SceneGraphNode("pastitos2")
    #baseName="pastitos2"

    #for i in range(-15,12): #el objetivo de este for es multiplicar las filas de pastitos

    #newNode = sg.SceneGraphNode(baseName + str(i))
    #newNode.transform = tr.translate(0.01*(-1)**i,-0.02*i , 0)
    #newNode.childs += [pastitos]

    #pastitos2.childs += [newNode]

    #Toda la parte comentada era mi idea de hacer un pasto mas "realista" con los materiales que hemos visto hasta el
    #momento pero era mucho trabajo para el computador por lo que la imagen estaba cortada cuando se reproducía

    #Esta es la opcion B del pasto
    pasto = sg.SceneGraphNode("pasto")
    pasto.transform = tr.matmul(
        [tr.translate(0, -0.035, 0),
         tr.scale(2, 0.45, 1)])
    pasto.childs += [gpuGreenQuad]

    #Se crea el muro de la derecha
    murod = sg.SceneGraphNode("murod")
    murod.transform = tr.matmul(
        [tr.translate(1, 0.04, 0),
         tr.scale(0.08, 0.6, 1)])
    murod.childs += [gpuGrayQuad]

    #Se crea el muro de la izquierda
    muroi = sg.SceneGraphNode("muroi")
    muroi.transform = tr.matmul(
        [tr.translate(-1, 0.04, 0),
         tr.scale(0.08, 0.6, 1)])
    muroi.childs += [gpuGrayQuad]

    #Se crea el muro de la divisor
    murodiv = sg.SceneGraphNode("murodiv")
    murodiv.transform = tr.matmul(
        [tr.translate(0, 0.04, 0),
         tr.scale(0.08, 0.6, 1)])
    murodiv.childs += [gpuGrayQuad]

    #Se crea el muro trasero
    murot = sg.SceneGraphNode("murot")
    murot.transform = tr.matmul(
        [tr.translate(0, 0.09, 0),
         tr.scale(2, 0.5, 1)])
    murot.childs += [gpuGrayQuad]

    entorno = sg.SceneGraphNode("entorno")
    entorno.childs += [murot, pasto, murod, muroi, murodiv]

    return entorno
Example #26
0
def crearNave():

	gpuBCirc = es.toGPUShape(bs.createCircle([0,0.4627,0.4118]))
	gpuBlackCirc = es.toGPUShape(bs.createCircle([0,0,0]))
	gpuSBCirc = es.toGPUShape(bs.createSemiCircle([0,0,0]))
	gpuSGreenCirc = es.toGPUShape(bs.createSemiCircle([0.4392,1,0.4078]))
	gpuGreenCirc = es.toGPUShape(bs.createCircle([0.4392,1,0.4078]))
	gpuBlackQuad = es.toGPUShape(bs.createColorQuad(0,0,0))
	gpuGreenQuad = es.toGPUShape(bs.createColorQuad(0.4392,1,0.4078))

	#Se crea la parte mas grande de la nave (asi como el chasis de auto)
	base = sg.SceneGraphNode("base")
	base.transform = tr.scale(0.5,0.08,0)
	base.childs += [gpuBCirc]

	#Creamos el "vidrio" de la nave, que es la parte donde podemos ver al marcianito, se crea negro para que sea mas facil ver la nave 
	#y al marciano debido a que con los colores del fondo la nave se pierde 
	vidrio = sg.SceneGraphNode("vidrio")
	vidrio.transform = tr.matmul([tr.translate(0,0.02,0),tr.scale(0.2,0.35,0)])
	vidrio.childs += [gpuSBCirc]

	#Se crean las patas de la nave, compuestas por una bolita negra y un rectangulo del mismo color 
	pataIzq = sg.SceneGraphNode("pataIzq")
	pataIzq.transform = tr.matmul([tr.rotationZ(np.pi/5) ,tr.scale(0.02,0.25,0)])
	pataIzq.childs += [gpuBlackQuad]

	pataDer = sg.SceneGraphNode("pataDer")
	pataDer.transform = tr.matmul([tr.rotationZ(-(np.pi/5)) ,tr.scale(0.02,0.25,0)])
	pataDer.childs += [gpuBlackQuad]

	pataItras = sg.SceneGraphNode("pataItras")
	pataItras.transform = tr.translate(0.3,-0.1,0)
	pataItras.childs += [pataIzq]

	pataDtras = sg.SceneGraphNode("pataDtras")
	pataDtras.transform = tr.translate(-0.3,-0.1,0)
	pataDtras.childs += [pataDer]

	finPataI = sg.SceneGraphNode("finPataI")
	finPataI.transform = tr.matmul([tr.translate(0.375,-0.2,0) ,tr.uniformScale(0.025)])
	finPataI.childs += [gpuBlackCirc]

	finPataD = sg.SceneGraphNode("finPataD")
	finPataD.transform = tr.matmul([tr.translate(-0.375,-0.2,0) ,tr.uniformScale(0.025)])
	finPataD.childs += [gpuBlackCirc]

	pataD = sg.SceneGraphNode("pataD")
	pataD.childs += [pataDtras, finPataD]

	pataI = sg.SceneGraphNode("pataI")
	pataI.childs += [pataItras, finPataI]

	#Creamos al marcianito 

	#Se crea primero el cuerpo
	cuerpoTripulacion = sg.SceneGraphNode("cuerpoTripulacion")
	cuerpoTripulacion.transform = tr.matmul([tr.translate(0,0.02,0), tr.scale(0.03,0.06,0)]) 
	cuerpoTripulacion.childs += [gpuSGreenCirc]

	#Creamos la cabeza
	cabezaTripulacion = sg.SceneGraphNode("cabezaTripulacion")
	cabezaTripulacion.transform = tr.matmul([tr.translate(0,0.12,0) , tr.uniformScale(0.04)])
	cabezaTripulacion.childs += [gpuGreenCirc]

	#Aqui creamos las antenas completas del marcianito, con una idea muy parecida a las patas de la nave
	antenaD = sg.SceneGraphNode("antenaD")
	antenaD.transform = tr.matmul([tr.translate(0.017,0.165,0) ,tr.scale(0.01,0.025,0)])
	antenaD.childs += [gpuGreenQuad]

	antenaI = sg.SceneGraphNode("antenaI")
	antenaI.transform = tr.matmul([tr.translate(-0.017,0.165,0),tr.scale(0.01,0.025,0)])
	antenaI.childs += [gpuGreenQuad]

	finAnD = sg.SceneGraphNode("finAnD")
	finAnD.transform = tr.matmul([tr.translate(0.017,0.19,0) , tr.uniformScale(0.015)])
	finAnD.childs = [gpuGreenCirc]

	finAnI = sg.SceneGraphNode("finAnI")
	finAnI.transform = tr.matmul([tr.translate(-0.017,0.19,0) , tr.uniformScale(0.015)])
	finAnI.childs = [gpuGreenCirc]		

	#Se  crea la nave en conjunto con la tripulacion
	nave = sg.SceneGraphNode("nave")
	nave.transform = tr.matmul([tr.translate(0,0.7,0) , tr.uniformScale(0.1)])
	nave.childs += [pataI, pataD, base, vidrio, cuerpoTripulacion, cabezaTripulacion, antenaD, antenaI, finAnD, finAnI]

	#Se crea esto para luego poder trasladar la nave en la parte final 
	navef = sg.SceneGraphNode("navef")
	navef.childs += [nave]


	return navef
Example #27
0
    def __init__(self):
        # Figuras básicas
        gpu_quarter_circle = es.toGPUShape(bs.createQuarterCircle())
        gpu_indicator_line = es.toGPUShape(bs.createColorQuad(1.0, 1.0, 1.0))
        gpu_center = es.toGPUShape(bs.createColorQuad(1, 1, 1))
        #creamos un medidor de revoluciones
        qvel = sg.SceneGraphNode('qvel')  # cuarto de circulo generico
        qvel.transform = tr.scale(0.25, 0.25, 1)
        qvel.childs += [gpu_quarter_circle]
        q1vel = sg.SceneGraphNode('q1vel')
        q1vel.childs += [qvel]
        q2vel = sg.SceneGraphNode('q2vel')
        q2vel.transform = tr.rotationZ(1.57)
        q2vel.childs += [qvel]
        q3vel = sg.SceneGraphNode('q3vel')
        q3vel.transform = tr.rotationZ(3.14)
        q3vel.childs += [qvel]
        q4vel = sg.SceneGraphNode('q4vel')
        q4vel.transform = tr.rotationZ(-1.57)
        q4vel.childs += [qvel]
        #un centro
        centro = sg.SceneGraphNode('centro')
        centro.transform = tr.uniformScale(0.02)
        centro.childs += [gpu_center]
        #hacemos los grados
        raya = sg.SceneGraphNode('raya')
        raya.childs += [gpu_indicator_line]
        raya1 = sg.SceneGraphNode('raya1')
        raya1.transform = tr.matmul(
            [tr.translate(0, 0.21, 0),
             tr.scale(0.005, 0.08, 1)])
        raya1.childs += [raya]
        raya2 = sg.SceneGraphNode('raya2')
        raya2.transform = tr.matmul([
            tr.translate(0.206, 0, 0),
            tr.rotationZ(1.58),
            tr.scale(0.005, 0.08, 1)
        ])
        raya2.childs += [raya]
        raya3 = sg.SceneGraphNode('raya3')
        raya3.transform = tr.matmul([
            tr.translate(-0.206, 0, 0),
            tr.rotationZ(1.58),
            tr.scale(0.005, 0.08, 1)
        ])
        raya3.childs += [raya]
        raya4 = sg.SceneGraphNode('raya4')
        raya4.transform = tr.matmul([
            tr.translate(-0.15, 0.15, 0),
            tr.rotationZ(0.5),
            tr.scale(0.005, 0.08, 1)
        ])
        raya4.childs += [raya]
        raya5 = sg.SceneGraphNode('raya5')
        raya5.transform = tr.matmul([
            tr.translate(0.15, 0.15, 0),
            tr.rotationZ(-0.5),
            tr.scale(0.005, 0.08, 1)
        ])
        raya5.childs += [raya]
        raya6 = sg.SceneGraphNode('raya6')
        raya6.transform = tr.matmul([
            tr.translate(0.15, -0.15, 0),
            tr.rotationZ(0.5),
            tr.scale(0.005, 0.08, 1)
        ])
        raya6.childs += [raya]
        raya7 = sg.SceneGraphNode('raya7')
        raya7.transform = tr.matmul([
            tr.translate(-0.15, -0.15, 0),
            tr.rotationZ(-0.5),
            tr.scale(0.005, 0.08, 1)
        ])
        raya7.childs += [raya]
        # Ensamblamos el mono
        rev = sg.SceneGraphNode('rev')
        rev.transform = tr.matmul(
            [tr.translate(-0.25, -0.7, 0),
             tr.scale(0.7, 1, 1)])
        rev.childs += [
            q1vel, q2vel, q3vel, q4vel, centro, raya1, raya2, raya3, raya4,
            raya5, raya6, raya7
        ]
        translate_rev = sg.SceneGraphNode('revTR')
        translate_rev.childs += [rev]

        self.model = rev
        self.pos = 0
Example #28
0
    def __init__(self):
        #creamos el avion

        # Figuras básicas
        gpu_body_quad = es.toGPUShape(bs.createColorQuad(0.65, 0.65,
                                                         0.65))  # gris
        gpu_tail_triangle = es.toGPUShape(
            bs.createColorTriangle(0.65, 0.65, 0.65))  # gris
        gpu_nose_triangle = es.toGPUShape(
            bs.createColorTriangle(0.65, 0.65, 0.65))  # gris
        gpu_wing_quad = es.toGPUShape(bs.createColorQuad(1, 0.5,
                                                         0.5))  # gris oscuro
        gpu_window_quad = es.toGPUShape(bs.createColorQuad(0, 1,
                                                           0.86))  # celeste

        #creamos el "cuerpo"

        body = sg.SceneGraphNode('body')
        body.transform = tr.scale(2.5, 0.7,
                                  1)  #alargamos el "cuerpo" del avion
        body.childs += [gpu_body_quad]

        # Creamos las ventanas
        window = sg.SceneGraphNode('window')  # ventana generica
        window.transform = tr.scale(0.25, 0.25, 1)
        window.childs += [gpu_window_quad]

        # prueba dos ventanas
        window_1 = sg.SceneGraphNode('window_1')
        window_1.transform = tr.translate(1, 0.14, 0)  # tr.matmul([])..
        window_1.childs += [window]

        window_2 = sg.SceneGraphNode('window_2')
        window_2.transform = tr.translate(0.65, 0.14, 0)  # tr.matmul([])..
        window_2.childs += [window]

        window_3 = sg.SceneGraphNode('window_3')
        window_3.transform = tr.translate(0.3, 0.14, 0)  # tr.matmul([])..
        window_3.childs += [window]

        # cola
        tail = sg.SceneGraphNode('tail')  #ventana generica
        tail.transform = tr.rotationZ(
            0.46
        )  #dejamos el borde trasero del triangulo ortogonal al cuerpo uwu
        tail.childs += [gpu_tail_triangle]

        tail_back = sg.SceneGraphNode('eyeLeft')
        tail_back.transform = tr.matmul(
            [tr.translate(-1.0092, 0.4, 0),
             tr.scale(1.1, 1.1, 0)])
        tail_back.childs += [tail]

        # nariz
        nose = sg.SceneGraphNode('nose')  #ventana generica
        nose.transform = tr.matmul([
            tr.rotationZ(0.465),
            tr.translate(1.26, -0.55, 0),
            tr.scale(0.64, 0.64, 0)
        ])
        nose.childs += [gpu_nose_triangle]

        #ala
        wing = sg.SceneGraphNode('wing')
        wing.transform = tr.matmul([
            tr.rotationZ(-0.55),
            tr.translate(0.1, -0.5, 0),
            tr.scale(0.3, 1, 0)
        ])
        wing.childs += [gpu_wing_quad]

        self.a = 0  #indica la aceleración del avión

        # Ensamblamos el mono
        mono = sg.SceneGraphNode('chansey')
        mono.transform = tr.matmul(
            [tr.scale(0.1, 0.2, 0),
             tr.translate(-8, -1.6, 0)])
        mono.childs += [
            body, window_1, window_2, window_3, tail_back, nose, wing
        ]

        transform_mono = sg.SceneGraphNode('chanseyTR')
        transform_mono.childs += [mono]

        self.model = transform_mono
        self.pos = 0  #posicion de la tecla, 1=> acelerando, -1=> desacelerando, 0=>cayendo
Example #29
0
def create_scene():
    gpu_cuchillo = os.toGPUShape(bs.createColorCuchillo(1, 1, 0))
    gpu_green_triangle = os.toGPUShape(bs.createColorTriangle(0, 1, 0))
    gpu_yellow_triangle = os.toGPUShape(bs.createColorTriangle(1, 1, 0))
    gpu_green_quad = es.toGPUShape(bs.createColorQuad(1, 1, 0))
    gpu_yellow_quad = es.toGPUShape(bs.createColorQuad(0, 1, 0))
    gpu_yellow_d = es.toGPUShape(bs.createColorD(0, 1, 0))

    # El cuchillo
    cuchillo = sg.SceneGraphNode('cuchillo')
    cuchillo.transform = tr.matmul([
        tr.translate(-8 / 15, -1 / 22, 0),
        tr.scale(3, 3, 1),
        tr.rotationZ(180)
    ])
    cuchillo.childs += [gpu_cuchillo]

    # La mesa
    mc1 = sg.SceneGraphNode('mc1')
    mc1.transform = tr.scale(4, 4, 1)
    mc1.childs += [gpu_yellow_quad]

    mt1 = sg.SceneGraphNode('mt1')
    mt1.transform = tr.translate(-1 / 15, -3 / 22, 0)
    mt1.childs += [gpu_yellow_quad]

    mt2 = sg.SceneGraphNode('mt2')
    mt2.transform = tr.translate(1 / 15, -3 / 22, 0)
    mt2.childs += [gpu_yellow_quad]

    MesaT = sg.SceneGraphNode('MesaT')
    MesaT.childs += [mt1, mt2]
    MesaT.transform = tr.scale(2, 2, 1)

    Mesa = sg.SceneGraphNode('Mesa')
    Mesa.childs += [MesaT, mc1]
    Mesa.transform = tr.matmul([
        tr.translate(5 / 15, 8 / 22, 0),
        tr.scale(2, 1.5, 1),
        tr.rotationZ(180)
    ])

    # El Árbol
    ac1 = sg.SceneGraphNode('ac1')
    ac1.transform = tr.scale(2, 2, 1)
    ac1.childs += [gpu_green_quad]

    at1 = sg.SceneGraphNode('at1')
    at1.transform = tr.translate(-1 / 15, 0, 0)
    at1.childs += [gpu_green_triangle]

    at2 = sg.SceneGraphNode('at2')
    at2.transform = tr.translate(1 / 15, 0, 0)
    at2.childs += [gpu_green_triangle]

    Rama1 = sg.SceneGraphNode('Rama1')
    Rama1.childs += [at1, at2]
    Rama1.transform = tr.translate(0, 4 / 22, 0)

    at3 = sg.SceneGraphNode('at3')
    at3.transform = tr.translate(-1 / 15, 0, 0)
    at3.childs += [gpu_green_triangle]

    at4 = sg.SceneGraphNode('at4')
    at4.transform = tr.translate(1 / 15, 0, 0)
    at4.childs += [gpu_green_triangle]

    Rama2 = sg.SceneGraphNode('Rama2')
    Rama2.childs += [at3, at4]
    Rama2.transform = tr.translate(0, 2 / 22, 0)

    ArbolT = sg.SceneGraphNode('ArbolT')
    ArbolT.childs += [Rama1, Rama2]
    ArbolT.transform = tr.scale(2, 2, 1)

    Arbol = sg.SceneGraphNode('Arbol')
    Arbol.childs += [ArbolT, ac1]
    Arbol.transform = tr.matmul([
        tr.translate(6 / 15, -13 / 22, 0),
        tr.scale(4, 2, 1),
        tr.rotationZ(360)
    ])

    # La Firma

    d = sg.SceneGraphNode('d')
    d.transform = tr.translate(7 / 22, 0, 0)
    d.childs += [gpu_yellow_d]

    i1 = sg.SceneGraphNode('i1')
    i1.transform = tr.matmul(
        [tr.translate(-1 / 15, 3.5 / 22, 0),
         tr.scale(1, 6, 1)])
    i1.childs += [gpu_green_quad]

    i2 = sg.SceneGraphNode('i2')
    i2.transform = tr.matmul(
        [tr.translate(-1 / 15, 0.5 / 22, 0),
         tr.scale(2, 5, 1)])
    i2.childs += [gpu_green_quad]

    i3 = sg.SceneGraphNode('i3')
    i3.transform = tr.matmul(
        [tr.translate(-1 / 15, -2.5 / 22, 0),
         tr.scale(1, 6, 1)])
    i3.childs += [gpu_green_quad]

    i = sg.SceneGraphNode('i')
    i.childs += [i1, i2, i3]

    Firma = sg.SceneGraphNode('Firma')
    Firma.childs += [i, d]
    Firma.transform = tr.matmul([tr.translate(-10 / 15, 19 / 22, 0)])

    # El Cepillo de Dientes

    ct1 = sg.SceneGraphNode('ct1')
    ct1.transform = tr.translate(0, 1 / 22, 0)
    ct1.childs += [gpu_green_triangle]

    ct2 = sg.SceneGraphNode('ct2')
    ct2.transform = tr.translate(0, 3 / 22, 0)
    ct2.childs += [gpu_green_triangle]

    ct3 = sg.SceneGraphNode('ct3')
    ct3.transform = tr.translate(0, 5 / 22, 0)
    ct3.childs += [gpu_green_triangle]

    CepilloT = sg.SceneGraphNode('CepilloT')
    CepilloT.childs += [ct1, ct2, ct3]
    CepilloT.transform = tr.matmul(
        [tr.translate(-3 / 15, 0, 0),
         tr.scale(2, 2, 1)])

    cc1 = sg.SceneGraphNode('cc1')
    cc1.transform = tr.translate(0, 5 / 22, 0)
    cc1.childs += [gpu_green_quad]

    cc2 = sg.SceneGraphNode('cc2')
    cc2.transform = tr.translate(0, 3 / 22, 0)
    cc2.childs += [gpu_green_quad]

    cc3 = sg.SceneGraphNode('cc3')
    cc3.transform = tr.translate(0, 1 / 22, 0)
    cc3.childs += [gpu_green_quad]

    cc4 = sg.SceneGraphNode('cc4')
    cc4.transform = tr.translate(0, -1 / 22, 0)
    cc4.childs += [gpu_green_quad]

    cc5 = sg.SceneGraphNode('cc5')
    cc5.transform = tr.translate(0, -3 / 22, 0)
    cc5.childs += [gpu_green_quad]

    cc6 = sg.SceneGraphNode('cc6')
    cc6.transform = tr.translate(0, -5 / 22, 0)
    cc6.childs += [gpu_green_quad]

    CepilloC = sg.SceneGraphNode('CepilloC')
    CepilloC.childs += [ct1, ct2, ct3]
    CepilloC.transform = tr.matmul(
        [tr.translate(-1 / 15, 0, 0),
         tr.scale(2, 2, 1)])

    Cepillo = sg.SceneGraphNode('Cepillo')
    Cepillo.childs += [CepilloT, CepilloC]
    Cepillo.transform = tr.matmul([
        tr.translate(2 / 15, -20 / 22, 0),
        tr.scale(0.5, 1.5, 1),
        tr.rotationZ(90)
    ])

    # el Mundo
    mundo = sg.SceneGraphNode('mundo')
    mundo.childs += [Mesa, Arbol, Cepillo, cuchillo, Firma]

    return mundo
def crearCasa(pos):

    gpuBeigeQuad = es.toGPUShape(bs.createColorQuad(1, 0.8667, 0.749))
    gpuRedTriangle = es.toGPUShape(bs.createColorTriangle(1, 0.1961, 0.4314))
    gpuSBQuad = es.toGPUShape(bs.createColorQuad(0.6588, 0.9686, 1))
    gpuOrangeQuad = es.toGPUShape(bs.createColorQuad(1, 0.5176, 0.3412))
    gpuBlackCirc = es.toGPUShape(bs.createCircle([0, 0, 0]))
    gpuBrownQuad = es.toGPUShape(bs.createColorQuad(0.6039, 0.2039, 0))
    gpuPQuad = es.toGPUShape(bs.createColorQuad(0.8392, 0.749, 1))

    #Se crea la base de la casa
    base = sg.SceneGraphNode("base")
    base.transform = tr.uniformScale(0.4)
    base.childs += [gpuBeigeQuad]

    # Se crea el techo de la casa
    techo = sg.SceneGraphNode("techo")
    techo.transform = tr.matmul(
        [tr.translate(0, 0.3, 0),
         tr.scale(0.6, 0.2, 1)])
    techo.childs += [gpuRedTriangle]

    #Se crean las ventanas con sus respectivos marcos
    ventD = sg.SceneGraphNode("ventD")
    ventD.transform = tr.matmul(
        [tr.translate(0.1, 0.1, 0),
         tr.uniformScale(0.1)])
    ventD.childs += [gpuSBQuad]

    marcoVD = sg.SceneGraphNode("marcoVD")
    marcoVD.transform = tr.matmul(
        [tr.translate(0.1, 0.1, 0),
         tr.uniformScale(0.12)])
    marcoVD.childs += [gpuBrownQuad]

    ventI = sg.SceneGraphNode("ventI")
    ventI.transform = tr.matmul(
        [tr.translate(-0.1, 0.1, 0),
         tr.uniformScale(0.1)])
    ventI.childs += [gpuSBQuad]

    marcoVI = sg.SceneGraphNode("marcoVI")
    marcoVI.transform = tr.matmul(
        [tr.translate(-0.1, 0.1, 0),
         tr.uniformScale(0.12)])
    marcoVI.childs += [gpuBrownQuad]

    #Se crea la puerta
    puerta = sg.SceneGraphNode("puerta")
    puerta.transform = tr.matmul(
        [tr.scale(0.1, 0.2, 1),
         tr.translate(0, -0.5, 0)])
    puerta.childs += [gpuOrangeQuad]

    #Se crea el marco de la puerta
    marcoP = sg.SceneGraphNode("marcoP")
    marcoP.transform = tr.matmul(
        [tr.scale(0.12, 0.21, 1),
         tr.translate(0, -0.45, 0)])
    marcoP.childs += [gpuBrownQuad]

    #Se crea la manilla de la puerta
    mani = sg.SceneGraphNode("mani")
    mani.transform = tr.matmul(
        [tr.translate(-0.03, -0.1, 0),
         tr.uniformScale(0.009)])
    mani.childs += [gpuBlackCirc]

    #Se crea un camino de entrada a la casa
    camino = sg.SceneGraphNode("camino")
    camino.transform = tr.matmul(
        [tr.translate(0, -0.23, 0),
         tr.scale(0.12, 0.06, 1)])
    camino.childs += [gpuPQuad]

    #Se crea la casa con todas su componentes
    casa = sg.SceneGraphNode("casa")
    casa.childs += [
        base, techo, marcoVD, ventD, marcoVI, ventI, marcoP, puerta, mani,
        camino
    ]

    #Trasladamos la casa segun la posicion que se le indique
    traslatedCasa = sg.SceneGraphNode("traslatedCar")
    traslatedCasa.transform = tr.translate(pos, 0, 0)
    traslatedCasa.childs += [casa]

    return traslatedCasa