Exemple #1
0
        public override void Init()
        {
            var fpsCamara = new TgcFpsCamera(Input);

            fpsCamara.MovementSpeed = 200f;
            fpsCamara.JumpSpeed     = 200f;
            fpsCamara.SetCamera(new TGCVector3(133.0014f, 264.8258f, -119.0311f), new TGCVector3(498.1584f, -299.4199f, 621.433f));
            Camera = fpsCamara;

            //Crear Modifier especial para este editor
            modifier = AddRoomsEditorModifier(this);
        }
Exemple #2
0
        private void InitCamera()
        {
            // Usar Coordenadas Originales del HeightMap [-32,32]
            var posicionCamaraX = -4;
            var posicionCamaraZ = -6;
            var posicionCamaraY = terreno.CalcularAlturaTerreno(posicionCamaraX, posicionCamaraZ);

            var alturaOjos = 0f;

            var cameraPosition  = new Vector3(posicionCamaraX * terreno.SceneScaleXZ, posicionCamaraY * terreno.SceneScaleY + alturaOjos, posicionCamaraZ * terreno.SceneScaleXZ);
            var cameraLookAt    = new Vector3(0, 0.5f, -1);
            var cameraMoveSpeed = 7000;
            var cameraJumpSpeed = 30000f;

            // Creo la cámara y defino la Posición y LookAt
            Camara = new TgcFpsCamera(this, cameraPosition, cameraMoveSpeed, cameraJumpSpeed, Input);
            Camara.SetCamera(cameraPosition, cameraLookAt);
        }
        public SceneEditorModifier(TgcSceneEditor editor)
        {
            InitializeComponent();

            this.editor    = editor;
            parser         = new TgcSceneParser();
            sceneLoader    = new TgcSceneLoader();
            pickingRay     = new TgcPickingRay(editor.Input);
            translateGizmo = new SceneEditorTranslateGizmo(editor.Input);
            helpWindow     = new SceneEditorHelpWindow();

            //openMeshDialog
            openMeshDialog = new OpenFileDialog();
            openMeshDialog.CheckFileExists = true;
            openMeshDialog.Title           = "Seleccionar malla de formato TGC";
            openMeshDialog.Filter          = "-TgcScene.xml |*-TgcScene.xml";
            openMeshDialog.Multiselect     = false;
            //openMeshDialog.InitialDirectory = ToolsModel.Instance.ExamplesMediaDir + "ModelosTgc\\";
            openMeshDialog.FileName = Settings.Default.MediaDirectory + "ModelosTgc\\Box\\Box-TgcScene.xml";
            fileName.Text           = "Box-TgcScene.xml";
            meshFilePath            = openMeshDialog.FileName;

            //openHeighmapDialog
            openHeighmapDialog = new OpenFileDialog();
            openHeighmapDialog.CheckFileExists  = true;
            openHeighmapDialog.Title            = "Seleccionar Heighmap";
            openHeighmapDialog.Filter           = ".JPG|*.jpg|.JPEG|*.jpeg|.GIF|*.gif|.PNG|*.png|.BMP|*.bmp | .TGA |*.tga";
            openHeighmapDialog.Multiselect      = false;
            openHeighmapDialog.InitialDirectory = Settings.Default.MediaDirectory + "Heighmaps\\";

            //openHeighmapDialog
            openTextureDialog = new OpenFileDialog();
            openTextureDialog.CheckFileExists  = true;
            openTextureDialog.Title            = "Seleccionar textura de terreno";
            openTextureDialog.Filter           = ".JPG|*.jpg|.JPEG|*.jpeg|.GIF|*.gif|.PNG|*.png|.BMP|*.bmp | .TGA |*.tga";
            openTextureDialog.Multiselect      = false;
            openTextureDialog.InitialDirectory = Settings.Default.MediaDirectory + "Heighmaps\\";

            //saveSceneDialog
            saveSceneDialog              = new SaveFileDialog();
            saveSceneDialog.DefaultExt   = ".xml";
            saveSceneDialog.Filter       = ".XML |*.xml";
            saveSceneDialog.AddExtension = true;

            SelectedMeshList = new List <SceneEditorMeshObject>();

            //Estado inicial
            currentState           = GuiState.Nothing;
            tabControl.SelectedTab = tabControl.TabPages["tabPageCreate"];

            //Camaras
            var pos      = new TGCVector3(50.406f, 185.5353f, -143.7283f);
            var lookAt   = new TGCVector3(-92.5515f, -567.6361f, 498.3744f);
            var upVector = TGCVector3.Up;

            BasicCamera = new TgcCamera();
            BasicCamera.SetCamera(pos, lookAt, upVector);

            FPSCamera = new TgcFpsCamera(editor.Input);
            FPSCamera.SetCamera(pos, lookAt, upVector);

            editor.Camera = FPSCamera;
        }
Exemple #4
0
        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);
        }