using System;
using System.Runtime.InteropServices;
using System.ComponentModel;
+using System.Diagnostics.CodeAnalysis;
using Tizen.NUI;
using Tizen.NUI.Binding;
using Tizen.NUI.BaseComponents;
private Animation cameraTransition;
private string skyboxUrl;
- internal SceneView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
+ internal SceneView(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn)
+ {
+ }
+
+ internal SceneView(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, true, cRegister)
{
}
/// </summary>
/// <param name="sceneView">The source object.</param>
/// <since_tizen> 10 </since_tizen>
- public SceneView(SceneView sceneView) : this(Interop.SceneView.NewScene(SceneView.getCPtr(sceneView)), true)
+ public SceneView(SceneView sceneView) : this(Interop.SceneView.NewScene(SceneView.getCPtr(sceneView)), true, false)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
/// <since_tizen> 10 </since_tizen>
public void AddCamera(Camera camera)
{
- if(camera != null)
+ if (camera != null)
{
Interop.SceneView.AddCamera(SwigCPtr, camera.SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
/// <since_tizen> 10 </since_tizen>
public void RemoveCamera(Camera camera)
{
- if(camera != null)
+ if (camera != null)
{
Interop.SceneView.RemoveCamera(SwigCPtr, camera.SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
{
global::System.IntPtr cPtr = Interop.SceneView.GetCamera(SwigCPtr, index);
Camera camera = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Camera;
- if(camera == null)
+ if (camera == null)
{
// Register new camera into Registry.
camera = new Camera(cPtr, true);
{
global::System.IntPtr cPtr = Interop.SceneView.GetCamera(SwigCPtr, name);
Camera camera = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Camera;
- if(camera == null)
+ if (camera == null)
{
// Register new camera into Registry.
camera = new Camera(cPtr, true);
/// <since_tizen> 10 </since_tizen>
public void SelectCamera(uint index)
{
- if(inCameraTransition)
+ if (inCameraTransition)
{
return;
}
+ this.GetSelectedCamera()?.Unparent();
Interop.SceneView.SelectCamera(SwigCPtr, index);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
/// <since_tizen> 10 </since_tizen>
public void SelectCamera(string name)
{
- if(inCameraTransition)
+ if (inCameraTransition)
{
return;
}
+ this.GetSelectedCamera()?.Unparent();
Interop.SceneView.SelectCamera(SwigCPtr, name);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
/// <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))
+ if (inCameraTransition || GetSelectedCamera() == GetCamera(index))
{
return;
}
SelectCamera(index);
Camera destination = GetSelectedCamera();
CameraTransition(source, destination, durationMilliSeconds, alphaFunction);
- source.Dispose();
- destination.Dispose();
}
/// <summary>
/// <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))
+ if (inCameraTransition || GetSelectedCamera() == GetCamera(name))
{
return;
}
SelectCamera(name);
Camera destination = GetSelectedCamera();
CameraTransition(source, destination, durationMilliSeconds, alphaFunction);
- source.Dispose();
- destination.Dispose();
}
/// <summary>
{
global::System.IntPtr cPtr = Interop.SceneView.GetSelectedCamera(SwigCPtr);
Camera camera = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Camera;
- if(camera == null)
+ if (camera == null)
{
// Register new camera into Registry.
camera = new Camera(cPtr, true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
+ /// <summary>
+ /// Add Lights to this SceneView.
+ /// </summary>
+ /// <param name="light">The light what we want to add</param>
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void AddLight(Light light)
+ {
+ Interop.SceneView.AddLight(SwigCPtr, Light.getCPtr(light));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ }
+
+ /// <summary>
+ /// Remove Lights from this SceneView.
+ /// </summary>
+ /// <param name="light">The light what we want to remove</param>
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void RemoveLight(Light light)
+ {
+ Interop.SceneView.RemoveLight(SwigCPtr, Light.getCPtr(light));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ }
+
+ /// <summary>
+ /// Sets SceneView's resolution manually.
+ /// </summary>
+ /// <param name="width">The input width.</param>
+ /// <param name="height">The input height.</param>
+ /// <remarks>
+ /// This manual resolution is only available when the SceneView uses FBO for rendering by using FBO (UseFrameBuffer is true).
+ /// If the aspect ratio of input width/height is different with SceneView's aspect ratio, the rendered result is stretched to fill SceneView's area.
+ /// </remarks>
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetResolution(uint width, uint height)
+ {
+ Interop.SceneView.SetResolution(SwigCPtr, width, height);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ /// <summary>
+ /// Retrieves width of resolution of the SceneView.
+ /// </summary>
+ /// <remarks>
+ /// If the SceneView not uses FBO, this method returns SceneView's width.
+ /// </remarks>
+ /// <returns> Camera currently used in SceneView as a selected Camera.</returns>
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public uint GetResolutionWidth()
+ {
+ uint result = Interop.SceneView.GetResolutionWidth(SwigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return result;
+ }
+
+ /// <summary>
+ /// Retrieves height of resolution of the SceneView.
+ /// </summary>
+ /// <remarks>
+ /// If the SceneView not uses FBO, this method returns SceneView's height.
+ /// </remarks>
+ /// <returns> Camera currently used in SceneView as a selected Camera.</returns>
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public uint GetResolutionHeight()
+ {
+ uint result = Interop.SceneView.GetResolutionHeight(SwigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return result;
+ }
+
+ /// <summary>
+ /// Resets SceneView's resolution to the current size of SceneView.
+ /// </summary>
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetResolution()
+ {
+ Interop.SceneView.ResetResolution(SwigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
internal void SetUseFramebuffer(bool useFramebuffer)
{
Interop.SceneView.UseFramebuffer(SwigCPtr, useFramebuffer);
cameraTransition.AnimateBetween(destinationCamera, "Position", positionKeyFrames, Animation.Interpolation.Linear, alphaFunction);
cameraTransition.AnimateBetween(destinationCamera, "Orientation", orientationKeyFrames, Animation.Interpolation.Linear, alphaFunction);
- if(destinationCamera.ProjectionMode == Camera.ProjectionModeType.Perspective)
+ if (destinationCamera.ProjectionMode == Camera.ProjectionModeType.Perspective)
{
Radian sourceFieldOfView = sourceCamera.FieldOfView;
Radian destinationFieldOfView = destinationCamera.FieldOfView;
float aspect = destinationCamera.AspectRatio;
if (destinationCamera.ProjectionDirection == Camera.ProjectionDirectionType.Vertical)
{
- sourceFieldOfView = Camera.ConvertFovFromHorizontalToVertical(aspect, sourceFieldOfView);
+ Camera.ConvertFovFromHorizontalToVertical(aspect, ref sourceFieldOfView);
}
else
{
- sourceFieldOfView = Camera.ConvertFovFromVerticalToHorizontal(aspect, sourceFieldOfView);
+ Camera.ConvertFovFromVerticalToHorizontal(aspect, ref sourceFieldOfView);
}
}