def model(): """ Draws a cube at an angle so it is more interesting """ r = Render(800, 600) t = Texture('./models/model.bmp') r.load('./models/model.obj', (1, 1, 1), (300, 300, 300), texture=t) r.display('out.bmp')
def earth(): """ Draws planet earth, racism free """ r = Render(800, 600) t = Texture('./models/earth.bmp') r.load('./models/earth.obj', (800, 600, 0), (0.5, 0.5, 1), texture=t) r.display('out.bmp')
def model_high_angle(): render = Render(2000, 2000) render.light = render.vector(0, 0, 1) render.active_texture = Texture('./models/Face/model.bmp') render.active_shader = shaders.randomPattern render.load_model_3D('./models/Face/model.obj', scale=render.vector(200, 200, 200), rotate=render.vector(35, 350, 0)) render.glFinish('output/high_angle.bmp')
def model_dutch_angle(): render = Render(2000, 2000) render.light = render.vector(0, 0, 1) render.active_texture = Texture('./models/Face/model.bmp') render.active_shader = shaders.grayscale render.load_model_3D('./models/Face/model.obj', scale=render.vector(200, 200, 200), rotate=render.vector(35, 25, 0)) render.glFinish('output/dutch_angle.bmp')
def model_texture(): render = Render(2000, 2000) render.light = render.vector(0, 0, 1) render.active_texture = Texture('./models/Face/model.bmp') render.active_shader = shaders.randomPattern render.load_model_3D('./models/Face/model.obj', scale=render.vector(200, 200, 200), rotate=render.vector(0, 0, 0)) render.glFinish() render.glZBuffer()
def model(): """ Draws a cube at an angle so it is more interesting """ r = Render(800, 600) t = Texture('./models/model.bmp') r.active_texture = t r.load('./models/model.obj', (1, 1, 1), (300, 300, 300)) r.draw_arrays('TRIANGLES') r.display('out.bmp')
def proyecto1(): render = Render(1080, 1080) background = Texture('./models/fondos/fondo.bmp') render.viewPort = background.pixels render.lookAt(render.vector(1, 1, 1), render.vector(0, 0, 0)) render.light = render.vector(0, 0, 1) render.active_shader = shaders.underwater render.load_model_3D('./models/Biplane/OBJ/HiPoly/Biplane.obj', scale=render.vector(18, 18, 18), rotate=render.vector(20, 225, 0), translate=render.vector(-0.5, -0.15, 0)) render.active_shader = shaders.grayscale render.active_texture = Texture('./models/beriev/Beriev_2048.bmp') render.load_model_3D('./models/beriev/BerievA50.obj', scale=render.vector(2, 2, 2), rotate=render.vector(340, 90, 0), translate=render.vector(0.25, 0.8, 0)) render.active_shader = shaders.toon render.active_texture = Texture('./models/f104/Albedo.bmp') render.load_model_3D('./models/f104/F-104.obj', scale=render.vector(7.5, 7.5, 7.5), rotate=render.vector(340, 90, 0), translate=render.vector(-0.1, 0.7, -0.25)) render.active_shader = shaders.randomPattern render.active_texture = Texture('./models/f16/Albedo.bmp') render.load_model_3D('./models/f16/F-16D.obj', scale=render.vector(20, 20, 20), rotate=render.vector(0, 340, 320), translate=render.vector(0.5, 0, -0.75)) render.active_shader = shaders.randomPattern render.active_texture = Texture('./models/dilophosaurus/skin.bmp') render.load_model_3D('./models/dilophosaurus/dilophosaurus.obj', scale=render.vector(100, 100, 100), rotate=render.vector(35, 25, 0), translate=render.vector(0.25, -0.6, -0.25)) render.active_shader = shaders.heat render.active_texture = Texture('./models/dilophosaurus/skin.bmp') render.load_model_3D('./models/dilophosaurus/dilophosaurus.obj', scale=render.vector(25, 25, 25), rotate=render.vector(10, 90, 0), translate=render.vector(0, -0.6, -0.5)) render.glFinish('output/proyecto1.bmp')
def goomba(): """ Draws a cube at an angle so it is more interesting """ t = Texture("./goomba_grp.bmp") r.load("./goomba.obj", (110, 2, 1), (3.5, 3.5, 3.5), texture=t)
def bmax(): t = Texture("./EyesWhite.bmp") r.load("./Bigmax_White_OBJ.obj", (150, 2, 1), (5, 5, 5), texture=t)
for x in range(15, 2500 - 2): for y in range(15, 1800 - 2): size = random.randint(1, 1080) if size == 2 and x % 2 != 0 and y % 2 != 0: for i in range(1, 15): r.glVertex_coord(x, y) r.glVertex_coord(x + i, y) r.glVertex_coord(x, y + i) r.glVertex_coord(x - i, y) r.glVertex_coord(x, y - i) posModel = V3(0, 0, -5) r.lookAt(posModel, V3(0, 0, 0)) r.active_texture = Texture('./models/earthday.bmp') r.active_shader = mutedColors r.loadModel('./models/earth.obj', V3(-4, -2.5, -7), V3(0.003, 0.003, 0.003), V3(0, 0, 45)) r.active_texture = Texture('./models/spaceship.bmp') r.active_shader = phong r.loadModel('./models/spaceship.obj', V3(2, 1.4, -6), V3(0.003, 0.003, 0.003), V3(0, 0, -30)) r.active_texture = Texture('./models/rocket.bmp') r.active_shader = toon r.loadModel('./models/rocket.obj', V3(-1.5, -0.7, -4), V3(0.003, 0.003, 0.003), V3(-10, 200, -30)) r.active_texture = Texture('./models/mars.bmp')
def luigi(): """ Draws a cube at an angle so it is more interesting """ t = Texture("./luigiD.bmp") r.load("./Luigi_obj.obj", (110, 2, 1), (3.5, 3.5, 3.5), texture=t)
from gl import Render, color, V2, V3 from obj import Obj, Texture import random r = Render(1000,1000) t = Texture('./models/model.bmp') r.loadModel('./models/model.obj', V3(500,500,0), V3(300,300,300), t) r.glFinish('output.bmp') #r.glZBuffer('zbuffer.bmp')
""" Maria Ines Vasquez Figueroa 18250 Gráficas SR5 Textures Main """ from gl import Render from obj import Obj, Texture #valores con los que se inicializan la ventana y viewport width = 1000 height = 1000 #creacion de Window r = Render(width, height) #se carga textura y modelo obj con la textura ##para cargar pelota de basketball t = Texture('./models/ball.bmp') r.loadModel('./models/earth.obj', (500, 500, 0), (1, 1, 1), t) #para cargar ejemplo OBJ de Carlos """t = Texture('./models/model.bmp') r.loadModel('./models/model.obj', (500,500,0), (300,300,300), t)""" r.glFinish('output.bmp')
# Gian Luca Rivera - 18049 from gl import Render from obj import Obj, Texture from shaders import gooch, static, phong, toon, normalMap, sand, moss # 3840 × 2160 bitmap = Render(3840, 2160) # bitmap.glViewPort(0, 0, 3840 , 2160) background = Texture('./background.bmp') bitmap.pixels = background.pixels # bitmap.lookAt((0, 0, -5), (2, 2, 0)) bitmap.active_texture = Texture('./Models/Textures/Stormtrooper.bmp') bitmap.active_normalMap = Texture('./Models/Textures/Stormtrooper_N.bmp') bitmap.active_shader = normalMap bitmap.loadObjModel('./Models/stormtrooper2.obj', (2600, 200, 0), (150, 150, 150), (0, -110, 0)) bitmap.active_texture = Texture('./Models/Textures/Body_Diffuse.bmp') bitmap.active_shader = moss bitmap.loadObjModel('./Models/bb-unit.obj', (900, 300, 0), (1.5, 1.5, 1.5), (0, 30, 0)) bitmap.active_texture = Texture('./Models/Textures/arc170fighter.bmp') bitmap.active_shader = gooch bitmap.loadObjModel('./Models/Arc170.obj', (2300, 1700, 0), (0.5, 0.5, 0.5), (0, 210, 30))
from gl import Render from obj import Texture from usefullFunctions import Matrix, matrixMultiplication, V3, norm from shaders import unlit, gouradShader r = Render(1024, 1024) r.lookAt(V3(0, 0, 100), V3(0, 0, 0), V3(0, 1, 0)) r.light = norm(V3(0, 0, 1)) t = Texture('models/space.bmp') r.active_texture = t r.paintBackground() t = Texture('models/surface.bmp') r.active_texture = t r.load('models/earth.obj', [0, 0.2, 0], [0.2, 0.2, 1], [0, 0, 0]) r.draw_arrays('TRIANGLE') t = Texture('models/moon.bmp') r.active_texture = t r.active_shader = unlit r.load('models/sphere.obj', [0, -0.8, 50], [2, 1, 1], [0, 0, 0]) r.draw_arrays('TRIANGLE') r.light = norm(V3(1, 1, 1)) t = Texture('models/saturnmap.bmp') r.active_texture = t r.active_shader = gouradShader r.load('models/saturn.obj', [-1.5, 1, -50], [1, 1, 1], [0, 0, 0]) r.draw_arrays('TRIANGLE') t = Texture('models/satelite.bmp') r.active_texture = t r.load('models/satelite.obj', [-0.4, 0, 30], [0.025, 0.025, 1], [0, 0, 0.2])
from gl import Render, color, V2, V3 from obj import Obj, Texture from shaders import * r = Render() r.glCreateWindow(1280, 720) # # Se carga el fondo de pantalla # imagen: fondo.bmp # print( 'Se va a cargar una escena, esta operación puede tardar unos minutos...\n') print('Cargando fondo de la escena...') fondo = Texture('./models/fondo.bmp') r.pixels = fondo.pixels print('Fondo cargado...') # # se agrega la camara # se setea la posición inicial de los modelos respecto a la cámara # posModel = V3(0, 0, 200) r.lookAt(posModel, V3(0, 0, 5)) #5,5,0 # # Se agrega el modelo de la torre de agua con textura y shader. # obj: water_tower.bmp # textura: water_tower.obj # shader: static_matix
def face(): r = Render(800, 600) t = Texture('./models/earth.bmp') r.load('./face.obj', (25, 5, 0), (15, 15, 15)) r.display('out.bmp')
from gr import Render, color from obj import Obj, Texture from shaders import * r = Render(512, 384) print("renderizando fondo") r.BgImage("./models/room.bmp") print("renderizando modelo 1/5") r.active_texture = Texture('./models/tv.bmp') r.active_shader = gourad #translate scale rotate r.loadModel('./models/tv.obj', (250, 60, -140), (60, 60, 60), (0, 0, 0)) print("renderizando modelo 2/5") r.active_texture = Texture('./models/woodtex.bmp') r.active_shader = gourad #translate scale rotate r.loadModel('./models/meja.obj', (250, 165, 20), (25, 25, 35), (10, 90, 0)) print("renderizando modelo 3/5") r.active_texture = Texture('./models/pandas.bmp') r.active_shader = gourad #translate scale rotate r.loadModel('./models/Panda.obj', (200, 200, 0), (8, 8, 8), (10, 90, 0)) print("renderizando modelo 4/5") r.active_texture = Texture('./models/bearskin.bmp') r.active_shader = gourad #translate scale rotate r.loadModel('./models/bear.obj', (310, 170, 0), (25, 25, 25), (10, -90, 0))
# -*- coding: utf-8 -*- """ Created on Sat Mar 16 12:45:21 2019 @author: Cristian """ import gl from obj import Texture gl.glCreateWindow(1000, 1000) tex = Texture('./sky.bmp') gl.glLoad('./earth.obj', (1000, 800, 0), (0.5, 0.5, 1), texture=tex) gl.glFinish('sr5')
from gl import Render, color, V2, V3 from obj import Obj, Texture from shaders import * r = Render() r.glCreateWindow(500, 500) r.active_texture = Texture('./models/model.bmp') r.active_shader = gourad posModel = V3(0, 3, 0) r.lookAt(posModel, V3(0, 0, -5)) r.glLoadModel('./models/model.obj', posModel, V3(2, 2, 2), V3(0, 0, 0)) r.glFinish('high_angle.bmp') r.glClear() posModel = V3(0, -3, 0) r.lookAt(posModel, V3(0, 0, -5)) r.glLoadModel('./models/model.obj', posModel, V3(2, 2, 2), V3(0, 0, 0)) r.glFinish('low_angle.bmp') r.glClear() posModel = V3(0, 0, 0) r.lookAt(posModel, V3(0, 0, -5)) r.glLoadModel('./models/model.obj', posModel, V3(2, 2, 2), V3(0, 0, 0)) r.glFinish('medium_angle.bmp') r.glClear()
def mario(): """ Draws a cube at an angle so it is more interesting """ t = Texture("./marioD1.bmp") r.load("./mario_obj.obj", (120, 2, 1), (3.5, 3.5, 3.5), texture=t)
from gl import Render, color, V2, V3 from obj import Obj, Texture from shaders import * r = Render(1920, 1080) #usamos la textura de dojo para hacer el fondo texture = Texture('./models/dojo.bmp') r.glBackground(texture) #katana (phong) r.active_shader = phong posModel = V3(2, 0, -5) r.active_texture = Texture('./models/Albedo.bmp') r.loadModel('./models/katana.obj', posModel, V3(4, 4, 4), V3(0, 0, 270)) #cleaver (freedom) r.active_shader = freedom posModel = V3(-3, 0, -5) r.active_texture = Texture('./models/cleaver.bmp') r.loadModel('./models/cleaver.obj', posModel, V3(10, 10, 10), V3(90, 0, -30)) #dagger (infrarojo)
def proyecto(): wood = Material(texture=Texture('assets/wood.bmp')) white_snow = Material(diffuse=Color.color(1, 0.98, 0.98), spec=96) grass = Material(diffuse=Color.color(0.26, 0.42, 0.18), spec=96) water = Material(diffuse=Color.color(0.031, 0.255, 0.361), spec=50, ior=1.5, matType=REFLECTIVE) darkblue = Material(diffuse=Color.color(0.031, 0.255, 0.361), spec=64) playera = Material(diffuse=Color.color(0.2, 0.86, 0.85), spec=64) piel = Material(diffuse=Color.color(0.85, 0.71, 0.45), spec=64) cafe = Material(diffuse=Color.color(0.32, 0.24, 0.08), spec=64) window = Material(spec=40, ior=1.5, matType=TRANSPARENT) rayTracer = Raytracer(500, 500) rayTracer.pointLight = PointLight(position=Raytracer.vector(0, 0, 0), intensity=1) rayTracer.pointLight = PointLight(position=Raytracer.vector(0, 1, 0), intensity=1) rayTracer.ambientLight = AmbientLight(strength=0.1) rayTracer.dirLight = DirectionalLight(direction=rayTracer.vector( 1, -1, -2), intensity=0.5) rayTracer.envmap = Envmap('assets/unnamed.bmp') # Suelo rayTracer.scene.append( Plane(Raytracer.vector(0, -5, 0), Raytracer.vector(0, 1, 0), grass)) # Agua rayTracer.scene.append( AABB(Raytracer.vector(-5, -5, -10), Raytracer.vector(7, 0.2, 5), water)) # Suelo rayTracer.scene.append( AABB(Raytracer.vector(-1, -4, -19), Raytracer.vector(20, 1, 10), grass)) rayTracer.scene.append( AABB(Raytracer.vector(3, -3, -21), Raytracer.vector(17, 1, 10), grass)) rayTracer.scene.append( AABB(Raytracer.vector(6, -2, -23), Raytracer.vector(15, 1, 10), grass)) # Casa rayTracer.scene.append( AABB(Raytracer.vector(9, 0, -25), Raytracer.vector(10, 10, 10), wood)) # Ventana rayTracer.scene.append( AABB(Raytracer.vector(8, 2, -25), Raytracer.vector(5, 3, 11), window)) # Steve # ======================= # Piernas rayTracer.scene.append( AABB(Raytracer.vector(2, -4, -10), Raytracer.vector(0.5, 1.5, 0.5), darkblue)) rayTracer.scene.append( AABB(Raytracer.vector(2.6, -4, -10), Raytracer.vector(0.5, 1.5, 0.5), darkblue)) # Playera rayTracer.scene.append( AABB(Raytracer.vector(2.3, -2.5, -10), Raytracer.vector(1.1, 1.5, 0.5), playera)) rayTracer.scene.append( AABB(Raytracer.vector(1.5, -2, -10), Raytracer.vector(0.5, 0.5, 0.5), playera)) rayTracer.scene.append( AABB(Raytracer.vector(3.1, -2, -10), Raytracer.vector(0.5, 0.5, 0.5), playera)) # Brazos rayTracer.scene.append( AABB(Raytracer.vector(1.5, -2.75, -10), Raytracer.vector(0.5, 1, 0.5), piel)) rayTracer.scene.append( AABB(Raytracer.vector(3.1, -2.75, -10), Raytracer.vector(0.5, 1, 0.5), piel)) # Cabeza rayTracer.scene.append( AABB(Raytracer.vector(2.3, -1.3, -10), Raytracer.vector(1.1, 0.9, 1), piel)) # Pelo rayTracer.scene.append( AABB(Raytracer.vector(2.3, -0.75, -10), Raytracer.vector(1.1, 0.2, 1), cafe)) # Ojos rayTracer.scene.append( AABB(Raytracer.vector(2.1, -1.2, -9.5), Raytracer.vector(0.1, 0.1, 0.2), cafe)) rayTracer.scene.append( AABB(Raytracer.vector(2, -1.2, -9.5), Raytracer.vector(0.1, 0.1, 0.2), white_snow)) rayTracer.scene.append( AABB(Raytracer.vector(2.5, -1.2, -9.5), Raytracer.vector(0.1, 0.1, 0.2), cafe)) rayTracer.scene.append( AABB(Raytracer.vector(2.6, -1.2, -9.5), Raytracer.vector(0.1, 0.1, 0.2), white_snow)) # Boca rayTracer.scene.append( AABB(Raytracer.vector(2.1, -1.4, -9.5), Raytracer.vector(0.1, 0.1, 0.2), cafe)) rayTracer.scene.append( AABB(Raytracer.vector(2.1, -1.5, -9.5), Raytracer.vector(0.1, 0.1, 0.2), cafe)) rayTracer.scene.append( AABB(Raytracer.vector(2.5, -1.4, -9.5), Raytracer.vector(0.1, 0.1, 0.2), cafe)) rayTracer.scene.append( AABB(Raytracer.vector(2.5, -1.5, -9.5), Raytracer.vector(0.1, 0.1, 0.2), cafe)) rayTracer.scene.append( AABB(Raytracer.vector(2.2, -1.5, -9.5), Raytracer.vector(0.1, 0.1, 0.2), cafe)) rayTracer.scene.append( AABB(Raytracer.vector(2.3, -1.5, -9.5), Raytracer.vector(0.1, 0.1, 0.2), cafe)) rayTracer.scene.append( AABB(Raytracer.vector(2.4, -1.5, -9.5), Raytracer.vector(0.1, 0.1, 0.2), cafe)) rayTracer.rtRender() rayTracer.glFinish('output/dr3.bmp')
def model(): r = Render(800, 600) t = Texture('./models/model.bmp') r.load('./models/model.obj', (1, 1, 1), (300, 300, 300), texture=t) r.display('out.bmp')
elif size==3: r.glVertex_coord(x,y) r.glVertex_coord(x+1,y) r.glVertex_coord(x,y+1) r.glVertex_coord(x-1,y) #r.glColor(1,1,1) #r.glVertex_coord(960,540) posModel = ( 0, 0, -5) r.lookAt(posModel, (0,0,0)) #rocketModel Texture r.active_texture = Texture('./models/planespace.bmp') r.active_shader = toon #rocketModel r.loadModel('./models/space-shuttle-orbiter.obj', (3,-1,-4), (0.002,0.002,0.002),(0,130,0)) #astro texture r.active_texture = Texture('./models/suit.bmp') r.active_normalMap = Texture('./models/normal_suit.bmp') r.active_shader = normalMap #Astro r.loadModel('./models/astronaute.obj', (-1,1,-5), (0.5,0.5,0.5),(0,0,0)) #mars r.active_texture = Texture('./models/metal.bmp')
r.load('./sphere.obj', translate=(5,0,6), scale=(0.1,0.1,0.1), rotate=(0,0,0)) r.drawArrays('SHADER') r.load('./sphere.obj', translate=(4,-1,2), scale=(0.038,0.038,0.038), rotate=(0,0,0)) r.drawArrays('SHADER') r.load('./sphere.obj', translate=(3,-1,2), scale=(0.03,0.03,0.03), rotate=(0,0,0)) r.drawArrays('SHADER') r.load('./sphere.obj', translate=(4,-1,6), scale=(0.085,0.085,0.085), rotate=(0,0,0)) r.drawArrays('SHADER') r.load('./sphere.obj', translate=(4,0,8), scale=(0.1,0.1,0.1), rotate=(0,0,0)) r.drawArrays('SHADER') t = Texture('./sun2.bmp') r.texture = t r.light = V3(0,0,1) r.lookAt(V3(1, 0, 1), V3(0, 0, 0), V3(0, 1, 0)) r.load('./Dark Knight.obj', translate=(9, 10, 20), scale=(0.045, 0.045, 0.045), rotate=(0,4*pi/5,pi)) r.drawArrays('GREYSHADER') r.load('./cube.obj', translate=(0.5, 18, 20), scale=(3, 3.5, 1), rotate=(0,0,pi/2)) r.drawArrays('GREYSHADER') t = Texture('./fur.bmp') r.texture = t r.load('./Alien Animal.obj', translate=(250, 0, 135), scale=(3, 3, 4), rotate=(pi, pi, 0)) r.drawArrays('TRIANGLE') r.glFinish('proyectoScene.bmp')
def earth(): r = Render(800, 600) t = Texture('./models/earth.bmp') r.load('./models/earth.obj', (800, 600, 0), (0.5, 0.5, 1), texture=t) r.display('out.bmp')
from gl import Raytracer, color, V2, V3 from obj import Obj, Texture, Envmap from sphere import * import random brick = Material(diffuse=color(0.8, 0.25, 0.25), spec=16) stone = Material(diffuse=color(0.4, 0.4, 0.4), spec=32) mirror = Material(spec=64, matType=REFLECTIVE) glass = Material(spec=64, ior=1.5, matType=TRANSPARENT) boxMat = Material(texture=Texture('box.bmp')) earthMat = Material(texture=Texture('earthDay.bmp')) width = 512 height = 512 r = Raytracer(width, height) r.glClearColor(0.2, 0.6, 0.8) r.glClear() r.envmap = Envmap('envmap.bmp') # Lights #r.pointLights.append( PointLight(position = V3(-4,4,0), intensity = 0.5)) #r.pointLights.append( PointLight(position = V3( 4,0,0), intensity = 0.5)) r.dirLight = DirectionalLight(direction=V3(1, -1, -2), intensity=0.5) r.ambientLight = AmbientLight(strength=0.1) # Objects #r.scene.append( Sphere(V3( 0, 0, -8), 2, brick) ) #r.scene.append( Sphere(V3( -0.5, 0.5, -5), 0.25, stone))
def car(): r = Render(800, 600) t = Texture('./models/car.bmp') r.load('./models/car.obj', (60, 20, 1), (5, 5, 5), texture=t) r.display('out.bmp')
from gl import Render, color, V2, V3 from obj import Obj, Texture import glMath from shaders import * import random r = Render(1000, 1000) r.active_texture = Texture('./models/earthDay.bmp') r.active_texture2 = Texture('./models/earthNight.bmp') r.active_shader = toon luz = V3(0, 0, 1) r.light = glMath.normalize(luz) r.loadModel('./models/earth.obj', V3(500, 500, 0), V3(1, 1, 1)) r.glFinish('toon.bmp')