Exemple #1
0
        public void Dispose()
        {
            for (int i = 0; i < meshFrames.Count; i++)
            {
                MeshContainer mesh = meshFrames[i].MeshContainer;
                while (mesh != null)
                {
                    if ((mesh.MeshData != null) && (mesh.MeshData.Mesh != null))
                    {
                        mesh.MeshData.Mesh.Dispose();
                    }
                    if (mesh is MorphMeshContainer)
                    {
                        MorphMeshContainer morphMesh = (MorphMeshContainer)mesh;
                        if (morphMesh.StartBuffer != morphMesh.EndBuffer)
                        {
                            morphMesh.StartBuffer.Dispose();
                        }
                        if (morphMesh.EndBuffer != null)
                        {
                            morphMesh.EndBuffer.Dispose();
                        }
                        if (morphMesh.CommonBuffer != null)
                        {
                            morphMesh.CommonBuffer.Dispose();
                        }
                        if (morphMesh.IndexBuffer != null)
                        {
                            morphMesh.IndexBuffer.Dispose();
                        }
                    }

                    for (int j = 0; j < Textures.Length; j++)
                    {
                        Texture tex = Textures[j];
                        if ((tex != null) && !tex.Disposed)
                        {
                            tex.Dispose();
                        }
                    }

                    mesh = mesh.NextMeshContainer;
                }
            }

            rootFrame.Dispose();
            AnimationController.Dispose();

            tweeningVertDec.Dispose();

            IsDisposed = true;
        }
Exemple #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                if (MeshContainer != null)
                {
                    MeshContainer.Dispose();
                }

                foreach (var child in Childs)
                {
                    child.Dispose();
                }
            }

            _disposed = true;
        }
Exemple #3
0
        public void SetTweenFactor(xxFrame meshFrame, xaMorphIndexSet idxSet, float tweenFactor)
        {
            foreach (AnimationFrame frame in meshFrames)
            {
                if (frame.Name == meshFrame.Name)
                {
                    xxMesh xxMesh     = meshFrame.Mesh;
                    int    meshObjIdx = xa.MorphMeshObjIdx(idxSet.MeshIndices, xxMesh);
                    if (meshObjIdx < 0)
                    {
                        Report.ReportLog("no valid mesh object was found for the morph");
                        return;
                    }
                    MeshContainer animMesh = frame.MeshContainer;
                    for (int i = 1; i < meshObjIdx; i++)
                    {
                        animMesh = animMesh.NextMeshContainer;
                        if (animMesh == null)
                        {
                            break;
                        }
                    }
                    if (animMesh == null)
                    {
                        Report.ReportLog("Bad submesh specified.");
                        return;
                    }
                    MorphMeshContainer morphMesh = (MorphMeshContainer)animMesh;

                    morphMesh.TweenFactor = tweenFactor;
                    return;
                }
            }
            Report.ReportLog("Mesh frame " + meshFrame + " not displayed.");
            return;
        }
Exemple #4
0
        public float UnsetMorphKeyframe(xxFrame meshFrame, xaMorphIndexSet idxSet, bool asStart)
        {
            foreach (AnimationFrame frame in meshFrames)
            {
                if (frame.Name == meshFrame.Name)
                {
                    xxMesh xxMesh     = meshFrame.Mesh;
                    int    meshObjIdx = xa.MorphMeshObjIdx(idxSet.MeshIndices, xxMesh);
                    if (meshObjIdx < 0)
                    {
                        Report.ReportLog("no valid mesh object was found for the morph");
                        return(-1f);
                    }
                    MeshContainer animMesh = frame.MeshContainer;
                    for (int i = 1; i < meshObjIdx; i++)
                    {
                        animMesh = animMesh.NextMeshContainer;
                        if (animMesh == null)
                        {
                            break;
                        }
                    }
                    if (animMesh == null)
                    {
                        Report.ReportLog("Bad submesh specified.");
                        return(-1f);
                    }
                    MorphMeshContainer morphMesh = (MorphMeshContainer)animMesh;

                    if (asStart)
                    {
                        if (morphMesh.StartBuffer != morphMesh.EndBuffer)
                        {
                            morphMesh.StartBuffer.Dispose();
                            morphMesh.StartBuffer = morphMesh.EndBuffer;
                        }
                        else
                        {
                            frame.MeshContainer = morphMesh.NextMeshContainer;
                        }
                        morphMesh.TweenFactor = 1.0f;
                    }
                    else
                    {
                        if (morphMesh.StartBuffer != morphMesh.EndBuffer)
                        {
                            morphMesh.EndBuffer.Dispose();
                            morphMesh.EndBuffer = morphMesh.StartBuffer;
                        }
                        else
                        {
                            frame.MeshContainer = morphMesh.NextMeshContainer;
                        }
                        morphMesh.TweenFactor = 0.0f;
                    }
                    return(morphMesh.TweenFactor);
                }
            }
            Report.ReportLog("Mesh frame " + meshFrame + " not displayed.");
            return(-1f);
        }