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


C++ Matrix32函数代码示例

本文整理汇总了C++中Matrix32函数的典型用法代码示例。如果您正苦于以下问题:C++ Matrix32函数的具体用法?C++ Matrix32怎么用?C++ Matrix32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: Matrix32

Matrix32 Node2D::get_relative_transform(const Node *p_parent) const {

	if (p_parent==this)
		return Matrix32();

	Node2D *parent_2d = get_parent()->cast_to<Node2D>();
	ERR_FAIL_COND_V(!parent_2d,Matrix32());
	if (p_parent==parent_2d)
		return get_transform();
	else
		return parent_2d->get_relative_transform(p_parent) * get_transform();
}
开发者ID:Ragar0ck,项目名称:godot,代码行数:12,代码来源:node_2d.cpp

示例2: _update_scroll

void ControlEditor::_update_scroll(float) {

	if (updating_scroll)
		return;

	if (!current_window)
		return;

	Point2 ofs;
	ofs.x=h_scroll->get_val();
	ofs.y=v_scroll->get_val();

//	current_window->set_scroll(-ofs);

	transform=Matrix32();

	transform.scale_basis(Size2(zoom,zoom));
	transform.elements[2]=-ofs*zoom;


	RID viewport = editor->get_scene_root()->get_viewport();

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

	update();

}
开发者ID:AutonomicStudios,项目名称:godot,代码行数:27,代码来源:control_editor_plugin.cpp

示例3: ERR_FAIL_COND_V

Matrix32 Physics2DServerSW::area_get_transform(RID p_area) const {

	Area2DSW *area = area_owner.get(p_area);
	ERR_FAIL_COND_V(!area,Matrix32());

	return area->get_transform();
};
开发者ID:PeaceSells50,项目名称:godot,代码行数:7,代码来源:physics_2d_server_sw.cpp

示例4: get_space

void Body2DSW::integrate_velocities(real_t p_step) {

	if (mode==Physics2DServer::BODY_MODE_STATIC)
		return;

	if (fi_callback)
		get_space()->body_add_to_state_query_list(&direct_state_query_list);

	if (mode==Physics2DServer::BODY_MODE_KINEMATIC) {

		_set_transform(new_transform,false);
		_set_inv_transform(new_transform.affine_inverse());
		if (contacts.size()==0 && linear_velocity==Vector2() && angular_velocity==0)
			set_active(false); //stopped moving, deactivate
		return;
	}

	real_t total_angular_velocity = angular_velocity+biased_angular_velocity;
	Vector2 total_linear_velocity=linear_velocity+biased_linear_velocity;

	real_t angle = get_transform().get_rotation() - total_angular_velocity * p_step;
	Vector2 pos = get_transform().get_origin() + total_linear_velocity * p_step;

	_set_transform(Matrix32(angle,pos),continuous_cd_mode==Physics2DServer::CCD_MODE_DISABLED);
	_set_inv_transform(get_transform().inverse());

	if (continuous_cd_mode!=Physics2DServer::CCD_MODE_DISABLED)
		new_transform=get_transform();

	//_update_inertia_tensor();
}
开发者ID:TierraDelFuego,项目名称:godot,代码行数:31,代码来源:body_2d_sw.cpp

示例5: switch

Matrix32 TileMap::get_cell_transform() const {

	switch(mode) {

		case MODE_SQUARE: {

			Matrix32 m;
			m[0]*=cell_size.x;
			m[1]*=cell_size.y;
			return m;
		} break;
		case MODE_ISOMETRIC: {

			//isometric only makes sense when y is positive in both x and y vectors, otherwise
			//the drawing of tiles will overlap
			Matrix32 m;
			m[0]=Vector2(cell_size.x*0.5,cell_size.y*0.5);
			m[1]=Vector2(-cell_size.x*0.5,cell_size.y*0.5);
			return m;

		} break;
		case MODE_CUSTOM: {

			return custom_transform;
		} break;
	}

	return Matrix32();
}
开发者ID:FEDE0D,项目名称:godot,代码行数:29,代码来源:tile_map.cpp

示例6: _update_stretch_transform

void Viewport::_update_stretch_transform() {

	if (size_override_stretch && size_override) {

		stretch_transform=Matrix32();
		stretch_transform.scale(rect.size/(size_override_size+size_override_margin*2));
		stretch_transform.elements[2]=size_override_margin;

	} else {

		stretch_transform=Matrix32();
	}

	_update_global_transform();

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

示例7: switch

void Camera2D::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_FIXED_PROCESS: {

			_update_scroll();

		} break;
		case NOTIFICATION_TRANSFORM_CHANGED: {


			if (!is_fixed_processing())
				_update_scroll();

		} break;
		case NOTIFICATION_ENTER_SCENE: {

			viewport = NULL;
			Node *n=this;
			while(n){

				viewport = n->cast_to<Viewport>();
				if (viewport)
					break;
				n=n->get_parent();
			}

			canvas = get_canvas();

			RID vp = viewport->get_viewport();

			group_name = "__cameras_"+itos(vp.get_id());
			canvas_group_name ="__cameras_c"+itos(canvas.get_id());
			add_to_group(group_name);
			add_to_group(canvas_group_name);

			_update_scroll();
			first=true;


		} break;
		case NOTIFICATION_EXIT_SCENE: {

			if (is_current()) {
				if (viewport) {
					viewport->set_canvas_transform( Matrix32() );
				}
			}
			remove_from_group(group_name);
			remove_from_group(canvas_group_name);
			viewport=NULL;

		} break;
	}
}
开发者ID:0871087123,项目名称:godot,代码行数:56,代码来源:camera_2d.cpp

示例8: ERR_FAIL_COND_V

Matrix32 CanvasItem::get_viewport_transform() const {

	ERR_FAIL_COND_V(!is_inside_tree(),Matrix32());

	if (canvas_layer) {

		if (get_viewport()) {
			return get_viewport()->get_final_transform() * canvas_layer->get_transform();
		} else {
			return canvas_layer->get_transform();
		}

	} else if (get_viewport()) {
		return get_viewport()->get_final_transform() * get_viewport()->get_canvas_transform();
	}

	return Matrix32();

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

示例9: get_visible_rect

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

示例10: Matrix32

 Variant::operator Matrix32() const {

	 if (type==MATRIX32) {
		 return *_data._matrix32;
	 } else if (type==TRANSFORM) {
		 const Transform& t = *_data._transform;;
		 Matrix32 m;
		 m.elements[0][0]=t.basis.elements[0][0];
		 m.elements[0][1]=t.basis.elements[1][0];
		 m.elements[1][0]=t.basis.elements[0][1];
		 m.elements[1][1]=t.basis.elements[1][1];
		 m.elements[2][0]=t.origin[0];
		 m.elements[2][1]=t.origin[1];
		 return m;
	 } else
		 return Matrix32();
}
开发者ID:kyoconan,项目名称:godot,代码行数:17,代码来源:variant.cpp

示例11: rect

void Polygon2DEditor::_uv_draw() {

	Ref<Texture> base_tex = node->get_texture();
	if (base_tex.is_null())
		return;

	Matrix32 mtx;
	mtx.elements[2]=-uv_draw_ofs;
	mtx.scale_basis(Vector2(uv_draw_zoom,uv_draw_zoom));

	VS::get_singleton()->canvas_item_set_clip(uv_edit_draw->get_canvas_item(),true);
	VS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(),mtx);
	uv_edit_draw->draw_texture(base_tex,Point2());
	VS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(),Matrix32());

	DVector<Vector2> uvs = node->get_uv();
	Ref<Texture> handle = get_icon("EditorHandle","EditorIcons");

	Rect2 rect(Point2(),mtx.basis_xform(base_tex->get_size()));
	rect.expand_to(mtx.basis_xform(uv_edit_draw->get_size()));

	for(int i=0;i<uvs.size();i++) {

		int next = (i+1)%uvs.size();
		uv_edit_draw->draw_line(mtx.xform(uvs[i]),mtx.xform(uvs[next]),Color(0.9,0.5,0.5),2);
		uv_edit_draw->draw_texture(handle,mtx.xform(uvs[i])-handle->get_size()*0.5);
		rect.expand_to(mtx.basis_xform(uvs[i]));
	}

	rect=rect.grow(200);
	updating_uv_scroll=true;
	uv_hscroll->set_min(rect.pos.x);
	uv_hscroll->set_max(rect.pos.x+rect.size.x);
	uv_hscroll->set_page(uv_edit_draw->get_size().x);
	uv_hscroll->set_val(uv_draw_ofs.x);
	uv_hscroll->set_step(0.001);

	uv_vscroll->set_min(rect.pos.y);
	uv_vscroll->set_max(rect.pos.y+rect.size.y);
	uv_vscroll->set_page(uv_edit_draw->get_size().y);
	uv_vscroll->set_val(uv_draw_ofs.y);
	uv_vscroll->set_step(0.001);
	updating_uv_scroll=false;

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

示例12: _add_concave

	void _add_concave(const Vector<Vector2> &p_points, const Matrix32 &p_xform = Matrix32()) {

		Physics2DServer *ps = Physics2DServer::get_singleton();
		VisualServer *vs = VisualServer::get_singleton();

		RID concave = ps->shape_create(Physics2DServer::SHAPE_CONCAVE_POLYGON);
		ps->shape_set_data(concave, p_points);
		RID body = ps->body_create(Physics2DServer::BODY_MODE_STATIC);
		ps->body_set_space(body, space);
		ps->body_add_shape(body, concave);
		ps->body_set_state(body, Physics2DServer::BODY_STATE_TRANSFORM, p_xform);

		RID sprite = vs->canvas_item_create();
		vs->canvas_item_set_parent(sprite, canvas);
		vs->canvas_item_set_transform(sprite, p_xform);
		for (int i = 0; i < p_points.size(); i += 2) {
			vs->canvas_item_add_line(sprite, p_points[i], p_points[i + 1], Color(0, 0, 0), 2);
		}
	}
开发者ID:allkhor,项目名称:godot,代码行数:19,代码来源:test_physics_2d.cpp

示例13: memnew

Variant::Variant(const Matrix32& p_transform) {

	type=MATRIX32;
	_data._matrix32 = memnew( Matrix32( p_transform ) );

}
开发者ID:kyoconan,项目名称:godot,代码行数:6,代码来源:variant.cpp

示例14:

void Physics2DServer::_bind_methods() {


	ObjectTypeDB::bind_method(_MD("shape_create","type"),&Physics2DServer::shape_create);
	ObjectTypeDB::bind_method(_MD("shape_set_data","shape","data"),&Physics2DServer::shape_set_data);

	ObjectTypeDB::bind_method(_MD("shape_get_type","shape"),&Physics2DServer::shape_get_type);
	ObjectTypeDB::bind_method(_MD("shape_get_data","shape"),&Physics2DServer::shape_get_data);


	ObjectTypeDB::bind_method(_MD("space_create"),&Physics2DServer::space_create);
	ObjectTypeDB::bind_method(_MD("space_set_active","space","active"),&Physics2DServer::space_set_active);
	ObjectTypeDB::bind_method(_MD("space_is_active","space"),&Physics2DServer::space_is_active);
	ObjectTypeDB::bind_method(_MD("space_set_param","space","param","value"),&Physics2DServer::space_set_param);
	ObjectTypeDB::bind_method(_MD("space_get_param","space","param"),&Physics2DServer::space_get_param);
	ObjectTypeDB::bind_method(_MD("space_get_direct_state:Physics2DDirectSpaceState","space"),&Physics2DServer::space_get_direct_state);

	ObjectTypeDB::bind_method(_MD("area_create"),&Physics2DServer::area_create);
	ObjectTypeDB::bind_method(_MD("area_set_space","area","space"),&Physics2DServer::area_set_space);
	ObjectTypeDB::bind_method(_MD("area_get_space","area"),&Physics2DServer::area_get_space);

	ObjectTypeDB::bind_method(_MD("area_set_space_override_mode","area","mode"),&Physics2DServer::area_set_space_override_mode);
	ObjectTypeDB::bind_method(_MD("area_get_space_override_mode","area"),&Physics2DServer::area_get_space_override_mode);

	ObjectTypeDB::bind_method(_MD("area_add_shape","area","shape","transform"),&Physics2DServer::area_add_shape,DEFVAL(Matrix32()));
	ObjectTypeDB::bind_method(_MD("area_set_shape","area","shape_idx","shape"),&Physics2DServer::area_set_shape);
	ObjectTypeDB::bind_method(_MD("area_set_shape_transform","area","shape_idx","transform"),&Physics2DServer::area_set_shape_transform);

	ObjectTypeDB::bind_method(_MD("area_get_shape_count","area"),&Physics2DServer::area_get_shape_count);
	ObjectTypeDB::bind_method(_MD("area_get_shape","area","shape_idx"),&Physics2DServer::area_get_shape);
	ObjectTypeDB::bind_method(_MD("area_get_shape_transform","area","shape_idx"),&Physics2DServer::area_get_shape_transform);

	ObjectTypeDB::bind_method(_MD("area_remove_shape","area","shape_idx"),&Physics2DServer::area_remove_shape);
	ObjectTypeDB::bind_method(_MD("area_clear_shapes","area"),&Physics2DServer::area_clear_shapes);


	ObjectTypeDB::bind_method(_MD("area_set_param","area","param","value"),&Physics2DServer::area_set_param);
	ObjectTypeDB::bind_method(_MD("area_set_transform","area","transform"),&Physics2DServer::area_set_transform);

	ObjectTypeDB::bind_method(_MD("area_get_param","area","param"),&Physics2DServer::area_get_param);
	ObjectTypeDB::bind_method(_MD("area_get_transform","area"),&Physics2DServer::area_get_transform);

	ObjectTypeDB::bind_method(_MD("area_attach_object_instance_ID","area","id"),&Physics2DServer::area_attach_object_instance_ID);
	ObjectTypeDB::bind_method(_MD("area_get_object_instance_ID","area"),&Physics2DServer::area_get_object_instance_ID);

	ObjectTypeDB::bind_method(_MD("area_set_monitor_callback","receiver","method"),&Physics2DServer::area_set_monitor_callback);

	ObjectTypeDB::bind_method(_MD("body_create","mode","init_sleeping"),&Physics2DServer::body_create,DEFVAL(BODY_MODE_RIGID),DEFVAL(false));

	ObjectTypeDB::bind_method(_MD("body_set_space","body","space"),&Physics2DServer::body_set_space);
	ObjectTypeDB::bind_method(_MD("body_get_space","body"),&Physics2DServer::body_get_space);

	ObjectTypeDB::bind_method(_MD("body_set_mode","body","mode"),&Physics2DServer::body_set_mode);
	ObjectTypeDB::bind_method(_MD("body_get_mode","body"),&Physics2DServer::body_get_mode);

	ObjectTypeDB::bind_method(_MD("body_add_shape","body","shape","transform"),&Physics2DServer::body_add_shape,DEFVAL(Matrix32()));
	ObjectTypeDB::bind_method(_MD("body_set_shape","body","shape_idx","shape"),&Physics2DServer::body_set_shape);
	ObjectTypeDB::bind_method(_MD("body_set_shape_transform","body","shape_idx","transform"),&Physics2DServer::body_set_shape_transform);
	ObjectTypeDB::bind_method(_MD("body_set_shape_metadata","body","shape_idx","metadata"),&Physics2DServer::body_set_shape_metadata);

	ObjectTypeDB::bind_method(_MD("body_get_shape_count","body"),&Physics2DServer::body_get_shape_count);
	ObjectTypeDB::bind_method(_MD("body_get_shape","body","shape_idx"),&Physics2DServer::body_get_shape);
	ObjectTypeDB::bind_method(_MD("body_get_shape_transform","body","shape_idx"),&Physics2DServer::body_get_shape_transform);
	ObjectTypeDB::bind_method(_MD("body_get_shape_metadata","body","shape_idx"),&Physics2DServer::body_get_shape_metadata);

	ObjectTypeDB::bind_method(_MD("body_remove_shape","body","shape_idx"),&Physics2DServer::body_remove_shape);
	ObjectTypeDB::bind_method(_MD("body_clear_shapes","body"),&Physics2DServer::body_clear_shapes);


	ObjectTypeDB::bind_method(_MD("body_set_shape_as_trigger","body","shape_idx","enable"),&Physics2DServer::body_set_shape_as_trigger);
	ObjectTypeDB::bind_method(_MD("body_is_shape_set_as_trigger","body","shape_idx"),&Physics2DServer::body_is_shape_set_as_trigger);

	ObjectTypeDB::bind_method(_MD("body_attach_object_instance_ID","body","id"),&Physics2DServer::body_attach_object_instance_ID);
	ObjectTypeDB::bind_method(_MD("body_get_object_instance_ID","body"),&Physics2DServer::body_get_object_instance_ID);


	ObjectTypeDB::bind_method(_MD("body_set_continuous_collision_detection_mode","body","mode"),&Physics2DServer::body_set_continuous_collision_detection_mode);
	ObjectTypeDB::bind_method(_MD("body_get_continuous_collision_detection_mode","body"),&Physics2DServer::body_get_continuous_collision_detection_mode);


	ObjectTypeDB::bind_method(_MD("body_set_layer_mask","body","mask"),&Physics2DServer::body_set_layer_mask);
	ObjectTypeDB::bind_method(_MD("body_get_layer_mask","body"),&Physics2DServer::body_get_layer_mask);

	ObjectTypeDB::bind_method(_MD("body_set_user_mask","body","mask"),&Physics2DServer::body_set_user_mask);
	ObjectTypeDB::bind_method(_MD("body_get_user_mask","body"),&Physics2DServer::body_get_user_mask);


	ObjectTypeDB::bind_method(_MD("body_set_param","body","param","value"),&Physics2DServer::body_set_param);
	ObjectTypeDB::bind_method(_MD("body_get_param","body","param"),&Physics2DServer::body_get_param);

	ObjectTypeDB::bind_method(_MD("body_set_state","body","state","value"),&Physics2DServer::body_set_state);
	ObjectTypeDB::bind_method(_MD("body_get_state","body","state"),&Physics2DServer::body_get_state);

	ObjectTypeDB::bind_method(_MD("body_apply_impulse","body","pos","impulse"),&Physics2DServer::body_apply_impulse);
	ObjectTypeDB::bind_method(_MD("body_set_axis_velocity","body","axis_velocity"),&Physics2DServer::body_set_axis_velocity);

	ObjectTypeDB::bind_method(_MD("body_add_collision_exception","body","excepted_body"),&Physics2DServer::body_add_collision_exception);
	ObjectTypeDB::bind_method(_MD("body_remove_collision_exception","body","excepted_body"),&Physics2DServer::body_remove_collision_exception);
//	virtual void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions)=0;

//.........这里部分代码省略.........
开发者ID:ScyDev,项目名称:godot,代码行数:101,代码来源:physics_2d_server.cpp

示例15: switch

bool Variant::is_zero() const {

	switch( type ) {
		case NIL: {

			return true;
		} break;

		// atomic types
		case BOOL: {

			return _data._bool==false;
		} break;
		case INT: {

			return _data._int==0;

		} break;
		case REAL: {

			return _data._real==0;

		} break;
		case STRING: {

			return *reinterpret_cast<const String*>(_data._mem)==String();

		} break;

		// math types

		case VECTOR2: {

			return *reinterpret_cast<const Vector2*>(_data._mem)==Vector2();

		} break;
		case RECT2: {

			return *reinterpret_cast<const Rect2*>(_data._mem)==Rect2();

		} break;
		case MATRIX32: {

			return *_data._matrix32==Matrix32();

		} break;
		case VECTOR3: {

			return *reinterpret_cast<const Vector3*>(_data._mem)==Vector3();

		} break;
		case PLANE: {

			return *reinterpret_cast<const Plane*>(_data._mem)==Plane();

		} break;
/*
		case QUAT: {


		} break;*/
		case _AABB: {

			return *_data._aabb==AABB();
		} break;
		case QUAT: {

			*reinterpret_cast<const Quat*>(_data._mem)==Quat();

		} break;
		case MATRIX3: {

			return *_data._matrix3==Matrix3();

		} break;
		case TRANSFORM: {

			return *_data._transform == Transform();

		} break;

		// misc types
		case COLOR: {

			return *reinterpret_cast<const Color*>(_data._mem)==Color();

		} break;
		case IMAGE: {

			return _data._image->empty();

		} break;
		case _RID: {

			return *reinterpret_cast<const RID*>(_data._mem)==RID();
		} break;
		case OBJECT: {

			return _get_obj().obj==NULL;
		} break;
//.........这里部分代码省略.........
开发者ID:kyoconan,项目名称:godot,代码行数:101,代码来源:variant.cpp


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