public override void Init() { time = 0f; Device d3dDevice = D3DDevice.Instance.Device; MyShaderDir = ShadersDir + "WorkshopShaders\\"; //Crear loader TgcSceneLoader loader = new TgcSceneLoader(); scene = loader.loadSceneFromFile(MediaDir + "WorkshopShaders\\comborata\\comborata-TgcScene.xml"); g_pBaseTexture = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\rocks.jpg"); g_pHeightmap = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\NM_height_rocks.tga"); g_pBaseTexture2 = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\stones.bmp"); g_pHeightmap2 = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\NM_height_stones.tga"); g_pBaseTexture3 = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\granito.jpg"); g_pHeightmap3 = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\NM_height_saint.tga"); g_pBaseTexture4 = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\granito.jpg"); g_pHeightmap4 = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\NM_four_height.tga"); foreach (TgcMesh mesh in scene.Meshes) { if (mesh.Name.Contains("Floor")) { rooms.Add(mesh.BoundingBox); } } //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); } lightDirModifier = AddVertex3f("LightDir", new TGCVector3(-1, -1, -1), new TGCVector3(1, 1, 1), TGCVector3.Down); minSampleModifier = AddFloat("minSample", 1f, 10f, 10f); maxSampleModifier = AddFloat("maxSample", 11f, 50f, 50f); heightMapScaleModifier = AddFloat("HeightMapScale", 0.001f, 0.5f, 0.1f); Camera = new TgcFpsCamera(new TGCVector3(147.2558f, 8.0f, 262.2509f), 100f, 10f, Input); Camera.SetCamera(new TGCVector3(147.2558f, 8.0f, 262.2509f), new TGCVector3(148.2558f, 8.0f, 263.2509f)); //Cargar personaje con animaciones TgcSkeletalLoader skeletalLoader = new TgcSkeletalLoader(); Random rnd = new Random(); // meto un enemigo por cada cuarto cant_enemigos = 0; foreach (TgcMesh mesh in scene.Meshes) { if (mesh.Name.Contains("Floor")) { float kx = rnd.Next(25, 75) / 100.0f; float kz = rnd.Next(25, 75) / 100.0f; float pos_x = mesh.BoundingBox.PMin.X * kx + mesh.BoundingBox.PMax.X * (1 - kx); float pos_z = mesh.BoundingBox.PMin.Z * kz + mesh.BoundingBox.PMax.Z * (1 - kz); TgcSkeletalMesh enemigo = skeletalLoader.loadMeshAndAnimationsFromFile(MediaDir + "SkeletalAnimations\\BasicHuman\\" + "CombineSoldier-TgcSkeletalMesh.xml", MediaDir + "SkeletalAnimations\\BasicHuman\\", new string[] { MediaDir + "SkeletalAnimations\\BasicHuman\\Animations\\" + "Walk-TgcSkeletalAnim.xml", }); enemigos.Add(enemigo); //Configurar animacion inicial enemigos[cant_enemigos].playAnimation("Walk", true); enemigos[cant_enemigos].Position = new TGCVector3(pos_x, 1f, pos_z); enemigos[cant_enemigos].Scale = new TGCVector3(0.3f, 0.3f, 0.3f); enemigos[cant_enemigos].Transform = TGCMatrix.Scaling(enemigos[cant_enemigos].Scale) * TGCMatrix.RotationYawPitchRoll(enemigos[cant_enemigos].Rotation.Y, enemigos[cant_enemigos].Rotation.X, enemigos[cant_enemigos].Rotation.Z) * TGCMatrix.Translation(enemigos[cant_enemigos].Position); enemigo_an[cant_enemigos] = 0; cant_enemigos++; } } // levanto el GUI float W = D3DDevice.Instance.Width; float H = D3DDevice.Instance.Height; gui.Create(MediaDir); gui.InitDialog(false); gui.InsertFrame("Combo Rata", 10, 10, 200, 200, Color.FromArgb(32, 120, 255, 132), frameBorder.sin_borde); gui.InsertFrame("", 10, (int)H - 150, 200, 140, Color.FromArgb(62, 120, 132, 255), frameBorder.sin_borde); gui.cursor_izq = gui.cursor_der = tipoCursor.sin_cursor; // le cambio el font gui.font.Dispose(); // Fonts gui.font = new Microsoft.DirectX.Direct3D.Font(d3dDevice, 12, 0, FontWeight.Bold, 0, false, CharacterSet.Default, Precision.Default, FontQuality.Default, PitchAndFamily.DefaultPitch, "Lucida Console"); gui.font.PreloadGlyphs('0', '9'); gui.font.PreloadGlyphs('a', 'z'); gui.font.PreloadGlyphs('A', 'Z'); gui.RTQ = gui.rectToQuad(0, 0, W, H, 0, 0, W - 150, 160, W - 200, H - 150, 0, H); }