From: seungho Date: Tue, 6 Sep 2022 13:47:27 +0000 (+0900) Subject: Fix SceneView about Camera X-Git-Tag: dali_2.1.40~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=3de943270298245987651685a725178af995032b Fix SceneView about Camera - Compute Orthographic properties according to the topPlane Change-Id: Ie67238c6703945c6684b2f01efaf78a086a2992a Signed-off-by: seungho --- diff --git a/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp b/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp index 659dd5a..b230f86 100644 --- a/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp +++ b/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp @@ -258,6 +258,7 @@ void SceneView::OnInitialize() mRenderTask.SetSourceActor(mRootLayer); mRenderTask.SetExclusive(true); mRenderTask.SetInputEnabled(true); + mRenderTask.SetCullMode(false); mRenderTask.SetScreenToFrameBufferMappingActor(Self()); mDefaultCamera = Dali::CameraActor::New(); @@ -329,25 +330,14 @@ void SceneView::UpdateRenderTask() } Vector3 size = Self().GetProperty(Dali::Actor::Property::SIZE); - float fov = 0.0f; - Vector3 cameraPosition(Vector3::ZERO); - float nearPlain = 1.0f; - float farPlain = 1.0f; - - // Several properties such as fov, nearPlane, farPlane, and position should not be changed after SetPerspectiveProjection is called. - // In the 3D scene, the properties are not changed by the changes of canvas size. - fov = mSelectedCamera[Dali::CameraActor::Property::FIELD_OF_VIEW]; - nearPlain = mSelectedCamera[Dali::CameraActor::Property::NEAR_PLANE_DISTANCE]; - farPlain = mSelectedCamera[Dali::CameraActor::Property::FAR_PLANE_DISTANCE]; - cameraPosition = Vector3(mSelectedCamera[Dali::Actor::Property::POSITION]); - - mSelectedCamera.SetPerspectiveProjection(Dali::Size(size)); - - mSelectedCamera[Dali::CameraActor::Property::FIELD_OF_VIEW] = fov; - mSelectedCamera[Dali::CameraActor::Property::NEAR_PLANE_DISTANCE] = nearPlain; - mSelectedCamera[Dali::CameraActor::Property::FAR_PLANE_DISTANCE] = farPlain; - mSelectedCamera[Dali::Actor::Property::POSITION] = cameraPosition; - + const float aspectRatio = size.width / size.height; + mSelectedCamera.SetAspectRatio(aspectRatio); + const float halfHeight = mSelectedCamera[Dali::CameraActor::Property::TOP_PLANE_DISTANCE]; + const float halfWidth = aspectRatio * halfHeight; + mSelectedCamera[Dali::CameraActor::Property::LEFT_PLANE_DISTANCE] = -halfWidth; + mSelectedCamera[Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE] = halfWidth; + mSelectedCamera[Dali::CameraActor::Property::TOP_PLANE_DISTANCE] = halfHeight; // Top is +ve to keep consistency with orthographic values + mSelectedCamera[Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE] = -halfHeight; // Bottom is -ve to keep consistency with orthographic values if(mUseFrameBuffer) { Dali::FrameBuffer currentFrameBuffer = mRenderTask.GetFrameBuffer(); diff --git a/dali-scene3d/public-api/controls/scene-view/scene-view.h b/dali-scene3d/public-api/controls/scene-view/scene-view.h index 15a28d4..cbbe9e0 100644 --- a/dali-scene3d/public-api/controls/scene-view/scene-view.h +++ b/dali-scene3d/public-api/controls/scene-view/scene-view.h @@ -60,7 +60,7 @@ class SceneView; * Users can place multiple cameras in a scene, either to show the entire scene or to show individual objects. * And the user can select the currently needed camera by using the SelectCamera() method. * - * SceneView has one CameraActor built-in by default at the (0, 0, -z). + * SceneView makes one built-in CameraActor by default. * The default CameraActor has index 0 and is not removed by using RemoveCamera() method. * Therefore, the minimum value returned by GetCameraCount() method is 1. * @@ -95,7 +95,6 @@ class SceneView; * sceneView.Add(model); * * CameraActor cameraActor = CameraActor::New(); - * // Setting CameraActor. * sceneView.AddCamera(cameraActor); * * @endcode @@ -167,14 +166,17 @@ public: * @brief Adds a CameraActor to the SceneView * The CameraActor can be used as a selected camera to render the scene by using SelectCamera(uint32_t) or SelectCamera(std::string) * - * @note Some properties of the CameraActor will be change depending on the Size of this SceneView. - * Those properties are as follows: - * projectionMode, aspectRatio, nearPlaneDistance, farPlaneDistance, leftPlaneDistance, rightPlaneDistance, topPlaneDistance, and bottomPlaneDistance. + * @note + * AspectRatio property of CameraActor will be changed depending on the Size of this SceneView. * + * For Perspective camera * The FieldOfView of Dali::CameraActor is for vertical fov. * When the size of the SceneView is changed, the vertical fov is maintained * and the horizontal fov is automatically calculated according to the SceneView's aspect ratio. * + * For Orthographic camera + * leftPlaneDistance, rightPlaneDistance, and bottomPlaneDistance properties are defined according to the topPlaneDistance and aspectRatio. + * * @param[in] camera CameraActor added on this scene view. */ void AddCamera(Dali::CameraActor camera);