public override void Init(GameModel _env)
        {
            Env = _env;
            string compilationErrors;

            var d3dDevice = D3DDevice.Instance.Device;

            EfectoRender3D = Effect.FromFile(d3dDevice, Env.ShadersDir + "render3D.fx",
                                             null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors);
            if (EfectoRender3D == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }
            EfectoRender2D = Effect.FromFile(d3dDevice, Env.ShadersDir + "render2D.fx",
                                             null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors);
            if (EfectoRender2D == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }
            EfectoRender2D.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth);
            EfectoRender2D.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight);
            try
            {
                texturaVida = TextureLoader.FromFile(d3dDevice, Env.MediaDir + "\\Menu\\heart.png");
            }
            catch
            {
                throw new Exception(string.Format("Error at loading texture: {0}", Env.MediaDir + "\\Menu\\heart.png"));
            }
            Reset();



            // Cargar escena
            Loader = new TgcSceneLoader();
            Scene  = Loader.loadSceneFromFile(Env.MediaDir + "\\" + "Escenario1\\escenarioSubterraneo-TgcScene.xml");


            // Setear cancion
            cancionPcpal.FileName = Env.MediaDir + "\\Sound\\crash.mp3";

            //piso
            var PisoSelvaTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, Env.MediaDir + "pasto.jpg");

            PisoSelva = new TgcPlane(new TGCVector3(-200f, 0f, -100f), new TGCVector3(50, 5f, 200), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
        }
Esempio n. 2
0
        public override void Init(GameModel _env)
        {
            //useShadows = false;
            Env = _env;
            string compilationErrors;
            var    d3dDevice = D3DDevice.Instance.Device;

            shadowEffect         = TgcShaders.loadEffect(Env.ShadersDir + "ShadowMap.fx");
            skeletalShadowEffect = TgcShaders.loadEffect(Env.ShadersDir + "TgcSkeletalShadowMapMeshShader.fx");

            shaderArbustos = TgcShaders.loadEffect(Env.ShadersDir + "movimientoArbustos.fx");

            shaderLiquidos = TgcShaders.loadEffect(Env.ShadersDir + "movimientoLiquidos.fx");

            shaderAceites = TgcShaders.loadEffect(Env.ShadersDir + "movimientoLiquidos.fx");

            time = 0;

            var dir = new TGCVector3(0, -1, 0);

            dir.Normalize();
            Lights.Add(new Tuple <float, TGCVector3, TGCVector3>(0.05f, new TGCVector3(0, 80, 100), dir));
            dir = new TGCVector3(1, -2, 0);
            dir.Normalize();
            Lights.Add(new Tuple <float, TGCVector3, TGCVector3>(0.05f, new TGCVector3(220, 80, 390), dir));
            Lights.Add(new Tuple <float, TGCVector3, TGCVector3>(0.05f, new TGCVector3(1370, 80, 57), new TGCVector3(0, -1, 0)));
            Lights.Add(new Tuple <float, TGCVector3, TGCVector3>(0.05f, new TGCVector3(842, 80, -327), new TGCVector3(0, -1, 0)));
            Lights.Add(new Tuple <float, TGCVector3, TGCVector3>(0.05f, new TGCVector3(1050, 80, -110), new TGCVector3(0, -1, 0)));
            g_LightPos     = new TGCVector3(140, 40, 390);
            EfectoRender2D = Effect.FromFile(d3dDevice, Env.ShadersDir + "render2D.fx",
                                             null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors);
            if (EfectoRender2D == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }
            EfectoRender2D.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth);
            EfectoRender2D.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight);
            try
            {
                texturaVida = TextureLoader.FromFile(d3dDevice, Env.MediaDir + "\\Menu\\heart.png");
                texturaLogo = TextureLoader.FromFile(d3dDevice, Env.MediaDir + "\\Menu\\LogoTGC.png");
            }
            catch
            {
                throw new Exception(string.Format("Error at loading texture: {0}", Env.MediaDir + "\\Menu\\heart.png"));
            }

            TextoLogo.Align = TgcText2D.TextAlign.LEFT;
            TextoLogo.changeFont(new System.Drawing.Font("Comic Sans MS", 24, FontStyle.Bold));
            TextoLogo.Position = new Point(D3DDevice.Instance.Width - 70, D3DDevice.Instance.Height - 65);
            TextoLogo.Color    = Color.White;


            var PisoSelvaTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, Env.MediaDir + "pasto.jpg");

            PisoSelva1 = new TgcPlane(new TGCVector3(-81f, 0f, -74f), new TGCVector3(168f, 5f, 161f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva1);
            PisoSelva2 = new TgcPlane(new TGCVector3(-81f, 0f, 150f), new TGCVector3(168f, 5f, 110f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva2);
            PisoSelva3 = new TgcPlane(new TGCVector3(-81f, 0f, 278f), new TGCVector3(302f, 5f, 247f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva3);
            PisoSelva4 = new TgcPlane(new TGCVector3(309f, 0f, 278f), new TGCVector3(111f, 5f, 247f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva4);
            PisoSelva5 = new TgcPlane(new TGCVector3(595f, 0f, 236f), new TGCVector3(387f, 5f, 350f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva5);
            PisoSelva6 = new TgcPlane(new TGCVector3(707f, 0f, -50f), new TGCVector3(259f, 5f, 77f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva6);
            PisoSelva7 = new TgcPlane(new TGCVector3(834f, 0f, 49f), new TGCVector3(132f, 5f, 48f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva7);
            PisoSelva8 = new TgcPlane(new TGCVector3(707f, 0f, 147.5f), new TGCVector3(130f, 5f, 38f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva8);
            PisoSelva9 = new TgcPlane(new TGCVector3(707f, -0.1f, 0f), new TGCVector3(81f, 5f, 148f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva9);
            PisoSelva10 = new TgcPlane(new TGCVector3(881f, -0.1f, -0.2f), new TGCVector3(79.5f, 5f, 50f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva10);
            PisoSelva11 = new TgcPlane(new TGCVector3(883f, -0.1f, 96f), new TGCVector3(83f, 5f, 145f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva11);
            PisoSelva12 = new TgcPlane(new TGCVector3(43.7f, -0.1f, 219f), new TGCVector3(552f, 5f, 133.5f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva12);
            PisoSelva13 = new TgcPlane(new TGCVector3(218f, -0.1f, 432f), new TGCVector3(379f, 5f, 148.5f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva13);
            PisoSelva14 = new TgcPlane(new TGCVector3(-81f, -0.1f, 86f), new TGCVector3(40f, 5f, 193f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva14);
            PisoSelva15 = new TgcPlane(new TGCVector3(41f, -0.1f, 82f), new TGCVector3(46f, 5f, 70f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva15);
            PisoSelva16 = new TgcPlane(new TGCVector3(705f, -0.1f, 185f), new TGCVector3(84f, 5f, 58f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva16);

            var PisoCastilloTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, Env.MediaDir + "rockfloor.jpg");

            PisoCastillo1 = new TgcPlane(new TGCVector3(791f, 21f, -155.4f), new TGCVector3(91f, 5f, 27.7f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo1);
            PisoCastillo2 = new TgcPlane(new TGCVector3(776f, 21f, -604f), new TGCVector3(218.2f, 5f, 331.3f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo2);
            PisoCastillo3 = new TgcPlane(new TGCVector3(1088.4f, 21f, -607.2f), new TGCVector3(158.8f, 5f, 118f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo3);
            PisoCastillo4 = new TgcPlane(new TGCVector3(1436.2f, 21f, -611.2f), new TGCVector3(270.4f, 5f, 331.4f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo4);
            PisoCastillo5 = new TgcPlane(new TGCVector3(1614.6f, 21f, -279.9f), new TGCVector3(87.65f, 5f, 97.9f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo5);
            PisoCastillo6 = new TgcPlane(new TGCVector3(1538.2f, 21f, -182.5f), new TGCVector3(169f, 5f, 58.6f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo6);
            PisoCastillo7 = new TgcPlane(new TGCVector3(1485f, 21f, -75.5f), new TGCVector3(228f, 5f, 192.2f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo7);
            PisoCastillo8 = new TgcPlane(new TGCVector3(1540f, 21f, -124.36f), new TGCVector3(58.35f, 5f, 49.16f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo8);
            PisoCastillo9 = new TgcPlane(new TGCVector3(986f, 21f, -108.7603f), new TGCVector3(134.15f, 5f, 223.6003f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo9);
            PisoCastillo10 = new TgcPlane(new TGCVector3(951f, 21f, -225f), new TGCVector3(130f, 5f, 116.2397f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo10);
            PisoCastillo11 = new TgcPlane(new TGCVector3(1080f, 21f, -185f), new TGCVector3(50f, 5f, 80f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo11);
            var Acido = TgcTexture.createTexture(D3DDevice.Instance.Device, Env.MediaDir + "slime7.jpg");

            PisoAcido = new TgcPlane(new TGCVector3(1427f, -228.4502f, -1000f), new TGCVector3(400f, 5f, 450f), TgcPlane.Orientations.XZplane, Acido, 15, 15);
            ListaPlanoAcido.Add(PisoAcido);

            //Crear SkyBox
            CreateSkyBox(TGCVector3.Empty, new TGCVector3(10000, 10000, 10000), "SkyBox1");

            // Cargar escena
            Loader = new TgcSceneLoader();
            Scene  = Loader.loadSceneFromFile(Env.MediaDir + "\\" + "Escenario1\\escenarioConLogos-TgcScene.xml");

            Reset();
            ///////////agrego pisos subterraneos

            ListaPisosSubterraneos = Scene.Meshes.FindAll(m => m.Name.Contains("Floor"));

            foreach (var piso in ListaPisosSubterraneos)
            {
                Scene.Meshes.Remove(piso);
            }

            // Paredes
            ListaParedesCastillo = Scene.Meshes.FindAll(m => m.Name.Contains("ParedCastillo"));
            TgcMesh paredSinBB = Scene.Meshes.Find(m => m.Name.Contains("ParedCastillo441"));

            foreach (var m in ListaParedesCastillo)
            {
                m.AutoTransform = false;
                var p = (m.BoundingBox.PMax + m.BoundingBox.PMin) * 0.5f;
                var t = new TGCVector3(0, 20.8f, 0);
                m.Transform = TGCMatrix.Translation(-1 * p) * TGCMatrix.Translation(t + p);
                m.BoundingBox.scaleTranslate(new TGCVector3(0, 21, 0), new TGCVector3(1, 1, 1));
            }
            ListaParedesCastillo.Remove(paredSinBB); //elimino la pared que no necesita agrandar su BB
            foreach (var m in ListaParedesCastillo)
            {
                m.BoundingBox = new TgcBoundingAxisAlignBox(m.BoundingBox.PMin - new TGCVector3(5, 0, 5), m.BoundingBox.PMax + new TGCVector3(5, 0, 5));
            }
            // Paredes envolventes
            ListaParedesEnvolventes = Scene.Meshes.FindAll(m => m.Name.Contains("ParedEnvolvente") || m.Name.Contains("Room"));
            foreach (var m in ListaParedesEnvolventes)
            {
                m.BoundingBox = new TgcBoundingAxisAlignBox(m.BoundingBox.PMin - new TGCVector3(5, 0, 5), m.BoundingBox.PMax + new TGCVector3(5, 0, 5));
            }
            // Paredes de caida
            ListaParedesCaida = Scene.Meshes.FindAll(m => m.Name.Contains("Plane"));
            foreach (var m in ListaParedesCaida)
            {
                var agregado = new TGCVector3(3, -0.8f, 3);
                m.BoundingBox = new TgcBoundingAxisAlignBox(m.BoundingBox.PMin - agregado, m.BoundingBox.PMax + agregado);
            }

            // Pozos
            ListaPozos = Scene.Meshes.FindAll(m => m.Name.Contains("Pozo"));
            foreach (var mesh in ListaPozos)
            {
                Scene.Meshes.Remove(mesh);
            }

            // Logos
            ListaLogos = Scene.Meshes.FindAll(m => m.Name.Contains("LogoTGC"));
            CantLogos  = ListaLogos.Count;

            // Alargar algunas AABB
            var r = new Random();

            foreach (var mesh in Scene.Meshes.FindAll(m => m.Name.Contains("Arbusto")))
            {
                mesh.BoundingBox.scaleTranslate(new TGCVector3(0, 0, 0), new TGCVector3(1, 10, 1));
                mesh.AutoTransform = false;
                var ang   = r.Next(0, 360);
                var p     = (mesh.BoundingBox.PMax + mesh.BoundingBox.PMin) * 0.5f;
                var s     = new TGCVector3(((float)r.Next(90, 110)) / 100f, 1, ((float)r.Next(90, 110)) / 100f);
                var rango = 6;
                var t     = new TGCVector3(((float)r.Next(-rango * 100, rango * 100)) / 100f, 0, ((float)r.Next(-rango * 100, rango * 100)) / 100f);
                mesh.Transform = TGCMatrix.Translation(-1 * p) * TGCMatrix.Scaling(s) * TGCMatrix.RotationY(ang) * TGCMatrix.Translation(t + p);
            }
            foreach (var mesh in Scene.Meshes.FindAll(m => m.Name.Contains("Flores")))
            {
                mesh.BoundingBox.scaleTranslate(new TGCVector3(0, 0, 0), new TGCVector3(1, 10, 1));
            }
            ListaPisosResbalosos = Scene.Meshes.FindAll(m => m.Name.Contains("PisoResbaloso"));
            ListaMeshesSinColision.Add(Scene.Meshes.Find(m => m.Name.Contains("ParedEnvolvente001233")));
            ListaMeshesSinColision.Add(Scene.Meshes.Find(m => m.Name.Contains("ParedEnvolvente001248")));

            // Cajas Empujables

            /*TgcMesh MeshEmpujable = Scene.Meshes.Find(m => m.Name.Contains("Caja3"));
             * Scene.Meshes.Remove(Scene.Meshes.Find(m => m.Name.Contains("Caja3")));
             * TGCVector3 PosicionMeshEmpujable = MeshEmpujable.Position;
             * CajaEmpujable CajaEmpujable = new CajaEmpujable(MeshEmpujable, new TGCVector3(0f, 0f, 0f));
             * ListaCajasEmpujables.Add(CajaEmpujable);*/
            foreach (var mesh in Scene.Meshes.FindAll(m => m.Name.Contains("Caja3")))
            {
                Scene.Meshes.Remove(mesh);
                TGCVector3    PosicionMeshEmpujable = mesh.Position;
                CajaEmpujable CajaEmpujable         = new CajaEmpujable(mesh, new TGCVector3(0f, 0f, 0f));
                ListaCajasEmpujables.Add(CajaEmpujable);
            }

            // Setear cancion
            cancionPcpal.FileName = Env.MediaDir + "\\Sound\\crash.mp3";

            // Setear plataformas
            Plataformas = new List <Plataforma>();
            List <TgcMesh> ListaPlataformaEstatica = new List <TgcMesh>();
            List <TgcMesh> ListaPlataformaX        = new List <TgcMesh>();
            // TgcMesh PlataformaY;
            List <TgcMesh> ListaPlataformaZ = new List <TgcMesh>();
            List <TgcMesh> ListaMovibles    = new List <TgcMesh>();
            List <TgcMesh> Escalones        = new List <TgcMesh>();

            ListaPlataformaEstatica = Scene.Meshes.FindAll(m => m.Name.Contains("Box_0"));
            ListaPlataformaX        = Scene.Meshes.FindAll(m => m.Name.Contains("Box_1"));
            ListaPlataformaZ        = Scene.Meshes.FindAll(m => m.Name.Contains("Box_2"));
            PlataformaY             = Scene.Meshes.Find(Mesh => Mesh.Name.Contains("SubeBaja"));
            ListaMovibles           = Scene.Meshes.FindAll(m => m.Name.Contains("Box_M"));
            Escalones = Scene.Meshes.FindAll(m => m.Name.Contains("Escalon"));

            //agrego plataforma que se mueven en X
            foreach (var p in ListaPlataformaX)
            {
                Plataformas.Add(new PlataformaLineal(p, new TGCVector3(0f, 0f, 0f), 25f, true, false, 12f, false));
            }

            //agrego plataforma que se mueven en Z
            foreach (var p in ListaPlataformaZ)
            {
                //-20f es para que este centrado en el camino
                if (p.Name == "Box_202" || p.Name == "Box_204")
                {
                    Plataformas.Add(new PlataformaLineal(p, new TGCVector3(0f, 0f, -20f), 25f, false, false, 12f, true));
                }
                else
                {
                    Plataformas.Add(new PlataformaLineal(p, new TGCVector3(0f, 0f, -20f), 25f, false, false, 12f, false));
                }
            }

            Plataformas.Add(new PlataformaLineal(PlataformaY, new TGCVector3(0f, -90f, 0f), 90f, false, true, 15f, true));

            //agrego objetos moviles
            foreach (var p in ListaMovibles)
            {
                Plataformas.Add(new PlataformaLineal(p, new TGCVector3(0f, 0f, 0f), 0f, false, false, 0f, false));
            }

            //agrego objetos estaticos
            foreach (var p in ListaPlataformaEstatica)
            {
                Plataformas.Add(new PlataformaLineal(p, new TGCVector3(0f, 0f, 0f), 0f, false, false, 0f, false));
            }

            //se agregan plataformas giratorias
            var meshGiratorio = Plataformas[0].Mesh.clone("pGira");

            Plataformas.Add(new PlataformaGiratoria(15, meshGiratorio, new TGCVector3(260f, 0f, 275f), 5f));
            Scene.Meshes.Add(meshGiratorio);
            var meshGiratorio2 = ListaPlataformaZ[4].clone("pGira2");

            Plataformas.Add(new PlataformaGiratoria(28, meshGiratorio2, new TGCVector3(75f, 0f, -20f), 5f));
            Scene.Meshes.Add(meshGiratorio2);
            var meshGiratorio3 = ListaPlataformaZ[4].clone("pGira3");

            Plataformas.Add(new PlataformaGiratoria(28, meshGiratorio3, new TGCVector3(-135f, 0f, 575f), 5f));
            Scene.Meshes.Add(meshGiratorio3);

            foreach (var plataforma in Plataformas)
            {
                ListaPlataformas.Add(plataforma.Mesh);
                MeshConMovimiento.Add(plataforma.Mesh);
                Scene.Meshes.Remove(plataforma.Mesh);
            }
            //agrego escalones


            foreach (var escalon in Escalones)
            {
                ListaEscalones.Add(escalon);
            }

            Grilla.create(Scene.Meshes.FindAll(m => !m.Name.Contains("Box")), Scene.BoundingBox);
            Grilla.createDebugMeshes();
        }
        public override void Init(GameModel _env)
        {
            Env = _env;
            string compilationErrors;
            var    d3dDevice = D3DDevice.Instance.Device;

            EfectoRender2D = Microsoft.DirectX.Direct3D.Effect.FromFile(d3dDevice, Env.ShadersDir + "render2D.fx",
                                                                        null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors);
            shadowEffect = TgcShaders.loadEffect(Env.ShadersDir + "ShadowMap.fx");

            skeletalShadowEffect = TgcShaders.loadEffect(Env.ShadersDir + "TgcSkeletalShadowMapMeshShader.fx");
            shadowEffect.SetValue("EPSILON", 0.005f);
            g_LightPos = new TGCVector3(0, 1000, 0);
            g_LightDir = new TGCVector3(0, -1, 0);
            g_LightDir.Normalize();
            if (EfectoRender2D == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }
            EfectoRender2D.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth);
            EfectoRender2D.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight);
            try
            {
                texturaVida = TextureLoader.FromFile(d3dDevice, Env.MediaDir + "\\Menu\\heart.png");
            }
            catch
            {
                throw new Exception(string.Format("Error at loading texture: {0}", Env.MediaDir + "\\Menu\\heart.png"));
            }
            //Crear pisos
            var AlfombraTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, Env.MediaDir + "carpet.jpg");
            var PiedraTexture   = TgcTexture.createTexture(D3DDevice.Instance.Device, Env.MediaDir + "piedra.jpg");

            base.Init(Env);
            Env.Personaje.Mesh.updateBoundingBox();
            var aabb = Env.Personaje.Mesh.BoundingBox;

            capsulePJ = BulletRigidBodyConstructor.CreateCapsule((aabb.PMax.X - aabb.PMin.X) / 2, (aabb.PMax.Y - aabb.PMin.Y) / 2, new TGCVector3(0, 0, 0));
            capsulePJ.CollisionFlags = CollisionFlags.CharacterObject | capsulePJ.CollisionFlags;
            dynamicsWorld.AddRigidBody(capsulePJ);
            boxes   = new List <Tuple <TGCBox, RigidBody> >();
            Paredes = new List <Tuple <TGCBox, RigidBody> >();
            var RoomSize   = 500f;
            var RoomHeight = 500f;

            //piso
            Paredes.Add(addBox(new TGCVector3(0f, -1f, 0f), new TGCVector3(RoomSize, 1, RoomSize), AlfombraTexture));

            //paredes
            Paredes.Add(addBox(new TGCVector3(0f, -1f, RoomSize / 2), new TGCVector3(RoomSize, RoomHeight, 1), PiedraTexture));
            Paredes.Add(addBox(new TGCVector3(0f, -1f, -RoomSize / 2), new TGCVector3(RoomSize, RoomHeight, 1), PiedraTexture));
            Paredes.Add(addBox(new TGCVector3(-RoomSize / 2, -1f, 0f), new TGCVector3(1, RoomHeight, RoomSize), PiedraTexture));
            Paredes.Add(addBox(new TGCVector3(RoomSize / 2, -1f, 0f), new TGCVector3(1, RoomHeight, RoomSize), PiedraTexture));
            Paredes.Add(addBox(new TGCVector3(0f, RoomHeight, RoomSize / 2), new TGCVector3(RoomSize, RoomHeight, 1), PiedraTexture));
            Paredes.Add(addBox(new TGCVector3(0f, RoomHeight, -RoomSize / 2), new TGCVector3(RoomSize, RoomHeight, 1), PiedraTexture));
            Paredes.Add(addBox(new TGCVector3(-RoomSize / 2, RoomHeight, 0f), new TGCVector3(1, RoomHeight, RoomSize), PiedraTexture));
            Paredes.Add(addBox(new TGCVector3(RoomSize / 2, RoomHeight, 0f), new TGCVector3(1, RoomHeight, RoomSize), PiedraTexture));

            // Sobrepisos
            Paredes.Add(addBox(new TGCVector3(0f, 3f, 75f / 2f + (200 + 25f / 2f) / 2), new TGCVector3(500, 2, 200 + 25f / 2f), AlfombraTexture));
            Paredes.Add(addBox(new TGCVector3(0f, 3f, -(75f / 2f) - (200 + 25f / 2f) / 2), new TGCVector3(500, 2, 200 + 25f / 2f), AlfombraTexture));
            Paredes.Add(addBox(new TGCVector3(-250f + 75f / 2f, 3f, 0), new TGCVector3(75, 2, 75f), AlfombraTexture));

            // Arrastrable/Movible
            addBox(new TGCVector3(-50f, 75f / 2f, 0f), new TGCVector3(75, 75, 75), PiedraTexture, 100);

            //Escalones primera pared
            addBox(new TGCVector3(217f, 130f, 100f), new TGCVector3(75, 75, 75), PiedraTexture);
            addBox(new TGCVector3(217f, 210f, 180f), new TGCVector3(75, 75, 75), PiedraTexture);

            // Plataformas Giratorias
            addSpinningPlatform(new TGCVector3(0f, 225f, 0f), new TGCVector3(100, 50, 100), PiedraTexture, 100000000000f);
            addSpinningPlatform(new TGCVector3(0f, 610f, 0f), new TGCVector3(60, 30, 60), PiedraTexture, 100000000000f);
            addSpinningPlatform(new TGCVector3(0f, 660f, 0f), new TGCVector3(50, 25, 50), PiedraTexture, 100000000000f);

            // Escalones segunda pared
            addBox(new TGCVector3(-217f, 210f, 180f), new TGCVector3(75, 75, 75), PiedraTexture);
            addBox(new TGCVector3(-217f, 320f, 80f), new TGCVector3(75, 75, 75), PiedraTexture);
            addBox(new TGCVector3(-217f, 430f, -20f), new TGCVector3(75, 75, 75), PiedraTexture);
            addBox(new TGCVector3(-217f, 540f, -110f), new TGCVector3(75, 75, 75), PiedraTexture);

            Reset();
            dynamicsWorld.SetInternalTickCallback((DynamicsWorld world, float timeStep) =>
            {
                for (int i = 0; i < world.Dispatcher.NumManifolds; i++)
                {
                    var manifold = world.Dispatcher.GetManifoldByIndexInternal(i);
                    PlataformaGiratoriaBullet giratoria = null;
                    if (manifold.Body0 == capsulePJ)
                    {
                        giratoria = giratorias.Find(g => g.Body == manifold.Body1);
                    }
                    else if (manifold.Body1 == capsulePJ)
                    {
                        giratoria = giratorias.Find(g => g.Body == manifold.Body0);
                    }
                    if (giratoria != null)
                    {
                        Vector3 pmax, pmin, aux;
                        giratoria.Body.CollisionShape.GetAabb(giratoria.Body.WorldTransform, out aux, out pmax);
                        capsulePJ.CollisionShape.GetAabb(capsulePJ.WorldTransform, out pmin, out aux);
                        if (pmin.Y >= pmax.Y - 1)
                        {
                            var t     = capsulePJ.CenterOfMassTransform;
                            t.Origin += giratoria.Delta;
                            capsulePJ.CenterOfMassTransform = t;
                        }
                    }
                }
            }
                                                  );
        }