예제 #1
0
    def _build_tree(self):
        # build tree
        self._log.info(u"Building kd-tree...")
        self.tree = KdTree(point_list=openOff(self._model_var.get()).get_vertices())
        self._log.info(u"Building kd-tree done.")
        
        # create vertex visualization
        self._log.info(u"Building kd-tree vizualization...")
        GLTargetDistantLight(
            pos = (0.3, -0.5, 1)
        )
        mat = GLMaterial(
            diffuse = (1, 0, 0)
            )

        vertices = list(self.tree.iter_vertices())
        t_vertices, t_faces = self._generate_trimesh_params(vertices)
        TriMesh(verts=t_vertices, faces=t_faces, material=mat) #, dynamics=False, static=True)

        #for vertex in list(tree.iter_vertices()):
            #Box(pos=vertex, lx=0.05, ly=0.05, lz=0.05, dynamics=False, static=True, material=mat)
        #Sphere()

        # create bbox visualization
        pass
        self._log.info(u"Building kd-tree vizualization done.")
예제 #2
0
    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)
예제 #3
0
 def from_file(cls, filename):
     logging.getLogger('SurfaceFactory').info(u"Reading surface from '%s'..." % filename)
     vertices = []
     normals = []
     for vertex, normal in openOff(filename).iter_vertices_and_normals():
         vertices.append(vertex)
         normals.append(normal)
     return cls(points=vertices, normals=normals)
예제 #4
0
 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)
예제 #5
0
 def from_file(cls, filename, invert_normals=False):
     logging.getLogger('SurfaceFactory').info(u"Reading surface from '%s'..." % filename)
     vertices = []
     normals = []
     for vertex, normal in openOff(filename).iter_vertices_and_normals():
         vertices.append(vertex)
         normals.append(normal)
     vertices = array(vertices)
     normals = array(normals)
     # scale points
     scale_factor = 1.0/norm(max(vertices, 0) - min(vertices, 0))
     vertices *= scale_factor
     # invert normals?
     if invert_normals:
         normals *= -1
     return cls(points=vertices, normals=normals)
예제 #6
0
    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)
예제 #7
0
 def init(self):
     WindowedScene.init(self)
     glutSetWindow(self.window)
     
     self.tex = Texture(image = self.application._current_texture)
     # get triangle mesh
     self._log.debug(u"Loading mesh...")
     triangles = openOff("./data/cow.off").get_triangles()
     mesh = TriangleMeshNode(triangles   = triangles,
                             scene       = self, 
                             #scaling=[0.5, 0.5, 0.5],
                             position    = [0.0, 0.0, 0.0],
                             texture     = self.tex, 
                             draw_origin = False)
     self.cursor = CursorNode(scene      = self, 
                              draw_origin= False)
     self.children.append(mesh)
     mesh.children.append(self.cursor)
예제 #8
0
    def init(self):
        WindowedScene.init(self)
        glutSetWindow(self.window)

        self.tex = Texture(image=self.application._current_texture)
        # get triangle mesh
        self._log.debug(u"Loading mesh...")
        triangles = openOff("./data/cow.off").get_triangles()
        mesh = TriangleMeshNode(
            triangles=triangles,
            scene=self,
            # scaling=[0.5, 0.5, 0.5],
            position=[0.0, 0.0, 0.0],
            texture=self.tex,
            draw_origin=False,
        )
        self.cursor = CursorNode(scene=self, draw_origin=False)
        self.children.append(mesh)
        mesh.children.append(self.cursor)
예제 #9
0
    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)
예제 #10
0
    def _build_tree(self):
        # build tree
        self._log.info(u"Building kd-tree...")
        self.tree = KdTree(
            point_list=openOff(self._model_var.get()).get_vertices())
        self._log.info(u"Building kd-tree done.")

        # create vertex visualization
        self._log.info(u"Building kd-tree vizualization...")
        GLTargetDistantLight(pos=(0.3, -0.5, 1))
        mat = GLMaterial(diffuse=(1, 0, 0))

        vertices = list(self.tree.iter_vertices())
        t_vertices, t_faces = self._generate_trimesh_params(vertices)
        TriMesh(verts=t_vertices, faces=t_faces,
                material=mat)  #, dynamics=False, static=True)

        #for vertex in list(tree.iter_vertices()):
        #Box(pos=vertex, lx=0.05, ly=0.05, lz=0.05, dynamics=False, static=True, material=mat)
        #Sphere()

        # create bbox visualization
        pass
        self._log.info(u"Building kd-tree vizualization done.")
예제 #11
0
 def from_file(cls, filename):
     logging.getLogger('SurfaceFactory').info(u"Reading surface from '%s'..." % filename)
     return cls(openOff(filename).iter_vertices())