Add the quantized Duck model for testing 23/300523/5
authorRichard Huang <r.huang@samsung.com>
Thu, 26 Oct 2023 14:29:08 +0000 (15:29 +0100)
committerRichard Huang <r.huang@samsung.com>
Tue, 21 Nov 2023 15:49:35 +0000 (15:49 +0000)
Change-Id: I687508dc61c07be76e3170a28d233c0369bc4477

examples/scene3d-model/scene3d-model-example.cpp
resources/models/Duck.bin [new file with mode: 0644]
resources/models/Duck.gltf [new file with mode: 0644]
resources/models/DuckCM.png [new file with mode: 0644]

index b306792..414ae5e 100644 (file)
@@ -41,54 +41,69 @@ using namespace Dali::Toolkit;
 
 namespace
 {
-static constexpr int32_t NUM_OF_GLTF_MODELS = 7;
+struct ModelInfo
+{
+  const char*   name;      ///< The name of the model.
+  const Vector2 size;      ///< The size of the model
+  const float   yPosition; ///< The position of the model in the Y axis.
+};
 
-const char* gltf_list[7] =
+const ModelInfo gltf_list[] =
   {
     /**
      * For the BoxAnimated.glb
      * Donated by Cesium for glTF testing.
      * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/BoxAnimated
      */
-    "BoxAnimated.glb",
+    {"BoxAnimated.glb", Vector2(300.0f, 300.0f), 100.0f},
+    /**
+     * For the quantized Duck.gltf and its Assets
+     * Created by Sony Computer Entertainment Inc.
+     * Licensed under the SCEA Shared Source License, Version 1.0
+     * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Duck/glTF-Quantized
+     */
+    {"Duck.gltf", Vector2(600.0f, 600.0f), 300.0f},
     /**
      * For the Lantern.gltf and its Assets
      * Donated by Microsoft for glTF testing
      * Created by Ryan Martin
      * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Lantern
      */
-    "Lantern.gltf",
+    {"Lantern.gltf", Vector2(600.0f, 600.0f), 0.0f},
     /**
      * For the BoomBox.gltf and its Assets
      * Donated by Microsoft for glTF testing
      * Created by Ryan Martin
      * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/BoomBox
      */
-    "BoomBox.gltf",
+    {"BoomBox.gltf", Vector2(600.0f, 600.0f), 0.0f},
     /**
      * For the DamagedHelmet.glb
      * Battle Damaged Sci-fi Helmet - PBR by theblueturtle_, published under a
      * Creative Commons Attribution-NonCommercial license
      * https://sketchfab.com/models/b81008d513954189a063ff901f7abfe4
      */
-    "DamagedHelmet.glb",
+    {"DamagedHelmet.glb", Vector2(600.0f, 600.0f), 0.0f},
     /**
      * For the microphone.gltf and its Assets
      * Microphone GXL 066 Bafhcteks by Gistold, published under a
      * Creative Commons Attribution-NonCommercial license
      * https://sketchfab.com/models/5172dbe9281a45f48cee8c15bdfa1831
      */
-    "microphone.gltf",
+    {"microphone.gltf", Vector2(600.0f, 600.0f), 0.0f},
     /**
      * For the beer_model.dli and its Assets
      * This model includes a bottle of beer and cube box.
      */
-    "beer_model.dli",
+    {"beer_model.dli", Vector2(600.0f, 600.0f), 0.0f},
     /**
      * For the exercise_model.dli and its Assets
      * This model includes a sportsman
      */
-    "exercise_model.dli"};
+    {"exercise_model.dli", Vector2(600.0f, 600.0f), 0.0f},
+};
+
+const int32_t NUM_OF_GLTF_MODELS = sizeof(gltf_list) / sizeof(gltf_list[0]);
 
 /**
  * For the diffuse and specular cube map texture.
@@ -266,18 +281,11 @@ public:
     }
 
     std::string gltfUrl = modeldir;
-    gltfUrl += gltf_list[index];
+    gltfUrl += gltf_list[index].name;
 
     mModel = Dali::Scene3D::Model::New(gltfUrl);
-    if(index == 0u)
-    {
-      mModel.SetProperty(Dali::Actor::Property::SIZE, Vector2(300, 300));
-      mModel.SetProperty(Dali::Actor::Property::POSITION_Y, 100);
-    }
-    else
-    {
-      mModel.SetProperty(Dali::Actor::Property::SIZE, Vector2(600, 600));
-    }
+    mModel.SetProperty(Dali::Actor::Property::SIZE, gltf_list[index].size);
+    mModel.SetProperty(Dali::Actor::Property::POSITION_Y, gltf_list[index].yPosition);
     mModel.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
     mModel.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
     mModel.SetImageBasedLightSource(uri_diffuse_texture, uri_specular_texture, 0.6f);
@@ -292,7 +300,7 @@ public:
     mReadyToLoad = true;
     if(mModel.GetAnimationCount() > 0)
     {
-      Animation animation = (std::string("exercise_model.dli") == gltf_list[mCurrentGlTF]) ? mModel.GetAnimation("idleToSquatClip_0") : mModel.GetAnimation(0u);
+      Animation animation = (std::string("exercise_model.dli") == gltf_list[mCurrentGlTF].name) ? mModel.GetAnimation("idleToSquatClip_0") : mModel.GetAnimation(0u);
       animation.Play();
       animation.SetLoopCount(0);
     }
diff --git a/resources/models/Duck.bin b/resources/models/Duck.bin
new file mode 100644 (file)
index 0000000..e723475
Binary files /dev/null and b/resources/models/Duck.bin differ
diff --git a/resources/models/Duck.gltf b/resources/models/Duck.gltf
new file mode 100644 (file)
index 0000000..7c5e4c7
--- /dev/null
@@ -0,0 +1,218 @@
+{\r
+  "buffers":[\r
+    {\r
+      "uri":"Duck.bin",\r
+      "byteLength":63656\r
+    }\r
+  ],\r
+  "asset":{\r
+    "version":"2.0",\r
+    "generator":"gltfpack 0.13"\r
+  },\r
+  "extensionsUsed":[\r
+    "KHR_mesh_quantization",\r
+    "KHR_texture_transform"\r
+  ],\r
+  "extensionsRequired":[\r
+    "KHR_mesh_quantization"\r
+  ],\r
+  "bufferViews":[\r
+    {\r
+      "buffer":0,\r
+      "byteOffset":0,\r
+      "byteLength":9596,\r
+      "byteStride":4,\r
+      "target":34962\r
+    },\r
+    {\r
+      "buffer":0,\r
+      "byteOffset":9596,\r
+      "byteLength":19192,\r
+      "byteStride":8,\r
+      "target":34962\r
+    },\r
+    {\r
+      "buffer":0,\r
+      "byteOffset":28788,\r
+      "byteLength":9596,\r
+      "byteStride":4,\r
+      "target":34962\r
+    },\r
+    {\r
+      "buffer":0,\r
+      "byteOffset":38384,\r
+      "byteLength":25272,\r
+      "target":34963\r
+    }\r
+  ],\r
+  "accessors":[\r
+    {\r
+      "bufferView":0,\r
+      "byteOffset":0,\r
+      "componentType":5120,\r
+      "count":2399,\r
+      "type":"VEC3",\r
+      "normalized":true\r
+    },\r
+    {\r
+      "bufferView":1,\r
+      "byteOffset":0,\r
+      "componentType":5123,\r
+      "count":2399,\r
+      "type":"VEC3",\r
+      "min":[\r
+        0,\r
+        0,\r
+        0\r
+      ],\r
+      "max":[\r
+        16383,\r
+        15251,\r
+        11411\r
+      ]\r
+    },\r
+    {\r
+      "bufferView":2,\r
+      "byteOffset":0,\r
+      "componentType":5123,\r
+      "count":2399,\r
+      "type":"VEC2"\r
+    },\r
+    {\r
+      "bufferView":3,\r
+      "byteOffset":0,\r
+      "componentType":5123,\r
+      "count":12636,\r
+      "type":"SCALAR"\r
+    }\r
+  ],\r
+  "images":[\r
+    {\r
+      "uri":"DuckCM.png"\r
+    }\r
+  ],\r
+  "textures":[\r
+    {\r
+      "source":0\r
+    }\r
+  ],\r
+  "materials":[\r
+    {\r
+      "name":"blinn3-fx",\r
+      "pbrMetallicRoughness":{\r
+        "baseColorTexture":{\r
+          "index":0,\r
+          "texCoord":0,\r
+          "extensions":{\r
+            "KHR_texture_transform":{\r
+              "offset":[\r
+                0.0264090002,\r
+                0.019963026\r
+              ],\r
+              "scale":[\r
+                0.000233684244,\r
+                0.000234450286\r
+              ]\r
+            }\r
+          }\r
+        },\r
+        "metallicFactor":0\r
+      }\r
+    }\r
+  ],\r
+  "meshes":[\r
+    {\r
+      "primitives":[\r
+        {\r
+          "attributes":{\r
+            "NORMAL":0,\r
+            "POSITION":1,\r
+            "TEXCOORD_0":2\r
+          },\r
+          "mode":4,\r
+          "indices":3,\r
+          "material":0\r
+        }\r
+      ]\r
+    }\r
+  ],\r
+  "nodes":[\r
+    {\r
+      "mesh":0,\r
+      "translation":[\r
+        -0.692984998,\r
+        0.0992936939,\r
+        -0.613281965\r
+      ],\r
+      "scale":[\r
+        0.900101006161,\r
+        0.900101006161,\r
+        0.900101006161\r
+      ]\r
+    },\r
+    {\r
+      "matrix":[\r
+        0.00999999978,\r
+        0,\r
+        0,\r
+        0,\r
+        0,\r
+        0.00999999978,\r
+        0,\r
+        0,\r
+        0,\r
+        0,\r
+        0.00999999978,\r
+        0,\r
+        0,\r
+        0,\r
+        0,\r
+        1\r
+      ],\r
+      "children":[\r
+        2\r
+      ]\r
+    },\r
+    {\r
+      "matrix":[\r
+        -0.72896868,\r
+        0,\r
+        -0.684547067,\r
+        0,\r
+        -0.425204903,\r
+        0.783693433,\r
+        0.452797294,\r
+        0,\r
+        0.536475062,\r
+        0.621147811,\r
+        -0.57128799,\r
+        0,\r
+        400.113007,\r
+        463.264008,\r
+        -431.078033,\r
+        1\r
+      ],\r
+      "camera":0\r
+    }\r
+  ],\r
+  "scenes":[\r
+    {\r
+      "nodes":[\r
+        0,\r
+        1\r
+      ]\r
+    }\r
+  ],\r
+  "cameras":[\r
+    {\r
+      "type":"perspective",\r
+      "perspective":{\r
+        "yfov":0.660592556,\r
+        "znear":1,\r
+        "aspectRatio":1.5,\r
+        "zfar":10000\r
+      }\r
+    }\r
+  ],\r
+  "scene":0\r
+}
\ No newline at end of file
diff --git a/resources/models/DuckCM.png b/resources/models/DuckCM.png
new file mode 100644 (file)
index 0000000..9fa2dd4
Binary files /dev/null and b/resources/models/DuckCM.png differ