mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:58:56 +02:00
cleaned up some spacing issues in Orientarion class
This commit is contained in:
parent
d99eef8c99
commit
2d8c15e0cb
2 changed files with 40 additions and 40 deletions
|
@ -20,25 +20,25 @@ Orientation::Orientation() {
|
||||||
void Orientation::setToIdentity() {
|
void Orientation::setToIdentity() {
|
||||||
|
|
||||||
quat = glm::quat();
|
quat = glm::quat();
|
||||||
right = glm::vec3( IDENTITY_RIGHT );
|
right = glm::vec3(IDENTITY_RIGHT);
|
||||||
up = glm::vec3( IDENTITY_UP );
|
up = glm::vec3(IDENTITY_UP );
|
||||||
front = glm::vec3( IDENTITY_FRONT );
|
front = glm::vec3(IDENTITY_FRONT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Orientation::set( Orientation o ) {
|
void Orientation::set(Orientation o) {
|
||||||
|
|
||||||
quat = o.quat;
|
quat = o.quat;
|
||||||
right = o.right;
|
right = o.right;
|
||||||
up = o.up;
|
up = o.up;
|
||||||
front = o.front;
|
front = o.front;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Orientation::yaw( float angle ) {
|
void Orientation::yaw(float angle) {
|
||||||
|
|
||||||
float radian = angle * PI_OVER_180;
|
float radian = angle * PI_OVER_180;
|
||||||
|
|
||||||
if ( USING_QUATERNIONS ) {
|
if (USING_QUATERNIONS) {
|
||||||
rotateAndGenerateDirections( glm::quat( glm::vec3( 0.0f, -radian, 0.0f )) );
|
rotateAndGenerateDirections(glm::quat(glm::vec3(0.0f, -radian, 0.0f)));
|
||||||
} else {
|
} else {
|
||||||
float s = sin(radian);
|
float s = sin(radian);
|
||||||
float c = cos(radian);
|
float c = cos(radian);
|
||||||
|
@ -53,12 +53,12 @@ void Orientation::yaw( float angle ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Orientation::pitch( float angle ) {
|
void Orientation::pitch(float angle) {
|
||||||
|
|
||||||
float radian = angle * PI_OVER_180;
|
float radian = angle * PI_OVER_180;
|
||||||
|
|
||||||
if ( USING_QUATERNIONS ) {
|
if (USING_QUATERNIONS) {
|
||||||
rotateAndGenerateDirections( glm::quat( glm::vec3( radian, 0.0f, 0.0f ) ) );
|
rotateAndGenerateDirections(glm::quat(glm::vec3(radian, 0.0f, 0.0f)));
|
||||||
} else {
|
} else {
|
||||||
float s = sin(radian);
|
float s = sin(radian);
|
||||||
float c = cos(radian);
|
float c = cos(radian);
|
||||||
|
@ -73,12 +73,12 @@ void Orientation::pitch( float angle ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Orientation::roll( float angle ) {
|
void Orientation::roll(float angle) {
|
||||||
|
|
||||||
float radian = angle * PI_OVER_180;
|
float radian = angle * PI_OVER_180;
|
||||||
|
|
||||||
if ( USING_QUATERNIONS ) {
|
if (USING_QUATERNIONS) {
|
||||||
rotateAndGenerateDirections( glm::quat( glm::vec3( 0.0f, 0.0f, radian )) );
|
rotateAndGenerateDirections(glm::quat(glm::vec3(0.0f, 0.0f, radian)));
|
||||||
} else {
|
} else {
|
||||||
float s = sin(radian);
|
float s = sin(radian);
|
||||||
float c = cos(radian);
|
float c = cos(radian);
|
||||||
|
@ -93,13 +93,13 @@ void Orientation::roll( float angle ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Orientation::rotate( float p, float y, float r ) {
|
void Orientation::rotate(float p, float y, float r) {
|
||||||
pitch(p);
|
pitch(p);
|
||||||
yaw (y);
|
yaw (y);
|
||||||
roll (r);
|
roll (r);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Orientation::rotate( glm::vec3 eulerAngles ) {
|
void Orientation::rotate(glm::vec3 eulerAngles) {
|
||||||
|
|
||||||
//this needs to be optimized!
|
//this needs to be optimized!
|
||||||
pitch(eulerAngles.x);
|
pitch(eulerAngles.x);
|
||||||
|
@ -112,13 +112,13 @@ void Orientation::rotate( glm::quat rotation ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Orientation::rotateAndGenerateDirections( glm::quat rotation ) {
|
void Orientation::rotateAndGenerateDirections(glm::quat rotation) {
|
||||||
|
|
||||||
quat = quat * rotation;
|
quat = quat * rotation;
|
||||||
|
|
||||||
glm::mat4 rotationMatrix = glm::mat4_cast(quat);
|
glm::mat4 rotationMatrix = glm::mat4_cast(quat);
|
||||||
|
|
||||||
right = glm::vec3( glm::vec4( IDENTITY_RIGHT, 0.0f ) * rotationMatrix );
|
right = glm::vec3(glm::vec4(IDENTITY_RIGHT, 0.0f) * rotationMatrix);
|
||||||
up = glm::vec3( glm::vec4( IDENTITY_UP, 0.0f ) * rotationMatrix );
|
up = glm::vec3(glm::vec4(IDENTITY_UP, 0.0f) * rotationMatrix);
|
||||||
front = glm::vec3( glm::vec4( IDENTITY_FRONT, 0.0f ) * rotationMatrix );
|
front = glm::vec3(glm::vec4(IDENTITY_FRONT, 0.0f) * rotationMatrix);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,33 +12,33 @@
|
||||||
#include <glm/gtc/quaternion.hpp>
|
#include <glm/gtc/quaternion.hpp>
|
||||||
|
|
||||||
// this is where the coordinate system is represented
|
// this is where the coordinate system is represented
|
||||||
const glm::vec3 IDENTITY_RIGHT = glm::vec3( -1.0f, 0.0f, 0.0f );
|
const glm::vec3 IDENTITY_RIGHT = glm::vec3(-1.0f, 0.0f, 0.0f);
|
||||||
const glm::vec3 IDENTITY_UP = glm::vec3( 0.0f, 1.0f, 0.0f );
|
const glm::vec3 IDENTITY_UP = glm::vec3( 0.0f, 1.0f, 0.0f);
|
||||||
const glm::vec3 IDENTITY_FRONT = glm::vec3( 0.0f, 0.0f, 1.0f );
|
const glm::vec3 IDENTITY_FRONT = glm::vec3( 0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
class Orientation
|
class Orientation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Orientation();
|
Orientation();
|
||||||
|
|
||||||
void set( Orientation );
|
void set(Orientation);
|
||||||
void setToIdentity();
|
void setToIdentity();
|
||||||
|
|
||||||
void pitch( float p );
|
void pitch(float p);
|
||||||
void yaw ( float y );
|
void yaw (float y);
|
||||||
void roll ( float r );
|
void roll (float r);
|
||||||
|
|
||||||
void rotate( float pitch, float yaw, float roll );
|
void rotate(float pitch, float yaw, float roll);
|
||||||
void rotate( glm::vec3 EulerAngles );
|
void rotate(glm::vec3 EulerAngles);
|
||||||
void rotate( glm::quat quaternion );
|
void rotate(glm::quat quaternion);
|
||||||
|
|
||||||
const glm::vec3 & getRight() const { return right; }
|
const glm::vec3 & getRight() const {return right;}
|
||||||
const glm::vec3 & getUp () const { return up; }
|
const glm::vec3 & getUp () const {return up; }
|
||||||
const glm::vec3 & getFront() const { return front; }
|
const glm::vec3 & getFront() const {return front;}
|
||||||
|
|
||||||
const glm::vec3 & getIdentityRight() const { return IDENTITY_RIGHT; }
|
const glm::vec3 & getIdentityRight() const {return IDENTITY_RIGHT;}
|
||||||
const glm::vec3 & getIdentityUp () const { return IDENTITY_UP; }
|
const glm::vec3 & getIdentityUp () const {return IDENTITY_UP;}
|
||||||
const glm::vec3 & getIdentityFront() const { return IDENTITY_FRONT; }
|
const glm::vec3 & getIdentityFront() const {return IDENTITY_FRONT;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ private:
|
||||||
glm::vec3 up;
|
glm::vec3 up;
|
||||||
glm::vec3 front;
|
glm::vec3 front;
|
||||||
|
|
||||||
void rotateAndGenerateDirections( glm::quat rotation );
|
void rotateAndGenerateDirections(glm::quat rotation);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue