Commit 5f403b4b7c937937fa87492011b27ad2c4f1b6b1

Authored by Richard Huang
1 parent aa48d55b

Add the quantized Duck model for testing

Change-Id: I687508dc61c07be76e3170a28d233c0369bc4477
examples/scene3d-model/scene3d-model-example.cpp
... ... @@ -41,54 +41,69 @@ using namespace Dali::Toolkit;
41 41  
42 42 namespace
43 43 {
44   -static constexpr int32_t NUM_OF_GLTF_MODELS = 7;
  44 +struct ModelInfo
  45 +{
  46 + const char* name; ///< The name of the model.
  47 + const Vector2 size; ///< The size of the model
  48 + const float yPosition; ///< The position of the model in the Y axis.
  49 +};
45 50  
46   -const char* gltf_list[7] =
  51 +const ModelInfo gltf_list[] =
47 52 {
48 53 /**
49 54 * For the BoxAnimated.glb
50 55 * Donated by Cesium for glTF testing.
51 56 * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/BoxAnimated
52 57 */
53   - "BoxAnimated.glb",
  58 + {"BoxAnimated.glb", Vector2(300.0f, 300.0f), 100.0f},
  59 + /**
  60 + * For the quantized Duck.gltf and its Assets
  61 + * Created by Sony Computer Entertainment Inc.
  62 + * Licensed under the SCEA Shared Source License, Version 1.0
  63 + * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Duck/glTF-Quantized
  64 + */
  65 + {"Duck.gltf", Vector2(600.0f, 600.0f), 300.0f},
54 66 /**
55 67 * For the Lantern.gltf and its Assets
56 68 * Donated by Microsoft for glTF testing
57 69 * Created by Ryan Martin
58 70 * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Lantern
59 71 */
60   - "Lantern.gltf",
  72 + {"Lantern.gltf", Vector2(600.0f, 600.0f), 0.0f},
61 73 /**
62 74 * For the BoomBox.gltf and its Assets
63 75 * Donated by Microsoft for glTF testing
64 76 * Created by Ryan Martin
65 77 * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/BoomBox
66 78 */
67   - "BoomBox.gltf",
  79 + {"BoomBox.gltf", Vector2(600.0f, 600.0f), 0.0f},
68 80 /**
69 81 * For the DamagedHelmet.glb
70 82 * Battle Damaged Sci-fi Helmet - PBR by theblueturtle_, published under a
71 83 * Creative Commons Attribution-NonCommercial license
72 84 * https://sketchfab.com/models/b81008d513954189a063ff901f7abfe4
73 85 */
74   - "DamagedHelmet.glb",
  86 + {"DamagedHelmet.glb", Vector2(600.0f, 600.0f), 0.0f},
75 87 /**
76 88 * For the microphone.gltf and its Assets
77 89 * Microphone GXL 066 Bafhcteks by Gistold, published under a
78 90 * Creative Commons Attribution-NonCommercial license
79 91 * https://sketchfab.com/models/5172dbe9281a45f48cee8c15bdfa1831
80 92 */
81   - "microphone.gltf",
  93 + {"microphone.gltf", Vector2(600.0f, 600.0f), 0.0f},
82 94 /**
83 95 * For the beer_model.dli and its Assets
84 96 * This model includes a bottle of beer and cube box.
85 97 */
86   - "beer_model.dli",
  98 + {"beer_model.dli", Vector2(600.0f, 600.0f), 0.0f},
87 99 /**
88 100 * For the exercise_model.dli and its Assets
89 101 * This model includes a sportsman
90 102 */
91   - "exercise_model.dli"};
  103 + {"exercise_model.dli", Vector2(600.0f, 600.0f), 0.0f},
  104 +};
  105 +
  106 +const int32_t NUM_OF_GLTF_MODELS = sizeof(gltf_list) / sizeof(gltf_list[0]);
92 107  
93 108 /**
94 109 * For the diffuse and specular cube map texture.
... ... @@ -266,18 +281,11 @@ public:
266 281 }
267 282  
268 283 std::string gltfUrl = modeldir;
269   - gltfUrl += gltf_list[index];
  284 + gltfUrl += gltf_list[index].name;
270 285  
271 286 mModel = Dali::Scene3D::Model::New(gltfUrl);
272   - if(index == 0u)
273   - {
274   - mModel.SetProperty(Dali::Actor::Property::SIZE, Vector2(300, 300));
275   - mModel.SetProperty(Dali::Actor::Property::POSITION_Y, 100);
276   - }
277   - else
278   - {
279   - mModel.SetProperty(Dali::Actor::Property::SIZE, Vector2(600, 600));
280   - }
  287 + mModel.SetProperty(Dali::Actor::Property::SIZE, gltf_list[index].size);
  288 + mModel.SetProperty(Dali::Actor::Property::POSITION_Y, gltf_list[index].yPosition);
281 289 mModel.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
282 290 mModel.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
283 291 mModel.SetImageBasedLightSource(uri_diffuse_texture, uri_specular_texture, 0.6f);
... ... @@ -292,7 +300,7 @@ public:
292 300 mReadyToLoad = true;
293 301 if(mModel.GetAnimationCount() > 0)
294 302 {
295   - Animation animation = (std::string("exercise_model.dli") == gltf_list[mCurrentGlTF]) ? mModel.GetAnimation("idleToSquatClip_0") : mModel.GetAnimation(0u);
  303 + Animation animation = (std::string("exercise_model.dli") == gltf_list[mCurrentGlTF].name) ? mModel.GetAnimation("idleToSquatClip_0") : mModel.GetAnimation(0u);
296 304 animation.Play();
297 305 animation.SetLoopCount(0);
298 306 }
... ...
resources/models/Duck.bin 0 → 100644
No preview for this file type
resources/models/Duck.gltf 0 → 100644
  1 +{
  2 + "buffers":[
  3 + {
  4 + "uri":"Duck.bin",
  5 + "byteLength":63656
  6 + }
  7 + ],
  8 + "asset":{
  9 + "version":"2.0",
  10 + "generator":"gltfpack 0.13"
  11 + },
  12 + "extensionsUsed":[
  13 + "KHR_mesh_quantization",
  14 + "KHR_texture_transform"
  15 + ],
  16 + "extensionsRequired":[
  17 + "KHR_mesh_quantization"
  18 + ],
  19 + "bufferViews":[
  20 + {
  21 + "buffer":0,
  22 + "byteOffset":0,
  23 + "byteLength":9596,
  24 + "byteStride":4,
  25 + "target":34962
  26 + },
  27 + {
  28 + "buffer":0,
  29 + "byteOffset":9596,
  30 + "byteLength":19192,
  31 + "byteStride":8,
  32 + "target":34962
  33 + },
  34 + {
  35 + "buffer":0,
  36 + "byteOffset":28788,
  37 + "byteLength":9596,
  38 + "byteStride":4,
  39 + "target":34962
  40 + },
  41 + {
  42 + "buffer":0,
  43 + "byteOffset":38384,
  44 + "byteLength":25272,
  45 + "target":34963
  46 + }
  47 + ],
  48 + "accessors":[
  49 + {
  50 + "bufferView":0,
  51 + "byteOffset":0,
  52 + "componentType":5120,
  53 + "count":2399,
  54 + "type":"VEC3",
  55 + "normalized":true
  56 + },
  57 + {
  58 + "bufferView":1,
  59 + "byteOffset":0,
  60 + "componentType":5123,
  61 + "count":2399,
  62 + "type":"VEC3",
  63 + "min":[
  64 + 0,
  65 + 0,
  66 + 0
  67 + ],
  68 + "max":[
  69 + 16383,
  70 + 15251,
  71 + 11411
  72 + ]
  73 + },
  74 + {
  75 + "bufferView":2,
  76 + "byteOffset":0,
  77 + "componentType":5123,
  78 + "count":2399,
  79 + "type":"VEC2"
  80 + },
  81 + {
  82 + "bufferView":3,
  83 + "byteOffset":0,
  84 + "componentType":5123,
  85 + "count":12636,
  86 + "type":"SCALAR"
  87 + }
  88 + ],
  89 + "images":[
  90 + {
  91 + "uri":"DuckCM.png"
  92 + }
  93 + ],
  94 + "textures":[
  95 + {
  96 + "source":0
  97 + }
  98 + ],
  99 + "materials":[
  100 + {
  101 + "name":"blinn3-fx",
  102 + "pbrMetallicRoughness":{
  103 + "baseColorTexture":{
  104 + "index":0,
  105 + "texCoord":0,
  106 + "extensions":{
  107 + "KHR_texture_transform":{
  108 + "offset":[
  109 + 0.0264090002,
  110 + 0.019963026
  111 + ],
  112 + "scale":[
  113 + 0.000233684244,
  114 + 0.000234450286
  115 + ]
  116 + }
  117 + }
  118 + },
  119 + "metallicFactor":0
  120 + }
  121 + }
  122 + ],
  123 + "meshes":[
  124 + {
  125 + "primitives":[
  126 + {
  127 + "attributes":{
  128 + "NORMAL":0,
  129 + "POSITION":1,
  130 + "TEXCOORD_0":2
  131 + },
  132 + "mode":4,
  133 + "indices":3,
  134 + "material":0
  135 + }
  136 + ]
  137 + }
  138 + ],
  139 + "nodes":[
  140 + {
  141 + "mesh":0,
  142 + "translation":[
  143 + -0.692984998,
  144 + 0.0992936939,
  145 + -0.613281965
  146 + ],
  147 + "scale":[
  148 + 0.900101006161,
  149 + 0.900101006161,
  150 + 0.900101006161
  151 + ]
  152 + },
  153 + {
  154 + "matrix":[
  155 + 0.00999999978,
  156 + 0,
  157 + 0,
  158 + 0,
  159 + 0,
  160 + 0.00999999978,
  161 + 0,
  162 + 0,
  163 + 0,
  164 + 0,
  165 + 0.00999999978,
  166 + 0,
  167 + 0,
  168 + 0,
  169 + 0,
  170 + 1
  171 + ],
  172 + "children":[
  173 + 2
  174 + ]
  175 + },
  176 + {
  177 + "matrix":[
  178 + -0.72896868,
  179 + 0,
  180 + -0.684547067,
  181 + 0,
  182 + -0.425204903,
  183 + 0.783693433,
  184 + 0.452797294,
  185 + 0,
  186 + 0.536475062,
  187 + 0.621147811,
  188 + -0.57128799,
  189 + 0,
  190 + 400.113007,
  191 + 463.264008,
  192 + -431.078033,
  193 + 1
  194 + ],
  195 + "camera":0
  196 + }
  197 + ],
  198 + "scenes":[
  199 + {
  200 + "nodes":[
  201 + 0,
  202 + 1
  203 + ]
  204 + }
  205 + ],
  206 + "cameras":[
  207 + {
  208 + "type":"perspective",
  209 + "perspective":{
  210 + "yfov":0.660592556,
  211 + "znear":1,
  212 + "aspectRatio":1.5,
  213 + "zfar":10000
  214 + }
  215 + }
  216 + ],
  217 + "scene":0
  218 +}
0 219 \ No newline at end of file
... ...
resources/models/DuckCM.png 0 → 100644

15.9 KB