コード例 #1
0
        public static float GetFaceArea(this ITVFace face, IList <IPoint3> verts)
        {
            // get all vert indices from this face
            int[] arrVertIndices = face.GetAllVerts();

            // get the IPoints from the vertlist
            // since all max sdk interface are using the IDisposable interface
            // you have to call dispose, they will be not handled by the garbage collection
            using (IPoint3 v0 = verts[arrVertIndices[0]])
                using (IPoint3 v1 = verts[arrVertIndices[1]])
                    using (IPoint3 v2 = verts[arrVertIndices[2]])
                    {
                        // build the edge vestors and return the result
                        using (IPoint3 v1v0 = v1.Subtract(v0))
                            using (IPoint3 v2v1 = v2.Subtract(v1))
                                return(v1v0.CrossProduct(v2v1).GetFaceArea());
                    }
        }
コード例 #2
0
        /// <summary>
        /// get the face area for a face
        /// </summary>
        /// <param name="face"></param>
        /// <param name="verts"></param>
        /// <returns></returns>
        public static IPoint3 GetFaceNormal(this IFace face, IList <IPoint3> verts)
        {
            // get all vert indices from this face
            int[] arrVertIndices = face.GetAllVerts();

            // get the IPoints from the vertlist
            // since all max sdk interface are using the IDisposable interface
            // you have to call dispose, they will be not handled by the garbage collection
            using (IPoint3 v0 = verts[arrVertIndices[0]])
                using (IPoint3 v1 = verts[arrVertIndices[1]])
                    using (IPoint3 v2 = verts[arrVertIndices[2]])
                    {
                        // build the edge vestors
                        using (IPoint3 v1v0 = v1.Subtract(v0))
                            using (IPoint3 v2v1 = v2.Subtract(v1))
                            {
                                // the cross product of the edge vector is the face normal ( unnormalized )
                                // the length of the face normal is twice the face area
                                return(v1v0.CrossProduct(v2v1));
                            }
                    }
        }