// EXTERNAL INCLUDES
#include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/internal/controls/control/control-data-impl.h>
#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
#include <dali/integration-api/debug.h>
#include <filesystem>
// INTERNAL INCLUDES
-#include <dali-scene3d/public-api/controls/model-view/model-view.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>
} // anonymous namespace
ModelView::ModelView(const std::string& modelPath, const std::string& resourcePath)
-: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)),
+: Control(ControlBehaviour(DISABLE_SIZE_NEGOTIATION | DISABLE_STYLE_CHANGE_SIGNALS)),
mModelPath(modelPath),
mResourcePath(resourcePath),
mModelRoot(),
mModelPivot(AnchorPoint::CENTER),
mIblScaleFactor(1.0f),
mFitSize(true),
- mFitCenter(true)
+ mFitCenter(true),
+ mModelResourceReady(false),
+ mIBLResourceReady(true)
{
}
void ModelView::SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor)
{
+ mIBLResourceReady = false;
Texture diffuseTexture = Dali::Scene3D::Loader::LoadCubeMap(diffuse);
Texture specularTexture = Dali::Scene3D::Loader::LoadCubeMap(specular);
SetImageBasedLightTexture(diffuseTexture, specularTexture, scaleFactor);
+ mIBLResourceReady = true;
+
+ // If Model resource is already ready, then set resource ready.
+ // If Model resource is still not ready, wait for model resource ready.
+ if(IsResourceReady())
+ {
+ SetResourceReady(false);
+ }
}
void ModelView::SetImageBasedLightTexture(Dali::Texture diffuse, Dali::Texture specular, float scaleFactor)
ScaleModel();
}
+bool ModelView::IsResourceReady() const
+{
+ return mModelResourceReady && mIBLResourceReady;
+}
+
void ModelView::LoadModel()
{
std::filesystem::path modelPath(mModelPath);
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));
+
+ mModelResourceReady = true;
+
+ Control::SetResourceReady(false);
}
void ModelView::ScaleModel()