Beispiel #1
0
    def hidden_status(self, faces, mx, mx_n):
        # sort out back-faces = with normals pointed away from camera
        #print 'HIDDEN_LINES: caution! not full implemented yet'
        front_faces = []
        front_edges = []
        for f in faces:
            #print 'deb: face=', f #---------
            #print 'deb: dir(face)=', dir(f) #---------
            # get its normal-vector in localCS
            vec_normal = f.no.copy()
            #print 'deb: vec_normal=', vec_normal #------------------
            # must be transferred to camera/view-CS
            vec_normal @= mx_n
            #vec_normal *= mb.rotationPart()
            #print 'deb:2vec_normal=', vec_normal #------------------
            #vec_normal *= mw0.rotationPart()
            #print 'deb:3vec_normal=', vec_normal, '\n' #------------------


            frontFace = False
            if not self.PERSPECTIVE: #for ortho mode ----------
                # normal must point the Z direction-hemisphere
                if vec_normal[2] > 0.00001:
                    frontFace = True
            else:
                v = f.verts[0]
                vert = mathutils.Vector(v.co) @ mx
                if mathutils.DotVecs(vert, vec_normal) < 0.00001:
                    frontFace = True

            if frontFace:
                front_faces.append(f.index)
                for key in f.edge_keys:
                    #this test can be done faster with set()
                    if key not in front_edges:
                        front_edges.append(key)

        #print 'deb: amount of visible faces=', len(front_faces) #---------
        #print 'deb: visible faces=', front_faces #---------
        #print 'deb: amount of visible edges=', len(front_edges) #---------
        #print 'deb: visible edges=', front_edges #---------
        return front_faces, front_edges
Beispiel #2
0
 def M_DotVecs(self, v1, v2):
     if 'cross' in dir(mathutils.Vector()):
         return v1.dot(v2)  #for up2.49
     else:
         return mathutils.DotVecs(v1, v2)  #for pre2.49