def __init__(self): self.pos = [[0, 0], [0, 0]] self.estado = 'Sana' gpu_triangulo_cian = es.toGPUShape(bs.createColorTriangle( 0, 0.5, 0.95)) triangulo_cian = sg.SceneGraphNode('triangulo') triangulo_cian.transform = tr.uniformScale(0.05) triangulo_cian.childs = [gpu_triangulo_cian] persona = sg.SceneGraphNode('persona') persona.childs = [triangulo_cian] self.model = persona
def __init__(self): gpu_egg = es.toGPUShape(bs.createColorTriangle(0.47, .19, .0)) #creamos una base y altura aleatoria para las montañas base = random.uniform(0.5, 3) altura = random.uniform(0.5, 2) egg = sg.SceneGraphNode('egg') egg.transform = tr.scale(base, altura, 1) egg.childs += [gpu_egg] egg_tr = sg.SceneGraphNode('eggTR') egg_tr.childs += [egg] self.pos_x = 3 # LOGICA self.pos_y = -0.2 self.model = egg_tr
def __init__(self, tamaño): self.tamaño = tamaño gpu_circulo = es.toGPUShape(bs.createCircle(d / self.tamaño)) # rojo gpu_triangulo = es.toGPUShape(bs.createColorTriangle(0, 0.8, 0)) #verde coronta = sg.SceneGraphNode('coronta') coronta.childs += [gpu_circulo] hoja = sg.SceneGraphNode('hoja') hoja.transform = tr.matmul( [tr.uniformScale(d / self.tamaño), tr.translate(0, 0.6, 0)]) hoja.childs += [gpu_triangulo] self.pos_x = -1 + d * 3 / self.tamaño + d * 2 / self.tamaño * random.randint( 0, self.tamaño - 3) self.pos_y = -1 + d * 3 / self.tamaño + d * 2 / self.tamaño * random.randint( 0, self.tamaño - 3) manzana = sg.SceneGraphNode('manzana') manzana.childs += [coronta, hoja] self.model = manzana
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 enfermar(self): gpu_triangulo_rojo = es.toGPUShape(bs.createColorTriangle(1, 0, 0)) self.estado = 'Enferma' triangulo = sg.findNode(self.model, 'triangulo') triangulo.childs = [gpu_triangulo_rojo]
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
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 __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
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