Esempio n. 1
0
            // template Mesh
            // {
            //      DWORD nVertices;
            //      array Vector vertices[nVertices];
            //      DWORD nFaces;
            //      array MeshFace faces[nFaces];
            //      [...]
            // }
            /// <summary>
            /// Imports a mesh.
            /// </summary>
            /// <returns>The imported mesh</returns>
            public NodeContent ImportMesh()
            {
                // Initialize mesh
                mesh      = new MeshContent();
                mesh.Name = tokens.ReadName();
                if (mesh.Name == null)
                {
                    mesh.Name = "Mesh" + meshID.ToString();
                    meshID++;
                }
                // Read in vertex positions and vertex indices
                InitializeMesh();

                // Fill in the geometry channels and materials for this mesh
                for (string next = tokens.NextToken(); next != "}"; next = tokens.NextToken())
                {
                    if (next == "MeshNormals")
                    {
                        ImportNormals();
                    }
                    else if (next == "MeshTextureCoords")
                    {
                        ImportTextureCoords();
                    }
                    else if (next == "SkinWeights")
                    {
                        ImportSkinWeights();
                    }
                    else if (next == "MeshMaterialList")
                    {
                        ImportMaterialList();
                    }
                    else if (next == "Frame")
                    {
                        mesh.Children.Add(model.ImportNode());
                    }
                    else if (next == "{")
                    {
                        tokens.SkipNode();
                    }
                    else if (next == "}")
                    {
                        break;
                    }
                }
                return(mesh);
            }
Esempio n. 2
0
 /// <summary>
 /// Imports the root and animation data associated with it
 /// </summary>
 private void ImportRoot()
 {
     // Read all tokens in the file
     if (!tokens.AtEnd)
     {
         do
         {
             string next = tokens.NextToken();
             // If nodes are found in the same scope as the root, add them
             // as children because the Model class only supports one root
             // frame
             if (next == "Frame")
             {
                 if (root == null)
                 {
                     root          = ImportNode();
                     root.Identity = new ContentIdentity();
                     root.Identity.SourceFilename = fileName;
                     root.Identity.SourceTool     = this.GetType().ToString();
                 }
                 else
                 {
                     root.Children.Add(ImportNode());
                 }
             }
             //template AnimTicksPerSecond
             // {
             //     DWORD AnimTicksPerSecond;
             // }
             else if (next == "AnimTicksPerSecond")
             {
                 animTicksPerSecond = tokens.SkipName().NextInt();
                 tokens.SkipToken();
             }
             // See ImportAnimationSet for template info
             else if (next == "AnimationSet")
             {
                 ImportAnimationSet();
             }
             else if (next == "Material")
             {
                 ImportMaterial();
             }
             else if (next == "template")
             {
                 tokens.SkipName().SkipNode();
             }
             else if (next == "AnimationLibOptions")
             {
                 tokens.SkipName();
                 int numOptions = tokens.NextInt();
                 for (int i = 0; i < numOptions; i++)
                 {
                     string animationOption = tokens.NextString();
                     animationOptions.Add(animationOption);
                 }
                 tokens.SkipToken().SkipToken();
             }
         }while (!tokens.AtEnd);
     }
 }