public void ProgressBarDlg() { gui.InitDialog(false, false); int W = D3DDevice.Instance.Width; int H = D3DDevice.Instance.Height; int x0 = -20; int y0 = 100; int dy = 350; int dx = W + 50; GUIItem frame = gui.InsertFrame("Cargando mision", x0, y0, dx, dy, Color.FromArgb(240, 240, 240), frameBorder.sin_borde); frame.c_font = Color.FromArgb(0, 0, 0); progress_bar = gui.InsertProgressBar(ID_PROGRESS1, 50, y0 + 150, W - 100, 60); Device d3dDevice = D3DDevice.Instance.Device; int cant_textures = 5; progress_bar.SetRange(0, cant_textures, "Descargando archivos.."); progress_bar.SetPos(1); for (int i = 0; i < cant_textures; ++i) { progress_bar.SetPos(i); progress_bar.text = "Descargando archivo: " + MediaDir + "Texturas\\f1\\f1piso2.png"; Texture textura_piso = Texture.FromBitmap(d3dDevice, (Bitmap)Bitmap.FromFile(MediaDir + "Texturas\\f1\\f1piso2.png"), Usage.None, Pool.Managed); textura_piso.Dispose(); MessageLoop(); } gui.EndDialog(); // progress bar dialog }
/// <summary> /// Dialog que muestra todas las categorias de texturas disponibles que hay. /// Al hacer clic te abre un segundo Dialog con las texturas dentro de esa categoria. /// </summary> public void TextureGroupDlg(DXGui gui) { // Inicio un dialogo modalless gui.InitDialog(false, false); int W = GuiController.Instance.Panel3d.Width; int H = GuiController.Instance.Panel3d.Height; int x0 = 20; int y0 = 50; int dy = 500; int dx = W - 40; int r = 250; gui.InsertFrame("Seleccione la categoría", x0, y0, dx, dy, Color.FromArgb(192, 192, 192), frameBorder.redondeado); //int sdx = 400; //int sdy = 120; //gui.InsertKinectScrollButton(0, "scroll_left.png", x0 + 40, y0 + dy - sdy - 50, sdx, sdy); //gui.InsertKinectScrollButton(1, "scroll_right.png", x0 + 40 + sdx + 20, y0 + dy - sdy - 50, sdx, sdy); gui_item cancel_btn = gui.InsertKinectCircleButton(1, "Cancel", "cancel.png", W - gui.KINECT_BUTTON_SIZE_X - 40, y0 + 20, gui.KINECT_BUTTON_SIZE_X); cancel_btn.scrolleable = false; // fijo el boton de cancelar //Crear un boton por cada grupo de textura for (int i = 0; i < grupos.Count; i++) { Group g = grupos[i]; gui.InsertKinectCircleButton(g.guiId, g.name, g.iconPath, x0 + 50 + i * (r + 20), y0 + 160, r); } }
/// <summary> /// Dialog que muestra todas las texturas dentro de una categoria especifica. /// Al seleccionar una textura la aplica a todos los mesh que tenga esa categoria /// </summary> public void TextureDlg(DXGui gui, int groupId) { // Inicio un dialogo modalless gui.InitDialog(false, false); int W = GuiController.Instance.Panel3d.Width; int H = GuiController.Instance.Panel3d.Height; int x0 = -20; int y0 = 0; int dy = 520; int dx = W + 40; int tdx = 250; int tdy = 200; gui.InsertFrame("Seleccione la textura", x0, y0, dx, dy, Color.FromArgb(192, 192, 192), frameBorder.sin_borde); int sdx = 500; int sdy = 120; gui.InsertKinectScrollButton(0, "scroll_left.png", x0 + 40, y0 + dy - sdy - 50, sdx, sdy); gui.InsertKinectScrollButton(1, "scroll_right.png", x0 + 40 + sdx + 20, y0 + dy - sdy - 50, sdx, sdy); gui_item cancel_btn = gui.InsertKinectCircleButton(1, "Cancel", "cancel.png", W - gui.KINECT_BUTTON_SIZE_X - 40, y0 + dy - gui.KINECT_BUTTON_SIZE_X - 50, gui.KINECT_BUTTON_SIZE_X); cancel_btn.scrolleable = false; // fijo el boton de cancelar //Buscar grupo con ese id de gui selectedGroup = null; foreach (Group g in grupos) { if (g.guiId == groupId) { selectedGroup = g; break; } } //Crear un boton por cada textura dentro de este grupo for (int i = 0; i < selectedGroup.textures.Count; i++) { Texture t = selectedGroup.textures[i]; gui.InsertKinectTileButton(t.guiId, (i + 1).ToString(), t.path, x0 + 50 + i * (tdx + 50), y0 + 100, tdx, tdy); } }
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); }