Exemplo n.º 1
0
        public PathTraceTest()
        {
            Object3dInfo[] skydomeInfo = Object3dInfo.LoadFromObj(Media.Get("ptracetest.obj"));
               // var sponza = Object3dInfo.LoadSceneFromObj(Media.Get("cryteksponza.obj"), Media.Get("cryteksponza.mtl"), 0.03f);
            List<Mesh3d> meshes = new List<Mesh3d>();
            List<GenericMaterial> mats = new List<GenericMaterial>
            {
                new GenericMaterial(new Vector4(10.0f, 10.0f, 10.0f, 1.0f)),
                new GenericMaterial(new Vector4(0.1f, 0, 0, 1.0f)),
                new GenericMaterial(new Vector4(0, 0.1f, 0, 1.0f)),
                new GenericMaterial(new Vector4(0, 0, 0.1f, 1.0f)),
                new GenericMaterial(new Vector4(0, 0, 0.1f, 1.0f)),
                new GenericMaterial(new Vector4(1, 0, 0.1f, 1.0f)),
                new GenericMaterial(new Vector4(1, 0, 0.1f, 1.0f)),
                new GenericMaterial(new Vector4(1, 0, 0.1f, 1.0f)),
                new GenericMaterial(new Vector4(1, 0, 0.1f, 1.0f)),
                new GenericMaterial(new Vector4(1, 0, 0.1f, 1.0f)),
            };
            int ix = 0;
            foreach(var sd in skydomeInfo)
            {
                var skydomeMaterial = mats[ix++ % mats.Count];
                var skydome = new Mesh3d(sd, skydomeMaterial);
                meshes.Add(skydome);
            }
            Tracer = new PathTracer();
            Tracer.PrepareTrianglesData(meshes);
            foreach(var m in meshes)
                Add(m);

            PointLight pd = new PointLight(new Vector3(3, 10, 3), new Vector3(1, 1, 1), 0.2f, 16);
            Tracer.SetLights(new List<PointLight> { pd });

            Commons.FreeCam.Cam.SetPosition(10, 5, 10);
            Commons.FreeCam.Cam.LookAt(new Vector3(0, 0, 0));
            PostProcessing.Tracer = Tracer;
        }
Exemplo n.º 2
0
        public OldCityScene()
        {
            var scene = Object3dInfo.LoadSceneFromObj(Media.Get("cryteksponza.obj"), Media.Get("cryteksponza.mtl"), 0.03f);
            //var instances = InstancedMesh3d.FromMesh3dList(testroom);
            foreach(var ob in scene)
            {
                ob.SetMass(0);
                //ob.SetCollisionShape(ob.MainObjectInfo.GetAccurateCollisionShape());
                //ob.SpecularComponent = 0.1f;
                //ob.MainMaterial.ReflectionStrength = ob.MainMaterial.SpecularComponent;
                //ob.SetCollisionShape(ob.ObjectInfo.GetAccurateCollisionShape());
               // ob.Material = new SolidColorMaterial(new Vector4(1, 1, 1, 0.1f));
                //(ob.MainMaterial as GenericMaterial).Type = GenericMaterial.MaterialType.WetDrops;
                //(ob.MainMaterial as GenericMaterial).BumpMap = null;
                this.Add(ob);
            }
            PathTracer tracer = new PathTracer();
            tracer.PrepareTrianglesData(scene);
            //var protagonist = Object3dInfo.LoadSceneFromObj(Media.Get("protagonist.obj"), Media.Get("protagonist.mtl"), 1.0f);
            //foreach(var o in protagonist)
            //    Add(o);
            /*
               var fountainWaterObj = Object3dInfo.LoadFromObjSingle(Media.Get("turbinegun.obj"));
               var water = new Mesh3d(fountainWaterObj, new GenericMaterial(new Vector4(1, 1, 1, 1)));
               water.Transformation.Scale(1.0f);
               water.Translate(0, 10, 0);
               Add(water);*/

               Object3dInfo waterInfo = Object3dGenerator.CreateTerrain(new Vector2(-200, -200), new Vector2(200, 200), new Vector2(100, 100), Vector3.UnitY, 333, (x, y) => 0);

               var color = GenericMaterial.FromMedia("checked.png");
               color.SetNormalMapFromMedia("stones_map.png");
               //color.SetBumpMapFromMedia("lightref.png");
               Mesh3d water2 = new Mesh3d(waterInfo, color);
               water2.SetMass(0);
               water2.Translate(0, 0.1f, 0);
               water2.MainMaterial.ReflectionStrength = 1;
               //water.SetCollisionShape(new BulletSharp.StaticPlaneShape(Vector3.UnitY, 0));
               Add(water2);
               var dragon3dInfo = Object3dInfo.LoadFromObjSingle(Media.Get("apple.obj"));
               dragon3dInfo.ScaleUV(0.1f);
               var mat = GenericMaterial.FromMedia("skin.jpg");
               var dragon = new Mesh3d(dragon3dInfo, mat);
               //mat.Type = GenericMaterial.MaterialType.WetDrops;
               //dragon.Scale(5);
               dragon.SetMass(0);
               dragon.SetCollisionShape(dragon3dInfo.GetAccurateCollisionShape());
               Add(dragon);
            /*
            Object3dInfo waterInfo = Object3dGenerator.CreateTerrain(new Vector2(-200, -200), new Vector2(200, 200), new Vector2(100, 100), Vector3.UnitY, 333, (x, y) => 0);

            var color = new GenericMaterial(Color.Green);
            color.SetBumpMapFromMedia("grassbump.png");
            color.Type = GenericMaterial.MaterialType.Grass;
            Mesh3d water = new Mesh3d(waterInfo, color);
            water.SetMass(0);
            water.Translate(0, 1, 0);
            water.SetCollisionShape(new BulletSharp.StaticPlaneShape(Vector3.UnitY, 0));
            Add(water);

            var dragon3dInfo = Object3dInfo.LoadFromRaw(Media.Get("lucymidres.vbo.raw"), Media.Get("lucymidres.indices.raw"));
            dragon3dInfo.ScaleUV(0.1f);
            var dragon = new Mesh3d(dragon3dInfo, new GenericMaterial(Color.White));
            //dragon.Translate(0, 0, 20);
            dragon.Scale(80);
            Add(dragon);
            */
        }