<NME> sci_fi_helmet_scene.cpp
<BEF> ADDFILE
<MSG> Added Sci Fi Helmet Scene (glTF)

<DFF> @@ -0,0 +1,49 @@
+#include <babylon/samples/loaders/gltf/furtherpbrmodels/sci_fi_helmet_scene.h>
+
+#include <babylon/cameras/arc_rotate_camera.h>
+#include <babylon/engines/scene.h>
+#include <babylon/helpers/environment_helper.h>
+#include <babylon/loading/glTF/gltf_file_loader.h>
+#include <babylon/loading/scene_loader.h>
+
+namespace BABYLON {
+namespace Samples {
+
+SciFiHelmetScene::SciFiHelmetScene(ICanvas* iCanvas) : IRenderableScene(iCanvas)
+{
+  GLTF2::GLTFFileLoader::RegisterAsSceneLoaderPlugin();
+}
+
+SciFiHelmetScene::~SciFiHelmetScene()
+{
+}
+
+const char* SciFiHelmetScene::getName()
+{
+  return "Sci Fi Helmet Scene (glTF)";
+}
+
+void SciFiHelmetScene::initializeScene(ICanvas* /*canvas*/, Scene* scene)
+{
+  SceneLoader::ImportMesh(
+    {}, "glTF-Sample-Models/2.0/SciFiHelmet/glTF/", "SciFiHelmet.gltf", scene,
+    [scene](const std::vector<AbstractMeshPtr>& /*meshes*/,
+            const std::vector<IParticleSystemPtr>& /*particleSystems*/,
+            const std::vector<SkeletonPtr>& /*skeletons*/,
+            const std::vector<AnimationGroupPtr>& /*animationGroups*/) {
+      scene->createDefaultCameraOrLight(true, true, true);
+      // Set the camera position
+      auto camera
+        = std::static_pointer_cast<ArcRotateCamera>(scene->activeCamera);
+      if (camera) {
+        camera->wheelPrecision = 100.f;
+        camera->setTarget(Vector3::Zero());
+        camera->alpha  = 0.9f;
+        camera->beta   = 1.f;
+        camera->radius = Math::PI2;
+      }
+    });
+}
+
+} // end of namespace Samples
+} // end of namespace BABYLON

{'commit': 'diff --git a/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet.bin b/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet.bin\nnew file mode 100644\nindex 000000000..3b8f70e21\nBinary files /dev/null and b/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet.bin differ\ndiff --git a/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet.gltf b/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet.gltf\nnew file mode 100644\nindex 000000000..dd3314682\n--- /dev/null\n+++ b/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet.gltf\n@@ -0,0 +1,228 @@\n+{\n+   "accessors" : [\n+      {\n+         "bufferView" : 0,\n+         "byteOffset" : 0,\n+         "componentType" : 5125,\n+         "count" : 70074,\n+         "max" : [\n+            70073\n+         ],\n+         "min" : [\n+            0\n+         ],\n+         "type" : "SCALAR"\n+      },\n+      {\n+         "bufferView" : 1,\n+         "byteOffset" : 0,\n+         "componentType" : 5126,\n+         "count" : 70074,\n+         "max" : [\n+            1.1511525,\n+            1.4587184,\n+            1.2511277\n+         ],\n+         "min" : [\n+            -1.1511525,\n+            -1.4587183,\n+            -1.2511287\n+         ],\n+         "type" : "VEC3"\n+      },\n+      {\n+         "bufferView" : 2,\n+         "byteOffset" : 0,\n+         "componentType" : 5126,\n+         "count" : 70074,\n+         "max" : [\n+            0.99993396,\n+            0.9998779,\n+            0.9999757\n+         ],\n+         "min" : [\n+            -0.99993396,\n+            -0.9999633,\n+            -0.9999864\n+         ],\n+         "type" : "VEC3"\n+      },\n+      {\n+         "bufferView" : 3,\n+         "byteOffset" : 0,\n+         "componentType" : 5126,\n+         "count" : 70074,\n+         "max" : [\n+            0.9999959,\n+            1.000000,\n+            0.9999942,\n+            1.000000\n+         ],\n+         "min" : [\n+            -0.99999845,\n+            -0.99996936,\n+            -0.9999994,\n+            1.000000\n+         ],\n+         "type" : "VEC4"\n+      },\n+      {\n+         "bufferView" : 4,\n+         "byteOffset" : 0,\n+         "componentType" : 5126,\n+         "count" : 70074,\n+         "max" : [\n+            0.995369,\n+            0.990894\n+         ],\n+         "min" : [\n+            0.003625,\n+            0.0064439773\n+         ],\n+         "type" : "VEC2"\n+      }\n+   ],\n+   "asset" : {\n+      "generator" : "VKTS glTF 2.0 exporter",\n+      "version" : "2.0"\n+   },\n+   "bufferViews" : [\n+      {\n+         "buffer" : 0,\n+         "byteLength" : 280296,\n+         "byteOffset" : 0,\n+         "target" : 34963\n+      },\n+      {\n+         "buffer" : 0,\n+         "byteLength" : 840888,\n+         "byteOffset" : 280296,\n+         "target" : 34962\n+      },\n+      {\n+         "buffer" : 0,\n+         "byteLength" : 840888,\n+         "byteOffset" : 1121184,\n+         "target" : 34962\n+      },\n+      {\n+         "buffer" : 0,\n+         "byteLength" : 1121184,\n+         "byteOffset" : 1962072,\n+         "target" : 34962\n+      },\n+      {\n+         "buffer" : 0,\n+         "byteLength" : 560592,\n+         "byteOffset" : 3083256,\n+         "target" : 34962\n+      }\n+   ],\n+   "buffers" : [\n+      {\n+         "byteLength" : 3643848,\n+         "uri" : "SciFiHelmet.bin"\n+      }\n+   ],\n+   "images" : [\n+      {\n+         "uri" : "SciFiHelmet_BaseColor.png"\n+      },\n+      {\n+         "uri" : "SciFiHelmet_MetallicRoughness.png"\n+      },\n+      {\n+         "uri" : "SciFiHelmet_Normal.png"\n+      },\n+      {\n+         "uri" : "SciFiHelmet_AmbientOcclusion.png"\n+      }\n+   ],\n+   "materials" : [\n+      {\n+         "name" : "SciFiHelmet",\n+         "normalTexture" : {\n+            "index" : 2\n+         },\n+         "occlusionTexture" : {\n+            "index" : 3\n+         },\n+         "pbrMetallicRoughness" : {\n+            "baseColorTexture" : {\n+               "index" : 0\n+            },\n+            "metallicRoughnessTexture" : {\n+               "index" : 1\n+            }\n+         }\n+      }\n+   ],\n+   "meshes" : [\n+      {\n+         "name" : "SciFiHelmet",\n+         "primitives" : [\n+            {\n+               "attributes" : {\n+                  "NORMAL" : 2,\n+                  "POSITION" : 1,\n+                  "TANGENT" : 3,\n+                  "TEXCOORD_0" : 4\n+               },\n+               "indices" : 0,\n+               "material" : 0,\n+               "mode" : 4\n+            }\n+         ]\n+      }\n+   ],\n+   "nodes" : [\n+      {\n+         "name" : "Camera",\n+         "rotation" : [\n+            0.483536,\n+            0.336872,\n+            -0.208704,\n+            0.780483\n+         ],\n+         "translation" : [\n+            7.481132,\n+            5.343665,\n+            6.507640\n+         ]\n+      },\n+      {\n+         "mesh" : 0,\n+         "name" : "SciFiHelmet"\n+      }\n+   ],\n+   "samplers" : [\n+      {}\n+   ],\n+   "scene" : 0,\n+   "scenes" : [\n+      {\n+         "nodes" : [\n+            0,\n+            1\n+         ]\n+      }\n+   ],\n+   "textures" : [\n+      {\n+         "sampler" : 0,\n+         "source" : 0\n+      },\n+      {\n+         "sampler" : 0,\n+         "source" : 1\n+      },\n+      {\n+         "sampler" : 0,\n+         "source" : 2\n+      },\n+      {\n+         "sampler" : 0,\n+         "source" : 3\n+      }\n+   ]\n+}\ndiff --git a/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet_AmbientOcclusion.png b/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet_AmbientOcclusion.png\nnew file mode 100644\nindex 000000000..b6b7c2441\nBinary files /dev/null and b/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet_AmbientOcclusion.png differ\ndiff --git a/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet_BaseColor.png b/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet_BaseColor.png\nnew file mode 100644\nindex 000000000..3c7c010b8\nBinary files /dev/null and b/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet_BaseColor.png differ\ndiff --git a/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet_MetallicRoughness.png b/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet_MetallicRoughness.png\nnew file mode 100644\nindex 000000000..3e6501b90\nBinary files /dev/null and b/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet_MetallicRoughness.png differ\ndiff --git a/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet_Normal.png b/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet_Normal.png\nnew file mode 100644\nindex 000000000..5aeeced24\nBinary files /dev/null and b/assets/glTF-Sample-Models/2.0/SciFiHelmet/glTF/SciFiHelmet_Normal.png differ\ndiff --git a/src/Samples/include/babylon/samples/loaders/gltf/furtherpbrmodels/sci_fi_helmet_scene.h b/src/Samples/include/babylon/samples/loaders/gltf/furtherpbrmodels/sci_fi_helmet_scene.h\nnew file mode 100644\nindex 000000000..1277dc52e\n--- /dev/null\n+++ b/src/Samples/include/babylon/samples/loaders/gltf/furtherpbrmodels/sci_fi_helmet_scene.h\n@@ -0,0 +1,30 @@\n+#ifndef BABYLON_SAMPLES_LOADERS_GLTF_FURTHER_PBR_MODELS_SCI_FI_HELMET_SCENE_H\n+#define BABYLON_SAMPLES_LOADERS_GLTF_FURTHER_PBR_MODELS_SCI_FI_HELMET_SCENE_H\n+\n+#include <babylon/interfaces/irenderable_scene.h>\n+\n+namespace BABYLON {\n+namespace Samples {\n+\n+/**\n+ * @brief Sci Fi Helmet Scene (glTF). Sci Fi Helmet having unsigned integer\n+ * indices.\n+ * @see https://doc.babylonjs.com/how_to/load_from_any_file_type\n+ * @see\n+ * https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/SciFiHelmet\n+ */\n+struct SciFiHelmetScene : public IRenderableScene {\n+\n+  SciFiHelmetScene(ICanvas* iCanvas);\n+  ~SciFiHelmetScene() override;\n+\n+  const char* getName() override;\n+  void initializeScene(ICanvas* canvas, Scene* scene) override;\n+\n+}; // end of struct SciFiHelmetScene\n+\n+} // end of namespace Samples\n+} // end of namespace BABYLON\n+\n+#endif // end of\n+       // BABYLON_SAMPLES_LOADERS_GLTF_FURTHER_PBR_MODELS_SCI_FI_HELMET_SCENE_H\ndiff --git a/src/Samples/src/samples/loaders/gltf/_loaders_gltf_samples_index.cpp b/src/Samples/src/samples/loaders/gltf/_loaders_gltf_samples_index.cpp\nindex 9c759f847..fadb2935e 100644\n--- a/src/Samples/src/samples/loaders/gltf/_loaders_gltf_samples_index.cpp\n+++ b/src/Samples/src/samples/loaders/gltf/_loaders_gltf_samples_index.cpp\n@@ -31,6 +31,7 @@\n #include <babylon/samples/loaders/gltf/furtherpbrmodels/animated_cube_scene.h>\n #include <babylon/samples/loaders/gltf/furtherpbrmodels/antique_camera_scene.h>\n #include <babylon/samples/loaders/gltf/furtherpbrmodels/cube_scene.h>\n+#include <babylon/samples/loaders/gltf/furtherpbrmodels/sci_fi_helmet_scene.h>\n #include <babylon/samples/loaders/gltf/furtherpbrmodels/suzanne_scene.h>\n #include <babylon/samples/loaders/gltf/furtherpbrmodels/two_sided_plane_scene.h>\n \n@@ -195,6 +196,12 @@ _LoadersGLTFSamplesIndex::_LoadersGLTFSamplesIndex()\n                       [](ICanvas* iCanvas) {                         //\n                         return std::make_unique<CubeScene>(iCanvas); //\n                       });                                            //\n+  // Sci Fi Helmet Scene (glTF)\n+  _samples["SciFiHelmetGLTFScene"]\n+    = std::make_tuple(true,                                                 //\n+                      [](ICanvas* iCanvas) {                                //\n+                        return std::make_unique<SciFiHelmetScene>(iCanvas); //\n+                      });                                                   //\n   // Suzanne Scene (glTF)\n   _samples["SuzanneGLTFScene"]\n     = std::make_tuple(true,                                             //\ndiff --git a/src/Samples/src/samples/loaders/gltf/furtherpbrmodels/sci_fi_helmet_scene.cpp b/src/Samples/src/samples/loaders/gltf/furtherpbrmodels/sci_fi_helmet_scene.cpp\nnew file mode 100644\nindex 000000000..5442cdbe9\n--- /dev/null\n+++ b/src/Samples/src/samples/loaders/gltf/furtherpbrmodels/sci_fi_helmet_scene.cpp\n@@ -0,0 +1,49 @@\n+#include <babylon/samples/loaders/gltf/furtherpbrmodels/sci_fi_helmet_scene.h>\n+\n+#include <babylon/cameras/arc_rotate_camera.h>\n+#include <babylon/engines/scene.h>\n+#include <babylon/helpers/environment_helper.h>\n+#include <babylon/loading/glTF/gltf_file_loader.h>\n+#include <babylon/loading/scene_loader.h>\n+\n+namespace BABYLON {\n+namespace Samples {\n+\n+SciFiHelmetScene::SciFiHelmetScene(ICanvas* iCanvas) : IRenderableScene(iCanvas)\n+{\n+  GLTF2::GLTFFileLoader::RegisterAsSceneLoaderPlugin();\n+}\n+\n+SciFiHelmetScene::~SciFiHelmetScene()\n+{\n+}\n+\n+const char* SciFiHelmetScene::getName()\n+{\n+  return "Sci Fi Helmet Scene (glTF)";\n+}\n+\n+void SciFiHelmetScene::initializeScene(ICanvas* /*canvas*/, Scene* scene)\n+{\n+  SceneLoader::ImportMesh(\n+    {}, "glTF-Sample-Models/2.0/SciFiHelmet/glTF/", "SciFiHelmet.gltf", scene,\n+    [scene](const std::vector<AbstractMeshPtr>& /*meshes*/,\n+            const std::vector<IParticleSystemPtr>& /*particleSystems*/,\n+            const std::vector<SkeletonPtr>& /*skeletons*/,\n+            const std::vector<AnimationGroupPtr>& /*animationGroups*/) {\n+      scene->createDefaultCameraOrLight(true, true, true);\n+      // Set the camera position\n+      auto camera\n+        = std::static_pointer_cast<ArcRotateCamera>(scene->activeCamera);\n+      if (camera) {\n+        camera->wheelPrecision = 100.f;\n+        camera->setTarget(Vector3::Zero());\n+        camera->alpha  = 0.9f;\n+        camera->beta   = 1.f;\n+        camera->radius = Math::PI2;\n+      }\n+    });\n+}\n+\n+} // end of namespace Samples\n+} // end of namespace BABYLON\n', 'commit_subject': 'Added Sci Fi Helmet Scene (glTF)', 'repo_name': 'samdauwe/BabylonCpp', 'committer': {'name': 'samdauwe', 'email': '637c8055e0642816555907e78ef80a031b1d7a65@gmail.com', 'time_sec': '1561488957', 'tz_offset': '120', 'date': {'seconds': '1561488957'}}, 'commit_tree': '5226cf387ae1e433ee79aa425299841523714d8e', 'commit_message': 'Added Sci Fi Helmet Scene (glTF)\n', 'language_name': 'Python', 'license': 'apache-2.0', 'hunks': '@@ -0,0 +1,49 @@\n+#include <babylon/samples/loaders/gltf/furtherpbrmodels/sci_fi_helmet_scene.h>\n+\n+#include <babylon/cameras/arc_rotate_camera.h>\n+#include <babylon/engines/scene.h>\n+#include <babylon/helpers/environment_helper.h>\n+#include <babylon/loading/glTF/gltf_file_loader.h>\n+#include <babylon/loading/scene_loader.h>\n+\n+namespace BABYLON {\n+namespace Samples {\n+\n+SciFiHelmetScene::SciFiHelmetScene(ICanvas* iCanvas) : IRenderableScene(iCanvas)\n+{\n+  GLTF2::GLTFFileLoader::RegisterAsSceneLoaderPlugin();\n+}\n+\n+SciFiHelmetScene::~SciFiHelmetScene()\n+{\n+}\n+\n+const char* SciFiHelmetScene::getName()\n+{\n+  return "Sci Fi Helmet Scene (glTF)";\n+}\n+\n+void SciFiHelmetScene::initializeScene(ICanvas* /*canvas*/, Scene* scene)\n+{\n+  SceneLoader::ImportMesh(\n+    {}, "glTF-Sample-Models/2.0/SciFiHelmet/glTF/", "SciFiHelmet.gltf", scene,\n+    [scene](const std::vector<AbstractMeshPtr>& /*meshes*/,\n+            const std::vector<IParticleSystemPtr>& /*particleSystems*/,\n+            const std::vector<SkeletonPtr>& /*skeletons*/,\n+            const std::vector<AnimationGroupPtr>& /*animationGroups*/) {\n+      scene->createDefaultCameraOrLight(true, true, true);\n+      // Set the camera position\n+      auto camera\n+        = std::static_pointer_cast<ArcRotateCamera>(scene->activeCamera);\n+      if (camera) {\n+        camera->wheelPrecision = 100.f;\n+        camera->setTarget(Vector3::Zero());\n+        camera->alpha  = 0.9f;\n+        camera->beta   = 1.f;\n+        camera->radius = Math::PI2;\n+      }\n+    });\n+}\n+\n+} // end of namespace Samples\n+} // end of namespace BABYLON\n', 'addition_count': 49, 'deletion_count': 0, 'src_file': '/dev/null', 'tgt_file': 'b/src/Samples/src/samples/loaders/gltf/furtherpbrmodels/sci_fi_helmet_scene.cpp', 'file_extension': '.cpp', 'before_file': 'ADDFILE', 'message': 'Added Sci Fi Helmet Scene (glTF)\n', 'author_name': 'samdauwe', 'lang': 'cpp'}