From: seungho Date: Wed, 17 Aug 2022 04:57:05 +0000 (+0900) Subject: Remove 3D layer from ModelView X-Git-Tag: dali_2.1.38~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=6ca842828e87d73a936a4dc3bc9a34f9b4274444 Remove 3D layer from ModelView Change-Id: I215018b54d7495753b3c99d98f8d99e5c564e292 Signed-off-by: seungho --- diff --git a/automated-tests/src/dali-scene3d/utc-Dali-ModelView.cpp b/automated-tests/src/dali-scene3d/utc-Dali-ModelView.cpp index 5424874..1b9833d 100644 --- a/automated-tests/src/dali-scene3d/utc-Dali-ModelView.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-ModelView.cpp @@ -422,14 +422,14 @@ int UtcDaliModelViewFitSize01(void) DALI_TEST_EQUALS(Vector3(2, 2, 2), rootSize, TEST_LOCATION); Vector3 rootScale = rootActor.GetProperty(Dali::Actor::Property::SCALE); - DALI_TEST_EQUALS(Vector3(1, 1, 1), rootScale, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3(25, -25, 25), rootScale, TEST_LOCATION); - view.FitSize(true); + view.FitSize(false); rootSize = rootActor.GetProperty(Dali::Actor::Property::SIZE); DALI_TEST_EQUALS(Vector3(2, 2, 2), rootSize, TEST_LOCATION); rootScale = rootActor.GetProperty(Dali::Actor::Property::SCALE); - DALI_TEST_EQUALS(Vector3(25, 25, 25), rootScale, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3(1, -1, 1), rootScale, TEST_LOCATION); END_TEST; } @@ -451,14 +451,14 @@ int UtcDaliModelViewFitSize02(void) DALI_TEST_EQUALS(Vector3(5, 5, 5), rootSize, TEST_LOCATION); Vector3 rootScale = rootActor.GetProperty(Dali::Actor::Property::SCALE); - DALI_TEST_EQUALS(Vector3(1, 1, 1), rootScale, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3(10, -10, 10), rootScale, TEST_LOCATION); - view.FitSize(true); + view.FitSize(false); rootSize = rootActor.GetProperty(Dali::Actor::Property::SIZE); DALI_TEST_EQUALS(Vector3(5, 5, 5), rootSize, TEST_LOCATION); rootScale = rootActor.GetProperty(Dali::Actor::Property::SCALE); - DALI_TEST_EQUALS(Vector3(10, 10, 10), rootScale, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3(1, -1, 1), rootScale, TEST_LOCATION); END_TEST; } @@ -480,14 +480,14 @@ int UtcDaliModelViewFitSize03(void) DALI_TEST_EQUALS(Vector3(2, 2, 2), rootSize, TEST_LOCATION); Vector3 rootScale = rootActor.GetProperty(Dali::Actor::Property::SCALE); - DALI_TEST_EQUALS(Vector3(1, 1, 1), rootScale, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3(1, -1, 1), rootScale, TEST_LOCATION); view.FitSize(true); rootSize = rootActor.GetProperty(Dali::Actor::Property::SIZE); DALI_TEST_EQUALS(Vector3(2, 2, 2), rootSize, TEST_LOCATION); rootScale = rootActor.GetProperty(Dali::Actor::Property::SCALE); - DALI_TEST_EQUALS(Vector3(1, 1, 1), rootScale, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3(1, -1, 1), rootScale, TEST_LOCATION); END_TEST; } @@ -509,11 +509,11 @@ int UtcDaliModelViewFitCenter(void) Actor rootActor = view.GetModelRoot(); Vector3 anchorPoint = rootActor.GetProperty(Dali::Actor::Property::ANCHOR_POINT); - DALI_TEST_EQUALS(Vector3(0.5, 0.5, 0.5), anchorPoint, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3(1.0, 1.0, 0.5), anchorPoint, TEST_LOCATION); - view.FitCenter(true); + view.FitCenter(false); anchorPoint = rootActor.GetProperty(Dali::Actor::Property::ANCHOR_POINT); - DALI_TEST_EQUALS(Vector3(1.0, 1.0, 0.5), anchorPoint, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3(0.5, 0.5, 0.5), anchorPoint, TEST_LOCATION); END_TEST; } diff --git a/dali-scene3d/internal/controls/model-view/model-view-impl.cpp b/dali-scene3d/internal/controls/model-view/model-view-impl.cpp index 35029f3..61a5303 100644 --- a/dali-scene3d/internal/controls/model-view/model-view-impl.cpp +++ b/dali-scene3d/internal/controls/model-view/model-view-impl.cpp @@ -176,13 +176,12 @@ ModelView::ModelView(const std::string& modelPath, const std::string& resourcePa : Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)), mModelPath(modelPath), mResourcePath(resourcePath), - mModelLayer(), mModelRoot(), mNaturalSize(Vector3::ZERO), mModelPivot(AnchorPoint::CENTER), mIblScaleFactor(1.0f), - mFitSize(false), - mFitCenter(false) + mFitSize(true), + mFitCenter(true) { } @@ -310,23 +309,6 @@ void ModelView::OnSceneDisconnection() Control::OnSceneDisconnection(); } -void ModelView::OnInitialize() -{ - Actor self = Self(); - mModelLayer = Layer::New(); - mModelLayer.SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D); - mModelLayer.SetProperty(Layer::Property::DEPTH_TEST, true); - mModelLayer.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); - mModelLayer.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); - mModelLayer.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, - Dimension::ALL_DIMENSIONS); - - // Models in glTF and dli are defined as right hand coordinate system. - // DALi uses left hand coordinate system. Scaling negative is for change winding order. - mModelLayer.SetProperty(Dali::Actor::Property::SCALE_Y, -1.0f); - self.Add(mModelLayer); -} - Vector3 ModelView::GetNaturalSize() { if(!mModelRoot) @@ -469,35 +451,40 @@ void ModelView::LoadModel() mNaturalSize = AABB.CalculateSize(); mModelPivot = AABB.CalculatePivot(); mModelRoot.SetProperty(Dali::Actor::Property::SIZE, mNaturalSize); + Vector3 controlSize = Self().GetProperty(Dali::Actor::Property::SIZE); + if(controlSize.x == 0.0f || controlSize.y == 0.0f) + { + Self().SetProperty(Dali::Actor::Property::SIZE, mNaturalSize); + } FitModelPosition(); ScaleModel(); - mModelLayer.Add(mModelRoot); + Self().Add(mModelRoot); + + Self().SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + Self().SetProperty(Dali::Actor::Property::ANCHOR_POINT, Vector3(mModelPivot.x, 1.0f - mModelPivot.y, mModelPivot.z)); } void ModelView::ScaleModel() { if(mModelRoot) { - if(mFitSize) + Vector3 size = Self().GetProperty(Dali::Actor::Property::SIZE); + if(mFitSize && size.x > 0.0f && size.y > 0.0f) { - Vector3 size = Self().GetProperty(Dali::Actor::Property::SIZE); - if(size.x > 0.0f && size.y > 0.0f) - { - float scaleFactor = MAXFLOAT; - scaleFactor = std::min(size.x / mNaturalSize.x, scaleFactor); - scaleFactor = std::min(size.y / mNaturalSize.y, scaleFactor); - mModelRoot.SetProperty(Dali::Actor::Property::SCALE, scaleFactor); - } - else - { - DALI_LOG_ERROR("ModelView size is wrong."); - } + float scaleFactor = MAXFLOAT; + scaleFactor = std::min(size.x / mNaturalSize.x, scaleFactor); + scaleFactor = std::min(size.y / mNaturalSize.y, scaleFactor); + // Models in glTF and dli are defined as right hand coordinate system. + // DALi uses left hand coordinate system. Scaling negative is for change winding order. + mModelRoot.SetProperty(Dali::Actor::Property::SCALE, Y_DIRECTION * scaleFactor); } else { - mModelRoot.SetProperty(Dali::Actor::Property::SCALE, 1.0f); + // Models in glTF and dli are defined as right hand coordinate system. + // DALi uses left hand coordinate system. Scaling negative is for change winding order. + mModelRoot.SetProperty(Dali::Actor::Property::SCALE, Y_DIRECTION); } } } diff --git a/dali-scene3d/internal/controls/model-view/model-view-impl.h b/dali-scene3d/internal/controls/model-view/model-view-impl.h index e17dde3..10d04f2 100644 --- a/dali-scene3d/internal/controls/model-view/model-view-impl.h +++ b/dali-scene3d/internal/controls/model-view/model-view-impl.h @@ -115,11 +115,6 @@ private: void OnSceneDisconnection() override; /** - * @copydoc Toolkit::Control::OnInitialize() - */ - void OnInitialize() override; - - /** * @copydoc Toolkit::Control::GetNaturalSize */ Vector3 GetNaturalSize() override; @@ -167,7 +162,6 @@ private: private: std::string mModelPath; std::string mResourcePath; - Dali::Layer mModelLayer; Dali::Actor mModelRoot; std::vector mAnimations; std::vector> mRenderableActors;