FlatRedBall CameraHelper

Tagged:

This library adds some features to the FRB Camera class.

Namespace: de.invidit.XNA
TargetFramework: .NET Framework 4
XNA Version: XNA4
Tested with FRB for XNAPC only.

The CameraHelper adds various extension methods to the Camera class.
Just add de.invidit.XNA to your source file and you are able to use the new methods.

Vector3 GetDistanceToScreenCenterInWorld (Vector3 position)
Returns the absolute distance from the specified position to the current center of the cameras view.

Vector2 GetPositionInWorld (Vector3 position)
Returns the world position of a specified position.

Vector2 GetPositionInWorld (Vector2 position)
Returns the world position of a specified position in a specified distance.

Vector2 GetPositionOnScreen (PositionedObject positionedObject)
Returns the position of a specified positioned object on the screen.

Vector2 GetPositionOnScreen (Vector3 position)
Returns the position of a specified position on the screen.

float GetScreenEdgeBottom (this Camera camera)
Returns the bottom screen edge in world coordinate distance of the current camera.

float GetScreenEdgeBottom (float distance)
Returns the bottom screen edge in world coordinate distance.

float GetScreenEdgeLeft (this Camera camera)
Returns the left screen edge in world coordinate distance of the current camera.

float GetScreenEdgeLeft (float distance)
Returns the left screen edge in world coordinate distance.

float GetScreenEdgeRight (this Camera camera)
Returns the right screen edge in world coordinate distance of the current camera.

float GetScreenEdgeRight (float distance)
Returns the right screen edge in world coordinate distance.

float GetScreenEdgeTop (this Camera camera)
Returns the top screen edge in world coordinate distance of the current camera.

float GetScreenEdgeTop (float distance)
Returns the top screen edge in world coordinate distance.

Rectangle GetViewInWorld (this Camera camera)
Returns the view in the world as a rectangle in the distance of the current camera.

Rectangle GetViewInWorld (float distance)
Returns the view in the world as a rectangle in the specified distance.

bool IsPointInView (Vector3 position, float edgeTolerance)
Returns whether a specified point is inside the current cameras view.

void MoveCameraDown (float distance)
Moves the camera downwards.

void MoveCameraLeft (float distance)
Moves the camera to the left.

void MoveCameraRight (float distance)
Moves the camera to the right.

void MoveCameraUp (float distance)
Moves the camera upwards.

void RotateCameraX (float angle)
Rotates the camera in x-direction.

void RotateCameraY (float angle)
Rotates the camera in y-direction.

void RotateCameraZ (float angle)
Rotates the camera in z-direction.

void SetPosition (Vector2 position)
Sets the cameras x and y position. The z-value will be untouched.

void SetPosition (Vector3 position)
Sets the cameras position in the world.

void SetXPosition (float x)
Sets the cameras x-position.

void SetYPosition (float y)
Sets the cameras y-position.

void SetZPosition (float z)
Sets the cameras z-position.

void ZoomCamera (float distance)
Zooms the camera in or out. Use negative zoom values to zoom out.

void ZoomCamera (float distance, float maxDistance)
Zooms the camera in or out to a maximum distance. Use negative zoom values to zoom out.

See included doc comments for details.

Also there is a CameraMover class included which helps moving the camera from it's current position to a new destination.

Usage:
Class scope:
CameraMover cameraMover;
In Initialize:
cameraMover = new CameraMover();
cameraMover.MoveTo(new Vector3(3, 3, 0), 0.5f); // should be set more intelligent

In Update:
cameraMover.Update();

Warning:
The CameraMover is not used in real projects yet. So it might not be tested very well.

Product File: 
Syndicate content