The implementation of a quad tree algorithm was a concept i looked at while researching my project. Although i will not be implementing it, I find the ideas behind it very interesting. I feel it’s good to try and get a grasp of all different aspects of terrain rendering. Anyway, this is a good read up on the concept of Quad Trees. Moving onto business though. After playing around with the code I have begun to get the camera functioning as desired. There are a few problems with getting the matrices working, so they will have to be worked on. In most of Bryan’s labs, he used cameras in the games worlds, and they all employ a the same concept. The below code is based on Bryan’s work :
Normalize Look Vector
Cross product look and right vector to change the up vector
Normalize the up vector
Cross product up and look to change the right vector
Normalize the right vector
float x = Dot product right vector with position
float y = Dot product up vector with position
float z = Dot product look vector with position
(_viewMatrix)(0,0) = _right.x;
(_viewMatrix)(0, 1) = _up.x;
(_viewMatrix)(0, 2) = _look.x;
(_viewMatrix)(0, 3) = 0.0f;
(_viewMatrix)(1,0) = _right.y;
(_viewMatrix)(1, 1) = _up.y;
(_viewMatrix)(1, 2) = _look.y;
(_viewMatrix)(1, 3) = 0.0f;
(_viewMatrix)(2,0) = _right.z;
(_viewMatrix)(2, 1) = _up.z;
(_viewMatrix)(2, 2) = _look.z;
(_viewMatrix)(2, 3) = 0.0f;
(_viewMatrix)(3,0) = x;
(_viewMatrix)(3, 1) = y;
(_viewMatrix)(3, 2) = z;
(_viewMatrix)(3, 3) = 1.0f;