本文整理汇总了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());
}
}
}
示例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;
}
}
示例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;
}
}