Ejemplo n.º 1
0
        private string ParseShape(NiTriShape shape)
        {
            if (!shape.Data.IsValid()) return "";

            NiTriShapeData geometry = (NiTriShapeData)shape.Data.Object;

            // The final text
            List<string> export = new List<string>();

            Matrix transformationMatrix = ComputeWorldMatrix(shape);

            // Set Object name
            export.Add("g Shape " + shape.Name + Environment.NewLine);

            NiMaterialProperty material = null;
            NiTexturingProperty texture = null;
            foreach (NiRef<NiProperty> property in shape.Properties)
            {
                if (property.Object is NiMaterialProperty)
                {
                    material = property.Object as NiMaterialProperty;
                }
                if (property.Object is NiTexturingProperty)
                {
                    texture = property.Object as NiTexturingProperty;
                }
            }

            if (material != null && texture != null)
            {
                export.Add(printMaterial(material, texture));
            }

            // Verticles (v)
            if (geometry.HasVertices && geometry.NumVertices >= 3)
            {
                export.Add(printVertices(geometry.Vertices, transformationMatrix));
            }

            // Texture coordinates (vt)
            if (geometry.UVSets.Length > 0)
            {
                export.Add(printUvSets(geometry.UVSets));
            }

            // Normals (vn)
            if (geometry.HasNormals)
            {
                export.Add(printNormals(geometry.Normals, transformationMatrix));
            }

            // Parameter space vertices (vp)

            // Face Definitions (f)
            export.Add(printTriangles(geometry.Triangles, (geometry.UVSets.Length > 0)));

            return string.Join(Environment.NewLine, export);
        }
Ejemplo n.º 2
0
        private void ParseShape(NiTriShape shape)
        {
            List<string> export = new List<string>();

            NiTriShapeData geometry = (NiTriShapeData)shape.Data.Object;

            // Verticles (v)
            if (geometry.HasVertices && geometry.NumVertices >= 3)
            {
                Matrix transformationMatrix = ComputeWorldMatrix(shape);
                computePolys(geometry.Triangles, geometry.Vertices, transformationMatrix);
            }
        }