// 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/internal/controls/scene-view/scene-view-impl.h>
#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/loader/animation-definition.h>
#include <dali-scene3d/public-api/loader/camera-parameters.h>
#include <dali-scene3d/public-api/loader/cube-map-loader.h>
mModelPivot(AnchorPoint::CENTER),
mIblScaleFactor(1.0f),
mFitSize(true),
- mFitCenter(true),
- mModelResourceReady(false),
- mIBLResourceReady(false)
+ mFitCenter(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();
- }
}
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;
- mIBLResourceReady = true;
-
- Control::SetResourceReady();
}
void ModelView::ScaleModel()
void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
/**
- * @copydoc Toolkit::Control::IsResourceReady()
- */
- bool IsResourceReady() const override;
-
- /**
* @brief Loads a model from file
*/
void LoadModel();
float mIblScaleFactor;
bool mFitSize;
bool mFitCenter;
- bool mModelResourceReady;
- bool mIBLResourceReady;
};
} // namespace Internal
{
if(camera)
{
- {
- // To do not change camera properties during OnScene in CameraActor
- // TODO: this will be removed after CameraActor is fixed.
- Vector3 size = Self().GetProperty<Vector3>(Dali::Actor::Property::SIZE);
- const float aspectRatio = (size.height > 0.1f) ? size.width / size.height : 1.0f;
- camera.SetAspectRatio(aspectRatio);
- }
if(mCameras.empty())
{
UpdateCamera(camera);
void SceneView::SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor)
{
- mIBLResourceReady = false;
Texture diffuseTexture = Dali::Scene3D::Loader::LoadCubeMap(diffuse);
if(diffuseTexture)
{
}
}
}
- mIBLResourceReady = true;
- Control::SetResourceReady();
}
void SceneView::UseFramebuffer(bool useFramebuffer)
mDefaultCamera.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
mDefaultCamera.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
mDefaultCamera.SetNearClippingPlane(1.0f);
- {
- // To do not change camera properties during OnScene in CameraActor
- // TODO: this will be removed after CameraActor is fixed.
- mDefaultCamera.SetAspectRatio(1.0f);
- }
AddCamera(mDefaultCamera);
UpdateCamera(mDefaultCamera);
}
UpdateRenderTask();
}
-bool SceneView::IsResourceReady() const
-{
- return mIBLResourceReady;
-}
-
void SceneView::UpdateCamera(CameraActor camera)
{
if(camera)
}
Vector3 size = Self().GetProperty<Vector3>(Dali::Actor::Property::SIZE);
- const float aspectRatio = size.width / size.height;
- mSelectedCamera.SetAspectRatio(aspectRatio);
- const float fov = mSelectedCamera[Dali::CameraActor::Property::FIELD_OF_VIEW];
- const float near = mSelectedCamera[Dali::CameraActor::Property::NEAR_PLANE_DISTANCE];
- const float halfHeight = tanf(fov/2) * near;
- const float halfWidth = aspectRatio * halfHeight;
- mSelectedCamera[Dali::CameraActor::Property::LEFT_PLANE_DISTANCE] = -halfWidth;
- mSelectedCamera[Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE] = halfWidth;
- mSelectedCamera[Dali::CameraActor::Property::TOP_PLANE_DISTANCE] = halfHeight; // Top is +ve to keep consistency with orthographic values
- mSelectedCamera[Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE] = -halfHeight; // Bottom is -ve to keep consistency with orthographic values
+ float fov = 0.0f;
+ Vector3 cameraPosition(Vector3::ZERO);
+ float nearPlain = 1.0f;
+ float farPlain = 1.0f;
+
+ // Several properties such as fov, nearPlane, farPlane, and position should not be changed after SetPerspectiveProjection is called.
+ // In the 3D scene, the properties are not changed by the changes of canvas size.
+ fov = mSelectedCamera[Dali::CameraActor::Property::FIELD_OF_VIEW];
+ nearPlain = mSelectedCamera[Dali::CameraActor::Property::NEAR_PLANE_DISTANCE];
+ farPlain = mSelectedCamera[Dali::CameraActor::Property::FAR_PLANE_DISTANCE];
+ cameraPosition = Vector3(mSelectedCamera[Dali::Actor::Property::POSITION]);
+
+ mSelectedCamera.SetPerspectiveProjection(Dali::Size(size));
+
+ mSelectedCamera[Dali::CameraActor::Property::FIELD_OF_VIEW] = fov;
+ mSelectedCamera[Dali::CameraActor::Property::NEAR_PLANE_DISTANCE] = nearPlain;
+ mSelectedCamera[Dali::CameraActor::Property::FAR_PLANE_DISTANCE] = farPlain;
+ mSelectedCamera[Dali::Actor::Property::POSITION] = cameraPosition;
+
if(mUseFrameBuffer)
{
Dali::FrameBuffer currentFrameBuffer = mRenderTask.GetFrameBuffer();
void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
/**
- * @copydoc Toolkit::Control::IsResourceReady()
- */
- bool IsResourceReady() const override;
-
- /**
* @brief Changes main camera as a input camera
*
* @param camera CameraActor that will be a main camera of the SceneView
Dali::Texture mDiffuseTexture;
float mIblScaleFactor{1.0f};
bool mUseFrameBuffer{false};
- bool mIBLResourceReady{true};
// TODO : Light Source
};
}
// Called by a Visual when it's resource is ready
-void Control::Impl::ResourceReady()
-{
- Actor self = mControlImpl.Self();
- // A visual is ready so control may need relayouting if staged
- if(self.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE))
- {
- mControlImpl.RelayoutRequest();
- }
-
- // Emit signal if all enabled visuals registered by the control are ready.
- if(IsResourceReady())
- {
- // Reset the flag
- mNeedToEmitResourceReady = false;
- EmitResourceReadySignal();
- }
-}
-
-// Called by a Visual when it's resource is ready
void Control::Impl::ResourceReady(Visual::Base& object)
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Control::Impl::ResourceReady() replacements pending[%d]\n", mRemoveVisuals.Count());
}
}
- ResourceReady();
+ // A visual is ready so control may need relayouting if staged
+ if(self.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE))
+ {
+ mControlImpl.RelayoutRequest();
+ }
+
+ // Emit signal if all enabled visuals registered by the control are ready.
+ if(IsResourceReady())
+ {
+ // Reset the flag
+ mNeedToEmitResourceReady = false;
+
+ EmitResourceReadySignal();
+ }
}
void Control::Impl::NotifyVisualEvent(Visual::Base& object, Property::Index signalId)
void LongPressDetected(Actor actor, const LongPressGesture& longPress);
/**
- * @brief Called when resources of control are ready.
- */
- void ResourceReady();
-
- /**
* @brief Called when a resource is ready.
* @param[in] object The visual whose resources are ready
* @note Overriding method in Visual::EventObserver.
RelayoutRequest();
}
-void Control::SetResourceReady()
-{
- Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(*this);
- controlDataImpl.ResourceReady();
-}
-
Toolkit::DevelControl::ControlAccessible* Control::GetAccessibleObject()
{
return mImpl->GetAccessibleObject();
{
}
-bool Control::IsResourceReady() const
-{
- const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(*this);
- return controlDataImpl.IsResourceReady();
-}
-
void Control::OnStyleChange(Toolkit::StyleManager styleManager, StyleChange::Type change)
{
// By default the control is only interested in theme (not font) changes
*/
void ClearBackground();
- /**
- * @brief Called when resources of control are ready.
- */
- void SetResourceReady();
-
// Accessibility
/**
*/
virtual void OnInitialize();
- /**
- * @copydoc Dali::Toolkit::Control::IsResourceReady
- */
- virtual bool IsResourceReady() const;
-
// Styling
/**
bool Control::IsResourceReady() const
{
- return Internal::GetImplementation(*this).IsResourceReady();
+ const Internal::Control& internalControl = Toolkit::Internal::GetImplementation(*this);
+ const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(internalControl);
+
+ return controlDataImpl.IsResourceReady();
}
Toolkit::Visual::ResourceStatus Control::GetVisualResourceStatus(Dali::Property::Index index)