コード例 #1
0
ファイル: BSAPIXNA.cs プロジェクト: CassieEllen/opensim
    public bool RayCastGround(BulletWorld pWorld, Vector3 _RayOrigin, float pRayHeight, BulletBody NotMe)
    {
        DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
        if (world != null)
        {
            if (NotMe is BulletBodyXNA && NotMe.HasPhysicalBody)
            {
                CollisionObject AvoidBody = (NotMe as BulletBodyXNA).body;

                IndexedVector3 rOrigin = new IndexedVector3(_RayOrigin.X, _RayOrigin.Y, _RayOrigin.Z);
                IndexedVector3 rEnd = new IndexedVector3(_RayOrigin.X, _RayOrigin.Y, _RayOrigin.Z - pRayHeight);
                using (
                    ClosestNotMeRayResultCallback rayCallback =
                                            new ClosestNotMeRayResultCallback(rOrigin, rEnd, AvoidBody)
                    )
                {
                    world.RayTest(ref rOrigin, ref rEnd, rayCallback);
                    if (rayCallback.HasHit())
                    {
                        IndexedVector3 hitLocation = rayCallback.m_hitPointWorld;
                    }
                    return rayCallback.HasHit();
                }
           }
        }
        return false;
    }
コード例 #2
0
 internal static bool RayCastGround(object pWorld, Vector3 _RayOrigin, float pRayHeight, object NotMe)
 {
     DynamicsWorld world = pWorld as DynamicsWorld;
     if (world != null)
     {
         if (NotMe is CollisionObject || NotMe is RigidBody)
         {
             CollisionObject AvoidBody = NotMe as CollisionObject;
             
             IndexedVector3 rOrigin = new IndexedVector3(_RayOrigin.X, _RayOrigin.Y, _RayOrigin.Z);
             IndexedVector3 rEnd = new IndexedVector3(_RayOrigin.X, _RayOrigin.Y, _RayOrigin.Z - pRayHeight);
             using (
                 ClosestNotMeRayResultCallback rayCallback = new ClosestNotMeRayResultCallback(rOrigin,
                                                                                               rEnd, AvoidBody)
                 )
             {
                 world.RayTest(ref rOrigin, ref rEnd, rayCallback);
                 if (rayCallback.HasHit())
                 {
                     IndexedVector3 hitLocation = rayCallback.m_hitPointWorld;
                     
                 }
                 return rayCallback.HasHit();
             }
        }
     }
     return false;
 }