Beispiel #1
0
        public BigTerrainScene()
        {
            var whiteboxInfo = Object3dManager.LoadFromObjSingle(Media.Get("whiteroom.obj"));
            var whitebox     = Mesh3d.Create(new Object3dInfo(whiteboxInfo.Vertices), new GenericMaterial(new Vector3(1000, 1000, 1000)));

            whitebox.GetInstance(0).Scale(3000);
            whitebox.GetInstance(0).Translate(0, -1500, 0);
            Game.World.Scene.Add(whitebox);
        }
Beispiel #2
0
        Mesh3d CreateDiffuseModelFromObj(string obj, Vector3 color)
        {
            var terrain3dManager = Object3dManager.LoadFromObjSingle(Media.Get(obj));

            terrain3dManager.ScaleUV(20);
            var terrain3dInfo   = new Object3dInfo(terrain3dManager.Vertices);
            var terrainMaterial = new GenericMaterial();

            terrainMaterial.DiffuseColor  = new Vector3(0.7f);
            terrainMaterial.SpecularColor = new Vector3(0.7f);
            terrainMaterial.Roughness     = 0.5f;
            var terrainMesh = Mesh3d.Create(terrain3dInfo, terrainMaterial);

            return(terrainMesh);
        }
        public static void Create()
        {
            var lucyobj = new Object3dInfo(Object3dManager.LoadFromObjSingle(Media.Get("sph1.obj")).Vertices);

            var bbmaterial = new GenericMaterial();

            bbmaterial.Roughness     = 0;
            bbmaterial.DiffuseColor  = Vector3.Zero;
            bbmaterial.SpecularColor = Vector3.One;

            var lucy = Mesh3d.Create(lucyobj, bbmaterial);

            lucy.ClearInstances();
            lucy.AutoRecalculateMatrixForOver16Instances = true;
            Game.World.Scene.Add(lucy);
            Commons.PickedMesh = lucy;
            Commons.Picked     = null;

            int      cnt = 0, din = 256;
            Renderer pp = new Renderer(din, din, 1);

            pp.GraphicsSettings.UseDeferred  = true;
            pp.GraphicsSettings.UseRSM       = false;
            pp.GraphicsSettings.UseVDAO      = true;
            pp.GraphicsSettings.UseFog       = false;
            pp.GraphicsSettings.UseBloom     = false;
            pp.GraphicsSettings.UseCubeMapGI = false;
            Game.DisplayAdapter.MainRenderer.CubeMaps.Clear();

            var internalMapping = new Dictionary <Renderer.CubeMapInfo, CubeMapFramebuffer>();

            /*
             * for(float x = -10; x < 13; x += 4.0f)
             * {
             *  for(float y = 0.2f; y < 15.3f; y += 6.0f)
             *  {
             *      for(float z = -3; z < 3.5; z += 3.0f)
             *      {
             *          CubeMapFramebuffer cubens = new CubeMapFramebuffer(din, din);
             *
             *          cubens.SetPosition(x*0.98f - 0.35f, y, z - 0.25f);
             *
             *          lucy.AddInstance(new Mesh3dInstance(new TransformationManager(cubens.GetPosition(), Quaternion.Identity, 0.1f), "cubemap-marker-" + cnt.ToString()));
             *          var info = new Renderer.CubeMapInfo()
             *          {
             *              FalloffScale = 5.0f,
             *              Texture = cubens.Texture,
             *              Position = cubens.GetPosition()
             *          };
             *          Game.DisplayAdapter.MainRenderer.CubeMaps.Add(info);
             *          internalMapping.Add(info, cubens);
             *          cnt++;
             *      }
             *  }
             * }*/

            for (int i = 0; i < 100; i++)
            {
                CubeMapFramebuffer cubens = new CubeMapFramebuffer(din, din);

                cubens.SetPosition(0, i, 0);

                lucy.AddInstance(new Mesh3dInstance(new TransformationManager(cubens.GetPosition(), Quaternion.Identity, 0.1f), "cubemap-marker-" + cnt.ToString()));
                var info = new Renderer.CubeMapInfo()
                {
                    FalloffScale = 7.0f,
                    Texture      = cubens.Texture,
                    Position     = cubens.GetPosition()
                };
                Game.DisplayAdapter.MainRenderer.CubeMaps.Add(info);
                internalMapping.Add(info, cubens);
                cnt++;
            }


            int  index    = 0;
            bool livemode = false;

            Game.OnKeyUp += (xa, eargs) =>
            {
                if (eargs.Key == OpenTK.Input.Key.PageUp)
                {
                    index++;
                }
                if (eargs.Key == OpenTK.Input.Key.PageDown)
                {
                    index--;
                }
                if (index > 9)
                {
                    index = 0;
                }
                if (index < 0)
                {
                    index = 9;
                }
                if (Commons.Picked == null)
                {
                    index = 0;
                }
                Commons.Picked      = lucy.GetInstance(index);
                TitleOutput.Message = "Picked cubemap ID " + index.ToString();
                if (eargs.Key == OpenTK.Input.Key.End)
                {
                    livemode = !livemode;
                }
                if (eargs.Key == OpenTK.Input.Key.Insert)
                {
                    for (int i = 0; i < cnt; i++)
                    {
                        Game.DisplayAdapter.MainRenderer.CubeMaps[i].Position *= -1;
                        internalMapping[Game.DisplayAdapter.MainRenderer.CubeMaps[i]].Clear();
                    }
                }
                if (eargs.Key == OpenTK.Input.Key.Home)
                {
                    var cpos = Camera.MainDisplayCamera.GetPosition();

                    /*
                     * float angle = 0;
                     * for(int i = 0; i < cnt; i++)
                     * {
                     *  float prc = (float)i / (float)cnt;
                     *  angle += 2.39996322f;
                     *  var disp = new Vector3(prc * 15.0f * (float)Math.Sin(angle), 1.0f - prc * 3.0f, prc * 15.0f * (float)Math.Cos(angle));
                     *  lucy.GetInstance(i).SetPosition(cpos + disp);
                     * }*/
                    for (int x = 0; x < 10; x++)
                    {
                        for (int y = 0; y < 10; y++)
                        {
                            int i = y + x * 10;
                            lucy.GetInstance(i).SetPosition(cpos + new Vector3(x - 5, 0, y - 5) * 2);
                        }
                    }
                }
                if (eargs.Key == OpenTK.Input.Key.Up)
                {
                    Game.DisplayAdapter.MainRenderer.CubeMaps[index].FalloffScale += 0.1f;
                }
                if (eargs.Key == OpenTK.Input.Key.Down)
                {
                    Game.DisplayAdapter.MainRenderer.CubeMaps[index].FalloffScale -= 0.1f;
                    if (Game.DisplayAdapter.MainRenderer.CubeMaps[index].FalloffScale < 0.02)
                    {
                        Game.DisplayAdapter.MainRenderer.CubeMaps[index].FalloffScale = 0.02f;
                    }
                }
            };
            int ix = 0;

            Game.OnBeforeDraw += (od, dsd) =>
            {
                //  for(int i = 0; i < 23; i++)
                // {
                //  if((lucy.GetInstance(i).GetPosition() - Game.DisplayAdapter.MainRenderer.CubeMaps[i].Position).Length > 0.01f)
                // {
                var cubes = Game.DisplayAdapter.MainRenderer.CubeMaps;
                if (!livemode)
                {
                    for (int iz = 0; iz < cnt; iz++)
                    {
                        if ((lucy.GetInstance(iz).GetPosition() - cubes[iz].Position).Length > 0.01f)
                        {
                            //internalMapping[cubes[iz]].Clear();
                        }
                    }
                    for (int iz = 0; iz < cnt; iz++)
                    {
                        if ((lucy.GetInstance(iz).GetPosition() - cubes[iz].Position).Length > 0.01f)
                        {
                            Game.World.CurrentlyRenderedCubeMap = iz;
                            pp.CubeMaps        = cubes;
                            cubes[iz].Position = lucy.GetInstance(iz).GetPosition();
                            internalMapping[cubes[iz]].SetPosition(lucy.GetInstance(iz).GetPosition());
                            pp.RenderToCubeMapFramebuffer(internalMapping[cubes[iz]]);
                            internalMapping[cubes[iz]].GenerateMipMaps();
                            Game.World.CurrentlyRenderedCubeMap = -1;
                        }
                    }

                    return;
                }
                int i = ix++;
                if (ix >= cnt)
                {
                    ix = 0;
                }
                Game.World.CurrentlyRenderedCubeMap = i;
                pp.CubeMaps       = cubes;
                cubes[i].Position = lucy.GetInstance(i).GetPosition();
                internalMapping[cubes[i]].SetPosition(lucy.GetInstance(i).GetPosition());
                pp.RenderToCubeMapFramebuffer(internalMapping[cubes[i]]);
                internalMapping[cubes[i]].GenerateMipMaps();
                Game.World.CurrentlyRenderedCubeMap = -1;
                //  }
                //  }
            };
        }
Beispiel #4
0
        private static void Main(string[] args)
        {
            Arguments = new Dictionary <string, string>();
            foreach (var a in args)
            {
                int i = a.IndexOf('=');
                if (i > 0)
                {
                    string k = a.Substring(0, i);
                    string v = a.Substring(i + 1);
                    Arguments.Add(k, v);
                }
            }
            mode             = args[0];
            infile           = args[1];
            outfile          = args[2];
            Media.SearchPath = "media";

            if (mode == "scene2assets")
            {
                string scenename = args[3];
                var    element   = new VEngine.FileFormats.GameScene(infile);
                element.Load();
                int           unnamed = 0;
                StringBuilder sceneb  = new StringBuilder();
                var           rand    = new Random();
                foreach (var m in element.Meshes)
                {
                    string name = "mesh" + (unnamed++);
                    SaveMeshToFile(m, name, outfile);
                    sceneb.AppendLine("mesh3d " + name + ".mesh3d");
                }
                File.WriteAllText(outfile + "/" + scenename, sceneb.ToString());
            }
            if (mode == "obj2raw")
            {
                var element = Object3dManager.LoadFromObjSingle(infile);
                element.SaveRaw(outfile);
            }
            if (mode == "obj2rawtangsmooth")
            {
                var element = Object3dManager.LoadFromObjSingle(infile);
                element.RecalulateNormals(Object3dManager.NormalRecalculationType.Smooth, 1);
                element.SaveRawWithTangents(outfile);
            }
            if (mode == "raw2rawtang")
            {
                var element = Object3dManager.LoadFromRaw(infile);
                element.SaveRawWithTangents(outfile);
            }
            if (mode == "obj2rawtang")
            {
                var element = Object3dManager.LoadFromObjSingle(infile);
                element.SaveRawWithTangents(outfile);
            }
            if (mode == "objscene2assets")
            {
                Console.WriteLine("Conversion started");
                var elements = Object3dManager.LoadSceneFromObj(infile + ".obj", infile + ".mtl");

                var           map       = new List <string>();
                var           r         = new Random();
                StringBuilder sceneb    = new StringBuilder();
                string        scenename = args[3];

                Console.WriteLine("Found elements " + elements.Count);
                foreach (var m in elements)
                {
                    string n = m.GetInstance(0).Name;
                    if (n == null || n.Length == 0 || map.Contains(n))
                    {
                        n = m.GetLodLevel(0).Info3d.Manager.Name;
                    }
                    if (n == null || n.Length == 0 || map.Contains(n))
                    {
                        n = m.GetLodLevel(0).Material.Name;
                    }
                    if (n == null || n.Length == 0 || map.Contains(n))
                    {
                        n = Path.GetFileNameWithoutExtension(m.GetLodLevel(0).Material.DiffuseTexture.FileName);
                    }
                    if (n == null || n.Length == 0 || map.Contains(n))
                    {
                        n = Path.GetFileNameWithoutExtension(m.GetLodLevel(0).Material.BumpTexture.FileName);
                    }
                    if (n == null || n.Length == 0 || map.Contains(n))
                    {
                        n = Path.GetFileNameWithoutExtension(m.GetLodLevel(0).Material.NormalsTexture.FileName);
                    }
                    while (n == null || n.Length == 0 || map.Contains(n))
                    {
                        n = "unknown_" + r.Next();
                    }
                    Console.WriteLine("Converting mesh " + n);

                    SaveMeshToFile(m, n, outfile);
                    sceneb.AppendLine("mesh3d " + n + ".mesh3d");
                }
                Console.WriteLine("Saving scene");
                File.WriteAllText(outfile + "/" + scenename, sceneb.ToString());
            }

            if (mode == "ply2raw")
            {
                var ai          = new AssimpContext();
                var vertexinfos = new List <VertexInfo>();
                var mi          = ai.ImportFile(infile, PostProcessSteps.Triangulate);
                foreach (var m in mi.Meshes)
                {
                    var indices = m.GetIndices();

                    for (int i = 0; i < indices.Length; i++)
                    {
                        int f  = indices[i];
                        var vp = m.Vertices[f];
                        var vn = m.Normals[f];
                        var vt = (m.TextureCoordinateChannels.Length == 0 || m.TextureCoordinateChannels[0].Count <= f) ? new Assimp.Vector3D(0) : m.TextureCoordinateChannels[0][f];
                        var vi = new VertexInfo()
                        {
                            Position = new Vector3(vp.X, vp.Y, vp.Z),
                            Normal   = new Vector3(vn.X, vn.Y, vn.Z),
                            UV       = new Vector2(vt.X, vt.Y)
                        };
                        vertexinfos.Add(vi);
                    }
                }

                var element = new Object3dManager(vertexinfos);
                element.SaveRaw(outfile);
            }
            if (mode == "generateterrain")
            {
                RequireArgs("resolution", "in", "out", "size", "uvscale", "height");
                var    img        = new System.Drawing.Bitmap(Arguments["in"]);
                int    resolution = int.Parse(Arguments["resolution"]);
                string ofile      = Arguments["out"];
                float  size       = float.Parse(Arguments["size"], System.Globalization.CultureInfo.InvariantCulture) / 2.0f;
                float  uvscale    = float.Parse(Arguments["uvscale"], System.Globalization.CultureInfo.InvariantCulture);
                float  height     = float.Parse(Arguments["height"], System.Globalization.CultureInfo.InvariantCulture);
                int    lx         = 1;
                var    t          = VEngine.Generators.Object3dGenerator.CreateTerrain(new Vector2(-size), new Vector2(size), new Vector2(uvscale), Vector3.UnitY, resolution, (x, y) =>
                {
                    int xpx = (int)(x * img.Size.Width);
                    int ypx = (int)(y * img.Size.Height);
                    if (xpx >= img.Size.Width)
                    {
                        xpx = img.Size.Width - 1;
                    }
                    if (ypx >= img.Size.Height)
                    {
                        ypx = img.Size.Height - 1;
                    }
                    var col  = img.GetPixel(xpx, ypx);
                    int zxzs = (int)(x * 100.0);
                    if (zxzs > lx)
                    {
                        Console.WriteLine(zxzs);
                    }
                    if (zxzs > lx)
                    {
                        lx = zxzs;
                    }
                    return(((float)(col.R) / 255.0f) * height);
                });
                Console.WriteLine("Starting saving");
                t.SaveRawWithTangents(ofile);
            }
            if (mode == "assimp2assets")
            {
                // convert.exe assimp2assets infile.dae outdir outname.scene
                var ai        = new AssimpContext();
                var usednames = new List <string>();
                var mi        = ai.ImportFile(infile, PostProcessSteps.Triangulate | PostProcessSteps.GenerateSmoothNormals);

                int    cnt       = 0;
                var    scenesb   = new StringBuilder();
                string scenename = args[3];
                doublefaced = args.Length == 5 && args[4] == "doublefaced";
                foreach (var m in mi.Materials)
                {
                    string name = usednames.Contains(m.Name) ? (m.Name + (unnamed++).ToString()) : m.Name;
                    var    sb   = new StringBuilder();
                    sb.AppendLine(string.Format("diffuse {0} {1} {2}", ftos(m.ColorDiffuse.R), ftos(m.ColorDiffuse.G), ftos(m.ColorDiffuse.B)));
                    sb.AppendLine(string.Format("roughness {0}", ftos(1.0f / (m.Shininess + 1.0f))));
                    sb.AppendLine(string.Format("metalness {0}", ftos(0.0f)));
                    sb.AppendLine();

                    if (m.HasTextureDiffuse)
                    {
                        sb.AppendLine("node");
                        sb.AppendLine(string.Format("texture {0}", Path.GetFileName(m.TextureDiffuse.FilePath)));
                        sb.AppendLine("mix REPLACE");
                        sb.AppendLine("target DIFFUSE");
                        sb.AppendLine("modifier LINEARIZE");
                        sb.AppendLine();
                    }
                    if (m.HasTextureReflection)
                    {
                        sb.AppendLine("node");
                        sb.AppendLine(string.Format("texture {0}", Path.GetFileName(m.TextureReflection.FilePath)));
                        sb.AppendLine("mix REPLACE");
                        sb.AppendLine("target ROUGHNESS");
                        sb.AppendLine();
                    }
                    if (m.HasTextureSpecular)
                    {
                        sb.AppendLine("node");
                        sb.AppendLine(string.Format("texture {0}", Path.GetFileName(m.TextureSpecular.FilePath)));
                        sb.AppendLine("mix REPLACE");
                        sb.AppendLine("target ROUGHNESS");
                        sb.AppendLine();
                    }
                    if (m.HasTextureNormal)
                    {
                        sb.AppendLine("node");
                        sb.AppendLine(string.Format("texture {0}", Path.GetFileName(m.TextureNormal.FilePath)));
                        sb.AppendLine("mix REPLACE");
                        sb.AppendLine("target NORMAL");
                        sb.AppendLine();
                    }
                    if (m.HasTextureDisplacement)
                    {
                        sb.AppendLine("node");
                        sb.AppendLine(string.Format("texture {0}", Path.GetFileName(m.TextureDisplacement.FilePath)));
                        sb.AppendLine("mix REPLACE");
                        sb.AppendLine("target BUMP");
                        sb.AppendLine();
                    }
                    Console.WriteLine("Saving " + outfile + "/" + name + ".material");
                    File.WriteAllText(outfile + "/" + name + ".material", sb.ToString());
                    matdict.Add(cnt, outfile + "/" + name + ".material");
                    cnt++;
                }
                recurseNode(mi, mi.RootNode, scenesb, Matrix4x4.Identity);
                Console.WriteLine("Saving " + outfile + "/" + scenename);
                File.WriteAllText(outfile + "/" + scenename, scenesb.ToString());
            }


            Console.WriteLine("Done");
        }
Beispiel #5
0
        public LightningTestScene()
        {
            var scene = Game.World.Scene;

            Game.Invoke(() =>
            {
                var ground = CreateWall(new Vector2(-1000), new Vector2(1000), Quaternion.Identity, Vector3.Zero, new Vector3(0.1f, 0.4f, 1));
                // scene.Add(ground);

                var obj = Object3dManager.LoadFromObjSingle(Media.Get("emily.obj"));
                obj.RecalulateNormals(Object3dManager.NormalRecalculationType.Smooth, 1);
                var t1 = CreateModel(obj.AsObject3dInfo(), new Vector3(0.8f), new Vector3(0.2f), 0.1f);

                t1.GetLodLevel(0).Material.SetDiffuseTexture("00_diffuse_unlit_unpainted.png");
                t1.GetLodLevel(0).Material.SetSpecularTexture("00_specular_unlit_unpainted.png");
                t1.GetLodLevel(0).Material.SetBumpTexture("00_displacement_misdfcro.png");

                scene.Add(t1);

                var obj2 = Object3dManager.LoadFromObjSingle(Media.Get("emilylashes.obj"));
                var t2   = CreateModel(obj2.AsObject3dInfo(), new Vector3(0.8f), new Vector3(0.2f), 0.1f);

                t2.GetLodLevel(0).Material.DiffuseColor  = Vector3.Zero;
                t2.GetLodLevel(0).Material.SpecularColor = Vector3.Zero;

                scene.Add(t2);

                // var obj2 = Object3dManager.LoadFromObjSingle(Media.Get("emilyeyes.obj"));
                //  var t2 = CreateModel(obj2.AsObject3dInfo(), new Vector3(0.8f), new Vector3(0.2f), 0.1f);

                //  t2.GetLodLevel(0).Material.DiffuseColor = Vector3.Zero;
                //  t2.GetLodLevel(0).Material.SpecularColor = Vector3.Zero;

                //  scene.Add(t2);

                /*
                 * var m = CreateDiffuseModelFromObj("hipolysphere.obj", new Vector3(1));
                 * m.GetLodLevel(0).Material.SpecularColor = new Vector3(1.0f);
                 * m.GetLodLevel(0).Material.DiffuseColor= new Vector3(0.0f);
                 * m.GetLodLevel(0).Material.Roughness = 0.9f;
                 * scene.Add(m);*/

                /* var green = CreateWall(new Vector2(-100), new Vector2(100), Quaternion.FromAxisAngle(Vector3.UnitX, MathHelper.DegreesToRadians(90)), Vector3.Zero, new Vector3(0.2f, 1, 0.3f));
                 * var red = CreateWall(new Vector2(-100), new Vector2(100), Quaternion.FromAxisAngle(Vector3.UnitZ, MathHelper.DegreesToRadians(90)), Vector3.Zero, new Vector3(1, 0.2f, 0.2f));
                 * green.GetInstance(0).Translate(0, 0, -15);
                 * red.GetInstance(0).Translate(15, 0, 0);
                 *
                 * var lucy = CreateDiffuseModelFromRaw("lucy.vbo.raw", new Vector3(1));
                 * //scene.Add(green);
                 * //scene.Add(red);
                 *
                 * Game.CascadeShadowMaps.SetDirection(Quaternion.FromAxisAngle(Vector3.UnitX, MathHelper.DegreesToRadians(-25)));
                 *
                 * scene.Add(lucy);
                 *
                 * float[] billboardfloats = {
                 *   -1.0f, 0, 0, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
                 *   1.0f, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
                 *   -1.0f, 1.0f, 0, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
                 *   1.0f, 1.0f, 0, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f
                 * };
                 *
                 * var billboardObj = new Object3dManager(VertexInfo.FromFloatArray(billboardfloats)).AsObject3dInfo();
                 * billboardObj.DrawMode = OpenTK.Graphics.OpenGL4.PrimitiveType.TriangleStrip;
                 * string[] trees = new string[] { "vurt_PineSnowy.dds" };
                 * for(int id = 0; id < 1; id++)
                 * {
                 *   var billboardMaterial = new GenericMaterial();
                 *   billboardMaterial.UseForwardRenderer = true;
                 *   billboardMaterial.IsBillboard = true;
                 *   billboardMaterial.SetDiffuseTexture(trees[id]);
                 *   //billboardMaterial.SetNormalsTexture("alphatest_n.png");
                 *   billboardMaterial.Roughness = 0.8f;
                 *   billboardMaterial.InvertUVy = true;
                 *
                 *   var billboardMesh = Mesh3d.Create(billboardObj, billboardMaterial);
                 *   billboardMesh.ClearInstances();
                 *
                 *   for(int i = 0; i < 30000; i++)
                 *   {
                 *       var pos = new Vector3(rand(-1000, 1000), 0, rand(-1000, 1000));
                 *       float uniscale = rand(1.7f, 2.5f);
                 *       var scale = new Vector3(uniscale, rand(12.3f, 12.4f), uniscale);
                 *       billboardMesh.AddInstance(new TransformationManager(pos, scale));
                 *   }
                 *   billboardMesh.UpdateMatrix();
                 *
                 *   Game.CreateThread(() =>
                 *   {
                 *       while(true)
                 *       {
                 *           //billboardMesh.IterationSortInstancesByDistanceFrom(Camera.MainDisplayCamera.Transformation.Position, 50);
                 *           billboardMesh.FullSortInstancesByDistanceFrom(Camera.MainDisplayCamera.Transformation.Position);
                 *           billboardMesh.UpdateMatrix(false);
                 *       }
                 *   });
                 *
                 *
                 *
                 *   scene.Add(billboardMesh);
                 * }
                 * string[] vegs = new string[] { "fieldgrassobj01.dds", "vurt_brownplants.dds" };
                 * for(int id = 0; id < 1; id++)
                 * {
                 *   var billboardMaterial = new GenericMaterial();
                 *   billboardMaterial.UseForwardRenderer = true;
                 *   billboardMaterial.IsBillboard = true;
                 *   billboardMaterial.SetDiffuseTexture(vegs[id]);
                 *   //billboardMaterial.SetNormalsTexture("alphatest_n.png");
                 *   billboardMaterial.Roughness = 0.8f;
                 *   billboardMaterial.InvertUVy = true;
                 *   billboardMaterial.Blending = GenericMaterial.BlendingEnum.Alpha;
                 *
                 *   var billboardMesh = Mesh3d.Create(billboardObj, billboardMaterial);
                 *   billboardMesh.ClearInstances();
                 *
                 *   for(int i = 0; i < 3000000; i++)
                 *   {
                 *       var pos = new Vector3(rand(-1000, 1000), 0, rand(-1000, 1000));
                 *       float uniscale = rand(1.7f, 2.5f);
                 *       var scale = new Vector3(uniscale, rand(2.3f, 2.4f), uniscale);
                 *       billboardMesh.AddInstance(new TransformationManager(pos, scale));
                 *   }
                 *   billboardMesh.UpdateMatrix();
                 *
                 *   Game.CreateThread(() =>
                 *   {
                 *       while(true)
                 *       {
                 *           //billboardMesh.IterationSortInstancesByDistanceFrom(Camera.MainDisplayCamera.Transformation.Position, 50);
                 *           billboardMesh.FullSortInstancesByDistanceFrom(Camera.MainDisplayCamera.Transformation.Position);
                 *           billboardMesh.UpdateMatrix(false);
                 *       }
                 *   });
                 *
                 *
                 *
                 *   scene.Add(billboardMesh);
                 * }*/

                /*
                 * var trootobj = new Object3dInfo(Object3dManager.LoadFromObjSingle(Media.Get("tree2r.obj")).Vertices);
                 * var tleavobj = new Object3dInfo(Object3dManager.LoadFromObjSingle(Media.Get("tree2l.obj")).Vertices);
                 * var rootmaterial = new GenericMaterial()
                 * {
                 *  Roughness = 0.9f,
                 *  DiffuseColor = Vector3.One,
                 *  SpecularColor = Vector3.Zero
                 * };
                 * var leavmaterial = new GenericMaterial()
                 * {
                 *  Roughness = 0.9f,
                 *  DiffuseColor = Vector3.One,
                 *  SpecularColor = Vector3.Zero
                 * };
                 * //  leavmaterial.SetAlphaTexture("Branches0018_1_S_mask.png");
                 * leavmaterial.SetDiffuseTexture("Hedge 00 seamless.jpg");
                 *
                 * var trm = Mesh3d.Create(trootobj, rootmaterial);
                 * var tlm = Mesh3d.Create(tleavobj, leavmaterial);
                 * scene.Add(trm);
                 * scene.Add(tlm);
                 *
                 * trm.ClearInstances();
                 * tlm.ClearInstances();
                 *
                 *
                 *
                 * for(int i = 0; i < 100; i++)
                 * {
                 *  var pos = new Vector3(rand(-100, 100), 0, rand(-100, 100));
                 *  float uniscale = rand(0.7f, 1.5f);
                 *  var scale = new Vector3(uniscale, rand(0.7f, 3.0f), uniscale);
                 *  trm.AddInstance(new TransformationManager(pos, scale));
                 *  tlm.AddInstance(new TransformationManager(pos, scale));
                 * }
                 * trm.UpdateMatrix();
                 * tlm.UpdateMatrix();
                 */
                /*
                 * var cubeMaterial = new GenericMaterial(new Vector3(1, 0, 0));
                 * var cubeObj3d = new Object3dInfo(Object3dGenerator.CreateCube(new Vector3(1), new Vector2(1)).Vertices);
                 * //var cubeObj3d = new Object3dInfo(Object3dGenerator.CreateGround(new Vector2(-1), new Vector2(1), new Vector2(1), Vector3.UnitY).Vertices);
                 *
                 * var cubes = Mesh3d.Create(cubeObj3d, cubeMaterial);
                 * cubes.ClearInstances();
                 *
                 * for(int x = 0; x < 100; x++)
                 *  for(int y = 0; y < 100; y++)
                 *      for(int z = 0; z < 100; z++)
                 *      {
                 *          cubes.AddInstance(new TransformationManager(new Vector3(x, y, z) * 4));
                 *      }
                 * cubes.UpdateMatrix();
                 *
                 * scene.Add(cubes);*/

                /*
                 * var cityMgr = Object3dManager.LoadFromObjSingle(Media.Get("somecity.obj"));
                 * cityMgr.TryToFixVertexWinding();
                 * cityMgr.RecalulateNormals(Object3dManager.NormalRecalculationType.Flat);
                 * var cityObj = cityMgr.AsObject3dInfo();
                 * var cityMat = new GenericMaterial()
                 * {
                 *  DiffuseColor = new Vector3(1, 0.89f, 0.97f),
                 *  Roughness = 0.2f
                 * };
                 * var cityMesh = Mesh3d.Create(cityObj, cityMat);
                 * cityMesh.GetInstance(0).Translate(0, 0.1f, 0);
                 * scene.Add(cityMesh);*/
                //
                //  var citimul = Object3dManager.LoadSceneFromObj("somecity.obj", "somecity.mtl");
                //  foreach(var m in citimul)
                //      scene.Add(m);

                /*
                 * var terrain = new Object3dInfo( Object3dGenerator.CreateTerrain(new Vector2(-10000, -10000), new Vector2(10000, 10000), new Vector2(1, -1), Vector3.UnitY, 512, (x,y) => 0).Vertices );
                 * var terrainMaterial = new GenericMaterial();
                 * terrainMaterial.Type = GenericMaterial.MaterialType.TessellatedTerrain;
                 * terrainMaterial.TessellationMultiplier = 1.0f;
                 * terrainMaterial.ParallaxHeightMultiplier = 200.0f;
                 * terrainMaterial.SetBumpTexture("ee.png");
                 * var terrainMesh = Mesh3d.Create(terrain, terrainMaterial);
                 * scene.Add(terrainMesh);*/

                // DynamicCubeMapController.Create();
            });
        }