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


C++ HBoxContainer::set_area_as_parent_rect方法代码示例

本文整理汇总了C++中HBoxContainer::set_area_as_parent_rect方法的典型用法代码示例。如果您正苦于以下问题:C++ HBoxContainer::set_area_as_parent_rect方法的具体用法?C++ HBoxContainer::set_area_as_parent_rect怎么用?C++ HBoxContainer::set_area_as_parent_rect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HBoxContainer的用法示例。


在下文中一共展示了HBoxContainer::set_area_as_parent_rect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: memnew

MeshEditor::MeshEditor() {

	viewport = memnew( Viewport );
	Ref<World> world;
	world.instance();
	viewport->set_world(world); //use own world
	add_child(viewport);
	viewport->set_process_input(false);

	camera = memnew( Camera );
	camera->set_transform(Transform(Matrix3(),Vector3(0,0,3)));
	camera->set_perspective(45,0.1,10);
	viewport->add_child(camera);

	light1 = memnew( DirectionalLight );
	light1->set_transform(Transform().looking_at(Vector3(-1,-1,-1),Vector3(0,1,0)));
	viewport->add_child(light1);

	light2 = memnew( DirectionalLight );
	light2->set_transform(Transform().looking_at(Vector3(0,1,0),Vector3(0,0,1)));
	light2->set_color(Light::COLOR_DIFFUSE,Color(0.7,0.7,0.7));
	light2->set_color(Light::COLOR_SPECULAR,Color(0.7,0.7,0.7));
	viewport->add_child(light2);

	mesh_instance = memnew( MeshInstance );
	viewport->add_child(mesh_instance);



	set_custom_minimum_size(Size2(1,150));

	HBoxContainer *hb = memnew( HBoxContainer );
	add_child(hb);
	hb->set_area_as_parent_rect(2);

	hb->add_spacer();

	VBoxContainer *vb_light = memnew( VBoxContainer );
	hb->add_child(vb_light);

	light_1_switch = memnew( TextureButton );
	light_1_switch->set_toggle_mode(true);
	vb_light->add_child(light_1_switch);
	light_1_switch->connect("pressed",this,"_button_pressed",varray(light_1_switch));

	light_2_switch = memnew( TextureButton );
	light_2_switch->set_toggle_mode(true);
	vb_light->add_child(light_2_switch);
	light_2_switch->connect("pressed",this,"_button_pressed",varray(light_2_switch));

	first_enter=true;

	rot_x=0;
	rot_y=0;


}
开发者ID:TheArchiver,项目名称:godot,代码行数:57,代码来源:mesh_editor_plugin.cpp

示例2: memnew


//.........这里部分代码省略.........
		vtx_idx++;\

		for (int i=0;i<6;i++) {


			Vector3 face_points[4];
			Vector3 normal_points[4];
			float uv_points[8]={0,0,0,1,1,1,1,0};

			for (int j=0;j<4;j++) {

				float v[3];
				v[0]=1.0;
				v[1]=1-2*((j>>1)&1);
				v[2]=v[1]*(1-2*(j&1));

				for (int k=0;k<3;k++) {

					if (i<3)
						face_points[j][(i+k)%3]=v[k]*(i>=3?-1:1);
					else
						face_points[3-j][(i+k)%3]=v[k]*(i>=3?-1:1);
				}
				normal_points[j]=Vector3();
				normal_points[j][i%3]=(i>=3?-1:1);
			}

		//tri 1
			ADD_VTX(0);
			ADD_VTX(1);
			ADD_VTX(2);
		//tri 2
			ADD_VTX(2);
			ADD_VTX(3);
			ADD_VTX(0);

		}



		Array d;
		d.resize(VS::ARRAY_MAX);
		d[VisualServer::ARRAY_NORMAL]= normals ;
		d[VisualServer::ARRAY_TANGENT]= tangents ;
		d[VisualServer::ARRAY_TEX_UV]= uvs ;
		d[VisualServer::ARRAY_VERTEX]= vertices ;

		PoolVector<int> indices;
		indices.resize(vertices.size());
		for(int i=0;i<vertices.size();i++)
			indices.set(i,i);
		d[VisualServer::ARRAY_INDEX]=indices;

		box_mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES,d);
		box_instance->set_mesh(box_mesh);
		box_instance->hide();



	}

	set_custom_minimum_size(Size2(1,150)*EDSCALE);

	HBoxContainer *hb = memnew( HBoxContainer );
	add_child(hb);
	hb->set_area_as_parent_rect(2);

	VBoxContainer *vb_shape = memnew( VBoxContainer );
	hb->add_child(vb_shape);

	sphere_switch = memnew( TextureButton );
	sphere_switch->set_toggle_mode(true);
	sphere_switch->set_pressed(true);
	vb_shape->add_child(sphere_switch);
	sphere_switch->connect("pressed",this,"_button_pressed",varray(sphere_switch));

	box_switch = memnew( TextureButton );
	box_switch->set_toggle_mode(true);
	box_switch->set_pressed(false);
	vb_shape->add_child(box_switch);
	box_switch->connect("pressed",this,"_button_pressed",varray(box_switch));

	hb->add_spacer();

	VBoxContainer *vb_light = memnew( VBoxContainer );
	hb->add_child(vb_light);

	light_1_switch = memnew( TextureButton );
	light_1_switch->set_toggle_mode(true);
	vb_light->add_child(light_1_switch);
	light_1_switch->connect("pressed",this,"_button_pressed",varray(light_1_switch));

	light_2_switch = memnew( TextureButton );
	light_2_switch->set_toggle_mode(true);
	vb_light->add_child(light_2_switch);
	light_2_switch->connect("pressed",this,"_button_pressed",varray(light_2_switch));

	first_enter=true;

}
开发者ID:baekdahl,项目名称:godot,代码行数:101,代码来源:material_editor_plugin.cpp


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