Sorry, I did mention that nothing here is parented, but I didn’t put attention to it.
There is no parenting happening at all. I purely what a coordinate frame from another object, but not be parented to it at all.
Basically what I’m trying to do is rotate an object by dragging it. I want all of the rotations to happen with respect to the scene (so the fifth image). Here is part of that code below:
AsyncTask::DoneStatus MyClass::drag(GenericAsyncTask* task, void* data)
{
MyClass* class = static_cast<MyClass*>(data);
NodePath ref = class->window_framework_->get_render(); // global reference frame, want these axes!
// grab the initial hpr of the object
static LPoint3f original_hpr;
if (task->get_elapsed_frames() == 0)
original_hpr = class->object_to_rotate_.get_hpr();
double newangle = lots_of_complicated_math;
if (dragging_x_rotation) {
class->object_to_rotate_.set_hpr(ref, original_hpr.get_x(), newangle, original_hpr.get_z());
} else if (dragging_y_rotation) {
class->object_to_rotate_.set_hpr(ref, original_hpr.get_x(), original_hpr.get_y(), newangle);
} else if (dragging_z_rotation) {
class->object_to_rotate_.set_hpr(ref, newangle, original_hpr.get_y(), original_hpr.get_z());
}
return AsyncTask::DS_cont;
}
This task will keep looping, and ideally i can drag my mouse around and change the object’s orientation on the fly about the axis that i specified.
The newangle (magnitude or rotation) isn’t important here. The axis over which I rotate is what is important. So say I want to rotate about x (relative to the whole scene), so i stick a plane that intersects this object and is perpendicular to my scene’s x-axis. When I rotate about x, the volume of each part of the object separated by the plane should not change as i rotate it.
Instead it continues to rotate over its original x axis, so its two segments separated by the plane are changing now.
It’s rotating as you mentioned here.
This is true for the roll and pitch, but when it comes to heading, that isn’t the case, and instead, it does what I want it to do
So I want to rotate it like in image 5. This is how heading is doing it.
It sounds like your saying objects can only rotate as it is in image 4, which is how roll and pitch are doing it.