// Inicializacion public override void init() { CargarSoldado(); mesh.Position = PosicionActual; disparo = new Disparo(); disparo.init(); sonido = new Sonido(); sonido2 = new Sonido(); sonido.currentFile = "pasos.wav"; sonido.init(); sonido2.currentFile = "Disparo.wav"; sonido2.init(); // INICIALIZO datos de camara Camara = new CamaraTerceraPersona(); Camara.Initialize(this); //colison sphere collisionManager = new SphereCollisionManager(); mesh.AutoUpdateBoundingBox = false; characterSphere = new TgcBoundingSphere(mesh.BoundingBox.calculateBoxCenter(), mesh.BoundingBox.calculateBoxRadius()); }
//==================================== // Inicializacion //==================================== public override void init() { this.velocidad = 3f; CargarDisparo(); //Random r = new Random(DateTime.Now.Millisecond); explo = new Explosion(new Vector3(20, 0, 0), Color.OrangeRed, new Vector3(10f, 10f, 10f), 1, 0, new Vector3(10, 10, 10), r.Next(0, 1000), 150, d3dDevice, 200); // sonido = new Sonido(); sonido.currentFile = "vidrios.wav"; sonido.init(); this.mesh3.Scale = new Vector3(0.25f, 0.25f, 0.25f); }
//==================================== // Inicializacion //==================================== public override void init() { this.velocidad = 50f; CargarMisil(); for (int i = 0; i < 100; i++) { FuegoShaders fuego = new FuegoShaders(); fuego.init(); fuego.mesh.Scale = new Vector3(0.1f, 0.1f, 0.1f); explosiones.Add(fuego); } sonido2 = new Sonido(); sonido2.currentFile = "grito.wav"; sonido2.init(); }
public void CrearEscenario() { //Modifier para variables de shader //GuiController.Instance.Modifiers.addVertex3f("LightPosition", new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000), new Vector3(0, 400, 0)); GuiController.Instance.Modifiers.addColor("AmbientColor", Color.White); GuiController.Instance.Modifiers.addColor("DiffuseColor", Color.Orange); GuiController.Instance.Modifiers.addColor("SpecularColor", Color.Red); GuiController.Instance.Modifiers.addFloat("SpecularPower", 1, 1000, 1000); //GuiController.Instance.Modifiers.addVertex3f("MeshPos", new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000), new Vector3(0, 0, 0)); sonido = new Sonido(); sonido2 = new Sonido(); sonido.currentFile = "Alarma.wav"; sonido2.currentFile = "Helicoptero_2.wav"; sonido.init(); sonido2.init(); camera = new CamaraTerceraPersona(); //Cargar pilar egipcio TgcSceneLoader loader = new TgcSceneLoader(); //Configurar MeshFactory customizado loader.MeshFactory = new CustomMeshShaderFactory(); //**************************************************** //Escenario Principal //**************************************************** TgcSceneLoader loader10 = new TgcSceneLoader(); //Configurar MeshFactory customizado loader10.MeshFactory = new CustomMeshShaderFactory(); terreno = loader10.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "Blizarro\\Meshes\\PuebloJapones\\PuebloJaponesv9X-TgcScene.xml"); //Separar el Terreno del resto de los objetos List <TgcMesh> list1 = new List <TgcMesh>(); separeteMeshList(new string[] { "cesped" }, out list1, out objetosIsla); terrenoMesh = list1; //terreno.separeteMeshList //Crear Quadtree quadtree = new Quadtree(); quadtree.create(objetosIsla, terreno.BoundingBox); quadtree.createDebugQuadtreeMeshes(); //Crear caja para indicar ubicacion de la luz //lightBox = TgcBox.fromSize(new Vector3(50, 50, 50), Color.Yellow); foreach (TgcMeshShader mesh in terreno.Meshes) { //Cargar Shader de PhonhShading string compilationErrors; mesh.Effect = Effect.FromFile(d3dDevice, GuiController.Instance.AlumnoEjemplosMediaDir + "Blizarro\\Shaders\\PhongShading.fx", null, null, ShaderFlags.None, null, out compilationErrors); if (mesh.Effect == null) { throw new Exception("Error al cargar shader. Errores: " + compilationErrors); } //Configurar Technique mesh.Effect.Technique = "DefaultTechnique"; mesh.Effect.SetValue("fvAmbient", ColorValue.FromColor(Color.White)); mesh.Effect.SetValue("fvDiffuse", ColorValue.FromColor(Color.Black)); mesh.Effect.SetValue("fvSpecular", ColorValue.FromColor(Color.Black)); mesh.Effect.SetValue("fSpecularPower", (float)GuiController.Instance.Modifiers["SpecularPower"]); } //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"); //UserVar para contar la cantidad de meshes que se renderizan GuiController.Instance.UserVars.addVar("Soldados"); //Carga fuertes enemigos d3dDevice.RenderState.AlphaBlendEnable = false; /////////////////////////////////////SKYBOX//////////////////////////////////////////// string texturesPath = GuiController.Instance.ExamplesMediaDir + "Texturas\\Quake\\SkyBox1\\"; //Crear SkyBox skyBox = new TgcSkyBox(); skyBox.Center = new Vector3(0, 5000, 0); skyBox.Size = new Vector3(8000, 11000, 10000); //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"); //Actualizar todos los valores para crear el SkyBox skyBox.updateValues(); // Cargo niebla /* GuiController.Instance.Fog.Enabled = true; * GuiController.Instance.Fog.StartDistance = 5; * GuiController.Instance.Fog.EndDistance = 8000; * GuiController.Instance.Fog.Density = 0.1f; * GuiController.Instance.Fog.updateValues(); */ GuiController.Instance.Modifiers.addBoolean("showQuadtree", "Show Quadtree", false); GuiController.Instance.Modifiers.addBoolean("showTerrain", "Show Terrain", true); //GuiController.Instance.Modifiers.addBoolean("showBoundingBox", "Bouding Box", false); }