mirror of
https://github.com/glest/glest-source.git
synced 2025-09-30 01:18:58 +02:00
Fixed the god-awful indentation
This commit is contained in:
@@ -14,176 +14,178 @@
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
namespace Shared {
|
||||
namespace Graphics {
|
||||
|
||||
// =====================================================
|
||||
// class AxisAngle
|
||||
// =====================================================
|
||||
// =====================================================
|
||||
// class AxisAngle
|
||||
// =====================================================
|
||||
|
||||
AxisAngle::AxisAngle(const Vec3f &axis, float angle){
|
||||
this->axis= axis;
|
||||
this->angle= angle;
|
||||
}
|
||||
AxisAngle::AxisAngle(const Vec3f &axis, float angle) {
|
||||
this->axis = axis;
|
||||
this->angle = angle;
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
// class EulerAngles
|
||||
// =====================================================
|
||||
// =====================================================
|
||||
// class EulerAngles
|
||||
// =====================================================
|
||||
|
||||
EulerAngles::EulerAngles(float x, float y, float z){
|
||||
this->x= x;
|
||||
this->y= y;
|
||||
this->z= z;
|
||||
}
|
||||
EulerAngles::EulerAngles(float x, float y, float z) {
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->z = z;
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
// class Quaternion
|
||||
// =====================================================
|
||||
// =====================================================
|
||||
// class Quaternion
|
||||
// =====================================================
|
||||
|
||||
Quaternion::Quaternion(){
|
||||
setMultIdentity();
|
||||
}
|
||||
Quaternion::Quaternion() {
|
||||
setMultIdentity();
|
||||
}
|
||||
|
||||
Quaternion::Quaternion(float w, const Vec3f &v){
|
||||
this->w= w;
|
||||
this->v= v;
|
||||
}
|
||||
Quaternion::Quaternion(float w, const Vec3f &v) {
|
||||
this->w = w;
|
||||
this->v = v;
|
||||
}
|
||||
|
||||
Quaternion::Quaternion(const EulerAngles &eulerAngles){
|
||||
setEuler(eulerAngles);
|
||||
}
|
||||
Quaternion::Quaternion(const EulerAngles &eulerAngles) {
|
||||
setEuler(eulerAngles);
|
||||
}
|
||||
|
||||
//Quaternion::Quaternion(const AxisAngle &axisAngle){
|
||||
// setAxisAngle(axisAngle);
|
||||
//}
|
||||
//Quaternion::Quaternion(const AxisAngle &axisAngle){
|
||||
// setAxisAngle(axisAngle);
|
||||
//}
|
||||
|
||||
void Quaternion::setMultIdentity(){
|
||||
w= 1.0f;
|
||||
v= Vec3f(0.0f);
|
||||
}
|
||||
void Quaternion::setMultIdentity() {
|
||||
w = 1.0f;
|
||||
v = Vec3f(0.0f);
|
||||
}
|
||||
|
||||
void Quaternion::setAddIdentity(){
|
||||
w= 0.0f;
|
||||
v= Vec3f(0.0f);
|
||||
}
|
||||
void Quaternion::setAddIdentity() {
|
||||
w = 0.0f;
|
||||
v = Vec3f(0.0f);
|
||||
}
|
||||
|
||||
void Quaternion::setEuler(const EulerAngles &eulerAngles){
|
||||
Quaternion qx, qy, qz, qr;
|
||||
void Quaternion::setEuler(const EulerAngles &eulerAngles) {
|
||||
Quaternion qx, qy, qz, qr;
|
||||
|
||||
qx.w= std::cos(eulerAngles.x/2.0f);
|
||||
qx.v= Vec3f(std::sin(eulerAngles.x/2.0f), 0.0f, 0.0f);
|
||||
qx.w = std::cos(eulerAngles.x / 2.0f);
|
||||
qx.v = Vec3f(std::sin(eulerAngles.x / 2.0f), 0.0f, 0.0f);
|
||||
|
||||
qy.w= std::cos(eulerAngles.y/2.0f);
|
||||
qy.v= Vec3f(0.0f, std::sin(eulerAngles.y/2.0f), 0.0f);
|
||||
qy.w = std::cos(eulerAngles.y / 2.0f);
|
||||
qy.v = Vec3f(0.0f, std::sin(eulerAngles.y / 2.0f), 0.0f);
|
||||
|
||||
qz.w= std::cos(eulerAngles.z/2.0f);
|
||||
qz.v= Vec3f(0.0f, 0.0f, std::sin(eulerAngles.z/2.0f));
|
||||
|
||||
qr= qx*qy*qz;
|
||||
qz.w = std::cos(eulerAngles.z / 2.0f);
|
||||
qz.v = Vec3f(0.0f, 0.0f, std::sin(eulerAngles.z / 2.0f));
|
||||
|
||||
w= qr.w;
|
||||
v= qr.v;
|
||||
}
|
||||
qr = qx*qy*qz;
|
||||
|
||||
Quaternion Quaternion::conjugate(){
|
||||
return Quaternion(w, -v);
|
||||
}
|
||||
w = qr.w;
|
||||
v = qr.v;
|
||||
}
|
||||
|
||||
Quaternion Quaternion::operator + (const Quaternion &q) const{
|
||||
return Quaternion(w +q.w, v+q.v);
|
||||
}
|
||||
Quaternion Quaternion::operator * (const Quaternion &q) const{
|
||||
return Quaternion(
|
||||
w*q.w - v.x*q.v.x - v.y*q.v.y - v.z*q.v.z,
|
||||
Vec3f(
|
||||
w*q.v.x + v.x*q.w + v.y*q.v.z - v.z*q.v.y,
|
||||
w*q.v.y + v.y*q.w + v.z*q.v.x - v.x*q.v.z,
|
||||
w*q.v.z + v.z*q.w + v.x*q.v.y - v.y*q.v.x));
|
||||
}
|
||||
Quaternion Quaternion::conjugate() {
|
||||
return Quaternion(w, -v);
|
||||
}
|
||||
|
||||
void Quaternion::operator += (const Quaternion &q){
|
||||
*this= *this + q;
|
||||
}
|
||||
Quaternion Quaternion::operator + (const Quaternion &q) const {
|
||||
return Quaternion(w + q.w, v + q.v);
|
||||
}
|
||||
Quaternion Quaternion::operator * (const Quaternion &q) const {
|
||||
return Quaternion(
|
||||
w*q.w - v.x*q.v.x - v.y*q.v.y - v.z*q.v.z,
|
||||
Vec3f(
|
||||
w*q.v.x + v.x*q.w + v.y*q.v.z - v.z*q.v.y,
|
||||
w*q.v.y + v.y*q.w + v.z*q.v.x - v.x*q.v.z,
|
||||
w*q.v.z + v.z*q.w + v.x*q.v.y - v.y*q.v.x));
|
||||
}
|
||||
|
||||
void Quaternion::operator *= (const Quaternion &q){
|
||||
*this= *this * q;
|
||||
}
|
||||
void Quaternion::operator += (const Quaternion &q) {
|
||||
*this = *this + q;
|
||||
}
|
||||
|
||||
Quaternion Quaternion::lerp(float t, const Quaternion &q) const{
|
||||
return Quaternion(
|
||||
w * (1.0f-t) + q.w * t,
|
||||
v * (1.0f-t) + q.v * t);
|
||||
}
|
||||
void Quaternion::operator *= (const Quaternion &q) {
|
||||
*this = *this * q;
|
||||
}
|
||||
|
||||
Matrix3f Quaternion::toMatrix3() const{
|
||||
Matrix3f rm;
|
||||
Quaternion Quaternion::lerp(float t, const Quaternion &q) const {
|
||||
return Quaternion(
|
||||
w * (1.0f - t) + q.w * t,
|
||||
v * (1.0f - t) + q.v * t);
|
||||
}
|
||||
|
||||
//row1
|
||||
rm[0]= 1.0f - 2*v.y*v.y - 2*v.z*v.z;
|
||||
rm[3]= 2*v.x*v.y - 2*w*v.z;
|
||||
rm[6]= 2*v.x*v.z + 2*w*v.y;
|
||||
Matrix3f Quaternion::toMatrix3() const {
|
||||
Matrix3f rm;
|
||||
|
||||
//row2
|
||||
rm[1]= 2*v.x*v.y + 2*w*v.z;
|
||||
rm[4]= 1.0f - 2*v.x*v.x - 2*v.z*v.z;
|
||||
rm[7]= 2*v.y*v.z - 2*w*v.x;
|
||||
//row1
|
||||
rm[0] = 1.0f - 2 * v.y*v.y - 2 * v.z*v.z;
|
||||
rm[3] = 2 * v.x*v.y - 2 * w*v.z;
|
||||
rm[6] = 2 * v.x*v.z + 2 * w*v.y;
|
||||
|
||||
//row3
|
||||
rm[2]= 2*v.x*v.z - 2*w*v.y;
|
||||
rm[5]= 2*v.y*v.z + 2*w*v.x;
|
||||
rm[8]= 1.0f - 2*v.x*v.x - 2*v.y*v.y;
|
||||
//row2
|
||||
rm[1] = 2 * v.x*v.y + 2 * w*v.z;
|
||||
rm[4] = 1.0f - 2 * v.x*v.x - 2 * v.z*v.z;
|
||||
rm[7] = 2 * v.y*v.z - 2 * w*v.x;
|
||||
|
||||
return rm;
|
||||
}
|
||||
//row3
|
||||
rm[2] = 2 * v.x*v.z - 2 * w*v.y;
|
||||
rm[5] = 2 * v.y*v.z + 2 * w*v.x;
|
||||
rm[8] = 1.0f - 2 * v.x*v.x - 2 * v.y*v.y;
|
||||
|
||||
Matrix4f Quaternion::toMatrix4() const{
|
||||
Matrix4f rm;
|
||||
return rm;
|
||||
}
|
||||
|
||||
//row1
|
||||
rm[0]= 1.0f - 2*v.y*v.y - 2*v.z*v.z;
|
||||
rm[4]= 2*v.x*v.y - 2*w*v.z;
|
||||
rm[8]= 2*v.x*v.z + 2*w*v.y;
|
||||
rm[12]= 0.0f;
|
||||
Matrix4f Quaternion::toMatrix4() const {
|
||||
Matrix4f rm;
|
||||
|
||||
//row2
|
||||
rm[1]= 2*v.x*v.y + 2*w*v.z;
|
||||
rm[5]= 1.0f - 2*v.x*v.x - 2*v.z*v.z;
|
||||
rm[9]= 2*v.y*v.z - 2*w*v.x;
|
||||
rm[13]= 0.0f;
|
||||
//row1
|
||||
rm[0] = 1.0f - 2 * v.y*v.y - 2 * v.z*v.z;
|
||||
rm[4] = 2 * v.x*v.y - 2 * w*v.z;
|
||||
rm[8] = 2 * v.x*v.z + 2 * w*v.y;
|
||||
rm[12] = 0.0f;
|
||||
|
||||
//row3
|
||||
rm[2]= 2*v.x*v.z - 2*w*v.y;
|
||||
rm[6]= 2*v.y*v.z + 2*w*v.x;
|
||||
rm[10]= 1.0f - 2*v.x*v.x - 2*v.y*v.y;
|
||||
rm[14]= 0.0f;
|
||||
//row2
|
||||
rm[1] = 2 * v.x*v.y + 2 * w*v.z;
|
||||
rm[5] = 1.0f - 2 * v.x*v.x - 2 * v.z*v.z;
|
||||
rm[9] = 2 * v.y*v.z - 2 * w*v.x;
|
||||
rm[13] = 0.0f;
|
||||
|
||||
//row4
|
||||
rm[3]= 0.0f;
|
||||
rm[7]= 0.0f;
|
||||
rm[11]= 0.0f;
|
||||
rm[15]= 1.0f;
|
||||
//row3
|
||||
rm[2] = 2 * v.x*v.z - 2 * w*v.y;
|
||||
rm[6] = 2 * v.y*v.z + 2 * w*v.x;
|
||||
rm[10] = 1.0f - 2 * v.x*v.x - 2 * v.y*v.y;
|
||||
rm[14] = 0.0f;
|
||||
|
||||
return rm;
|
||||
}
|
||||
//row4
|
||||
rm[3] = 0.0f;
|
||||
rm[7] = 0.0f;
|
||||
rm[11] = 0.0f;
|
||||
rm[15] = 1.0f;
|
||||
|
||||
Vec3f Quaternion::getLocalXAxis() const{
|
||||
return Vec3f(
|
||||
1.0f - 2*v.y*v.y - 2*v.z*v.z,
|
||||
2*v.x*v.y + 2*w*v.z,
|
||||
2*v.x*v.z - 2*w*v.y);
|
||||
}
|
||||
return rm;
|
||||
}
|
||||
|
||||
Vec3f Quaternion::getLocalYAxis() const{
|
||||
return Vec3f(
|
||||
2*v.x*v.y - 2*w*v.z,
|
||||
1.0f - 2*v.x*v.x - 2*v.z*v.z,
|
||||
2*v.y*v.z + 2*w*v.x);
|
||||
}
|
||||
Vec3f Quaternion::getLocalXAxis() const {
|
||||
return Vec3f(
|
||||
1.0f - 2 * v.y*v.y - 2 * v.z*v.z,
|
||||
2 * v.x*v.y + 2 * w*v.z,
|
||||
2 * v.x*v.z - 2 * w*v.y);
|
||||
}
|
||||
|
||||
Vec3f Quaternion::getLocalZAxis() const{
|
||||
return Vec3f(
|
||||
2*v.x*v.z + 2*w*v.y,
|
||||
2*v.y*v.z - 2*w*v.x,
|
||||
1.0f - 2*v.x*v.x - 2*v.y*v.y);
|
||||
}
|
||||
Vec3f Quaternion::getLocalYAxis() const {
|
||||
return Vec3f(
|
||||
2 * v.x*v.y - 2 * w*v.z,
|
||||
1.0f - 2 * v.x*v.x - 2 * v.z*v.z,
|
||||
2 * v.y*v.z + 2 * w*v.x);
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
Vec3f Quaternion::getLocalZAxis() const {
|
||||
return Vec3f(
|
||||
2 * v.x*v.z + 2 * w*v.y,
|
||||
2 * v.y*v.z - 2 * w*v.x,
|
||||
1.0f - 2 * v.x*v.x - 2 * v.y*v.y);
|
||||
}
|
||||
|
||||
}
|
||||
}//end namespace
|
||||
|
Reference in New Issue
Block a user