Exemple #1
0
        public void MoveOrientedY(float movement)
        {
            var z = FastMath.Cos(Rotation.Y) * movement;
            var x = FastMath.Sin(Rotation.Y) * movement;

            Move(x, 0, z);
        }
Exemple #2
0
        public override void update(float Tiempo)
        {
            ControladorJuego instanciaControlador = ControladorJuego.getInstance();

            this.mantenerseEnAtaque(instanciaControlador.personaje, Tiempo, instanciaControlador.objetosColisionablesDinamicos.FindAll(x => !x.Equals(this.mesh4.BoundingBox)));

            PosicionActual = mesh4.Position;
            mesh4.Scale    = C_Altura;
            xTiempo++;
            if (!disparando)
            {
                disparando    = true;
                TiempoDisparo = xTiempo;
                frenteTanque  = new Vector3(0 - 13 * (FastMath.Sin(this.mesh4.Rotation.Y)),
                                            0,
                                            0 - 13 * (FastMath.Cos(this.mesh4.Rotation.Y)));

                misil.PosicionDisparo(this.mesh4.Position, frenteTanque);
                misil.update(Tiempo);
            }

            if ((disparando) && (xTiempo >= TiempoDisparo * 100))
            {
                disparando = false;
                xTiempo    = 1;
            }

            misil.update(Tiempo);

            //misil.setPosicionInicial(GuiController.Instance.ThirdPersonCamera.getPosition());
        }
Exemple #3
0
 private float AngleDistance(float a, float b)
 {
     //float c = b - a + FastMath.PI;
     //float mod = c - FastMath.Floor(c / FastMath.PI_HALF) * FastMath.PI - FastMath.PI_HALF;
     //return mod;
     return(FastMath.Atan2(FastMath.Sin(b - a), FastMath.Cos(b - a)));
 }
Exemple #4
0
        private Vector3 PosicionEnemigo()
        {
            Vector3 posicion;
            bool posicionEnTerreno;

            do
            {
                // hacer un spawn random del enemigo dentro de una distancia del jugador
                Vector3 posicionPlayer = GuiController.Instance.CurrentCamera.getPosition();

                int distanciaRandom = randomEnemigosAdmin.Next(160, 300);
                float anguloRandom = ((float)randomEnemigosAdmin.Next(0, 100) / 50) * FastMath.PI;

                float posicionX = distanciaRandom * FastMath.Cos(anguloRandom);
                float posicionZ = distanciaRandom * FastMath.Sin(anguloRandom);

                posicion = new Vector3((int)(posicionPlayer.X + posicionX), 0, (int)(posicionPlayer.Z + posicionZ));

                posicionEnTerreno = true;
                posicionEnTerreno = posicionEnTerreno && posicion.X > limiteTerrenoInferior.X;
                posicionEnTerreno = posicionEnTerreno && posicion.Z > limiteTerrenoInferior.Z;
                posicionEnTerreno = posicionEnTerreno && posicion.X < limiteTerrenoSuperior.X;
                posicionEnTerreno = posicionEnTerreno && posicion.Z < limiteTerrenoSuperior.Z;

            } while (posicionEnTerreno == false);

            return posicion;
        }
Exemple #5
0
        /// <summary>
        /// Mueve la malla en base a la orientacion actual de rotacion.
        /// Es necesario rotar la malla primero
        /// </summary>
        /// <param name="movement">Desplazamiento. Puede ser positivo (hacia adelante) o negativo (hacia atras)</param>
        public void moveOrientedY(float movement)
        {
            float z = FastMath.Cos(rotation.Y) * movement;
            float x = FastMath.Sin(rotation.Y) * movement;

            move(x, 0, z);
        }
        public virtual void Actualizar(float valor)
        {
            posicionActual = valor;
            var x = a.X * FastMath.Cos(posicionActual);
            var y = b.Y * FastMath.Sin(posicionActual);

            mesh.Position = new Vector3(x, y, mesh.Position.Z);
        }
Exemple #7
0
        override public void mover(float elapsedTime)
        {
            movimientoVela += elapsedTime;
            var random  = FastMath.Cos(6 * movimientoVela);
            var random2 = FastMath.Cos(12 * movimientoVela);

            vela1.Meshes[0].Rotation = new Vector3(Geometry.DegreeToRadian(-5f + random2), Geometry.DegreeToRadian(-14f + random), Geometry.DegreeToRadian(0f));
        }
Exemple #8
0
        override public void mover(float elapsedTime)
        {
            movimientoLinterna += elapsedTime;
            var random  = FastMath.Cos(6 * movimientoLinterna);
            var random2 = FastMath.Cos(12 * movimientoLinterna);

            linterna.Meshes[0].Rotation = new Vector3(Geometry.DegreeToRadian(-350f + random2), Geometry.DegreeToRadian(180f + random), Geometry.DegreeToRadian(-270f));
        }
Exemple #9
0
        /************************* PARTES DEL BARCO ****************************/

        public Vector3 proa()
        {
            Vector3 offsetProa = new Vector3(FastMath.Sin(anguloRotacion), 0, FastMath.Cos(anguloRotacion));
            Vector3 proa       = getPosition() - offsetProa * (LargoBote / 2);

            proa.Y = 0;

            return(proa);
        }
Exemple #10
0
        public Vector3 popa()
        {
            Vector3 offsetPopa = new Vector3(FastMath.Sin(anguloRotacion), 0, FastMath.Cos(anguloRotacion));
            Vector3 popa       = getPosition() + offsetPopa * (LargoBote / 2);

            popa.Y = 0;

            return(popa);
        }
Exemple #11
0
 private float WindCurve(float x)
 {
     // Curva de viento para arboles, basada en el libro de GPU Gems.
     return
         (FastMath.Cos(x * FastMath.PI) *
          FastMath.Cos(x * 3.0f * FastMath.PI) *
          FastMath.Cos(x * 5.0f * FastMath.PI) *
          FastMath.Cos(x * 7.0f * FastMath.PI) +
          FastMath.Sin(x * 25.0f * FastMath.PI) * 0.1f);
 }
Exemple #12
0
        public void deformacion_esfera()
        {
            timer += ElapsedTime;

            var variacionY = FastMath.Max(2f, 6f * FastMath.Abs(FastMath.Cos(timer * 1.5f)));
            var variacionZ = FastMath.Max(2f, 6f * FastMath.Abs(FastMath.Sin(timer * 1.5f)));

            var escalado = new TGCVector3(6f, variacionY, variacionZ);

            sphereOne.Transform = TGCMatrix.RotationY(timer) * TGCMatrix.Scaling(escalado) * TGCMatrix.Translation(spheresCenter);
        }
Exemple #13
0
        /// <param name="elapsedTime">Tiempo en segundos transcurridos desde el último frame</param>
        public override void render(float elapsedTime)
        {
            float moveForward = 0;
            float jump        = 0;



            //Device de DirectX para renderizar
            Device d3dDevice = GuiController.Instance.D3dDevice;


            //conviene deshabilitar ambas camaras para que no haya interferencia

            //Capturar Input teclado
            if (GuiController.Instance.D3dInput.keyDown(Microsoft.DirectX.DirectInput.Key.F))
            {
                moveForward = 100 * elapsedTime;
                //Tecla F apretada
            }

            if (GuiController.Instance.D3dInput.keyDown(Microsoft.DirectX.DirectInput.Key.Space))
            {
                jump = 100 * elapsedTime;
            }

            //Capturar Input Mouse
            if (GuiController.Instance.D3dInput.buttonPressed(TgcViewer.Utils.Input.TgcD3dInput.MouseButtons.BUTTON_LEFT))
            {
                //Boton izq apretado
            }

            Vector3 movementVector = new Vector3(
                FastMath.Sin(sphere.Rotation.Y) * moveForward,
                jump,
                FastMath.Cos(sphere.Rotation.Y) * moveForward
                );

            Vector3 realMovement = collisionManager.moveCharacter(sphere.BoundingSphere, movementVector, objetosColisionables);

            sphere.move(realMovement);

            sphere.updateValues();
            scene.renderAll();
            sphere.render();
            GuiController.Instance.RotCamera.CameraCenter = sphere.Position;

            //Mover Auto
            //mainCar.elapsedTime = elapsedTime;
            //mainCar.Mover();
            //

            //mainCar.meshAuto.render();
            //SetCarCamera();
        }
Exemple #14
0
        public float angulo(Vector3 puntoObjetivo, Vector3 miPosicion)
        {
            float componenteX = FastMath.Sin(rotacion.Y);
            float componenteZ = FastMath.Cos(rotacion.Y);

            Vector3 v3 = new Vector3(puntoObjetivo.X - miPosicion.X, 0, puntoObjetivo.Z - miPosicion.Z);
            Vector3 v4 = new Vector3(componenteX, 0, componenteZ);
            Vector3 vectorPerpendicular = Vector3.Cross(v3, v4);

            return(vectorPerpendicular.Y);
        }
Exemple #15
0
        private bool estaALaIzquierda(Vector3 puntoObjetivo, Vector3 miPosicion)
        {
            float componenteX = FastMath.Sin(rotacion.Y);
            float componenteZ = FastMath.Cos(rotacion.Y);

            Vector3 v3 = new Vector3(puntoObjetivo.X - miPosicion.X, 0, puntoObjetivo.Z - miPosicion.Z);
            Vector3 v4 = new Vector3(componenteX, 0, componenteZ);
            Vector3 vectorPerpendicular = Vector3.Cross(v3, v4);

            return(vectorPerpendicular.Y < -0.2f);
        }
Exemple #16
0
        private void moverse(float elapsedTime, Terreno terreno)
        {
            //Aplicamos el movimiento
            //TODO Ver si es correcta la forma que aplico para representar que se esta a la altura del terreno.
            var xm             = FastMath.Sin(Mesh.Rotation.Y) * velocidadCaminar;
            var zm             = FastMath.Cos(Mesh.Rotation.Y) * velocidadCaminar;
            var movementVector = new Vector3(xm, 0, zm);

            Mesh.move(movementVector * elapsedTime);
            Mesh.Position = new Vector3(Mesh.Position.X, terreno.CalcularAltura(Mesh.Position.X, Mesh.Position.Z),
                                        Mesh.Position.Z);
        }
        public override void Update(float ElapsedTime)
        {
            Moment += ElapsedTime;
            while (Moment >= Period)
            {
                Moment -= Period;
            }
            var old = Mesh.Position;

            Mesh.Position = new TGCVector3(Pos.X + Radio * FastMath.Cos((Moment / Period) * FastMath.TWO_PI), Pos.Y, Pos.Z + Radio * FastMath.Sin((Moment / Period) * FastMath.TWO_PI));
            Delta         = Mesh.Position - old;
        }
Exemple #18
0
        public void Render(GameModel gameModel)
        {
            // Mini Viewport
            device.Viewport = view;

            var posOriginal = mesh.Position;
            var cam         = (TgcThirdPersonCamera)gameModel.Camara;

            time += gameModel.ElapsedTime;
            var asd = gameModel.Camara.LookAt - gameModel.Camara.Position;

            asd.Normalize();
            asd *= 4.85f;

            if (player1.SelectedWeapon != null)
            {
                mesh.Position = gameModel.Camara.Position + asd;
                mesh.Rotation = new TGCVector3(0, cam.RotationY, 0);
                mesh.RotateY(FastMath.Cos(time * 3) * 1.3f);
                mesh.Render();
            }

            device.Viewport = original_view;

            // Dibujar los Sprites
            drawer2D.BeginDrawSprite();
            drawer2D.DrawSprite(hudSprites);
            drawer2D.DrawSprite(healthBar);
            drawer2D.DrawSprite(specialBar);
            drawer2D.EndDrawSprite();

            // Renderizar Texto
            if (speed.Text.Contains("-"))
            {
                speed.Color = Color.IndianRed;
            }
            else
            {
                speed.Color = Color.Green;
            }

            speed.render();
            km.render();
            weaponName.render();
            ammoQuantity.render();
            reloj.render();

            if (player1.turbo)
            {
                turbo.render();
            }
        }
Exemple #19
0
        public void giro_en_plano()
        {
            timer += ElapsedTime;

            var posicion = new TGCVector3(radio * FastMath.Sin(timer), 0f, radio * FastMath.Cos(timer));

            var posicionNormalizada = posicion;

            posicionNormalizada.Normalize();
            var quaternion = TGCQuaternion.RotationAxis(posicionNormalizada, -timer * 5f);

            sphereOne.Transform = TGCMatrix.Scaling(spheresScale) * TGCMatrix.RotationTGCQuaternion(quaternion) * TGCMatrix.Translation(posicion + new TGCVector3(0f, 4f, 0f));
        }
Exemple #20
0
        public override void calcularTraslacionYRotacion(float elapsedTime, TerrenoSimple agua, float time, Vector3 lastPosition)
        {
            distance = player.popa() - this.getPosition();
            Vector3 iaDirectionVersor = this.vectorDireccion();

            iaDirectionVersor.Normalize();
            Vector3 lookAtPopaVersor = new Vector3(distance.X, distance.Y, distance.Z);

            lookAtPopaVersor.Normalize();

            float   rotationAngle = FastMath.Acos(Vector3.Dot(iaDirectionVersor, lookAtPopaVersor));
            Vector3 cross         = Vector3.Cross(lookAtPopaVersor, iaDirectionVersor);

            //Vector3 lastPosition = getPosition();

            if (cross.Length() > 0.1)
            {
                if (cross.Y > 0.1)
                {
                    anguloRotacion -= elapsedTime * ROTATION_SPEED;
                }
                if (cross.Y < -0.1)
                {
                    anguloRotacion += elapsedTime * ROTATION_SPEED;
                }

                rotacion = Matrix.RotationY(anguloRotacion);
            }

            if (FastMath.Abs(distance.Length()) > 1000)
            {
                movementSpeed = Math.Min(movementSpeed + ESCALON_VEL, VEL_MAXIMA);
            }
            if (FastMath.Abs(distance.Length()) <= 1000)
            {
                if (FastMath.Abs(distance.Length()) > 400)
                {
                    movementSpeed = Math.Max(movementSpeed - movementSpeed / distance.Length(), 0);
                }
                else
                {
                    movementSpeed = 0;
                }
            }

            movZ -= movementSpeed * FastMath.Cos(anguloRotacion) * elapsedTime;
            movX -= movementSpeed * FastMath.Sin(anguloRotacion) * elapsedTime;
            movY  = agua.aplicarOlasA(getPosition(), time).Y + AltoBote / 2;

            administrarColisiones(lastPosition, new Vector3(movX, movY, movZ));
        }
 public void execute()
 {
     if (model.Input.keyDown(Key.Down) || model.Input.keyDown(Key.S))
     {
         TGCVector3 movement = new TGCVector3
         {
             X = (-1) * FastMath.Sin(model.DirectorAngle),
             Y = 0,
             Z = (-1) * FastMath.Cos(model.DirectorAngle)
         };
         model.BandicootMovement      = movement;
         model.BandicootCamera.Target = model.Bandicoot.Position;
     }
 }
        public void execute()
        {
            if (model.Input.keyDown(Key.Up) || model.Input.keyDown(Key.W))
            {
                TGCVector3 movement = new TGCVector3
                {
                    X = FastMath.Sin(model.DirectorAngle),
                    Y = 0,
                    Z = FastMath.Cos(model.DirectorAngle)
                };

                model.BandicootMovement = movement;
            }
        }
Exemple #23
0
        public void Update(float ElapsedTime)
        {
            Moment += ElapsedTime;
            while (Moment >= Period)
            {
                Moment -= Period;
            }
            var t = Body.CenterOfMassTransform;
            var p = new Vector3(Pos.X + Radio * FastMath.Cos((Moment / Period) * FastMath.TWO_PI), Pos.Y, Pos.Z + Radio * FastMath.Sin((Moment / Period) * FastMath.TWO_PI));

            Delta    = p - t.Origin;
            t.Origin = p;
            Body.CenterOfMassTransform = t;
        }
Exemple #24
0
        public void Update(float ElapsedTime, Vector3 MeshPosition, float Rotation)
        {
            float rohumo, alfa_humo;
            float posicion_xhumo;
            float posicion_yhumo;

            rohumo = FastMath.Sqrt(this.posicionHumo.X * this.posicionHumo.X + this.posicionHumo.Y * this.posicionHumo.Y);

            alfa_humo = FastMath.Asin(this.posicionHumo.X / rohumo);
            posicion_xhumo = FastMath.Sin(alfa_humo + Rotation) * rohumo;
            posicion_yhumo = FastMath.Cos(alfa_humo + Rotation) * rohumo;

            this.ElapsedTime = ElapsedTime;
            this.emitter.Position = MeshPosition + new Vector3 (posicion_xhumo, 5, posicion_yhumo);
        }
        /// <summary>
        ///     Construye el mesh del BoundingSphere
        /// </summary>
        private void updateValues()
        {
            if (vertices == null)
            {
                var verticesCount = (SPHERE_MESH_RESOLUTION * 2 + 2) * 3;
                vertices = new CustomVertex.PositionColored[verticesCount];
            }

            var index = 0;

            var step = FastMath.TWO_PI / SPHERE_MESH_RESOLUTION;

            // Plano XY
            for (var a = 0f; a <= FastMath.TWO_PI; a += step)
            {
                vertices[index++] =
                    new CustomVertex.PositionColored(
                        new Vector3(FastMath.Cos(a) * Radius, FastMath.Sin(a) * Radius, 0f) + Center, RenderColor);
                vertices[index++] =
                    new CustomVertex.PositionColored(
                        new Vector3(FastMath.Cos(a + step) * Radius, FastMath.Sin(a + step) * Radius, 0f) + Center,
                        RenderColor);
            }

            // Plano XZ
            for (var a = 0f; a <= FastMath.TWO_PI; a += step)
            {
                vertices[index++] =
                    new CustomVertex.PositionColored(
                        new Vector3(FastMath.Cos(a) * Radius, 0f, FastMath.Sin(a) * Radius) + Center, RenderColor);
                vertices[index++] =
                    new CustomVertex.PositionColored(
                        new Vector3(FastMath.Cos(a + step) * Radius, 0f, FastMath.Sin(a + step) * Radius) + Center,
                        RenderColor);
            }

            // Plano YZ
            for (var a = 0f; a <= FastMath.TWO_PI; a += step)
            {
                vertices[index++] =
                    new CustomVertex.PositionColored(
                        new Vector3(0f, FastMath.Cos(a) * Radius, FastMath.Sin(a) * Radius) + Center, RenderColor);
                vertices[index++] =
                    new CustomVertex.PositionColored(
                        new Vector3(0f, FastMath.Cos(a + step) * Radius, FastMath.Sin(a + step) * Radius) + Center,
                        RenderColor);
            }
        }
Exemple #26
0
        //mueve el barco y su boundingspehere en Y; hay que refactorearlo...
        //mueve el barco y su boundingspehere en Y; hay que refactorearlo...
        virtual public void flotar()
        {
            //normal del mar en el punto donde se encuentra el barco
            normal = Oceano.normalEnPuntoXZ(this.Position.X, this.Position.Z);

            //altura del mar en el punto de se encuentra el barco
            float Y = Oceano.alturaEnPunto(this.Position.X, this.Position.Z);

            //ponemos el bounding sphere a la altura donde esta el barco
            this.boundingSphere.moveCenter(new Vector3(0, Y - boundingSphere.Position.Y + 40, 0));

            //ubicamos al barco...
            this.Position   = new Vector3(this.Position.X, Y - 15, this.Position.Z);                                                                                    // ...en alto...
            this.rotation.Z = FastMath.Atan2(-normal.X * FastMath.Cos(this.rotation.Y), normal.Y) + FastMath.Atan2(normal.Z * FastMath.Sin(this.rotation.Y), normal.Y); // ...con rotacion en Z...
            this.rotation.X = FastMath.Atan2(normal.Z * FastMath.Cos(this.rotation.Y), normal.Y) + FastMath.Atan2(normal.X * FastMath.Sin(this.rotation.Y), normal.Y);  // ...con rotacion en Y...
        }
Exemple #27
0
        public override void render(float elapsedTime)
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;


            // 1) Crear un vector en 3D
            Vector3 v = new Vector3(0, 19, -1759.21f);


            // 2) Producto escalar entre dos vectores (dot product)
            Vector3 v1        = new Vector3(0, 19, -1759.21f);
            Vector3 v2        = new Vector3(0, 19, -1759.21f);
            float   dotResult = Vector3.Dot(v1, v2);


            // 3) Producto vectorial entre dos vectores (cross product). El orden de v1 y v2 influye en la orientacion del resultado
            Vector3 crossResultVec = Vector3.Cross(v1, v2);


            // 4) Distancia entre dos puntos
            Vector3 p1                = new Vector3(100, 200, 300);
            Vector3 p2                = new Vector3(1000, 2000, 3000);
            float   distancia         = Vector3.Length(p2 - p1);
            float   distanciaCuadrada = Vector3.LengthSq(p2 - p1); //Es mas eficiente porque evita la raiz cuadrada (pero te da el valor al cuadrado)


            // 5) Normalizar vector
            Vector3 norm = Vector3.Normalize(v1);


            // 6) Obtener el ángulo que hay entre dos vectores que están en XZ, expresion A.B=|A||B|cos(a)
            Vector3 v3    = new Vector3(-1, 0, 19);
            Vector3 v4    = new Vector3(3, 0, -5);
            float   angle = FastMath.Acos(Vector3.Dot(Vector3.Normalize(v3), Vector3.Normalize(v4))); //Tienen que estar normalizados


            // 7) Tenemos un objeto que rota un cierto ángulo en Y (ej: un auto) y queremos saber los componentes X,Z para donde tiene que avanzar al moverse
            float   rotacionY           = FastMath.PI_HALF;
            float   componenteX         = FastMath.Sin(rotacionY);
            float   componenteZ         = FastMath.Cos(rotacionY);
            float   velocidadMovimiento = 100; //Ojo que este valor deberia siempre multiplicarse por el elapsedTime
            Vector3 movimientoAdelante  = new Vector3(componenteX * velocidadMovimiento, 0, componenteZ * velocidadMovimiento);



            GuiController.Instance.Text3d.drawText("Este ejemplo no muestra nada por pantalla. Sino que es para leer el código y sus comentarios.", 5, 50, Color.Yellow);
        }
Exemple #28
0
        public void update(float elapsedTime, Vector3 normal, float rotacionAuto, Vector3 posicionAuto, float anguloDerrape, float direcGiroDerrape, bool nitro, float autoVelocidad)
        {
            int i = 0;

            foreach (HumoParticula particula in quadPool)
            {
                float rohumo, alfa_humo;
                float posicion_xhumo;
                float posicion_yhumo;
                rohumo = FastMath.Sqrt(-particula.posX * -particula.posX + particula.posZ * particula.posZ);

                alfa_humo      = FastMath.Asin(particula.posX / rohumo);
                posicion_xhumo = FastMath.Sin(alfa_humo + rotacionAuto + (anguloDerrape * direcGiroDerrape)) * rohumo;
                posicion_yhumo = FastMath.Cos(alfa_humo + rotacionAuto + (anguloDerrape * direcGiroDerrape)) * rohumo;



                particula.setPosicion(new Vector3(posicion_xhumo, 16.0f, posicion_yhumo) + posicionAuto);
                i++;

                particula.disminuirVida(2 * elapsedTime, FastMath.Max(0.3f, autoVelocidad / 300f));

                if (nitro)
                {
                    particula.setTextura(TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "TheC#\\Particulas\\Textures\\fuego.png"));
                }
                else
                {
                    particula.setTextura(TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "TheC#\\Particulas\\Textures\\humo.png"));
                }

                if (particula.tiempoDeVida < 0.0f)
                {
                    int random1 = random.Next(10) - 5;
                    int random2 = random.Next(30) - 15;
                    particula.resetear(3.0f, new List <float> {
                        -19f + random1, 126f + random2
                    });
                }

                particula.setNormal(new Vector3(0, rotacionAuto, 0));

                particula.calcularAlpha();
                particula.calcularTamanio();
            }
        }
        public override void Render()
        {
            PreRender();

            // 1) Crear un vector en 3D
            var v = new TGCVector3(0, 19, -1759.21f);

            // 2) Producto escalar entre dos vectores (dot product)
            var v1        = new TGCVector3(0, 19, -1759.21f);
            var v2        = new TGCVector3(0, 19, -1759.21f);
            var dotResult = TGCVector3.Dot(v1, v2);

            // 3) Producto vectorial entre dos vectores (cross product). El orden de v1 y v2 influye en la orientacion del resultado
            var crossResultVec = TGCVector3.Cross(v1, v2);

            // 4) Distancia entre dos puntos
            var p1                = new TGCVector3(100, 200, 300);
            var p2                = new TGCVector3(1000, 2000, 3000);
            var distancia         = TGCVector3.Length(p2 - p1);
            var distanciaCuadrada = TGCVector3.LengthSq(p2 - p1);
            //Es mas eficiente porque evita la raiz cuadrada (pero te da el valor al cuadrado)

            // 5) Normalizar vector
            var norm = TGCVector3.Normalize(v1);

            // 6) Obtener el angulo que hay entre dos vectores que estan en XZ, expresion A.B=|A||B|cos(a)
            var v3    = new TGCVector3(-1, 0, 19);
            var v4    = new TGCVector3(3, 0, -5);
            var angle = FastMath.Acos(TGCVector3.Dot(TGCVector3.Normalize(v3), TGCVector3.Normalize(v4)));
            //Tienen que estar normalizados

            // 7) Tenemos un objeto que rota un cierto angulo en Y (ej: un auto) y queremos saber los componentes X,Z para donde tiene que avanzar al moverse
            var   rotacionY           = FastMath.PI_HALF;
            var   componenteX         = FastMath.Sin(rotacionY);
            var   componenteZ         = FastMath.Cos(rotacionY);
            float velocidadMovimiento = 100; //Ojo que este valor deberia siempre multiplicarse por el elapsedTime
            var   movimientoAdelante  = new TGCVector3(componenteX * velocidadMovimiento, 0, componenteZ * velocidadMovimiento);

            DrawText.drawText(
                "Este ejemplo no muestra nada por pantalla. Sino que es para leer el codigo y sus comentarios.", 5, 50,
                Color.Yellow);

            PostRender();
        }
        public void Update(float ElapsedTime, Vector3 MeshPosition, float Rotation)
        {
            float rohumo, alfa_choque;
            float posicion_xchoque;
            float posicion_ychoque;

            if (this.ChoqueAdelanteIzquierda)
            {
                posicionChoque = new Vector2(-45, 40);
            }

            if (this.ChoqueAdelanteDerecha)
            {
                posicionChoque = new Vector2(0, 40);
            }

            if (this.ChoqueAtrasIzquierda)
            {
                posicionChoque = new Vector2(30, 35);
            }

            if (this.ChoqueAtrasDerecha)
            {
                posicionChoque = new Vector2(0, 35);
            }

            rohumo = FastMath.Sqrt(this.posicionChoque.X * this.posicionChoque.X + this.posicionChoque.Y * this.posicionChoque.Y);

            alfa_choque = FastMath.Asin(this.posicionChoque.X / rohumo);

            if (this.ChoqueAdelanteIzquierda || this.ChoqueAdelanteDerecha)
            {
                alfa_choque += FastMath.PI;
            }

            posicion_xchoque = FastMath.Sin(alfa_choque + Rotation) * rohumo;
            posicion_ychoque = FastMath.Cos(alfa_choque + Rotation) * rohumo;

            this.ElapsedTime      = ElapsedTime;
            this.emitter.Position = MeshPosition + new Vector3(posicion_xchoque, 20, posicion_ychoque);
        }