12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #include "math/View.h"
- void View::updateDirections(float lengthAngle, float widthAngle) {
- back.setAngles(lengthAngle, widthAngle);
- right = back.cross(Vector3(0.0f, 1.0f, 0.0f));
- right.normalize();
- up = right.cross(back);
- up.normalize();
- back = -back;
- }
- void View::updateDirections(const Quaternion& q) {
- up = q * Vector3(0.0f, 1.0f, 0.0f);
- back = q * Vector3(-1.0f, 0.0f, 0.0f);
- right = up.cross(back);
- right.normalize();
- }
- const Matrix& View::updateMatrix(const Vector3& pos) {
- view.set(0, Vector4(right[0], right[1], right[2], right.dot(-pos)));
- view.set(1, Vector4(up[0], up[1], up[2], up.dot(-pos)));
- view.set(2, Vector4(back[0], back[1], back[2], back.dot(-pos)));
- view.set(3, Vector4(0.0f, 0.0f, 0.0f, 1.0f));
- return view;
- }
- Vector3 View::getUp() const {
- return up;
- }
- Vector3 View::getDown() const {
- return -up;
- }
- Vector3 View::getLeft() const {
- return -right;
- }
- Vector3 View::getRight() const {
- return right;
- }
- Vector3 View::getFront() const {
- return -back;
- }
- Vector3 View::getBack() const {
- return back;
- }
|