提示コードですが.jsonファイルの"vertices"の二次元float配列を読み込んでvector型にでも格納したいのですがどうすればいいのでしょうか?
参考サイト: https://www.boost.org/doc/libs/1_74_0/libs/property_map/doc/property_map.html
.json
{ "version":1, "vertexformat":"PosNormTex", "shader":"BasicMesh", "textures":[ "Assets/Cube.png" ], "specularPower":100.0, "vertices":[ [-0.5,-0.5,-0.5,0,0,-1,0,0], [0.5,-0.5,-0.5,0,0,-1,1,0], [-0.5,0.5,-0.5,0,0,-1,0,-1], [0.5,0.5,-0.5,0,0,-1,1,-1], [-0.5,0.5,0.5,0,1,0,0,-1], [0.5,0.5,0.5,0,1,0,1,-1], [-0.5,-0.5,0.5,0,0,1,0,0], [0.5,-0.5,0.5,0,0,1,1,0], [-0.5,0.5,-0.5,0,0,-1,0,-1], [0.5,-0.5,-0.5,0,0,-1,1,0], [-0.5,0.5,-0.5,0,1,0,0,-1], [0.5,0.5,-0.5,0,1,0,1,-1], [-0.5,0.5,0.5,0,1,0,0,-1], [-0.5,0.5,0.5,0,0,1,0,-1], [0.5,0.5,0.5,0,0,1,1,-1], [-0.5,-0.5,0.5,0,0,1,0,0], [-0.5,-0.5,0.5,0,-1,0,0,0], [0.5,-0.5,0.5,0,-1,0,1,0], [-0.5,-0.5,-0.5,0,-1,0,0,0], [0.5,-0.5,-0.5,0,-1,0,1,0], [0.5,-0.5,-0.5,1,0,0,1,0], [0.5,-0.5,0.5,1,0,0,1,0], [0.5,0.5,-0.5,1,0,0,1,-1], [0.5,0.5,0.5,1,0,0,1,-1], [-0.5,-0.5,0.5,-1,0,0,0,0], [-0.5,-0.5,-0.5,-1,0,0,0,0], [-0.5,0.5,0.5,-1,0,0,0,-1], [-0.5,0.5,-0.5,-1,0,0,0,-1] ], "indices":[ [2,1,0], [3,9,8], [4,11,10], [5,11,12], [6,14,13], [7,14,15], [18,17,16], [19,17,18], [22,21,20], [23,21,22], [26,25,24], [27,25,26] ] }
ソースファイル
#include "Game.hpp" #include "Debug.hpp" #include "Windows.h" #include <string> #include <boost/property_tree/ptree.hpp> #include <boost/property_tree/json_parser.hpp> #include <boost/foreach.hpp> #include <boost/optional.hpp> #include <glew/include/GL/glew.h> #include "GL/gl.h" #include <fstream> using namespace boost::property_tree; Game::Game() { } bool Game::Initialization(HDC dc) { mDeviceContext = dc; std::string str = "Assets/Cube.json"; //メッシュを読み込む boost::property_tree::ptree pt; boost::property_tree::read_json(str,pt); BOOST_FOREACH(const ptree::value_type& child,pt.get_child("Cube.vertices")) { // printf("ああああ\n"); const ptree& info = child.second; boost::optional<float> id = info.get_optional<fint>("id"); std::cout <<"id: "<<id.get() <<std::endl; } return true; }
boost 以外のライブラリでも読み込めればよいですか?

一番楽なライブラリ等の名称を教えてくれますでしょうか?
これですね nlohmnn-json
https://qiita.com/yohm/items/0f389ba5c5de4e2df9cf
boost はいろいろとめんどくさいです
回答1件
あなたの回答
tips
プレビュー