IGF - ChaseCamera3D

rated by 0 users
This post has 7 Replies | 2 Followers

Top 75 Contributor
Posts 68
SunBurn_Community_Licensee
Raccoon Posted: 06-26-2012 11:20 AM

Guys,

Has anyone got this one working correctly? For me the camera does not appear to react to object's rotation.

It does however, follow the object slightly "infront" (TargetPositionOffset does not appear to function correctly either).

Created one with the following code:

 

 

private void SetupCamera()

{

var environment = Application.Content.Load<SceneEnvironment>("Environment/Environment");

var camera = new ChaseCamera3D(MathHelper.ToRadians(70.0f),

Application.GraphicsDevice.Viewport.AspectRatio, 0.1f, environment.VisibleDistance);

ISceneEntity target;

SceneInterface.ActiveSceneInterface.ObjectManager.Find("MyObject", false, out target);

camera.TargetEntity = target;

camera.TargetPositionOffset = new Vector3(10, 10, 10);

SunBurn.GetManager<ICameraManager>(true).Submit(camera);

camera.SceneEnvironment = environment;

}

If there is any aditional documentation or sample code for this class - would be greatly appreciated.

Thanks in advance!

Top 75 Contributor
Posts 68
SunBurn_Community_Licensee

Looking at the source code the two properties which are very important to the how the chase camera positions are:

TargetPositionOffset - this is where the chase comera will be focused of and..

DesiredPositionOffset - this would be the camera's desired trailing position.

These properties had to be set in unison for me to achieve the desired effect:

camera.DesiredPositionOffset = new Vector3(0, 10, 10);
camera.TargetPositionOffset = new Vector3(0, 0, 0);

Which resulted in the case camera trailing slightly above the target focused at the target.

To most important part of my question I did not find the answers for in the source code - I could not see any logic for auto-tracking and inheriting the target object's orientation by the chase camera.

Top 75 Contributor
Posts 68
SunBurn_Community_Licensee

Guys,

I've re-implemented ChaseCamera based on Microsoft XNA Community Game Platform "Chase Camera" example.

IMHO much more useful implementation. It has a direction but due to certain constrains I had to use Quaternion to Euler conversion (to figure target ISceneObject's orientation).

It still implements Camera3D & has fewer parameters (very much target oriented impl). If anyone interested I can mail you the class.

Top 75 Contributor
Posts 68
SunBurn_Community_Licensee

OKay, got rid of 'certain constraints' in my head and Euler conversions :)

Top 75 Contributor
Posts 68
SunBurn_Community_Licensee

How fast is Slerp btw? Anyone profiled?

Top 10 Contributor
Posts 5,368
Employee
SunBurn_Studio_Licensee

Hi Raccoon,

Slerp is very fast and should not affect performance especially when only using it in a few chase cameras.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 75 Contributor
Posts 68
SunBurn_Community_Licensee

Thanks John!

Awesome. Initially I was surprised not to find Orientation (and only Translation) for entities. But now it makes sense. The only 'downside' is that Sunburn developers need to have some understanding of Quaternions. :)

Top 75 Contributor
Posts 68
SunBurn_Community_Licensee

FYI,

Philippe got back to me and confirmed that the current impl of ChaseCamera3D (IGF 0.9.2.0) is somewhat limited and I need to provide a codeplex patch (which would've been quick easy had I had all prerequisite software installed :}).

Page 1 of 1 (8 items) | RSS