Esempio n. 1
0
cornellObjects[4].setRgbColor([1, 0, 0])  #left wall
cornellObjects[5].setRgbColor([0, 1, 0])  #right wall
cornellObjects[6].setRgbColor([0.96, 0.85, 0.69])  #back wall

cornellObjects[0].setMaterial(Material([1, 1, 1, 1], [0.1, 0.1, 0.2, 1], 0))
cornellObjects[1].setMaterial(Material([1, 1, 1, 1], [0.1, 0.1, 0.1, 1], 127))
cornellObjects[2].setMaterial(Material([1, 1, 1, 1], [0.3, 0.1, 0.1, 1], 127))
cornellObjects[3].setMaterial(Material([1, 1, 1, 1], [0.1, 0.1, 0.1, 1], 127))
cornellObjects[4].setMaterial(Material([1, 1, 1, 1], [0.2, 0.2, 0.1, 1], 127))
cornellObjects[5].setMaterial(Material([1, 1, 1, 1], [0.3, 0.1, 0.1, 1], 127))
cornellObjects[6].setMaterial(Material([1, 1, 1, 1], [0.1, 0.2, 0.1, 1], 127))

grid = Grid()
scene = Scene()
for obj in cornellObjects:
    scene.addObject(obj)
#scene.addObject(grid)

camera = Camera(Vec3d(-3, 25, 76), Vec3d(0, 0, -1))

light1 = Light([0.6, 0.6, 0.6, 1], [1, 1, 1, 1], [.1, .1, .1, 1],
               [16, 44, 0, 1], 1)
light2 = Light(
    [0.6, 0.6, 0.6, 1], [1, 1, 1, 1], [.1, .1, .1, 1], [-3.4, 25, 90], 2
)  #you can detect light2 by pressing s and going backward from initial position
light2.switchLight()  #turning of the light2.

scene.addObject(light1)
scene.addObject(light2)

# Some api in the chain is translating the keystrokes to this octal string
Esempio n. 2
0
from grid import Grid

from camera import Camera
from scene import Scene

firstMouse=False
lineVision=True
objVision=True

camera=Camera(Vec3d(0,0,5),Vec3d(0,0,-1))
scene=Scene()

grid=Grid()
ico=Icosahedron()

scene.addObject(ico)
scene.addObject(grid)
    

# Some api in the chain is translating the keystrokes to this octal string
# so instead of saying: ESCAPE = 27, we use the following.
ESCAPE = b'\033'

# Number of the glut window.
window = 0
# A general OpenGL initialization function.  Sets all of the initial parameters. 
def InitGL(Width, Height):              # We call this right after our OpenGL window is created.
    glClearColor(0.0, 0.0, 0.0, 0.0)    # This Will Clear The Background Color To Black
    glClearDepth(1.0)                   # Enables Clearing Of The Depth Buffer
    glDepthFunc(GL_LESS)                # The Type Of Depth Test To Do
    glEnable(GL_DEPTH_TEST)             # Enables Depth Testing
Esempio n. 3
0
    red = Vector(1, 0, 0)
    green = Vector(0, 1, 0)
    blue = Vector(0, 0, 1)
    yellow = Vector(1, 1, 0)
    grey = Vector(.5, .5, .5)

    # Materials
    redSurface = Material(red)
    greenSurface = Material(green)
    blueSurface = Material(blue)
    greySurface = Material(grey)
    yellowSurface = Material(yellow)
    checkerboard = CheckerboardMaterial() 

    # Add objects to scene
    scene.addObject(Sphere(Point(2.5, 3, -10), RADIUS, redSurface))
    scene.addObject(Sphere(Point(-2.5, 3, -10), RADIUS, greenSurface))
    scene.addObject(Sphere(Point(0, 7, -10), RADIUS, blueSurface))
    scene.addObject(Plane(Point(0, 0, 0), Vector(0, 1, 0), checkerboard))# greySurface))
    scene.addObject(Triangle(Point(2.5, 3, -10), Point(-2.5, 3, -10), Point(0, 7, -10), yellowSurface))

    scene.addLight(Light(Point(30, 30, 10)))

    scene.setUpCamera(Point(0,2,10), Vector(0,1,0), Point(0,3,0), FIELDOFVIEW)

    # and render
    scene.render(image, level=recursionLevel)
    
    print 'Rendering Time: %d seconds' % (time.time() - beginTime)
    
    image.show()
Esempio n. 4
0
    print("input only one .obj file to command line")
    sys.exit()

filename = sys.argv[1]  #get the filename from terminal

if filename.split(".")[
        1] != "obj":  # if file type is not .obj print error message and exit
    print("please input .obj file type to command line")
    sys.exit()

my_obj = DividableObject(
    filename)  #instantiate obj with the filename from terminal

grid = Grid()
scene = Scene()
scene.addObject(my_obj)
scene.addObject(grid)

camera = Camera(Vec3d(0, 0, 8), Vec3d(0, 0, -1))

# Some api in the chain is translating the keystrokes to this octal string
# so instead of saying: ESCAPE = 27, we use the following.
ESCAPE = b'\033'

# Number of the glut window.
window = 0


# A general OpenGL initialization function.  Sets all of the initial parameters.
def InitGL(Width,
           Height):  # We call this right after our OpenGL window is created.
Esempio n. 5
0
import sys

sys.path.append("..")

#from box import Box
from box2 import Box
from scene import Scene

box1 = Box(.5, .5, .5)
box1.translate(0.55, 0, 0)

box2 = Box(.5, .5, .5)
box2.translate(-0.55, 0, 0)

scene = Scene()
scene.addObject(box1)
scene.addObject(box2)

lineVision = True
objVision = True

ESCAPE = b'\033'


def render():
    global box1
    global lineVision
    global objVision

    glClearColor(0, 0, 0, 1)
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
Esempio n. 6
0
from vec3d import Vec3d
from camera import Camera
from scene import Scene
from rectangle2d import Rectangle2d
from triangle2d import Triangle2d

lineVision = True
objVision = True

scene = Scene()

rec = Rectangle2d(1, 1)
tri = Triangle2d(1.15)
tri.translate(0, -0.5, 0)

scene.addObject(rec)
scene.addObject(tri)

camera = Camera(Vec3d(1, 0, 5), Vec3d(0, 0, -1))
# Some api in the chain is translating the keystrokes to this octal string
# so instead of saying: ESCAPE = 27, we use the following.
ESCAPE = b'\033'

# Number of the glut window.
window = 0


# A general OpenGL initialization function.  Sets all of the initial parameters.
def InitGL(Width,
           Height):  # We call this right after our OpenGL window is created.
    glClearColor(0.0, 0.0, 0.0,