예제 #1
0
def genVertexNormalsPlane(segment):
    """
    generate per vertex normals.
    segment must consist of plane polygon faces.
    """
    normals = [zeros(3, float32)] * segment.numVertices

    # Calculate the vertex normals.
    for face in segment.faces:
        _genPlaneFaceNormals(segment, face, normals)

    # Normalize the vertex normals.
    for i in range(segment.numVertices):
        normalize(normals[i])

    return normals
예제 #2
0
def genVertexNormalsUnplane(segment):
    """
    generate normals for not plane faces.
    """
    normals = [zeros(3, float32)] * segment.numVertices

    # Calculate the vertex normals.
    for face in segment.faces:
        planeFaces = face.getPlaneFaces(segment)
        for face in planeFaces:
            _genPlaneFaceNormals(segment, face, normals)

    # Normalize the vertex normals.
    for i in range(segment.numVertices):
        normalize(normals[i])

    return normals
예제 #3
0
    def motion(self, x, y):
        """ mouse motion event handler,
            only rotates if button 1 pressed. """
        
        x -= self.app.halfSize[0]
        y -= self.app.halfSize[1]
        
        if not self.leftMouseButtonPressed:
            self.lastX = x
            self.lastY = y
            return
    
        rotX = - float(x - self.lastX) * self.sensitivity
        rotY = - float(y - self.lastY) * self.sensitivity

        rotateView( self.direction, rotX, 0.0, 1.0, 0.0 )
        
        rotAxis = array( [ -self.direction[2], 0.0, self.direction[0] ] , float32 )
        normalize( rotAxis )
        rotateView( self.direction, rotY, rotAxis[0], rotAxis[1], rotAxis[2] )
        
        self.lastX = x
        self.lastY = y
        self.needsUpdate = True