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


C++ Spatial::set_transform方法代码示例

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


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

示例1: _update_remote

void RemoteTransform::_update_remote() {

	if (!is_inside_tree())
		return;

	if (!cache)
		return;

	Spatial *n = Object::cast_to<Spatial>(ObjectDB::get_instance(cache));
	if (!n)
		return;

	if (!n->is_inside_tree())
		return;

	//todo make faster
	if (use_global_coordinates) {

		if (update_remote_position && update_remote_rotation && update_remote_scale) {
			n->set_global_transform(get_global_transform());
		} else {
			Transform n_trans = n->get_global_transform();
			Transform our_trans = get_global_transform();

			if (!update_remote_position)
				our_trans.set_origin(n_trans.get_origin());

			n->set_global_transform(our_trans);

			if (!update_remote_rotation)
				n->set_rotation(n_trans.basis.get_rotation());

			if (!update_remote_scale)
				n->set_scale(n_trans.basis.get_scale());
		}

	} else {
		if (update_remote_position && update_remote_rotation && update_remote_scale) {
			n->set_global_transform(get_global_transform());
		} else {
			Transform n_trans = n->get_transform();
			Transform our_trans = get_transform();

			if (!update_remote_position)
				our_trans.set_origin(n_trans.get_origin());

			n->set_transform(our_trans);

			if (!update_remote_rotation)
				n->set_rotation(n_trans.basis.get_rotation());

			if (!update_remote_scale)
				n->set_scale(n_trans.basis.get_scale());
		}
	}
}
开发者ID:RandomShaper,项目名称:godot,代码行数:56,代码来源:remote_transform.cpp

示例2: _notification


//.........这里部分代码省略.........
			Bone *bonesptr=&bones[0];
			int len=bones.size();

			vs->skeleton_resize( skeleton, len ); // if same size, nothin really happens

			// pose changed, rebuild cache of inverses
			if (rest_global_inverse_dirty) {

				// calculate global rests and invert them
				for (int i=0;i<len;i++) {
					Bone &b=bonesptr[i];
					if (b.parent>=0)
						b.rest_global_inverse=bonesptr[b.parent].rest_global_inverse * b.rest;
					else
						b.rest_global_inverse=b.rest;
				}
				for (int i=0;i<len;i++) {
					Bone &b=bonesptr[i];
					b.rest_global_inverse.affine_invert();
				}

				rest_global_inverse_dirty=false;

			}

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

				Bone &b=bonesptr[i];

				if (b.disable_rest) {
					if (b.enabled) {

						Transform pose=b.pose;
						if (b.custom_pose_enable) {

							pose = b.custom_pose * pose;
						}

						if (b.parent>=0) {

							b.pose_global=bonesptr[b.parent].pose_global * pose;
						} else {

							b.pose_global=pose;
						}
					} else {

						if (b.parent>=0) {

							b.pose_global=bonesptr[b.parent].pose_global;
						} else {

							b.pose_global=Transform();
						}
					}

				} else {
					if (b.enabled) {

						Transform pose=b.pose;
						if (b.custom_pose_enable) {

							pose = b.custom_pose * pose;
						}

						if (b.parent>=0) {

							b.pose_global=bonesptr[b.parent].pose_global * (b.rest * pose);
						} else {

							b.pose_global=b.rest * pose;
						}
					} else {

						if (b.parent>=0) {

							b.pose_global=bonesptr[b.parent].pose_global * b.rest;
						} else {

							b.pose_global=b.rest;
						}
					}
				}

				vs->skeleton_bone_set_transform( skeleton, i,  b.pose_global * b.rest_global_inverse );

				for(List<uint32_t>::Element *E=b.nodes_bound.front();E;E=E->next()) {

					Object *obj=ObjectDB::get_instance(E->get());
					ERR_CONTINUE(!obj);
					Spatial *sp = obj->cast_to<Spatial>();
					ERR_CONTINUE(!sp);
					sp->set_transform(b.pose_global);
				}
			}

			dirty=false;
		} break;
	}
}
开发者ID:03050903,项目名称:godot,代码行数:101,代码来源:skeleton.cpp

示例3: _notification


//.........这里部分代码省略.........

			_update_process_order();

			const int *order = process_order.ptr();

			// pose changed, rebuild cache of inverses
			if (rest_global_inverse_dirty) {

				// calculate global rests and invert them
				for (int i = 0; i < len; i++) {
					Bone &b = bonesptr[order[i]];
					if (b.parent >= 0)
						b.rest_global_inverse = bonesptr[b.parent].rest_global_inverse * b.rest;
					else
						b.rest_global_inverse = b.rest;
				}
				for (int i = 0; i < len; i++) {
					Bone &b = bonesptr[order[i]];
					b.rest_global_inverse.affine_invert();
				}

				rest_global_inverse_dirty = false;
			}

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

				Bone &b = bonesptr[order[i]];

				if (b.disable_rest) {
					if (b.enabled) {

						Transform pose = b.pose;
						if (b.custom_pose_enable) {

							pose = b.custom_pose * pose;
						}

						if (b.parent >= 0) {

							b.pose_global = bonesptr[b.parent].pose_global * pose;
						} else {

							b.pose_global = pose;
						}
					} else {

						if (b.parent >= 0) {

							b.pose_global = bonesptr[b.parent].pose_global;
						} else {

							b.pose_global = Transform();
						}
					}

				} else {
					if (b.enabled) {

						Transform pose = b.pose;
						if (b.custom_pose_enable) {

							pose = b.custom_pose * pose;
						}

						if (b.parent >= 0) {

							b.pose_global = bonesptr[b.parent].pose_global * (b.rest * pose);
						} else {

							b.pose_global = b.rest * pose;
						}
					} else {

						if (b.parent >= 0) {

							b.pose_global = bonesptr[b.parent].pose_global * b.rest;
						} else {

							b.pose_global = b.rest;
						}
					}
				}

				b.transform_final = b.pose_global * b.rest_global_inverse;
				vs->skeleton_bone_set_transform(skeleton, order[i], b.transform_final);

				for (List<uint32_t>::Element *E = b.nodes_bound.front(); E; E = E->next()) {

					Object *obj = ObjectDB::get_instance(E->get());
					ERR_CONTINUE(!obj);
					Spatial *sp = Object::cast_to<Spatial>(obj);
					ERR_CONTINUE(!sp);
					sp->set_transform(b.pose_global);
				}
			}

			dirty = false;
		} break;
	}
}
开发者ID:Valentactive,项目名称:godot,代码行数:101,代码来源:skeleton.cpp


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