本文整理汇总了C++中Spatial::set_global_transform方法的典型用法代码示例。如果您正苦于以下问题:C++ Spatial::set_global_transform方法的具体用法?C++ Spatial::set_global_transform怎么用?C++ Spatial::set_global_transform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spatial
的用法示例。
在下文中一共展示了Spatial::set_global_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: process_spring
void SpringArm::process_spring() {
// From
real_t motion_delta(1);
real_t motion_delta_unsafe(1);
Vector3 motion;
const Vector3 cast_direction(get_global_transform().basis.xform(Vector3(0, 0, 1)));
if (shape.is_null()) {
motion = Vector3(cast_direction * (spring_length));
PhysicsDirectSpaceState::RayResult r;
bool intersected = get_world()->get_direct_space_state()->intersect_ray(get_global_transform().origin, get_global_transform().origin + motion, r, excluded_objects, mask);
if (intersected) {
float dist = get_global_transform().origin.distance_to(r.position);
dist -= margin;
motion_delta = dist / (spring_length);
}
} else {
motion = Vector3(cast_direction * spring_length);
get_world()->get_direct_space_state()->cast_motion(shape->get_rid(), get_global_transform(), motion, 0, motion_delta, motion_delta_unsafe, excluded_objects, mask);
}
current_spring_length = spring_length * motion_delta;
Transform childs_transform;
childs_transform.origin = get_global_transform().origin + cast_direction * (spring_length * motion_delta);
for (int i = get_child_count() - 1; 0 <= i; --i) {
Spatial *child = Object::cast_to<Spatial>(get_child(i));
if (child) {
childs_transform.basis = child->get_global_transform().basis;
child->set_global_transform(childs_transform);
}
}
}
示例3: _update_remote
void RemoteTransform::_update_remote() {
if (!is_inside_tree())
return;
if (!cache)
return;
Object *obj = ObjectDB::get_instance(cache);
if (!obj)
return;
Spatial *n = obj->cast_to<Spatial>();
if (!n)
return;
if (!n->is_inside_tree())
return;
//todo make faster
n->set_global_transform(get_global_transform());
}