Haubitze wrote:Hello Paul Doe,
i have a question about camera position. i need to turn a camera around a point. so i can "orbit" him.
in BlitzBasic3D i think i use lookat and move. but i cant build it in your engine.
can you explain how i can orbit an point with a given distance with an camera?
thanks for this nice work :)
Owww sorry mate! Didn't see this post before (I wasn't really looking, though =D)
You can do the same here, but you get 'drifting' due to the crappy precision of the singles and the fact that the code uses in-place array modification and does not perform any kind of orthonormalization every once and then, so distances tend to drift and axes tend to become skewed. A better approach is simply to load the identity vectors and construct the matrices again from scratch (like the old OpenGL fixed-function pipeline did, if you programmed it back in the days).
Or, you can compute and apply the transformation matrix yourself. Remember it was:
- Translate the object you want to rotate to the position you want to orbit around.
- Perform the rotation around the axis you want.
- And then translate back in that direction.
I think I have a better version of this crap lying around, but couldn't find it for the life of me. If there's some interest, I shall rework this little demo (it was coded in a real
hurry, and it shows) into something a little more manageable and useful, with a scene manager too (complete with frustum culling) so it can really be used as a base for some more advanced. I don't know, I've been pretty busy with other things recently, sorry =D