本文整理汇总了C++中MeshInstance::add_child方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshInstance::add_child方法的具体用法?C++ MeshInstance::add_child怎么用?C++ MeshInstance::add_child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshInstance
的用法示例。
在下文中一共展示了MeshInstance::add_child方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _fix_node
//.........这里部分代码省略.........
// step 3 bubbly sort points
int swaps=0;
do {
swaps=0;
for(int i=0;i<portal_points.size()-1;i++) {
float a = portal_points[i].atan2();
float b = portal_points[i+1].atan2();
if (a>b) {
SWAP( portal_points[i], portal_points[i+1] );
swaps++;
}
}
} while(swaps);
Portal *portal = memnew( Portal );
portal->set_shape(portal_points);
portal->set_transform( mi->get_transform() * t);
p_node->replace_by(portal);
memdelete(p_node);
p_node=portal;
} else if (p_node->cast_to<MeshInstance>()) {
//last attempt, maybe collision insde the mesh data
MeshInstance *mi = p_node->cast_to<MeshInstance>();
Ref<Mesh> mesh = mi->get_mesh();
if (!mesh.is_null()) {
if (p_flags&SCENE_FLAG_CREATE_COLLISIONS && _teststr(mesh->get_name(),"col")) {
mesh->set_name( _fixstr(mesh->get_name(),"col") );
Ref<Shape> shape;
if (collision_map.has(mesh)) {
shape = collision_map[mesh];
} else {
shape = mesh->create_trimesh_shape();
if (!shape.is_null())
collision_map[mesh]=shape;
}
if (!shape.is_null()) {
#if 0
StaticBody* static_body = memnew( StaticBody );
ERR_FAIL_COND_V(!static_body,NULL);
static_body->set_name( String(mesh->get_name()) + "_col" );
shape->set_name(static_body->get_name());
static_body->add_shape(shape);
mi->add_child(static_body);
if (mi->get_owner())
static_body->set_owner( mi->get_owner() );
#endif
}
}
for(int i=0;i<mesh->get_surface_count();i++) {
Ref<FixedMaterial> fm = mesh->surface_get_material(i);
if (fm.is_valid()) {
String name = fm->get_name();
if (_teststr(name,"alpha")) {
fm->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA,true);
name=_fixstr(name,"alpha");
}
if (_teststr(name,"vcol")) {
fm->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY,true);
name=_fixstr(name,"vcol");
}
fm->set_name(name);
}
}
}
}
return p_node;
}