Пример #1
0
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Paths para archivo XML de la malla
            string pathMesh = GuiController.Instance.ExamplesMediaDir + "KeyframeAnimations\\Robot\\Robot-TgcKeyFrameMesh.xml";
            
            //Path para carpeta de texturas de la malla
            string mediaPath = GuiController.Instance.ExamplesMediaDir + "KeyframeAnimations\\Robot\\";

            //Lista de animaciones disponibles
            string[] animationList = new string[]{
                "Parado",
                "Caminando",
                "Correr",
                "PasoDerecho",
                "PasoIzquierdo",
                "Empujar",
                "Patear",
                "Pegar",
                "Arrojar",
            };

            //Crear rutas con cada animacion
            string[] animationsPath = new string[animationList.Length];
            for (int i = 0; i < animationList.Length; i++)
            {
                animationsPath[i] = mediaPath + animationList[i] + "-TgcKeyFrameAnim.xml";
            }

            //Cargar mesh y animaciones
            TgcKeyFrameLoader loader = new TgcKeyFrameLoader();
            mesh = loader.loadMeshAndAnimationsFromFile(pathMesh, mediaPath, animationsPath);

            //Agregar combo para elegir animacion
            GuiController.Instance.Modifiers.addInterval("animation", animationList, 0);
            selectedAnim = animationList[0];

            //Modifier para especificar si la animación se anima con loop
            animateWithLoop = true;
            GuiController.Instance.Modifiers.addBoolean("loop", "Loop anim:", animateWithLoop);

            //Modifier para color
            currentColor = Color.White;
            GuiController.Instance.Modifiers.addColor("Color", currentColor);

            //Modifier para BoundingBox
            GuiController.Instance.Modifiers.addBoolean("BoundingBox", "BoundingBox:", false);

            //Elegir animacion Caminando
            mesh.playAnimation(selectedAnim, true);


            //Configurar camara
            GuiController.Instance.RotCamera.setCamera(new Vector3(0, 70, 0), 200);
        }
        public override void init()
        {

            Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice;


            //Crear loader
            TgcKeyFrameLoader loader = new TgcKeyFrameLoader();

            //Crear piso
            TgcTexture pisoTexture = TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesMediaDir + "Texturas\\tierra.jpg");
            piso = TgcBox.fromSize(new Vector3(0, -60, 0), new Vector3(1000, 5, 1000), pisoTexture);

            String mediaDir = CommandosUI.Instance.MediaDir;
           

           //Cargar modelo con una animación Key Frame
            string pathMesh = mediaDir  + "Pez//" + "pez-TgcKeyFrameMesh.xml";
            string[] animationsPath = new string[] {
                mediaDir + "Pez//Animaciones//nadar-TgcKeyFrameAnim.xml",
                mediaDir + "Pez//Animaciones//quieto-TgcKeyFrameAnim.xml"
            };
            personaje = (TgcKeyFrameMesh)loader.loadMeshAndAnimationsFromFile(pathMesh, animationsPath);

            personaje.playAnimation("quieto");

            //Sonido

            //Cargar sonido
            sonidoChapoteo = new TgcStaticSound();
            sonidoChapoteo.loadSound(mediaDir+ "Pez//" + "Sound//WATER.WAV");

            //Posicion inicial
            personaje.Position = new Vector3(0, -45, 0);
            personaje.rotateY(Geometry.DegreeToRadian(180f));


             GuiController.Instance.Modifiers.addFloat("speed", 10, 100, 40);
            //Crear un modifier para un ComboBox con opciones
            string[] opciones = new string[] { "Teclas", "Picking"};
            GuiController.Instance.Modifiers.addInterval("Controles", opciones, 0);
            currentControl = "Teclas";

            //Configurar camara en Tercer Persona
            GuiController.Instance.ThirdPersonCamera.Enable = true;
            GuiController.Instance.ThirdPersonCamera.setCamera(personaje.Position, 30, -30);

            //Coordenadas mouse
            GuiController.Instance.UserVars.addVar("Posicion Mouse");



            //Musica :D
            GuiController.Instance.Mp3Player.FileName = mediaDir + "Pez//" + "Music//UWSDWF.mp3";
            GuiController.Instance.Mp3Player.play(true);
            reproduciendo = true;
            GuiController.Instance.Modifiers.addBoolean("Musica", "Reproducir", true);

            //Picking
            pickingRay = new TgcPickingRay();
            collisionPointMesh = TgcBox.fromSize(new Vector3(3, 1, 3), Color.Red);
           
         }