def init(self): Scene.init(self) self.triangles = triangles = openOff( "./meshes/icosa.off").get_triangles() self.mesh = TriangleMeshNode( triangles=triangles, scene=self, #scaling=[0.5, 0.5, 0.5], scaling=[1.0, 1.0, 1.0], position=[0.0, 0.0, 0.0], draw_origin=False) self.pointer = PointerNode(scene=self, draw_origin=False) self.points = ColoredPointCloudNode(scene=self, color=(1.0, 1.0, 1.0, 1.0), position=[0.0, 0.0, 10.0], draw_origin=False) self.helpers = ColoredPointCloudNode(scene=self, color=(1.0, 1.0, 1.0, 1.0), position=[0.0, 0.0, 0.0], draw_origin=False) self.children.append(self.mesh) self.children.append(self.pointer) self.children.append(self.points) self.children.append(self.helpers)
def draw(self): modelview = array(glGetDoublev(GL_MODELVIEW_MATRIX)).transpose() inv_modelview = inv(modelview) self.eye = dot(inv_modelview, array([0.0, 0.0, 0.0, 1.0])) # self.eye /= self.eye[3] # print modelview # print self.eye Scene.draw(self)
def draw(self): modelview = array(glGetDoublev(GL_MODELVIEW_MATRIX)).transpose() inv_modelview = inv(modelview) self.eye = dot(inv_modelview, array([0.0, 0.0, 0.0, 1.0])) #self.eye /= self.eye[3] #print modelview #print self.eye Scene.draw(self)
def init(self): Scene.init(self) # get triangle bsp tree triangles = openOff("./meshes/teapot.off").get_triangles() self._log.debug(u"Constructing bsp tree...") bsptree = TriangleBspTree(triangles, scene=self, #scaling=[0.5, 0.5, 0.5], position=[0.0, 0.0, 0.0], draw_origin=False) self._log.debug(u"Partitioning using autopartition...") bsptree.autopartition() #bsptree.testpartition() self.children.append(bsptree)
def init(self): Scene.init(self) # get triangle bsp tree triangles = openOff("./meshes/teapot.off").get_triangles() self._log.debug(u"Constructing bsp tree...") bsptree = TriangleBspTree( triangles, scene=self, # scaling=[0.5, 0.5, 0.5], position=[0.0, 0.0, 0.0], draw_origin=False, ) self._log.debug(u"Partitioning using autopartition...") bsptree.autopartition() # bsptree.testpartition() self.children.append(bsptree)
def init(self): Scene.init(self) self.triangles = triangles = openOff("./meshes/icosa.off").get_triangles() self.mesh = TriangleMeshNode( triangles=triangles, scene=self, # scaling=[0.5, 0.5, 0.5], scaling=[1.0, 1.0, 1.0], position=[0.0, 0.0, 0.0], draw_origin=False, ) self.pointer = PointerNode(scene=self, draw_origin=False) self.points = ColoredPointCloudNode( scene=self, color=(1.0, 1.0, 1.0, 1.0), position=[0.0, 0.0, 10.0], draw_origin=False ) self.helpers = ColoredPointCloudNode( scene=self, color=(1.0, 1.0, 1.0, 1.0), position=[0.0, 0.0, 0.0], draw_origin=False ) self.children.append(self.mesh) self.children.append(self.pointer) self.children.append(self.points) self.children.append(self.helpers)
def __init__(self, application): Scene.__init__(self, application, name="cg1_ex5", draw_origin=False) #self.eye = array([0.0, 0.0, 0.0, 1.0]) self.max_recursion = 2
from __future__ import division from random import seed from mathutils import Point3D from imageutils import Image from raytracer import render, trace_ray from scenegraph import Scene class Path: def __init__(self, primary_hit, last_hit): self.primary_hit = primary_hit self.last_hit = last_hit self.depth = 0 if __name__ == "__main__": scene = Scene() seed(10) camera_position = Point3D(0, 0, 0) image = Image() render(scene, camera_position, image) image.write("out.ppm") trace_ray(129, 188, camera_position, scene)
def __init__(self, application): Scene.__init__(self, application, name="cg1_ex5", draw_origin=False) # self.eye = array([0.0, 0.0, 0.0, 1.0]) self.max_recursion = 2
def init(self): Scene.init(self) # add child nodes torso = CuboidNode( scene=self, name="torso", size=[0.3, 0.5, 0.3], position=[0, 0, 0], rotation=[0, 0, 0], offset=[0, 0, 0], color=[1, 1, 1, 0.1], draw_origin=True, ) head = CuboidNode( scene=self, name="head", size=[0.15, 0.15, 0.15], position=[0, 0.25, 0], rotation=[0, 0, 0], offset=[0, -0.075, 0], color=[1, 1, 1, 0.1], draw_origin=True, ) leg = CuboidNode( scene=self, name="leg", size=[0.1, 0.4, 0.1], position=[0, -0.25, 0], rotation=[0, 0, 0], offset=[0, 0.2, 0], color=[1, 1, 1, 0.1], draw_origin=True, ) foot = CuboidNode( scene=self, name="foot", size=[0.2, 0.05, 0.2], position=[0, -0.4, 0], rotation=[0, 0, 0], offset=[0, 0.025, 0], color=[1, 1, 1, 0.1], draw_origin=True, ) larm = CuboidNode( scene=self, name="left arm", size=[0.1, 0.4, 0.1], position=[-0.15, 0.25, 0], rotation=[-30, 0, 0], offset=[0.05, 0.2, 0], color=[1, 1, 1, 0.1], draw_origin=True, ) rarm = CuboidNode( scene=self, name="right arm", size=[0.1, 0.4, 0.1], position=[0.15, 0.25, 0], rotation=[15, 0, 0], offset=[-0.05, 0.2, 0], color=[1, 1, 1, 0.1], draw_origin=True, ) lhand = CuboidNode( scene=self, name="left hand", size=[0.05, 0.15, 0.05], position=[-0.05, -0.4, 0], rotation=[-15, 0, 0], offset=[0, 0.075, 0], color=[1, 1, 1, 0.1], draw_origin=True, ) rhand = CuboidNode( scene=self, name="right hand", size=[0.05, 0.15, 0.05], position=[0.05, -0.4, 0], rotation=[0, 0, 0], offset=[0, 0.075, 0], color=[1, 1, 1, 0.1], draw_origin=True, ) self.children.append(torso) torso.children.append(head) torso.children.append(leg) leg.children.append(foot) torso.children.append(larm) torso.children.append(rarm) larm.children.append(lhand) rarm.children.append(rhand)
def __init__(self, application): Scene.__init__(self, application, name="cg1_ex4", draw_origin=False)
def __init__(self, application): Scene.__init__(self, application, name="cg1_ex3", draw_origin=False) self.eye = array([0.0, 0.0, 0.0, 1.0])
def init(self): Scene.init(self) # add child nodes torso = CuboidNode(scene=self, name="torso", size=[0.3, 0.5, 0.3], position=[0, 0, 0], rotation=[0, 0, 0], offset=[0, 0, 0], color=[1, 1, 1, 0.1], draw_origin=True) head = CuboidNode(scene=self, name="head", size=[0.15, 0.15, 0.15], position=[0, 0.25, 0], rotation=[0, 0, 0], offset=[0, -0.075, 0], color=[1, 1, 1, 0.1], draw_origin=True) leg = CuboidNode(scene=self, name="leg", size=[0.1, 0.4, 0.1], position=[0, -0.25, 0], rotation=[0, 0, 0], offset=[0, 0.2, 0], color=[1, 1, 1, 0.1], draw_origin=True) foot = CuboidNode(scene=self, name="foot", size=[0.2, 0.05, 0.2], position=[0, -0.4, 0], rotation=[0, 0, 0], offset=[0, 0.025, 0], color=[1, 1, 1, 0.1], draw_origin=True) larm = CuboidNode(scene=self, name="left arm", size=[0.1, 0.4, 0.1], position=[-0.15, 0.25, 0], rotation=[-30, 0, 0], offset=[0.05, 0.2, 0], color=[1, 1, 1, 0.1], draw_origin=True) rarm = CuboidNode(scene=self, name="right arm", size=[0.1, 0.4, 0.1], position=[0.15, 0.25, 0], rotation=[15, 0, 0], offset=[-0.05, 0.2, 0], color=[1, 1, 1, 0.1], draw_origin=True) lhand = CuboidNode(scene=self, name="left hand", size=[0.05, 0.15, 0.05], position=[-0.05, -0.4, 0], rotation=[-15, 0, 0], offset=[0, 0.075, 0], color=[1, 1, 1, 0.1], draw_origin=True) rhand = CuboidNode(scene=self, name="right hand", size=[0.05, 0.15, 0.05], position=[0.05, -0.4, 0], rotation=[0, 0, 0], offset=[0, 0.075, 0], color=[1, 1, 1, 0.1], draw_origin=True) self.children.append(torso) torso.children.append(head) torso.children.append(leg) leg.children.append(foot) torso.children.append(larm) torso.children.append(rarm) larm.children.append(lhand) rarm.children.append(rhand)
def __init__(self, application): Scene.__init__(self, application, name="cg1_ex1", draw_origin=False)