Beispiel #1
0
def createTextureDeathStar(filename):
    gpuSphere = es.toGPUShape(bs.createTextureSphere(filename),
                              GL_MIRRORED_REPEAT, GL_NEAREST)
    gpuInside = es.toGPUShape(bs.createInsideSphere("textures/dsInside.jpg"),
                              GL_MIRRORED_REPEAT, GL_NEAREST)
    gpuCone = es.toGPUShape(bs.createTextureCone("textures/laser.png"),
                            GL_MIRRORED_REPEAT, GL_NEAREST)

    star_base = sg.SceneGraphNode("star_base")
    star_base.transform = tr2.scale(0.5, 0.5, 0.5)
    star_base.childs += [gpuSphere]

    star_inside = sg.SceneGraphNode("star_inside")
    star_inside.transform = tr2.scale(0.5, 0.5, 0.5)
    star_inside.childs += [gpuInside]

    star_aerial = sg.SceneGraphNode("star_aerial")
    star_aerial.transform = np.matmul(
        tr2.translate(0, -np.sin(3 * np.pi / 8) / 2,
                      np.cos(3 * np.pi / 8) / 2), tr2.rotationX(3 * np.pi / 8))
    star_aerial.transform = np.matmul(star_aerial.transform,
                                      tr2.scale(0.15, 0.15, 0.05))
    star_aerial.childs += [gpuCone]

    star = sg.SceneGraphNode("star")
    star.transform = tr2.rotationY(np.pi / 32)
    star.childs += [star_inside, star_base, star_aerial]

    return star
Beispiel #2
0
def createBox(filename):
    gpuCube = es.toGPUShape(bs.createTextureCube(filename), GL_MIRRORED_REPEAT,
                            GL_NEAREST)
    bgCube_scaled = sg.SceneGraphNode("bgCube_scaled")
    bgCube_scaled.transform = tr2.scale(9, 9, 9)
    bgCube_scaled.childs += [gpuCube]

    bgCube = sg.SceneGraphNode("bgCube_scaled")
    bgCube.transform = tr2.translate(0, 0, 0)
    bgCube.childs += [bgCube_scaled]

    return bgCube
Beispiel #3
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
Beispiel #4
0
def createEarth():
    gpuEarth_texture = es.toGPUShape(
        bs.createTextureQuad("textures/earth.png"), GL_REPEAT, GL_NEAREST)
    earth_scaled = sg.SceneGraphNode("earth_scaled")
    earth_scaled.transform = tr2.scale(0.5, 0.5, 0.5)
    earth_scaled.childs += [gpuEarth_texture]

    earth_rotated = sg.SceneGraphNode("earth_rotated_x")
    earth_rotated.transform = tr2.rotationX(np.pi / 2)
    earth_rotated.childs += [earth_scaled]

    earth = sg.SceneGraphNode("earth")
    earth.transform = tr2.translate(0.5, 4, 0.6)
    earth.childs += [earth_rotated]

    return earth
def createGround(image, trans):
    gpuGround_texture = es.toGPUShape(bs.createTextureQuad(image), GL_REPEAT,
                                      GL_NEAREST)
    ground_scaled = sg.SceneGraphNode("ground_scaled")
    ground_scaled.transform = tr2.scale(2, 2, 2)
    ground_scaled.childs += [gpuGround_texture]

    ground_rotated = sg.SceneGraphNode("ground_rotated_x")
    ground_rotated.transform = tr2.rotationX(0)
    ground_rotated.childs += [ground_scaled]

    ground = sg.SceneGraphNode("ground")
    ground.transform = tr2.translate(0, 0, trans)
    ground.childs += [ground_rotated]

    return ground
def createAmbiente(filename, x, y, z, rot):
    gpuAirport_texture = es.toGPUShape(bs.createTextureQuad(filename),
                                       GL_REPEAT, GL_LINEAR)
    ambiente_scaled = sg.SceneGraphNode("ambiente_scaled")
    ambiente_scaled.transform = tr2.scale(2, 2, 2)
    ambiente_scaled.childs += [gpuAirport_texture]

    ambiente_rotated = sg.SceneGraphNode("ambiente_rotated")
    ambiente_rotated.transform = np.matmul(tr2.rotationX(np.pi / 2),
                                           tr2.rotationY(rot))
    ambiente_rotated.childs += [ambiente_scaled]

    ambiente = sg.SceneGraphNode("ambiente")
    ambiente.transform = tr2.translate(x, y, z)
    ambiente.childs += [ambiente_rotated]

    return ambiente
Beispiel #7
0
def createCar(r, g, b):

    gpuBlackQuad = es.toGPUShape(bs.createColorCube(0, 0, 0))
    gpuChasisQuad = es.toGPUShape(bs.createColorCube(r, g, b))

    # Cheating a single wheel
    wheel = sg.SceneGraphNode("wheel")
    wheel.transform = tr2.scale(0.2, 0.8, 0.2)
    wheel.childs += [gpuBlackQuad]

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

    # Instanciating 2 wheels, for the front and back parts
    frontWheel = sg.SceneGraphNode("frontWheel")
    frontWheel.transform = tr2.translate(0.3, 0, -0.3)
    frontWheel.childs += [wheelRotation]

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

    # Creating the chasis of the car
    chasis = sg.SceneGraphNode("chasis")
    chasis.transform = tr2.scale(1, 0.7, 0.5)
    chasis.childs += [gpuChasisQuad]

    # All pieces together
    car = sg.SceneGraphNode("car")
    car.childs += [chasis]
    car.childs += [frontWheel]
    car.childs += [backWheel]

    return car
Beispiel #8
0
def createSpaceShip():
    gpuCenterShip = es.toGPUShape(
        bs.createTextureSphere("textures/ssCenter.jpg"), GL_MIRRORED_REPEAT,
        GL_NEAREST)
    gpuBlock = es.toGPUShape(bs.createTextureCube("textures/ssBlock.jpg"),
                             GL_REPEAT, GL_NEAREST)
    gpuPlane = es.toGPUShape(bs.createTextureHex("textures/ssWings.jpg"),
                             GL_REPEAT, GL_NEAREST)

    spaceShipCenter = sg.SceneGraphNode("spaceShipCenter")
    spaceShipCenter.transform = tr2.scale(0.1, 0.1, 0.1)
    spaceShipCenter.childs += [gpuCenterShip]

    spaceShipBlock = sg.SceneGraphNode("spaceShipBlock")
    spaceShipBlock.transform = tr2.scale(0.02, 0.4, 0.02)
    spaceShipBlock.childs += [gpuBlock]

    spaceShipWingL = sg.SceneGraphNode("spaceShipLeftWing")
    spaceShipWingL.transform = np.matmul(
        tr2.translate(0.02, -0.2, 0.02),
        np.matmul(tr2.rotationX(np.pi / 2), tr2.scale(0.3, 0.3, 0.3)))
    spaceShipWingL.childs += [gpuPlane]

    spaceShipWingR = sg.SceneGraphNode("spaceShipRightWing")
    spaceShipWingR.transform = np.matmul(
        tr2.translate(0.02, 0.2, 0.02),
        np.matmul(tr2.rotationX(np.pi / 2), tr2.scale(0.3, 0.3, 0.3)))
    spaceShipWingR.childs += [gpuPlane]

    spaceShip_rotated = sg.SceneGraphNode("spaceShip_rotated")
    spaceShip_rotated.transform = np.matmul(tr2.rotationZ(0),
                                            tr2.rotationY(np.pi / 2))
    spaceShip_rotated.childs += [
        spaceShipCenter, spaceShipBlock, spaceShipWingR, spaceShipWingL
    ]

    spaceShip_scaled = sg.SceneGraphNode("spaceShip_scaled")
    spaceShip_scaled.transform = tr2.scale(0.5, 0.5, 0.5)
    spaceShip_scaled.childs += [spaceShip_rotated]

    spaceShip = sg.SceneGraphNode("spaceShip")
    spaceShip.transform = tr2.translate(0, 0, 0)
    spaceShip.childs += [spaceShip_scaled]

    return spaceShip
    def __init__(self, texture_head):
        gpu_body = es.toGPUShape(bs.createColorCube(1, 0, 0))
        gpu_leg = es.toGPUShape(bs.createColorCube(0, 0, 1))
        gpu_skin = es.toGPUShape(bs.createColorCube(1, 1, 0))
        gpu_head = es.toGPUShape(bs.createTextureCube(texture_head), GL_REPEAT,
                                 GL_LINEAR)

        # Creamos el nucleo
        core = sg.SceneGraphNode('core')
        core.transform = tr.scale(0.32, 0.5, 0.6)
        core.childs += [gpu_body]

        # Piernas
        leg = sg.SceneGraphNode('leg')
        leg.transform = tr.scale(0.14, 0.14, 0.5)
        leg.childs += [gpu_leg]

        leg_left = sg.SceneGraphNode('leg_left')
        leg_left.transform = tr.translate(0, -0.17, -0.5)
        leg_left.childs += [leg]

        leg_right = sg.SceneGraphNode('leg_right')
        leg_right.transform = tr.translate(0, 0.17, -0.5)
        leg_right.childs += [leg]

        # Brazos
        arm = sg.SceneGraphNode('arm')
        arm.transform = tr.scale(0.13, 0.5, 0.13)
        arm.childs += [gpu_skin]

        arm_left = sg.SceneGraphNode('arm_left')
        arm_left.transform = tr.translate(0, -0.4, 0.23)
        arm_left.childs += [arm]

        arm_right = sg.SceneGraphNode('arm_right')
        arm_right.transform = tr.translate(0, 0.4, 0.23)
        arm_right.childs += [arm]

        # Cuello
        neck = sg.SceneGraphNode('neck')
        neck.transform = tr.matmul(
            [tr.scale(0.12, 0.12, 0.2),
             tr.translate(0, 0, 1.6)])
        neck.childs += [gpu_skin]

        # Cabeza
        head = sg.SceneGraphNode('head')
        head.transform = tr.matmul(
            [tr.scale(0.35, 0.35, 0.35),
             tr.translate(-0.08, 0, 1.75)])
        head.childs += [gpu_skin]

        body = sg.SceneGraphNode('body')
        body.childs += [
            arm_left, arm_right, leg_left, leg_right, core, neck, head
        ]

        face = sg.SceneGraphNode('face')
        face.transform = tr.matmul(
            [tr.scale(0.3, 0.3, 0.3),
             tr.translate(0, 0, 2)])
        face.childs += [gpu_head]

        body_tr = sg.SceneGraphNode('bodyTR')
        body_tr.childs += [body, face]

        self.face = face
        self.body = body

        self.model = body_tr
        self.show_face = True
Beispiel #10
0
def crearbarco(image_filename_1, image_filename_2, image_filename_3):
    gpuBote = es.toGPUShape(cr.createBote(image_filename_1), GL_REPEAT,
                            GL_LINEAR)
    gpuMastil = es.toGPUShape(cr.createMastil(image_filename_1), GL_REPEAT,
                              GL_LINEAR)
    gpuVela = es.toGPUShape(cr.createVela(image_filename_2), GL_REPEAT,
                            GL_LINEAR)
    gpuFlag = es.toGPUShape(cr.createFlag(image_filename_3), GL_REPEAT,
                            GL_LINEAR)

    #instancia del bote
    bote = sg.SceneGraphNode("bote")
    bote.childs += [gpuBote]
    #instancia de flag
    flag = sg.SceneGraphNode("flag")
    flag.transform = tr2.uniformScale(0.5)
    flag.childs += [gpuFlag]

    flagTranslate = sg.SceneGraphNode("flagTranslate")
    flagTranslate.transform = tr2.translate(-3, 0, 2.5)
    flagTranslate.childs += [flag]
    #2 instancias de mastil
    frontMastil = sg.SceneGraphNode("frontMastil")
    frontMastil.transform = tr2.translate(1.2, 0, 0)
    frontMastil.childs += [gpuMastil]

    backMastil = sg.SceneGraphNode("backMastil")
    backMastil.transform = tr2.translate(-1.2, 0, 0)
    backMastil.childs += [gpuMastil]
    #2 instancias de velas
    frontVela = sg.SceneGraphNode("frontVela")
    frontVela.transform = tr2.translate(1.2, 0, 2.5)
    frontVela.childs += [gpuVela]

    backVela = sg.SceneGraphNode("backVela")
    backVela.transform = tr2.translate(-1.2, 0, 2.5)
    backVela.childs += [gpuVela]
    #instancia de cola
    cola = sg.SceneGraphNode("cola")
    cola.transform = tr2.uniformScale(0.5)
    cola.childs += [gpuMastil]
    colaTranslated = sg.SceneGraphNode("colaTranslated")
    colaTranslated.transform = tr2.translate(-2.5, 0, 1)
    colaTranslated.childs += [cola]

    #instacia del barco completo
    barco = sg.SceneGraphNode("barco")
    barco.childs += [bote]
    barco.childs += [frontMastil]
    barco.childs += [backMastil]
    barco.childs += [colaTranslated]
    barco.childs += [frontVela]
    barco.childs += [backVela]
    barco.childs += [flagTranslate]

    #barco rotado
    scaledBarco = sg.SceneGraphNode("scaledBarco")
    scaledBarco.transform = tr2.uniformScale(0.05)
    scaledBarco.childs += [barco]
    rotatedBarco = sg.SceneGraphNode("rotatedBarco")
    rotatedBarco.transform = tr2.rotationZ(3)
    rotatedBarco.childs += [scaledBarco]

    traslatedBarco = sg.SceneGraphNode("traslatedBarco")
    traslatedBarco.transform = tr2.translate(0.0, 0.0, 0.0)
    traslatedBarco.childs += [rotatedBarco]
    return traslatedBarco
Beispiel #11
0
def createMar(image_filename):
    gpuMar = es.toGPUShape(cr.createSuperficie(image_filename, 1, 1),
                           GL_REPEAT, GL_LINEAR)
    mar = sg.SceneGraphNode("mar")
    mar.childs += [gpuMar]
    return mar
Beispiel #12
0
def crearIsla():
    gpuIsla = es.toGPUShape(cr.createIsland())
    isla = sg.SceneGraphNode("isla")
    isla.childs += [gpuIsla]
    return isla
def createEdificio():

    gpuBase = es.toGPUShape(bs.createTextureCube("textura.jpg"), GL_REPEAT,
                            GL_NEAREST)
    gpuLados = es.toGPUShape(bs.createTextureCube("textura.jpg"), GL_REPEAT,
                             GL_NEAREST)
    gpuBase2 = es.toGPUShape(bs.createTextureCube("techo.jpg"), GL_REPEAT,
                             GL_NEAREST)
    gpuAntena = es.toGPUShape(bs.createTextureCube("metal.jpg"), GL_REPEAT,
                              GL_NEAREST)
    gpuAntena1 = es.toGPUShape(bs.createCilindro(0, 0, 0))

    base = sg.SceneGraphNode("base")
    base.transform = np.matmul(tr2.scale(0.8 / 2, 0.7 / 2, 0.1875 / 2),
                               tr2.translate(0, 0, 0.5))
    base.childs += [gpuBase]

    lados = sg.SceneGraphNode("lados")
    lados.transform = np.matmul(tr2.translate(0.15, 0, 0.2),
                                tr2.scale(0.0875 / 2, 0.468 / 2, 0.625 / 2))
    lados.childs += [gpuLados]

    lados1 = sg.SceneGraphNode("lados1")
    lados1.transform = np.matmul(tr2.translate(-0.15, 0, 0.2),
                                 tr2.scale(0.0875 / 2, 0.468 / 2, 0.625 / 2))
    lados1.childs += [gpuLados]

    base2 = sg.SceneGraphNode("base2")
    base2.transform = np.matmul(tr2.scale(0.495 / 2, 0.545 / 2, 0.645 / 2),
                                tr2.translate(0, 0, 0.7))
    base2.childs += [gpuBase]

    base3 = sg.SceneGraphNode("base3")
    base3.transform = np.matmul(tr2.scale(0.32 / 2, 0.32 / 2, 2 / 2),
                                tr2.translate(0, 0, 0.8))
    base3.childs += [gpuBase]

    base4 = sg.SceneGraphNode("base4")
    base4.transform = np.matmul(tr2.scale(0.25 / 2, 0.25 / 2, 0.05 / 2),
                                tr2.translate(0, 0, 52.5))
    base4.childs += [gpuBase2]

    base5 = sg.SceneGraphNode("base4")
    base5.transform = np.matmul(tr2.scale(0.2 / 2, 0.2 / 2, 0.05 / 2),
                                tr2.translate(0, 0, 53.5))
    base5.childs += [gpuBase2]

    base6 = sg.SceneGraphNode("base4")
    base6.transform = np.matmul(tr2.scale(0.15 / 2, 0.15 / 2, 0.05 / 2),
                                tr2.translate(0, 0, 54.5))
    base6.childs += [gpuBase2]

    antena = sg.SceneGraphNode("antena")
    antena.transform = np.matmul(tr2.scale(0.015, 0.015, 0.3),
                                 tr2.translate(0, 0, 4.5))
    antena.childs += [gpuAntena]

    antena1 = sg.SceneGraphNode("antena1")
    antena1.transform = np.matmul(tr2.scale(0.01, 0.01, 0.3),
                                  tr2.translate(0, 0, 5))
    antena1.childs += [gpuAntena]

    antena2 = sg.SceneGraphNode("antena2")
    antena2.transform = np.matmul(tr2.scale(0.005, 0.005, 0.3),
                                  tr2.translate(0, 0, 6))
    antena2.childs += [gpuAntena]

    lados_1 = sg.SceneGraphNode("lado_1")
    lados_1.transform = np.matmul(tr2.scale(0.1 / 2, 0.5 / 2, 1.2 / 2),
                                  tr2.translate(1.55, 0, 1.15))
    lados_1.childs += [gpuLados]

    lados_2 = sg.SceneGraphNode("lado_2")
    lados_2.transform = np.matmul(tr2.scale(0.1 / 2, 0.5 / 2, 1.2 / 2),
                                  tr2.translate(-1.55, 0, 1.15))
    lados_2.childs += [gpuLados]

    lados_3 = sg.SceneGraphNode("lado_2")
    lados_3.transform = np.matmul(tr2.scale(0.09 / 2, 0.4 / 2, 0.4 / 2),
                                  tr2.translate(1.65, 0, 5.4))
    lados_3.childs += [gpuLados]

    lados_4 = sg.SceneGraphNode("lado_2")
    lados_4.transform = np.matmul(tr2.scale(0.09 / 2, 0.4 / 2, 0.4 / 2),
                                  tr2.translate(-1.65, 0, 5.4))
    lados_4.childs += [gpuLados]

    edificio = sg.SceneGraphNode("edificio")
    edificio.childs += [lados]
    edificio.childs += [lados1]
    edificio.childs += [base]
    edificio.childs += [base2]
    edificio.childs += [base3]
    edificio.childs += [base4]
    edificio.childs += [base5]
    edificio.childs += [base6]
    edificio.childs += [lados_1]
    edificio.childs += [lados_2]
    edificio.childs += [lados_3]
    edificio.childs += [lados_4]
    edificio.childs += [antena]
    edificio.childs += [antena1]
    edificio.childs += [antena2]

    return edificio
def createCar(r1, g1, b1, r2, g2, b2, isNormal):

    gpuBlackQuad = es.toGPUShape(bs.createCilindro(0, 0, 0), GL_REPEAT,
                                 GL_NEAREST)
    gpuChasisQuad_color1 = es.toGPUShape(bs.createTextureCube("militar.jpg"),
                                         GL_REPEAT, GL_NEAREST)
    gpuChasisQuad_color2 = es.toGPUShape(bs.createTextureCube("auto2.png"),
                                         GL_REPEAT, GL_NEAREST)
    gpuChasisPrism = es.toGPUShape(
        bs.createColorTriangularPrism(153 / 255, 204 / 255, 255 / 255))

    # Cheating a single rueda

    auto = sg.SceneGraphNode("auto")
    auto.transform = tr2.scale(0.2, 0.8, 0.2)
    auto.childs += [gpuBlackQuad]

    rueda = sg.SceneGraphNode("rueda")
    rueda.transform = tr2.scale(0.2 / 6, 0.8 / 6, 0.2 / 6)
    rueda.childs += [gpuBlackQuad]

    ruedaRotation = sg.SceneGraphNode("ruedaRotation")
    ruedaRotation.childs += [rueda]

    # Instanciating 2 ruedas, for the front and back parts
    frontrueda = sg.SceneGraphNode("frontrueda")
    frontrueda.transform = tr2.translate(0.05, 0, -0.45)
    frontrueda.childs += [ruedaRotation]

    backrueda = sg.SceneGraphNode("backrueda")
    backrueda.transform = tr2.translate(-0.05, 0, -0.45)
    backrueda.childs += [ruedaRotation]

    # Creating the bottom chasis of the car
    bot_chasis = sg.SceneGraphNode("bot_chasis")
    bot_chasis.transform = tr2.scale(1 / 5, 0.5 / 5, 0.5 / 6)
    bot_chasis.childs += [gpuChasisQuad_color1]

    # Moving bottom chasis
    moved_b_chasis = sg.SceneGraphNode("moved_b_chasis")
    moved_b_chasis.transform = tr2.translate(0, 0, -0.4)
    moved_b_chasis.childs += [bot_chasis]

    ventana = sg.SceneGraphNode("ventana")
    ventana.transform = np.matmul(tr2.scale(0.6 / 4, 0.3 / 4, 0.3 / 4),
                                  tr2.translate(0, 0, -4.5))
    ventana.childs += [gpuChasisQuad_color1]

    palito = sg.SceneGraphNode("palito")
    palito.transform = np.matmul(tr2.scale(0.2, 0.01, 0.01),
                                 tr2.translate(0.3, -0, -35),
                                 tr2.rotationY(np.pi / 6))
    palito.childs += [gpuChasisQuad_color1]

    # Joining chasis parts
    complete_chasis = sg.SceneGraphNode("complete_chasis")
    complete_chasis.childs += [moved_b_chasis]
    complete_chasis.childs += [ventana]
    complete_chasis.childs += [palito]

    # All pieces together
    car = sg.SceneGraphNode("car")
    car.childs += [complete_chasis]
    car.childs += [frontrueda]
    car.childs += [backrueda]

    return car