Exemplo n.º 1
0
    aquariumBorder = bs.Shape([], [])
    for i in range(X.shape[0] - 1):
        for j in range(X.shape[1] - 1):
            for k in range(X.shape[2] - 1):
                if ((i == 0 or i == X.shape[0] - 2) and (
                        j == 0 or j == X.shape[1] - 2 or k == 0 or k == X.shape[2] - 2)) or (
                        (j == 0 or j == X.shape[1] - 2) and (
                        i == 0 or i == X.shape[0] - 2 or k == 0 or k == X.shape[2] - 2)) or (
                        (j == 0 or j == X.shape[1] - 2 or i == 0 or i == X.shape[0] - 2) and (
                        k == 0 or k == X.shape[2] - 2)):
                    temp_shape = createColorCube2(i, j, k, X, Y, Z, 1.0, 1.0, 1.0)
                    merge(aquariumBorder, 6, temp_shape)

    gpu_surfaceA = es.toGPUShape(isosurfaceA)
    surfaceA = sg.SceneGraphNode('surfaceA')
    surfaceA.transform = tr.translate(-20, -10, -10)
    surfaceA.childs += [gpu_surfaceA]
    scaledSurfaceA = sg.SceneGraphNode('scaledSurfaceA')
    scaledSurfaceA.transform = tr.uniformScale(0.5)
    scaledSurfaceA.childs += [surfaceA]

    gpu_surfaceB = es.toGPUShape(isosurfaceB)
    surfaceB = sg.SceneGraphNode('surfaceB')
    surfaceB.transform = tr.translate(-20, -10, -10)
    surfaceB.childs += [gpu_surfaceB]
    scaledSurfaceB = sg.SceneGraphNode('scaledSurfaceB')
    scaledSurfaceB.transform = tr.uniformScale(0.5)
    scaledSurfaceB.childs += [surfaceB]

    gpu_surfaceC = es.toGPUShape(isosurfaceC)
Exemplo n.º 2
0
    def __init__(self,
                 color,
                 radius,
                 distance,
                 velocity,
                 satellites,
                 parent=None):
        self.selected = False
        self.color = color
        self.radius = radius
        self.distance = distance
        self.velocity = velocity
        self.parent = parent
        if parent is None:
            self.parent_x = 0
            self.parent_y = 0
        else:
            self.parent_x = parent.get_x()
            self.parent_y = parent.get_y()
        self.satellites = satellites  # Lista de jsons
        self.satellites_objects = []
        self.satellites_nodes = []
        self.orbit_color = [x / 2 for x in color]
        self.x = 0 + self.parent_x
        self.x2 = self.x
        self.y = 1 * distance + self.parent_y
        self.y2 = self.y
        self.zoom = 1

        # Figuras básicas
        gpu_body_circle = es.toGPUShape(s.createColorCircle(*self.color))
        gpu_orbit_circumference = es.toGPUShape(
            s.createColorCircumference(*self.orbit_color))
        gpu_selection = es.toGPUShape(s.createColorCircle(1, 1, 1))

        # Create Satellites
        if satellites != "Null":
            for cuerpo in satellites:
                new_cuerpo = Cuerpo(cuerpo['Color'], cuerpo['Radius'],
                                    cuerpo['Distance'], cuerpo['Velocity'],
                                    cuerpo['Satellites'], self)
                self.satellites_objects.append(new_cuerpo)
                self.satellites_nodes.append(new_cuerpo.get_model())

        # Orbita
        # The circumference and it's scale
        orbit_circumference = sg.SceneGraphNode('orbit')
        orbit_circumference.transform = tr.uniformScale(distance)
        orbit_circumference.childs += [gpu_orbit_circumference]

        # Then the translation
        orbit = sg.SceneGraphNode('orbit')
        orbit.transform = tr.translate(self.parent_x, self.parent_y, 0)
        orbit.childs += [orbit_circumference]

        # Selection circle
        selection = sg.SceneGraphNode('selection_circle')
        selection.transform = tr.uniformScale(0)
        selection.childs += [gpu_selection]

        # Cuerpo
        # The circle and it's scale
        body_circle = sg.SceneGraphNode('body_circle')
        body_circle.transform = tr.uniformScale(self.radius)
        body_circle.childs += [gpu_body_circle]

        # Then the translation
        body = sg.SceneGraphNode('body')
        body.transform = tr.translate(self.x, self.y, 0)
        body.childs += [selection, body_circle]

        # Satellites
        satellites_node = sg.SceneGraphNode('satellites')
        satellites_node.transform = tr.translate(self.parent_x, self.parent_y,
                                                 0)
        satellites_node.childs += [*self.satellites_nodes]

        # Ensamble
        planeta = sg.SceneGraphNode('Planeta')
        planeta.childs += [orbit, body, satellites_node]

        transform_planeta = sg.SceneGraphNode('planetaTR')
        transform_planeta.childs += [planeta]

        self.model = transform_planeta
def crearCurso(cubo):

	cuboRojo = cubo


	#Aqui se comienzan a crear los cursos 

	#Primer año

	TDP_101 = sg.SceneGraphNode("TDP_101") #Se crea el cubo completo ubicado en la posicion correcta
	TDP_101.transform = tr.translate(-2.1,2.1,0)
	TDP_101.childs += [cuboRojo, tc.TapaCursoNorm('DP_101')]

	DP_101 = sg.SceneGraphNode("DP_101") #Se crea el cubo completo 
	DP_101.childs += [TDP_101]

	CDP_101 = cc.Curso('DP_101',[],-2.1,2.1,0,['DGP_201','DG_701','DG_702'])




	TDP_102 = sg.SceneGraphNode("TDP_102") #Se crea el cubo completo ubicado en la posicion correcta
	TDP_102.transform = tr.translate(-1.5,2.1,0)
	TDP_102.childs += [cuboRojo,tc.TapaCursoNorm('DP_102')]

	DP_102 = sg.SceneGraphNode("DP_102") #Se crea el cubo completo 
	DP_102.childs += [TDP_102]

	CDP_102 = cc.Curso('DP_102',[],-1.5,2.1,0,['DGP_202','DG_701','DG_702'])




	TDP_103 = sg.SceneGraphNode("TDP_103") #Se crea el cubo completo ubicado en la posicion correcta 
	TDP_103.transform = tr.translate(-0.9,2.1,0)
	TDP_103.childs += [cuboRojo, tc.TapaCursoNorm('DP_103')]

	DP_103 = sg.SceneGraphNode("DP_103") #Se crea el cubo completo 
	DP_103.childs += [TDP_103]

	CDP_103 = cc.Curso('DP_103',[],-0.9,2.1,0,['DGP_203','DG_701','DG_702'])




	TDT_104 = sg.SceneGraphNode("TDT_104") #Se crea el cubo completo ubicado en la posicion correcta
	TDT_104.transform = tr.translate(-0.3,2.1,0)
	TDT_104.childs += [cuboRojo, tc.TapaCursoNorm('DT_104')]

	DT_104 = sg.SceneGraphNode("DT_104") #Se crea el cubo completo 
	DT_104.childs += [TDT_104]

	CDT_104 = cc.Curso('DT_104',[],-0.3,2.1,0,['DGT_303','DG_701','DG_702'])



	TDT_105 = sg.SceneGraphNode("TDT_105") #Se crea el cubo completo ubicado en la pisicion correcta
	TDT_105.transform = tr.translate(0.3,2.1,0) 
	TDT_105.childs += [cuboRojo,tc.TapaCursoNorm('DT_105')]

	DT_105 = sg.SceneGraphNode("DT_105") #Se crea el cubo completo 
	DT_105.childs += [ TDT_105]

	CDT_105 = cc.Curso('DT_105',[],0.3,2.1,0,['DGT_205','DG_701','DG_702'])




	TDH_106 = sg.SceneGraphNode("TDH_106") #Se crea el cubo completo ubicado en la posicion correcta 
	TDH_106.transform = tr.translate(0.9,2.1,0)
	TDH_106.childs += [cuboRojo, tc.TapaCursoNorm('DH_106')]

	DH_106 = sg.SceneGraphNode("DH_106") #Se crea el cubo completo 
	DH_106.childs += [TDH_106]

	CDH_106 = cc.Curso('DH_106',[],0.9,2.1,0,['DGH_206','DG_701','DG_702'])




	TDH_107 = sg.SceneGraphNode("TDH_107") #Se crea el cubo completo ubicado en la posicion correcta 
	TDH_107.transform = tr.translate(1.5,2.1,0)
	TDH_107.childs += [cuboRojo, tc.TapaCursoNorm('DH_107')]

	DH_107 = sg.SceneGraphNode("DH_107") #Se crea el cubo completo 
	DH_107.childs += [TDH_107]

	CDH_107 = cc.Curso('DH_107',[],1.5,2.1,0,['DGH_305','DG_701','DG_702'])




	TDH_108 = sg.SceneGraphNode("TDH_108") #Se crea el cubo completo ubicado en la posicion correcta 
	TDH_108.transform = tr.translate(2.1,2.1,0)
	TDH_108.childs += [cuboRojo, tc.TapaCursoNorm('DH_108')]

	DH_108 = sg.SceneGraphNode("DH_108") #Se crea el cubo completo 
	DH_108.childs += [TDH_108]

	CDH_108 = cc.Curso('DH_108',[],2.1,2.1,0,['DGH_208','DG_701','DG_702'])









	#Segundo año 
	TDGP_201 = sg.SceneGraphNode("TDGP_201") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGP_201.transform = tr.translate(-2.1,1.5,0)
	TDGP_201.childs += [cuboRojo, tc.TapaCursoNorm('DGP_201')]

	DGP_201 = sg.SceneGraphNode("DGP_201") #Se crea el cubo completo 
	DGP_201.childs += [TDGP_201]

	CDGP_201 = cc.Curso('DGP_201',['DP_101'],-2.1,1.5,0,['DGP_301','DG_701','DG_702'])



	TDGP_202 = sg.SceneGraphNode("TDGP_202") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGP_202.transform = tr.translate(-1.5,1.5,0)
	TDGP_202.childs += [cuboRojo, tc.TapaCursoNorm('DGP_202')]

	DGP_202 = sg.SceneGraphNode("DGP_202") #Se crea el cubo completo 
	DGP_202.childs += [TDGP_202]

	CDGP_202 = cc.Curso('DGP_202',['DP_102'],-1.5,1.5,0,['DG_701','DG_702'])




	TDGP_203 = sg.SceneGraphNode("TDGP_203") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGP_203.transform = tr.translate(-0.9,1.5,0)
	TDGP_203.childs += [cuboRojo, tc.TapaCursoNorm('DGP_203')]

	DGP_203 = sg.SceneGraphNode("DGP_203") #Se crea el cubo completo 
	DGP_203.childs += [TDGP_203]

	CDGP_203 = cc.Curso('DGP_203',['DP_103'],-0.9,1.5,0,['DGP_301','DG_701','DG_702'])



	TDGT_204 = sg.SceneGraphNode("TDGT_204") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGT_204.transform = tr.translate(-0.3,1.5,0)
	TDGT_204.childs += [cuboRojo, tc.TapaCursoNorm('DGT_204')]

	DGT_204 = sg.SceneGraphNode("DGT_204") #Se crea el cubo completo 
	DGT_204.childs += [TDGT_204]

	CDGT_204 = cc.Curso('DGT_204',[],-0.3,1.5,0,['DGT_304','DG_701','DG_702'])



	TDGT_205 = sg.SceneGraphNode("TDGT_205") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGT_205.transform = tr.translate(0.3,1.5,0)
	TDGT_205.childs += [cuboRojo, tc.TapaCursoNorm('DGT_205')]

	DGT_205 = sg.SceneGraphNode("DGT_205") #Se crea el cubo completo 
	DGT_205.childs += [TDGT_205]

	CDGT_205 = cc.Curso('DGT_205',['DT_105'],0.3,1.5,0,['DGT_303', 'DGT_302','DG_701','DG_702'])



	TDGH_206 = sg.SceneGraphNode("TDGH_206") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGH_206.transform = tr.translate(0.9,1.5,0)
	TDGH_206.childs += [cuboRojo, tc.TapaCursoNorm('DGH_206')]

	DGH_206 = sg.SceneGraphNode("DGH_206") #Se crea el cubo completo 
	DGH_206.childs += [TDGH_206]

	CDGH_206 = cc.Curso('DGH_206',['DH_106'],0.9,1.5,0,['DG_701','DG_702'])



	TDGH_207 = sg.SceneGraphNode("TDGH_207") #Se crea el cubo completo ubicado en la posicion correcta
	TDGH_207.transform = tr.translate(1.5,1.5,0) 
	TDGH_207.childs += [cuboRojo, tc.TapaCursoNorm('DGH_207')]

	DGH_207 = sg.SceneGraphNode("DGH_207") #Se crea el cubo completo 
	DGH_207.childs += [TDGH_207]

	CDGH_207 = cc.Curso('DGH_207',[],1.5,1.5,0,['DGP_301', 'DGH_306','DG_701','DG_702'])


	
	TDGH_208 = sg.SceneGraphNode("TDGH_208") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGH_208.transform = tr.translate(2.1,1.5,0)
	TDGH_208.childs += [cuboRojo, tc.TapaCursoNorm('DGH_208')]

	DGH_208 = sg.SceneGraphNode("DGH_208") #Se crea el cubo completo 
	DGH_208.childs += [TDGH_208]

	CDGH_208 = cc.Curso('DGH_208',['DH_108'],0.9,1.5,0,['DGH_307','DG_701','DG_702'])








	#Quinto Semestre 

	TDGP_301 = sg.SceneGraphNode("TDGP_301") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGP_301.transform = tr.translate(-2.1,0.9,0)
	TDGP_301.childs += [cuboRojo, tc.TapaCursoNorm('DGP_301')]

	DGP_301 = sg.SceneGraphNode("DGP_301") #Se crea el cubo completo 
	DGP_301.childs += [TDGP_301]

	CDGP_301 = cc.Curso('DGP_301',['DGP_201','DGP_203','DGH_207'],-2.1,0.9,0,['DGP_401','DG_701','DG_702'])



	TDGT_302 = sg.SceneGraphNode("TDGT_302") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGT_302.transform = tr.translate(-1.5,0.9,0)
	TDGT_302.childs += [cuboRojo, tc.TapaCursoNorm('DGT_302')]

	DGT_302 = sg.SceneGraphNode("DGT_302") #Se crea el cubo completo 
	DGT_302.childs += [TDGT_302]

	CDGT_302 = cc.Curso('DGT_302',['DGT_205'],-1.5,0.9,0,['DGT_402','DG_701','DG_702'])



	TDGT_303 = sg.SceneGraphNode("TDGT_303") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGT_303.transform = tr.translate(-0.9,0.9,0)
	TDGT_303.childs += [cuboRojo, tc.TapaCursoNorm('DGT_303')]

	DGT_303 = sg.SceneGraphNode("DGT_303") #Se crea el cubo completo 
	DGT_303.childs += [TDGT_303]

	CDGT_303 = cc.Curso('DGT_303',['DGT_205','DT_104'],-0.9,0.9,0,['DGT_403','DG_701','DG_702'])



	TDGT_304 = sg.SceneGraphNode("TDGT_304") #Se crea el cubo completo ubicado en la posicion correcta
	TDGT_304.transform = tr.translate(-0.3,0.9,0) 
	TDGT_304.childs += [cuboRojo, tc.TapaCursoNorm('DGT_304')]

	DGT_304 = sg.SceneGraphNode("DGT_304") #Se crea el cubo completo 
	DGT_304.childs += [TDGT_304]

	CDGT_304 = cc.Curso('DGT_304',['DGT_204'],-0.3,0.9,0,['DGT_404','DG_701','DG_702'])



	TDGH_305 = sg.SceneGraphNode("TDGH_305") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGH_305.transform = tr.translate(0.3,0.9,0)
	TDGH_305.childs += [cuboRojo, tc.TapaCursoNorm('DGH_305')]

	DGH_305 = sg.SceneGraphNode("DGH_305") #Se crea el cubo completo 
	DGH_305.childs += [TDGH_305]

	CDGH_305 = cc.Curso('DGH_305',['DH_107'],0.3,0.9,0,['DGH_505','DG_701','DG_702'])



	TDGH_306 = sg.SceneGraphNode("TDGH_306") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGH_306.transform = tr.translate(0.9,0.9,0)
	TDGH_306.childs += [cuboRojo, tc.TapaCursoNorm('DGH_306')]

	DGH_306 = sg.SceneGraphNode("DGH_306") #Se crea el cubo completo 
	DGH_306.childs += [TDGH_306]

	CDGH_306 = cc.Curso('DGH_306',['DGH_207'],0.9,0.9,0,['DGP_401', 'DGH_406','DG_701','DG_702'])



	TDGH_307 = sg.SceneGraphNode("TDGH_307") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGH_307.transform = tr.translate(1.5,0.9,0)
	TDGH_307.childs += [cuboRojo, tc.TapaCursoNorm('DGH_307')]

	DGH_307 = sg.SceneGraphNode("DGH_307") #Se crea el cubo completo 
	DGH_307.childs += [TDGH_307]

	CDGH_307 = cc.Curso('DGH_307',['DGH_208'],1.5,0.9,0, ['DGP_401', 'DGH_407','DG_701','DG_702'])



	TDE_1 = sg.SceneGraphNode("TDE_1") #Se crea el cubo completo ubicado en la posicion correcta 
	TDE_1.transform = tr.translate(2.1,0.9,0)
	TDE_1.childs += [cuboRojo, tc.TapaCursoNorm('DE_1')]

	DE_1 = sg.SceneGraphNode("DE_1") #Se crea el cubo completo 
	DE_1.childs += [TDE_1]

	CDE_1 = cc.Curso('DE_1',[],2.1,0.9,0,['DE_3','DE_4','DG_701','DG_702'])








	#Sexto Semestre 
	TDGP_401 = sg.SceneGraphNode("TDGP_401") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGP_401.transform = tr.translate(-2.1,0.3,0)
	TDGP_401.childs += [cuboRojo, tc.TapaCursoNorm('DGP_401')]

	DGP_401 = sg.SceneGraphNode("DGP_401") #Se crea el cubo completo 
	DGP_401.childs += [TDGP_401]

	CDGP_401 = cc.Curso('DGP_401',['DGH_307','DGP_301','DGH_306'],-2.1,0.3,0,['DGP_501','DG_701','DG_702'])



	TDGT_402 = sg.SceneGraphNode("TDGT_402") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGT_402.transform = tr.translate(-1.5,0.3,0)
	TDGT_402.childs += [cuboRojo, tc.TapaCursoNorm('DGT_402')]

	DGT_402 = sg.SceneGraphNode("DGT_402") #Se crea el cubo completo 
	DGT_402.childs += [TDGT_402]

	CDGT_402 = cc.Curso('DGT_402',['DGT_302'],-1.5,0.3,0,['DGH_507','DG_701','DG_702'])



	TDGT_403 = sg.SceneGraphNode("TDGT_403") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGT_403.transform = tr.translate(-0.9,0.3,0)
	TDGT_403.childs += [cuboRojo, tc.TapaCursoNorm('DGT_403')]

	DGT_403 = sg.SceneGraphNode("DGT_403") #Se crea el cubo completo 
	DGT_403.childs += [TDGT_403]

	CDGT_403 = cc.Curso('DGT_403',['DGT_303'],-0.9,0.3,0,['DGP_501', 'DGP_502','DG_701','DG_702'])



	TDGT_404 = sg.SceneGraphNode("TDGT_404") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGT_404.transform = tr.translate(-0.3,0.3,0)
	TDGT_404.childs += [cuboRojo, tc.TapaCursoNorm('DGT_404')]

	DGT_404 = sg.SceneGraphNode("DGT_404") #Se crea el cubo completo 
	DGT_404.childs += [TDGT_404]

	CDGT_404 = cc.Curso('DGT_404',['DGT_304'],-0.3,0.3,0,['DGT_503','DG_701','DG_702'])



	TDGH_405 = sg.SceneGraphNode("TDGH_405") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGH_405.transform = tr.translate(0.3,0.3,0)
	TDGH_405.childs += [cuboRojo, tc.TapaCursoNorm('DGH_405')]

	DGH_405 = sg.SceneGraphNode("DGH_405") #Se crea el cubo completo 
	DGH_405.childs += [TDGH_405]

	CDGH_405 = cc.Curso('DGH_405',[],0.3,0.3,0,['DGH_504','DG_701','DG_702'])



	TDGH_406 = sg.SceneGraphNode("TDGH_406") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGH_406.transform = tr.translate(0.9,0.3,0)
	TDGH_406.childs += [cuboRojo, tc.TapaCursoNorm('DGH_406')]

	DGH_406 = sg.SceneGraphNode("DGH_406") #Se crea el cubo completo 
	DGH_406.childs += [TDGH_406]

	CDGH_406 = cc.Curso('DGH_406',['DGH_306'],0.9,0.3,0,['DGP_501','DG_701','DG_702'])



	TDGH_407 = sg.SceneGraphNode("TDGH_407") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGH_407.transform = tr.translate(1.5,0.3,0)
	TDGH_407.childs += [cuboRojo, tc.TapaCursoNorm('DGH_407')]

	DGH_407 = sg.SceneGraphNode("DGH_407") #Se crea el cubo completo 
	DGH_407.childs += [TDGH_407]

	CDGH_407 = cc.Curso('DGH_407',['DGH_307'],1.5,0.3,0,['DGP_501','DGH_506','DG_701','DG_702'])
	


	TDE_2 = sg.SceneGraphNode("TDE_2") #Se crea el cubo completo ubicado en la posicion correcta 
	TDE_2.transform = tr.translate(2.1,0.3,0)
	TDE_2.childs += [cuboRojo, tc.TapaCursoNorm('DE_2')]

	DE_2 = sg.SceneGraphNode("DE_2") #Se crea el cubo completo 
	DE_2.childs += [TDE_2]

	CDE_2 = cc.Curso('DE_2',[],2.1,0.3,0,['DE_4','DG_701','DG_702'])








	#Septimo Semestre
	TDGP_501 = sg.SceneGraphNode("TDGP_501") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGP_501.transform = tr.translate(-2.1,-0.3,0)
	TDGP_501.childs += [cuboRojo, tc.TapaCursoNorm('DGP_501')]

	DGP_501 = sg.SceneGraphNode("DGP_501") #Se crea el cubo completo 
	DGP_501.childs += [TDGP_501]

	CDGP_501 = cc.Curso('DGP_501',['DGT_403','DGH_407','DGH_406','DGP_401'],-2.1,-0.3,0,['DGP_601','DG_701','DG_702'])



	TDGP_502 = sg.SceneGraphNode("TDGP_502") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGP_502.transform = tr.translate(-1.5,-0.3,0)
	TDGP_502.childs += [cuboRojo, tc.TapaCursoNorm('DGP_502')]

	DGP_502 = sg.SceneGraphNode("DGP_502") #Se crea el cubo completo 
	DGP_502.childs += [TDGP_502]

	CDGP_502 = cc.Curso('DGP_502',['DGT_403'],-1.5,-0.3,0,['DGP_602','DG_701','DG_702'])



	TDGT_503 = sg.SceneGraphNode("TDGT_503") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGT_503.transform = tr.translate(-0.9,-0.3,0)
	TDGT_503.childs += [cuboRojo, tc.TapaCursoNorm('DGT_503')]

	DGT_503 = sg.SceneGraphNode("DGT_503") #Se crea el cubo completo 
	DGT_503.childs += [TDGT_503]

	CDGT_503 = cc.Curso('DGT_503',['DGT_404'],-0.9,-0.3,0,['DGT_603','DG_701','DG_702'])



	TDGH_504 = sg.SceneGraphNode("TDGH_504") #Se crea el cubo completo ubicado en la posicion correcta
	TDGH_504.transform = tr.translate(-0.3,-0.3,0) 
	TDGH_504.childs += [cuboRojo, tc.TapaCursoNorm('DGH_504')]

	DGH_504 = sg.SceneGraphNode("DGH_504") #Se crea el cubo completo 
	DGH_504.childs += [TDGH_504]

	CDGH_504 = cc.Curso('DGH_504',['DGH_405'],-0.3,-0.3,0,['DGH_604','DG_701','DG_702'])



	TDGH_505 = sg.SceneGraphNode("TDGH_505") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGH_505.transform = tr.translate(0.3,-0.3,0)
	TDGH_505.childs += [cuboRojo, tc.TapaCursoNorm('DGH_505')]

	DGH_505 = sg.SceneGraphNode("DGH_505") #Se crea el cubo completo 
	DGH_505.childs += [TDGH_505]

	CDGH_505 = cc.Curso('DGH_505',['DGH_305'],0.3,-0.3,0,['DG_701','DG_702'])



	TDGH_506 = sg.SceneGraphNode("TDGH_506") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGH_506.transform = tr.translate(0.9,-0.3,0)
	TDGH_506.childs += [cuboRojo, tc.TapaCursoNorm('DGH_506')]

	DGH_506 = sg.SceneGraphNode("DGH_506") #Se crea el cubo completo 
	DGH_506.childs += [TDGH_506]

	CDGH_506 = cc.Curso('DGH_506',['DGH_407'],0.9,-0.3,0,['DGP_601','DGH_606','DG_701','DG_702'])



	TDGH_507 = sg.SceneGraphNode("TDGH_507") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGH_507.transform = tr.translate(1.5,-0.3,0)
	TDGH_507.childs += [cuboRojo, tc.TapaCursoNorm('DGH_507')]

	DGH_507 = sg.SceneGraphNode("DGH_507") #Se crea el cubo completo 
	DGH_507.childs += [TDGH_507]

	CDGH_507 = cc.Curso('DGH_507',['DGT_402'],1.5,-0.3,0,['DG_701','DG_702'])



	TDE_3 = sg.SceneGraphNode("TDE_3") #Se crea el cubo completo ubicado en la posicion correcta 
	TDE_3.transform = tr.translate(2.1,-0.3,0)
	TDE_3.childs += [cuboRojo, tc.TapaCursoNorm('DE_3')]

	DE_3 = sg.SceneGraphNode("DE_3") #Se crea el cubo completo 
	DE_3.childs += [TDE_3]

	CDE_3 = cc.Curso('DE_3',['DE_1'],2.1,-0.3,0,['DG_701','DG_702'])








	#Octavo Semestre 
	TDGP_601 = sg.SceneGraphNode("TDGP_601") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGP_601.transform = tr.translate(-2.1,-0.9,0)
	TDGP_601.childs += [cuboRojo, tc.TapaCursoNorm('DGP_601')]

	DGP_601 = sg.SceneGraphNode("DGP_601") #Se crea el cubo completo 
	DGP_601.childs += [TDGP_601]

	CDGP_601 = cc.Curso('DGP_601',['DGH_506','DGP_501'],-2.1,-0.9,0,['DG_701','DG_702'])



	TDGP_602 = sg.SceneGraphNode("TDGP_602") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGP_602.transform = tr.translate(-1.5,-0.9,0)
	TDGP_602.childs += [cuboRojo, tc.TapaCursoNorm('DGP_602')]

	DGP_602 = sg.SceneGraphNode("DGP_602") #Se crea el cubo completo 
	DGP_602.childs += [TDGP_602]

	CDGP_602 = cc.Curso('DGP_602',['DGP_502'],-1.5,-0.9,0,['DG_701','DG_702'])



	TDGT_603 = sg.SceneGraphNode("TDGT_603") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGT_603.transform = tr.translate(-0.9,-0.9,0)
	TDGT_603.childs += [cuboRojo, tc.TapaCursoNorm('DGT_603')]

	DGT_603 = sg.SceneGraphNode("DGT_603") #Se crea el cubo completo 
	DGT_603.childs += [TDGT_603]

	CDGT_603 = cc.Curso('DGT_603',['DGT_503'],-0.9,-0.9,0,['DG_701','DG_702'])



	TDGH_604 = sg.SceneGraphNode("TDGH_604") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGH_604.transform = tr.translate(-0.3,-0.9,0)
	TDGH_604.childs += [cuboRojo, tc.TapaCursoNorm('DGH_604')]

	DGH_604 = sg.SceneGraphNode("DGH_604") #Se crea el cubo completo 
	DGH_604.childs += [TDGH_604]

	CDGH_604 = cc.Curso('DGH_604',['DGH_504'],-0.3,-0.9,0,['DG_701','DG_702'])



	TDGH_605 = sg.SceneGraphNode("TDGH_605") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGH_605.transform = tr.translate(0.3,-0.9,0)
	TDGH_605.childs += [cuboRojo, tc.TapaCursoNorm('DGH_605')]

	DGH_605 = sg.SceneGraphNode("DGH_605") #Se crea el cubo completo 
	DGH_605.childs += [TDGH_605]

	CDGH_605 = cc.Curso('DGH_605',[],0.3,-0.9,0,['DG_701','DG_702'])



	TDGH_606 = sg.SceneGraphNode("TDGH_606") #Se crea el cubo completo ubicado en la posicion correcta 
	TDGH_606.transform = tr.translate(0.9,-0.9,0)
	TDGH_606.childs += [cuboRojo, tc.TapaCursoNorm('DGH_606')]

	DGH_606 = sg.SceneGraphNode("DGH_606") #Se crea el cubo completo 
	DGH_606.childs += [TDGH_606]

	CDGH_606 = cc.Curso('DGH_606',['DGH_506'],0.9,-0.9,0,['DG_701','DG_702'])



	TDE_4 = sg.SceneGraphNode("TDE_4") #Se crea el cubo completo ubicado en la posicion correcta 
	TDE_4.transform = tr.translate(1.5,-0.9,0)
	TDE_4.childs += [cuboRojo, tc.TapaCursoNorm('DE_4')]

	DE_4 = sg.SceneGraphNode("DE_4") #Se crea el cubo completo 
	DE_4.childs += [TDE_4]

	CDE_4 = cc.Curso('DE_4',['DE_1','DE_2'],1.5,-0.9,0,['DG_701','DG_702'])



	Licenciatura_P_Prof = ['DP_101','DP_102','DP_103','DT_104','DT_105','DH_106','DH_107','DH_108',
							'DGP_201','DGP_202','DGP_203','DGT_204','DGT_205','DGH_206','DGH_207','DGH_208',
							'DGP_301','DGT_302','DGT_303','DGT_304','DGH_305','DGH_306','DGH_307','DE_1',
							'DGP_401','DGT_402','DGT_403','DGT_404','DGH_405','DGH_406','DGH_407','DE_2',
							'DGP_501','DGP_502','DGT_503','DGH_504','DGH_505','DGH_506','DGH_507','DE_3',
							'DGP_601','DGP_602','DGT_603','DGH_604','DGH_605','DGH_606','DE_4'] 



	#Noveno semestre 
	TDG_701 = sg.SceneGraphNode("TDG_701") #Se crea el cubo completo ubicado en la posicion correcta 
	TDG_701.transform = tr.translate(-2.1,-1.5,0)
	TDG_701.childs += [cuboRojo, tc.TapaCursoNorm('DG_701')]

	DG_701 = sg.SceneGraphNode("DG_701") #Se crea el cubo completo 
	DG_701.childs += [TDG_701]

	CDG_701 = cc.Curso('DG_701',Licenciatura_P_Prof,-2.1,-1.5,0,['DG_801'])



	TDG_702 = sg.SceneGraphNode("TDG_702") #Se crea el cubo completo ubicado en la posicion correcta 
	TDG_702.transform = tr.translate(-1.5,-1.5,0)
	TDG_702.childs += [cuboRojo, tc.TapaCursoNorm('DG_702')]

	DG_702 = sg.SceneGraphNode("DG_702") #Se crea el cubo completo 
	DG_702.childs += [TDG_702]

	CDG_702 = cc.Curso('DG_702',Licenciatura_P_Prof,-1.5,-1.5,0,['DG_801'])










	#Decimo semestre 
	TDG_801 = sg.SceneGraphNode("TDG_801") #Se crea el cubo completo ubicado en la posicion correcta 
	TDG_801.transform = tr.translate(-2.1,-2.1,0)
	TDG_801.childs += [cuboRojo, tc.TapaCursoNorm('DG_801')]

	DG_801 = sg.SceneGraphNode("DG_801") #Se crea el cubo completo 
	DG_801.childs += [TDG_801]

	CDG_801 = cc.Curso('DG_801',['DG_701','DG_702'],-2.1,-2.1,0)








	#Aqui se comienzan a crear los cursos en un mismo plano 
	semestre1 = sg.SceneGraphNode("semestre1")
	semestre1.childs += [DP_101,DP_102,DP_103,DT_104,DT_105,DH_106,DH_107,DH_108]

	semestre2 = sg.SceneGraphNode("semestre2")
	semestre2.childs += [DGP_201,DGP_202,DGP_203,DGT_204,DGT_205,DGH_206,DGH_207,DGH_208]

	semestre3 = sg.SceneGraphNode("semestre3")
	semestre3.childs += [DGP_301,DGT_302,DGT_303,DGT_304,DGH_305,DGH_306,DGH_307,DE_1]

	semestre4 = sg.SceneGraphNode("semestre4")
	semestre4.childs += [DGP_401,DGT_402,DGT_403,DGT_404,DGH_405,DGH_406,DGH_407,DE_2]

	semestre5 = sg.SceneGraphNode("semestre5")
	semestre5.childs += [DGP_501,DGP_502,DGT_503,DGH_504,DGH_505,DGH_506,DGH_507,DE_3]

	semestre6 = sg.SceneGraphNode("semestre6")
	semestre6.childs += [DGP_601,DGP_602,DGT_603,DGH_604,DGH_605,DGH_606,DE_4]

	semestre7 = sg.SceneGraphNode("semestre7")
	semestre7.childs += [DG_701,DG_702]

	semestre8 = sg.SceneGraphNode("semestre8")
	semestre8.childs += [DG_801]



	Csemestre1 = [CDP_101,CDP_102,CDP_103,CDT_104,CDT_105,CDH_106,CDH_107,CDH_108]

	Csemestre2 = [CDGP_201,CDGP_202,CDGP_203,CDGT_204,CDGT_205,CDGH_206,CDGH_207,CDGH_208]

	Csemestre3 = [CDGP_301,CDGT_302,CDGT_303,CDGT_304,CDGH_305,CDGH_306,CDGH_307,CDE_1]

	Csemestre4 = [CDGP_401,CDGT_402,CDGT_403,CDGT_404,CDGH_405,CDGH_406,CDGH_407,CDE_2]

	Csemestre5 = [CDGP_501,CDGP_502,CDGT_503,CDGH_504,CDGH_505,CDGH_506,CDGH_507,CDE_3]

	Csemestre6 = [CDGP_601,CDGP_602,CDGT_603,CDGH_604,CDGH_605,CDGH_606,CDE_4]

	Csemestre7 = [CDG_701,CDG_702]

	Csemestre8 = [CDG_801]

	Cmalla = [Csemestre1,Csemestre2,Csemestre3,Csemestre4,Csemestre5,Csemestre6,Csemestre7,Csemestre8]



	malla = sg.SceneGraphNode("malla")
	malla.childs = [semestre1,semestre2,semestre3,semestre4,semestre5,semestre6,semestre7,semestre8]
	

	return malla , Cmalla
Exemplo n.º 4
0
def createTree(rule="F[RF]F[LF]F", order=1, size=1.0, skip=0):

    # The different parts of the tree with different materials
    woodGraph = sg.SceneGraphNode("wood")
    leavesGraph = sg.SceneGraphNode("leaves")

    # Scene graph that will contain the whole tree
    treeGraph = sg.SceneGraphNode("tree")
    treeGraph.childs += [woodGraph, leavesGraph]

    # String used to construct the tree
    blueprint = "F"

    # Variables used to keep the size consistent
    counter = 0
    lockCounter = 0

    # Applies the rule to the blueprint, increasing the complexity
    for _ in range(order):
        newBlueprint = ""

        for character in blueprint:
            newBlueprint += rule if character == "F" else character

        blueprint = newBlueprint

    blueprint += "]"

    # Counts how many times the rule is applied, reducing the size of the
    # branches in order to make a tree of the given size
    for character in rule:

        if character == "F" and lockCounter == 0:
            counter += 1

        elif character == "[":
            lockCounter += 1

        elif character == "]":
            lockCounter -= 1

    size /= counter**order

    # Base gpu shapes
    gpuBranch = es.toGPUShape(createBranch(size, 0.05))
    gpuLeaf = es.toGPUShape(createLeaf())

    # Lists that store the information necessary to put new branches
    phiList = [0]
    thetaList = [0]
    decayList = [0.8]
    xList = [0]
    yList = [0]
    zList = [0]

    allLists = [phiList, thetaList, decayList, xList, yList, zList]

    # Creating the tree
    for character in blueprint:

        # Creating a new branch considering the lists of properties
        if character == "F":

            phi = phiList[-1]
            theta = thetaList[-1]
            decay = decayList[-1]
            x = xList[-1]
            y = yList[-1]
            z = zList[-1]

            # Adding the wood
            branchGraph = sg.SceneGraphNode("branch")
            branchGraph.childs += [gpuBranch]

            rotation = tr.matmul([tr.rotationZ(theta), tr.rotationY(phi)])

            branchGraph.transform = tr.matmul(
                [rotation, tr.uniformScale(decay)])
            branchGraph.transform = tr.matmul(
                [tr.translate(x, y, z), branchGraph.transform])

            woodGraph.childs += [branchGraph]

            # Changing the position of the next branch
            localSize = size * decay

            xList[-1] += localSize * np.sin(phi) * np.cos(theta)
            yList[-1] += localSize * np.sin(phi) * np.sin(theta)
            zList[-1] += localSize * np.cos(phi)

        # Changing the angle of the next branch using a spherical system
        elif character == "L":
            phiList[-1] += BRANCH_ANGLE

        elif character == "R":
            phiList[-1] -= BRANCH_ANGLE

        elif character == "U":
            thetaList[-1] += BRANCH_ANGLE

        elif character == "D":
            thetaList[-1] -= BRANCH_ANGLE

        # Setting up a new path for the branches
        elif character == "[":
            for ls in allLists:
                ls.append(ls[-1])

            decayList[-1] **= 2

        # Closing a path, sometimes with a leaf
        elif character == "]":

            if skip > 0:
                skip -= 1

            else:
                x = xList[-1]
                y = yList[-1]
                z = zList[-1]

                # Adding a leaf at the end of a path
                leafGraph = sg.SceneGraphNode("leaf")
                leafGraph.childs += [gpuLeaf]

                leafSize = tr.uniformScale(0.2 * size * decayList[-1])
                leafGraph.transform = tr.matmul(
                    [tr.translate(x, y, z), leafSize])

                leavesGraph.childs += [leafGraph]

            for ls in allLists:
                ls.pop()

    return treeGraph
Exemplo n.º 5
0
def setupEnemies(image, main_node, enemies_amount):
    global enemy0_animations, enemy1_animations, enemy2_animations, ENEMIES_LEFT, CURRENT_ENEMY

    # ENEMY0 SETUP
    enemy0_flying_frames = anim.createFrames(image, [64, 64], [0, 0], [4], [0, 0]) #se recorta la imagen
    enemy0_explote_frames = anim.createFrames(image, [64, 64], [0, 0], [9], [0, 1])
    #se crean las animaciones
    enemy0_flying_anim = anim.Animation(enemy0_flying_frames, 12, True, False)
    enemy0_explote_anim = anim.Animation(enemy0_explote_frames, 12, False, False)
    #se crea la agrupacion de animaciones
    enemy0_animations = {"flying" : enemy0_flying_anim, "explote" : enemy0_explote_anim}

    #ENEMY1 SETUP
    enemy1_flying_frames = anim.createFrames(image, [64, 64], [0, 0], [4], [0, 4]) #se recorta la imagen
    enemy1_explote_frames = anim.createFrames(image, [64, 64], [0, 0], [9], [0, 5])
    # se crean las animaciones
    enemy1_flying_anim = anim.Animation(enemy1_flying_frames, 12, True, False)
    enemy1_explote_anim = anim.Animation(enemy1_explote_frames, 12, False, False)
    # se crea la agrupacion de animaciones
    enemy1_animations = {"flying": enemy1_flying_anim, "explote": enemy1_explote_anim}

    # ENEMY2 SETUP
    enemy2_flying_frames = anim.createFrames(image, [64, 64], [0, 0], [4], [0, 8]) #se recorta la imagen
    enemy2_explote_frames = anim.createFrames(image, [64, 64], [0, 0], [9], [0, 9])
    # se crean las animaciones
    enemy2_flying_anim = anim.Animation(enemy2_flying_frames, 12, True, False)
    enemy2_explote_anim = anim.Animation(enemy2_explote_frames, 12, False, False)
    # se crea la agrupacion de animaciones
    enemy2_animations = {"flying": enemy2_flying_anim, "explote": enemy2_explote_anim}

    #se crea la coleccion de enmigos y se agrega al nodo principal
    enemies_collection = sg.SceneGraphNode("enemies")
    main_node.childs += [enemies_collection]
    Enemies = go.findNode(main_node, "enemies")

    #se define la cantidad de enemigos restantes
    ENEMIES_LEFT = enemies_amount
    #se elige un tipo de enemigos aleatoriamente
    random_enemy = random.randint(0, ENEMIES - 1)
    if enemies_amount <=5:
        #si la cantidad de enemigos es menor a 5 apaarece un grupo de enemy1
        addEnemies1(Enemies, enemies_amount)
        ENEMIES_LEFT -= enemies_amount
        CURRENT_ENEMY = 1
    elif random_enemy == 0:
        #aparece un grupo de enemy0 y se actualizan las variables
        addEnemies0(Enemies, ENEMY0_AMOUNT)
        ENEMIES_LEFT -= ENEMY0_AMOUNT
        CURRENT_ENEMY = 0
    elif random_enemy == 1:
        # aparece un grupo de enemy1 y se actualizan las variables
        addEnemies1(Enemies, ENEMY1_AMOUNT)
        ENEMIES_LEFT -= ENEMY1_AMOUNT
        CURRENT_ENEMY = 1
    elif random_enemy == 2:
        # aparece un grupo de enemy2 y se actualizan las variables
        addEnemies2(Enemies, ENEMY2_AMOUNT)
        ENEMIES_LEFT -= ENEMY2_AMOUNT
        CURRENT_ENEMY = 2

    #retorna una referencia a la coleccion de enemigos
    return Enemies
Exemplo n.º 6
0
    # Using the same view and projection matrices in the whole application
    projection = tr.perspective(45, float(width) / float(height), 0.1, 100)

    camera_theta = 0.0
    camera_phi = np.pi / 4
    camera_r = 3
    ltime = 0

    # FOREST GENERATION
    # Terrain dimension
    f_width = 4
    f_lenght = 4
    # Create forest terrain
    fz = generate_random_terrain_fun(args.gauss_num, args.spikyness)
    terrain = create_terrain(width=f_width, lenght=f_lenght, spu=7, fz=fz)
    terrain_node = sg.SceneGraphNode("terrain_node")
    terrain_node.childs = [es.toGPUShape(terrain.to_shape((0, 0.5, 0.3)))]

    # Create trees
    trees, leaves = generate_tree_models(num=args.species_num, rec_level=3)
    treesGPU = []
    for i in range(len(trees)):
        treesGPU.append(
            tree.get_tree_model_sg(tree_obj=trees[i],
                                   leaves_obj=leaves[i],
                                   tree_color=(0.59, 0.29, 0.00),
                                   leaves_color=(0, 0.7, 0)))
    area = f_width * f_lenght
    tree_rad = 0.2
    tree_area = np.pi * (tree_rad**2)
    num_trees = int((area / tree_area) * args.tree_den)
Exemplo n.º 7
0
def createWoz(advanced = False):

    # Variable used to change the colors
    # I preferred to use this over a different shader program
    # because I also need to use a different logic for the
    # advanced ships and they had a slighty different model
    channel =  1- int(advanced)

    gpuVariantTriangle = es.toGPUShape(ve.createColorTriangle(channel, 0.6, 0))

    gpuBlueTrapeze = es.toGPUShape(ve.createColorTrapeze(0, 0, 1))
    gpuVariantTrapeze0 = es.toGPUShape(ve.createColorTrapeze(channel, 1 - channel, 0))
    gpuVariantTrapeze1 = es.toGPUShape(ve.createColorTrapeze(channel, 0.4, 0))
    
    # Creating the cannon of the ship
    cannon = sg.SceneGraphNode("cannon")
    cannon.transform = tr.translate(0, -1.22, 1)
    cannon.childs += [createCannon()]

    # Creating the motor of the ship
    motor = sg.SceneGraphNode("motor")
    motor.transform = tr.translate(0, 0.62, 0)
    motor.childs += [createMotor()]

    # Creating the front of the ship
    front = sg.SceneGraphNode("front")
    front.transform = tr.matmul([tr.translate(0, -0.87, 0.5), tr.scale(0.6, -0.75, 1)])
    front.childs += [gpuVariantTriangle]

    # Creating the center of the ship
    center = sg.SceneGraphNode("center")
    center.transform = tr.scale(1, -1, 1)
    center.childs += [gpuVariantTrapeze0]

    # Creating the cabin of the ship
    cabin = sg.SceneGraphNode("cabin")
    cabin.transform = tr.matmul([tr.translate(0, 0, 1), tr.uniformScale(-0.5)])
    cabin.childs += [gpuBlueTrapeze]

    # Creating the wings of the ship
    wing0 = sg.SceneGraphNode("wing0")
    wing0.transform = tr.matmul([tr.uniformScale(0.5), tr.rotationZ(math.pi / 2)])
    wing0.transform = tr.matmul([tr.shearing(0, 1.2, 0, 0, 0, 0), wing0.transform])
    wing0.transform = tr.matmul([tr.translate(-0.6, -0.25, 0), tr.rotationZ(0.2), wing0.transform])
    wing0.childs += [gpuVariantTrapeze1]

    wing1 = sg.SceneGraphNode("wing1")
    wing1.transform = tr.matmul([tr.scale(-1, 1, 1), wing0.transform])
    wing1.childs += [gpuVariantTrapeze1]

    woz = sg.SceneGraphNode("woz")
    woz.childs += [wing0, wing1]
    woz.childs += [motor, center, front]
    woz.childs += [cabin]
    woz.childs += [cannon]

    # Upgrading the Woz
    if advanced:
        extraCannon0 = sg.SceneGraphNode("extraCannon0")
        extraCannon0.transform = tr.matmul([tr.translate(0.75, 0.5, 0), cannon.transform])
        extraCannon0.childs += [createCannon()]

        extraCannon1 = sg.SceneGraphNode("extraCannon1")
        extraCannon1.transform = tr.matmul([tr.scale(-1, 1, 1), extraCannon0.transform])
        extraCannon1.childs += [createCannon()]

        woz.childs += [extraCannon0, extraCannon1]

    return woz
Exemplo n.º 8
0
def createAvelyn():

    gpuGrayTriangle = es.toGPUShape(ve.createColorTriangle(0.4, 0.6, 0.4))

    gpuGrayTrapeze = es.toGPUShape(ve.createColorTrapeze(0.6, 0.8, 0.6))
    gpuYellowTrapeze = es.toGPUShape(ve.createColorTrapeze(1, 1, 0))

    gpuGrayQuad0 = es.toGPUShape(bs.createColorQuad(0.4, 0.6, 0.4))
    gpuGrayQuad1 = es.toGPUShape(bs.createColorQuad(0.6, 0.8, 0.6))
    gpuGrayQuad2 = es.toGPUShape(bs.createColorQuad(0.5, 0.7, 0.5))

    # Creating the cannon of the ship
    cannon = sg.SceneGraphNode("cannon")
    cannon.transform = tr.translate(0, -1.22, 1)
    cannon.childs += [createCannon()]

    # Creating the motor of the ship
    motor = sg.SceneGraphNode("motor")
    motor.transform = tr.translate(0, 0.95, 0)
    motor.childs += [createMotor()]

    # Creating the front of the ship
    front = sg.SceneGraphNode("front")
    front.transform = tr.matmul([tr.translate(0, -0.87, 0.5), tr.scale(0.6, -0.75, 1)])
    front.childs += [gpuGrayTriangle]

    # Creating the center of the ship
    center = sg.SceneGraphNode("center")
    center.transform = tr.scale(1, -1, 1)
    center.childs += [gpuGrayTrapeze]

    # Creating the cabin of the ship
    cabin = sg.SceneGraphNode("cabin")
    cabin.transform = tr.matmul([tr.translate(0, 0, 1), tr.uniformScale(-0.5)])
    cabin.childs += [gpuYellowTrapeze]

    # Creating extensions of the ship
    extension0 = sg.SceneGraphNode("extension0")
    extension0.transform = tr.matmul([tr.translate(0, 0.60, 0), tr.scale(1, 0.2, 1)])
    extension0.childs += [gpuGrayQuad0]

    extension1 = sg.SceneGraphNode("extension1")
    extension1.transform = tr.matmul([tr.translate(0, 0.75, 0), tr.scale(1, 0.2, 1)])
    extension1.childs += [gpuGrayQuad1]

    # Creating shapes to decorate the wings
    rectangle = sg.SceneGraphNode("rectangle")
    rectangle.transform = tr.scale(0.75, 1.5, 1)
    rectangle.childs += [gpuGrayQuad2]

    decorated = sg.SceneGraphNode("decorated")
    decorated.transform = tr.matmul([tr.translate(0, 0.5, 0), tr.scale(0.8, 0.2, 1)])
    decorated.childs += [gpuGrayQuad0]

    # Creating the wings of the ship
    wing0 = sg.SceneGraphNode("wing0")
    wing0.transform = tr.matmul([tr.translate(-0.6, 0.4, 0), tr.rotationZ(math.pi / 4)])
    wing0.childs += [rectangle]
    wing0.childs += [decorated]

    wing1 = sg.SceneGraphNode("wing1")
    wing1.transform = tr.scale(-1, 1, 1)
    wing1.childs += [wing0]

    # Joining all the parts
    avelyn = sg.SceneGraphNode("avelyn")
    avelyn.childs += [wing0, wing1]
    avelyn.childs += [motor, center, front]
    avelyn.childs += [extension0, extension1]
    avelyn.childs += [cabin]
    avelyn.childs += [cannon]

    return avelyn
Exemplo n.º 9
0
    # As we work in 3D, we need to check which part is in front,
    # and which one is at the back
    glEnable(GL_DEPTH_TEST)

    # Filling the shapes
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)

    # Getting the contours
    x, y = np.mgrid[:shapeSol[0], :shapeSol[1]]
    cnt = mpl.contour(x, y, solution, 12)

    cnt_list = get_contour_verts(cnt)[1:11]
    cnt_levels = cnt.levels[1:11]

    # Creating the graphs
    roofGraph = sg.SceneGraphNode("roof")
    roofGraph.transform = tr.translate(0, 0, 1)
    roofGraph.childs += [es.toGPUShape(createRoof())]

    floorGraph = sg.SceneGraphNode("floor")
    floorGraph.childs += [es.toGPUShape(createFloor())]

    wallGraph = sg.SceneGraphNode("wall")
    wallGraph.childs += [es.toGPUShape(createWalls())]

    curvesGpu = []
    for contour, level in zip(cnt_list, cnt_levels):
        curvesGpu.append(es.toGPUShape(createCurve(contour[0], level)))

    arrowGpu = es.toGPUShape(createArrowMap())
Exemplo n.º 10
0
def createRollercoaster(puntos):
    #creando los cuadrados
    gpuBlackQuad = es.toGPUShape(bs.createColorQuad(0, 0, 0))
    gpuRedQuad = es.toGPUShape(bs.createColorQuad(1, 0, 0))
    gpuSkinQuad = es.toGPUShape(bs.createColorQuad(0.98,0.82,0.77))
    gpuGreenQuad= es.toGPUShape(bs.createColorQuad(0,1,0))
    gpuBlueQuad = es.toGPUShape(bs.createColorQuad(0, 0, 1))
    #creando la curva
    riel,subcurvas=createRiel(puntos)
    #creando las barras
    bars=createMetalBars(subcurvas)
    riel.childs+=[bars]
    riel.transform = np.matmul(tr.uniformScale(1.7), tr.translate(-0.29, -0.025, 0))
    curva=[]
    for subcurva in subcurvas:
        for punto in subcurva:
         curva.append(punto)

    #creando el carrito con los cuadrados
    body1scaled = sg.SceneGraphNode("body1scaled")
    body1scaled.transform = tr.scale(0.03,0.05,0)
    body1scaled.childs += [gpuRedQuad]

    body1 = sg.SceneGraphNode('body1')
    body1.transform=tr.translate(-0.005,0.05,0)
    body1.childs+=[body1scaled]

    head1scaled = sg.SceneGraphNode('head1scaled')
    head1scaled.transform = tr.uniformScale(0.025)
    head1scaled.childs += [gpuSkinQuad]

    head1=sg.SceneGraphNode('head1')
    head1.transform = tr.translate(-0.005,0.087,0)
    head1.childs += [head1scaled]

    person1 = sg.SceneGraphNode('person1')
    person1.transform= tr.translate(-0.04,0.005,0)
    person1.childs += [head1, body1]

    body2scaled = sg.SceneGraphNode("body2scaled")
    body2scaled.transform = tr.scale(0.03, 0.05, 0)
    body2scaled.childs += [gpuBlueQuad]

    body2 = sg.SceneGraphNode('body2')
    body2.transform = tr.translate(-0.0025, 0.05, 0)
    body2.childs += [body2scaled]

    head2scaled = sg.SceneGraphNode('head2scaled')
    head2scaled.transform = tr.uniformScale(0.025)
    head2scaled.childs += [gpuSkinQuad]

    head2 = sg.SceneGraphNode('head1')
    head2.transform = tr.translate(-0.0025, 0.087, 0)
    head2.childs += [head2scaled]

    person2 = sg.SceneGraphNode('person2')
    person2.transform = tr.translate(-0.003, 0.005, 0)
    person2.childs += [head2, body2]

    body3scaled = sg.SceneGraphNode("body3scaled")
    body3scaled.transform = tr.scale(0.03, 0.05, 0)
    body3scaled.childs += [gpuGreenQuad]

    body3 = sg.SceneGraphNode('body3')
    body3.transform = tr.translate(-0.0025, 0.05, 0)
    body3.childs += [body3scaled]

    head3scaled = sg.SceneGraphNode('head3scaled')
    head3scaled.transform = tr.uniformScale(0.025)
    head3scaled.childs += [gpuSkinQuad]

    head3 = sg.SceneGraphNode('head3')
    head3.transform = tr.translate(-0.0035, 0.087, 0)
    head3.childs += [head3scaled]

    person3 = sg.SceneGraphNode('person2')
    person3.transform = tr.translate(0.04, 0.005, 0)
    person3.childs += [head3, body3]

    wheel = sg.SceneGraphNode("wheel")
    wheel.transform = tr.uniformScale(0.025)
    wheel.childs += [gpuBlackQuad]


    frontWheel = sg.SceneGraphNode("frontWheel")
    frontWheel.transform = tr.translate(0.0375, -0.0375, 0)
    frontWheel.childs += [wheel]

    backWheel = sg.SceneGraphNode("backWheel")
    backWheel.transform = tr.translate(-0.0375, -0.0375, 0)
    backWheel.childs += [wheel]

    chasis = sg.SceneGraphNode("chasis")
    chasis.transform = tr.scale(0.125, 0.0625, 0.0625)
    chasis.childs += [gpuRedQuad]

    rollercoaster = sg.SceneGraphNode("rollercoaster")
    rollercoaster.childs += [chasis]
    rollercoaster.childs += [frontWheel]
    rollercoaster.childs += [backWheel]
    rollercoaster.childs += [person1, person2, person3]
    rollercoaster.transform=tr.uniformScale(0.8)

    traslatedRollercoaster = sg.SceneGraphNode("traslatedRollercoaster")
    traslatedRollercoaster.transform = tr.translate(-0.9, 0, 0)
    traslatedRollercoaster.childs += [rollercoaster]

    final= sg.SceneGraphNode("final")
    final.transform=tr.translate(0,-0.3,0)
    final.childs += [traslatedRollercoaster,riel]
    return final,curva
Exemplo n.º 11
0
def createSky():
    skyTexture = es.toGPUShape(bs.createTextureQuad("sky.jpg"), GL_REPEAT, GL_NEAREST)
    sky = sg.SceneGraphNode("sky")
    sky.transform=tr.uniformScale(2)
    sky.childs += [skyTexture]
    return sky
Exemplo n.º 12
0
    def __init__(self):
        self.gpu_body = es.toGPUShape(bs.createColorNormalsCube(0.8, 0.8, 0.0))
        self.gpu_upper_wing = es.toGPUShape(
            bs.createColorNormalsCube(0.8, 0.8, 0.0))
        self.gpu_fore_wing = es.toGPUShape(
            bs.createColorNormalsCube(0.0, 0.5, 1.0))
        self.gpu_neck = es.toGPUShape(bs.createColorNormalsCube(0.0, 0.5, 1.0))
        self.gpu_head = es.toGPUShape(bs.createColorNormalsCube(0.0, 0.5, 1.0))
        self.gpu_back_wing = es.toGPUShape(
            bs.createColorNormalsCube(0.0, 0.5, 1.0))
        self.gpu_paw = es.toGPUShape(bs.createColorNormalsCube(0.0, 0.5, 1.0))

        # Body of the bird
        self.body = sg.SceneGraphNode("body")
        self.body.transform = tr.scale(1, 0.7, 0.5)
        self.body.childs += [self.gpu_body]

        # Creating a single upper wing
        self.upperWing = sg.SceneGraphNode("upperWing")
        self.upperWing.transform = tr.scale(0.5, 0.5, 0.1)
        self.upperWing.childs += [self.gpu_upper_wing]

        # Creating a single fore wing
        self.foreWing = sg.SceneGraphNode("foreWing")
        self.foreWing.transform = tr.scale(0.5, 0.7, 0.1)
        self.foreWing.childs += [self.gpu_fore_wing]

        # Creating the right wing of the bird
        self.upperRight = sg.SceneGraphNode("upperRight")
        self.upperRight.transform = tr.matmul(
            [tr.translate(0, -0.5, 0),
             tr.rotationX(5 * np.pi / 6)])
        self.upperRight.childs += [self.upperWing]

        self.upperRightRotation = sg.SceneGraphNode("upperRightRotation")
        self.upperRightRotation.childs += [self.upperRight]

        self.foreRight = sg.SceneGraphNode("foreRight")
        self.foreRight.transform = tr.matmul(
            [tr.translate(0, -1, 0.285),
             tr.rotationX(5 * np.pi / 6)])
        self.foreRight.childs += [self.foreWing]

        self.foreRightRotation = sg.SceneGraphNode("foreRightRotation")
        self.foreRightRotation.childs += [self.foreRight]

        # Creating the left wing of the bird
        self.upperLeft = sg.SceneGraphNode("upperLeft")
        self.upperLeft.transform = tr.matmul(
            [tr.translate(0, 0.5, 0),
             tr.rotationX(np.pi / 6)])
        self.upperLeft.childs += [self.upperWing]

        self.upperLeftRotation = sg.SceneGraphNode("upperLeftRotation")
        self.upperLeftRotation.childs += [self.upperLeft]

        self.foreLeft = sg.SceneGraphNode("foreLeft")
        self.foreLeft.transform = tr.matmul(
            [tr.translate(0, 1, 0.285),
             tr.rotationX(np.pi / 6)])
        self.foreLeft.childs += [self.foreWing]

        self.foreLeftRotation = sg.SceneGraphNode("foreLeftRotation")
        self.foreLeftRotation.childs += [self.foreLeft]

        # Creating the neck of the bird
        self.neck = sg.SceneGraphNode("neck")
        self.neck.transform = tr.matmul([
            tr.translate(0.5, 0, 0.2),
            tr.rotationY(2.5 * np.pi / 3),
            tr.scale(0.6, 0.3, 0.3)
        ])
        self.neck.childs += [self.gpu_neck]

        # Creating the head of the bird
        self.head = sg.SceneGraphNode("head")
        self.head.transform = tr.matmul(
            [tr.translate(0.8, 0, 0.5),
             tr.uniformScale(0.5)])
        self.head.childs += [self.gpu_head]

        self.headAndNeckRotation = sg.SceneGraphNode("headAndNeckRotation")
        self.headAndNeckRotation.childs += [self.head, self.neck]

        # Creating the back wing of the bird
        self.backWing = sg.SceneGraphNode("backWing")
        self.backWing.transform = tr.matmul([
            tr.translate(-0.6, 0, 0.1),
            tr.rotationY(-2.5 * np.pi / 3),
            tr.scale(0.6, 0.3, 0.1)
        ])
        self.backWing.childs += [self.gpu_back_wing]

        self.backWingRotation = sg.SceneGraphNode("backWingRotation")
        self.backWingRotation.childs += [self.backWing]

        # Creating a single paw
        self.paw = sg.SceneGraphNode("paw")
        self.paw.transform = tr.scale(0.1, 0.1, 1)
        self.paw.childs += [self.gpu_paw]

        # Creating both paws
        self.rightPaw = sg.SceneGraphNode("rightPaw")
        self.rightPaw.transform = tr.translate(0, -0.2, -0.3)
        self.rightPaw.childs += [self.paw]

        self.leftPaw = sg.SceneGraphNode("leftPaw")
        self.leftPaw.transform = tr.translate(0, 0.2, -0.3)
        self.leftPaw.childs += [self.paw]

        # Creating the bird
        self.bird = sg.SceneGraphNode("bird")
        self.bird.childs += [self.body]
        self.bird.childs += [self.upperRightRotation]
        self.bird.childs += [self.foreRightRotation]
        self.bird.childs += [self.upperLeftRotation]
        self.bird.childs += [self.foreLeftRotation]
        self.bird.childs += [self.headAndNeckRotation]
        self.bird.childs += [self.backWingRotation]
        self.bird.childs += [self.leftPaw]
        self.bird.childs += [self.rightPaw]
Exemplo n.º 13
0
def updatePlayer(delta_time , player, controller, bullets, enemy_bullets, hearts, en_amount):
    global player_bullet_counter

    #Si quedan enemigos, se ejecuta la actualizacion normal de la nave(se puede mover, recibe daño, dispara, etc)
    if en_amount > 0:
        #si se ha borrado/ muerto, no hace nada
        if player == None:
            return
        #si al player no se le han acabado las vidas y esta explotando
        if not player.isExploding:

            #se actualiza las variables de posicion con los valores de traslacion
            player.position[0] = player.transform[0][3]
            player.position[1] = player.transform[1][3]
            player.position[2] = player.transform[2][3]

            #se crea la refencia al AnimController del player
            anim_player = player.childs[0].childs[0]

            #controla el tiempo en que el jugador no puede recibir daño luego de recibir un disparo
            if player.time_counter > HURTED_TIME and player.isHurted:
                player.isHurted = False
                anim_player.Play("slow")
                player.time_counter = 0
            else:
                player.time_counter += delta_time

            #se cambia la velocidad segun el input y se cambia la animacion si esta avanzando o retrocediendo
            if controller.is_up_pressed:
                player.velocity[1] +=  PLAYER_ACC
                if anim_player.current_anim == "slow" :
                    if not player.isHurted:
                        anim_player.Play("fast")
            if controller.is_down_pressed:
                player.velocity[1] -=  PLAYER_ACC
                if anim_player.current_anim == "fast" :
                    if not player.isHurted:
                        anim_player.Play("slow")

            if controller.is_right_pressed:
                player.velocity[0]+= PLAYER_ACC
            elif controller.is_left_pressed:
                player.velocity[0] -= PLAYER_ACC

            #controla el disparo y el tiempo de recarga
            if player.time_counter2 > BULLET_RELOAD_TIME and controller.is_space_press:
                player.shoot(bullets, player_bullet_counter)
                player_bullet_counter += 1
                player.time_counter2 = 0
            else:
                player.time_counter2 += delta_time

            #se normaliza la velocidad y se limita
            vel_sqr_mag=  player.velocity[0]**2 + player.velocity[1]**2
            if vel_sqr_mag > PLAYER_MAX_SPEED**2:
                player.velocity[0] = (player.velocity[0] / math.sqrt(vel_sqr_mag)) * PLAYER_MAX_SPEED
                player.velocity[1] = (player.velocity[1] / math.sqrt(vel_sqr_mag)) * PLAYER_MAX_SPEED

            #si no recibe input que mueva la nave, la velocidad se interpola para que no frene de inmediato
            if not(controller.is_up_pressed or controller.is_down_pressed or controller.is_left_pressed or controller.is_right_pressed):
                player.velocity[0] = go.lerp(player.velocity[0], 0, PLAYER_FRICC)
                player.velocity[1] = go.lerp(player.velocity[1], 0, PLAYER_FRICC)

            #la nueva posicion corresponde a la anterior mas la velocidad por un delta de tiempo
            vx = player.position[0] + player.velocity[0] * delta_time
            vy = player.position[1] + player.velocity[1] * delta_time *  WIDTH / HEIGHT #se multiplica por esta razon debido a las dimensiones de la pantalla
            vz = player.position[2] + player.velocity[2] * delta_time

            #controla que la nave no se salga de los bordes de la ventana
            if vx < -0.95:
                vx = player.position[0]
                player.velocity[0] = 0
            if vx > 0.95:
                vx = player.position[0]
                player.velocity[0] = 0
            if vy < -0.95:
                vy = player.position[1]
                player.velocity[1] = 0
            if vy > 0.92:
                vy = player.position[1]
                player.velocity[1] = 0

            #actualiza la posicion de la nave con los valores calculador
            player.transform = tr.translate(vx, vy, vz)

            #deteccion de colisiones
            if player.childs[1].canCollide:
                #funcion que entrega una referencia al nodo colisionado (o un None si no hay)
                collide_bullet = player.childs[1].collidingWith(enemy_bullets)
                if collide_bullet != None and ( not player.isHurted): #la nave detecta colisiones si no esta herida
                    collide_bullet.velocity = np.zeros(3) #la bala enemiga se detiene
                    collide_bullet.childs[1].canCollide = False #la bala enemiga ya no puede ser detectada
                    collide_bullet.childs[0].childs[0].Play("explote") #la bala enemiga explota
                    collide_bullet.isExploding = True
                    player.health -= 1 #player pierde 1 vida
                    del(hearts.childs[-1]) # se elimina un corazon

                    # si al player le queda vida, se encuentra herido por el tiempo correspondiente
                    if player.health > 0:
                        player.isHurted = True
                        player.time_counter = 0
                        anim_player.Play("hurt")
                    else:
                        #si no le queda vida, explota y no puede ser detectado
                        player.childs[1].canCollide = False
                        anim_player.Play("explode")
                        player.isExploding = True
                        player.time_counter = 0
        #si se le acabaron las vidas y esta explotando
        elif not player.isDead:
            if player.childs[0].childs[0].isFinished: #si ha terminado la animacion de explotar, esta muerto
                player.isDead = True
            if player.isDead: #si esta muerto se elimina
                player.childs[0] = sg.SceneGraphNode("None")
    else:
        #si no quedan mas enemigos, player ha ganado por lo que abandona la pantalla por arriba
        if player.childs[0].childs[0].current_anim != "fast":
            player.childs[0].childs[0].Play("fast")

        if player.position[1] < 1.5:
            player.position[0] = player.transform[0][3]
            player.position[1] = player.transform[1][3]
            player.position[2] = player.transform[2][3]

            vx = player.position[0]
            vy = player.position[1] + PLAYER_LEAVE_SPEED * delta_time * WIDTH / HEIGHT
            vz = player.position[2]
            player.transform = tr.translate(vx, vy, vz)