public void Update(float elapsedTime)
        {
            TGCQuaternion rotationX  = TGCQuaternion.RotationAxis(new TGCVector3(0.0f, 1.0f, 0.0f), Geometry.DegreeToRadian(90f /* + anguloEntreVectores*15*/));
            TGCVector3    PosicionA  = posicionInicial;
            TGCVector3    PosicionB  = jugador.GetPosicion();
            TGCVector3    DireccionA = new TGCVector3(0, 0, -1);
            TGCVector3    DireccionB = PosicionB - PosicionA;

            if (DireccionB.Length() >= 15f && PosicionA.Z > PosicionB.Z + 10f)
            {
                DireccionB.Normalize();
                // anguloEntreVectores = (float)Math.Acos(TGCVector3.Dot(DireccionA, DireccionB));

                var cross       = TGCVector3.Cross(DireccionA, DireccionB);
                var newRotation = TGCQuaternion.RotationAxis(cross, FastMath.Acos(TGCVector3.Dot(DireccionA, DireccionB)));
                quaternionAuxiliar = rotationX * newRotation;
                mainMesh.Transform = baseScaleRotation *
                                     TGCMatrix.RotationTGCQuaternion(rotationX * newRotation) *
                                     baseQuaternionTranslation;
            }
            else
            {
                mainMesh.Transform = baseScaleRotation *
                                     TGCMatrix.RotationTGCQuaternion(quaternionAuxiliar) *
                                     baseQuaternionTranslation;
            }
            //codigo de prueba------
            tiempo += .1f + elapsedTime;
            if (tiempo > 15f)
            {
                Disparar(PosicionB);
                tiempo = 0f;
            }
            //--------
        }
Exemple #2
0
        private bool naveAvanzoLoSuficiente()
        {
            float posZ = nave.GetPosicion().Z;

            if (numeroBloques == 1)
            {
                return(posZ > tamanioZBloques / 2);
            }
            return(posZ > tamanioZBloques * (numeroBloques - 1) + tamanioZBloques / 2);
        }