This is a combination of 5 commits.
Configure cameraParam by API
Let scene3d example camera configure cameraActor by API,
not the sample's own logic.
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
Modify to use LoadEnvironmentMap to load skybox env map
Signed-off-by: seungho baek <sbsh.baek@samsung.com>
Fix to use async resource load in scene3d-model example
Signed-off-by: seungho baek <sbsh.baek@samsung.com>
Use Layer_3D in scene3d-model example
Signed-off-by: seungho baek <sbsh.baek@samsung.com>
Fix scene3d examples
Signed-off-by: seungho baek <sbsh.baek@samsung.com>
Change-Id: I818a05f443f62249bde40bcc3107e7969952d3bf
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
#include <cstring>
#include <dali-scene3d/public-api/controls/model/model.h>
+#include <dali-scene3d/public-api/loader/environment-map-loader.h>
using namespace Dali;
using namespace Dali::Toolkit;
mWindow = application.GetWindow();
mWindow.GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
- mWindow.GetRootLayer().SetProperty(Dali::Layer::Property::BEHAVIOR, Dali::Layer::Behavior::LAYER_3D);
-
// Get a handle to the mWindow
mWindow.SetBackgroundColor(Color::WHITE);
void CreateSceneFromGLTF(uint32_t index)
{
+ mReadyToLoad = false;
if(mModel)
{
mWindow.GetRootLayer().Remove(mModel);
mModel.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
mModel.SetImageBasedLightSource(uri_diffuse_texture, uri_specular_texture, 0.6f);
- mWindow.Add(mModel);
+ mModel.ResourceReadySignal().Connect(this, &Scene3DModelExample::ResourceReady);
- mModel.ResourceReadySignal().Connect(this, &Scene3DModelExample::ResourceReadySignal);
+ mWindow.Add(mModel);
}
- void ResourceReadySignal(Control control)
+ void ResourceReady(Control control)
{
+ mReadyToLoad = true;
if(mModel.GetAnimationCount() > 0)
{
- mModel.GetAnimation(0u).Play();
- mModel.GetAnimation(0u).SetLoopCount(0);
+ Animation animation = (mCurrentGlTF == 0u) ? mModel.GetAnimation(0u) : mModel.GetAnimation("idleToSquatClip_0");
+ animation.Play();
+ animation.SetLoopCount(0);
}
}
mSkyboxGeometry.AddVertexBuffer(vertexBuffer);
mSkyboxGeometry.SetType(Geometry::TRIANGLES);
- // Diffuse Cube Map
- Devel::PixelBuffer diffusePixelBuffer = LoadImageFromFile(uri_cube_diffuse_texture);
- int32_t diffuseFaceSize = diffusePixelBuffer.GetWidth() / 4;
- Texture texture = Texture::New(TextureType::TEXTURE_CUBE, diffusePixelBuffer.GetPixelFormat(), diffuseFaceSize, diffuseFaceSize);
- for(int32_t i = 0; i < 6; ++i)
- {
- UploadTextureFace(texture, diffusePixelBuffer, i);
- }
- texture.GenerateMipmaps();
+ Dali::Scene3D::Loader::EnvironmentMapData environmentMapData;
+ Dali::Scene3D::Loader::LoadEnvironmentMap(uri_cube_diffuse_texture, environmentMapData);
+ Texture texture = environmentMapData.GetTexture();
mSkyboxTextures = TextureSet::New();
mSkyboxTextures.SetTexture(0, texture);
void ChangeModel(int32_t direction)
{
+ if(!mReadyToLoad)
+ {
+ return;
+ }
+
mCurrentGlTF += direction;
if(mCurrentGlTF >= NUM_OF_GLTF_MODELS)
{
float mWheelDelta{1.0f};
int32_t mCurrentGlTF{0};
+
+ bool mReadyToLoad{true};
};
int32_t DALI_EXPORT_API main(int32_t argc, char** argv)
return label;\r
}\r
\r
-void ConfigureCamera(const CameraParameters& params, CameraActor camera)\r
-{\r
- if(params.isPerspective)\r
- {\r
- camera.SetProjectionMode(Camera::PERSPECTIVE_PROJECTION);\r
- camera.SetNearClippingPlane(params.zNear);\r
- camera.SetFarClippingPlane(params.zFar);\r
- camera.SetFieldOfView(Radian(Degree(params.yFov)));\r
- }\r
- else\r
- {\r
- camera.SetProjectionMode(Camera::ORTHOGRAPHIC_PROJECTION);\r
- camera.SetOrthographicProjection(params.orthographicSize.x,\r
- params.orthographicSize.y,\r
- params.orthographicSize.z,\r
- params.orthographicSize.w,\r
- params.zNear,\r
- params.zFar);\r
- }\r
-\r
- // model\r
- Vector3 camTranslation;\r
- Vector3 camScale;\r
- Quaternion camOrientation;\r
- params.CalculateTransformComponents(camTranslation, camOrientation, camScale);\r
-\r
- SetActorCentered(camera);\r
- camera.SetInvertYAxis(true);\r
- camera.SetProperty(Actor::Property::POSITION, camTranslation);\r
- camera.SetProperty(Actor::Property::ORIENTATION, camOrientation);\r
- camera.SetProperty(Actor::Property::SCALE, camScale);\r
-\r
- camOrientation.Conjugate();\r
-}\r
-\r
void ConfigureBlendShapeShaders(ResourceBundle& resources, const SceneDefinition& scene, Actor root, std::vector<BlendshapeShaderConfigurationRequest>&& requests)\r
{\r
std::vector<std::string> errors;\r
cameraParameters.push_back(CameraParameters());\r
cameraParameters[0].matrix.SetTranslation(CAMERA_DEFAULT_POSITION);\r
}\r
- ConfigureCamera(cameraParameters[0], camera);\r
+ cameraParameters[0].ConfigureCamera(camera);\r
+ SetActorCentered(camera);\r
\r
ViewProjection viewProjection = cameraParameters[0].GetViewProjection();\r
Transforms xforms{\r
\r
if(!animations->empty())\r
{\r
- auto getActor = [&root](const Scene3D::Loader::AnimatedProperty& property) {\r
- return root.FindChildByName(property.mNodeName);\r
+ auto getActor = [&](const Scene3D::Loader::AnimatedProperty& property)\r
+ {\r
+ Dali::Actor actor;\r
+ if(property.mNodeIndex != Scene3D::Loader::INVALID_INDEX)\r
+ {\r
+ auto* node = scene.GetNode(property.mNodeIndex);\r
+ if(node != nullptr)\r
+ {\r
+ actor = root.FindChildById(node->mNodeId);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ actor = root.FindChildByName(property.mNodeName);\r
+ }\r
+ return actor;\r
};\r
\r
animation = (*animations)[0].ReAnimate(getActor);\r
\r
auto id = mItemView.GetItemId(actor);\r
\r
+ Scene3D::Loader::InitializeGltfLoader();\r
try\r
{\r
auto window = mApp.GetWindow();\r
"uCubeMatrix" : [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ],
"uMaxLOD" : 6
}, {
- "vertex" : "dli_images.vsh",
- "fragment" : "dli_images.fsh",
+ "vertex" : "../shaders/dli_images.vsh",
+ "fragment" : "../shaders/dli_images.fsh",
"rendererState" : "DEPTH_TEST|ALPHA_BLEND",
"uCubeMatrix" : [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ],
"uTilt" : [ 0.0, 0.0 ]