SpiecsEngine
 
Loading...
Searching...
No Matches

◆ GltfMeshes()

Spices::GltfMeshes::GltfMeshes ( const Json & data)
inlineexplicit

Constructor Function.

Parameters
[in]dataSpecific Json element.

Definition at line 50 of file GltfMeshes.h.

51 : GltfObject(data)
52 {
54
55 m_MeshesData.resize(data.size());
56
57 for (int i = 0; i < data.size(); i++)
58 {
59 Item& item = m_MeshesData[i];
60 const Json& json = data[i];
61
62 item.name = GltfHelper::GetElementString(json, "name", "");
63
64 if (json.find("primitives") == json.end()) continue;
65
66 auto& primitives = json["primitives"];
67 item.primitives.resize(primitives.size());
68 for (int j = 0; j < primitives.size(); j++)
69 {
70 Primitive& prim = item.primitives[j];
71 auto& primitive = primitives[j];
72
73 prim.POSITION = GltfHelper::GetElementInt(primitive["attributes"], "POSITION", -1);
74 prim.NORMAL = GltfHelper::GetElementInt(primitive["attributes"], "NORMAL", -1);
75 prim.TEXCOORD_0 = GltfHelper::GetElementInt(primitive["attributes"], "TEXCOORD_0", -1);
76 prim.TANGENT = GltfHelper::GetElementInt(primitive["attributes"], "TANGENT", -1);
77
78 prim.indices = GltfHelper::GetElementInt(primitive, "indices", -1);
79 prim.material = GltfHelper::GetElementInt(primitive, "material", -1);
80 prim.mode = GltfHelper::GetElementInt(primitive, "mode", -1);
81 }
82 }
83
84 std::stringstream ss;
85 ss << "Meshes Counts: " << data.size();
86
87 SPICES_CORE_INFO(ss.str())
88 }
#define SPICES_PROFILE_ZONE
static int GetElementInt(const Json::object_t &root, const char *path, int pDefault)
Get int value in Json::object_t.
static std::string GetElementString(const Json::object_t &root, const char *path, const std::string &pDefault)
Get string value in Json::object_t.
std::vector< Item > m_MeshesData
Data of Gltf Json Meshes.
Definition GltfMeshes.h:106
GltfObject(const Json &data)
Constructor Function.
Definition GltfObject.h:33
nlohmann::json Json
using Json insteadd of nlohmann::json
Definition GltfObject.h:25

References GltfMeshes().

Referenced by GltfMeshes().