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!
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.
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.
OKay, got rid of 'certain constraints' in my head and Euler conversions :)
How fast is Slerp btw? Anyone profiled?
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 tweetsAwesome XNA Videos – Lighting, Rendering, and game videos
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. :)
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 :}).