Esempio n. 1
0
        private SceneNodeBase GetRootNode()
        {
            var group     = new GroupNode();
            var filenames = new string[] { "floor.obj_", "cube.obj_", };
            var colors    = new Color[] { Color.Green, Color.White, Color.White, };

            for (int i = 0; i < filenames.Length; i++)
            {
                string       folder   = System.Windows.Forms.Application.StartupPath;
                string       filename = System.IO.Path.Combine(folder + @"\..\..\..\..\Infrastructure\CSharpGL.Models", filenames[i]);
                var          parser   = new ObjVNFParser(true);
                ObjVNFResult result   = parser.Parse(filename);
                if (result.Error != null)
                {
                    MessageBox.Show(result.Error.ToString());
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new AdjacentTriangleModel(mesh);
                    var        node  = ShadowVolumeNode.Create(model, ObjVNF.strPosition, ObjVNF.strNormal, model.GetSize());
                    node.Color         = colors[i].ToVec3();
                    node.WorldPosition = new vec3(0, i * 5, 0);
                    node.Name          = filename;
                    group.Children.Add(node);
                }
            }
            {
                var obj = new AnnulusModel(3, 0.4f, 16, 16);
                obj.DumpObjFile("annulus.obj_");
                var          parser = new ObjVNFParser(true);
                ObjVNFResult result = parser.Parse("annulus.obj_");
                if (result.Error != null)
                {
                    MessageBox.Show(result.Error.ToString());
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new AdjacentTriangleModel(mesh);
                    var        node  = ShadowVolumeNode.Create(model, ObjVNF.strPosition, ObjVNF.strNormal, model.GetSize());
                    node.Color         = new vec3(1, 1, 1);
                    node.WorldPosition = new vec3(0, 1 * 5, 0);
                    node.Name          = "annulus.obj_";
                    group.Children.Add(node);
                }
            }

            return(group);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            {
                Console.WriteLine("sphere");
                var sphere   = new Sphere(1, 40, 80);
                var filename = "sphere.obj_";
                sphere.DumpObjFile(filename, "sphere");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "sphere");
                }
            }
            {
                Console.WriteLine("prismoid");
                var prismoid = new PrismoidModel(5, 5, 6, 6, 2);
                var filename = "prismoid.obj_";
                prismoid.DumpObjFile(filename, "prismoid");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "prismoid");
                }
            }
            {
                Console.WriteLine("cylinder");
                var cylinder = new CylinderModel(0.25f, 6, 17);
                var filename = "cylinder.obj_";
                cylinder.DumpObjFile(filename, "cylinder");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "cylinder");
                }
            }

            {
                Console.WriteLine("annulus");
                var annulus  = new AnnulusModel(0.5f + 0.4f, 0.3f, 17, 17);
                var filename = "annulus.obj_";
                annulus.DumpObjFile(filename, "annulus");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "annulus");
                }
            }

            {
                Console.WriteLine("disk");
                var disk     = new DiskModel(0.5f + 0.4f, 0.3f, 0.3f, 17, 17);
                var filename = "disk.obj_";
                disk.DumpObjFile(filename, "disk");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "disk");
                }
            }
            {
                Console.WriteLine("hanoiTower");
                var  list         = HanoiTower.GetDataSource();
                uint nextIndex    = 0;
                var  positionList = new List <vec3>();
                var  indexList    = new List <uint>();
                foreach (var item in list)
                {
                    vec3[] positions = item.model.GetPositions();
                    uint[] indexes   = item.model.GetIndexes();
                    for (int i = 0; i < positions.Length; i++)
                    {
                        positionList.Add(positions[i] + item.position);
                    }
                    for (int i = 0; i < indexes.Length; i++)
                    {
                        indexList.Add(indexes[i] + nextIndex);
                    }

                    nextIndex += (uint)positions.Length;
                }
                var hanoiTower = new TmpModel(positionList.ToArray(), indexList.ToArray());
                var filename   = "HanoiTower.obj_";
                hanoiTower.DumpObjFile(filename, "hanoiTower");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "hanoiTower");
                }
            }
            Console.WriteLine("done");
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            {
                Console.WriteLine("prismoid");
                var prismoid = new PrismoidModel(5, 5, 6, 6, 2);
                var filename = "prismoid.obj";
                prismoid.DumpObjFile(filename, "prismoid");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "prismoid");
                }
            }
            {
                Console.WriteLine("cylinder");
                var cylinder = new CylinderModel(0.25f, 6, 17);
                var filename = "cylinder.obj";
                cylinder.DumpObjFile(filename, "cylinder");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "cylinder");
                }
            }

            {
                Console.WriteLine("annulus");
                var annulus  = new AnnulusModel(0.5f + 0.4f, 0.3f, 17, 17);
                var filename = "annulus.obj";
                annulus.DumpObjFile(filename, "annulus");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "annulus");
                }
            }

            {
                Console.WriteLine("disk");
                var disk     = new DiskModel(0.5f + 0.4f, 0.3f, 0.3f, 17, 17);
                var filename = "disk.obj";
                disk.DumpObjFile(filename, "disk");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "disk");
                }
            }
            Console.WriteLine("done");
        }