Beispiel #1
0
        private ComplexUvAnimation ParseComplexUvAnimation(XmlNode complexUvAnimationXmlNode)
        {
            string      name = XmlUtility.GetStringAttribute(complexUvAnimationXmlNode, "name");
            XmlNodeList complexFrameNodes = complexUvAnimationXmlNode.SelectNodes("ComplexFrame");

            if (complexFrameNodes.Count == 0)
            {
                Console.LogError("ComplexUvAnimation " + name + " does not have any ComplexFrames defined in node: " + complexUvAnimationXmlNode.OuterXml);
                return(null);
            }

            ComplexFrame[] frames = new ComplexFrame[complexFrameNodes.Count];

            /* Foreach ComplexFrame */
            int complexFrameCount = 0;

            foreach (XmlNode complexFrameNode in complexFrameNodes)
            {
                int   repeatFrame       = XmlUtility.GetIntAttribute(complexFrameNode, "repeatFrame");
                float waitAfterFinished = XmlUtility.GetFloatAttribute(complexFrameNode, "waitAfterFinished");

                XmlNodeList simpleAnimationNodes = complexFrameNode.SelectNodes("SimpleAnimation");
                if (simpleAnimationNodes.Count == 0)
                {
                    Console.LogError("ComplexFrame does not have any Simple animations defined in name: " + complexFrameNode.OuterXml);
                    return(null);
                }

                /* Foreach Animation Frame */
                List <SimpleUvAnimation> simpleAnimations = new List <SimpleUvAnimation>();
                foreach (XmlNode simpleAnimation in simpleAnimationNodes)
                {
                    string      uvAnimationId = XmlUtility.GetStringAttribute(simpleAnimation, "assetId");
                    UvAnimation uvAnimation;
                    if (mUvAnimationLookUpTable.TryGetValue(uvAnimationId, out uvAnimation))
                    {
                        SimpleUvAnimation simpleUvAnimation = (SimpleUvAnimation)uvAnimation;
                        if (simpleUvAnimation == null)
                        {
                            Console.Log("Could not assign uvAnimation as SimpleAnimation from key: " + uvAnimationId);
                        }
                        else
                        {
                            simpleAnimations.Add(simpleUvAnimation);
                        }
                    }
                    else
                    {
                        Console.LogError("Unable to pull simple uv animation from dictionary using key: " + uvAnimationId);
                    }
                }
                frames[complexFrameCount] = new ComplexFrame(repeatFrame, waitAfterFinished, simpleAnimations.ToArray());
                ++complexFrameCount;
            }

            return(new ComplexUvAnimation(name, frames));
        }
        /*
         *      Create a SimpleUvAnimation from XML
         */
        public static SimpleUvAnimation Parse(XmlNode uvAnimationXmlNode)
        {
            string      name = XmlUtility.GetStringAttribute(uvAnimationXmlNode, "name");
            XmlNodeList frameSequenceNodes = uvAnimationXmlNode.SelectNodes("descendant::FrameSequence");

            if (frameSequenceNodes.Count == 0)
            {
                Console.LogError("SimpleUvAnimation " + name + " does not have any FrameSequences defined");
                return(null);
            }

            int[][]  frameSequences      = new int[frameSequenceNodes.Count][];
            string[] frameSequenceTarget = new string[frameSequenceNodes.Count];

            /* Foreach FrameSequence */
            int sequenceCount = 0;

            foreach (XmlNode frameSequenceNode in frameSequenceNodes)
            {
                string sequenceTarget = XmlUtility.GetStringAttribute(frameSequenceNode, "target");
                frameSequenceTarget[sequenceCount] = sequenceTarget;

                XmlNodeList frameNodes = frameSequenceNode.SelectNodes("descendant::Frame");
                if (frameNodes.Count == 0)
                {
                    Console.LogError("FrameSequence for target " + sequenceTarget + " does not have any Frames defined");
                    return(null);
                }

                /* Foreach Animation Frame */
                frameSequences[sequenceCount] = new int[frameNodes.Count];
                int frameCount = 0;
                foreach (XmlNode frameNode in frameNodes)
                {
                    frameSequences[sequenceCount][frameCount] = XmlUtility.GetIntAttribute(frameNode, "value");
                    ++frameCount;
                }
                ++sequenceCount;
            }
            return(new SimpleUvAnimation(name, frameSequenceTarget, frameSequences));
        }
Beispiel #3
0
        public FaceMeshAsset(AssetSubType type, Mesh mesh, string displayName, string path, string key, XmlNode meshInfo)
            : base(type, mesh, displayName, path, key)
        {
            if (mesh == null)
            {
                throw new ArgumentNullException("mesh");
            }

            XmlNode faceMeshInfoNode = meshInfo;

            XmlNodeList uvShellNodes = faceMeshInfoNode.SelectNodes("descendant::UvShell");

            mUvShellCount = uvShellNodes.Count;
            if (mUvShellCount == 0)
            {
                Console.LogError("FaceMeshAsset(): FaceMesh " + DisplayName + " does not have any UvShell info");
                return;
            }
            mUvShellNames     = new string[mUvShellCount];
            mUvGridDimensions = new Vector2[mUvShellCount];
            mTextureZoneNames = new string[mUvShellCount];

            /* foreach UvShell get its data */
            int count = 0;

            foreach (XmlNode uvShellNode in uvShellNodes)
            {
                int subMeshIndex = XmlUtility.GetIntAttribute(uvShellNode, "subMeshIndex");
                mUvShellNames[subMeshIndex]     = XmlUtility.GetStringAttribute(uvShellNode, "name");
                mTextureZoneNames[subMeshIndex] = XmlUtility.GetStringAttribute(uvShellNode, "textureZone");

                int gridWidth  = XmlUtility.GetIntAttribute(uvShellNode, "gridWidth");
                int gridHeight = XmlUtility.GetIntAttribute(uvShellNode, "gridHeight");

                mUvGridDimensions[subMeshIndex] = new Vector2(gridWidth, gridHeight);
                ++count;
            }
        }