Ejemplo n.º 1
0
        private void CalculateSurfaceQuad(OrientedBoxRayHit boxRayHit)
        {
            OrientedBox      hitBox = boxRayHit.HitBox;
            CoordinateSystem pickedFaceCoordSystem = hitBox.GetBoxFaceCoordinateSystem(boxRayHit.HitFace);

            _surfaceQuad = new XZOrientedQuad3D(pickedFaceCoordSystem.GetOriginPosition(),
                                                hitBox.GetBoxFaceSizeAlongFaceLocalXZAxes(boxRayHit.HitFace),
                                                pickedFaceCoordSystem.GetRotation());
        }
Ejemplo n.º 2
0
        public bool Raycast(Ray ray, out OrientedBoxRayHit boxRayHit)
        {
            boxRayHit = null;
            float t;

            if (Raycast(ray, out t))
            {
                boxRayHit = new OrientedBoxRayHit(ray, t, this);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        public GameObjectRayHit(Ray ray, GameObject hitObject, OrientedBoxRayHit objectBoxHit, MeshRayHit objectMeshHit, TerrainRayHit objectTerrainHit, SpriteRayHit objectSpriteHit)
        {
            _ray       = ray;
            _hitObject = hitObject;

            // Only one kind of entity can be registered as a hit, so we will take the first
            // non-null hit instance using the following priority: terrain, mesh, sprite, box.
            if (objectTerrainHit != null)
            {
                _objectTerrainHit = objectTerrainHit;
                _objectBoxHit     = null;
                _objectMeshHit    = null;
                _objectSpriteHit  = null;
            }
            else
            if (objectMeshHit != null)
            {
                _objectTerrainHit = null;
                _objectBoxHit     = null;
                _objectMeshHit    = objectMeshHit;
                _objectSpriteHit  = null;
            }
            else
            if (objectSpriteHit != null)
            {
                _objectTerrainHit = null;
                _objectBoxHit     = null;
                _objectMeshHit    = null;
                _objectSpriteHit  = objectSpriteHit;
            }
            if (objectBoxHit != null)
            {
                _objectTerrainHit = null;
                _objectBoxHit     = objectBoxHit;
                _objectMeshHit    = null;
                _objectSpriteHit  = null;
            }
        }