Exemplo n.º 1
0
    def gridify(self,*args):
        #take the selected object and create a new object that are the point inside
        #use a default stepsize for the grid
        #use some usefull tools from histovol.grid ?
        #probably need the normal for that
        mode = self.getVal(self.mode)
        step = self.getVal(self.grid_step)
        if self.object_target is None :
            self.object_target = self.helper.getCurrentSelection()[0]
        mesh = self.object_target
        #canwe usethe ogranelle mesh system from autopack
        from autopack.Organelle import Organelle
        faces,vertices,vnormals,fn = self.helper.DecomposeMesh(mesh,
                                    edit=False,copy=False,tri=True,transform=True,fn=True)
        o1 = Organelle(self.helper.getName(mesh),vertices, faces, vnormals,fnormals=fn)
        o1.ref_obj = mesh
        o1.number = 1
        b=self.helper.getObject("BBOX")
        if b is None :
            b = self.helper.Box("BBOX", cornerPoints=o1.bb)
            bb=o1.bb
        else :
            bb=self.helper.getCornerPointCube(b)
        display = self.getVal(self.rt_display)
        useFix= self.getVal(self.useFix)
        if mode =="bhtree_dot":
            inner, surface = o1.getSurfaceInnerPoints(bb,step,display=display,useFix=useFix)
        elif mode ==  "sdf_fixdimension":
            inner, surface = o1.getSurfaceInnerPoints_sdf(bb,step,display=display,useFix=useFix)
        elif mode ==  "sdf_interpolate":
            inner, surface = o1.getSurfaceInnerPoints_sdf_interpolate(bb,step,display=display,useFix=useFix)
        elif mode ==  "jordan_raycast":
            inner, surface = o1.getSurfaceInnerPoints_jordan(bb,step,display=display,useFix=useFix)
        elif mode ==  "jordan_3raycast":
            inner, surface = o1.getSurfaceInnerPoints_jordan(bb,step,display=display,useFix=useFix,ray=3)
#        inner, surface = o1.getSurfaceInnerPoints(bb,step,display=display,useFix=useFix)
        n1=n=o1.name+"_innerPts"
        n2=o1.name+"_surfacePts"
        if self.helper.host == "maya" :
            n=o1.name+"_innerPtsds"
        s = self.helper.getObject(n)
        if s is None :
            s = self.helper.PointCloudObject(n1, vertices=inner )
            s2 = self.helper.PointCloudObject(n2, vertices=surface )
        else :
            if self.helper.host == "c4d" :
                self.helper.updateMesh(s,vertices=inner)
            else :
                self.helper.updateParticle(s,inner,None)
Exemplo n.º 2
0
    def gridify(self, *args):
        #take the selected object and create a new object that are the point inside
        #use a default stepsize for the grid
        #use some usefull tools from histovol.grid ?
        #probably need the normal for that
        mode = self.getVal(self.mode)
        step = self.getVal(self.grid_step)
        if self.object_target is None:
            self.object_target = self.helper.getCurrentSelection()[0]
        mesh = self.object_target
        #canwe usethe ogranelle mesh system from autopack
        from autopack.Organelle import Organelle
        faces, vertices, vnormals, fn = self.helper.DecomposeMesh(
            mesh, edit=False, copy=False, tri=True, transform=True, fn=True)
        o1 = Organelle(self.helper.getName(mesh),
                       vertices,
                       faces,
                       vnormals,
                       fnormals=fn)
        o1.ref_obj = mesh
        o1.number = 1
        b = self.helper.getObject("BBOX")
        if b is None:
            b = self.helper.Box("BBOX", cornerPoints=o1.bb)
            bb = o1.bb
        else:
            bb = self.helper.getCornerPointCube(b)
        display = self.getVal(self.rt_display)
        useFix = self.getVal(self.useFix)
        if mode == "bhtree_dot":
            inner, surface = o1.getSurfaceInnerPoints(bb,
                                                      step,
                                                      display=display,
                                                      useFix=useFix)
        elif mode == "sdf_fixdimension":
            inner, surface = o1.getSurfaceInnerPoints_sdf(bb,
                                                          step,
                                                          display=display,
                                                          useFix=useFix)
        elif mode == "sdf_interpolate":
            inner, surface = o1.getSurfaceInnerPoints_sdf_interpolate(
                bb, step, display=display, useFix=useFix)
        elif mode == "jordan_raycast":
            inner, surface = o1.getSurfaceInnerPoints_jordan(bb,
                                                             step,
                                                             display=display,
                                                             useFix=useFix)
        elif mode == "jordan_3raycast":
            inner, surface = o1.getSurfaceInnerPoints_jordan(bb,
                                                             step,
                                                             display=display,
                                                             useFix=useFix,
                                                             ray=3)
#        inner, surface = o1.getSurfaceInnerPoints(bb,step,display=display,useFix=useFix)
        n1 = n = o1.name + "_innerPts"
        n2 = o1.name + "_surfacePts"
        if self.helper.host == "maya":
            n = o1.name + "_innerPtsds"
        s = self.helper.getObject(n)
        if s is None:
            s = self.helper.PointCloudObject(n1, vertices=inner)
            s2 = self.helper.PointCloudObject(n2, vertices=surface)
        else:
            if self.helper.host == "c4d":
                self.helper.updateMesh(s, vertices=inner)
            else:
                self.helper.updateParticle(s, inner, None)