本文整理汇总了C++中MeshInstance::get_child_count方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshInstance::get_child_count方法的具体用法?C++ MeshInstance::get_child_count怎么用?C++ MeshInstance::get_child_count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshInstance
的用法示例。
在下文中一共展示了MeshInstance::get_child_count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _import_scene
void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, bool p_merge) {
if (!p_merge)
p_library->clear();
for(int i=0;i<p_scene->get_child_count();i++) {
Node *child = p_scene->get_child(i);
if (!child->cast_to<MeshInstance>()) {
if (child->get_child_count()>0) {
child=child->get_child(0);
if (!child->cast_to<MeshInstance>()) {
continue;
}
} else
continue;
}
MeshInstance *mi = child->cast_to<MeshInstance>();
Ref<Mesh> mesh=mi->get_mesh();
if (mesh.is_null())
continue;
int id = p_library->find_item_name(mi->get_name());
if (id<0) {
id=p_library->get_last_unused_item_id();
p_library->create_item(id);
p_library->set_item_name(id,mi->get_name());
}
p_library->set_item_mesh(id,mesh);
Ref<Shape> collision;
for(int j=0;j<mi->get_child_count();j++) {
#if 1
Node *child2 = mi->get_child(j);
if (!child2->cast_to<StaticBody>())
continue;
StaticBody *sb = child2->cast_to<StaticBody>();
if (sb->get_shape_count()==0)
continue;
collision=sb->get_shape(0);
if (!collision.is_null())
break;
#endif
}
if (!collision.is_null()) {
p_library->set_item_shape(id,collision);
}
}
//generate previews!
if (1) {
Vector<int> ids = p_library->get_item_list();
RID vp = VS::get_singleton()->viewport_create();
VS::ViewportRect vr;
vr.x=0;
vr.y=0;
vr.width=EditorSettings::get_singleton()->get("grid_map/preview_size");
vr.height=EditorSettings::get_singleton()->get("grid_map/preview_size");
VS::get_singleton()->viewport_set_rect(vp,vr);
VS::get_singleton()->viewport_set_as_render_target(vp,true);
VS::get_singleton()->viewport_set_render_target_update_mode(vp,VS::RENDER_TARGET_UPDATE_ALWAYS);
RID scen = VS::get_singleton()->scenario_create();
VS::get_singleton()->viewport_set_scenario(vp,scen);
RID cam = VS::get_singleton()->camera_create();
VS::get_singleton()->camera_set_transform(cam, Transform() );
VS::get_singleton()->viewport_attach_camera(vp,cam);
RID light = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL);
RID lightinst = VS::get_singleton()->instance_create2(light,scen);
VS::get_singleton()->camera_set_orthogonal(cam,1.0,0.01,1000.0);
EditorProgress ep("mlib","Creating Mesh Library",ids.size());
for(int i=0;i<ids.size();i++) {
int id=ids[i];
Ref<Mesh> mesh = p_library->get_item_mesh(id);
if (!mesh.is_valid())
continue;
AABB aabb= mesh->get_aabb();
print_line("aabb: "+aabb);
Vector3 ofs = aabb.pos + aabb.size*0.5;
aabb.pos-=ofs;
Transform xform;
//.........这里部分代码省略.........