Ejemplo n.º 1
0
        protected void InitializeMesh(string name)
        {
            mesh = ResourceManager.Inst.GetMesh(name);
            rootNodes = mesh.GetRootNodes(out nodes);

            int vertexCount = 0;
            VertexBuffer origBuffer = mesh.GetVertexBuffer(out vertexCount);
            vertices = new VertexPNTTI[vertexCount];
            origBuffer.GetData<VertexPNTTI>(vertices);
            vertexBuffer = new VertexBuffer(GFX.Device, VertexPNTTI.SizeInBytes * vertexCount, BufferUsage.WriteOnly);
            vertexBuffer.SetData<VertexPNTTI>(vertices);

            List<AnimationNode> orderedNodes = new List<AnimationNode>();
            for (int i = 0; i < nodes.Count; i++)
            {
                string currKey = nodes.Keys[i];
                defaultTranslations.Add(currKey, nodes[currKey].Translation);
                defaultRotations.Add(currKey, nodes[currKey].Rotation);
            }

            AnimationNode[] tempNodes = mesh.GetNodes();
            for(int i = 0; i < tempNodes.Length; i++)
            {
                orderedNodes.Add(nodes[tempNodes[i].Name]);
            }
            this.orderedNodes = orderedNodes.ToArray();

            mainAnimationLayer = new AnimationLayer(this);
        }