Esempio n. 1
0
        public static GrnNode ReadByNodeType(GrnBinaryReader reader, GrnNode parentNode, GrnNodeType nodeType)
        {
            GrnNode node;

            if (nodeType == GrnNodeType.FileDirectory)
            {
                node = new GrnMainNode();
            }
            else if (nodeType == GrnNodeType.VersionFrameDirectory ||
                     nodeType == GrnNodeType.StandardFrameDirectory ||
                     nodeType == GrnNodeType.NullFrameDirectory)
            {
                node = new GrnSectionNode(parentNode, nodeType);
            }
            else if (nodeType == GrnNodeType.StringTable)
            {
                node = new GrnStringTableNode(parentNode);
            }
            else if (parentNode.NodeType == GrnNodeType.MeshVertexSet)
            {
                if (nodeType == GrnNodeType.MeshVertices)
                {
                    node = new GrnMeshVerticesNode(parentNode);
                }
                else if (nodeType == GrnNodeType.MeshNormals)
                {
                    node = new GrnMeshNormalsNode(parentNode);
                }
                else
                {
                    node = new GrnNode(parentNode, nodeType);
                }
            }
            else if (nodeType == GrnNodeType.MeshField)
            {
                node = new GrnMeshFieldNode(parentNode);
            }
            else if (nodeType == GrnNodeType.MeshWeights)
            {
                node = new GrnMeshWeightsNode(parentNode);
            }
            else if (nodeType == GrnNodeType.MeshTriangles)
            {
                node = new GrnMeshTrianglesNode(parentNode);
            }
            else if (nodeType == GrnNodeType.DataExtensionProperty)
            {
                node = new GrnDataExtensionPropertyNode(parentNode);
            }
            else if (nodeType == GrnNodeType.DataExtensionPropertyValue)
            {
                node = new GrnDataExtensionPropertyValueNode(parentNode);
            }
            else if (nodeType == GrnNodeType.DataExtensionReference)
            {
                node = new GrnDataExtensionReferenceNode(parentNode);
            }
            else if (nodeType == GrnNodeType.Bone)
            {
                node = new GrnBoneNode(parentNode);
            }
            else if (nodeType == GrnNodeType.MaterialSimpleDiffuseTexture)
            {
                node = new GrnMaterialSimpleDiffuseTextureNode(parentNode);
            }
            else if (nodeType == GrnNodeType.FormBoneChannels)
            {
                node = new GrnFormBoneChannelsNode(parentNode);
            }
            else if (nodeType == GrnNodeType.FormMesh)
            {
                node = new GrnFormMeshNode(parentNode);
            }
            else if (nodeType == GrnNodeType.FormMeshBone)
            {
                node = new GrnFormMeshBoneNode(parentNode);
            }
            else if (nodeType == GrnNodeType.RenderPass)
            {
                node = new GrnRenderPassNode(parentNode);
            }
            else if (nodeType == GrnNodeType.RenderPassTriangles)
            {
                node = new GrnRenderPassTrianglesNode(parentNode);
            }
            else if (nodeType == GrnNodeType.AnimationTransformTrackKeys)
            {
                node = new GrnAnimationTransformTrackKeysNode(parentNode);
            }
            else if (nodeType == GrnNodeType.TextureMapImage)
            {
                node = new GrnTextureMapImageNode(parentNode);
            }
            else
            {
                node = new GrnNode(parentNode, nodeType);
            }

            node.Read(reader);
            return(node);
        }
Esempio n. 2
0
        public void Write(GrnNode meshSecNode)
        {
            GrnNode meshNode = new GrnNode(meshSecNode, GrnNodeType.Mesh);
            meshSecNode.AppendChild(meshNode);
            GrnNode meshVertSetSecNode = new GrnNode(meshNode, GrnNodeType.MeshVertexSetSection);
            meshNode.AppendChild(meshVertSetSecNode);
            GrnNode meshVertSetNode = new GrnNode(meshVertSetSecNode, GrnNodeType.MeshVertexSet);
            meshVertSetSecNode.AppendChild(meshVertSetNode);

            GrnMeshVerticesNode mVertNode = new GrnMeshVerticesNode(meshVertSetNode);
            mVertNode.Vertices = this.Vertices;
            meshVertSetNode.AppendChild(mVertNode);
            GrnMeshNormalsNode mNormNode = new GrnMeshNormalsNode(meshVertSetNode);
            mNormNode.Normals = this.Normals;
            meshVertSetNode.AppendChild(mNormNode);
            GrnNode meshFieldSecNode = new GrnNode(meshVertSetNode, GrnNodeType.MeshFieldSection);
            meshVertSetNode.AppendChild(meshFieldSecNode);
            GrnMeshFieldNode mFieldNode = new GrnMeshFieldNode(meshFieldSecNode);
            mFieldNode.TextureCoordinates = this.TextureCoordinates;
            meshFieldSecNode.AppendChild(mFieldNode);

            GrnMeshWeightsNode mWeightNode = new GrnMeshWeightsNode(meshNode);
            mWeightNode.VertexWeights = this.VertexWeights;
            meshNode.AppendChild(mWeightNode);
            GrnMeshTrianglesNode mTriNode = new GrnMeshTrianglesNode(meshNode);
            mTriNode.Faces = this.Faces;
            meshNode.AppendChild(mTriNode);
            GrnDataExtensionReferenceNode mDERefNode = new GrnDataExtensionReferenceNode(meshNode);
            mDERefNode.DataExtensionIndex = this.DataExtensionIndex + 1;
            meshNode.AppendChild(mDERefNode);
        }