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


C++ Matrix32::get_scale方法代码示例

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


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

示例1: set_canvas_transform

void Viewport::set_canvas_transform(const Matrix32& p_transform) {

	canvas_transform=p_transform;
	VisualServer::get_singleton()->viewport_set_canvas_transform(viewport,find_world_2d()->get_canvas(),canvas_transform);

	Matrix32 xform = (global_canvas_transform * canvas_transform).affine_inverse();
	Size2 ss = get_visible_rect().size;
	SpatialSound2DServer::get_singleton()->listener_set_transform(listener_2d,Matrix32(0,xform.xform(ss*0.5)));
	Vector2 ss2 = ss*xform.get_scale();
	float panrange = MAX(ss2.x,ss2.y);

	SpatialSound2DServer::get_singleton()->listener_set_param(listener_2d,SpatialSound2DServer::LISTENER_PARAM_PAN_RANGE,panrange);


}
开发者ID:ErosOlmi,项目名称:godot,代码行数:15,代码来源:viewport.cpp

示例2: _update_global_transform

void Viewport::_update_global_transform() {


	Matrix32 sxform = stretch_transform * global_canvas_transform;

	VisualServer::get_singleton()->viewport_set_global_canvas_transform(viewport,sxform);

	Matrix32 xform = (sxform * canvas_transform).affine_inverse();
	Size2 ss = get_visible_rect().size;
	SpatialSound2DServer::get_singleton()->listener_set_transform(listener_2d,Matrix32(0,xform.xform(ss*0.5)));
	Vector2 ss2 = ss*xform.get_scale();
	float panrange = MAX(ss2.x,ss2.y);

	SpatialSound2DServer::get_singleton()->listener_set_param(listener_2d,SpatialSound2DServer::LISTENER_PARAM_PAN_RANGE,panrange);

}
开发者ID:ErosOlmi,项目名称:godot,代码行数:16,代码来源:viewport.cpp

示例3: _draw_cell

void TileMapEditor::_draw_cell(int p_cell, const Point2i& p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Matrix32& p_xform) {

	Ref<Texture> t = node->get_tileset()->tile_get_texture(p_cell);

	if (t.is_null())
		return;

	Vector2 tile_ofs = node->get_tileset()->tile_get_texture_offset(p_cell);

	Rect2 r = node->get_tileset()->tile_get_region(p_cell);
	Size2 sc = p_xform.get_scale();

	Rect2 rect = Rect2();
	rect.pos = node->map_to_world(p_point) + node->get_cell_draw_offset();

	if (r.has_no_area()) {
		rect.size = t->get_size();
	} else {
		rect.size = r.size;
	}

	if (rect.size.y > rect.size.x) {
		if ((p_flip_h && (p_flip_v || p_transpose)) || (p_flip_v && !p_transpose))
			tile_ofs.y += rect.size.y - rect.size.x;
	} else if (rect.size.y < rect.size.x) {
		if ((p_flip_v && (p_flip_h || p_transpose)) || (p_flip_h && !p_transpose))
			tile_ofs.x += rect.size.x - rect.size.y;
	}

	if (p_transpose) {
		SWAP(tile_ofs.x, tile_ofs.y);
	}
	if (p_flip_h) {
		sc.x*=-1.0;
		tile_ofs.x*=-1.0;
	}
	if (p_flip_v) {
		sc.y*=-1.0;
		tile_ofs.y*=-1.0;
	}

	if (node->get_tile_origin()==TileMap::TILE_ORIGIN_TOP_LEFT) {

		rect.pos+=tile_ofs;
	} else if (node->get_tile_origin()==TileMap::TILE_ORIGIN_CENTER) {
		rect.pos+=node->get_cell_size()/2;
		Vector2 s = r.size;

		Vector2 center = (s/2) - tile_ofs;

		if (p_flip_h)
			rect.pos.x-=s.x-center.x;
		else
			rect.pos.x-=center.x;

		if (p_flip_v)
			rect.pos.y-=s.y-center.y;
		else
			rect.pos.y-=center.y;
	}

	rect.pos=p_xform.xform(rect.pos);
	rect.size*=sc;

	if (r.has_no_area())
		canvas_item_editor->draw_texture_rect(t, rect, false, Color(1,1,1,0.5), p_transpose);
	else
		canvas_item_editor->draw_texture_rect_region(t, rect, r, Color(1,1,1,0.5), p_transpose);
}
开发者ID:baifang,项目名称:godot,代码行数:69,代码来源:tile_map_editor_plugin.cpp

示例4:

void Body2DSW::update_inertias() {

	//update shapes and motions

	switch(mode) {

		case Physics2DServer::BODY_MODE_RIGID: {

			//update tensor for allshapes, not the best way but should be somehow OK. (inspired from bullet)
			float total_area=0;

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

				total_area+=get_shape_aabb(i).get_area();
			}

			real_t _inertia=0;

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

				const Shape2DSW* shape=get_shape(i);

				float area=get_shape_aabb(i).get_area();

				float mass = area * this->mass / total_area;

				Matrix32 mtx = get_shape_transform(i);
				Vector2 scale = mtx.get_scale();
				_inertia += shape->get_moment_of_inertia(mass,scale) + mass * mtx.get_origin().length_squared();
				//Rect2 ab = get_shape_aabb(i);
				//_inertia+=mass*ab.size.dot(ab.size)/12.0f;



			}

			if (_inertia!=0)
				_inv_inertia=1.0/_inertia;
			else
				_inv_inertia=0.0; //wathever

			if (mass)
				_inv_mass=1.0/mass;
			else
				_inv_mass=0;

		} break;
		case Physics2DServer::BODY_MODE_KINEMATIC:
		case Physics2DServer::BODY_MODE_STATIC: {

			_inv_inertia=0;
			_inv_mass=0;
		} break;
		case Physics2DServer::BODY_MODE_CHARACTER: {

			_inv_inertia=0;
			_inv_mass=1.0/mass;

		} break;
	}
	//_update_inertia_tensor();

	//_update_shapes();

}
开发者ID:TierraDelFuego,项目名称:godot,代码行数:65,代码来源:body_2d_sw.cpp

示例5: _canvas_draw


//.........这里部分代码省略.........
			if (node->get_half_offset()==TileMap::HALF_OFFSET_Y && ABS(over_tile.x)&1)
				endpoints[i]+=cell_xf[1]*0.5;
			endpoints[i]=xform.xform(endpoints[i]);
		}
		Color col;
		if (node->get_cell(over_tile.x,over_tile.y)!=TileMap::INVALID_CELL)
			col=Color(0.2,0.8,1.0,0.8);
		else
			col=Color(1.0,0.4,0.2,0.8);

		for(int i=0;i<4;i++)
			canvas_item_editor->draw_line(endpoints[i],endpoints[(i+1)%4],col,2);



		if (tool==TOOL_DUPLICATING) {

			Rect2i duplicate=selection;
			duplicate.pos=over_tile;


			Vector<Vector2> points;
			points.push_back( xform.xform( node->map_to_world(duplicate.pos ) ));
			points.push_back( xform.xform( node->map_to_world((duplicate.pos+Point2(duplicate.size.x+1,0)) ) ));
			points.push_back( xform.xform( node->map_to_world((duplicate.pos+Point2(duplicate.size.x+1,duplicate.size.y+1))) ));
			points.push_back( xform.xform( node->map_to_world((duplicate.pos+Point2(0,duplicate.size.y+1))) ));
			Color col=Color(0.2,1.0,0.8,0.4);

			canvas_item_editor->draw_colored_polygon(points,col);

		} else {

			Ref<TileSet> ts = node->get_tileset();


			if (ts.is_valid()) {

				int st = get_selected_tile();
				if (ts->has_tile(st)) {

					Ref<Texture> t = ts->tile_get_texture(st);
					if (t.is_valid()) {
						Vector2 from = node->map_to_world(over_tile)+node->get_cell_draw_offset();
						Rect2 r = ts->tile_get_region(st);
						Size2 sc = xform.get_scale();
						if (mirror_x->is_pressed())
							sc.x*=-1.0;
						if (mirror_y->is_pressed())
							sc.y*=-1.0;

						Rect2 rect;
						if (r==Rect2()) {
							rect=Rect2(from,t->get_size());
						} else {

							rect=Rect2(from,r.get_size());
						}


						if (node->get_tile_origin()==TileMap::TILE_ORIGIN_TOP_LEFT) {
							rect.pos+=ts->tile_get_texture_offset(st);

						} else if (node->get_tile_origin()==TileMap::TILE_ORIGIN_CENTER) {
							rect.pos+=node->get_cell_size()/2;
							Vector2 s = r.size;

							Vector2 center = (s/2) - ts->tile_get_texture_offset(st);


							if (mirror_x->is_pressed())
								rect.pos.x-=s.x-center.x;
							else
								rect.pos.x-=center.x;

							if (mirror_y->is_pressed())
								rect.pos.y-=s.y-center.y;
							else
								rect.pos.y-=center.y;
						}

						rect.pos=xform.xform(rect.pos);
						rect.size*=sc;

						if (r==Rect2()) {

							canvas_item_editor->draw_texture_rect(t,rect,false,Color(1,1,1,0.5),transpose->is_pressed());
						} else {

							canvas_item_editor->draw_texture_rect_region(t,rect,r,Color(1,1,1,0.5),transpose->is_pressed());
						}
					}
				}
			}

		}
	}



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


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