{
get
{
- return InternalProjectionDirection == ProjectionDirectionType.Vertical ? TopPlaneDistance : RightPlaneDistance;
+ return InternalOrthographicSize;
}
set
{
- float halfHeight;
- float halfWidth;
- if(InternalProjectionDirection == ProjectionDirectionType.Vertical)
- {
- halfHeight = value;
- halfWidth = AspectRatio * value;
- }
- else
- {
- halfHeight = value / AspectRatio;
- halfWidth = value;
- }
- SetValue(TopPlaneDistanceProperty, halfHeight);
- SetValue(BottomPlaneDistanceProperty, -halfHeight);
- SetValue(LeftPlaneDistanceProperty, -halfWidth);
- SetValue(RightPlaneDistanceProperty, halfWidth);
+ SetValue(OrthographicSizeProperty, value);
NotifyPropertyChanged();
}
}
}
}
+ private float InternalOrthographicSize
+ {
+ get
+ {
+ float returnValue = 0.0f;
+ PropertyValue orthographicSize = GetProperty(Interop.Camera.OrthographicSizeGet());
+ orthographicSize?.Get(out returnValue);
+ orthographicSize?.Dispose();
+ return returnValue;
+ }
+ set
+ {
+ PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
+ SetProperty(Interop.Camera.OrthographicSizeGet(), setValue);
+ setValue.Dispose();
+ }
+ }
+
private float InternalAspectRatio
{
get
/// </summary>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
[EditorBrowsable(EditorBrowsableState.Never)]
- public static Radian ConvertFovFromVerticalToHorizontal(float aspect, Radian verticalFov)
+ public static void ConvertFovFromVerticalToHorizontal(float aspect, ref Radian fov)
{
- if(verticalFov == null)
+ if(fov == null)
{
- return null;
+ return;
}
- return new Radian(2.0f * (float)Math.Atan(Math.Tan(verticalFov.ConvertToFloat() * 0.5f) * aspect));
+ fov.Value = 2.0f * (float)Math.Atan(Math.Tan(fov.ConvertToFloat() * 0.5f) * aspect);
}
/// <summary>
/// </summary>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
[EditorBrowsable(EditorBrowsableState.Never)]
- public static Radian ConvertFovFromHorizontalToVertical(float aspect, Radian horizontalFov)
+ public static void ConvertFovFromHorizontalToVertical(float aspect, ref Radian fov)
{
- if(horizontalFov == null)
+ if(fov == null)
{
- return null;
+ return;
}
- return new Radian(2.0f * (float)Math.Atan(Math.Tan(horizontalFov.ConvertToFloat() * 0.5f) / aspect));
+ fov.Value = 2.0f * (float)Math.Atan(Math.Tan(fov.ConvertToFloat() * 0.5f) / aspect);
}
/// <summary>
using System;
using System.Runtime.InteropServices;
using System.ComponentModel;
+using System.Diagnostics.CodeAnalysis;
using Tizen.NUI;
using Tizen.NUI.Binding;
using Tizen.NUI.BaseComponents;
/// <param name="durationMilliSeconds">The duration in milliseconds.</param>
/// <param name="alphaFunction">The alpha function to apply.</param>
/// <since_tizen> 10 </since_tizen>
+ [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "The ownership of camera object is not owned by this class.")]
public void CameraTransition(uint index, int durationMilliSeconds, AlphaFunction alphaFunction = null)
{
if(inCameraTransition || GetSelectedCamera() == GetCamera(index))
/// <param name="durationMilliSeconds">The duration in milliseconds.</param>
/// <param name="alphaFunction">The alpha function to apply.</param>
/// <since_tizen> 10 </since_tizen>
+ [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "The ownership of camera object is not owned by this class.")]
public void CameraTransition(string name, int durationMilliSeconds, AlphaFunction alphaFunction = null)
{
if(inCameraTransition || GetSelectedCamera() == GetCamera(name))
Position sourcePosition = sourceCamera.Position;
Rotation sourceOrientation = sourceCamera.Orientation;
- Radian sourceFieldOfView = sourceCamera.FieldOfView;
Position destinationPosition = destinationCamera.Position;
Rotation destinationOrientation = destinationCamera.Orientation;
- Radian destinationFieldOfView = destinationCamera.FieldOfView;
-
- // If ProjectionDirection is not equal, match the value.
- if (sourceCamera.ProjectionDirection != destinationCamera.ProjectionDirection)
- {
- float aspect = destinationCamera.AspectRatio;
- if (destinationCamera.ProjectionDirection == Camera.ProjectionDirectionType.Vertical)
- {
- sourceFieldOfView = Camera.ConvertFovFromHorizontalToVertical(aspect, sourceFieldOfView);
- }
- else
- {
- sourceFieldOfView = Camera.ConvertFovFromVerticalToHorizontal(aspect, sourceFieldOfView);
- }
- }
cameraTransition = new Animation(durationMilliSeconds);
orientationKeyFrames.Add(0.0f, sourceOrientation);
orientationKeyFrames.Add(1.0f, destinationOrientation);
- KeyFrames fieldOfViewKeyFrames = new KeyFrames();
- fieldOfViewKeyFrames.Add(0.0f, sourceFieldOfView.ConvertToFloat());
- fieldOfViewKeyFrames.Add(1.0f, destinationFieldOfView.ConvertToFloat());
-
cameraTransition.AnimateBetween(destinationCamera, "Position", positionKeyFrames, Animation.Interpolation.Linear, alphaFunction);
cameraTransition.AnimateBetween(destinationCamera, "Orientation", orientationKeyFrames, Animation.Interpolation.Linear, alphaFunction);
- cameraTransition.AnimateBetween(destinationCamera, "FieldOfView", fieldOfViewKeyFrames, Animation.Interpolation.Linear, alphaFunction);
+
+ if(destinationCamera.ProjectionMode == Camera.ProjectionModeType.Perspective)
+ {
+ Radian sourceFieldOfView = sourceCamera.FieldOfView;
+ Radian destinationFieldOfView = destinationCamera.FieldOfView;
+
+ // If ProjectionDirection is not equal, match the value.
+ if (sourceCamera.ProjectionDirection != destinationCamera.ProjectionDirection)
+ {
+ float aspect = destinationCamera.AspectRatio;
+ if (destinationCamera.ProjectionDirection == Camera.ProjectionDirectionType.Vertical)
+ {
+ Camera.ConvertFovFromHorizontalToVertical(aspect, ref sourceFieldOfView);
+ }
+ else
+ {
+ Camera.ConvertFovFromVerticalToHorizontal(aspect, ref sourceFieldOfView);
+ }
+ }
+
+ KeyFrames fieldOfViewKeyFrames = new KeyFrames();
+ fieldOfViewKeyFrames.Add(0.0f, sourceFieldOfView.ConvertToFloat());
+ fieldOfViewKeyFrames.Add(1.0f, destinationFieldOfView.ConvertToFloat());
+ cameraTransition.AnimateBetween(destinationCamera, "FieldOfView", fieldOfViewKeyFrames, Animation.Interpolation.Linear, alphaFunction);
+
+ sourceFieldOfView.Dispose();
+ destinationFieldOfView.Dispose();
+ fieldOfViewKeyFrames.Dispose();
+ }
+ else
+ {
+ float sourceOrthographicSize = sourceCamera.OrthographicSize;
+ float destinationOrthographicSize = destinationCamera.OrthographicSize;
+
+ // If ProjectionDirection is not equal, match the value.
+ if (sourceCamera.ProjectionDirection != destinationCamera.ProjectionDirection)
+ {
+ float aspect = destinationCamera.AspectRatio;
+ if (destinationCamera.ProjectionDirection == Camera.ProjectionDirectionType.Vertical)
+ {
+ sourceOrthographicSize = sourceOrthographicSize / aspect;
+ }
+ else
+ {
+ sourceOrthographicSize = sourceOrthographicSize * aspect;
+ }
+ }
+
+ KeyFrames orthographicSizeKeyFrames = new KeyFrames();
+ orthographicSizeKeyFrames.Add(0.0f, sourceOrthographicSize);
+ orthographicSizeKeyFrames.Add(1.0f, destinationOrthographicSize);
+ cameraTransition.AnimateBetween(destinationCamera, "OrthographicSize", orthographicSizeKeyFrames, Animation.Interpolation.Linear, alphaFunction);
+
+ orthographicSizeKeyFrames.Dispose();
+ }
float destinationNearPlaneDistance = destinationCamera.NearPlaneDistance;
float destinationFarPlaneDistance = destinationCamera.FarPlaneDistance;
};
cameraTransition.Play();
- sourceFieldOfView.Dispose();
positionKeyFrames.Dispose();
orientationKeyFrames.Dispose();
- fieldOfViewKeyFrames.Dispose();
}
/// <summary>