Tripping down the memory lane
It's quite amazing how one can forget all the basics by working with abstractions. More specificly… I had been creating a series of auxiliary classes for using them in my demos, so I didn't have to think of gluLookAt's and similar, and concentrate instead in specifying cameras in human terms, like, look to that point, etc.
The problem arises when I look at what did exactly each class and how it interacts with OpenGL - I just can realise how much I have forgotten about everything. Did OpenGL setup a default projection matrix? Which values did it have? Did I need to push that projection matrix and load an identity one? And what about the modelview matrix? Why can't I do a decent particle billboarding even looking at three tutorials and finally even copying the same code that works?
I am trying to avoid the kind of particles which appeared on vslpx [mov video], i.e., not properly oriented. But no matter what I do in regards to the projection or modelview matrix, the supposedly billboarded particles always appear like if they had a mind of their own, putting their front face wherever they decide to, and obviously not being perpendicular to the camera's Look vector, and I feel a bit lost >_<
Luckily it is raining so it might be time for taking advantage of the bad weather and stay home while guessing how my not-engine worked ;)


Jcl
20060212
Vector up = cameraUpVector;
Vector dir = cameraPosition - cameraTarget;
dir.Normalize();
Vector right = up.Cross(dir);
dir = Quaternion.FromAngleAndAxis(cameraRotX, up).ToMatrix() * dir;
dir = Quaternion.FromAngleAndAxis(cameraRotY, right).ToMatrix() * dir;
right = up.Cross(dir);
up = dir.Cross(right);
cameraPosition = cameraTarget + (dir * cameraDistance);
cameraUpVector = up;
Vector pan = new Vector(cameraPanX, cameraPanY, cameraPanZ);
cameraTarget += dir * pan;
cameraPosition += dir * pan;
cameraPanX = cameraPanY = cameraPanZ = 0;
…
yuju! o/
Jcl
20060212
Ahora me dedico a las bases de datos :)
sole
20060212
eh.. that's quite similar to what is in this nehe lesson: Quaternion Camera Class
I would use that method if it wasn't because I am a bit disorientated now :'(
but it seems quite logical and a bit similar to 3dstudio approach i think… need to think about this (and try to remember all those interesting concepts about the view and the model transformations & co)
Jcl
20060212
Oh, that's not the camera class… that's the mouse camera handling for my material editor.
The camera class is pretty different… I was just pasting random code :)
http://jcl.scenesp.org/files/code/camera.cs
:-)
sole
20060212
so you're trying to dirty my blog!! boooh!
anyway it reminded me to the lesson i told you…