#include <dali-scene3d/internal/light/light-impl.h>
// EXTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali/integration-api/debug.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/object/type-registry.h>
{
}
-void Light::Initialize()
+// From Internal::Control.
+
+void Light::OnInitialize()
{
- Self().SetProperty(Dali::Actor::Property::COLOR, Color::WHITE);
+ Actor self = Self();
+
+ // TODO : We need to check this is enough.
+ Toolkit::DevelControl::EnableCreateAccessible(Toolkit::Control::DownCast(self), false);
+
+ self.SetProperty(Dali::Actor::Property::COLOR, Color::WHITE);
// Directional Light setting
mLightSourceActor = Dali::CameraActor::New();
mLightSourceActor.SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
mLightSourceActor.SetProperty(Dali::Actor::Property::POSITION, Vector3::ZERO);
mLightSourceActor.SetProperty(Dali::Actor::Property::ORIENTATION, Quaternion());
- Self().Add(mLightSourceActor);
-}
-
-void Light::Enable(bool enable)
-{
- if(enable == mIsEnabled)
- {
- return;
- }
- mIsEnabled = enable;
-
- Scene3D::SceneView sceneView = mParentSceneView.GetHandle();
- if(!sceneView)
- {
- return;
- }
-
- if(mIsEnabled)
- {
- GetImpl(sceneView).AddLight(Scene3D::Light::DownCast(Self()));
- }
- else
- {
- GetImpl(sceneView).RemoveLight(Scene3D::Light::DownCast(Self()));
- }
-}
-
-bool Light::IsEnabled() const
-{
- return mIsEnabled;
-}
-
-void Light::EnableShadow(bool enable)
-{
- if(enable == mIsShadowEnabled)
- {
- return;
- }
- mIsShadowEnabled = enable;
-
- Scene3D::SceneView sceneView = mParentSceneView.GetHandle();
- if(!sceneView)
- {
- return;
- }
-
- if(mIsShadowEnabled)
- {
- GetImpl(sceneView).SetShadow(Scene3D::Light::DownCast(Self()));
- }
- else
- {
- GetImpl(sceneView).RemoveShadow(Scene3D::Light::DownCast(Self()));
- }
+ self.Add(mLightSourceActor);
}
-bool Light::IsShadowEnabled() const
-{
- return mIsShadowEnabled;
-}
-
-CameraActor Light::GetCamera() const
-{
- return mLightSourceActor;
-}
-
-void Light::EnableShadowSoftFiltering(bool useSoftFiltering)
-{
- mUseSoftFiltering = useSoftFiltering;
- UpdateShadowUniforms();
-}
-
-bool Light::IsShadowSoftFilteringEnabled() const
-{
- return mUseSoftFiltering;
-}
-
-void Light::SetShadowIntensity(float shadowIntensity)
-{
- mShadowIntensity = shadowIntensity;
- UpdateShadowUniforms();
-}
-
-float Light::GetShadowIntensity() const
-{
- return mShadowIntensity;
-}
-
-void Light::SetShadowBias(float shadowBias)
-{
- mShadowBias = shadowBias;
- UpdateShadowUniforms();
-}
-
-float Light::GetShadowBias() const
-{
- return mShadowBias;
-}
+// From CustomActorImpl.
void Light::OnSceneConnection(int depth)
{
// Public Method
+void Light::Enable(bool enable)
+{
+ if(enable == mIsEnabled)
+ {
+ return;
+ }
+ mIsEnabled = enable;
+
+ Scene3D::SceneView sceneView = mParentSceneView.GetHandle();
+ if(!sceneView)
+ {
+ return;
+ }
+
+ if(mIsEnabled)
+ {
+ GetImpl(sceneView).AddLight(Scene3D::Light::DownCast(Self()));
+ }
+ else
+ {
+ GetImpl(sceneView).RemoveLight(Scene3D::Light::DownCast(Self()));
+ }
+}
+
+bool Light::IsEnabled() const
+{
+ return mIsEnabled;
+}
+
+void Light::EnableShadow(bool enable)
+{
+ if(enable == mIsShadowEnabled)
+ {
+ return;
+ }
+ mIsShadowEnabled = enable;
+
+ Scene3D::SceneView sceneView = mParentSceneView.GetHandle();
+ if(!sceneView)
+ {
+ return;
+ }
+
+ if(mIsShadowEnabled)
+ {
+ GetImpl(sceneView).SetShadow(Scene3D::Light::DownCast(Self()));
+ }
+ else
+ {
+ GetImpl(sceneView).RemoveShadow(Scene3D::Light::DownCast(Self()));
+ }
+}
+
+bool Light::IsShadowEnabled() const
+{
+ return mIsShadowEnabled;
+}
+
+CameraActor Light::GetCamera() const
+{
+ return mLightSourceActor;
+}
+
+void Light::EnableShadowSoftFiltering(bool useSoftFiltering)
+{
+ mUseSoftFiltering = useSoftFiltering;
+ UpdateShadowUniforms();
+}
+
+bool Light::IsShadowSoftFilteringEnabled() const
+{
+ return mUseSoftFiltering;
+}
+
+void Light::SetShadowIntensity(float shadowIntensity)
+{
+ mShadowIntensity = shadowIntensity;
+ UpdateShadowUniforms();
+}
+
+float Light::GetShadowIntensity() const
+{
+ return mShadowIntensity;
+}
+
+void Light::SetShadowBias(float shadowBias)
+{
+ mShadowBias = shadowBias;
+ UpdateShadowUniforms();
+}
+
+float Light::GetShadowBias() const
+{
+ return mShadowBias;
+}
+
+// Public Static Method
+
uint32_t Light::GetMaximumEnabledLightCount()
{
return MAX_NUMBER_OF_LIGHT;
return SHADOW_VIEW_PROJECTION_MATRIX_STRING;
}
+// Private Method
+
void Light::UpdateShadowUniforms()
{
Scene3D::SceneView sceneView = mParentSceneView.GetHandle();
*/
static Scene3D::Light New();
- /**
- * @copydoc Scene3D::Light::Enable()
- */
- void Enable(bool enable);
-
- /**
- * @copydoc Scene3D::Light::IsEnabled()
- */
- bool IsEnabled() const;
-
- /**
- * @copydoc Scene3D::Light::EnableShadow()
- */
- void EnableShadow(bool enable);
-
- /**
- * @copydoc Scene3D::Light::IsShadowEnabled()
- */
- bool IsShadowEnabled() const;
-
- /**
- * @copydoc Scene3D::Light::GetCamera()
- */
- CameraActor GetCamera() const;
-
- /**
- * @copydoc Scene3D::Light::EnableShadowSoftFiltering()
- */
- void EnableShadowSoftFiltering(bool useSoftFiltering);
-
- /**
- * @copydoc Scene3D::Light::IsShadowSoftFilteringEnabled()
- */
- bool IsShadowSoftFilteringEnabled() const;
-
- /**
- * @copydoc Scene3D::Light::SetShadowIntensity()
- */
- void SetShadowIntensity(float shadowIntensity);
-
- /**
- * @copydoc Scene3D::Light::GetShadowIntensity()
- */
- float GetShadowIntensity() const;
-
- /**
- * @copydoc Scene3D::Light::SetShadowBias()
- */
- void SetShadowBias(float shadowBias);
-
- /**
- * @copydoc Scene3D::Light::GetShadowBias()
- */
- float GetShadowBias() const;
-
protected:
/**
* @brief Virtual destructor.
*/
virtual ~Light();
-protected: // From CustomActorImpl
+public: // From Internal::Control.
+ /**
+ * @copydoc Dali::Toolkit::Internal::Control::OnInitialize()
+ */
+ void OnInitialize() override;
+
+protected: // From CustomActorImpl. Note that it will make we can ignore many codes what Internal::Control using now.
/**
* @copydoc CustomActorImpl::OnSceneConnection()
* @note If overridden, then an up-call to Light::OnSceneConnection MUST be made at the end.
*/
Light();
+public: // Public Method
/**
- * @brief Second phase initialization.
+ * @copydoc Scene3D::Light::Enable()
*/
- void Initialize();
+ void Enable(bool enable);
-public: // Public Method
+ /**
+ * @copydoc Scene3D::Light::IsEnabled()
+ */
+ bool IsEnabled() const;
+
+ /**
+ * @copydoc Scene3D::Light::EnableShadow()
+ */
+ void EnableShadow(bool enable);
+
+ /**
+ * @copydoc Scene3D::Light::IsShadowEnabled()
+ */
+ bool IsShadowEnabled() const;
+
+ /**
+ * @copydoc Scene3D::Light::GetCamera()
+ */
+ CameraActor GetCamera() const;
+
+ /**
+ * @copydoc Scene3D::Light::EnableShadowSoftFiltering()
+ */
+ void EnableShadowSoftFiltering(bool useSoftFiltering);
+
+ /**
+ * @copydoc Scene3D::Light::IsShadowSoftFilteringEnabled()
+ */
+ bool IsShadowSoftFilteringEnabled() const;
+
+ /**
+ * @copydoc Scene3D::Light::SetShadowIntensity()
+ */
+ void SetShadowIntensity(float shadowIntensity);
+
+ /**
+ * @copydoc Scene3D::Light::GetShadowIntensity()
+ */
+ float GetShadowIntensity() const;
+
+ /**
+ * @copydoc Scene3D::Light::SetShadowBias()
+ */
+ void SetShadowBias(float shadowBias);
+
+ /**
+ * @copydoc Scene3D::Light::GetShadowBias()
+ */
+ float GetShadowBias() const;
+
+public: // Public Static Method
/**
* @copydoc Scene3D::Light::GetMaximumEnabledLightCount()
*/