Arcball Camera up/down rotation bug
3 posters
Arcball Camera up/down rotation bug
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)
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?
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
Re: Arcball Camera up/down rotation bug
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,
Cheers,
Re: Arcball Camera up/down rotation bug
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
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
Re: Arcball Camera up/down rotation bug
Heuuuuuuu by the way where you bind the new matrix to the _SIO2camera are you doing it or?
Re: Arcball Camera up/down rotation bug
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
Re: Arcball Camera up/down rotation bug
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...
Re: Arcball Camera up/down rotation bug
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
Re: Arcball Camera up/down rotation bug
yeah, create a template project reproducing the bug and send it to me over email...
Re: Arcball Camera up/down rotation bug
also you might want to try to avoid setting the dir at 0.0f, give a little treshold like 0.01f or something...
Re: Arcball Camera up/down rotation bug
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?
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
Re: Arcball Camera up/down rotation bug
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
Cheers,
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
Cheers,
Re: Arcball Camera up/down rotation bug
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
Thanks again for the help!
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
Thanks again for the help!
gregtayl- Posts : 8
Join date : 2009-01-10
Re: Arcball Camera up/down rotation bug
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...
dir is the direction vector from the location to the target...
Re: Arcball Camera up/down rotation bug
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:
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
Re: Arcball Camera up/down rotation bug
Thanks, Rom - it works now
ColorDelta- Posts : 16
Join date : 2009-03-25
Location : London, UK
Similar topics
» Rotation of rolling object is zero.
» Widget rotation?
» Strange behavior of object and lamp during rotation
» auto rotation
» Collision objects without rotation
» Widget rotation?
» Strange behavior of object and lamp during rotation
» auto rotation
» Collision objects without rotation
Permissions in this forum:
You cannot reply to topics in this forum