Exemple #1
0
        public override void Init()
        {
            var loader        = new TgcSceneLoader();
            var sceneOriginal = loader.loadSceneFromFile(MediaDir + "ModelosTgc\\Box\\" +
                                                         "Box-TgcScene.xml");
            var meshOriginal = sceneOriginal.Meshes[0];

            var meshInstance1 = new TgcMesh(meshOriginal.Name + "-1", meshOriginal,
                                            new Vector3(50, 0, 0), meshOriginal.Rotation, meshOriginal.Scale);

            meshInstance1.Enabled = true;

            var meshInstance2 = new TgcMesh(meshOriginal.Name + "-2", meshOriginal,
                                            new Vector3(100, 0, 0), meshOriginal.Rotation, meshOriginal.Scale);

            meshInstance2.Enabled = true;

            meshes = new List <TgcMesh>();
            meshes.Add(meshOriginal);
            meshes.Add(meshInstance1);
            meshes.Add(meshInstance2);

            var texture = TgcTexture.createTexture(D3DDevice.Instance.Device,
                                                   MediaDir + "ModelosTgc\\Piso\\Textures\\piso2.jpg");

            meshOriginal.changeDiffuseMaps(new[] { texture });

            Camara = new TgcFpsCamera();
        }
Exemple #2
0
        public override void Init()
        {
            D3DDevice.Instance.Device.RenderState.AlphaFunction    = Compare.Greater;
            D3DDevice.Instance.Device.RenderState.BlendOperation   = BlendOperation.Add;
            D3DDevice.Instance.Device.RenderState.SourceBlend      = Blend.SourceAlpha;
            D3DDevice.Instance.Device.RenderState.DestinationBlend = Blend.InvSourceAlpha;

            var texture = TgcTexture.createTexture(D3DDevice.Instance.Device,
                                                   MediaDir + "ModelosTgc\\BoxAlpha\\Textures\\pruebaAlpha.png");

            mesh1 = new TgcPlaneWall(new Vector3(0, 0, -50), new Vector3(50, 50, 50), TgcPlaneWall.Orientations.XYplane,
                                     texture);
            mesh1.AutoAdjustUv = false;
            mesh1.UTile        = 1;
            mesh1.VTile        = 1;
            mesh1.updateValues();

            mesh2 = new TgcPlaneWall(new Vector3(0, 0, 50), new Vector3(50, 50, 50), TgcPlaneWall.Orientations.XYplane,
                                     texture);
            mesh2.AutoAdjustUv = false;
            mesh2.UTile        = 1;
            mesh2.VTile        = 1;
            mesh2.updateValues();

            Camara = new TgcFpsCamera(new Vector3(50.0f, 50.0f, 150.0f));

            Modifiers.addBoolean("invertRender", "Invert Render", false);
        }
        public override void Init()
        {
            //Crear SkyBox
            skyBox        = new TgcSkyBox();
            skyBox.Center = new Vector3(0, 0, 0);
            skyBox.Size   = new Vector3(10000, 10000, 10000);

            //Configurar color
            //skyBox.Color = Color.OrangeRed;

            var texturesPath = MediaDir + "Texturas\\Quake\\SkyBox1\\";

            //Configurar las texturas para cada una de las 6 caras
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Up, texturesPath + "phobos_up.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Down, texturesPath + "phobos_dn.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Left, texturesPath + "phobos_lf.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Right, texturesPath + "phobos_rt.jpg");

            //Hay veces es necesario invertir las texturas Front y Back si se pasa de un sistema RightHanded a uno LeftHanded
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Front, texturesPath + "phobos_bk.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Back, texturesPath + "phobos_ft.jpg");
            skyBox.SkyEpsilon = 25f;
            //Inicializa todos los valores para crear el SkyBox
            skyBox.InitSkyBox();

            //Modifier para ver BoundingBox
            Modifiers.addBoolean("moveWhitCamera", "Move Whit Camera", false);

            Camara = new TgcFpsCamera();
        }
        public override void Init()
        {
            //Cargar escenario
            var loader = new TgcSceneLoader();

            scene = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");

            //Camara en 1ra persona
            Camara = new TgcFpsCamera(new Vector3(-20, 80, 450), 400f, 300f);

            //Mesh para la luz
            lightMesh = TgcBox.fromSize(new Vector3(10, 10, 10), Color.Red);

            //Modifiers de la luz
            Modifiers.addBoolean("lightEnable", "lightEnable", true);
            Modifiers.addVertex3f("lightPos", new Vector3(-200, -100, -200),
                                  new Vector3(200, 200, 300), new Vector3(60, 35, 250));
            Modifiers.addColor("lightColor", Color.White);
            Modifiers.addFloat("lightIntensity", 0, 150, 20);
            Modifiers.addFloat("lightAttenuation", 0.1f, 2, 0.3f);
            Modifiers.addFloat("specularEx", 0, 20, 9f);

            //Modifiers de material
            Modifiers.addColor("mEmissive", Color.Black);
            Modifiers.addColor("mAmbient", Color.White);
            Modifiers.addColor("mDiffuse", Color.White);
            Modifiers.addColor("mSpecular", Color.White);
        }
        public override void Init()
        {
            var sphere = MediaDir + "ModelosTgc\\Sphere\\Sphere-TgcScene.xml";

            var loader = new TgcSceneLoader();

            //Cargar modelos para el sol, la tierra y la luna. Son esfereas a las cuales le cambiamos la textura
            sun = loader.loadSceneFromFile(sphere).Meshes[0];
            sun.changeDiffuseMaps(new[]
            {
                TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "SistemaSolar\\SunTexture.jpg")
            });

            earth = loader.loadSceneFromFile(sphere).Meshes[0];
            earth.changeDiffuseMaps(new[]
            {
                TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "SistemaSolar\\EarthTexture.jpg")
            });

            moon = loader.loadSceneFromFile(sphere).Meshes[0];
            moon.changeDiffuseMaps(new[]
            {
                TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "SistemaSolar\\MoonTexture.jpg")
            });

            //Deshabilitamos el manejo automático de Transformaciones de TgcMesh, para poder manipularlas en forma customizada
            sun.AutoTransformEnable   = false;
            earth.AutoTransformEnable = false;
            moon.AutoTransformEnable  = false;

            //Camara en primera persona
            Camara = new TgcFpsCamera(new Vector3(705.2938f, 305.347f, -888.1567f));
        }
        public override void Init()
        {
            //Path de Heightmap default del terreno y Modifier para cambiarla
            currentHeightmap = MediaDir + "Heighmaps\\" + "Heightmap1.jpg";
            Modifiers.addTexture("heightmap", currentHeightmap);

            //Modifiers para variar escala del mapa
            currentScaleXZ = 20f;
            Modifiers.addFloat("scaleXZ", 0.1f, 100f, currentScaleXZ);
            currentScaleY = 1.3f;
            Modifiers.addFloat("scaleY", 0.1f, 10f, currentScaleY);
            createHeightMapMesh(D3DDevice.Instance.Device, currentHeightmap, currentScaleXZ, currentScaleY);

            //Path de Textura default del terreno y Modifier para cambiarla
            currentTexture = MediaDir + "Heighmaps\\" + "TerrainTexture1-256x256.jpg";
            Modifiers.addTexture("texture", currentTexture);
            loadTerrainTexture(D3DDevice.Instance.Device, currentTexture);

            //Configurar FPS Camara
            Camara = new TgcFpsCamera(new Vector3(-24.9069f, 386.3114f, 673.7542f), 100f, 100f);

            //UserVars para cantidad de vertices
            UserVars.addVar("Vertices", totalVertices);
            UserVars.addVar("Triangles", totalVertices / 3);
        }
        public override void Init()
        {
            //Crear SkyBox
            skyBox = new TgcSkyBox();
            skyBox.Center = new TGCVector3(0, 500, 0);
            skyBox.Size = new TGCVector3(10000, 10000, 10000);
            var texturesPath = MediaDir + "Texturas\\Quake\\SkyBox LostAtSeaDay\\";
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Up, texturesPath + "lostatseaday_up.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Down, texturesPath + "lostatseaday_dn.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Left, texturesPath + "lostatseaday_lf.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Right, texturesPath + "lostatseaday_rt.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Front, texturesPath + "lostatseaday_bk.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Back, texturesPath + "lostatseaday_ft.jpg");
            skyBox.Init();

            //Cargar escenario de Isla
            var loader = new TgcSceneLoader();
            var scene = loader.loadSceneFromFile(MediaDir + "Isla\\Isla-TgcScene.xml");

            //Separar el Terreno del resto de los objetos
            var list1 = new List<TgcMesh>();
            scene.separeteMeshList(new[] { "Terreno" }, out list1, out objetosIsla);
            terreno = list1[0];

            //Crear grilla
            grilla = new GrillaRegular();
            grilla.create(objetosIsla, scene.BoundingBox);
            grilla.createDebugMeshes();

            //Camara en 1ra persona
            Camara = new TgcFpsCamera(new TGCVector3(1500, 800, 0), Input);

            showGridModifier = AddBoolean("showGrid", "Show Grid", false);
            showTerrainModifier = AddBoolean("showTerrain", "Show Terrain", true);
        }
Exemple #8
0
        public override void Init()
        {
            //FPS Camara
            Camara = new TgcFpsCamera(new Vector3(-140f, 40f, -50f), 200f, 200f);

            //Cargar escena desde archivo ZIP
            var loader = new TgcSceneLoader();

            tgcScene = loader.loadSceneFromZipFile("4toPiso-TgcScene.xml", MediaDir + "4toPiso\\4toPiso.zip",
                                                   MediaDir + "4toPiso\\Extract\\");

            /*
             * //Version para cargar escena desde carpeta descomprimida
             * TgcSceneLoader loader = new TgcSceneLoader();
             * tgcScene = loader.loadSceneFromFile(
             *  this.MediaDir + "4toPiso\\Extract\\4toPiso-TgcScene.xml",
             *  this.MediaDir + "4toPiso\\Extract\\");
             */

            //Modifier para habilitar o deshabilitar FrustumCulling
            Modifiers.addBoolean("culling", "Frustum culling", true);

            //UserVar para contar la cantidad de meshes que se renderizan
            UserVars.addVar("Meshes renderizadas");
        }
Exemple #9
0
        public override void Init()
        {
            //Cargar escenario
            var loader = new TgcSceneLoader();

            //Configurar MeshFactory customizado
            scene = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");

            //Camara en 1ra persona
            Camera = new TgcFpsCamera(new TGCVector3(200, 250, 175), 400f, 300f, Input);

            //Mesh para la luz
            lightMesh = TGCBox.fromSize(new TGCVector3(10, 10, 10), Color.Red);

            //Modifiers de la luz
            lightEnableModifier      = AddBoolean("lightEnable", "lightEnable", true);
            lightPosModifier         = AddVertex3f("lightPos", new TGCVector3(-200, -100, -200), new TGCVector3(200, 200, 300), new TGCVector3(-60, 90, 175));
            lightDirModifier         = AddVertex3f("lightDir", new TGCVector3(-1, -1, -1), TGCVector3.One, new TGCVector3(-0.05f, 0, 0));
            lightColorModifier       = AddColor("lightColor", Color.White);
            lightIntensityModifier   = AddFloat("lightIntensity", 0, 150, 35);
            lightAttenuationModifier = AddFloat("lightAttenuation", 0.1f, 2, 0.3f);
            specularExModifier       = AddFloat("specularEx", 0, 20, 9f);
            spotAngleModifier        = AddFloat("spotAngle", 0, 180, 39f);
            spotExponentModifier     = AddFloat("spotExponent", 0, 20, 7f);

            //Modifiers de material
            mEmissiveModifier = AddColor("mEmissive", Color.Black);
            mAmbientModifier  = AddColor("mAmbient", Color.White);
            mDiffuseModifier  = AddColor("mDiffuse", Color.White);
            mSpecularModifier = AddColor("mSpecular", Color.White);
        }
        public override void Init()
        {
            var d3dDevice = D3DDevice.Instance.Device;

            var loader = new TgcSceneLoader();
            var scene  = loader.loadSceneFromFile(MediaDir + "ModelosTgc\\Box\\" + "Box-TgcScene.xml",
                                                  MediaDir + "ModelosTgc\\Box\\");

            mesh       = scene.Meshes[0];
            mesh.Scale = new Vector3(0.25f, 0.25f, 0.25f);

            Camara = new TgcFpsCamera(new Vector3(7.9711f, 11.7f, -32.5475f));

            Modifiers.addVertex3f("origin", new Vector3(-100, -100, -100), new Vector3(100, 100, 100),
                                  new Vector3(0, 0, 0));
            Modifiers.addVertex3f("dimension", new Vector3(-100, -100, -100), new Vector3(1000, 1000, 100),
                                  new Vector3(10, 10, 10));
            Modifiers.addInterval("orientation", new[] { "XY", "XZ", "YZ" }, 0);
            Modifiers.addVertex2f("tiling", new Vector2(0, 0), new Vector2(10, 10), new Vector2(1, 1));

            var texturePath = MediaDir + "Texturas\\Quake\\TexturePack2\\brick1_1.jpg";

            currentTexture = TgcTexture.createTexture(d3dDevice, texturePath);
            Modifiers.addTexture("texture", currentTexture.FilePath);

            updateWall();
        }
        public override void Init()
        {
            //Cargar shader de este ejemplo
            effect = TgcShaders.loadEffect(ShadersDir + "EjemploGetZBuffer.fx");

            //Cargamos un escenario
            var loader = new TgcSceneLoader();
            var scene  = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");

            meshes = scene.Meshes;
            foreach (var mesh in meshes)
            {
                mesh.Effect = effect;
            }

            //Crear textura para almacenar el zBuffer. Es una textura que se usa como RenderTarget y que tiene un formato de 1 solo float de 32 bits.
            //En cada pixel no vamos a guardar un color sino el valor de Z de la escena
            //La creamos con un solo nivel de mipmap (el original)
            zBufferTexture = new Texture(D3DDevice.Instance.Device, D3DDevice.Instance.Device.Viewport.Width,
                                         D3DDevice.Instance.Device.Viewport.Height, 1,
                                         Usage.RenderTarget, Format.R32F, Pool.Default);

            //Camara en 1ra persona
            Camara = new TgcFpsCamera(new Vector3(-20, 80, 450), 400f, 300f);
        }
Exemple #12
0
        public override void Init()
        {
            //Path de Heightmap default del terreno y Modifier para cambiarla
            currentHeightmap  = MediaDir + "Heighmaps\\" + "Heightmap3.jpg";
            heightmapModifier = AddTexture("heightmap", currentHeightmap);

            //Modifiers para variar escala del mapa
            currentScaleXZ  = 50f;
            scaleXZModifier = AddFloat("scaleXZ", 0.1f, 100f, currentScaleXZ);
            currentScaleY   = 1.5f;
            scaleYModifier  = AddFloat("scaleY", 0.1f, 10f, currentScaleY);
            createHeightMapMesh(D3DDevice.Instance.Device, currentHeightmap, currentScaleXZ, currentScaleY);

            //Path de Textura default del terreno y Modifier para cambiarla
            currentTexture  = MediaDir + "Heighmaps\\" + "TerrainTexture3.jpg";
            textureModifier = AddTexture("texture", currentTexture);
            loadTerrainTexture(D3DDevice.Instance.Device, currentTexture);

            //Configurar FPS Camara
            Camara = new TgcFpsCamera(new TGCVector3(3200f, 450f, 1500f), Input);

            //UserVars para cantidad de vertices
            UserVars.addVar("Vertices", totalVertices);
            UserVars.addVar("Triangles", totalVertices / 3);
        }
Exemple #13
0
        public override void Init()
        {
            time = 0;

            var d3dDevice = D3DDevice.Instance.Device;

            MyShaderDir = ShadersDir + "WorkshopShaders\\";

            //Cargamos un escenario
            var loader = new TgcSceneLoader();
            var scene  = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");

            meshes = scene.Meshes;

            //Cargar Shader personalizado
            string compilationErrors;

            effect = Effect.FromFile(d3dDevice, MyShaderDir + "FullQuad.fx", null, null, ShaderFlags.PreferFlowControl,
                                     null, out compilationErrors);
            if (effect == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }
            //Configurar Technique dentro del shader
            effect.Technique = "DefaultTechnique";

            //Camara en primera persona
            Camara = new TgcFpsCamera(new Vector3(-182.3816f, 82.3252f, -811.9061f));

            g_pDepthStencil = d3dDevice.CreateDepthStencilSurface(d3dDevice.PresentationParameters.BackBufferWidth,
                                                                  d3dDevice.PresentationParameters.BackBufferHeight,
                                                                  DepthFormat.D24S8, MultiSampleType.None, 0, true);

            // inicializo el render target
            g_pRenderTarget = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth
                                          , d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.X8R8G8B8,
                                          Pool.Default);

            effect.SetValue("g_RenderTarget", g_pRenderTarget);

            // Resolucion de pantalla
            effect.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth);
            effect.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight);

            CustomVertex.PositionTextured[] vertices =
            {
                new CustomVertex.PositionTextured(-1,  1, 1, 0, 0),
                new CustomVertex.PositionTextured(1,   1, 1, 1, 0),
                new CustomVertex.PositionTextured(-1, -1, 1, 0, 1),
                new CustomVertex.PositionTextured(1,  -1, 1, 1, 1)
            };
            //vertex buffer de los triangulos
            g_pVBV3D = new VertexBuffer(typeof(CustomVertex.PositionTextured),
                                        4, d3dDevice, Usage.Dynamic | Usage.WriteOnly,
                                        CustomVertex.PositionTextured.Format, Pool.Default);
            g_pVBV3D.SetData(vertices, 0, LockFlags.None);

            Modifiers.addBoolean("activar_efecto", "Activar efecto", true);
        }
Exemple #14
0
        public override void Init()
        {
            //Cargar escenario, pero inicialmente solo hacemos el parser, para separar los objetos que son solo luces y no meshes
            var scenePath = MediaDir + "Escenario\\EscenarioLuces-TgcScene.xml";
            var mediaPath = MediaDir + "Escenario\\";
            var parser    = new TgcSceneParser();
            var sceneData = parser.parseSceneFromString(File.ReadAllText(scenePath));

            //Separar modelos reales de las luces, segun layer "Lights"
            lights = new List <LightData>();
            var realMeshData = new List <TgcMeshData>();

            for (var i = 0; i < sceneData.meshesData.Length; i++)
            {
                var meshData = sceneData.meshesData[i];

                //Es una luz, no cargar mesh, solo importan sus datos
                if (meshData.layerName == "Lights")
                {
                    //Guardar datos de luz
                    var light = new LightData();
                    light.color = Color.FromArgb((int)meshData.color[0], (int)meshData.color[1],
                                                 (int)meshData.color[2]);
                    light.aabb = new TgcBoundingAxisAlignBox(TgcParserUtils.float3ArrayToVector3(meshData.pMin),
                                                             TgcParserUtils.float3ArrayToVector3(meshData.pMax));
                    light.pos = light.aabb.calculateBoxCenter();
                    lights.Add(light);
                }
                //Es un mesh real, agregar a array definitivo
                else
                {
                    realMeshData.Add(meshData);
                }
            }

            //Reemplazar array original de meshData de sceneData por el definitivo
            sceneData.meshesData = realMeshData.ToArray();

            //Ahora si cargar meshes reales
            var loader = new TgcSceneLoader();

            scene = loader.loadScene(sceneData, mediaPath);

            //Camara en 1ra persona
            Camara = new TgcFpsCamera(new Vector3(-20, 80, 450), 400f, 300f, Input);

            //Modifiers para variables de luz
            Modifiers.addBoolean("lightEnable", "lightEnable", true);
            Modifiers.addFloat("lightIntensity", 0, 150, 20);
            Modifiers.addFloat("lightAttenuation", 0.1f, 2, 0.3f);
            Modifiers.addFloat("specularEx", 0, 20, 9f);

            //Modifiers para material
            Modifiers.addColor("mEmissive", Color.Black);
            Modifiers.addColor("mAmbient", Color.White);
            Modifiers.addColor("mDiffuse", Color.White);
            Modifiers.addColor("mSpecular", Color.White);
        }
Exemple #15
0
        public override void Init()
        {
            //Se crean 2 triangulos (o Quad) con las dimensiones de la pantalla con sus posiciones ya transformadas
            // x = -1 es el extremo izquiedo de la pantalla, x = 1 es el extremo derecho
            // Lo mismo para la Y con arriba y abajo
            // la Z en 1 simpre
            CustomVertex.PositionTextured[] screenQuadVertices =
            {
                new CustomVertex.PositionTextured(-1,  1, 1, 0, 0),
                new CustomVertex.PositionTextured(1,   1, 1, 1, 0),
                new CustomVertex.PositionTextured(-1, -1, 1, 0, 1),
                new CustomVertex.PositionTextured(1,  -1, 1, 1, 1)
            };
            //vertex buffer de los triangulos
            screenQuadVB = new VertexBuffer(typeof(CustomVertex.PositionTextured), 4, D3DDevice.Instance.Device, Usage.Dynamic | Usage.WriteOnly,
                                            CustomVertex.PositionTextured.Format, Pool.Default);
            screenQuadVB.SetData(screenQuadVertices, 0, LockFlags.None);

            //Creamos un Render Targer sobre el cual se va a dibujar la pantalla
            renderTarget2D = new Texture(D3DDevice.Instance.Device, D3DDevice.Instance.Device.PresentationParameters.BackBufferWidth,
                                         D3DDevice.Instance.Device.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);

            //Creamos un DepthStencil que debe ser compatible con nuestra definicion de renderTarget2D.
            depthStencil = D3DDevice.Instance.Device.CreateDepthStencilSurface(D3DDevice.Instance.Device.PresentationParameters.BackBufferWidth,
                                                                               D3DDevice.Instance.Device.PresentationParameters.BackBufferHeight, DepthFormat.D24S8, MultiSampleType.None, 0, true);
            depthStencilOld = D3DDevice.Instance.Device.DepthStencilSurface;
            //Cargar shader con efectos de Post-Procesado
            effect = TGCShaders.Instance.LoadEffect(ShadersDir + "PostProcess.fx");

            //Configurar Technique dentro del shader
            effect.Technique = "AlarmaTechnique";

            //Cargar textura que se va a dibujar arriba de la escena del Render Target
            alarmTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\efecto_alarma.png");

            //Interpolador para efecto de variar la intensidad de la textura de alarma
            intVaivenAlarm       = new InterpoladorVaiven();
            intVaivenAlarm.Min   = 0;
            intVaivenAlarm.Max   = 1;
            intVaivenAlarm.Speed = 5;
            intVaivenAlarm.reset();

            //Cargamos un escenario
            var loader = new TgcSceneLoader();
            var scene  = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");

            meshes = scene.Meshes;

            //Camara en primera persona
            Camera = new TgcFpsCamera(new TGCVector3(250, 160, -570), Input);

            //Modifier para activar/desactivar efecto de alarma
            activarEfectoModifier = AddBoolean("activar_efecto", "Activar efecto", true);

            //Modifier para activar/desactivar stensil para ver como el ejemplo se rompe.
            activarStencilModifier = AddBoolean("activar_stencil", "Activar stensil", true);
        }
        /// <summary>
        /// Crea todos los modulos necesarios de la aplicacion
        /// </summary>
        internal void initGraphics(MainForm mainForm, Control panel3d)
        {
            this.mainForm        = mainForm;
            this.panel3d         = panel3d;
            this.fullScreenPanel = new FullScreenPanel();
            panel3d.Focus();

            //Iniciar graficos
            this.tgcD3dDevice    = new TgcD3dDevice(panel3d);
            this.texturesManager = new TgcTexture.Manager();
            this.tgcD3dDevice.OnResetDevice(tgcD3dDevice.D3dDevice, null);

            //Iniciar otras herramientas
            this.texturesPool      = new TgcTexture.Pool();
            this.logger            = new Logger(mainForm.LogConsole);
            this.text3d            = new TgcDrawText(tgcD3dDevice.D3dDevice);
            this.tgcD3dInput       = new TgcD3dInput(mainForm, panel3d);
            this.fpsCamera         = new TgcFpsCamera();
            this.rotCamera         = new TgcRotationalCamera();
            this.thirdPersonCamera = new TgcThirdPersonCamera();
            this.axisLines         = new TgcAxisLines(tgcD3dDevice.D3dDevice);
            this.userVars          = new TgcUserVars(mainForm.getDataGridUserVars());
            this.modifiers         = new TgcModifiers(mainForm.getModifiersPanel());
            this.elapsedTime       = -1;
            this.frustum           = new TgcFrustum();
            this.mp3Player         = new TgcMp3Player();
            this.directSound       = new TgcDirectSound();
            this.fog                 = new TgcFog();
            this.currentCamera       = this.rotCamera;
            this.customRenderEnabled = false;
            this.drawer2D            = new TgcDrawer2D();
            this.shaders             = new TgcShaders();

            //toogles
            this.rotCamera.Enable         = true;
            this.fpsCamera.Enable         = false;
            this.thirdPersonCamera.Enable = false;
            this.fpsCounterEnable         = true;
            this.axisLines.Enable         = true;

            //Cargar algoritmos
            exampleLoader          = new ExampleLoader();
            examplesDir            = System.Environment.CurrentDirectory + "\\" + ExampleLoader.EXAMPLES_DIR + "\\";
            examplesMediaDir       = examplesDir + "Media" + "\\";
            alumnoEjemplosDir      = System.Environment.CurrentDirectory + "\\" + "AlumnoEjemplos" + "\\";
            alumnoEjemplosMediaDir = alumnoEjemplosDir + "AlumnoMedia" + "\\";
            exampleLoader.loadExamplesInGui(mainForm.TreeViewExamples, new string[] { examplesDir, alumnoEjemplosDir });

            //Cargar shaders del framework
            this.shaders.loadCommonShaders();

            //Cargar ejemplo default
            TgcExample defaultExample = exampleLoader.getExampleByName(mainForm.Config.defaultExampleName, mainForm.Config.defaultExampleCategory);

            executeExample(defaultExample);
        }
Exemple #17
0
        public override void Init()
        {
            time = 0;

            Device d3dDevice = D3DDevice.Instance.Device;

            //Cargamos un escenario
            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene       scene  = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");

            meshes = scene.Meshes;

            //Cargar Shader personalizado
            string compilationErrors;

            effect = Effect.FromFile(d3dDevice, ShadersDir + "WorkshopShaders\\FullQuad.fx", null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors);
            if (effect == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }
            //Configurar Technique dentro del shader
            effect.Technique = "DefaultTechnique";

            //Camara en primera personas
            Camara = new TgcFpsCamera(new TGCVector3(-182.3816f, 82.3252f, -811.9061f), 100, 10, Input);

            g_pDepthStencil = d3dDevice.CreateDepthStencilSurface(d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, DepthFormat.D24S8, MultiSampleType.None, 0, true);

            // inicializo el render target
            g_pRenderTarget = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);

            effect.SetValue("g_RenderTarget", g_pRenderTarget);

            // Resolucion de pantalla
            effect.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth);
            effect.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight);

            CustomVertex.PositionTextured[] vertices = new CustomVertex.PositionTextured[]
            {
                new CustomVertex.PositionTextured(-1, 1, 1, 0, 0),
                new CustomVertex.PositionTextured(1, 1, 1, 1, 0),
                new CustomVertex.PositionTextured(-1, -1, 1, 0, 1),
                new CustomVertex.PositionTextured(1, -1, 1, 1, 1)
            };
            //vertex buffer de los triangulos
            g_pVBV3D = new VertexBuffer(typeof(CustomVertex.PositionTextured), 4, d3dDevice, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default);
            g_pVBV3D.SetData(vertices, 0, LockFlags.None);

            distorcionadorModifier = AddEnum("distorcionador", typeof(Distorciones), Distorciones.Pincushion);
            gridModifier           = AddBoolean("grid", "mostrar grilla", false);
            kuModifier             = AddFloat("Ku", 0, 1, 0.1f);
            kvModifier             = AddFloat("Kv", 0, 1, 0.1f);

            ocScaleInModifier = AddFloat("oc_scale_in", 0.1f, 4, 2.5f);
            ocScaleModifier   = AddFloat("oc_scale", 0.01f, 1f, 0.35f);
        }
        /// <summary>
        ///     Se llama una sola vez, al principio cuando se ejecuta el ejemplo.
        ///     Escribir aquí todo el código de inicialización: cargar modelos, texturas, estructuras de optimización, todo
        ///     procesamiento que podemos pre calcular para nuestro juego.
        ///     Borrar el codigo ejemplo no utilizado.
        /// </summary>
        public override void Init()
        {
            //Device de DirectX para crear primitivas.
            d3dDevice = D3DDevice.Instance.Device;

            //Instancio el loader del framework
            loader = new TgcSceneLoader();

            //creo usuario
            Player1           = new Player();
            Player1.gameModel = this;

            //inicializo mesh para hacha
            Axe = loader.loadSceneFromFile(MediaDir + "Meshes\\Hacha\\Hacha-TgcScene.xml").Meshes[0];

            //Inicializo cámara
            MyCamera = new TgcFpsCamera(Player1, Axe, Input, (MapLength / 2), -(MapLength / 2), (MapLength / 2), -(MapLength / 2));
            Camara   = MyCamera;

            Frustum.updateVolume(D3DDevice.Instance.Device.Transform.View, D3DDevice.Instance.Device.Transform.Projection);

            //genero el mundo
            MyWorld = new World(MediaDir, d3dDevice, loader, Camara, Frustum, MapLength, true);
            MyWorld.RenderDistance = RenderDistance;
            //inicializo efectos
            effectsManager = new EffectsManager(ShadersDir, this, MyWorld, ElapsedTime);

            effectsManager.applyEffect(Axe);

            //emisor de partículas
            emitter                    = new ParticleEmitter(MediaDir + "Textures\\smokeParticle.png", 10);
            emitter.Position           = new Vector3(0, 0, 0);
            emitter.MinSizeParticle    = 2f;
            emitter.MaxSizeParticle    = 5f;
            emitter.ParticleTimeToLive = 1f;
            emitter.CreationFrecuency  = 1f;
            emitter.Dispersion         = 25;
            emitter.Speed              = new Vector3(5f, 5f, 5f);

            //colisiones
            pickingRay = new TgcPickingRay(Input);
            //sonidos
            soundPlayer = new SoundPlayer(DirectSound, MediaDir);
            soundPlayer.startAmbient();
            //gui
            MenuInterface = new GUI(MediaDir, D3DDevice.Instance, Player1, this);

            TopRightText       = GameUtils.createText("", 0, 0, 20, true);
            TopRightText.Color = Color.LightGray;
            TopRightText.Align = TgcText2D.TextAlign.RIGHT;

            CenterText       = GameUtils.createText("", 0, (D3DDevice.Instance.Height * 0.85f), 25, true);
            CenterText.Color = Color.DodgerBlue;
            CenterText.Align = TgcText2D.TextAlign.CENTER;
        }
        public override void Init()
        {
            box1Texture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\pasto.jpg");
            box2Texture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\tierra.jpg");
            box3Texture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\madera.jpg");

            Modifiers.addEnum("Render Method", typeof(RenderMethod), RenderMethod.Unsorted);
            createMeshes(25);

            Camara = new TgcFpsCamera(new Vector3(32.1944f, 42.1327f, -68.7882f));
        }
Exemple #20
0
        public override void Init()
        {
            Device d3dDevice = D3DDevice.Instance.Device;

            //Cargamos un escenario

            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene       scene  = loader.loadSceneFromFile(MediaDir + "\\MeshCreator\\Meshes\\Esqueletos\\EsqueletoHumano3\\Esqueleto3-TgcScene.xml");

            mesh = scene.Meshes[0];

            //Cargar Shader personalizado
            string compilationErrors;

            effect = Effect.FromFile(d3dDevice, ShadersDir + "WorkshopShaders\\GaussianBlur.fx", null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors);
            if (effect == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }
            //Configurar Technique dentro del shader
            effect.Technique = "DefaultTechnique";

            //Camara en primera persona
            Camara = new TgcFpsCamera(new TGCVector3(50, 30, 50), 100, 10, Input);

            g_pDepthStencil = d3dDevice.CreateDepthStencilSurface(d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, DepthFormat.D24S8, MultiSampleType.None, 0, true);

            // inicializo el render target
            g_pRenderTarget = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);
            effect.SetValue("g_RenderTarget", g_pRenderTarget);

            // Blur Factor
            g_pBlurFactor = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);
            effect.SetValue("g_BlurFactor", g_pBlurFactor);

            // Resolucion de pantalla
            effect.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth);
            effect.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight);

            CustomVertex.PositionTextured[] vertices = new CustomVertex.PositionTextured[]
            {
                new CustomVertex.PositionTextured(-1, 1, 1, 0, 0),
                new CustomVertex.PositionTextured(1, 1, 1, 1, 0),
                new CustomVertex.PositionTextured(-1, -1, 1, 0, 1),
                new CustomVertex.PositionTextured(1, -1, 1, 1, 1)
            };
            //vertex buffer de los triangulos
            g_pVBV3D = new VertexBuffer(typeof(CustomVertex.PositionTextured), 4, d3dDevice, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default);
            g_pVBV3D.SetData(vertices, 0, LockFlags.None);

            activarEfectoModifier = AddBoolean("activar_efecto", "Activar efecto", true);
            focusPlaneModifier    = AddFloat("focus_plane", 1, 300, 10);
            blurFactorModifier    = AddFloat("blur_factor", 0.1f, 5f, 0.5f);
        }
Exemple #21
0
        public override void Init()
        {
            var fpsCamara = new TgcFpsCamera(Input);

            fpsCamara.MovementSpeed = 200f;
            fpsCamara.JumpSpeed     = 200f;
            fpsCamara.SetCamera(new TGCVector3(133.0014f, 264.8258f, -119.0311f), new TGCVector3(498.1584f, -299.4199f, 621.433f));
            Camera = fpsCamara;

            //Crear Modifier especial para este editor
            modifier = AddRoomsEditorModifier(this);
        }
Exemple #22
0
        public override void Init()
        {
            //Cargar escenario
            var loader = new TgcSceneLoader();

            scene =
                loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");

            //Camara en 1ra persona
            Camara = new TgcFpsCamera(new Vector3(260f, 170f, 390f), 400f, 300f, Input);

            //Cargar Shader personalizado de MultiDiffuseLights

            /*
             * Cargar Shader personalizado de MultiDiffuseLights
             * Este Shader solo soporta TgcMesh con RenderType DIFFUSE_MAP (que son las unicas utilizadas en este ejemplo)
             * El shader toma 4 luces a la vez para iluminar un mesh.
             * Pero como hacer 4 veces los calculos en el shader es costoso, de cada luz solo calcula el componente Diffuse.
             */
            effect = TgcShaders.loadEffect(ShadersDir + "MultiDiffuseLights.fx");

            //Crear 4 mesh para representar las 4 para la luces. Las ubicamos en distintas posiciones del escenario, cada una con un color distinto.
            lightMeshes  = new TgcBox[4];
            origLightPos = new Vector3[lightMeshes.Length];
            var c = new Color[4] {
                Color.Red, Color.Blue, Color.Green, Color.Yellow
            };

            for (var i = 0; i < lightMeshes.Length; i++)
            {
                var co = c[i % c.Length];
                lightMeshes[i] = TgcBox.fromSize(new Vector3(10, 10, 10), co);
                lightMeshes[i].AutoTransformEnable = true;
                origLightPos[i] = new Vector3(-40, 20 + i * 20, 400);
            }

            //Modifiers
            Modifiers.addBoolean("lightEnable", "lightEnable", true);
            Modifiers.addBoolean("lightMove", "lightMove", true);
            Modifiers.addFloat("lightIntensity", 0, 150, 38);
            Modifiers.addFloat("lightAttenuation", 0.1f, 2, 0.15f);

            Modifiers.addColor("mEmissive", Color.Black);
            Modifiers.addColor("mDiffuse", Color.White);

            //Interpolador para mover las luces de un lado para el otro
            interp         = new InterpoladorVaiven();
            interp.Min     = -200f;
            interp.Max     = 200f;
            interp.Speed   = 100f;
            interp.Current = 0f;
        }
Exemple #23
0
        public override void Init()
        {
            //Se crean 2 triangulos (o Quad) con las dimensiones de la pantalla con sus posiciones ya transformadas
            // x = -1 es el extremo izquiedo de la pantalla, x = 1 es el extremo derecho
            // Lo mismo para la Y con arriba y abajo
            // la Z en 1 simpre
            CustomVertex.PositionTextured[] screenQuadVertices =
            {
                new CustomVertex.PositionTextured(-1,  1, 1, 0, 0),
                new CustomVertex.PositionTextured(1,   1, 1, 1, 0),
                new CustomVertex.PositionTextured(-1, -1, 1, 0, 1),
                new CustomVertex.PositionTextured(1,  -1, 1, 1, 1)
            };
            //vertex buffer de los triangulos
            screenQuadVB = new VertexBuffer(typeof(CustomVertex.PositionTextured),
                                            4, D3DDevice.Instance.Device, Usage.Dynamic | Usage.WriteOnly,
                                            CustomVertex.PositionTextured.Format, Pool.Default);
            screenQuadVB.SetData(screenQuadVertices, 0, LockFlags.None);

            //Creamos un Render Targer sobre el cual se va a dibujar la pantalla
            renderTarget2D = new Texture(D3DDevice.Instance.Device,
                                         D3DDevice.Instance.Device.PresentationParameters.BackBufferWidth
                                         , D3DDevice.Instance.Device.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget,
                                         Format.X8R8G8B8, Pool.Default);

            //Creamos un DepthStencil que debe ser compatible con nuestra definicion de renderTarget2D.
            depthStencil =
                D3DDevice.Instance.Device.CreateDepthStencilSurface(
                    D3DDevice.Instance.Device.PresentationParameters.BackBufferWidth,
                    D3DDevice.Instance.Device.PresentationParameters.BackBufferHeight,
                    DepthFormat.D24S8, MultiSampleType.None, 0, true);

            //Cargar shader con efectos de Post-Procesado
            effect = TgcShaders.loadEffect(ShadersDir + "PostProcess.fx");

            //Configurar Technique dentro del shader
            effect.Technique = "OndasTechnique";

            //Cargamos un escenario
            var loader = new TgcSceneLoader();
            var scene  = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");

            meshes = scene.Meshes;

            //Camara en primera personas
            Camara = new TgcFpsCamera(new Vector3(250, 160, -570), Input);

            //Modifier para variar tamano de ondas
            Modifiers.addBoolean("activar_efecto", "Activar efecto", true);
            Modifiers.addFloat("wave_length", 0, 300, 200);
            Modifiers.addFloat("wave_size", 0.01f, 1, 0.01f);
        }
        public override void Init()
        {
            //Crear suelo
            var pisoTexture = TgcTexture.createTexture(D3DDevice.Instance.Device,
                                                       MediaDir + "Texturas\\Quake\\TexturePack2\\rock_floor1.jpg");

            suelo = TgcBox.fromSize(new Vector3(500, 0, 500), new Vector3(2000, 0, 2000), pisoTexture);

            //Cargar malla original
            var loader    = new TgcSkeletalLoader();
            var pathMesh  = MediaDir + "SkeletalAnimations\\Robot\\Robot-TgcSkeletalMesh.xml";
            var mediaPath = MediaDir + "SkeletalAnimations\\Robot\\";

            original = loader.loadMeshFromFile(pathMesh, mediaPath);

            //Agregar animación a original
            loader.loadAnimationFromFile(original, mediaPath + "Patear-TgcSkeletalAnim.xml");

            //Agregar attachment a original
            var attachment    = new TgcSkeletalBoneAttach();
            var attachmentBox = TgcBox.fromSize(new Vector3(3, 60, 3), Color.Green);

            attachment.Mesh   = attachmentBox.toMesh("attachment");
            attachment.Bone   = original.getBoneByName("Bip01 L Hand");
            attachment.Offset = Matrix.Translation(10, -40, 0);
            attachment.updateValues();
            original.Attachments.Add(attachment);

            //Crear 9 instancias mas de este modelo, pero sin volver a cargar el modelo entero cada vez
            float offset         = 200;
            var   cantInstancias = 4;

            instances = new List <TgcSkeletalMesh>();
            for (var i = 0; i < cantInstancias; i++)
            {
                var instance = original.createMeshInstance(original.Name + i);

                instance.move(i * offset, 0, 0);
                instances.Add(instance);
            }

            //Especificar la animación actual para todos los modelos
            original.playAnimation("Patear");
            foreach (var instance in instances)
            {
                instance.playAnimation("Patear");
            }

            //Camara en primera persona
            Camara = new TgcFpsCamera(new Vector3(293.201f, 291.0797f, -604.6647f));
        }
        public override void Init()
        {
            //Cargar escenario
            var loader = new TgcSceneLoader();

            scene = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");

            //Cargar mesh con animaciones
            var skeletalLoader = new TgcSkeletalLoader();

            skeletalMesh =
                skeletalLoader.loadMeshAndAnimationsFromFile(
                    MediaDir + "SkeletalAnimations\\Robot\\Robot-TgcSkeletalMesh.xml",
                    new[] { MediaDir + "SkeletalAnimations\\Robot\\Parado-TgcSkeletalAnim.xml" });

            //Configurar animacion inicial
            skeletalMesh.playAnimation("Parado", true);

            //Corregir normales
            skeletalMesh.computeNormals();

            //Pongo al mesh en posicion, activo e AutoTransform
            skeletalMesh.AutoTransformEnable = true;
            skeletalMesh.Position            = new Vector3(0, 0, 100);
            skeletalMesh.rotateY(FastMath.PI);

            //Camara en 1ra persona
            Camara = new TgcFpsCamera(new Vector3(250, 140, 150), Input);

            //Mesh para la luz
            lightMesh = TgcBox.fromSize(new Vector3(10, 10, 10));

            //Pongo al mesh en posicion, activo e AutoTransform
            lightMesh.AutoTransformEnable = true;
            lightMesh.Position            = new Vector3(0, 150, 150);

            //Modifiers de la luz
            Modifiers.addBoolean("lightEnable", "lightEnable", lightMesh.Enabled);
            Modifiers.addVertex3f("lightPos", new Vector3(-200, -100, -200), new Vector3(200, 200, 300),
                                  lightMesh.Position);
            Modifiers.addColor("lightColor", lightMesh.Color);
            Modifiers.addFloat("lightIntensity", 0, 150, 20);
            Modifiers.addFloat("lightAttenuation", 0.1f, 2, 0.3f);
            Modifiers.addFloat("specularEx", 0, 20, 9f);

            //Modifiers de material
            Modifiers.addColor("mEmissive", Color.Black);
            Modifiers.addColor("mAmbient", Color.White);
            Modifiers.addColor("mDiffuse", Color.White);
            Modifiers.addColor("mSpecular", Color.White);
        }
        public override void Init()
        {
            effect = TGCShaders.Instance.LoadEffect(ShadersDir + "Blinn.fx");

            ConfigureModifiers();
            InitializePlanes();
            InitializeLightBox();

            D3DDevice.Instance.Device.RenderState.CullMode = Cull.CounterClockwise;

            BackgroundColor = Color.DarkGray;

            Camera = new TgcFpsCamera(new TGCVector3(0, 80f, 0), 300f, 0f, Input);
        }
        public override void Init()
        {
            //Se crean 2 triangulos (o Quad) con las dimensiones de la pantalla con sus posiciones ya transformadas
            // x = -1 es el extremo izquiedo de la pantalla, x = 1 es el extremo derecho
            // Lo mismo para la Y con arriba y abajo
            // la Z en 1 simpre
            CustomVertex.PositionTextured[] screenQuadVertices =
            {
                new CustomVertex.PositionTextured(-1,  1, 1, 0, 0),
                new CustomVertex.PositionTextured(1,   1, 1, 1, 0),
                new CustomVertex.PositionTextured(-1, -1, 1, 0, 1),
                new CustomVertex.PositionTextured(1,  -1, 1, 1, 1)
            };
            //vertex buffer de los triangulos
            screenQuadVB = new VertexBuffer(typeof(CustomVertex.PositionTextured),
                                            4, D3DDevice.Instance.Device, Usage.Dynamic | Usage.WriteOnly,
                                            CustomVertex.PositionTextured.Format, Pool.Default);
            screenQuadVB.SetData(screenQuadVertices, 0, LockFlags.None);

            //Creamos un Render Targer sobre el cual se va a dibujar la pantalla
            renderTarget2D = new Texture(D3DDevice.Instance.Device,
                                         D3DDevice.Instance.Device.PresentationParameters.BackBufferWidth
                                         , D3DDevice.Instance.Device.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget,
                                         Format.X8R8G8B8, Pool.Default);

            //Cargar shader con efectos de Post-Procesado
            effect = TgcShaders.loadEffect(ShadersDir + "PostProcess.fx");

            //Configurar Technique dentro del shader
            effect.Technique = "OscurecerTechnique";

            //Interpolador para efecto de variar la intensidad de la textura de alarma
            intVaivenOscurecer       = new InterpoladorVaiven();
            intVaivenOscurecer.Min   = 0;
            intVaivenOscurecer.Max   = 1;
            intVaivenOscurecer.Speed = 0.4f;
            intVaivenOscurecer.reset();

            //Cargamos un escenario
            var loader = new TgcSceneLoader();
            var scene  = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");

            meshes = scene.Meshes;

            //Camara en primera personas
            Camara = new TgcFpsCamera(new Vector3(-182.3816f, 82.3252f, -811.9061f));

            //Modifier para activar/desactivar efecto de oscurecer
            Modifiers.addBoolean("activar_efecto", "Activar efecto", true);
        }
        public override void Init()
        {
            box = TgcBox.fromSize(new Vector3(300, 100, 150));

            lastTexture = MediaDir + "Texturas\\Quake\\TexturePack2\\concrete1_4.jpg";
            Modifiers.addTexture("Texture", lastTexture);
            changeBoxTexure(D3DDevice.Instance.Device, box, lastTexture);

            lastFiltering = "Linear";
            Modifiers.addInterval("Filtering", new[] { "Nearest", "Linear", "Bilinear", "Anisotropic" }, 0);
            changeTextureFiltering(D3DDevice.Instance.Device, lastFiltering);

            Camara = new TgcFpsCamera(new Vector3(-54.93998f, 2f, -1.118192f), 150f, 500f);
        }
Exemple #29
0
        public override void Init()
        {
            //Crea línea genérica
            line = new TgcBoxLine();

            //Crear modifiers
            Modifiers.addVertex3f("start", new Vector3(-50, -50, -50), new Vector3(50, 50, 50), new Vector3(0, 0, 0));
            Modifiers.addVertex3f("end", new Vector3(-50, -50, -50), new Vector3(50, 50, 50), new Vector3(0, 10, 0));
            Modifiers.addFloat("thickness", 0.1f, 5, 0.2f);
            Modifiers.addColor("color", Color.Red);

            //Camara FPS
            Camara = new TgcFpsCamera(new Vector3(0.0302f, 5.842f, -18.97f), 10f, 10f);
        }
Exemple #30
0
        public override void Init()
        {
            effect = TGCShaders.Instance.LoadEffect(ShadersDir + "PBRIBL.fx");

            InitializeScene();
            InitializePBRMesh();
            InitializeLights();
            InitializeLightBoxes();
            InitializeUnitCube();
            InitializeTextures();
            InitializeFullScreenQuad();

            FixedTickEnable = true;
            Camera          = new TgcFpsCamera(new TGCVector3(250, 160, -570), Input);
        }