Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

ofEasyCam save and restore position/orientation

$
0
0

@gonzzza wrote:

Hi! I am creating a video installation and using ofCamera in my 3D scene.
I want to pre-record camera positon/orientation and then to restore them by triggering events. The problem is that the restored parameters are not the the same I wanted to restore. Here's an example... (not exactly my final code, but it shows what i'm doing wrong)

I save the values with this code:

ofEasyCam               cam;
float values[7];

values[0] = cam.getPosition().x;
values[1] = cam.getPosition().y;
values[2] = cam.getPosition().z;

values[3] = cam.getOrientationQuat().x;
values[4] = cam.getOrientationQuat().y;
values[5] = cam.getOrientationQuat().z;
values[6] = cam.getOrientationQuat().w;

An then I'm trying to restore the values like this:

cam.setPosition(
                        values[0],
                        values[1],
                        values[2]);
cam.setOrientation(ofQuaternion(
                                    values[3],
                                    values[4],
                                    values[5],
                                    values[6]));

The problem is that I'm getting the different values... When I'm saving the values
Position: 2.88935, -547.984, 255.531
Rotation: 0.248289, 0.225038, -0.542905, 0.770044

But when I'm restoring those i get:
Position: 2.88935, -547.984, 255.531 >> correct!
Rotation: 0.248289, 0, -0.542905, 1 >> incorrect!

Why the rotation values are different in such strange way? I could replace ofEasyCam with ofCamera, but i suspect the reason is my wrong understanding of 3d fundamentals...

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929

Latest Images

Trending Articles



Latest Images