public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene sceneOriginal = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Box\\" + "Box-TgcScene.xml");
            TgcMesh meshOriginal = sceneOriginal.Meshes[0];

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

            TgcMesh 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);

            TgcTexture texture = TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Piso\\Textures\\piso2.jpg");
            meshOriginal.changeDiffuseMaps(new TgcTexture[] { texture });

            GuiController.Instance.FpsCamera.Enable = true;
        }
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Activamos el renderizado customizado. De esta forma el framework nos delega control total sobre como dibujar en pantalla
            //La responsabilidad cae toda de nuestro lado
            GuiController.Instance.CustomRenderEnabled = true;

            //Cargar shader de este ejemplo
            effect = TgcShaders.loadEffect(GuiController.Instance.ExamplesMediaDir + "Shaders\\EjemploGetZBuffer.fx");

            //Cargamos un escenario
            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");
            meshes = scene.Meshes;
            foreach (TgcMesh 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, d3dDevice.Viewport.Width, d3dDevice.Viewport.Height, 1, Usage.RenderTarget, Format.R32F, Pool.Default);

            //Camara en 1ra persona
            GuiController.Instance.FpsCamera.Enable = true;
            GuiController.Instance.FpsCamera.MovementSpeed = 400f;
            GuiController.Instance.FpsCamera.JumpSpeed = 300f;
            GuiController.Instance.FpsCamera.setCamera(new Vector3(-20, 80, 450), new Vector3(0, 80, 1));
        }
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            meshes = new List<TgcMesh>();

            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\BoxAlpha\\Box-TgcScene.xml");
            TgcMesh originalMesh = scene.Meshes[0];

            meshes.Add(originalMesh);
            originalMesh.Position = new Vector3(0,0,0);
            originalMesh.AlphaBlendEnable = true;

            TgcMesh instanceMesh;
            for (int i = 0; i < 5; i++)
            {
                instanceMesh = originalMesh.createMeshInstance("Box" + (i+1));
                instanceMesh.Position = new Vector3(0, 0, i * 50);
                instanceMesh.AlphaBlendEnable = true;
                meshes.Add(instanceMesh);
            }

            GuiController.Instance.FpsCamera.Enable = true;
        }
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Cargar 25 cajas formando una matriz
            TgcSceneLoader loader = new TgcSceneLoader();
            boxes = new List<TgcBox>();
            TgcTexture texture = TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesMediaDir + "Texturas\\granito.jpg");
            Vector3 boxSize = new Vector3(30, 30, 30);
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    Vector3 center = new Vector3((boxSize.X + boxSize.X / 2)  * i, (boxSize.Y + boxSize.Y / 2) * j,  0);
                    TgcBox box = TgcBox.fromSize(center, boxSize, texture);
                    boxes.Add(box);
                }
            }

            //Iniciarlizar PickingRay
            pickingRay = new TgcPickingRay();

            //Camara fija
            GuiController.Instance.RotCamera.Enable = false;
            GuiController.Instance.setCamera(new Vector3(94.9854f, 138.4992f, -284.3344f), new Vector3(86.4563f, -15.4191f, 703.7123f));

            //Crear caja para marcar en que lugar hubo colision
            collisionPointMesh = TgcBox.fromSize(new Vector3(3, 3, 3), Color.Red);
            selected = false;

            //UserVars para mostrar en que punto hubo colision
            GuiController.Instance.UserVars.addVar("CollP-X:");
            GuiController.Instance.UserVars.addVar("CollP-Y:");
            GuiController.Instance.UserVars.addVar("CollP-Z:");
        }
        public override void init()
        {
            Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice;

            //Cuerpo principal que se controla con el teclado
            box = TgcBox.fromSize(new Vector3(0, 10, 0), new Vector3(10, 10, 10), Color.Blue);

            //triangulo
            triangle = new CustomVertex.PositionColored[3];
            triangle[0] = new CustomVertex.PositionColored(-100, 0, 0, Color.Red.ToArgb());
            triangle[1] = new CustomVertex.PositionColored(0, 0, 50, Color.Green.ToArgb());
            triangle[2] = new CustomVertex.PositionColored(0, 100, 0, Color.Blue.ToArgb());
            triagleAABB = TgcBoundingBox.computeFromPoints(new Vector3[] { triangle[0].Position, triangle[1].Position, triangle[2].Position });

            //box2
            box2 = TgcBox.fromSize(new Vector3(-50, 10, -20), new Vector3(15, 15, 15), Color.Violet);

            //sphere
            sphere = new TgcBoundingSphere(new Vector3(30, 20, -20), 15);

            //OBB: computar OBB a partir del AABB del mesh.
            TgcSceneLoader loader = new TgcSceneLoader();
            TgcMesh meshObb = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\StarWars-ATST\\StarWars-ATST-TgcScene.xml").Meshes[0];
            obb = TgcObb.computeFromAABB(meshObb.BoundingBox);
            meshObb.dispose();
            obb.move(new Vector3(100, 0, 30));
            obb.setRotation(new Vector3(0, FastMath.PI / 4, 0));


            //Configurar camara en Tercer Persona
            GuiController.Instance.ThirdPersonCamera.Enable = true;
            GuiController.Instance.ThirdPersonCamera.setCamera(box.Position, 30, -75);
        }
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;
            

            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene scene = loader.loadSceneFromFile(
                    GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Box\\" + "Box-TgcScene.xml",
                    GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Box\\");
            mesh = scene.Meshes[0];
            mesh.Scale = new Vector3(0.25f, 0.25f, 0.25f);


            GuiController.Instance.FpsCamera.Enable = true;
            GuiController.Instance.FpsCamera.setCamera(new Vector3(7.9711f, 11.7f, -32.5475f), new Vector3(7.972f, 11.4178f, -31.5475f));


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

            string texturePath = GuiController.Instance.ExamplesMediaDir + "Texturas\\Quake\\TexturePack2\\brick1_1.jpg";
            currentTexture = TgcTexture.createTexture(d3dDevice, texturePath);
            GuiController.Instance.Modifiers.addTexture("texture", currentTexture.FilePath);



            updateWall();
        
        }
        /// <summary>
        /// Método que se llama una sola vez,  al principio cuando se ejecuta el ejemplo.
        /// Escribir aquí todo el código de inicialización: cargar modelos, texturas, modifiers, uservars, etc.
        /// Borrar todo lo que no haga falta
        /// </summary>
        public override void init()
        {
            //GuiController.Instance: acceso principal a todas las herramientas del Framework

            //Device de DirectX para crear primitivas
            Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice;
            TgcSceneLoader loader = new TgcSceneLoader();

            nivel = new Nivel1();

            fpsCamara = new Camara();

            GuiController.Instance.CurrentCamera = fpsCamara;

            fpsCamara.MovementSpeed = 1000f;
            fpsCamara.RotationSpeed = 2f;

            fpsCamara.setCamera(nivel.posicionInicial(), nivel.orientacionCamara());
            fpsCamara.updateViewMatrix(d3dDevice);

            colisionador = new ManejadorColisiones(fpsCamara, nivel.Obstaculos);

            //Iniciarlizar PickingRay
            pickingRay = new TgcPickingRay();
        }
Example #8
0
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            string sphere = GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Sphere\\Sphere-TgcScene.xml";

            TgcSceneLoader 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[] { TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesDir + "Transformations\\SistemaSolar\\SunTexture.jpg") });
            
            earth = loader.loadSceneFromFile(sphere).Meshes[0];
            earth.changeDiffuseMaps(new TgcTexture[] { TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesDir + "Transformations\\SistemaSolar\\EarthTexture.jpg") });
            
            moon = loader.loadSceneFromFile(sphere).Meshes[0];
            moon.changeDiffuseMaps(new TgcTexture[] { TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesDir + "Transformations\\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;


            //Color de fondo
            GuiController.Instance.BackgroundColor = Color.Black;


            //Camara en primera persona
            GuiController.Instance.FpsCamera.Enable = true;
            GuiController.Instance.FpsCamera.setCamera(new Vector3(705.2938f, 305.347f, -888.1567f), new Vector3(183.6915f, 19.6596f, -84.2204f));
        }
Example #9
0
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Cargar modelo
            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene scene = loader.loadSceneFromFile(
                GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\StarWars-ATST\\StarWars-ATST-TgcScene.xml");
            mesh = scene.Meshes[0];

            //Computar OBB a partir del AABB del mesh. Inicialmente genera el mismo volumen que el AABB, pero luego te permite rotarlo (cosa que el AABB no puede)
            obb = TgcObb.computeFromAABB(mesh.BoundingBox);

            //Otra alternativa es computar OBB a partir de sus vertices. Esto genera un OBB lo mas apretado posible pero es una operacion costosa
            //obb = TgcObb.computeFromPoints(mesh.getVertexPositions());

            


            //Alejar camara rotacional segun tamaño del BoundingBox del objeto
            GuiController.Instance.RotCamera.targetObject(mesh.BoundingBox);


            //Modifier para poder rotar y mover el mesh
            GuiController.Instance.Modifiers.addFloat("rotation", 0, 360, 0);
            GuiController.Instance.Modifiers.addVertex3f("position", new Vector3(0, 0, 0), new Vector3(50, 50, 50), new Vector3(0, 0, 0));
        }
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Cargar escenario con información especial exportada de PortalRendering
            TgcSceneLoader loader = new TgcSceneLoader();
            scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesDir + "PortalRendering\\EscenarioPortal\\EscenarioPortal-TgcScene.xml");

            //Descactivar inicialmente a todos los modelos
            scene.setMeshesEnabled(false);

            //Camara en 1ra persona
            GuiController.Instance.FpsCamera.Enable = true;
            GuiController.Instance.FpsCamera.MovementSpeed = 800f;
            GuiController.Instance.FpsCamera.JumpSpeed = 600f;
            GuiController.Instance.FpsCamera.setCamera(new Vector3(0, 0, 0), new Vector3(0, 0, 1));

            //Modifiers
            GuiController.Instance.Modifiers.addBoolean("portalRendering", "PortalRendering", true);
            GuiController.Instance.Modifiers.addBoolean("WireFrame", "WireFrame", false);
            GuiController.Instance.Modifiers.addBoolean("showPortals", "Show Portals", false);

            //UserVars
            GuiController.Instance.UserVars.addVar("MeshCount");

            //Crear portales debug
            scene.PortalRendering.createDebugPortals(Color.Purple);
        }
Example #11
0
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Cargar mesh
            TgcSceneLoader loader = new TgcSceneLoader();
            mesh = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\LogoTGC\\LogoTGC-TgcScene.xml").Meshes[0];

            //Cargar Shader de PhongShading
            mesh.Effect = GuiController.Instance.Shaders.TgcMeshPhongShader;
            mesh.Technique = GuiController.Instance.Shaders.getTgcMeshTechnique(mesh.RenderType);

            //Texto help
            textHelp = new TgcText2d();
            textHelp.Position = new Point(15, 260);
            textHelp.Size = new Size(500, 100);
            textHelp.changeFont(new System.Drawing.Font("TimesNewRoman", 16, FontStyle.Regular));
            textHelp.Color = Color.Yellow;
            textHelp.Align = TgcText2d.TextAlign.LEFT;
            textHelp.Text = "¿Por dónde empezar? Presionar \"H\"";

            //Help form
            string helpRtf = File.ReadAllText(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\LogoTGC\\help.rtf");
            helpForm = new EjemploDefaultHelpForm(helpRtf);

            //Camara
            GuiController.Instance.RotCamera.Enable = true;
            GuiController.Instance.RotCamera.CameraCenter = new Vector3(0, 0, 0);
            GuiController.Instance.RotCamera.CameraDistance = 150;

            GuiController.Instance.BackgroundColor = Color.Black;
        }
Example #12
0
 public Chispa()
 {
     TgcSceneLoader loader = new TgcSceneLoader();
     mesh = loader.loadSceneFromFile(sphere).Meshes[0];
     mesh.changeDiffuseMaps(new TgcTexture[] { TgcTexture.createTexture(d3dDevice, Shared.mediaPath + "\\otros\\giallo.png") });
     mesh.Scale = new Vector3(0.08f, 0.08f, 0.08f);
 }
        public EscenarioManager()
        {
            EscenarioManager.Instance = this;

            sonido = SoundManager.getInstance();
            arboles = new List<TgcMesh>();
            pasto = new List<TgcMesh>();
            barriles = new List<Barril>();
            loader = new TgcSceneLoader();

            casillasPorEje = 50;
            divisionesPiso = new Vector3[2500];
            _random = new Random();

            piso = new TgcBox();
            piso.UVTiling = new Vector2(300, 300);
            pisoSize = (int) tamanio;
            piso.setPositionSize(new Vector3(0, 0, 0), new Vector3(pisoSize*2, 0, pisoSize*2));
            piso.updateValues();

            piso.setTexture(TgcTexture.createTexture(GuiController.Instance.D3dDevice, GuiController.Instance.AlumnoEjemplosMediaDir + "\\RenderMan\\texturas\\nieve.png"));

            generarSkyBox();

            colisionables = new List<TgcBoundingCylinder>();

            limites = new TgcBoundingBox(new Vector3(-tamanio, 0, -tamanio), new Vector3(tamanio, 5000, tamanio));

            GuiController.Instance.Modifiers.addInt("Viento en X", 0, 30, 5);
            GuiController.Instance.Modifiers.addInt("Viento en Z", 0, 30, 5);
        }
        public List<TgcMesh> import(string path)
        {
            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene scene = loader.loadSceneFromFile(path);
            List<TgcMesh> instances = new List<TgcMesh>();
            foreach (TgcMesh m in scene.Meshes)
            {
                if (m.ParentInstance == null)//Si es un mesh original
                {
                    //Lo agrego al diccionario
                    if (!meshes.ContainsKey(m.Name)) meshes.Add(m.Name, m);
                    else
                    {
                        //Por ahora no se puede cargar mas de un mesh original con el mismo nombre.
                        //TODO: Ver de que otro modo indexarlas y como unificar instancias de un mismo mesh que se cargo dos veces.

                        meshes[m.Name].dispose();
                        meshes.Remove(m.Name);

                    }

                    //Si no tenia hijos, creo una instancia para que se vea.
                    if (m.MeshInstances.Count == 0)
                    {
                        instances.Add(instanceOf(m));

                    }
                }
                else instances.Add(m);
            }
            return instances;
        }
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Crear loader
            TgcSceneLoader loader = new TgcSceneLoader();

            //Cargar mesh
            TgcScene scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Olla\\Olla-TgcScene.xml");
            mesh = scene.Meshes[0];

            //Crear caja para indicar ubicacion de la luz
            lightMesh = TgcBox.fromSize(new Vector3(20, 20, 20), Color.Yellow);

            //Modifiers de la luz
            GuiController.Instance.Modifiers.addBoolean("lightEnable", "lightEnable", true);
            GuiController.Instance.Modifiers.addVertex3f("lightPos", new Vector3(-500, -500, -500), new Vector3(500, 800, 500), new Vector3(0, 500, 0));
            GuiController.Instance.Modifiers.addColor("ambient", Color.Gray);
            GuiController.Instance.Modifiers.addColor("diffuse", Color.Blue);
            GuiController.Instance.Modifiers.addColor("specular", Color.White);
            GuiController.Instance.Modifiers.addFloat("specularEx", 0, 40, 20f);

            //Centrar camara rotacional respecto a este mesh
            GuiController.Instance.RotCamera.targetObject(mesh.BoundingBox);
        }
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Cargar escenario
            TgcSceneLoader loader = new TgcSceneLoader();
            scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");

            //Camara en 1ra persona
            GuiController.Instance.FpsCamera.Enable = true;
            GuiController.Instance.FpsCamera.MovementSpeed = 400f;
            GuiController.Instance.FpsCamera.JumpSpeed = 300f;
            GuiController.Instance.FpsCamera.setCamera(new Vector3(-20, 80, 450), new Vector3(0, 80, 1));

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

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

            //Modifiers de material
            GuiController.Instance.Modifiers.addColor("mEmissive", Color.Black);
            GuiController.Instance.Modifiers.addColor("mAmbient", Color.White);
            GuiController.Instance.Modifiers.addColor("mDiffuse", Color.White);
            GuiController.Instance.Modifiers.addColor("mSpecular", Color.White);
        }
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene sceneOriginal = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Iglesia\\" + "Iglesia-TgcScene.xml");
            TgcScene sceneOriginal2 = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Iglesia\\" + "Iglesia-TgcScene.xml");
            //sceneOriginal = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\CajaVerde\\" + "CajaVerde-TgcScene.xml");
            //sceneOriginal = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Avion\\" + "Avion-TgcScene.xml");
            //sceneOriginal = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Iglesia\\" + "Iglesia-TgcScene.xml");
            //TgcScene sceneOriginal = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Box\\" + "Box-TgcScene.xml");
            //TgcScene sceneOriginal2 = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Box\\" + "Box-TgcScene.xml");

            string destFolder = GuiController.Instance.ExamplesDir + "\\" + "PruebaExporter";
            TgcScene unifiedScene = new TgcScene("PruebaExporter", destFolder);
            unifiedScene.Meshes.AddRange(sceneOriginal.Meshes);
            unifiedScene.Meshes.AddRange(sceneOriginal2.Meshes);

            TgcSceneExporter exporter = new TgcSceneExporter();
            //string fileSaved = exporter.exportSceneToXml(unifiedScene, destFolder);
            //string fileSaved = exporter.exportAndAppendSceneToXml(unifiedScene, destFolder);

            TgcSceneExporter.ExportResult r = exporter.exportAndAppendSceneToXml(sceneOriginal, destFolder);

            sceneRecover = loader.loadSceneFromFile(r.filePath);
        }
Example #18
0
        public override void init()
        {
            //FPS Camara
            GuiController.Instance.FpsCamera.Enable = true;
            GuiController.Instance.FpsCamera.setCamera(new Vector3(-140f, 40f, -50f), new Vector3(-140f,40f,-120f));
            GuiController.Instance.FpsCamera.MovementSpeed = 200f;
            GuiController.Instance.FpsCamera.JumpSpeed = 200f;


            
            //Cargar escena desde archivo ZIP
            TgcSceneLoader loader = new TgcSceneLoader();
            tgcScene = loader.loadSceneFromZipFile(
                "4toPiso-TgcScene.xml",
                GuiController.Instance.ExamplesMediaDir + "4toPiso\\4toPiso.zip",
                GuiController.Instance.ExamplesMediaDir + "4toPiso\\Extract\\" );

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


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

            //UserVar para contar la cantidad de meshes que se renderizan
            GuiController.Instance.UserVars.addVar("Meshes renderizadas");

        }
Example #19
0
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;
            //Crear loader
            TgcSceneLoader loader = new TgcSceneLoader();

            //Cargar los mesh:
            scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir
                            + "MeshCreator\\Meshes\\Vehiculos\\TanqueFuturistaRuedas\\TanqueFuturistaRuedas-TgcScene.xml");
            mesh = scene.Meshes[0];
            mesh.Scale = new Vector3(0.5f, 0.5f, 0.5f);
            mesh.Position = new Vector3(0f, 0f, 0f);

            //Cargar Shader personalizado
            effect = TgcShaders.loadEffect(GuiController.Instance.ExamplesDir + "Shaders\\WorkshopShaders\\Shaders\\BasicShader.fx");

            // le asigno el efecto a la malla 
            mesh.Effect = effect;

            // indico que tecnica voy a usar 
            // Hay effectos que estan organizados con mas de una tecnica.
            mesh.Technique = "RenderScene";

            //Centrar camara rotacional respecto a este mesh
            GuiController.Instance.RotCamera.targetObject(mesh.BoundingBox);

            time = 0;
        }
Example #20
0
 public BarcoBot(int vida, int danio, float velocidad,float aceleracion, float rotacion, TgcMesh mesh, double pot, Barco barcoEnemigo,TgcSceneLoader bm,TgcMesh bala)
     : base(vida, danio, velocidad, rotacion, mesh,pot,bm,bala)
 {
     BarcoEnemigo = barcoEnemigo;
     LastPos = Mesh.Position;
     BarcosEnemigos.Add(barcoEnemigo);
     daniado = false;
 }
Example #21
0
        public override void init()
        {
            time = 0f;
            Device d3dDevice = GuiController.Instance.D3dDevice;
            MyMediaDir = GuiController.Instance.ExamplesDir + "Shaders\\WorkshopShaders\\Media\\";
            MyShaderDir = GuiController.Instance.ExamplesDir + "Shaders\\WorkshopShaders\\Shaders\\";

            //Crear loader
            TgcSceneLoader loader = new TgcSceneLoader();

            // parallax oclussion
            scene = loader.loadSceneFromFile(MyMediaDir +"Piso\\Piso-TgcScene.xml");

            g_pBaseTexture  = TextureLoader.FromFile(d3dDevice, MyMediaDir 
                    + "Piso\\Textures\\wood.bmp");
            g_pHeightmap = TextureLoader.FromFile(d3dDevice, MyMediaDir 
                    + "Piso\\Textures\\four_NM_height.tga");

            g_pBaseTexture2 = TextureLoader.FromFile(d3dDevice, MyMediaDir
                    + "Piso\\Textures\\stones.bmp");
            g_pHeightmap2 = TextureLoader.FromFile(d3dDevice, MyMediaDir
                    + "Piso\\Textures\\stones_NM_height.tga");

            g_pBaseTexture3 = TextureLoader.FromFile(d3dDevice, MyMediaDir
                    + "Piso\\Textures\\rocks.jpg");
            g_pHeightmap3 = TextureLoader.FromFile(d3dDevice, MyMediaDir
                    + "Piso\\Textures\\rocks_NM_height.tga");

            mesh = scene.Meshes[0];
            int[] adj = new int[mesh.D3dMesh.NumberFaces * 3];
            mesh.D3dMesh.GenerateAdjacency(0, adj);
            mesh.D3dMesh.ComputeNormals(adj);

            //Cargar Shader
            string compilationErrors;
            effect = Effect.FromFile(d3dDevice, MyShaderDir + "Parallax.fx", null, null, ShaderFlags.None, null, out compilationErrors);
            if (effect == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }

            GuiController.Instance.Modifiers.addVertex3f("LightDir", new Vector3(-1, -1, -1), new Vector3(1, 1, 1), new Vector3(0, -1, 0));
            GuiController.Instance.Modifiers.addFloat("minSample", 1f, 10f, 10f);
            GuiController.Instance.Modifiers.addFloat("maxSample", 11f, 50f, 50f);
            GuiController.Instance.Modifiers.addFloat("HeightMapScale", 0.001f, 0.5f, 0.1f);

            //Centrar camara rotacional respecto a este mesh
            GuiController.Instance.RotCamera.targetObject(mesh.BoundingBox);
            GuiController.Instance.RotCamera.CameraCenter = new Vector3(0, 0, 0);
            GuiController.Instance.RotCamera.CameraDistance = 100;
            GuiController.Instance.RotCamera.RotationSpeed = 1000f;

 

            pom = false;
            phong = true;
            nro_textura = 0;
        }
Example #22
0
        public TankPlayer(Vector3 initialPosition, Terrain.Terrain terrain, string scenePath)
            : base(initialPosition, terrain, scenePath)
        {
            var loader = new TgcSceneLoader { MeshFactory = new MeshShaderFactory() };
            var turretScene = loader.loadSceneFromFile(Path.Turret);
            this.turret = turretScene.Meshes[0];
            this.turretAngle = 0;

            this.turret.AutoUpdateBoundingBox = this.turret.AutoTransformEnable = false;
        }
Example #23
0
    public Missile(Vector3 tankPosition,Vector3 tankRotation)
    {
        var loader = new TgcSceneLoader();
        var scene = loader.loadSceneFromFile(Path.TankScene);

        this.mesh = scene.Meshes[1];
        this.mesh.Position = new Vector3(tankPosition.X, tankPosition.Y + ALTURA_CANION, tankPosition.Z);
        this.mesh.Rotation = new Vector3(tankRotation.X, tankRotation.Y, tankRotation.Z );
        this.initialVeticalSpeed = 8f;
    }
Example #24
0
 public override void Init()
 {
     //Carga del mesh del arma
     TgcSceneLoader loader = new TgcSceneLoader();
     TgcScene scene = loader.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Meshes\\svd\\svd-TgcScene.xml");
     mesh = scene.Meshes[0];
     weaponSoundDir = GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Audio/Armas/Sniper.wav";
     WEAPON_OFFSET = new Vector3(5f, -10.2f, 0.8f);
     WEAPON_ORIENTATION_Y = 0.1f;
     scaleMuzzle = new Vector3(0.0002f, 0.0002f, 0.0002f);
     base.Init();
 }
Example #25
0
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //En este ejemplo no cargamos un solo modelo 3D sino una escena completa, compuesta por varios modelos.
            //El framework posee varias escenas ya hechas en la carpeta TgcViewer\Examples\Media\MeshCreator\Scenes.
            TgcSceneLoader loader = new TgcSceneLoader();
            scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Scenes\\Iglesia\\Iglesia-TgcScene.xml");

            //Hacemos que la cámara esté centrada sobre la escena
            GuiController.Instance.RotCamera.targetObject(scene.BoundingBox);
        }
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Cargar escenario
            TgcSceneLoader loader = new TgcSceneLoader();
            scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");

            //Camara en 1ra persona
            GuiController.Instance.FpsCamera.Enable = true;
            GuiController.Instance.FpsCamera.MovementSpeed = 400f;
            GuiController.Instance.FpsCamera.JumpSpeed = 300f;
            GuiController.Instance.FpsCamera.setCamera(new Vector3(-210.0958f, 114.911f, -109.2159f), new Vector3(-209.559f, 114.8029f, -108.3791f));

            //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(GuiController.Instance.ExamplesMediaDir + "Shaders\\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];
            Color[] c = new Color[4] { Color.Red, Color.Blue, Color.Green, Color.Yellow };
            for (int i = 0; i < lightMeshes.Length; i++)
            {
                Color co = c[i % c.Length];
                lightMeshes[i] = TgcBox.fromSize(new Vector3(10, 10, 10), co);
                origLightPos[i] = new Vector3(-40, 20 + i * 20, 400);
            }

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

            GuiController.Instance.Modifiers.addColor("mEmissive", Color.Black);
            GuiController.Instance.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;
        }
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Cargar modelo estatico
            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene scene = loader.loadSceneFromFile(
                GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\Buggy\\Buggy-TgcScene.xml");
            mesh = scene.Meshes[0];

            //Alejar camara rotacional segun tamaño del BoundingBox del objeto
            GuiController.Instance.RotCamera.targetObject(mesh.BoundingBox);
        }
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            /* Cargar ecena que tiene un modelo configurado con AlphaBlending
             * Los modelos fueron exportados en 3Ds MAX con el mapa "Opacity" cargado en el "Material Editor"
             * Entonces el TgcSceneLoader automáticamente hace mesh.AlphaBlendEnable(true);
             */
            TgcSceneLoader loader = new TgcSceneLoader();
            scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vegetacion\\Pino\\Pino-TgcScene.xml");

            GuiController.Instance.RotCamera.targetObject(scene.BoundingBox);
        }
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            for (int i = 0; i < 100; i++)
            {
                TgcSceneLoader loader = new TgcSceneLoader();
                TgcScene scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vegetacion\\Palmera\\Palmera-TgcScene.xml");
                scene.disposeAll();
            }

            TgcSceneLoader loader1 = new TgcSceneLoader();
            scene1 = loader1.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vegetacion\\Palmera\\Palmera-TgcScene.xml");
        }
Example #30
0
        public Plane()
        {
            String path = GuiController.Instance.ExamplesMediaDir + @"MeshCreator\Meshes\Vehiculos\AvionCaza\AvionCaza-TgcScene.xml";
            TgcSceneLoader loader = new TgcSceneLoader();
            plane = loader.loadSceneFromFile(path).Meshes[0];
            plane.AutoTransformEnable = false;

            rollSpeed = 2.5f;
            pitchSpeed = 2.0f;
            velocidad_normal = 0.6f;
            velocidad_aceleracion = 150.0f;

            Reset();
        }
Example #31
0
        /// <summary>
        /// Método que se llama una sola vez,  al principio cuando se ejecuta el ejemplo.
        /// Escribir aquí todo el código de inicialización: cargar modelos, texturas, modifiers, uservars, etc.
        /// Borrar todo lo que no haga falta
        /// </summary>
        public override void init()
        {
            EjemploAlumno.Instance = this;

            //GuiController.Instance: acceso principal a todas las herramientas del Framework

            //Device de DirectX para crear primitivas
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Carpeta de archivos Media del alumno
            string alumnoMediaFolder = GuiController.Instance.AlumnoEjemplosMediaDir;


            //Terreno
            currentHeightmap = GuiController.Instance.AlumnoEjemplosMediaDir + "Heightmap3.jpg";
            currentTexture   = GuiController.Instance.AlumnoEjemplosMediaDir + "TerrainTexture3.jpg";

            terrain = new TerrenoSimple();
            terrain.loadHeightmap(currentHeightmap, currentScaleXZ, currentScaleY, new Vector3(0, -125, 0));
            terrain.loadTexture(currentTexture);

            //Agua
            agua = new TerrenoSimple();
            agua.loadHeightmap(GuiController.Instance.AlumnoEjemplosMediaDir + "18_vertex_texture_02.jpg", 50f, 0.5f, new Vector3(0, -125, 0));
            agua.loadTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "4141-diffuse.jpg");
            agua.AlphaBlendEnable = true;
            //heightOlas = agua.heightOlas;

            //Modifier
            GuiController.Instance.Modifiers.addFloat("heightOlas", 10, 50, 40);

            //Estado
            EjemploAlumno.Instance.estado = EstadoDelJuego.SinEmpezar;
            menu = new Menu();

            // Crear SkyBox:
            skyBox        = new TgcSkyBox();
            skyBox.Center = new Vector3(0, 0, 0);
            skyBox.Size   = new Vector3(12000, 12000, 12000);
            skyboxSoleado(skyBox);

            skyBoundingBox                  = new TgcBox();
            skyBoundingBox.Size             = skyBox.Size;
            skyBoundingBox.Position         = skyBox.Center;
            skyBoundingBox.AlphaBlendEnable = true;
            skyBoundingBox.updateValues();

            lloviendo = false;

            //Cargar meshes
            TgcViewer.Utils.TgcSceneLoader.TgcSceneLoader loader = new TgcViewer.Utils.TgcSceneLoader.TgcSceneLoader();
            TgcViewer.Utils.TgcSceneLoader.TgcScene       scene  = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\Canoa\\Canoa-TgcScene.xml");

            meshShip = scene.Meshes[0];
            meshShip.setColor(Color.Chocolate);

            scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\Canoa\\Canoa-TgcScene.xml");

            meshes.Add(meshShip);

            meshShipContrincante = scene.Meshes[0];
            meshShipContrincante.setColor(Color.BlueViolet);
            meshes.Add(meshShipContrincante);

            scene      = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Armas\\Canon\\Canon.max-TgcScene.xml");
            meshCanion = scene.Meshes[0];
            meshes.Add(meshCanion);

            scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Armas\\Canon\\Canon.max-TgcScene.xml");
            meshCanionContrincante = scene.Meshes[0];
            meshes.Add(meshCanionContrincante);

            //Shader
            effect                = TgcShaders.loadEffect(alumnoMediaFolder + "shader agua.fx");
            agua.Effect           = effect;
            agua.Technique        = "RenderScene";
            time                  = 0;
            agua.AlphaBlendEnable = true;

            efectoSombra = TgcShaders.loadEffect(alumnoMediaFolder + "shader agua.fx");


            //Creaciones
            ship             = new Ship(POS_SHIP, meshShip, new Canion(POS_SHIP, 5, meshCanion, true));
            shipContrincante = new EnemyShip(ship, POS_CONTRINCANTE, meshShipContrincante, new Canion(POS_CONTRINCANTE, 5, meshCanionContrincante, false));

            mainCamera = new MainCamera(ship);

            //Crear caja para indicar ubicacion de la luz
            lightMesh = TgcBox.fromSize(new Vector3(20, 20, 20), Color.Yellow);
        }