utc-Dali-FacialAnimation.cpp
utc-Dali-Gltf2Loader.cpp
utc-Dali-KtxLoader.cpp
- utc-Dali-ModelView.cpp
+ utc-Dali-Model.cpp
utc-Dali-SceneView.cpp
utc-Dali-MatrixStack.cpp
utc-Dali-MeshDefinition.cpp
--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <stdlib.h>
+#include <iostream>
+
+#include <dali-scene3d/public-api/controls/model/model.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+void model_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void model_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+namespace
+{
+/**
+ * For the AnimatedCube.gltf and its Assets
+ * Donated by Norbert Nopper for glTF testing.
+ * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/AnimatedCube
+ */
+const char* TEST_GLTF_FILE_NAME = TEST_RESOURCE_DIR "/AnimatedCube.gltf";
+const char* TEST_GLTF_ANIMATION_TEST_FILE_NAME = TEST_RESOURCE_DIR "/animationTest.gltf";
+const char* TEST_DLI_FILE_NAME = TEST_RESOURCE_DIR "/arc.dli";
+/**
+ * For the diffuse and specular cube map texture.
+ * These textures are based off version of Wave engine sample
+ * Take from https://github.com/WaveEngine/Samples
+ *
+ * Copyright (c) 2022 Wave Coorporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+const char* TEST_DIFFUSE_TEXTURE = TEST_RESOURCE_DIR "/forest_irradiance.ktx";
+const char* TEST_SPECULAR_TEXTURE = TEST_RESOURCE_DIR "/forest_radiance.ktx";
+} // namespace
+
+// Negative test case for a method
+int UtcDaliModelUninitialized(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliModelUninitialized");
+
+ Scene3D::Model model;
+
+ try
+ {
+ // New() must be called to create a Model or it wont be valid.
+ Actor a = Actor::New();
+ model.Add(a);
+ DALI_TEST_CHECK(false);
+ }
+ catch(Dali::DaliException& e)
+ {
+ // Tests that a negative test of an assertion succeeds
+ DALI_TEST_PRINT_ASSERT(e);
+ DALI_TEST_CHECK(!model);
+ }
+ END_TEST;
+}
+
+// Positive test case for a method
+int UtcDaliModelNew(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliModelNew");
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+ DALI_TEST_CHECK(model);
+ END_TEST;
+}
+
+// Positive test case for a method
+int UtcDaliModelDownCast(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliModelDownCast");
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+ BaseHandle handle(model);
+
+ Scene3D::Model model2 = Scene3D::Model::DownCast(handle);
+ DALI_TEST_CHECK(model);
+ DALI_TEST_CHECK(model2);
+ DALI_TEST_CHECK(model2 == model);
+ END_TEST;
+}
+
+int UtcDaliModelTypeRegistry(void)
+{
+ ToolkitTestApplication application;
+
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+ DALI_TEST_CHECK(typeRegistry);
+
+ TypeInfo typeInfo = typeRegistry.GetTypeInfo("Model");
+ DALI_TEST_CHECK(typeInfo);
+
+ BaseHandle handle = typeInfo.CreateInstance();
+ DALI_TEST_CHECK(handle);
+
+ Scene3D::Model model = Scene3D::Model::DownCast(handle);
+ DALI_TEST_CHECK(model);
+
+ END_TEST;
+}
+
+// Positive test case for a method
+int UtcDaliModelAddRemove(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliModelAddRemove");
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+ DALI_TEST_CHECK(model);
+
+ Actor actor = Actor::New();
+ DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
+
+ model.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ model.SetProperty(Actor::Property::SIZE, application.GetScene().GetSize());
+ model.Add(actor);
+ application.GetScene().Add(model);
+
+ DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
+
+ model.Remove(actor);
+
+ DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
+ END_TEST;
+}
+
+int UtcDaliModelCopyAndAssignment(void)
+{
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+ DALI_TEST_CHECK(model);
+
+ Scene3D::Model copy(model);
+ DALI_TEST_CHECK(model == copy);
+
+ Scene3D::Model assign;
+ DALI_TEST_CHECK(!assign);
+
+ assign = copy;
+ DALI_TEST_CHECK(assign == model);
+
+ END_TEST;
+}
+
+int UtcDaliModelMoveConstructor(void)
+{
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+ DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
+ model.SetProperty(Actor::Property::SENSITIVE, false);
+ DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
+
+ Scene3D::Model moved = std::move(model);
+ DALI_TEST_CHECK(moved);
+ DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
+ DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
+ DALI_TEST_CHECK(!model);
+
+ END_TEST;
+}
+
+int UtcDaliModelMoveAssignment(void)
+{
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+ DALI_TEST_EQUALS(1, model.GetBaseObject().ReferenceCount(), TEST_LOCATION);
+ model.SetProperty(Actor::Property::SENSITIVE, false);
+ DALI_TEST_CHECK(false == model.GetProperty<bool>(Actor::Property::SENSITIVE));
+
+ Scene3D::Model moved;
+ moved = std::move(model);
+ DALI_TEST_CHECK(moved);
+ DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
+ DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
+ DALI_TEST_CHECK(!model);
+
+ END_TEST;
+}
+
+int UtcDaliModelOnScene01(void)
+{
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+
+ application.GetScene().Add(model);
+
+ application.SendNotification();
+ application.Render();
+
+ uint32_t modelCount = model.GetModelRoot().GetChildCount();
+ DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliModelOnScene02(void)
+{
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_DLI_FILE_NAME);
+
+ application.GetScene().Add(model);
+
+ application.SendNotification();
+ application.Render();
+
+ uint32_t modelCount = model.GetModelRoot().GetChildCount();
+ DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
+
+ Actor rootActor = model.GetModelRoot();
+ Vector3 rootSize = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
+ DALI_TEST_EQUALS(Vector3(2, 2, 1), rootSize, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliModelOnSizeSet(void)
+{
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+
+ application.GetScene().Add(model);
+
+ application.SendNotification();
+ application.Render();
+
+ Vector2 size(200.0f, 300.0f);
+ model.SetProperty(Actor::Property::SIZE, size);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(model.GetCurrentProperty<Vector2>(Actor::Property::SIZE), size, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliModelGetNaturalSize(void)
+{
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+
+ Vector3 naturalSize = model.GetNaturalSize();
+
+ DALI_TEST_EQUALS(Vector3(2, 2, 2), naturalSize, TEST_LOCATION);
+
+ Actor root = model.GetModelRoot();
+ DALI_TEST_CHECK(root);
+
+ END_TEST;
+}
+
+int UtcDaliModelSetImageBasedLightSource01(void)
+{
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+
+ application.GetScene().Add(model);
+
+ application.SendNotification();
+ application.Render();
+
+ Actor meshActor = model.FindChildByName("AnimatedCube");
+ DALI_TEST_CHECK(meshActor);
+
+ Renderer renderer = meshActor.GetRendererAt(0u);
+ DALI_TEST_CHECK(renderer);
+
+ TextureSet textureSet = renderer.GetTextures();
+ DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION);
+
+ Texture diffuseTexture = textureSet.GetTexture(5u);
+ Texture specularTexture = textureSet.GetTexture(6u);
+
+ model.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
+
+ Texture newDiffuseTexture = textureSet.GetTexture(5u);
+ Texture newSpecularTexture = textureSet.GetTexture(6u);
+
+ DALI_TEST_NOT_EQUALS(diffuseTexture, newDiffuseTexture, 0.0f, TEST_LOCATION);
+ DALI_TEST_NOT_EQUALS(specularTexture, newSpecularTexture, 0.0f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliModelSetImageBasedLightSource02(void)
+{
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+
+ application.GetScene().Add(model);
+
+ application.SendNotification();
+ application.Render();
+
+ Actor meshActor = model.FindChildByName("AnimatedCube");
+ DALI_TEST_CHECK(meshActor);
+
+ Renderer renderer = meshActor.GetRendererAt(0u);
+ DALI_TEST_CHECK(renderer);
+
+ TextureSet textureSet = renderer.GetTextures();
+ DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION);
+
+ Texture diffuseTexture = textureSet.GetTexture(5u);
+ Texture specularTexture = textureSet.GetTexture(6u);
+
+ model.SetImageBasedLightSource("", "");
+
+ Texture newDiffuseTexture = textureSet.GetTexture(5u);
+ Texture newSpecularTexture = textureSet.GetTexture(6u);
+
+ DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
+ DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliModelSetImageBasedLightSource03(void)
+{
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+
+ application.GetScene().Add(model);
+
+ application.SendNotification();
+ application.Render();
+
+ Actor meshActor = model.FindChildByName("AnimatedCube");
+ DALI_TEST_CHECK(meshActor);
+
+ Renderer renderer = meshActor.GetRendererAt(0u);
+ DALI_TEST_CHECK(renderer);
+
+ TextureSet textureSet = renderer.GetTextures();
+ DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION);
+
+ Texture diffuseTexture = textureSet.GetTexture(5u);
+ Texture specularTexture = textureSet.GetTexture(6u);
+
+ model.SetImageBasedLightSource("dummy.ktx", "dummy.ktx");
+
+ Texture newDiffuseTexture = textureSet.GetTexture(5u);
+ Texture newSpecularTexture = textureSet.GetTexture(6u);
+
+ DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
+ DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliModelImageBasedFactor(void)
+{
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+
+ DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
+
+ model.SetImageBasedLightScaleFactor(0.5f);
+ DALI_TEST_EQUALS(model.GetImageBasedLightScaleFactor(), 0.5f, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliModelAnimation01(void)
+{
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+ model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
+
+ application.GetScene().Add(model);
+
+ application.SendNotification();
+ application.Render();
+
+ uint32_t animationCount = model.GetAnimationCount();
+ DALI_TEST_EQUALS(1, animationCount, TEST_LOCATION);
+
+ Animation animationByIndex = model.GetAnimation(0u);
+ DALI_TEST_CHECK(animationByIndex);
+
+ Animation animationByName = model.GetAnimation("animation_AnimatedCube");
+ DALI_TEST_CHECK(animationByName);
+ DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliModelAnimation02(void)
+{
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
+ model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
+
+ application.GetScene().Add(model);
+
+ application.SendNotification();
+ application.Render();
+
+ uint32_t animationCount = model.GetAnimationCount();
+ DALI_TEST_EQUALS(9, animationCount, TEST_LOCATION);
+
+ Animation animation1 = model.GetAnimation("Step Scale");
+ DALI_TEST_CHECK(animation1);
+ DALI_TEST_EQUALS(1.66667f, animation1.GetDuration(), 0.001f, TEST_LOCATION);
+
+ Animation animation2 = model.GetAnimation("CubicSpline Scale");
+ DALI_TEST_CHECK(animation2);
+ DALI_TEST_EQUALS(1.66667f, animation2.GetDuration(), 0.001f, TEST_LOCATION);
+
+ DALI_TEST_NOT_EQUALS(animation1, animation2, 0.0f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+// For ResourceReady
+namespace
+{
+static bool gOnRelayoutCallBackCalled = false;
+void OnRelayoutCallback(Actor actor)
+{
+ gOnRelayoutCallBackCalled = true;
+}
+
+static bool gResourceReadyCalled = false;
+void OnResourceReady(Control control)
+{
+ gResourceReadyCalled = true;
+}
+}
+
+int UtcDaliModelResourceReady(void)
+{
+ ToolkitTestApplication application;
+
+ gOnRelayoutCallBackCalled = false;
+ gResourceReadyCalled = false;
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
+ model.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
+ model.OnRelayoutSignal().Connect(OnRelayoutCallback);
+ model.ResourceReadySignal().Connect(OnResourceReady);
+ DALI_TEST_EQUALS(model.IsResourceReady(), false, TEST_LOCATION);
+
+ // Sanity check
+ DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
+ DALI_TEST_CHECK(!gResourceReadyCalled);
+
+ application.GetScene().Add(model);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
+ DALI_TEST_EQUALS(model.IsResourceReady(), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
+
+ END_TEST;
+}
+++ /dev/null
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-#include <stdlib.h>
-#include <iostream>
-
-#include <dali-scene3d/public-api/controls/model-view/model-view.h>
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-void model_view_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void model_view_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-namespace
-{
-/**
- * For the AnimatedCube.gltf and its Assets
- * Donated by Norbert Nopper for glTF testing.
- * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/AnimatedCube
- */
-const char* TEST_GLTF_FILE_NAME = TEST_RESOURCE_DIR "/AnimatedCube.gltf";
-const char* TEST_GLTF_TRIANGLE_FILE_NAME = TEST_RESOURCE_DIR "/AnimatedTriangle.gltf";
-const char* TEST_GLTF_ANIMATION_TEST_FILE_NAME = TEST_RESOURCE_DIR "/animationTest.gltf";
-const char* TEST_DLI_FILE_NAME = TEST_RESOURCE_DIR "/arc.dli";
-const char* TEST_DLI_BEER_FILE_NAME = TEST_RESOURCE_DIR "/beer_modelViewTest.dli";
-/**
- * For the diffuse and specular cube map texture.
- * These textures are based off version of Wave engine sample
- * Take from https://github.com/WaveEngine/Samples
- *
- * Copyright (c) 2022 Wave Coorporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-const char* TEST_DIFFUSE_TEXTURE = TEST_RESOURCE_DIR "/forest_irradiance.ktx";
-const char* TEST_SPECULAR_TEXTURE = TEST_RESOURCE_DIR "/forest_radiance.ktx";
-} // namespace
-
-// Negative test case for a method
-int UtcDaliModelViewUninitialized(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliModelViewUninitialized");
-
- Scene3D::ModelView view;
-
- try
- {
- // New() must be called to create a ModelView or it wont be valid.
- Actor a = Actor::New();
- view.Add(a);
- DALI_TEST_CHECK(false);
- }
- catch(Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- DALI_TEST_PRINT_ASSERT(e);
- DALI_TEST_CHECK(!view);
- }
- END_TEST;
-}
-
-// Positive test case for a method
-int UtcDaliModelViewNew(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliModelViewNew");
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
- DALI_TEST_CHECK(view);
- END_TEST;
-}
-
-// Positive test case for a method
-int UtcDaliModelViewDownCast(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliModelViewDownCast");
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
- BaseHandle handle(view);
-
- Scene3D::ModelView modelView = Scene3D::ModelView::DownCast(handle);
- DALI_TEST_CHECK(view);
- DALI_TEST_CHECK(modelView);
- DALI_TEST_CHECK(modelView == view);
- END_TEST;
-}
-
-int UtcDaliModelViewTypeRegistry(void)
-{
- ToolkitTestApplication application;
-
- TypeRegistry typeRegistry = TypeRegistry::Get();
- DALI_TEST_CHECK(typeRegistry);
-
- TypeInfo typeInfo = typeRegistry.GetTypeInfo("ModelView");
- DALI_TEST_CHECK(typeInfo);
-
- BaseHandle handle = typeInfo.CreateInstance();
- DALI_TEST_CHECK(handle);
-
- Scene3D::ModelView modelView = Scene3D::ModelView::DownCast(handle);
- DALI_TEST_CHECK(modelView);
-
- END_TEST;
-}
-
-// Positive test case for a method
-int UtcDaliModelViewAddRemove(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliModelViewAddRemove");
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
- DALI_TEST_CHECK(view);
-
- Actor actor = Actor::New();
- DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
-
- view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
- view.SetProperty(Actor::Property::SIZE, application.GetScene().GetSize());
- view.Add(actor);
- application.GetScene().Add(view);
-
- DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
-
- view.Remove(actor);
-
- DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
- END_TEST;
-}
-
-int UtcDaliModelViewCopyAndAssignment(void)
-{
- ToolkitTestApplication application;
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
- DALI_TEST_CHECK(view);
-
- Scene3D::ModelView copy(view);
- DALI_TEST_CHECK(view == copy);
-
- Scene3D::ModelView assign;
- DALI_TEST_CHECK(!assign);
-
- assign = copy;
- DALI_TEST_CHECK(assign == view);
-
- END_TEST;
-}
-
-int UtcDaliModelViewMoveConstructor(void)
-{
- ToolkitTestApplication application;
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
- DALI_TEST_EQUALS(1, view.GetBaseObject().ReferenceCount(), TEST_LOCATION);
- view.SetProperty(Actor::Property::SENSITIVE, false);
- DALI_TEST_CHECK(false == view.GetProperty<bool>(Actor::Property::SENSITIVE));
-
- Scene3D::ModelView moved = std::move(view);
- DALI_TEST_CHECK(moved);
- DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
- DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
- DALI_TEST_CHECK(!view);
-
- END_TEST;
-}
-
-int UtcDaliModelViewMoveAssignment(void)
-{
- ToolkitTestApplication application;
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
- DALI_TEST_EQUALS(1, view.GetBaseObject().ReferenceCount(), TEST_LOCATION);
- view.SetProperty(Actor::Property::SENSITIVE, false);
- DALI_TEST_CHECK(false == view.GetProperty<bool>(Actor::Property::SENSITIVE));
-
- Scene3D::ModelView moved;
- moved = std::move(view);
- DALI_TEST_CHECK(moved);
- DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
- DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
- DALI_TEST_CHECK(!view);
-
- END_TEST;
-}
-
-int UtcDaliModelViewOnScene01(void)
-{
- ToolkitTestApplication application;
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
-
- application.GetScene().Add(view);
-
- application.SendNotification();
- application.Render();
-
- uint32_t modelCount = view.GetModelRoot().GetChildCount();
- DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliModelViewOnScene02(void)
-{
- ToolkitTestApplication application;
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_DLI_FILE_NAME);
-
- application.GetScene().Add(view);
-
- application.SendNotification();
- application.Render();
-
- uint32_t modelCount = view.GetModelRoot().GetChildCount();
- DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
-
- Actor rootActor = view.GetModelRoot();
- Vector3 rootSize = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
- DALI_TEST_EQUALS(Vector3(2, 2, 1), rootSize, TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliModelViewOnSizeSet(void)
-{
- ToolkitTestApplication application;
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
-
- application.GetScene().Add(view);
-
- application.SendNotification();
- application.Render();
-
- Vector2 size(200.0f, 300.0f);
- view.SetProperty(Actor::Property::SIZE, size);
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS(view.GetCurrentProperty<Vector2>(Actor::Property::SIZE), size, TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliModelViewGetNaturalSize(void)
-{
- ToolkitTestApplication application;
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
-
- Vector3 naturalSize = view.GetNaturalSize();
-
- DALI_TEST_EQUALS(Vector3(2, 2, 2), naturalSize, TEST_LOCATION);
-
- Actor root = view.GetModelRoot();
- DALI_TEST_CHECK(root);
-
- END_TEST;
-}
-
-int UtcDaliModelViewSetImageBasedLightSource01(void)
-{
- ToolkitTestApplication application;
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
-
- application.GetScene().Add(view);
-
- application.SendNotification();
- application.Render();
-
- Actor meshActor = view.FindChildByName("AnimatedCube");
- DALI_TEST_CHECK(meshActor);
-
- Renderer renderer = meshActor.GetRendererAt(0u);
- DALI_TEST_CHECK(renderer);
-
- TextureSet textureSet = renderer.GetTextures();
- DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION);
-
- Texture diffuseTexture = textureSet.GetTexture(5u);
- Texture specularTexture = textureSet.GetTexture(6u);
-
- view.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
-
- Texture newDiffuseTexture = textureSet.GetTexture(5u);
- Texture newSpecularTexture = textureSet.GetTexture(6u);
-
- DALI_TEST_NOT_EQUALS(diffuseTexture, newDiffuseTexture, 0.0f, TEST_LOCATION);
- DALI_TEST_NOT_EQUALS(specularTexture, newSpecularTexture, 0.0f, TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliModelViewSetImageBasedLightSource02(void)
-{
- ToolkitTestApplication application;
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
-
- application.GetScene().Add(view);
-
- application.SendNotification();
- application.Render();
-
- Actor meshActor = view.FindChildByName("AnimatedCube");
- DALI_TEST_CHECK(meshActor);
-
- Renderer renderer = meshActor.GetRendererAt(0u);
- DALI_TEST_CHECK(renderer);
-
- TextureSet textureSet = renderer.GetTextures();
- DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION);
-
- Texture diffuseTexture = textureSet.GetTexture(5u);
- Texture specularTexture = textureSet.GetTexture(6u);
-
- view.SetImageBasedLightSource("", "");
-
- Texture newDiffuseTexture = textureSet.GetTexture(5u);
- Texture newSpecularTexture = textureSet.GetTexture(6u);
-
- DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
- DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliModelViewSetImageBasedLightSource03(void)
-{
- ToolkitTestApplication application;
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
-
- application.GetScene().Add(view);
-
- application.SendNotification();
- application.Render();
-
- Actor meshActor = view.FindChildByName("AnimatedCube");
- DALI_TEST_CHECK(meshActor);
-
- Renderer renderer = meshActor.GetRendererAt(0u);
- DALI_TEST_CHECK(renderer);
-
- TextureSet textureSet = renderer.GetTextures();
- DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION);
-
- Texture diffuseTexture = textureSet.GetTexture(5u);
- Texture specularTexture = textureSet.GetTexture(6u);
-
- view.SetImageBasedLightSource("dummy.ktx", "dummy.ktx");
-
- Texture newDiffuseTexture = textureSet.GetTexture(5u);
- Texture newSpecularTexture = textureSet.GetTexture(6u);
-
- DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION);
- DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliModelViewImageBasedFactor(void)
-{
- ToolkitTestApplication application;
-
- Scene3D::ModelView modelView = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
-
- DALI_TEST_EQUALS(modelView.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
-
- modelView.SetImageBasedLightScaleFactor(0.5f);
- DALI_TEST_EQUALS(modelView.GetImageBasedLightScaleFactor(), 0.5f, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliModelViewFitSize01(void)
-{
- ToolkitTestApplication application;
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
- view.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
-
- application.GetScene().Add(view);
-
- application.SendNotification();
- application.Render();
-
- Actor rootActor = view.GetModelRoot();
- Vector3 rootSize = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
- DALI_TEST_EQUALS(Vector3(2, 2, 2), rootSize, TEST_LOCATION);
-
- Vector3 rootScale = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SCALE);
- DALI_TEST_EQUALS(Vector3(25, -25, 25), rootScale, TEST_LOCATION);
-
- view.FitSize(false);
- rootSize = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
- DALI_TEST_EQUALS(Vector3(2, 2, 2), rootSize, TEST_LOCATION);
-
- rootScale = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SCALE);
- DALI_TEST_EQUALS(Vector3(1, -1, 1), rootScale, TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliModelViewFitSize02(void)
-{
- ToolkitTestApplication application;
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_DLI_BEER_FILE_NAME);
- view.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
-
- application.GetScene().Add(view);
-
- application.SendNotification();
- application.Render();
-
- Actor rootActor = view.GetModelRoot();
- Vector3 rootSize = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
- DALI_TEST_EQUALS(Vector3(5, 5, 5), rootSize, TEST_LOCATION);
-
- Vector3 rootScale = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SCALE);
- DALI_TEST_EQUALS(Vector3(10, -10, 10), rootScale, TEST_LOCATION);
-
- view.FitSize(false);
- rootSize = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
- DALI_TEST_EQUALS(Vector3(5, 5, 5), rootSize, TEST_LOCATION);
-
- rootScale = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SCALE);
- DALI_TEST_EQUALS(Vector3(1, -1, 1), rootScale, TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliModelViewFitSize03(void)
-{
- ToolkitTestApplication application;
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
- view.SetProperty(Dali::Actor::Property::SIZE, Vector2(0, 0));
-
- application.GetScene().Add(view);
-
- application.SendNotification();
- application.Render();
-
- Actor rootActor = view.GetModelRoot();
- Vector3 rootSize = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
- DALI_TEST_EQUALS(Vector3(2, 2, 2), rootSize, TEST_LOCATION);
-
- Vector3 rootScale = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SCALE);
- DALI_TEST_EQUALS(Vector3(1, -1, 1), rootScale, TEST_LOCATION);
-
- view.FitSize(true);
- rootSize = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
- DALI_TEST_EQUALS(Vector3(2, 2, 2), rootSize, TEST_LOCATION);
-
- rootScale = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SCALE);
- DALI_TEST_EQUALS(Vector3(1, -1, 1), rootScale, TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliModelViewFitCenter(void)
-{
- ToolkitTestApplication application;
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_TRIANGLE_FILE_NAME);
- view.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
-
- application.GetScene().Add(view);
-
- application.SendNotification();
- application.Render();
-
- Vector3 naturalSize = view.GetNaturalSize();
- DALI_TEST_EQUALS(Vector3(1, 1, 0), naturalSize, TEST_LOCATION);
-
- Actor rootActor = view.GetModelRoot();
- Vector3 anchorPoint = rootActor.GetProperty<Vector3>(Dali::Actor::Property::ANCHOR_POINT);
- DALI_TEST_EQUALS(Vector3(1.0, 1.0, 0.5), anchorPoint, TEST_LOCATION);
-
- view.FitCenter(false);
- anchorPoint = rootActor.GetProperty<Vector3>(Dali::Actor::Property::ANCHOR_POINT);
- DALI_TEST_EQUALS(Vector3(0.5, 0.5, 0.5), anchorPoint, TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliModelViewAnimation01(void)
-{
- ToolkitTestApplication application;
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
- view.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
-
- application.GetScene().Add(view);
-
- application.SendNotification();
- application.Render();
-
- uint32_t animationCount = view.GetAnimationCount();
- DALI_TEST_EQUALS(1, animationCount, TEST_LOCATION);
-
- Animation animationByIndex = view.GetAnimation(0u);
- DALI_TEST_CHECK(animationByIndex);
-
- Animation animationByName = view.GetAnimation("animation_AnimatedCube");
- DALI_TEST_CHECK(animationByName);
- DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliModelViewAnimation02(void)
-{
- ToolkitTestApplication application;
-
- Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
- view.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
-
- application.GetScene().Add(view);
-
- application.SendNotification();
- application.Render();
-
- uint32_t animationCount = view.GetAnimationCount();
- DALI_TEST_EQUALS(9, animationCount, TEST_LOCATION);
-
- Animation animation1 = view.GetAnimation("Step Scale");
- DALI_TEST_CHECK(animation1);
- DALI_TEST_EQUALS(1.66667f, animation1.GetDuration(), 0.001f, TEST_LOCATION);
-
- Animation animation2 = view.GetAnimation("CubicSpline Scale");
- DALI_TEST_CHECK(animation2);
- DALI_TEST_EQUALS(1.66667f, animation2.GetDuration(), 0.001f, TEST_LOCATION);
-
- DALI_TEST_NOT_EQUALS(animation1, animation2, 0.0f, TEST_LOCATION);
-
- END_TEST;
-}
-
-// For ResourceReady
-namespace
-{
-static bool gOnRelayoutCallBackCalled = false;
-void OnRelayoutCallback(Actor actor)
-{
- gOnRelayoutCallBackCalled = true;
-}
-
-static bool gResourceReadyCalled = false;
-void OnResourceReady(Control control)
-{
- gResourceReadyCalled = true;
-}
-}
-
-int UtcDaliModelViewResourceReady(void)
-{
- ToolkitTestApplication application;
-
- gOnRelayoutCallBackCalled = false;
- gResourceReadyCalled = false;
- Scene3D::ModelView model = Scene3D::ModelView::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
- model.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
- model.OnRelayoutSignal().Connect(OnRelayoutCallback);
- model.ResourceReadySignal().Connect(OnResourceReady);
- DALI_TEST_EQUALS(model.IsResourceReady(), false, TEST_LOCATION);
-
- // Sanity check
- DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
- DALI_TEST_CHECK(!gResourceReadyCalled);
-
- application.GetScene().Add(model);
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
- DALI_TEST_EQUALS(model.IsResourceReady(), true, TEST_LOCATION);
- DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
-
- END_TEST;
-}
#include <stdlib.h>
#include <iostream>
-#include <dali-scene3d/public-api/controls/model-view/model-view.h>
+#include <dali-scene3d/public-api/controls/model/model.h>
#include <dali-scene3d/public-api/controls/scene-view/scene-view.h>
using namespace Dali;
const char* TEST_DIFFUSE_TEXTURE = TEST_RESOURCE_DIR "/forest_irradiance.ktx";
const char* TEST_SPECULAR_TEXTURE = TEST_RESOURCE_DIR "/forest_radiance.ktx";
-Dali::Texture GetDiffuseTexture(Dali::Scene3D::ModelView modelView)
+Dali::Texture GetDiffuseTexture(Dali::Scene3D::Model model)
{
Dali::Texture texture;
- Actor meshActor = modelView.FindChildByName("AnimatedCube");
+ Actor meshActor = model.FindChildByName("AnimatedCube");
if(meshActor)
{
Renderer renderer = meshActor.GetRendererAt(0u);
return texture;
}
-Dali::Texture GetSpecularTexture(Dali::Scene3D::ModelView modelView)
+Dali::Texture GetSpecularTexture(Dali::Scene3D::Model model)
{
Dali::Texture texture;
- Actor meshActor = modelView.FindChildByName("AnimatedCube");
+ Actor meshActor = model.FindChildByName("AnimatedCube");
if(meshActor)
{
Renderer renderer = meshActor.GetRendererAt(0u);
try
{
- // New() must be called to create a ModelView or it wont be valid.
+ // New() must be called to create a Model or it wont be valid.
Actor a = Actor::New();
view.Add(a);
DALI_TEST_CHECK(false);
BaseHandle handle = typeInfo.CreateInstance();
DALI_TEST_CHECK(handle);
- Scene3D::SceneView modelView = Scene3D::SceneView::DownCast(handle);
- DALI_TEST_CHECK(modelView);
+ Scene3D::SceneView model = Scene3D::SceneView::DownCast(handle);
+ DALI_TEST_CHECK(model);
END_TEST;
}
application.SendNotification();
application.Render();
- Scene3D::ModelView modelView1 = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
- Scene3D::ModelView modelView2 = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
- Scene3D::ModelView modelView3 = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
+ Scene3D::Model modelView1 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+ Scene3D::Model modelView2 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+ Scene3D::Model modelView3 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
view.Add(modelView1);
view.Add(modelView2);
application.SendNotification();
application.Render();
- Scene3D::ModelView modelView1 = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
+ Scene3D::Model modelView1 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
view.Add(modelView1);
DALI_TEST_EQUALS(view.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
*/
// CLASS HEADER
-#include "model-view-impl.h"
+#include <dali-scene3d/internal/controls/model/model-impl.h>
// EXTERNAL INCLUDES
#include <dali-toolkit/dali-toolkit.h>
#include <filesystem>
// INTERNAL INCLUDES
+#include <dali-scene3d/public-api/controls/model/model.h>
#include <dali-scene3d/internal/controls/scene-view/scene-view-impl.h>
-#include <dali-scene3d/public-api/controls/model-view/model-view.h>
#include <dali-scene3d/public-api/loader/animation-definition.h>
#include <dali-scene3d/public-api/loader/camera-parameters.h>
#include <dali-scene3d/public-api/loader/cube-map-loader.h>
{
BaseHandle Create()
{
- return Scene3D::ModelView::New(std::string());
+ return Scene3D::Model::New(std::string());
}
// Setup properties, signals and actions using the type-registry.
-DALI_TYPE_REGISTRATION_BEGIN(Scene3D::ModelView, Toolkit::Control, Create);
+DALI_TYPE_REGISTRATION_BEGIN(Scene3D::Model, Toolkit::Control, Create);
DALI_TYPE_REGISTRATION_END()
static constexpr uint32_t OFFSET_FOR_DIFFUSE_CUBE_TEXTURE = 2u;
} // anonymous namespace
-ModelView::ModelView(const std::string& modelPath, const std::string& resourcePath)
+Model::Model(const std::string& modelUrl, const std::string& resourceDirectoryUrl)
: Control(ControlBehaviour(DISABLE_SIZE_NEGOTIATION | DISABLE_STYLE_CHANGE_SIGNALS)),
- mModelPath(modelPath),
- mResourcePath(resourcePath),
+ mModelUrl(modelUrl),
+ mResourceDirectoryUrl(resourceDirectoryUrl),
mModelRoot(),
mNaturalSize(Vector3::ZERO),
mModelPivot(AnchorPoint::CENTER),
mIblScaleFactor(1.0f),
- mFitSize(true),
- mFitCenter(true),
mModelResourceReady(false),
mIBLResourceReady(true)
{
}
-ModelView::~ModelView()
+Model::~Model()
{
}
-Dali::Scene3D::ModelView ModelView::New(const std::string& modelPath, const std::string& resourcePath)
+Dali::Scene3D::Model Model::New(const std::string& modelUrl, const std::string& resourceDirectoryUrl)
{
- ModelView* impl = new ModelView(modelPath, resourcePath);
+ Model* impl = new Model(modelUrl, resourceDirectoryUrl);
- Dali::Scene3D::ModelView handle = Dali::Scene3D::ModelView(*impl);
+ Dali::Scene3D::Model handle = Dali::Scene3D::Model(*impl);
// Second-phase init of the implementation
// This can only be done after the CustomActor connection has been made...
return handle;
}
-const Actor ModelView::GetModelRoot() const
+const Actor Model::GetModelRoot() const
{
return mModelRoot;
}
-void ModelView::FitSize(bool fit)
-{
- mFitSize = fit;
- ScaleModel();
-}
-
-void ModelView::FitCenter(bool fit)
-{
- mFitCenter = fit;
- FitModelPosition();
-}
-
-void ModelView::SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor)
+void Model::SetImageBasedLightSource(const std::string& diffuseUrl, const std::string& specularUrl, float scaleFactor)
{
mIBLResourceReady = false;
- Texture diffuseTexture = Dali::Scene3D::Loader::LoadCubeMap(diffuse);
- Texture specularTexture = Dali::Scene3D::Loader::LoadCubeMap(specular);
+ Texture diffuseTexture = Dali::Scene3D::Loader::LoadCubeMap(diffuseUrl);
+ Texture specularTexture = Dali::Scene3D::Loader::LoadCubeMap(specularUrl);
SetImageBasedLightTexture(diffuseTexture, specularTexture, scaleFactor);
mIBLResourceReady = true;
}
}
-void ModelView::SetImageBasedLightTexture(Dali::Texture diffuse, Dali::Texture specular, float scaleFactor)
+void Model::SetImageBasedLightTexture(Dali::Texture diffuseTexture, Dali::Texture specularTexture, float scaleFactor)
{
- if(diffuse && specular)
+ if(diffuseTexture && specularTexture)
{
- if(mDiffuseTexture != diffuse || mSpecularTexture != specular)
+ if(mDiffuseTexture != diffuseTexture || mSpecularTexture != specularTexture)
{
- mDiffuseTexture = diffuse;
- mSpecularTexture = specular;
+ mDiffuseTexture = diffuseTexture;
+ mSpecularTexture = specularTexture;
UpdateImageBasedLightTexture();
}
if(mIblScaleFactor != scaleFactor)
}
}
-void ModelView::SetImageBasedLightScaleFactor(float scaleFactor)
+void Model::SetImageBasedLightScaleFactor(float scaleFactor)
{
mIblScaleFactor = scaleFactor;
if(mDiffuseTexture && mSpecularTexture)
}
}
-float ModelView::GetImageBasedLightScaleFactor() const
+float Model::GetImageBasedLightScaleFactor() const
{
return mIblScaleFactor;
}
-uint32_t ModelView::GetAnimationCount() const
+uint32_t Model::GetAnimationCount() const
{
return mAnimations.size();
}
-Dali::Animation ModelView::GetAnimation(uint32_t index) const
+Dali::Animation Model::GetAnimation(uint32_t index) const
{
Dali::Animation animation;
if(mAnimations.size() > index)
return animation;
}
-Dali::Animation ModelView::GetAnimation(const std::string& name) const
+Dali::Animation Model::GetAnimation(const std::string& name) const
{
Dali::Animation animation;
if(!name.empty())
// Private methods
//
-void ModelView::OnSceneConnection(int depth)
+void Model::OnSceneConnection(int depth)
{
if(!mModelRoot)
{
Scene3D::SceneView sceneView = Scene3D::SceneView::DownCast(parent);
if(sceneView)
{
- GetImpl(sceneView).RegisterModelView(Scene3D::ModelView::DownCast(Self()));
+ GetImpl(sceneView).RegisterModel(Scene3D::Model::DownCast(Self()));
mParentSceneView = sceneView;
break;
}
Control::OnSceneConnection(depth);
}
-void ModelView::OnSceneDisconnection()
+void Model::OnSceneDisconnection()
{
Scene3D::SceneView sceneView = mParentSceneView.GetHandle();
if(sceneView)
{
- GetImpl(sceneView).UnregisterModelView(Scene3D::ModelView::DownCast(Self()));
+ GetImpl(sceneView).UnregisterModel(Scene3D::Model::DownCast(Self()));
mParentSceneView.Reset();
}
Control::OnSceneDisconnection();
}
-Vector3 ModelView::GetNaturalSize()
+Vector3 Model::GetNaturalSize()
{
if(!mModelRoot)
{
return mNaturalSize;
}
-float ModelView::GetHeightForWidth(float width)
+float Model::GetHeightForWidth(float width)
{
Extents padding;
padding = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
return Control::GetHeightForWidth(width) + padding.top + padding.bottom;
}
-float ModelView::GetWidthForHeight(float height)
+float Model::GetWidthForHeight(float height)
{
Extents padding;
padding = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
return Control::GetWidthForHeight(height) + padding.start + padding.end;
}
-void ModelView::OnRelayout(const Vector2& size, RelayoutContainer& container)
+void Model::OnRelayout(const Vector2& size, RelayoutContainer& container)
{
Control::OnRelayout(size, container);
ScaleModel();
}
-bool ModelView::IsResourceReady() const
+bool Model::IsResourceReady() const
{
return mModelResourceReady && mIBLResourceReady;
}
-void ModelView::LoadModel()
+void Model::LoadModel()
{
- std::filesystem::path modelPath(mModelPath);
- if(mResourcePath.empty())
+ std::filesystem::path modelUrl(mModelUrl);
+ if(mResourceDirectoryUrl.empty())
{
- mResourcePath = std::string(modelPath.parent_path()) + "/";
+ mResourceDirectoryUrl = std::string(modelUrl.parent_path()) + "/";
}
- std::string extension = modelPath.extension();
+ std::string extension = modelUrl.extension();
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
Dali::Scene3D::Loader::ResourceBundle::PathProvider pathProvider = [&](Dali::Scene3D::Loader::ResourceType::Value type) {
- return mResourcePath;
+ return mResourceDirectoryUrl;
};
Dali::Scene3D::Loader::ResourceBundle resources;
nullptr,
{}};
Dali::Scene3D::Loader::DliLoader::LoadParams loadParams{input, output};
- if(!loader.LoadScene(mModelPath, loadParams))
+ if(!loader.LoadScene(mModelUrl, loadParams))
{
- Dali::Scene3D::Loader::ExceptionFlinger(ASSERT_LOCATION) << "Failed to load scene from '" << mModelPath << "': " << loader.GetParseError();
+ Dali::Scene3D::Loader::ExceptionFlinger(ASSERT_LOCATION) << "Failed to load scene from '" << mModelUrl << "': " << loader.GetParseError();
}
}
else if(extension == GLTF_EXTENSION)
{
Dali::Scene3D::Loader::ShaderDefinitionFactory sdf;
sdf.SetResources(resources);
- Dali::Scene3D::Loader::LoadGltfScene(mModelPath, sdf, output);
+ Dali::Scene3D::Loader::LoadGltfScene(mModelUrl, sdf, output);
resources.mEnvironmentMaps.push_back({});
}
Control::SetResourceReady(false);
}
-void ModelView::ScaleModel()
+void Model::ScaleModel()
{
if(mModelRoot)
{
- Vector3 size = Self().GetProperty<Vector3>(Dali::Actor::Property::SIZE);
- if(mFitSize && 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);
- // 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
+ float scale = 1.0f;
+ Vector3 size = Self().GetProperty<Vector3>(Dali::Actor::Property::SIZE);
+ if(size.x > 0.0f && size.y > 0.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);
+ scale = MAXFLOAT;
+ scale = std::min(size.x / mNaturalSize.x, scale);
+ scale = std::min(size.y / mNaturalSize.y, scale);
}
+ // 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 * scale);
}
}
-void ModelView::FitModelPosition()
+void Model::FitModelPosition()
{
if(mModelRoot)
{
- if(mFitCenter)
- {
- // Loaded model pivot is not the model center.
- mModelRoot.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
- mModelRoot.SetProperty(Dali::Actor::Property::ANCHOR_POINT, Vector3::ONE - mModelPivot);
- }
- else
- {
- mModelRoot.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
- mModelRoot.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
- }
+ // Loaded model pivot is not the model center.
+ mModelRoot.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ mModelRoot.SetProperty(Dali::Actor::Property::ANCHOR_POINT, Vector3::ONE - mModelPivot);
}
}
-void ModelView::CollectRenderableActor(Actor actor)
+void Model::CollectRenderableActor(Actor actor)
{
uint32_t rendererCount = actor.GetRendererCount();
if(rendererCount)
}
}
-void ModelView::UpdateImageBasedLightTexture()
+void Model::UpdateImageBasedLightTexture()
{
if(!mDiffuseTexture || !mSpecularTexture)
{
}
}
-void ModelView::UpdateImageBasedLightScaleFactor()
+void Model::UpdateImageBasedLightScaleFactor()
{
if(!mDiffuseTexture || !mSpecularTexture)
{
-#ifndef DALI_SCENE3D_INTERNAL_MODEL_VIEW_H
-#define DALI_SCENE3D_INTERNAL_MODEL_VIEW_H
+#ifndef DALI_SCENE3D_INTERNAL_MODEL_H
+#define DALI_SCENE3D_INTERNAL_MODEL_H
/*
* Copyright (c) 2022 Samsung Electronics Co., Ltd.
#include <dali/public-api/object/weak-handle.h>
// INTERNAL INCLUDES
-#include <dali-scene3d/public-api/controls/model-view/model-view.h>
+#include <dali-scene3d/public-api/controls/model/model.h>
#include <dali-scene3d/public-api/controls/scene-view/scene-view.h>
namespace Dali
{
namespace Scene3D
{
-class ModelView;
+class Model;
namespace Internal
{
/**
- * @brief Impl class for ModelView.
+ * @brief Impl class for Model.
*/
-class ModelView : public Dali::Toolkit::Internal::Control
+class Model : public Dali::Toolkit::Internal::Control
{
public:
using AnimationData = std::pair<std::string, Dali::Animation>;
/**
- * @brief Creates a new ModelView.
+ * @brief Creates a new Model.
*
- * @return A public handle to the newly allocated ModelView.
+ * @return A public handle to the newly allocated Model.
*/
- static Dali::Scene3D::ModelView New(const std::string& modelPath, const std::string& resourcePath);
+ static Dali::Scene3D::Model New(const std::string& modelUrl, const std::string& resourceDirectoryUrl);
/**
- * @copydoc ModelView::GetModelRoot()
+ * @copydoc Model::GetModelRoot()
*/
const Actor GetModelRoot() const;
/**
- * @copydoc ModelView::FitModel()
+ * @copydoc Model::SetImageBasedLightSource()
*/
- void FitSize(bool fit);
+ void SetImageBasedLightSource(const std::string& diffuseUrl, const std::string& specularUrl, float scaleFactor);
/**
- * @copydoc ModelView::FitCenter()
+ * @copydoc Model::SetImageBasedLightTexture()
*/
- void FitCenter(bool fit);
+ void SetImageBasedLightTexture(Dali::Texture diffuseTexture, Dali::Texture specularTexture, float scaleFactor);
/**
- * @copydoc ModelView::SetImageBasedLightSource()
- */
- void SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor);
-
- /**
- * @copydoc ModelView::SetImageBasedLightTexture()
- */
- void SetImageBasedLightTexture(Dali::Texture diffuse, Dali::Texture specular, float scaleFactor);
-
- /**
- * @copydoc ModelView::SetImageBasedLightScaleFactor()
+ * @copydoc Model::SetImageBasedLightScaleFactor()
*/
void SetImageBasedLightScaleFactor(float scaleFactor);
/**
- * @copydoc ModelView::GetImageBasedLightScaleFactor()
+ * @copydoc Model::GetImageBasedLightScaleFactor()
*/
float GetImageBasedLightScaleFactor() const;
/**
- * @copydoc ModelView::GetAnimationCount()
+ * @copydoc Model::GetAnimationCount()
*/
uint32_t GetAnimationCount() const;
/**
- * @copydoc ModelView::GetAnimation()
+ * @copydoc Model::GetAnimation()
*/
Dali::Animation GetAnimation(uint32_t index) const;
/**
- * @copydoc ModelView::GetAnimation()
+ * @copydoc Model::GetAnimation()
*/
Dali::Animation GetAnimation(const std::string& name) const;
protected:
/**
- * @brief Constructs a new ModelView.
+ * @brief Constructs a new Model.
*/
- ModelView(const std::string& modelPath, const std::string& resourcePath);
+ Model(const std::string& modelUrl, const std::string& resourceDirectoryUrl);
/**
* A reference counted object may only be deleted by calling Unreference()
*/
- virtual ~ModelView();
+ virtual ~Model();
private:
/**
void UpdateImageBasedLightScaleFactor();
private:
- std::string mModelPath;
- std::string mResourcePath;
+ std::string mModelUrl;
+ std::string mResourceDirectoryUrl;
Dali::Actor mModelRoot;
std::vector<AnimationData> mAnimations;
std::vector<WeakHandle<Actor>> mRenderableActors;
Vector3 mNaturalSize;
Vector3 mModelPivot;
float mIblScaleFactor;
- bool mFitSize;
- bool mFitCenter;
bool mModelResourceReady;
bool mIBLResourceReady;
};
} // namespace Internal
// Helpers for public-api forwarding methods
-inline Dali::Scene3D::Internal::ModelView& GetImpl(Dali::Scene3D::ModelView& obj)
+inline Dali::Scene3D::Internal::Model& GetImpl(Dali::Scene3D::Model& obj)
{
DALI_ASSERT_ALWAYS(obj);
Dali::RefObject& handle = obj.GetImplementation();
- return static_cast<Dali::Scene3D::Internal::ModelView&>(handle);
+ return static_cast<Dali::Scene3D::Internal::Model&>(handle);
}
-inline const Dali::Scene3D::Internal::ModelView& GetImpl(const Dali::Scene3D::ModelView& obj)
+inline const Dali::Scene3D::Internal::Model& GetImpl(const Dali::Scene3D::Model& obj)
{
DALI_ASSERT_ALWAYS(obj);
const Dali::RefObject& handle = obj.GetImplementation();
- return static_cast<const Dali::Scene3D::Internal::ModelView&>(handle);
+ return static_cast<const Dali::Scene3D::Internal::Model&>(handle);
}
} // namespace Scene3D
} // namespace Dali
-#endif // DALI_SCENE3D_INTERNAL_MODEL_VIEW_H
+#endif // DALI_SCENE3D_INTERNAL_MODEL_H
#include <dali/public-api/object/type-registry.h>
// INTERNAL INCLUDES
-#include <dali-scene3d/internal/controls/model-view/model-view-impl.h>
+#include <dali-scene3d/internal/controls/model/model-impl.h>
#include <dali-scene3d/public-api/loader/cube-map-loader.h>
#include <dali/integration-api/debug.h>
UpdateCamera(GetCamera(name));
}
-void SceneView::RegisterModelView(Scene3D::ModelView modelView)
+void SceneView::RegisterModel(Scene3D::Model model)
{
- if(modelView)
+ if(model)
{
- modelView.SetImageBasedLightTexture(mDiffuseTexture, mSpecularTexture, mIblScaleFactor);
- mModels.push_back(modelView);
+ model.SetImageBasedLightTexture(mDiffuseTexture, mSpecularTexture, mIblScaleFactor);
+ mModels.push_back(model);
}
}
-void SceneView::UnregisterModelView(Scene3D::ModelView modelView)
+void SceneView::UnregisterModel(Scene3D::Model model)
{
- if(modelView)
+ if(model)
{
for(uint32_t i = 0; i < mModels.size(); ++i)
{
- if(mModels[i] == modelView)
+ if(mModels[i] == model)
{
mModels.erase(mModels.begin() + i);
break;
}
}
-void SceneView::SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor)
+void SceneView::SetImageBasedLightSource(const std::string& diffuseUrl, const std::string& specularUrl, float scaleFactor)
{
mIBLResourceReady = false;
- Texture diffuseTexture = Dali::Scene3D::Loader::LoadCubeMap(diffuse);
+ Texture diffuseTexture = Dali::Scene3D::Loader::LoadCubeMap(diffuseUrl);
if(diffuseTexture)
{
- Texture specularTexture = Dali::Scene3D::Loader::LoadCubeMap(specular);
+ Texture specularTexture = Dali::Scene3D::Loader::LoadCubeMap(specularUrl);
if(specularTexture)
{
mDiffuseTexture = diffuseTexture;
#include <dali/public-api/rendering/texture.h>
// INTERNAL INCLUDES
-#include <dali-scene3d/public-api/controls/model-view/model-view.h>
#include <dali-scene3d/public-api/controls/scene-view/scene-view.h>
+#include <dali-scene3d/public-api/controls/model/model.h>
namespace Dali
{
void SelectCamera(const std::string& name);
/**
- * @brief Register a ModelView.
- * Some works like ibl setting should be applied on the only ModelView not the all child actors.
- * SceneView contains child ModelView list to apply the works effectively.
+ * @brief Register a Model.
+ * Some works like ibl setting should be applied on the only Model not the all child actors.
+ * SceneView contains child Model list to apply the works effectively.
*
- * @param[in] modelView ModelView to be registered.
+ * @param[in] model Model to be registered.
*/
- void RegisterModelView(Scene3D::ModelView modelView);
+ void RegisterModel(Scene3D::Model model);
/**
- * @brief Unregister a ModelView
+ * @brief Unregister a Model
*
- * @param[in] modelView ModelView to be unregistered.
+ * @param[in] model Model to be unregistered.
*/
- void UnregisterModelView(Scene3D::ModelView modelView);
+ void UnregisterModel(Scene3D::Model model);
/**
* @copydoc SceneView::SetImageBasedLightSource()
*/
- void SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor);
+ void SetImageBasedLightSource(const std::string& diffuseUrl, const std::string& specularUrl, float scaleFactor);
/**
* @copydoc SceneView::SetImageBasedLightScaleFactor()
/////////////////////////////////////////////////////////////
// FrameBuffer and Rendertask to render child objects as a 3D Scene
- CameraActor mDefaultCamera;
- CameraActor mSelectedCamera;
- std::vector<CameraActor> mCameras;
- std::vector<Scene3D::ModelView> mModels;
- Dali::FrameBuffer mRenderTarget;
- Dali::Texture mTexture;
- Dali::RenderTask mRenderTask;
+ CameraActor mDefaultCamera;
+ CameraActor mSelectedCamera;
+ std::vector<CameraActor> mCameras;
+ std::vector<Scene3D::Model> mModels;
+ Dali::FrameBuffer mRenderTarget;
+ Dali::Texture mTexture;
+ Dali::RenderTask mRenderTask;
Layer mRootLayer;
${scene3d_internal_dir}/loader/hash.cpp
${scene3d_internal_dir}/loader/json-reader.cpp
${scene3d_internal_dir}/loader/json-util.cpp
- ${scene3d_internal_dir}/controls/model-view/model-view-impl.cpp
+ ${scene3d_internal_dir}/controls/model/model-impl.cpp
${scene3d_internal_dir}/controls/scene-view/scene-view-impl.cpp
)
+++ /dev/null
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali-scene3d/public-api/controls/model-view/model-view.h>
-
-// INTERNAL INCLUDES
-#include <dali-scene3d/internal/controls/model-view/model-view-impl.h>
-
-namespace Dali
-{
-namespace Scene3D
-{
-ModelView::ModelView()
-{
-}
-
-ModelView::ModelView(const ModelView& modelView) = default;
-
-ModelView::ModelView(ModelView&& rhs) = default;
-
-ModelView& ModelView::operator=(const ModelView& modelView) = default;
-
-ModelView& ModelView::operator=(ModelView&& rhs) = default;
-
-ModelView::~ModelView()
-{
-}
-
-ModelView ModelView::New(const std::string& modelPath, const std::string& resourcePath)
-{
- return Internal::ModelView::New(modelPath, resourcePath);
-}
-
-ModelView ModelView::DownCast(BaseHandle handle)
-{
- return Control::DownCast<ModelView, Internal::ModelView>(handle);
-}
-
-ModelView::ModelView(Internal::ModelView& implementation)
-: Control(implementation)
-{
-}
-
-ModelView::ModelView(Dali::Internal::CustomActor* internal)
-: Control(internal)
-{
- VerifyCustomActorPointer<Internal::ModelView>(internal);
-}
-
-const Actor ModelView::GetModelRoot() const
-{
- return GetImpl(*this).GetModelRoot();
-}
-
-void ModelView::FitSize(bool fit)
-{
- GetImpl(*this).FitSize(fit);
-}
-
-void ModelView::FitCenter(bool fit)
-{
- GetImpl(*this).FitCenter(fit);
-}
-
-void ModelView::SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor)
-{
- GetImpl(*this).SetImageBasedLightSource(diffuse, specular, scaleFactor);
-}
-
-void ModelView::SetImageBasedLightTexture(Texture diffuse, Texture specular, float scaleFactor)
-{
- GetImpl(*this).SetImageBasedLightTexture(diffuse, specular, scaleFactor);
-}
-
-void ModelView::SetImageBasedLightScaleFactor(float scaleFactor)
-{
- GetImpl(*this).SetImageBasedLightScaleFactor(scaleFactor);
-}
-
-float ModelView::GetImageBasedLightScaleFactor() const
-{
- return GetImpl(*this).GetImageBasedLightScaleFactor();
-}
-
-uint32_t ModelView::GetAnimationCount() const
-{
- return GetImpl(*this).GetAnimationCount();
-}
-
-Dali::Animation ModelView::GetAnimation(uint32_t index) const
-{
- return GetImpl(*this).GetAnimation(index);
-}
-
-Dali::Animation ModelView::GetAnimation(const std::string& name) const
-{
- return GetImpl(*this).GetAnimation(name);
-}
-
-} // namespace Scene3D
-
-} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-scene3d/public-api/controls/model/model.h>
+
+// INTERNAL INCLUDES
+#include <dali-scene3d/internal/controls/model/model-impl.h>
+
+namespace Dali
+{
+namespace Scene3D
+{
+Model::Model()
+{
+}
+
+Model::Model(const Model& model) = default;
+
+Model::Model(Model&& rhs) = default;
+
+Model& Model::operator=(const Model& model) = default;
+
+Model& Model::operator=(Model&& rhs) = default;
+
+Model::~Model()
+{
+}
+
+Model Model::New(const std::string& modelUrl, const std::string& resourceDirectoryUrl)
+{
+ return Internal::Model::New(modelUrl, resourceDirectoryUrl);
+}
+
+Model Model::DownCast(BaseHandle handle)
+{
+ return Control::DownCast<Model, Internal::Model>(handle);
+}
+
+Model::Model(Internal::Model& implementation)
+: Control(implementation)
+{
+}
+
+Model::Model(Dali::Internal::CustomActor* internal)
+: Control(internal)
+{
+ VerifyCustomActorPointer<Internal::Model>(internal);
+}
+
+const Actor Model::GetModelRoot() const
+{
+ return GetImpl(*this).GetModelRoot();
+}
+
+void Model::SetImageBasedLightSource(const std::string& diffuseUrl, const std::string& specularUrl, float scaleFactor)
+{
+ GetImpl(*this).SetImageBasedLightSource(diffuseUrl, specularUrl, scaleFactor);
+}
+
+void Model::SetImageBasedLightTexture(Texture diffuseTexture, Texture specularTexture, float scaleFactor)
+{
+ GetImpl(*this).SetImageBasedLightTexture(diffuseTexture, specularTexture, scaleFactor);
+}
+
+void Model::SetImageBasedLightScaleFactor(float scaleFactor)
+{
+ GetImpl(*this).SetImageBasedLightScaleFactor(scaleFactor);
+}
+
+float Model::GetImageBasedLightScaleFactor() const
+{
+ return GetImpl(*this).GetImageBasedLightScaleFactor();
+}
+
+uint32_t Model::GetAnimationCount() const
+{
+ return GetImpl(*this).GetAnimationCount();
+}
+
+Dali::Animation Model::GetAnimation(uint32_t index) const
+{
+ return GetImpl(*this).GetAnimation(index);
+}
+
+Dali::Animation Model::GetAnimation(const std::string& name) const
+{
+ return GetImpl(*this).GetAnimation(name);
+}
+
+} // namespace Scene3D
+
+} // namespace Dali
-#ifndef DALI_SCENE3D_MODEL_VIEW_H
-#define DALI_SCENE3D_MODEL_VIEW_H
+#ifndef DALI_SCENE3D_MODEL_H
+#define DALI_SCENE3D_MODEL_H
/*
* Copyright (c) 2022 Samsung Electronics Co., Ltd.
{
namespace Internal DALI_INTERNAL
{
-class ModelView;
+class Model;
}
/**
- * @addtogroup dali_toolkit_controls_model_view
+ * @addtogroup dali_toolkit_controls_model
* @{
*/
/**
- * @brief ModelView is a control to show 3D model objects.
- * ModelView supports to load glTF 2.0 and DLI models for the input format
+ * @brief Model is a control to show 3D model objects.
+ * Model supports to load glTF 2.0 and DLI models for the input format
* and also supports Physically Based Rendering with Image Based Lighting.
*
* The Animations defined in the glTF or DLI models are also loaded and can be retrieved by using GetAnimation() method.
* The number of animation is also retrieved by GetAnimationCount() method.
*
- * By default, The loaded model has it's own position and size which are defined in vertex buffer regardless of the Control size.
- * The model can be resized and repositioned to fit to the ModelView Control with FitSize() and FitCenter() methods.
+ * By default, The loaded model has its own position and size which are defined in vertex buffer regardless of the Control size.
*
* @code
*
- * ModelView modelView = ModelView::New(modelUrl);
- * modelView.SetProperty(Dali::Actor::Property::SIZE, Vector2(width, height));
- * modelView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
- * modelView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
- * modelView.SetImageBasedLightSource(diffuseUrl, specularUrl, scaleFactor);
- * modelView.FitSize(true);
- * modelView.FitCenter(true);
- * window.Add(modelView);
- * uint32_t animationCount = modelView.GetAnimationCount();
- * Dali::Animation animation = modelView.GetAnimation(0);
+ * Model model = Model::New(modelUrl);
+ * model.SetProperty(Dali::Actor::Property::SIZE, Vector2(width, height));
+ * model.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+ * model.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ * model.SetImageBasedLightSource(diffuseUrl, specularUrl, scaleFactor);
+ * window.Add(model);
+ * uint32_t animationCount = model.GetAnimationCount();
+ * Dali::Animation animation = model.GetAnimation(0);
* animation.Play();
*
* @endcode
*/
-class DALI_SCENE3D_API ModelView : public Dali::Toolkit::Control
+class DALI_SCENE3D_API Model : public Dali::Toolkit::Control
{
public:
/**
- * @brief Create an initialized ModelView.
- * @param[in] modelPath model file path.(e.g., glTF, and DLI).
- * @param[in] resourcePath resource file path that includes binary, image etc.
- * @note If resourcePath is empty, the parent directory path of modelPath is used for resource path.
+ * @brief Create an initialized Model.
+ * @param[in] modelUrl model file path.(e.g., glTF, and DLI).
+ * @param[in] resourceDirectoryUrl resource file path that includes binary, image etc.
+ * @note If resourceDirectoryUrl is empty, the parent directory path of modelUrl is used for resource path.
* @return A handle to a newly allocated Dali resource
*/
- static ModelView New(const std::string& modelPath, const std::string& resourcePath = std::string());
+ static Model New(const std::string& modelUrl, const std::string& resourceDirectoryUrl = std::string());
/**
- * @brief Creates an uninitialized ModelView.
+ * @brief Creates an uninitialized Model.
*
* Only derived versions can be instantiated. Calling member
* functions with an uninitialized Dali::Object is not allowed.
*/
- ModelView();
+ Model();
/**
* @brief Destructor.
*
* This is non-virtual since derived Handle types must not contain data or virtual methods.
*/
- ~ModelView();
+ ~Model();
/**
* @brief Copy constructor.
- * @param[in] modelView Handle to an object
+ * @param[in] model Handle to an object
*/
- ModelView(const ModelView& modelView);
+ Model(const Model& model);
/**
* @brief Move constructor
*
* @param[in] rhs A reference to the moved handle
*/
- ModelView(ModelView&& rhs);
+ Model(Model&& rhs);
/**
* @brief Assignment operator.
- * @param[in] modelView Handle to an object
+ * @param[in] model Handle to an object
* @return reference to this
*/
- ModelView& operator=(const ModelView& modelView);
+ Model& operator=(const Model& model);
/**
* @brief Move assignment
* @param[in] rhs A reference to the moved handle
* @return A reference to this
*/
- ModelView& operator=(ModelView&& rhs);
+ Model& operator=(Model&& rhs);
/**
- * @brief Downcasts an Object handle to ModelView.
+ * @brief Downcasts an Object handle to Model.
*
- * If handle points to a ModelView, the downcast produces valid handle.
+ * If handle points to a Model, the downcast produces valid handle.
* If not, the returned handle is left uninitialized.
*
* @param[in] handle Handle to an object
- * @return Handle to a ModelView or an uninitialized handle
+ * @return Handle to a Model or an uninitialized handle
*/
- static ModelView DownCast(BaseHandle handle);
+ static Model DownCast(BaseHandle handle);
/**
* @brief Retrieves model root Actor.
const Actor GetModelRoot() const;
/**
- * @brief Fits the model to the Control size.
- * @param[in] fit true to fit model size to control.
- * @note This method makes model fit to the Control size by keeping original model ratio.
- * It means If model size is (2, 2, 2) and ModelView size is (10, 8), then the model become looks (8, 8, 8).
- * If ModelView Size x or y is 0, this method don't work anything.
- * If ModelView Size z is 0, this method considers only x and y values of ModelView Size.
- */
- void FitSize(bool fit);
-
- /**
- * @brief Moves the model to the center of control.
- * @param[in] fit true to fit model to center of control.
- * @note This method doesn't changes size of model.
- */
- void FitCenter(bool fit);
-
- /**
* @brief Changes Image Based Light as the input textures.
- * @param[in] diffuse cube map that can be used as a diffuse IBL source.
- * @param[in] specular cube map that can be used as a specular IBL source.
+ * @param[in] diffuseUrl cube map that can be used as a diffuse IBL source.
+ * @param[in] specularUrl cube map that can be used as a specular IBL source.
* @param[in] scaleFactor scale factor that controls light source intensity in [0.0f, 1.0f]. Default value is 1.0f.
*/
- void SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor = 1.0f);
+ void SetImageBasedLightSource(const std::string& diffuseUrl, const std::string& specularUrl, float scaleFactor = 1.0f);
/**
* @brief Sets Image Based Light Texture.
*
- * @param[in] diffuse cube map texture that can be used as a diffuse IBL source.
- * @param[in] specular cube map texture that can be used as a specular IBL source.
+ * @param[in] diffuseTexture cube map texture that can be used as a diffuse IBL source.
+ * @param[in] specularTexture cube map texture that can be used as a specular IBL source.
* @param[in] scaleFactor scale factor that controls light source intensity in [0.0f, 1.0f]. Default value is 1.0f.
*
- * @note Both of diffuse and specular should be available. If not, nothing applied.
+ * @note Both of diffuse texture and specular texture should be available. If not, nothing applied.
*/
- void SetImageBasedLightTexture(Texture diffuse, Texture specular, float scaleFactor = 1.0f);
+ void SetImageBasedLightTexture(Texture diffuseTexture, Texture specularTexture, float scaleFactor = 1.0f);
/**
* @brief Sets Scale Factor of Image Based Light Source.
*
* @param[in] implementation The Control implementation
*/
- DALI_INTERNAL ModelView(Internal::ModelView& implementation);
+ DALI_INTERNAL Model(Internal::Model& implementation);
/**
* @brief Allows the creation of this Control from an Internal::CustomActor pointer.
*
* @param[in] internal A pointer to the internal CustomActor
*/
- DALI_INTERNAL ModelView(Dali::Internal::CustomActor* internal);
+ DALI_INTERNAL Model(Dali::Internal::CustomActor* internal);
/// @endcond
};
} // namespace Dali
-#endif // DALI_SCENE3D_MODEL_VIEW_H
+#endif // DALI_SCENE3D_MODEL_H
GetImpl(*this).SelectCamera(name);
}
-void SceneView::SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor)
+void SceneView::SetImageBasedLightSource(const std::string& diffuseUrl, const std::string& specularUrl, float scaleFactor)
{
- GetImpl(*this).SetImageBasedLightSource(diffuse, specular, scaleFactor);
+ GetImpl(*this).SetImageBasedLightSource(diffuseUrl, specularUrl, scaleFactor);
}
void SceneView::SetImageBasedLightScaleFactor(float scaleFactor)
* sceneView.SetProperty(Dali::Actor::Property::SIZE, Vector2(400, 400));
* mWindow.Add(sceneView);
*
- * Dali::Scene3D::ModelView model = Dali::Scene3D::ModelView::New(...);
+ * Dali::Scene3D::Model model = Dali::Scene3D::Model::New(...);
* sceneView.Add(model);
*
* CameraActor cameraActor = CameraActor::New();
* If SceneView has IBL, IBL of newly added Model is also overridden.
* To set indivisual IBL for each Model, the Model's IBL should be set after the SceneView's IBL.
*
- * @param[in] diffuse cube map that can be used as a diffuse IBL source.
- * @param[in] specular cube map that can be used as a specular IBL source.
+ * @param[in] diffuseUrl cube map that can be used as a diffuse IBL source.
+ * @param[in] specularUrl cube map that can be used as a specular IBL source.
* @param[in] scaleFactor scale factor that controls light source intensity in [0.0f, 1.0f]. Default value is 1.0f.
*/
- void SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor = 1.0f);
+ void SetImageBasedLightSource(const std::string& diffuseUrl, const std::string& specularUrl, float scaleFactor = 1.0f);
/**
* @brief Sets Scale Factor of Image Based Light Source.
set(scene3d_public_api_dir "${scene3d_dir}/public-api")
set(scene3d_src_files ${scene3d_src_files}
- ${scene3d_public_api_dir}/controls/model-view/model-view.cpp
+ ${scene3d_public_api_dir}/controls/model/model.cpp
${scene3d_public_api_dir}/controls/scene-view/scene-view.cpp
${scene3d_public_api_dir}/loader/alpha-function-helper.cpp
${scene3d_public_api_dir}/loader/animated-property.cpp