本文整理汇总了C++中MeshInstance::get_global_transform方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshInstance::get_global_transform方法的具体用法?C++ MeshInstance::get_global_transform怎么用?C++ MeshInstance::get_global_transform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshInstance
的用法示例。
在下文中一共展示了MeshInstance::get_global_transform方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _find_meshes
void GIProbe::_find_meshes(Node *p_at_node,Baker *p_baker){
MeshInstance *mi = p_at_node->cast_to<MeshInstance>();
if (mi && mi->get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT)) {
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid()) {
Rect3 aabb = mesh->get_aabb();
Transform xf = get_global_transform().affine_inverse() * mi->get_global_transform();
if (Rect3(-extents,extents*2).intersects(xf.xform(aabb))) {
Baker::PlotMesh pm;
pm.local_xform=xf;
pm.mesh=mesh;
for(int i=0;i<mesh->get_surface_count();i++) {
pm.instance_materials.push_back(mi->get_surface_material(i));
}
pm.override_material=mi->get_material_override();
p_baker->mesh_list.push_back(pm);
}
}
}
for(int i=0;i<p_at_node->get_child_count();i++) {
Node *child = p_at_node->get_child(i);
if (!child->get_owner())
continue; //maybe a helper
_find_meshes(child,p_baker);
}
}
示例2: _find_meshes_and_lights
void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, List<PlotMesh> &plot_meshes, List<PlotLight> &plot_lights) {
MeshInstance *mi = Object::cast_to<MeshInstance>(p_at_node);
if (mi && mi->get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT) && mi->is_visible_in_tree()) {
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid()) {
bool all_have_uv2 = true;
for (int i = 0; i < mesh->get_surface_count(); i++) {
if (!(mesh->surface_get_format(i) & Mesh::ARRAY_FORMAT_TEX_UV2)) {
all_have_uv2 = false;
break;
}
}
if (all_have_uv2 && mesh->get_lightmap_size_hint() != Size2()) {
//READY TO BAKE! size hint could be computed if not found, actually..
AABB aabb = mesh->get_aabb();
Transform xf = get_global_transform().affine_inverse() * mi->get_global_transform();
if (AABB(-extents, extents * 2).intersects(xf.xform(aabb))) {
PlotMesh pm;
pm.local_xform = xf;
pm.mesh = mesh;
pm.path = get_path_to(mi);
pm.instance_idx = -1;
for (int i = 0; i < mesh->get_surface_count(); i++) {
pm.instance_materials.push_back(mi->get_surface_material(i));
}
pm.override_material = mi->get_material_override();
plot_meshes.push_back(pm);
}
}
}
}
Spatial *s = Object::cast_to<Spatial>(p_at_node);
if (!mi && s) {
Array meshes = p_at_node->call("get_bake_meshes");
if (meshes.size() && (meshes.size() & 1) == 0) {
Transform xf = get_global_transform().affine_inverse() * s->get_global_transform();
for (int i = 0; i < meshes.size(); i += 2) {
PlotMesh pm;
Transform mesh_xf = meshes[i + 1];
pm.local_xform = xf * mesh_xf;
pm.mesh = meshes[i];
pm.instance_idx = i / 2;
if (!pm.mesh.is_valid())
continue;
pm.path = get_path_to(s);
plot_meshes.push_back(pm);
}
}
}
Light *light = Object::cast_to<Light>(p_at_node);
if (light && light->get_bake_mode() != Light::BAKE_DISABLED) {
PlotLight pl;
Transform xf = get_global_transform().affine_inverse() * light->get_global_transform();
pl.local_xform = xf;
pl.light = light;
plot_lights.push_back(pl);
}
for (int i = 0; i < p_at_node->get_child_count(); i++) {
Node *child = p_at_node->get_child(i);
if (!child->get_owner())
continue; //maybe a helper
_find_meshes_and_lights(child, plot_meshes, plot_lights);
}
}