Example #1
0
        public static void Dump(this MainChunk chunk, out ThreeDSModel4LegacyOpenGL model)
        {
            model = new ThreeDSModel4LegacyOpenGL();

            foreach (var item in chunk.Children)
            {
                if (item is VersionChunk)
                {
                    (item as VersionChunk).Dump(model);
                }
                else if (item is _3DEditorChunk)
                {
                    (item as _3DEditorChunk).Dump(model);
                }
                else if (item is KeyframeChunk)
                {
                    (item as KeyframeChunk).Dump(model);
                }
                else if (!(item is UndefinedChunk))
                {
                    throw new NotImplementedException(string.Format(
                                                          "not dumper implemented for {0}", item.GetType()));
                }
            }
        }
Example #2
0
 public static void Dump(this FramesChunk chunk, ThreeDSModel4LegacyOpenGL model)
 {
     foreach (var item in chunk.Children)
     {
         if (item is ObjectNameChunk)
         {
             (item as ObjectNameChunk).Dump(model);
         }
         else if (item is ObjectPivotPointChunk)
         {
             (item as ObjectPivotPointChunk).Dump(model);
         }
         else if (item is PositionTrackChunk)
         {
             (item as PositionTrackChunk).Dump(model);
         }
         else if (item is RotationTrackChunk)
         {
             (item as RotationTrackChunk).Dump(model);
         }
         else if (item is ScaleTrackChunk)
         {
             (item as ScaleTrackChunk).Dump(model);
         }
         else if (item is HierarchyPositionChunk)
         {
             (item as HierarchyPositionChunk).Dump(model);
         }
         else if (!(item is UndefinedChunk))
         {
             throw new NotImplementedException(string.Format(
                                                   "not dumper implemented for {0}", item.GetType()));
         }
     }
 }
Example #3
0
 public static void Dump(this FramesChunk chunk, ThreeDSModel4LegacyOpenGL model)
 {
     foreach (var item in chunk.Children)
     {
         if (item is ObjectNameChunk)
         {
             (item as ObjectNameChunk).Dump(model);
         }
         else if (item is ObjectPivotPointChunk)
         {
             (item as ObjectPivotPointChunk).Dump(model);
         }
         else if (item is PositionTrackChunk)
         {
             (item as PositionTrackChunk).Dump(model);
         }
         else if (item is RotationTrackChunk)
         {
             (item as RotationTrackChunk).Dump(model);
         }
         else if (item is ScaleTrackChunk)
         {
             (item as ScaleTrackChunk).Dump(model);
         }
         else if (item is HierarchyPositionChunk)
         {
             (item as HierarchyPositionChunk).Dump(model);
         }
         else if (!(item is UndefinedChunk))
         {
             throw new NotImplementedException(string.Format(
                 "not dumper implemented for {0}", item.GetType()));
         }
     }
 }
        public static void Dump(this TriangularMeshChunk chunk, ThreeDSModel4LegacyOpenGL model)
        {
            ThreeDSMesh4LegacyOpenGL mesh = new ThreeDSMesh4LegacyOpenGL();

            foreach (var item in chunk.Children)
            {
                if (item is VerticesListChunk)
                {
                    (item as VerticesListChunk).Dump(model, mesh);
                }
                else if (item is FacesDescriptionChunk)
                {
                    (item as FacesDescriptionChunk).Dump(model, mesh);
                }
                else if (item is MappingCoordinatesListChunk)
                {
                    (item as MappingCoordinatesListChunk).Dump(model, mesh);
                }
                else if (item is LocalCoordinatesSystemChunk)
                {
                    (item as LocalCoordinatesSystemChunk).Dump(model, mesh);
                }
                else if (!(item is UndefinedChunk))
                {
                    throw new NotImplementedException(string.Format(
                        "not dumper implemented for {0}", item.GetType()));
                }
            }

            model.Entities.Add(mesh);
        }
        public static void Dump(this TriangularMeshChunk chunk, ThreeDSModel4LegacyOpenGL model)
        {
            ThreeDSMesh4LegacyOpenGL mesh = new ThreeDSMesh4LegacyOpenGL();

            foreach (var item in chunk.Children)
            {
                if (item is VerticesListChunk)
                {
                    (item as VerticesListChunk).Dump(model, mesh);
                }
                else if (item is FacesDescriptionChunk)
                {
                    (item as FacesDescriptionChunk).Dump(model, mesh);
                }
                else if (item is MappingCoordinatesListChunk)
                {
                    (item as MappingCoordinatesListChunk).Dump(model, mesh);
                }
                else if (item is LocalCoordinatesSystemChunk)
                {
                    (item as LocalCoordinatesSystemChunk).Dump(model, mesh);
                }
                else if (!(item is UndefinedChunk))
                {
                    throw new NotImplementedException(string.Format(
                                                          "not dumper implemented for {0}", item.GetType()));
                }
            }

            model.Entities.Add(mesh);
        }
Example #6
0
        public static void Dump(this MainChunk chunk, out ThreeDSModel4LegacyOpenGL model)
        {
            model = new ThreeDSModel4LegacyOpenGL();

            foreach (var item in chunk.Children)
            {
                if(item is VersionChunk)
                {
                    (item as VersionChunk).Dump(model);
                }
                else if(item is _3DEditorChunk)
                {
                    (item as _3DEditorChunk).Dump(model);
                }
                else if (item is KeyframeChunk)
                {
                    (item as KeyframeChunk).Dump(model);
                }
                else if(!(item is UndefinedChunk))
                {
                    throw new NotImplementedException(string.Format(
                        "not dumper implemented for {0}", item.GetType()));
                }
            }
        }
Example #7
0
 public static void Dump(this LightChunk chunk, ThreeDSModel4LegacyOpenGL model)
 {
     foreach (var item in chunk.Children)
     {
         if (item is SpotlightChunk)
         {
             (item as SpotlightChunk).Dump(model);
         }
         else if (!(item is UndefinedChunk))
         {
             throw new NotImplementedException(string.Format(
                                                   "not dumper implemented for {0}", item.GetType()));
         }
     }
 }
Example #8
0
 public static void Dump(this LightChunk chunk, ThreeDSModel4LegacyOpenGL model)
 {
     foreach (var item in chunk.Children)
     {
         if(item is SpotlightChunk)
         {
             (item as SpotlightChunk).Dump(model);
         }
         else if (!(item is UndefinedChunk))
         {
             throw new NotImplementedException(string.Format(
                 "not dumper implemented for {0}", item.GetType()));
         }
     }
 }
Example #9
0
        public static void Dump(this MaterialBlockChunk chunk, ThreeDSModel4LegacyOpenGL model)
        {
            ThreeDSMaterial4LegacyOpenGL material = new ThreeDSMaterial4LegacyOpenGL();

            foreach (var item in chunk.Children)
            {
                if (item is MaterialNameChunk)
                {
                    (item as MaterialNameChunk).Dump(model, material);
                }
                else if (item is AmbientColorChunk)
                {
                    (item as AmbientColorChunk).Dump(model, material);
                }
                else if (item is DiffuseColorChunk)
                {
                    (item as DiffuseColorChunk).Dump(model, material);
                }
                else if (item is SpecularColorChunk)
                {
                    (item as SpecularColorChunk).Dump(model, material);
                }
                else if (item is MatShininessChunk)
                {
                    (item as MatShininessChunk).Dump(model, material);
                }
                else if (item is TextureMapChunk)
                {
                    (item as TextureMapChunk).Dump(model, material);
                }
                else if (item is BumpMapChunk)
                {
                    (item as BumpMapChunk).Dump(model, material);
                }
                else if (item is ReflectionMapChunk)
                {
                    (item as ReflectionMapChunk).Dump(model, material);
                }
                else if (!(item is UndefinedChunk))
                {
                    throw new NotImplementedException(string.Format(
                                                          "not dumper implemented for {0}", item.GetType()));
                }
            }

            model.MaterialDict.Add(material.MaterialName, material);
        }
        public static void Dump(this MaterialBlockChunk chunk, ThreeDSModel4LegacyOpenGL model)
        {
            ThreeDSMaterial4LegacyOpenGL material = new ThreeDSMaterial4LegacyOpenGL();

            foreach (var item in chunk.Children)
            {
                if(item is MaterialNameChunk)
                {
                    (item as MaterialNameChunk).Dump(model, material);
                }
                else if(item is AmbientColorChunk)
                {
                    (item as AmbientColorChunk).Dump(model, material);
                }
                else if (item is DiffuseColorChunk)
                {
                    (item as DiffuseColorChunk).Dump(model, material);
                }
                else if(item is SpecularColorChunk)
                {
                    (item as SpecularColorChunk).Dump(model, material);
                }
                else if(item is MatShininessChunk)
                {
                    (item as MatShininessChunk).Dump(model, material);
                }
                else if(item is TextureMapChunk)
                {
                    (item as TextureMapChunk).Dump(model, material);
                }
                else if(item is BumpMapChunk)
                {
                    (item as BumpMapChunk).Dump(model, material);
                }
                else if(item is ReflectionMapChunk)
                {
                    (item as ReflectionMapChunk).Dump(model, material);
                }
                else if (!(item is UndefinedChunk))
                {
                    throw new NotImplementedException(string.Format(
                        "not dumper implemented for {0}", item.GetType()));
                }
            }

            model.MaterialDict.Add(material.MaterialName, material);
        }
Example #11
0
 public static void Dump(this BumpMapChunk chunk, ThreeDSModel4LegacyOpenGL model, ThreeDSMaterial4LegacyOpenGL material)
 {
     foreach (var item in chunk.Children)
     {
         if (item is MappingFilenameChunk)
         {
             string filename = string.Empty;
             (item as MappingFilenameChunk).Dump(out filename);
             material.BumpFilename = filename;
         }
         else if (item is MappingParametersChunk)
         {
             (item as MappingParametersChunk).Dump(model, material);
         }
         else if (!(item is UndefinedChunk))
         {
             throw new NotImplementedException(string.Format(
                                                   "not dumper implemented for {0}", item.GetType()));
         }
     }
 }
        public static void Dump(this FacesDescriptionChunk chunk, ThreeDSModel4LegacyOpenGL model, ThreeDSMesh4LegacyOpenGL mesh)
        {
            mesh.TriangleIndexes = chunk.triangleIndexes;

            foreach (var item in chunk.Children)
            {
                if (item is FacesMaterialChunk)
                {
                    (item as FacesMaterialChunk).Dump(model, mesh);
                }
                else if (item is SmoothingGroupListChunk)
                {
                    (item as SmoothingGroupListChunk).Dump(model, mesh);
                }
                else if (!(item is UndefinedChunk))
                {
                    throw new NotImplementedException(string.Format(
                                                          "not dumper implemented for {0}", item.GetType()));
                }
            }
        }
 public static void Dump(this TextureMapChunk chunk, ThreeDSModel4LegacyOpenGL model, ThreeDSMaterial4LegacyOpenGL material)
 {
     foreach (var item in chunk.Children)
     {
         if (item is MappingFilenameChunk)
         {
             string filename = string.Empty;
             (item as MappingFilenameChunk).Dump(out filename);
             material.TextureFilename = filename;
         }
         else if (item is MappingParametersChunk)
         {
             (item as MappingParametersChunk).Dump(model, material);
         }
         else if (!(item is UndefinedChunk))
         {
             throw new NotImplementedException(string.Format(
                 "not dumper implemented for {0}", item.GetType()));
         }
     }
 }
        public static void Dump(this FacesDescriptionChunk chunk, ThreeDSModel4LegacyOpenGL model, ThreeDSMesh4LegacyOpenGL mesh)
        {
            mesh.TriangleIndexes = chunk.triangleIndexes;

            foreach (var item in chunk.Children)
            {
                if (item is FacesMaterialChunk)
                {
                    (item as FacesMaterialChunk).Dump(model, mesh);
                }
                else if (item is SmoothingGroupListChunk)
                {
                    (item as SmoothingGroupListChunk).Dump(model, mesh);
                }
                else if (!(item is UndefinedChunk))
                {
                    throw new NotImplementedException(string.Format(
                        "not dumper implemented for {0}", item.GetType()));
                }
            }
        }
Example #15
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.open3DSDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    var parser   = new ThreeDSParser();
                    var filename = this.open3DSDlg.FileName;
                    var tree     = parser.Parse(filename);
                    ThreeDSModel4LegacyOpenGL model = null;
                    tree.Dump(out model);
                    if (model.Entities == null)
                    {
                        MessageBox.Show("No entity found!");
                        return;
                    }
                    var  builder = new StringBuilder();
                    int  i = 1;
                    bool emptyVerticesFound = false, emptyIndicesFound = false, emptyTexCoordsFound = false;
                    foreach (var entity in model.Entities)
                    {
                        builder.Append("entity "); builder.Append(i++); builder.Append(":");
                        if (entity.Vertexes == null)
                        {
                            if (!emptyVerticesFound)
                            {
                                MessageBox.Show("No vertices in some entity!"); emptyVerticesFound = true;
                            }
                        }
                        else
                        {
                            builder.Append(" "); builder.Append(entity.Vertexes.Length); builder.Append(" vertices");
                        }

                        if (entity.TriangleIndexes == null)
                        {
                            if (!emptyIndicesFound)
                            {
                                MessageBox.Show("No faces in some entity.");
                                emptyIndicesFound = true;
                            }
                        }
                        else
                        {
                            builder.Append(" "); builder.Append(entity.TriangleIndexes.Length); builder.Append(" indices");
                        }

                        if (entity.TexCoords == null)
                        {
                            if (!emptyTexCoordsFound)
                            {
                                MessageBox.Show("No UV in some entity.");
                                emptyTexCoordsFound = true;
                            }
                        }
                        else
                        {
                            builder.Append(" "); builder.Append(entity.TexCoords.Length); builder.Append(" UVs");
                        }

                        builder.AppendLine();
                    }

                    if (i == 1)
                    {
                        builder.Append("no entity found.");
                    }

                    this.model = model;

                    MessageBox.Show(builder.ToString(), "Info");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error");
                }
            }
        }
Example #16
0
        private void lineTextureToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (open3DSDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                var parser   = new ThreeDSParser();
                var filename = this.open3DSDlg.FileName;
                var file     = new FileInfo(open3DSDlg.FileName);

                var tree = parser.Parse(filename);
                ThreeDSModel4LegacyOpenGL model = null;
                tree.Dump(out model);
                if (model.Entities == null)
                {
                    MessageBox.Show("No entity found!");
                    return;
                }

                int uvMapCount  = 0;
                int uvMapLength = 500;
                var pens        = new Pen[] { new Pen(Color.Red), new Pen(Color.Green), new Pen(Color.Blue) };
                int penIndex    = 0;
                foreach (var entity in model.Entities)
                {
                    foreach (var item in entity.usingMaterialIndexesList)
                    {
                        using (var uvMap = new Bitmap(uvMapLength, uvMapLength))
                        {
                            var graphics = Graphics.FromImage(uvMap);
                            var material = model.MaterialDict[item.Item1];

                            if (entity.TexCoords != null && entity.TriangleIndexes != null)
                            {
                                foreach (var usingIndex in item.Item2)
                                {
                                    var tri = entity.TriangleIndexes[usingIndex];
                                    var uv1 = entity.TexCoords[tri.vertex1];
                                    var uv2 = entity.TexCoords[tri.vertex2];
                                    var uv3 = entity.TexCoords[tri.vertex3];
                                    var p1  = new Point((int)(uv1.U * uvMapLength), (int)(uv1.V * uvMapLength));
                                    var p2  = new Point((int)(uv2.U * uvMapLength), (int)(uv2.V * uvMapLength));
                                    var p3  = new Point((int)(uv3.U * uvMapLength), (int)(uv3.V * uvMapLength));
                                    graphics.DrawLine(pens[penIndex], p1, p2);
                                    graphics.DrawLine(pens[penIndex], p2, p3);
                                    graphics.DrawLine(pens[penIndex], p3, p1);
                                    penIndex = (penIndex + 1 == pens.Length) ? 0 : penIndex + 1;
                                }
                            }
                            else
                            {
                                graphics.FillRectangle(new SolidBrush(Color.Gray), 0, 0, uvMapLength, uvMapLength);
                            }
                            uvMap.Save(Path.Combine(file.DirectoryName,
                                                    string.Format("{0}-{1}-{2}.bmp", file.Name, uvMapCount++, item.Item1)));

                            graphics.Dispose();
                        }
                    }
                }

                Process.Start("explorer", file.DirectoryName);
            }
        }
Example #17
0
 public static void Dump(this HierarchyPositionChunk chunk, ThreeDSModel4LegacyOpenGL model)
 {
     // nothing to do.
 }
 public static void Dump(this VersionChunk chunk, ThreeDSModel4LegacyOpenGL model)
 {
     Console.WriteLine("version:" + chunk.Version);
 }
Example #19
0
 public static void Dump(this ObjectPivotPointChunk chunk, ThreeDSModel4LegacyOpenGL model)
 {
     // nothing to do.
 }
 public static void Dump(this SmoothingGroupListChunk chunk, ThreeDSModel4LegacyOpenGL model,ThreeDSMesh4LegacyOpenGL mesh)
 {
     // nothing to do.
 }
 public static void Dump(this SpecularColorChunk chunk, ThreeDSModel4LegacyOpenGL model, ThreeDSMaterial4LegacyOpenGL material)
 {
     material.Specular = new float[] { chunk.R, chunk.G, chunk.B, };
 }
Example #22
0
 public static void Dump(this LocalCoordinatesSystemChunk chunk, ThreeDSModel4LegacyOpenGL model, ThreeDSMesh4LegacyOpenGL mesh)
 {
     // nothing to do.
 }
Example #23
0
 public static void Dump(this VerticesListChunk chunk, ThreeDSModel4LegacyOpenGL model, ThreeDSMesh4LegacyOpenGL mesh)
 {
     mesh.Vertexes = chunk.vertexes;
 }
Example #24
0
 public static void Dump(this MatShininessChunk chunk, ThreeDSModel4LegacyOpenGL model, ThreeDSMaterial4LegacyOpenGL material)
 {
     material.Shininess = chunk.Shininess;
 }
Example #25
0
 public static void Dump(this SpotlightChunk chunk, ThreeDSModel4LegacyOpenGL model)
 {
     // nothing to do.
 }
Example #26
0
        public static void Dump(this FacesMaterialChunk chunk, ThreeDSModel4LegacyOpenGL model, ThreeDSMesh4LegacyOpenGL mesh)
        {
            var tuple = new Tuple <string, ushort[]>(chunk.UsesMaterial, chunk.usesIndexes);

            mesh.usingMaterialIndexesList.Add(tuple);
        }
 public static void Dump(this SpotLightInformationBlockChunk chunk, ThreeDSModel4LegacyOpenGL model)
 {
     // nothing to do.
 }
 public static void Dump(this DiffuseColorChunk chunk, ThreeDSModel4LegacyOpenGL model, ThreeDSMaterial4LegacyOpenGL material)
 {
     material.Diffuse = new float[] { chunk.R, chunk.G, chunk.B, };
 }
Example #29
0
 public static void Dump(this MappingParametersChunk chunk, ThreeDSModel4LegacyOpenGL model, ThreeDSMaterial4LegacyOpenGL material)
 {
     // nothing to do.
 }
 public static void Dump(this ObjectNameChunk chunk, ThreeDSModel4LegacyOpenGL model)
 {
     Console.WriteLine("Object Name: " + chunk.Name);
 }
 public static void Dump(this FacesMaterialChunk chunk, ThreeDSModel4LegacyOpenGL model, ThreeDSMesh4LegacyOpenGL mesh)
 {
     var tuple = new Tuple<string, ushort[]>(chunk.UsesMaterial, chunk.usesIndexes);
     mesh.usingMaterialIndexesList.Add(tuple);
 }
Example #32
0
 public static void Dump(this MaterialNameChunk chunk, ThreeDSModel4LegacyOpenGL model, ThreeDSMaterial4LegacyOpenGL material)
 {
     material.MaterialName = chunk.MaterialName;
 }
 public static void Dump(this SmoothingGroupListChunk chunk, ThreeDSModel4LegacyOpenGL model, ThreeDSMesh4LegacyOpenGL mesh)
 {
     // nothing to do.
 }
Example #34
0
 public static void Dump(this MappingCoordinatesListChunk chunk, ThreeDSModel4LegacyOpenGL model, ThreeDSMesh4LegacyOpenGL mesh)
 {
     mesh.TexCoords = chunk.texCoords;
 }
Example #35
0
 public static void Dump(this ScaleTrackChunk chunk, ThreeDSModel4LegacyOpenGL model)
 {
     // nothing to do.
 }
Example #36
0
 public static void Dump(this CameraChunk chunk, ThreeDSModel4LegacyOpenGL model)
 {
     // nothing to do.
 }