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;
END_TEST;
}
+int UtcDaliSceneViewImageBasedFactor(void)
+{
+ ToolkitTestApplication application;
+
+ Scene3D::SceneView view = Scene3D::SceneView::New();
+ view.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
+
+ application.GetScene().Add(view);
+
+ application.SendNotification();
+ application.Render();
+
+ Scene3D::ModelView modelView1 = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
+ view.Add(modelView1);
+
+ DALI_TEST_EQUALS(view.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(modelView1.GetImageBasedLightScaleFactor(), 1.0f, TEST_LOCATION);
+
+ view.SetImageBasedLightScaleFactor(0.5f);
+ DALI_TEST_EQUALS(view.GetImageBasedLightScaleFactor(), 0.5f, TEST_LOCATION);
+ DALI_TEST_EQUALS(modelView1.GetImageBasedLightScaleFactor(), 0.5f, TEST_LOCATION);
+ END_TEST;
+}
+
int UtcDaliSceneViewUseFramebuffer01(void)
{
ToolkitTestApplication application;
return handle;
}
-const Actor ModelView::GetModelRoot()
+const Actor ModelView::GetModelRoot() const
{
return mModelRoot;
}
{
if(diffuse && specular)
{
- mDiffuseTexture = diffuse;
- mSpecularTexture = specular;
- mIblScaleFactor = scaleFactor;
+ if(mDiffuseTexture != diffuse || mSpecularTexture != specular)
+ {
+ mDiffuseTexture = diffuse;
+ mSpecularTexture = specular;
+ UpdateImageBasedLightTexture();
+ }
+ if(mIblScaleFactor != scaleFactor)
+ {
+ mIblScaleFactor = scaleFactor;
+ UpdateImageBasedLightScaleFactor();
+ }
- UpdateImageBasedLight();
}
}
-uint32_t ModelView::GetAnimationCount()
+void ModelView::SetImageBasedLightScaleFactor(float scaleFactor)
+{
+ mIblScaleFactor = scaleFactor;
+ if(mDiffuseTexture && mSpecularTexture)
+ {
+ UpdateImageBasedLightScaleFactor();
+ }
+}
+
+float ModelView::GetImageBasedLightScaleFactor() const
+{
+ return mIblScaleFactor;
+}
+
+uint32_t ModelView::GetAnimationCount() const
{
return mAnimations.size();
}
-Dali::Animation ModelView::GetAnimation(uint32_t index)
+Dali::Animation ModelView::GetAnimation(uint32_t index) const
{
Dali::Animation animation;
if(mAnimations.size() > index)
return animation;
}
-Dali::Animation ModelView::GetAnimation(const std::string& name)
+Dali::Animation ModelView::GetAnimation(const std::string& name) const
{
Dali::Animation animation;
if(!name.empty())
mRenderableActors.clear();
CollectRenderableActor(mModelRoot);
- UpdateImageBasedLight();
+ UpdateImageBasedLightTexture();
+ UpdateImageBasedLightScaleFactor();
mNaturalSize = AABB.CalculateSize();
mModelPivot = AABB.CalculatePivot();
}
}
-void ModelView::UpdateImageBasedLight()
+void ModelView::UpdateImageBasedLightTexture()
{
if(!mDiffuseTexture || !mSpecularTexture)
{
Actor renderableActor = actor.GetHandle();
if(renderableActor)
{
- renderableActor.RegisterProperty(Dali::Scene3D::Loader::NodeDefinition::GetIblScaleFactorUniformName().data(), mIblScaleFactor);
-
uint32_t rendererCount = renderableActor.GetRendererCount();
for(uint32_t i = 0; i < rendererCount; ++i)
{
}
}
+void ModelView::UpdateImageBasedLightScaleFactor()
+{
+ if(!mDiffuseTexture || !mSpecularTexture)
+ {
+ return;
+ }
+ for(auto&& actor : mRenderableActors)
+ {
+ Actor renderableActor = actor.GetHandle();
+ if(renderableActor)
+ {
+ renderableActor.RegisterProperty(Dali::Scene3D::Loader::NodeDefinition::GetIblScaleFactorUniformName().data(), mIblScaleFactor);
+ }
+ }
+}
+
} // namespace Internal
} // namespace Scene3D
} // namespace Dali
/**
* @copydoc ModelView::GetModelRoot()
*/
- const Actor GetModelRoot();
+ const Actor GetModelRoot() const;
/**
* @copydoc ModelView::FitModel()
void SetImageBasedLightTexture(Dali::Texture diffuse, Dali::Texture specular, float scaleFactor);
/**
+ * @copydoc ModelView::SetImageBasedLightScaleFactor()
+ */
+ void SetImageBasedLightScaleFactor(float scaleFactor);
+
+ /**
+ * @copydoc ModelView::GetImageBasedLightScaleFactor()
+ */
+ float GetImageBasedLightScaleFactor() const;
+
+ /**
* @copydoc ModelView::GetAnimationCount()
*/
- uint32_t GetAnimationCount();
+ uint32_t GetAnimationCount() const;
/**
* @copydoc ModelView::GetAnimation()
*/
- Dali::Animation GetAnimation(uint32_t index);
+ Dali::Animation GetAnimation(uint32_t index) const;
/**
* @copydoc ModelView::GetAnimation()
*/
- Dali::Animation GetAnimation(const std::string& name);
+ Dali::Animation GetAnimation(const std::string& name) const;
protected:
/**
void CollectRenderableActor(Actor actor);
/**
- * @brief Changes IBL information of the input node.
+ * @brief Changes IBL textures of the input node.
+ */
+ void UpdateImageBasedLightTexture();
+
+ /**
+ * @brief Changes IBL scale factor of the input node.
*/
- void UpdateImageBasedLight();
+ void UpdateImageBasedLightScaleFactor();
private:
std::string mModelPath;
}
}
-uint32_t SceneView::GetCameraCount()
+uint32_t SceneView::GetCameraCount() const
{
return mCameras.size();
}
-CameraActor SceneView::GetSelectedCamera()
+CameraActor SceneView::GetSelectedCamera() const
{
return mSelectedCamera;
}
-CameraActor SceneView::GetCamera(uint32_t index)
+CameraActor SceneView::GetCamera(uint32_t index) const
{
if(index < mCameras.size())
{
return CameraActor();
}
-CameraActor SceneView::GetCamera(const std::string& name)
+CameraActor SceneView::GetCamera(const std::string& name) const
{
CameraActor returnCamera;
for(auto&& camera : mCameras)
Control::SetResourceReady(false);
}
+void SceneView::SetImageBasedLightScaleFactor(float scaleFactor)
+{
+ mIblScaleFactor = scaleFactor;
+ for(auto&& model : mModels)
+ {
+ if(model)
+ {
+ model.SetImageBasedLightScaleFactor(scaleFactor);
+ }
+ }
+}
+
+float SceneView::GetImageBasedLightScaleFactor() const
+{
+ return mIblScaleFactor;
+}
+
void SceneView::UseFramebuffer(bool useFramebuffer)
{
if(mUseFrameBuffer != useFramebuffer)
}
}
-bool SceneView::IsUsingFramebuffer()
+bool SceneView::IsUsingFramebuffer() const
{
return mUseFrameBuffer;
}
/**
* @copydoc SceneView::GetCameraCount()
*/
- uint32_t GetCameraCount();
+ uint32_t GetCameraCount() const;
/**
* @copydoc SceneView::GetSelectedCamera()
*/
- CameraActor GetSelectedCamera();
+ CameraActor GetSelectedCamera() const;
/**
* @copydoc SceneView::GetCamera()
*/
- CameraActor GetCamera(uint32_t index);
+ CameraActor GetCamera(uint32_t index) const;
/**
* @copydoc SceneView::GetCamera()
*/
- CameraActor GetCamera(const std::string& name);
+ CameraActor GetCamera(const std::string& name) const;
/**
* @copydoc SceneView::SelectCamera()
void SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor);
/**
+ * @copydoc SceneView::SetImageBasedLightScaleFactor()
+ */
+ void SetImageBasedLightScaleFactor(float scaleFactor);
+
+ /**
+ * @copydoc SceneView::GetImageBasedLightScaleFactor()
+ */
+ float GetImageBasedLightScaleFactor() const;
+
+ /**
* @copydoc SceneView::UseFramebuffer()
*/
void UseFramebuffer(bool useFramebuffer);
/**
* @copydoc SceneView::IsUsingFramebuffer()
*/
- bool IsUsingFramebuffer();
+ bool IsUsingFramebuffer() const;
protected:
/**
VerifyCustomActorPointer<Internal::ModelView>(internal);
}
-const Actor ModelView::GetModelRoot()
+const Actor ModelView::GetModelRoot() const
{
return GetImpl(*this).GetModelRoot();
}
GetImpl(*this).SetImageBasedLightTexture(diffuse, specular, scaleFactor);
}
-uint32_t ModelView::GetAnimationCount()
+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)
+Dali::Animation ModelView::GetAnimation(uint32_t index) const
{
return GetImpl(*this).GetAnimation(index);
}
-Dali::Animation ModelView::GetAnimation(const std::string& name)
+Dali::Animation ModelView::GetAnimation(const std::string& name) const
{
return GetImpl(*this).GetAnimation(name);
}
* @brief Retrieves model root Actor.
* @return Root Actor of the model.
*/
- const Actor GetModelRoot();
+ const Actor GetModelRoot() const;
/**
* @brief Fits the model to the Control size.
void SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor = 1.0f);
/**
- * @brief Set Image Based Light Texture.
+ * @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.
void SetImageBasedLightTexture(Texture diffuse, Texture specular, float scaleFactor = 1.0f);
/**
+ * @brief Sets Scale Factor of Image Based Light Source.
+ *
+ * @note If SetImageBasedLightSource() or SetImageBasedLightTexture() method is called after this method, scaleFactor is overrided.
+ *
+ * @param[in] scaleFactor scale factor that controls light source intensity in [0.0f, 1.0f].
+ */
+ void SetImageBasedLightScaleFactor(float scaleFactor);
+
+ /**
+ * @brief Gets Scale Factor of Image Based Light Source.
+ * Default value is 1.0f.
+ *
+ * @return scale factor that controls light source intensity.
+ */
+ float GetImageBasedLightScaleFactor() const;
+
+ /**
* @brief Gets number of animations those loaded from model file.
* @return The number of loaded animations.
* @note This method should be called after Model load finished.
*/
- uint32_t GetAnimationCount();
+ uint32_t GetAnimationCount() const;
/**
* @brief Gets animation at the index.
* @return Animation at the index.
* @note This method should be called after Model load finished.
*/
- Dali::Animation GetAnimation(uint32_t index);
+ Dali::Animation GetAnimation(uint32_t index) const;
/**
* @brief Retrieves animation with the given name.
* @return Animation that has the given name.
* @note This method should be called after Model load finished.
*/
- Dali::Animation GetAnimation(const std::string& name);
+ Dali::Animation GetAnimation(const std::string& name) const;
public: // Not intended for application developers
/// @cond internal
GetImpl(*this).RemoveCamera(camera);
}
-uint32_t SceneView::GetCameraCount()
+uint32_t SceneView::GetCameraCount() const
{
return GetImpl(*this).GetCameraCount();
}
-CameraActor SceneView::GetSelectedCamera()
+CameraActor SceneView::GetSelectedCamera() const
{
return GetImpl(*this).GetSelectedCamera();
}
-CameraActor SceneView::GetCamera(uint32_t index)
+CameraActor SceneView::GetCamera(uint32_t index) const
{
return GetImpl(*this).GetCamera(index);
}
-CameraActor SceneView::GetCamera(const std::string& name)
+CameraActor SceneView::GetCamera(const std::string& name) const
{
return GetImpl(*this).GetCamera(name);
}
GetImpl(*this).SetImageBasedLightSource(diffuse, specular, scaleFactor);
}
+void SceneView::SetImageBasedLightScaleFactor(float scaleFactor)
+{
+ GetImpl(*this).SetImageBasedLightScaleFactor(scaleFactor);
+}
+
+float SceneView::GetImageBasedLightScaleFactor() const
+{
+ return GetImpl(*this).GetImageBasedLightScaleFactor();
+}
+
void SceneView::UseFramebuffer(bool useFramebuffer)
{
GetImpl(*this).UseFramebuffer(useFramebuffer);
}
-bool SceneView::IsUsingFramebuffer()
+bool SceneView::IsUsingFramebuffer() const
{
return GetImpl(*this).IsUsingFramebuffer();
}
*
* @return Number of cameras those currently the SceneView contains.
*/
- uint32_t GetCameraCount();
+ uint32_t GetCameraCount() const;
/**
* @brief Retrieves selected CameraActor.
*
* @return CameraActor currently used in SceneView as a selected CameraActor
*/
- CameraActor GetSelectedCamera();
+ CameraActor GetSelectedCamera() const;
/**
* @brief Retrieves a CameraActor of the index.
*
* @return CameraActor of the index
*/
- CameraActor GetCamera(uint32_t index);
+ CameraActor GetCamera(uint32_t index) const;
/**
* @brief Retrieves a CameraActor of the name.
*
* @return CameraActor that has the name as a Dali::Actor::Property::NAME
*/
- CameraActor GetCamera(const std::string& name);
+ CameraActor GetCamera(const std::string& name) const;
/**
* @brief Makes SceneView use a CameraActor of index as a selected camera.
void SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor = 1.0f);
/**
+ * @brief Sets Scale Factor of Image Based Light Source.
+ *
+ * @note If SetImageBasedLightSource() or SetImageBasedLightTexture() method is called after this method, scaleFactor is overriden.
+ * @note Default value is 1.0f.
+ *
+ * @param[in] scaleFactor scale factor that controls light source intensity in [0.0f, 1.0f].
+ */
+ void SetImageBasedLightScaleFactor(float scaleFactor);
+
+ /**
+ * @brief Gets Scale Factor of Image Based Light Source.
+ * Default value is 1.0f.
+ *
+ * @return scale factor that controls light source intensity.
+ */
+ float GetImageBasedLightScaleFactor() const;
+
+ /**
* @brief Sets whether to use FBO or not for the SceneView.
* If useFramebuffer is true, rendering result of SceneView is drawn on FBO and it is mapping on this SceneView plane.
* If useFramebuffer is false, each item in SceneView is rendered on window directly.
*
* @return bool True if this SceneView uses Framebuffer.
*/
- bool IsUsingFramebuffer();
+ bool IsUsingFramebuffer() const;
public: // Not intended for application developers
/// @cond internal