{
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
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)
+ {
+ sourceFieldOfView = Camera.ConvertFovFromHorizontalToVertical(aspect, sourceFieldOfView);
+ }
+ else
+ {
+ sourceFieldOfView = Camera.ConvertFovFromVerticalToHorizontal(aspect, 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();
+ }
cameraTransition.Finished += (s, e) =>
{
};
cameraTransition.Play();
- sourceFieldOfView.Dispose();
positionKeyFrames.Dispose();
orientationKeyFrames.Dispose();
- fieldOfViewKeyFrames.Dispose();
}
/// <summary>