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


C++ MeshInstance::get_child_count方法代码示例

本文整理汇总了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;
//.........这里部分代码省略.........
开发者ID:AwsomeGameEngine,项目名称:godot,代码行数:101,代码来源:cube_grid_theme_editor_plugin.cpp


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