Exemplo n.º 1
0
        public void SphereCast(AGKVector3 rFrom, AGKVector3 rTo, float rRadius, bool rSlide)
        {
            Agk.SetVector3(FromVectorNumber, rFrom.X, rFrom.Y, rFrom.Z);
            Agk.SetVector3(ToVectorNumber, rTo.X, rTo.Y, rTo.Z);
            Agk.SphereCast3DPhysics(ResourceNumber, (int)FromVectorNumber, (int)ToVectorNumber, rRadius);
            HitObjectNumber = (uint)Agk.Get3DPhysicsRayCastObjectHit(ResourceNumber, Agk.Get3DPhysicsRayCastFraction(ResourceNumber));
            if (HitObjectNumber > 0)
            {
                Agk.Get3DPhysicsRayCastContactPosition(ResourceNumber, Agk.Get3DPhysicsRayCastFraction(ResourceNumber), (int)HitVectorNumber);
                HitPosition.X = Agk.GetVector3X(HitVectorNumber);
                HitPosition.Y = Agk.GetVector3Y(HitVectorNumber);
                HitPosition.Z = Agk.GetVector3Z(HitVectorNumber);

                if (!rSlide)
                {
                    return;
                }

                Agk.Get3DPhysicsRayCastNormalVector(ResourceNumber, (int)HitVectorNumber);

                if (Math.Abs(HitNormalVector.Y) > 0.999)
                {
                    SlideVector = new AGKVector3(HitNormalVector.Y, 0.0f, 0.0f);
                }
                else
                {
                    SlideVector = new AGKVector3(-HitNormalVector.Z, 0.0f, HitNormalVector.X).Normalize();
                }
                HitPosition *= SlideVector;
            }
        }
Exemplo n.º 2
0
 public void RayCast(AGKVector3 rFrom, AGKVector3 rTo)
 {
     Agk.SetVector3(FromVectorNumber, rFrom.X, rFrom.Y, rFrom.Z);
     Agk.SetVector3(ToVectorNumber, rTo.X, rTo.Y, rTo.Z);
     Agk.RayCast3DPhysics(ResourceNumber, (int)FromVectorNumber, (int)ToVectorNumber, 1);
     HitObjectNumber = (uint)Agk.Get3DPhysicsRayCastObjectHit(ResourceNumber, Agk.Get3DPhysicsRayCastFraction(ResourceNumber));
     if (HitObjectNumber > 0)
     {
         Agk.Get3DPhysicsRayCastContactPosition(ResourceNumber, Agk.Get3DPhysicsRayCastFraction(ResourceNumber), (int)HitVectorNumber);
         HitPosition.X = Agk.GetVector3X(HitVectorNumber);
         HitPosition.Y = Agk.GetVector3Y(HitVectorNumber);
         HitPosition.Z = Agk.GetVector3Z(HitVectorNumber);
     }
 }