4 using SiliconStudio.Core.Serialization.Converters;
5 using SiliconStudio.Paradox.Effects;
6 using SiliconStudio.Paradox.EntityModel;
7 using SiliconStudio.Core;
8 using SiliconStudio.Core.Mathematics;
10 namespace SiliconStudio.
Paradox.Engine
16 [DataContract(
"CameraComponent")]
19 private float focusDistance;
42 AspectRatio = 16f / 9f;
44 TargetUp = Vector3.UnitY;
45 NearPlane = nearPlane;
47 VerticalFieldOfView = (float)Math.PI * 0.4f;
55 [Obsolete(
"This method will be removed in a future release")]
60 var entity =
new Entity(name);
74 public float VerticalFieldOfView {
get; set; }
83 public float NearPlane {
get; set; }
92 public float FarPlane {
get; set; }
101 public float AspectRatio {
get; set; }
124 public bool AutoFocus {
get; set; }
131 public float FocusDistance
138 if (
Entity != null && Target != null)
140 var eye = Entity.Transformation.WorldMatrix.TranslationVector;
141 var target = Target.Transformation.WorldMatrix.TranslationVector;
142 return Vector3.Distance(eye, target);
145 return focusDistance;
155 if (
Entity == null || Target == null)
157 focusDistance = value;
167 public bool UseViewMatrix {
get; set; }
181 public bool UseProjectionMatrix {
get; set; }
188 public Matrix ProjectionMatrix {
get; set; }
198 return EnsureEntity.Transformation.Translation;
203 EnsureEntity.Transformation.Translation = value;
218 viewMatrix = ViewMatrix;
226 var transformation = EnsureEntity.Transformation;
227 var targetUp = TargetUp;
228 Vector3.TransformNormal(ref targetUp, ref transformation.WorldMatrix, out targetUp);
229 viewMatrix = Matrix.LookAtRH(transformation.WorldMatrix.TranslationVector, Target.Transformation.WorldMatrix.TranslationVector, targetUp);
234 var worldMatrix = EnsureEntity.Transformation.WorldMatrix;
235 Matrix.Invert(ref worldMatrix, out viewMatrix);
240 if (UseProjectionMatrix)
242 projection = ProjectionMatrix;
246 Matrix.PerspectiveFovRH(VerticalFieldOfView, AspectRatio, NearPlane, FarPlane, out projection);
void Calculate(out Matrix projection, out Matrix viewMatrix)
Calculates the projection matrix and view matrix.
Game entity. It usually aggregates multiple EntityComponent
static void SetCamera(this RenderPass pass, CameraComponent camera)
Base class for converters to/from a data type.
Represents a three dimensional mathematical vector.
static CameraComponent GetCamera(this RenderPass pass)
A processor that updates camera view and projection along the setup of RenderTargetSetter ...
Describes the camera projection and view.
CameraComponent(Entity target, float nearPlane, float farPlane)
Create a new CameraComponent instance with the provided target, near plane and far plane...
CameraComponent()
Create a new CameraComponent instance.
RenderPass is a hierarchy that defines how to collect and render meshes.
A class that represents a tag propety.
CameraComponent WithEntity(string name)
Associates an entity with this camera component.
Represents a 4x4 mathematical matrix.