Exemple #1
0
        private Vector3 GetTargetOriginPosition()
        {
            ThirdPersonCamera thirdPersonCamera = m_viewerCamera as ThirdPersonCamera;

            if (thirdPersonCamera != null)
            {
                return((thirdPersonCamera.GetThirdPersonTarget() as Component).ComponentTranslation);
            }
            else
            {
                return(m_viewerCamera.GetEyeVector());
            }
        }
Exemple #2
0
        public void TryCameraCollision(BaseCamera camera)
        {
            ThirdPersonCamera thirdPersonCamera = camera as ThirdPersonCamera;

            if (thirdPersonCamera == null)
            {
                return;
            }

            // Start moving from camera target to it's seek position
            float   distanceFromTargetToCamera = thirdPersonCamera.MaxDistanceFromTargetToCamera;
            Vector3 cameraForwardVector        = thirdPersonCamera.GetEyeSpaceForwardVector();
            Vector3 startPosition = thirdPersonCamera.GetTargetVector();

            float safeInterval = thirdPersonCamera.CameraCollisionSphereRadius;

            for (float interval = safeInterval; interval <= distanceFromTargetToCamera; interval += (thirdPersonCamera.CameraCollisionSphereRadius / 10.0f))
            {
                var intermediatePosition = startPosition - cameraForwardVector * interval;

                FSphere cameraCollisionSphere = new FSphere(intermediatePosition, thirdPersonCamera.CameraCollisionSphereRadius);
                var     boundingBoxes         = GetBoundingBoxesForCameraCollisionTest(ref cameraCollisionSphere, thirdPersonCamera.GetThirdPersonTarget().GetRootComponent());
                if (boundingBoxes.Count > 0)
                {
                    //if (IsCameraCollisionWithBoundingBoxes(ref cameraCollisionSphere, boundingBoxes))
                    //{
                    //    break;
                    //}
                }

                safeInterval = interval;
            }

            thirdPersonCamera.SetDistanceFromTargetToCamera(safeInterval);
        }