--- /dev/null
+{
+ "asset": { "version": "1.0" },
+ "scene": 0,
+ "scenes": [ { "nodes": [ 0 ] } ],
+ "nodes": [
+ {
+ "name": "Scene",
+ "matrix": [ 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1 ],
+ "children": [ 1, 2 ]
+ },
+ {
+ "name": "Cube",
+ "matrix": [ 2.5, 0, 0, 0, 0, 2.5, 0, 0, 0, 0, 2.5, 0, 0, 0, 0, 1 ],
+ "model": {
+ "mesh": 0,
+ "material": 0,
+ "shader": 0
+ }
+ },
+ {
+ "name": "bottle",
+ "matrix": [ 0.125, 0, 0, 0, 0, -0, 0.125, 0, 0, -0.125, -0, 0, -0, 0, -1.5, 1 ],
+ "children": [ 3, 4, 5, 6 ]
+ },
+ {
+ "name": "bottle-cap",
+ "model": {
+ "mesh": 3,
+ "material": 2,
+ "shader": 1
+ }
+ },
+ {
+ "name": "bottle-alpha-front",
+ "model": {
+ "mesh": 1,
+ "material": 1,
+ "shader": 2
+ }
+ },
+ {
+ "name": "bottle-alpha-back",
+ "model": {
+ "mesh": 1,
+ "material": 1,
+ "shader": 3
+ }
+ },
+ {
+ "name": "bottle-label",
+ "model": {
+ "mesh": 2,
+ "material": 0,
+ "shader": 4
+ }
+ }
+ ],
+ "meshes": [
+ {
+ "uri": "cube.bin",
+ "attributes": 31,
+ "primitive": "TRIANGLES",
+ "indices": { "byteOffset": 0, "byteLength": 72 },
+ "positions": { "byteOffset": 72, "byteLength": 288 },
+ "normals": { "byteOffset": 360, "byteLength": 288 },
+ "textures": { "byteOffset": 648, "byteLength": 192 },
+ "tangents": { "byteOffset": 840, "byteLength": 288 }
+ },
+ {
+ "uri": "beer.bin",
+ "attributes": 31,
+ "primitive": "TRIANGLES",
+ "indices": { "byteOffset": 0, "byteLength": 19920 },
+ "positions": { "byteOffset": 19920, "byteLength": 54792 },
+ "normals": { "byteOffset": 74712, "byteLength": 54792 },
+ "textures": { "byteOffset": 129504, "byteLength": 36528 },
+ "tangents": { "byteOffset": 166032, "byteLength": 54792 }
+ },
+ {
+ "uri": "beer.bin",
+ "attributes": 31,
+ "primitive": "TRIANGLES",
+ "indices": { "byteOffset": 220824, "byteLength": 13200 },
+ "positions": { "byteOffset": 234024, "byteLength": 14628 },
+ "normals": { "byteOffset": 248652, "byteLength": 14628 },
+ "textures": { "byteOffset": 263280, "byteLength": 9752 },
+ "tangents": { "byteOffset": 273032, "byteLength": 14628 }
+ },
+ {
+ "uri": "beer.bin",
+ "attributes": 31,
+ "primitive": "TRIANGLES",
+ "indices": { "byteOffset": 287660, "byteLength": 31440 },
+ "positions": { "byteOffset": 319100, "byteLength": 121032 },
+ "normals": { "byteOffset": 440132, "byteLength": 121032 },
+ "textures": { "byteOffset": 561164, "byteLength": 80688 },
+ "tangents": { "byteOffset": 641852, "byteLength": 121032 }
+ }
+ ],
+ "skeletons": [
+ ],
+ "cameras": [
+ {
+ "fov": 60,
+ "near": 0.1,
+ "far": 100,
+ "matrix": [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 3.5, 1 ]
+ }
+ ],
+ "lights": [
+ ],
+ "materials": [
+ {
+ "color": [ 1.0, 0.95, 0.5 ],
+ "metallic": 0.25,
+ "roughness": 1.0,
+ "environment": 1
+ },
+ {
+ "color": [ 0.1, 0.4, 0.0, 0.6 ],
+ "metallic": 0.4,
+ "roughness": 0.0,
+ "environment": 1
+ },
+ {
+ "color": [ 0.5, 0.5, 0.5 ],
+ "metallic": 1.0,
+ "roughness": 0.0,
+ "environment": 1
+ }
+ ],
+ "environment": [
+ {
+ },
+ {
+ "cubeSpecular": "Studio/Radiance.ktx",
+ "cubeDiffuse": "Studio/Irradiance.ktx",
+ "iblIntensity": 0.75
+ }
+ ],
+ "shaders": [
+ {
+ "vertex": "dli_pbr.vsh",
+ "fragment": "dli_pbr.fsh",
+ "rendererState": "DEPTH_TEST|CULL_FRONT",
+ "uCubeMatrix": [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ],
+ "uMaxLOD": 6
+ },
+ {
+ "vertex": "dli_pbr.vsh",
+ "fragment": "dli_pbr.fsh",
+ "rendererState": "DEPTH_TEST|DEPTH_WRITE",
+ "uCubeMatrix": [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ],
+ "uMaxLOD": 6
+ },
+ {
+ "vertex": "dli_pbr.vsh",
+ "fragment": "dli_pbr.fsh",
+ "defines": [ "THREE_TEX" ],
+ "rendererState": "ALPHA_BLEND|DEPTH_TEST|CULL_FRONT",
+ "uCubeMatrix": [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ],
+ "uMaxLOD": 6
+ },
+ {
+ "vertex": "dli_pbr.vsh",
+ "fragment": "dli_pbr.fsh",
+ "defines": [ "THREE_TEX" ],
+ "rendererState": "ALPHA_BLEND|DEPTH_TEST|CULL_BACK",
+ "uCubeMatrix": [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ],
+ "uMaxLOD": 6
+ },
+ {
+ "vertex": "dli_pbr.vsh",
+ "fragment": "dli_pbr.fsh",
+ "defines": [ "FLIP_V" ],
+ "rendererState": "DEPTH_TEST|DEPTH_WRITE|CULL_BACK",
+ "uCubeMatrix": [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ],
+ "uMaxLOD": 6
+ }
+ ]
+}
const char* TEST_GLTF_TRIANGLE_FILE_NAME = TEST_RESOURCE_DIR "/AnimatedTriangle.gltf";
const char* TEST_GLTF_ANIMATION_TEST_FILE_NAME = TEST_RESOURCE_DIR "/animationTest.gltf";
const char* TEST_DLI_FILE_NAME = TEST_RESOURCE_DIR "/arc.dli";
+const char* TEST_DLI_BEER_FILE_NAME = TEST_RESOURCE_DIR "/beer_modelViewTest.dli";
/**
* For the diffuse and specular cube map texture.
* These textures are based off version of Wave engine sample
{
ToolkitTestApplication application;
+ Scene3D::ModelView view = Scene3D::ModelView::New(TEST_DLI_BEER_FILE_NAME);
+ view.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
+
+ application.GetScene().Add(view);
+
+ application.SendNotification();
+ application.Render();
+
+ Actor rootActor = view.GetModelRoot();
+ Vector3 rootSize = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
+ DALI_TEST_EQUALS(Vector3(5, 5, 5), rootSize, TEST_LOCATION);
+
+ Vector3 rootScale = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SCALE);
+ DALI_TEST_EQUALS(Vector3(1, 1, 1), rootScale, TEST_LOCATION);
+
+ view.FitSize(true);
+ rootSize = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
+ DALI_TEST_EQUALS(Vector3(5, 5, 5), rootSize, TEST_LOCATION);
+
+ rootScale = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SCALE);
+ DALI_TEST_EQUALS(Vector3(10, 10, 10), rootScale, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliModelViewFitSize03(void)
+{
+ ToolkitTestApplication application;
+
Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME);
view.SetProperty(Dali::Actor::Property::SIZE, Vector2(0, 0));
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
}
+void MeshDefinition::Blob::ComputeMinMax(std::vector<float>& min, std::vector<float>& max, uint32_t numComponents, uint32_t count, const float* values)
+{
+ min.assign(numComponents, MAXFLOAT);
+ max.assign(numComponents, -MAXFLOAT);
+ for(uint32_t i = 0; i < count; ++i)
+ {
+ for(uint32_t j = 0; j < numComponents; ++j)
+ {
+ min[j] = std::min(min[j], *values);
+ max[j] = std::max(max[j], *values);
+ values++;
+ }
+ }
+}
+
void MeshDefinition::Blob::ApplyMinMax(const std::vector<float>& min, const std::vector<float>& max, uint32_t count, float* values)
{
DALI_ASSERT_DEBUG(max.size() == min.size() || max.size() * min.size() == 0);
return IsConsecutive() ? mLength : (mLength * mElementSizeHint / mStride);
}
+void MeshDefinition::Blob::ComputeMinMax(uint32_t numComponents, uint32_t count, float* values)
+{
+ ComputeMinMax(mMin, mMax, numComponents, count, values);
+}
+
void MeshDefinition::Blob::ApplyMinMax(uint32_t count, float* values) const
{
ApplyMinMax(mMin, mMax, count, values);
}
MeshDefinition::RawData
-MeshDefinition::LoadRaw(const std::string& modelsPath) const
+MeshDefinition::LoadRaw(const std::string& modelsPath)
{
RawData raw;
if(IsQuad())
}
uint32_t numVector3 = bufferSize / sizeof(Vector3);
- mPositions.mBlob.ApplyMinMax(numVector3, reinterpret_cast<float*>(buffer.data()));
+ if(mPositions.mBlob.mMin.size() != 3u || mPositions.mBlob.mMax.size() != 3u)
+ {
+ mPositions.mBlob.ComputeMinMax(3u, numVector3, reinterpret_cast<float*>(buffer.data()));
+ }
+ else
+ {
+ mPositions.mBlob.ApplyMinMax(numVector3, reinterpret_cast<float*>(buffer.data()));
+ }
if(HasBlendShapes())
{
#ifndef DALI_SCENE_LOADER_MESH_DEFINITION_H
#define DALI_SCENE_LOADER_MESH_DEFINITION_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
std::vector<float> mMin;
std::vector<float> mMax;
+ static void ComputeMinMax(std::vector<float>& min, std::vector<float>& max, uint32_t numComponents, uint32_t count, const float* values);
+
static void ApplyMinMax(const std::vector<float>& min, const std::vector<float>& max, uint32_t count, float* values);
Blob() = default;
}
/**
- * @brief Applies the min / max values, if they're defined.
+ * @brief Computes the min / max of the input value data.
+ * The min and max are stored in mMin and mMax.
+ *
+ * @param[in] numComponents number of components of data type. e.g., 3 for Vector3.
+ * @param[in] count The number of data.
+ * @param[in] values Data for the mesh.
+ */
+ void ComputeMinMax(uint32_t numComponents, uint32_t count, float* values);
+
+ /**
+ * @brief Applies the min / max values, if they're defined in the model
+ *
+ * @param[in] count The number of data.
+ * @param[in] values Data for the mesh that min / max values will be applied.
*/
void ApplyMinMax(uint32_t count, float* values) const;
};
* attribute buffers, as well as blend shape data. This is then returned.
* @note This can be done on any thread.
*/
- RawData LoadRaw(const std::string& modelsPath) const;
+ RawData LoadRaw(const std::string& modelsPath);
/**
* @brief Creates a MeshGeometry based firstly on the value of the uri member: