本文整理汇总了C++中JsonValue::to_json方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonValue::to_json方法的具体用法?C++ JsonValue::to_json怎么用?C++ JsonValue::to_json使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonValue
的用法示例。
在下文中一共展示了JsonValue::to_json方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: save
void ModelDesc::save(const std::string &filename)
{
JsonValue json_animations = JsonValue::array();
for (const auto &animation : animations)
{
JsonValue json_animation = JsonValue::object();
json_animation["name"].set_string(animation.name);
json_animation["start_frame"].set_number(animation.start_frame);
json_animation["end_frame"].set_number(animation.end_frame);
json_animation["play_speed"].set_number(animation.play_speed);
json_animation["move_speed"].set_number(animation.move_speed);
json_animation["loop"].set_boolean(animation.loop);
json_animation["rarity"].set_number(animation.rarity);
json_animations.items().push_back(json_animation);
}
JsonValue json_attachment_points = JsonValue::array();
for (const auto &attachment : attachment_points)
{
JsonValue json_attachment = JsonValue::object();
json_attachment["bone_name"].set_string(attachment.bone_name);
json_attachment["name"].set_string(attachment.name);
json_attachment["orientation"] = JsonValue::object();
json_attachment["orientation"]["x"].set_number(attachment.orientation.x);
json_attachment["orientation"]["y"].set_number(attachment.orientation.y);
json_attachment["orientation"]["z"].set_number(attachment.orientation.z);
json_attachment["orientation"]["w"].set_number(attachment.orientation.w);
json_attachment["position"] = JsonValue::object();
json_attachment["position"]["x"].set_number(attachment.position.x);
json_attachment["position"]["y"].set_number(attachment.position.y);
json_attachment["position"]["z"].set_number(attachment.position.z);
json_attachment["test_model"].set_string(PathHelp::make_relative(PathHelp::get_fullpath(filename), attachment.test_model));
json_attachment["test_scale"].set_number(attachment.test_scale);
json_attachment_points.items().push_back(json_attachment);
}
JsonValue json_materials = JsonValue::array();
for (const auto &material : materials)
{
JsonValue json_material = JsonValue::object();
json_material["mesh_material"].set_string(material.mesh_material);
json_material["transparent"].set_boolean(material.transparent);
json_material["two_sided"].set_boolean(material.two_sided);
json_material["alpha_test"].set_boolean(material.alpha_test);
json_materials.items().push_back(json_material);
}
JsonValue json_emitters = JsonValue::array();
JsonValue json = JsonValue::object();
json["type"].set_string("fbx-model");
json["version"].set_number(1);
json["animations"] = json_animations;
json["attachment_points"] = json_attachment_points;
json["materials"] = json_materials;
json["emitters"] = json_emitters;
json["fbx_filename"].set_string(PathHelp::make_relative(PathHelp::get_fullpath(filename), fbx_filename));
File::write_all_text(filename, json.to_json());
}