Esempio n. 1
0
        public bool ExtractToTriangles()
        {
            bool res = false;

            //try extract mesh-objects and vertex-morph animations
            if (mMeshObjectList != null)
            {
                for (int i = 0; i < mMeshObjectList.GetMeshObjectCount(); i++)
                {
                    List <Vector3Int> originalFaceIndices = new List <Vector3Int>();
                    NullMeshObject    meshObject          = mMeshObjectList[i];
                    res |= meshObject.ExtractToTriangles(originalFaceIndices);
                    if (meshObject.IsVertexAnimationMeshObject() && mVertexMorphAnimations != null)
                    {
                        for (int k = 0; k < mVertexMorphAnimations.GetAnimationCount(); k++)
                        {
                            NullVertexMorphAnimation animation = mVertexMorphAnimations[k];
                            for (int j = 0; j < animation.GetFrameCount(); j++)
                            {
                                NullVertexMorphAnimationFrame animationFrame = animation[j];
                                NullVertexMorphObject         morphObject    = animationFrame.FindMorphAnimationNodeByIndex(i);
                                Assert.IsTrue(morphObject != null, "");
                                switch (meshObject.GetMeshObjectType())
                                {
                                case NullPrimitiveType.MOT_INDEXED_PRIMITIVES:
                                    res |= morphObject.ExtractToTrianglesFromIndexedPrimitives(originalFaceIndices);
                                    break;
                                    //case NullPrimitiveType.MOT_TRIANGLE_STRIPS:
                                    //    res |= morphObject.ExtractToTrianglesFromStrips(meshObject.GetTriangleCount());
                                    //    break;
                                }
                            }
                        }
                    }
                    originalFaceIndices.Clear();
                }
            }

            //try extract mesh-objects and skeleton-bindings
            if (mSkinObjectList != null)
            {
                for (int i = 0; i < mSkinObjectList.GetMeshObjectCount(); i++)
                {
                    List <Vector3Int> originalFaceIndices = new List <Vector3Int>();
                    NullMeshObject    meshObject          = mSkinObjectList[i];
                    res |= meshObject.ExtractToTriangles(originalFaceIndices);
                    if (mSkeletonBinding != null && mSkeletonBinding.GetSkeletonBindingCount() > 0)
                    {
                        NullSkeletonPiece skeletonPiece = mSkeletonBinding[i];
                        switch (meshObject.GetMeshObjectType())
                        {
                        case NullPrimitiveType.MOT_INDEXED_PRIMITIVES:
                            res |= skeletonPiece.ExtractToTrianglesFromIndexedPrimitives(originalFaceIndices);
                            break;
                            //case HexMeshObject::MOT_TRIANGLE_STRIPS:
                            //    res |= skeletonPiece.ExtractToTrianglesFromStrips(meshObject.GetTriangleCount());
                            //    break;
                        }
                    }
                }
            }

            return(res);
        }