Beispiel #1
0
        //*********************************************
        /* Carga el tanque de Guerra */
        //*********************************************
        public void CargarTanque()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            TgcSceneLoader loader7 = new TgcSceneLoader();

            loader7.MeshFactory = new CustomMeshShaderFactory();
            TgcScene scene7 = loader7.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\TanqueFuturistaRuedas\\TanqueFuturistaRuedas-TgcScene.xml");

            mesh4 = (TgcMeshShader)scene7.Meshes[0];


            mesh4.Position   = C_PosicionActual;
            mesh4.Scale      = new Vector3(0.2f, 0.2f, 0.2f);
            C_PosicionAnt    = C_PosicionActual;
            C_PosicionActual = mesh4.Position;
            C_Estado         = "Vivo";

            //Cargar Shader de PhonhShading
            string compilationErrors;

            mesh4.Effect = Effect.FromFile(d3dDevice, GuiController.Instance.ExamplesMediaDir + "Shaders\\PhongShading.fx", null, null, ShaderFlags.None, null, out compilationErrors);
            if (mesh4.Effect == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }
            //Configurar Technique
            mesh4.Effect.Technique = "DefaultTechnique";

            //Crear caja para indicar ubicacion de la luz
            lightBox = TgcBox.fromSize(new Vector3(50, 50, 50), Color.Yellow);
        }
Beispiel #2
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;
        }
Beispiel #3
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()
        {
            //Crear loader
            var loader = new TgcSceneLoader();

            //Cargar mesh
            var scene = loader.loadSceneFromFile(MediaDir + "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
            Modifiers.addBoolean("lightEnable", "lightEnable", true);
            Modifiers.addVertex3f("lightPos", new Vector3(-500, -500, -500), new Vector3(500, 800, 500),
                                  new Vector3(0, 500, 0));
            Modifiers.addColor("ambient", Color.Gray);
            Modifiers.addColor("diffuse", Color.Blue);
            Modifiers.addColor("specular", Color.White);
            Modifiers.addFloat("specularEx", 0, 40, 20f);

            //Centrar camara rotacional respecto a este mesh
            Camara = new TgcRotationalCamera(mesh.BoundingBox.calculateBoxCenter(),
                                             mesh.BoundingBox.calculateBoxRadius() * 2);
        }
Beispiel #5
0
        public override void Init()
        {
            //Crear loader
            var loader = new TgcSceneLoader();

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

            //Cargar Shader personalizado
            effect = TgcShaders.loadEffect(ShadersDir + "WorkshopShaders\\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 = "RenderScene2";

            //Centrar camara rotacional respecto a este mesh

            Camara = new TgcRotationalCamera(mesh.BoundingBox.calculateBoxCenter(),
                                             mesh.BoundingBox.calculateBoxRadius() * 5, Input);

            time = 0;
        }
Beispiel #6
0
        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;

            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;
        }
Beispiel #8
0
        private void LoadShip()
        {
            string pathShip = MediaDir + "\\Meshes\\ship\\ship-TgcScene.xml";

            var loader = new TgcSceneLoader();
            var scene  = loader.loadSceneFromFile(pathShip);

            var position = new TGCVector3(10000f, 150f, 800f);
            var scale    = new TGCVector3(5, 5, 5);
            var rotation = new TGCVector3(-(FastMath.PI / 8), -(FastMath.PI / 4), 0);

            foreach (var mesh in scene.Meshes)
            {
                mesh.Position = position;
                mesh.Scale    = scale;
                mesh.Rotation = rotation;

                ItemModel item = new ItemModel {
                    Mesh = mesh
                };

                //The ship has collision
                item.RigidBody = bulletManager.AddRigidBody(mesh, position, scale);

                meshes.Add(item);
            }
        }
Beispiel #9
0
        private void LoadRocks()
        {
            var    rnd      = new Random();
            string pathRock = MediaDir + "\\Meshes\\rock\\Roca-TgcScene.xml";

            var loader       = new TgcSceneLoader();
            var originalMesh = loader.loadSceneFromFile(pathRock).Meshes[0];

            var xMax = 12000f;
            var zMax = 12000f;
            var cant = 10;

            for (int i = 0; i < cant; i++)
            {
                var posX = xMax * (float)rnd.NextDouble();
                var posZ = zMax * (float)rnd.NextDouble();
                var posY = underseaTerrain.HeightmapData[Convert.ToInt32(posX / currentScaleXZ), Convert.ToInt32(posZ / currentScaleXZ)];

                var position = new TGCVector3(posX, posY * currentScaleY, posZ);
                var scale    = new TGCVector3(i * 1.5f, i, i * 1.5f);

                var rock = originalMesh.createMeshInstance(originalMesh.Name + $"_{i}");

                rock.Transform = TGCMatrix.Scaling(scale) * TGCMatrix.Translation(position);

                ItemModel item = new ItemModel {
                    Mesh = rock
                };

                //The rocks has collision
                item.RigidBody = bulletManager.AddRigidBody(rock, position, scale);

                meshes.Add(item);
            }
        }
Beispiel #10
0
        private void LoadMask()
        {
            recoltableItemEffect           = TGCShaders.Instance.LoadEffect(ShadersDir + "\\RecolectableItemShader.fx");
            recoltableItemEffect.Technique = "RecolectableItemTechnique";

            string pathMask = MediaDir + "\\Meshes\\mask\\mask_floor-TgcScene.xml";

            var loader = new TgcSceneLoader();
            var meshes = loader.loadSceneFromFile(pathMask).Meshes;

            int i = 0;

            foreach (var mesh in meshes)
            {
                mesh.Position = new TGCVector3(6939, 4105, 6585);
                mesh.Scale    = new TGCVector3(1f, 1f, 1f);
                mesh.Rotation = new TGCVector3(0, 90, 0);

                mesh.Effect    = recoltableItemEffect;
                mesh.Technique = "RecolectableItemTechnique";

                mesh.Name = "maskfloor_" + i.ToString();
                i++;

                collectModel.CollisionMeshes.Add(new ItemModel {
                    Mesh = mesh, IsCollectable = true, CollectablePosition = mesh.Position
                });
            }
        }
Beispiel #11
0
        private void LoadBoat()
        {
            string pathBoat = MediaDir + "\\Meshes\\boat2\\boat2-TgcScene.xml";

            var loader = new TgcSceneLoader();
            var scene  = loader.loadSceneFromFile(pathBoat);

            var position = new TGCVector3(6000, 3800, 6000);
            var scale    = new TGCVector3(15, 5, 15);

            foreach (var mesh in scene.Meshes)
            {
                mesh.Position = position;
                mesh.Scale    = scale;

                ItemModel item = new ItemModel {
                    Mesh = mesh
                };

                //The boat has collision
                item.RigidBody = bulletManager.AddRigidBody(mesh, position, scale);

                meshes.Add(item);
            }
        }
        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);
        }
Beispiel #13
0
        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;
        }
Beispiel #14
0
        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);
        }
Beispiel #15
0
        /// <summary>
        /// para crear un oponente. Tiempo de espera es para que no ande doblando todo el tiempo.
        /// </summary>
        /// <param name="gm"></param>
        /// <param name="AutoPlayer"></param>
        /// <param name="velocidadd"></param>
        /// <param name="desvioChoquee"></param>
        /// <param name="tiempoEspera"></param>
        public AutoOponente(GameModel gm, Auto AutoPlayer, float velocidadd, float desvioChoquee, float tiempoEspera, Vector3 posicion)
        {
            posTarget        = AutoPlayer.Mesh.Position;
            autoPlayer       = AutoPlayer;
            gameModel        = gm;
            elapsedTime      = gm.ElapsedTime;
            meshTarget       = AutoPlayer.Mesh;
            velocidad        = velocidadd;
            desvioChoque     = desvioChoquee;
            FixedWaitingTime = tiempoEspera; //el tiempo que espera hasta volver a girar.
            tiempoEspera     = 0f;           //este el contador del tiempo de espera.


            //creo el mesh
            TgcSceneLoader Loader = new TgcSceneLoader();
            TgcScene       sc     = Loader.loadSceneFromFile(gameModel.MediaDir + "AerodeslizadorFuturista\\AerodeslizadorFuturista-TgcScene.xml");

            Mesh = sc.Meshes[0];
            float scale = 0.45f;

            Scale      = new Vector3(scale, scale, scale);
            Mesh.Scale = Scale;
            Mesh.AutoTransformEnable = false;

            Mesh.Position  = posTarget - new Vector3(0, 0, -400);
            Mesh.Transform = Matrix.Scaling(Scale) * Matrix.Translation(Mesh.Position);
            computarBoundingBox();
        }
        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);
        }
Beispiel #17
0
        public static TgcMesh loadMesh(string path)
        {
            TgcSceneLoader loader       = new TgcSceneLoader();
            TgcScene       currentScene = loader.loadSceneFromFile(path);

            return(currentScene.Meshes[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
            Camara = 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()
        {
            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();
        }
        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);
        }
Beispiel #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;
        }
Beispiel #22
0
        //mansion spencer 2.0.xml

        public override void Init()
        {
            var loader = new TgcSceneLoader();

            scene = loader.loadSceneFromFile(MediaDir + "Desktop\\mansion spencer 2.0.xml");

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

            //Camara = new TgcFpsCamera(new Vector3(0, 0, 0), 800f, 600f, Input);
            // Camara = new TgcCamera();

            var cameraPosition = new Vector3(0, 0, 125);
            var lookAt         = Vector3.Empty;

            Camara.SetCamera(cameraPosition, lookAt);


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

            //throw new NotImplementedException();
            UserVars.addVar("MeshCount");
        }
Beispiel #23
0
        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);
            depthStencil = D3DDevice.Instance.Device.CreateDepthStencilSurface(D3DDevice.Instance.Device.Viewport.Width,
                                                                               D3DDevice.Instance.Device.Viewport.Height,
                                                                               DepthFormat.D24S8, MultiSampleType.None, 0, true);

            //Camara en 1ra persona
            Camara = new TgcFpsCamera(new TGCVector3(-20, 80, 450), 400f, 300f, Input);
        }
Beispiel #24
0
        public override void init()
        {
            TgcSceneLoader loader = new TgcSceneLoader();

            scene = loader.loadSceneFromFile(sceneFolder + "PuebloJapones\\PuebloJapones-TgcScene.xml");
            //mainCarMesh = loader.loadSceneFromFile(mediaFolder + "meshes\\objects\\Auto\\Auto-TgcScene.xml").Meshes[0];
            //mainCar = new Auto(mainCarMesh);

            objetosColisionables.Clear();
            foreach (TgcMesh mesh in scene.Meshes)
            {
                objetosColisionables.Add(mesh.BoundingBox);
            }

            collisionManager = new SphereCollisionManager();
            collisionManager.GravityEnabled = true;
            collisionManager.GravityForce   = new Vector3(0, -1, 0);


            sphere          = new TgcSphere();
            sphere.Radius   = 5;
            sphere.Position = new Vector3(0, 10, 0);
            sphere.setColor(Color.Blue);


            Vector3 movementVector = Vector3.Empty;

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

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

            GuiController.Instance.RotCamera.CameraDistance = 100;
            //initCarCamera();
        }
Beispiel #25
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();
        }
Beispiel #26
0
        /// <summary>
        /// Atender mensaje InformacionInicial
        /// </summary>
        private void clienteAtenderInformacionInicial(TgcSocketRecvMsg msg)
        {
            //Recibir data
            VehiculoData vehiculoData = (VehiculoData)msg.readNext();

            //Cargar mesh
            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene       scene  = loader.loadSceneFromFile(vehiculoData.meshPath);

            meshPrincipal = scene.Meshes[0];

            //Ubicarlo en escenario
            meshPrincipal.Position = vehiculoData.initialPos;

            //Camara
            GuiController.Instance.ThirdPersonCamera.resetValues();
            GuiController.Instance.ThirdPersonCamera.setCamera(meshPrincipal.Position, 100, 400);

            //Ver si ya habia mas clientes para cuando nosotros nos conectamos
            int otrosVehiculosCant = (int)msg.readNext();

            for (int i = 0; i < otrosVehiculosCant; i++)
            {
                VehiculoData vData = (VehiculoData)msg.readNext();
                crearMeshOtroCliente(vData);
            }
        }
Beispiel #27
0
        public void initializeSol()
        {
            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
            sol = loader.loadSceneFromFile(sphere).Meshes[0];
            sol.changeDiffuseMaps(new TgcTexture[] { TgcTexture.createTexture(d3dDevice, GuiController.Instance.AlumnoEjemplosMediaDir + "Textures\\environment\\sol1.jpg") });

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

            //Posición del sol
            //NO logro ubicarlo arriba de todo.
            sol.Position = new Vector3(990, 500, 1500);

            //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);
        }
Beispiel #28
0
        private void InitializeMeshes()
        {
            TgcTexture tiles, lava, stones, water;

            tiles  = TgcTexture.createTexture(MediaDir + "Textures/tiles.jpg");
            lava   = TgcTexture.createTexture(MediaDir + "Textures/lava.jpg");
            stones = TgcTexture.createTexture(MediaDir + "Textures/stones.bmp");
            water  = TgcTexture.createTexture(MediaDir + "Textures/water.bmp");

            TGCSphere baseSphere = new TGCSphere(1f, Color.White, TGCVector3.Empty);

            baseSphere.setTexture(lava);
            baseSphere.updateValues();
            sphereOne = baseSphere.toMesh("sphereOne");
            meshes.Add(sphereOne);
            baseSphere.setTexture(stones);
            sphereTwo = baseSphere.toMesh("sphereTwo");
            meshes.Add(sphereTwo);
            baseSphere.setTexture(water);
            sphereThree = baseSphere.toMesh("sphereThree");
            meshes.Add(sphereThree);

            TgcSceneLoader loader = new TgcSceneLoader();
            var            scene  = loader.loadSceneFromFile(MediaDir + "Robot2-TgcScene.xml");

            robot           = scene.Meshes[0];
            robot.Transform = TGCMatrix.Scaling(0.1f, 0.1f, 0.1f) * TGCMatrix.RotationY(FastMath.PI) * TGCMatrix.Translation(TGCVector3.Up * 40f);
            meshes.Add(robot);

            TgcPlane tgcPlane = new TgcPlane(TGCVector3.Empty, TGCVector3.One * 100f, TgcPlane.Orientations.XZplane, tiles, 10f, 10f);

            plane = tgcPlane.toMesh("plane");
            meshes.Add(plane);
        }
Beispiel #29
0
        public override void Init()
        {
            //Cargar mesh
            var loader = new TgcSceneLoader();

            mesh = loader.loadSceneFromFile(MediaDir + "ModelosTgc\\LogoTGC\\LogoTGC-TgcScene.xml").Meshes[0];

            //Cargar Shader de PhongShading
            mesh.Effect    = TGCShaders.Instance.TgcMeshPhongShader;
            mesh.Technique = TGCShaders.Instance.GetTGCMeshTechnique(mesh.RenderType);

            //Texto help
            textHelp          = new TgcText2D();
            textHelp.Position = new Point(15, 260);
            textHelp.Size     = new Size(500, 100);
            textHelp.changeFont(new Font("TimesNewRoman", 16, FontStyle.Regular));
            textHelp.Color = Color.Yellow;
            textHelp.Align = TgcText2D.TextAlign.LEFT;
            textHelp.Text  = "��Por donde empezar? Presionar \"H\"";

            //Help form
            var helpRtf = File.ReadAllText(MediaDir + "\\help.rtf");

            helpForm = new EjemploDefaultHelpForm(helpRtf);

            //Camara
            Camara = new TgcRotationalCamera(TGCVector3.Empty, 150f, Input);
        }
Beispiel #30
0
        //=================================================================================
        // carga armamento en alguna de las manos del personaje
        //=================================================================================
        public void AgarrarArmamento()
        {
            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene       scene  = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Armas\\Escudo\\Escudo-TgcScene.xml");

            TgcSceneLoader loader2 = new TgcSceneLoader();
            TgcScene       scene2  = loader2.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Armas\\Hacha\\Hacha-TgcScene.xml");

            C_ArmamentoManoDerecha = scene.Meshes[0];//.Meshes[0];
            //C_ArmamentoManoDerecha.AutoTransformEnable = true;
            C_ArmamentoManoDerecha.Scale = new Vector3(10, 10, 10);
            C_ArmamentoManoIzquierda     = scene2.Meshes[0];//.Meshes[0];

            //Agregar attachment a original
            TgcSkeletalBoneAttach attachment  = new TgcSkeletalBoneAttach();
            TgcSkeletalBoneAttach attachment2 = new TgcSkeletalBoneAttach();

            attachment.Mesh   = C_ArmamentoManoDerecha;
            attachment.Bone   = mesh.getBoneByName("Bip01 R Hand");
            attachment.Offset = Matrix.Transformation2D(new Vector2(0, 10), 0, new Vector2(1.5f, 1.5f), new Vector2(0, 0), 60, new Vector2(2, 5));

            attachment2.Mesh   = C_ArmamentoManoIzquierda;
            attachment2.Bone   = mesh.getBoneByName("Bip01 L Hand");
            attachment2.Offset = Matrix.Transformation2D(new Vector2(0, 10), 0, new Vector2(2, 2), new Vector2(0, 0), 60, new Vector2(2, 5));

            attachment.updateValues();
            attachment2.updateValues();
            mesh.Attachments.Add(attachment);
            mesh.Attachments.Add(attachment2);
        }