Arcball Camera up/down rotation bug

Page 1 of 2 1, 2  Next

View previous topic View next topic Go down

Arcball Camera up/down rotation bug

Post  gregtayl on Sun Mar 01, 2009 10:48 pm

Hey All,

I've implemented a simple arcball camera and am encountering a bug with it's up/down rotation, which didn't exist in v1.3.1 (not sure if it's related to the sio2Transform transition)

My application tracks pitch (up/down rotation about XY-axis), and yaw (left/right rotation about Z-axis) and positions the camera using the following snippet: (pitch is clamped between -80 to 80 degrees)

Code:

//calculate/set the camera position
vec3 targetPos;
targetPos.x = 0;
targetPos.y = 0;
targetPos.z = 0;
sio2Rotate3D(&targetPos, pitch, yaw, distance, camera->_SIO2transform->loc);

//calculate/set the camera lookat
sio2Vec3Diff(&targetPos, camera->_SIO2transform->loc, camera->_SIO2transform->dir);
sio2Normalize(camera->_SIO2transform->dir, camera->_SIO2transform->dir);

The bug: As the pitch value approaches either limit, the camera appears to move further away from the target position. Strangely, the actual distance between the camera location and the target position is exactly the same (as I've tracked with debug output). I'm not sure if this is a skewing issue, or potentially an issue related to the packing of the camera matrix.

Any thoughts? Has anyone else experienced this?

gregtayl

Posts: 8
Join date: 2009-01-10

View user profile

Back to top Go down

Re: Arcball Camera up/down rotation bug

Post  sio2interactive on Sun Mar 01, 2009 11:11 pm

Sounds to me that the direction vector is extremely small which create the distortion in the perspective... Can you post a print of the dirXYZ values and camera->_SIO2transform->loc?? also what is the distance that you set?

Cheers,

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com

sio2interactive

Posts: 1526
Join date: 2008-08-26
Age: 35
Location: Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: Arcball Camera up/down rotation bug

Post  gregtayl on Sun Mar 01, 2009 11:27 pm

Thanks for the quick reply!

The distance is currently 10. The camera's dir vector is normalized each frame - so I assume no distortion should result.

Please let me know if the following is enough data points -

pitch:0
loc:0.000000,-10.000000,0.000000
dir:0.000000,1.000000,0.000000

pitch:45
loc:0.000000,-7.071161,7.070975
dir:0.000000,0.707116,-0.707097

pitch:60
loc:0.000000,-5.000153,8.660166
dir:0.000000,0.500015,-0.866017

pitch:80
loc:0.000000,-1.736712,9.848037
dir:0.000000,0.173671,-0.984804

gregtayl

Posts: 8
Join date: 2009-01-10

View user profile

Back to top Go down

Re: Arcball Camera up/down rotation bug

Post  sio2interactive on Sun Mar 01, 2009 11:35 pm

Heuuuuuuu by the way where you bind the new matrix to the _SIO2camera are you doing it or?

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com

sio2interactive

Posts: 1526
Join date: 2008-08-26
Age: 35
Location: Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: Arcball Camera up/down rotation bug

Post  gregtayl on Sun Mar 01, 2009 11:53 pm

I'm not actually explicitly calling sio2TransformBindMatrix(camera->_SIO2transform) on the camera - I wasn't aware this was a requirement as I was under the impression the sio2CameraRender function handled all updating of the camera matrix. When I add the sio2TransformBindMatrix call all objects disappear from view - is this function supposed to be called everytime the camera is moved?

gregtayl

Posts: 8
Join date: 2009-01-10

View user profile

Back to top Go down

Re: Arcball Camera up/down rotation bug

Post  sio2interactive on Mon Mar 02, 2009 12:06 am

nah in your case no need... in any case check tutorial09 in the new version to make sure that you are using the same sequence...

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com

sio2interactive

Posts: 1526
Join date: 2008-08-26
Age: 35
Location: Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: Arcball Camera up/down rotation bug

Post  gregtayl on Tue Mar 03, 2009 9:02 pm

Just curious is there's anything that can be done to prevent the issue I'm encountering? Did the data I provided help debug the situation at all? Is there anything I can try on my end to assist?

gregtayl

Posts: 8
Join date: 2009-01-10

View user profile

Back to top Go down

Re: Arcball Camera up/down rotation bug

Post  sio2interactive on Tue Mar 03, 2009 9:10 pm

yeah, create a template project reproducing the bug and send it to me over email...

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com

sio2interactive

Posts: 1526
Join date: 2008-08-26
Age: 35
Location: Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: Arcball Camera up/down rotation bug

Post  sio2interactive on Tue Mar 03, 2009 9:11 pm

also you might want to try to avoid setting the dir at 0.0f, give a little treshold like 0.01f or something...

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com

sio2interactive

Posts: 1526
Join date: 2008-08-26
Age: 35
Location: Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: Arcball Camera up/down rotation bug

Post  gregtayl on Tue Mar 03, 2009 10:07 pm

Thanks again for the quick reply -

You can find the sample app at: http://www.mindlessgoods.com/dropzone/ArcballCamBug.zip

When you say avoid setting the dir at 0.0f - do you mean avoid setting a dir vector of length/magnitude 0.0f? Or do you mean avoid setting any of the dir xyz components to 0.0f?

gregtayl

Posts: 8
Join date: 2009-01-10

View user profile

Back to top Go down

Re: Arcball Camera up/down rotation bug

Post  sio2interactive on Tue Mar 03, 2009 11:20 pm

Heuuu dude... I think I misread your post... actually this is not what you want to do... sio2Rotate is creating an orbit around the object the behavior is absolutely correct... what you want to do is this:


http://www.sgi.com/products/software/opengl/examples/glut/examples/source/dinospin.c

or

http://rainwarrior.thenoos.net/dragon/arcball.html

This is totally different for doing this you need quarternion. Ma'bad, that's what happen when you are doing too much programming and not get enough sleep Wink

Cheers,

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com

sio2interactive

Posts: 1526
Join date: 2008-08-26
Age: 35
Location: Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: Arcball Camera up/down rotation bug

Post  gregtayl on Tue Mar 03, 2009 11:48 pm

Thanks for the reference - however, I'm still confused at what the actual problem is. I'm only using the sio2Orbit function to calculate the proper camera position. sio2Orbit appears to use a simple rotation formula to calculate a rotated unit vector based on a horizontal and vertical rotation value (yaw and pitch). The camera's position seems to be calculated properly - and is always 10 units away from the target position.

The bug appears to be when I set the camera's dir vector to a unit vector pointing at the target position. Am I misunderstanding what the camera dir vector is? Or am I setting it with an invalid value? Sorry for the barrage of questions - I'm just confused as to where I'm going wrong as the logic seems sound in my head, and the algorithm seemed to work fine in v1.3.1.

I was hoping to avoid quaternions - namely because I don't need to worry about gimble-lock as I'm clamping the vertical rotation value. If need be I can definitely investigate integrating them into my application - I just want to make sure I understand the issue first Smile

Thanks again for the help!

gregtayl

Posts: 8
Join date: 2009-01-10

View user profile

Back to top Go down

Re: Arcball Camera up/down rotation bug

Post  sio2interactive on Wed Mar 04, 2009 12:57 am

sio2Rotate3D is the same as sio2Orbit... its just that now I got a 2D and 3D function so I rename the name... Im sure you will have the same behavior using 1.3.1...

dir is the direction vector from the location to the target...

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com

sio2interactive

Posts: 1526
Join date: 2008-08-26
Age: 35
Location: Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: Arcball Camera up/down rotation bug

Post  ColorDelta on Sat Jul 11, 2009 3:31 am

Old post but has anyone managed to resolve the issue with sio2Rotate3D?

It seems to skew the perspective if you load Tutorial 9 and change line 264 (Pitch(_ax): 10.0f to 80.0f), i.e. the further away from 0, the more distortion:

Code:
sio2Rotate3D( object->_SIO2transform->loc, 80.0f, ROTZ, 15.0f, &tmp_pos );

ColorDelta

Posts: 16
Join date: 2009-03-25
Location: London, UK

View user profile

Back to top Go down

Re: Arcball Camera up/down rotation bug

Post  sio2interactive on Sat Jul 11, 2009 3:50 am

use sio2LookAt that will fix your problem...

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com

sio2interactive

Posts: 1526
Join date: 2008-08-26
Age: 35
Location: Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Page 1 of 2 1, 2  Next

View previous topic View next topic Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum