本文整理汇总了C++中group::emplace_back方法的典型用法代码示例。如果您正苦于以下问题:C++ group::emplace_back方法的具体用法?C++ group::emplace_back怎么用?C++ group::emplace_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类group
的用法示例。
在下文中一共展示了group::emplace_back方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_world
void create_world( rendering_assets_type& rendering_assets, black_label::rendering::view& view ) {
static group all_statics;
static auto get_vec3 = [](const boost::property_tree::ptree& root) {
assert(3 == root.size());
auto first = root.begin();
auto x = (*first++).second.get<float>("");
auto y = (*first++).second.get<float>("");
auto z = (*first++).second.get<float>("");
return glm::vec3(x, y, z);
};
path scene_file{"scene.json"};
BOOST_LOG_TRIVIAL(info) << "Importing scene file " << scene_file << "...";
boost::property_tree::ptree root;
boost::property_tree::read_json(scene_file.string(), root);
vector<path> models, dynamics;
vector<glm::mat4> transformations;
for (auto entity : root.get_child("entities") | boost::adaptors::map_values) {
auto model = entity.get<string>("model");
models.emplace_back(move(model));
auto dynamic = entity.get<string>("dynamic");
dynamics.emplace_back(move(dynamic));
glm::mat4 transformation; // Identity matrix
if (auto transformation_root_ = entity.get_child_optional("transformation"))
for (auto& transformation_child : *transformation_root_)
{
if (auto scale = transformation_child.second.get_optional<float>("scale"))
transformation = glm::scale(transformation, glm::vec3{*scale});
if (auto translation = transformation_child.second.get_child_optional("translate"))
transformation = glm::translate(transformation, get_vec3(*translation));
}
transformations.emplace_back(transformation);
}
all_statics.emplace_back(std::make_shared<entities>(
models,
dynamics,
transformations));
using rendering_entities = rendering_assets_type::external_entities;
vector<rendering_entities> asset_data;
asset_data.reserve(all_statics.size());
int id{0};
for (const auto& entity : all_statics)
asset_data.emplace_back(
id++,
boost::make_iterator_range(entity->begin(entity->models), entity->end(entity->models)),
boost::make_iterator_range(entity->begin(entity->transformations), entity->end(entity->transformations)));
rendering_assets.add_statics(cbegin(asset_data), cend(asset_data));
// Camera
view.eye = get_vec3(root.get_child("camera.eye"));
view.target = get_vec3(root.get_child("camera.target"));
view.on_view_moved();
}