Title: Camera Control via 3dmouse outputting simple rotation angles and trans values Post by: tryptophan on September 20, 2012, 10:46:11 PM I've been trying to learn as much as I can the past few days so I could avoid asking this question but I'm finding that I'm stuck and really need to take a math course. In the meantime though I really would like to be able to control the camera in the DE-Raytracer with a 3d mouse that outputs 6 values tx, ty, tz, rx, ry, rz where t[x,y,z] are simply position and r[x,y,z] are actual rotation angles not vectors.
I realize I can use some of the math utilities in the mathutil include but I'm not exactly sure how to set it up so I can replace the uniforms eye, target, and up in the vertex shader with variables generated from a SpaceMouse function. I'm noticing with the rotationMatrix3 function that it takes a vector "v" and a float "angle" should I use this function and input the translate value coming from the SpaceMouse into the "v" variable and then just one of the rotation angles, and then repeat the process 2 more times for the other two angles and then add or multiply the 3 matrices together? Even after doing this though I'm not sure how to get the eye, target, and up values. I know I'm a total novice when it come to matrix transformations and I am currently learning as much as possible but I really don't know enough yet to use this knowledge to get this data into the 3 camera variables. any help would really be appreciated thanks Keith Title: Re: Camera Control via 3dmouse outputting simple rotation angles and trans values Post by: Syntopia on September 20, 2012, 11:58:42 PM You need to construct a rotation matrix from your r-vector. Now, I don't know how the Space Mouse returns the orientation, but given that it is three numbers, it is not the vector/angle representation I use. It might be Euler angles, but you have to check the documentation for that. Googling 'rotation matrix' should quickly give you the matrices for most common representations.
You also need to know if the Space Mouse return absolute orientations or relative changes. If it is an absolute orientation, you could create the rotation matrix, M, and apply it to the camera direction (which is 'Target-Eye'), and calculate a new target. I.e.: NewTarget = Eye + M*(Target-Eye) And send this value to the uniform in the shader. If the changes are relative, I'd create a similar matrix M, where I accumulated the changes. Hope this helps, Mikael. Title: Re: Camera Control via 3dmouse outputting simple rotation angles and trans values Post by: tryptophan on November 10, 2012, 10:53:49 PM Thanks Mikael, I understand what I need to do as far as using the matrix but I'm not sure about a couple of things.
Quote NewTarget = Eye + M*(Target-Eye) And send this value to the uniform in the shader. I imagine you mean send it to the Target uniform of the shader? I'm not exactly sure what to do about the Up uniform? Lastly it seems that the Eye uniform would just be my tx,ty,tz values? I got stuck with this a while ago when I first asked but now I would really like to animate the camera but can't really do it until I figure this out so any help would be hugely appreciated. thanks Keith Title: Re: Camera Control via 3dmouse outputting simple rotation angles and trans values Post by: tryptophan on April 15, 2013, 03:14:26 AM Hi I'm back trying to get this camera controller to work again. I'm quite a bit closer now but I can't seem to figure out what to do with the Up uniform. I've tried a few things and some come close to working but not fully. I'm still getting some flipping when passing the 90 degree point along certain axis. I'm not sure if this is even right but it does seem to mostly work just it is just the up vector that is seems to be giving me the problems now. Here is what I have so far: Code: uniform vec4 uResolution; I realize that the lines for getting the up vector are completely wrong but I can't really find much info on how to deal with it. Any suggestions? |