当前位置: 首页>>代码示例>>C++>>正文


C++ JsonValue::to_json方法代码示例

本文整理汇总了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());
}
开发者ID:dreamsxin,项目名称:Scene3D,代码行数:60,代码来源:model_desc.cpp


注:本文中的JsonValue::to_json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。