MCPcopy Create free account
hub / github.com/MihailRis/voxelcore / loadCustomBlockModel

Method loadCustomBlockModel

src/content/ContentLoader.cpp:241–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241void ContentLoader::loadCustomBlockModel(Block& def, dynamic::Map* primitives) {
242 if (primitives->has("aabbs")) {
243 auto modelboxes = primitives->list("aabbs");
244 for (uint i = 0; i < modelboxes->size(); i++ ) {
245 /* Parse aabb */
246 auto boxarr = modelboxes->list(i);
247 AABB modelbox;
248 modelbox.a = glm::vec3(boxarr->num(0), boxarr->num(1), boxarr->num(2));
249 modelbox.b = glm::vec3(boxarr->num(3), boxarr->num(4), boxarr->num(5));
250 modelbox.b += modelbox.a;
251 def.modelBoxes.push_back(modelbox);
252
253 if (boxarr->size() == 7)
254 for (uint j = 6; j < 12; j++) {
255 def.modelTextures.emplace_back(boxarr->str(6));
256 }
257 else if (boxarr->size() == 12)
258 for (uint j = 6; j < 12; j++) {
259 def.modelTextures.emplace_back(boxarr->str(j));
260 }
261 else
262 for (uint j = 6; j < 12; j++) {
263 def.modelTextures.emplace_back("notfound");
264 }
265 }
266 }
267 if (primitives->has("tetragons")) {
268 auto modeltetragons = primitives->list("tetragons");
269 for (uint i = 0; i < modeltetragons->size(); i++) {
270 /* Parse tetragon to points */
271 auto tgonobj = modeltetragons->list(i);
272 glm::vec3 p1(tgonobj->num(0), tgonobj->num(1), tgonobj->num(2)),
273 xw(tgonobj->num(3), tgonobj->num(4), tgonobj->num(5)),
274 yh(tgonobj->num(6), tgonobj->num(7), tgonobj->num(8));
275 def.modelExtraPoints.push_back(p1);
276 def.modelExtraPoints.push_back(p1+xw);
277 def.modelExtraPoints.push_back(p1+xw+yh);
278 def.modelExtraPoints.push_back(p1+yh);
279
280 def.modelTextures.emplace_back(tgonobj->str(9));
281 }
282 }
283}
284
285void ContentLoader::loadItem(ItemDef& def, const std::string& name, const fs::path& file) {
286 auto root = files::read_json(file);

Callers

nothing calls this directly

Calls 5

listMethod · 0.80
numMethod · 0.80
strMethod · 0.80
hasMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected