コード例 #1
0
from render import Render, V2, V3

from obj import Obj

from texture import Texture

from shaders import gourad, toon, outline, toon_mod

from utils import color

r = Render()
r.glCreateWindow(1000,1000)
r.glClear()

r.active_texture = Texture('./models/model.bmp')
r.active_shader = toon

#r.light = V3(1,0,0)

r.loadModel('./models/model.obj', V3(250,500,0), V3(150,150,150))

r.active_shader = outline

r.loadModel('./models/model.obj', V3(500,500,0), V3(150,150,150))

r.active_shader = toon_mod

r.loadModel('./models/model.obj', V3(750,500,0), V3(150,150,150))


r.glFinish('output2.bmp')
コード例 #2
0
import random

width = 1920
height = 1076

r = Render(width, height)

r.light = V3(0, 0, 1)
# For background image
r.bk_texture = Texture('./models/background.bmp')
r.setBackground()

r.glColor(255, 255, 255)
# r.lookAt(posModel, V3(0,0,0))

r.active_shader = gourad

# horse model
r.active_shader = toon_mod
posModel = V3(0, -20, -40)
r.active_texture = Texture('./models/horse.bmp')
r.loadModel('./models/horse.obj', posModel, V3(0.05, 0.05, 0.05),
            V3(0, 160, 0))

r.active_shader = toon_mod
posModel = V3(-10, -20, -40)
r.active_texture = Texture('./models/horse.bmp')
r.loadModel('./models/horse.obj', posModel, V3(0.06, 0.06, 0.06),
            V3(0, -45, 0))

# UFO
コード例 #3
0
"""

We draw to moons, using an sphere model, each one has different texture
and differnt shader to produce the effect of an celestial body. This models
were made using bump mapping. 


"""

#Draw the moon Iscaco
t = Texture('./models/iscalo.bmp')
r.active_texture = t
r.active_light = norm(V3(0, 20, 0))
r.load('./models/sphere.obj', [-0.55, 0.70, 0], [0.22, 0.22, 0.22],
       [0, 0.2, 0])
r.active_shader = moon
r.draw_arrays('TRIANGLES')

#Draw the moon Urica
t = Texture('./models/urica.bmp')
r.active_texture = t
r.load('./models/sphere.obj', [0.57, 0.80, 0], [0.20, 0.20, 0.20], [0, 0.2, 0])
r.active_shader = planet
r.draw_arrays('TRIANGLES')
"""

We use model.bmp that is a face, to draw some mountains in the background, in 
this way we use just the back and top part of the face. We generate 30 faces of 
different sizes, to get the effect of mountains Sometimes this will develop a bad
effect because of random
コード例 #4
0
from utils import color

r = Render(1000, 1000)

r.light = V3(0, 0, 1)

posModel = V3(0, 0, -20)

#low-angle-shot
# r.lookAt(posModel, V3(0,-8,0))

#medium shot
# r.lookAt(posModel, V3(0,0,0))
# posModel = V3(0,0,-30)

# highangle
r.lookAt(posModel, V3(0, 15, 0))
posModel = V3(0, 5, -20)

#dutch angle
# r.camRotation = V3(0,0,15)
# r.createViewMatrix()
# r.createProjectionMatrix()
# posModel = V3(0,0,-20)

r.active_texture = Texture('./models/heli.bmp')
r.active_shader = unlit

r.loadModel('./models/heli.obj', posModel, V3(0.1, 0.1, 0.1), V3(0, 0, 0))

r.glFinish('highangle.bmp')