Al's Programming Resource Homepage  Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

OBJECT Class Reference

#include <object.h>

Inheritance diagram for OBJECT:

CAMERA List of all members.

Public Methods

 OBJECT ()
 ~OBJECT ()
void Set ()
void Rotate ()
void Draw ()
void UpdatePosition ()
void UpdatePosition (float x, float y, float z)
void MoveX ()
void MoveY ()
void MoveZ ()
void MoveX (float x)
void MoveY (float y)
void MoveZ (float z)
VECTOR GetXUnit ()
VECTOR GetYUnit ()
VECTOR GetZUnit ()

Public Attributes

QUAT Orientation
VECTOR Position
float Delta_x
float Delta_y
float Delta_z
float Movement_x
float Movement_y
float Movement_z
float Multiplier

Constructor & Destructor Documentation

OBJECT::OBJECT  
 

Definition at line 9 of file object.cpp.

00010 {
00011 }

OBJECT::~OBJECT  
 

Definition at line 13 of file object.cpp.

00014 {
00015 }


Member Function Documentation

void OBJECT::Draw  
 

Definition at line 36 of file object.cpp.

00037 {
00038   // Should probably be a pure virtual 
00039 }

VECTOR OBJECT::GetXUnit  
 

Definition at line 203 of file object.cpp.

References QUAT::EulerToQuat(), QUAT::MultQuat(), Orientation, pi, QUAT::w, VECTOR::x, QUAT::x, VECTOR::y, QUAT::y, VECTOR::z, and QUAT::z.

00204 {
00205     float DirX;
00206     float DirY;
00207     float DirZ;
00208     float W = 0.0;
00209     float X = 0.0;
00210     float Y = 0.0;
00211     float Z = 0.0;
00212     QUAT TempQuat;
00213     QUAT TempQuat2;
00214     TempQuat = Orientation;
00215     TempQuat2.EulerToQuat(0.0, -90.0*(pi/180), 0.0);
00216     TempQuat.MultQuat(TempQuat2);
00217     W = TempQuat.w;
00218     X = TempQuat.x;
00219     Y = TempQuat.y;
00220     Z = TempQuat.z;
00221     DirX = 2.0 * ( X * Z - W * Y );
00222     DirY = 2.0 * ( Y * Z + W * X );
00223     DirZ = 1.0 - 2.0 * ( X * X + Y * Y );
00224     VECTOR Unit;
00225     Unit.x += DirX * 1;
00226     Unit.y += DirY * 1;
00227     Unit.z += DirZ * 1;
00228     return Unit;
00229 }

VECTOR OBJECT::GetYUnit  
 

Definition at line 231 of file object.cpp.

References QUAT::EulerToQuat(), QUAT::MultQuat(), Orientation, pi, QUAT::w, VECTOR::x, QUAT::x, VECTOR::y, QUAT::y, VECTOR::z, and QUAT::z.

00232 {
00233     float DirX;
00234     float DirY;
00235     float DirZ;
00236     float W = 0.0;
00237     float X = 0.0;
00238     float Y = 0.0;
00239     float Z = 0.0;
00240     QUAT TempQuat;
00241     QUAT TempQuat2;
00242     TempQuat = Orientation;
00243     TempQuat2.EulerToQuat(90.0*(pi/180), 0.0, 0.0);
00244     TempQuat.MultQuat(TempQuat2);
00245     W = TempQuat.w;
00246     X = TempQuat.x;
00247     Y = TempQuat.y;
00248     Z = TempQuat.z;
00249     DirX = 2.0 * ( X * Z - W * Y );
00250     DirY = 2.0 * ( Y * Z + W * X );
00251     DirZ = 1.0 - 2.0 * ( X * X + Y * Y );
00252     VECTOR Unit;    
00253     Unit.x += DirX * 1;
00254     Unit.y += DirY * 1;
00255     Unit.z += DirZ * 1;
00256     return Unit;
00257 }

VECTOR OBJECT::GetZUnit  
 

Definition at line 259 of file object.cpp.

References Orientation, QUAT::w, VECTOR::x, QUAT::x, VECTOR::y, QUAT::y, VECTOR::z, and QUAT::z.

00260 {
00261     float DirX;
00262     float DirY;
00263     float DirZ;
00264     float W = Orientation.w;
00265     float X = Orientation.x;
00266     float Y = Orientation.y;
00267     float Z = Orientation.z;
00268     DirX = 2.0 * ( X * Z - W * Y );
00269     DirY = 2.0 * ( Y * Z + W * X );
00270     DirZ = 1.0 - 2.0 * ( X * X + Y * Y );
00271     VECTOR Unit;
00272     Unit.x += DirX * 1;
00273     Unit.y += DirY * 1;
00274     Unit.z += DirZ * 1;
00275     return Unit;
00276 }

void OBJECT::MoveX float    x
 

Definition at line 134 of file object.cpp.

References QUAT::EulerToQuat(), Multiplier, QUAT::MultQuat(), Orientation, pi, Position, QUAT::w, VECTOR::x, QUAT::x, VECTOR::y, QUAT::y, VECTOR::z, and QUAT::z.

00135 {
00136     float DirX;
00137     float DirY;
00138     float DirZ;
00139     float W = 0.0;
00140     float X = 0.0;
00141     float Y = 0.0;
00142     float Z = 0.0;
00143     QUAT TempQuat;
00144     QUAT TempQuat2;
00145     TempQuat = Orientation;
00146     TempQuat2.EulerToQuat(0.0, -90.0*(pi/180), 0.0);
00147     TempQuat.MultQuat(TempQuat2);
00148     W = TempQuat.w;
00149     X = TempQuat.x;
00150     Y = TempQuat.y;
00151     Z = TempQuat.z;
00152     DirX = 2.0 * ( X * Z - W * Y );
00153     DirY = 2.0 * ( Y * Z + W * X );
00154     DirZ = 1.0 - 2.0 * ( X * X + Y * Y );
00155     Position.x += DirX * x * Multiplier;
00156     Position.y += DirY * x * Multiplier;
00157     Position.z += DirZ * x * Multiplier;
00158 }

void OBJECT::MoveX  
 

Definition at line 65 of file object.cpp.

References QUAT::EulerToQuat(), Movement_x, Multiplier, QUAT::MultQuat(), Orientation, pi, Position, QUAT::w, VECTOR::x, QUAT::x, VECTOR::y, QUAT::y, VECTOR::z, and QUAT::z.

Referenced by UpdatePosition().

00066 {
00067     float DirX;
00068     float DirY;
00069     float DirZ;
00070     float W = 0.0;
00071     float X = 0.0;
00072     float Y = 0.0;
00073     float Z = 0.0;
00074     QUAT TempQuat;
00075     QUAT TempQuat2;
00076     TempQuat = Orientation;
00077     TempQuat2.EulerToQuat(0.0, -90.0*(pi/180), 0.0);
00078     TempQuat.MultQuat(TempQuat2);
00079     W = TempQuat.w;
00080     X = TempQuat.x;
00081     Y = TempQuat.y;
00082     Z = TempQuat.z;
00083     DirX = 2.0 * ( X * Z - W * Y );
00084     DirY = 2.0 * ( Y * Z + W * X );
00085     DirZ = 1.0 - 2.0 * ( X * X + Y * Y );
00086     Position.x += DirX * Movement_x * Multiplier;
00087     Position.y += DirY * Movement_x * Multiplier;
00088     Position.z += DirZ * Movement_x * Multiplier;
00089 }

void OBJECT::MoveY float    y
 

Definition at line 160 of file object.cpp.

References QUAT::EulerToQuat(), Multiplier, QUAT::MultQuat(), Orientation, pi, Position, QUAT::w, VECTOR::x, QUAT::x, VECTOR::y, QUAT::y, VECTOR::z, and QUAT::z.

00161 {
00162     float DirX;
00163     float DirY;
00164     float DirZ;
00165     float W = 0.0;
00166     float X = 0.0;
00167     float Y = 0.0;
00168     float Z = 0.0;
00169     QUAT TempQuat;
00170     QUAT TempQuat2;
00171     TempQuat = Orientation;
00172     TempQuat2.EulerToQuat(90.0*(pi/180), 0.0, 0.0);
00173     TempQuat.MultQuat(TempQuat2);
00174     W = TempQuat.w;
00175     X = TempQuat.x;
00176     Y = TempQuat.y;
00177     Z = TempQuat.z;
00178     DirX = 2.0 * ( X * Z - W * Y );
00179     DirY = 2.0 * ( Y * Z + W * X );
00180     DirZ = 1.0 - 2.0 * ( X * X + Y * Y );
00181     Position.x += DirX * y * Multiplier;
00182     Position.y += DirY * y * Multiplier;
00183     Position.z += DirZ * y * Multiplier;
00184 }

void OBJECT::MoveY  
 

Definition at line 91 of file object.cpp.

References QUAT::EulerToQuat(), Movement_y, Multiplier, QUAT::MultQuat(), Orientation, pi, Position, QUAT::w, VECTOR::x, QUAT::x, VECTOR::y, QUAT::y, VECTOR::z, and QUAT::z.

Referenced by UpdatePosition().

00092 {
00093     float DirX;
00094     float DirY;
00095     float DirZ;
00096     float W = 0.0;
00097     float X = 0.0;
00098     float Y = 0.0;
00099     float Z = 0.0;
00100     QUAT TempQuat;
00101     QUAT TempQuat2;
00102     TempQuat = Orientation;
00103     TempQuat2.EulerToQuat(90.0*(pi/180), 0.0, 0.0);
00104     TempQuat.MultQuat(TempQuat2);
00105     W = TempQuat.w;
00106     X = TempQuat.x;
00107     Y = TempQuat.y;
00108     Z = TempQuat.z;
00109     DirX = 2.0 * ( X * Z - W * Y );
00110     DirY = 2.0 * ( Y * Z + W * X );
00111     DirZ = 1.0 - 2.0 * ( X * X + Y * Y );
00112     Position.x += DirX * Movement_y * Multiplier;
00113     Position.y += DirY * Movement_y * Multiplier;
00114     Position.z += DirZ * Movement_y * Multiplier;
00115 }

void OBJECT::MoveZ float    z
 

Definition at line 186 of file object.cpp.

References Multiplier, Orientation, Position, QUAT::w, VECTOR::x, QUAT::x, VECTOR::y, QUAT::y, VECTOR::z, and QUAT::z.

00187 {
00188     float DirX;
00189     float DirY;
00190     float DirZ;
00191     float W = Orientation.w;
00192     float X = Orientation.x;
00193     float Y = Orientation.y;
00194     float Z = Orientation.z;
00195     DirX = 2.0 * ( X * Z - W * Y );
00196     DirY = 2.0 * ( Y * Z + W * X );
00197     DirZ = 1.0 - 2.0 * ( X * X + Y * Y );
00198     Position.x += DirX * z * Multiplier;
00199     Position.y += DirY * z * Multiplier;
00200     Position.z += DirZ * z * Multiplier;
00201 }

void OBJECT::MoveZ  
 

Definition at line 117 of file object.cpp.

References Movement_z, Multiplier, Orientation, Position, QUAT::w, VECTOR::x, QUAT::x, VECTOR::y, QUAT::y, VECTOR::z, and QUAT::z.

Referenced by UpdatePosition().

00118 {
00119     float DirX;
00120     float DirY;
00121     float DirZ;
00122     float W = Orientation.w;
00123     float X = Orientation.x;
00124     float Y = Orientation.y;
00125     float Z = Orientation.z;
00126     DirX = 2.0 * ( X * Z - W * Y );
00127     DirY = 2.0 * ( Y * Z + W * X );
00128     DirZ = 1.0 - 2.0 * ( X * X + Y * Y );
00129     Position.x += DirX * Movement_z * Multiplier;
00130     Position.y += DirY * Movement_z * Multiplier;
00131     Position.z += DirZ * Movement_z * Multiplier;
00132 }

void OBJECT::Rotate  
 

Definition at line 29 of file object.cpp.

References Delta_x, Delta_y, Delta_z, QUAT::EulerToQuat(), Multiplier, QUAT::MultQuat(), Orientation, and radians.

Referenced by CAMERA::UpdateCamera().

00030 {
00031         QUAT temp_quat;
00032     temp_quat.EulerToQuat(Delta_x * radians * Multiplier, Delta_y * radians * Multiplier, Delta_z * radians * Multiplier);
00033         Orientation.MultQuat(temp_quat);
00034 }

void OBJECT::Set  
 

Reimplemented in CAMERA.

Definition at line 17 of file object.cpp.

References Delta_x, Delta_y, Delta_z, Movement_x, Movement_y, Movement_z, Orientation, Position, VECTOR::Set(), and QUAT::Set().

00018 {
00019     Orientation.Set();
00020     Position.Set();
00021         Delta_x = 0.0;
00022         Delta_y = 0.0;
00023         Delta_z = 0.0;
00024         Movement_x = 0.0;
00025         Movement_y = 0.0;
00026         Movement_z = 0.0;
00027 }

void OBJECT::UpdatePosition float    x,
float    y,
float    z
 

Definition at line 55 of file object.cpp.

References MoveX(), MoveY(), and MoveZ().

00056 {
00057     if (x != 0)
00058         MoveX(x);
00059     if (y != 0)
00060         MoveY(y);
00061     if (z != 0)
00062         MoveZ(z);
00063 }

void OBJECT::UpdatePosition  
 

Definition at line 41 of file object.cpp.

References Movement_x, Movement_y, Movement_z, MoveX(), MoveY(), and MoveZ().

Referenced by CAMERA::UpdateCamera().

00042 {
00043     if (Movement_x != 0)
00044         MoveX();
00045     if (Movement_y != 0)
00046         MoveY();
00047     if (Movement_z != 0)
00048         MoveZ();
00049 
00050     Movement_x = 0.0;
00051     Movement_y = 0.0;
00052     Movement_z = 0.0;
00053 }


Member Data Documentation

float OBJECT::Delta_x
 

Definition at line 32 of file object.h.

Referenced by Rotate(), Set(), and CAMERA::Set().

float OBJECT::Delta_y
 

Definition at line 33 of file object.h.

Referenced by Rotate(), Set(), and CAMERA::Set().

float OBJECT::Delta_z
 

Definition at line 34 of file object.h.

Referenced by Rotate(), Set(), and CAMERA::Set().

float OBJECT::Movement_x
 

Definition at line 35 of file object.h.

Referenced by MoveX(), Set(), and UpdatePosition().

float OBJECT::Movement_y
 

Definition at line 36 of file object.h.

Referenced by MoveY(), Set(), and UpdatePosition().

float OBJECT::Movement_z
 

Definition at line 37 of file object.h.

Referenced by MoveZ(), Set(), and UpdatePosition().

float OBJECT::Multiplier
 

Definition at line 38 of file object.h.

Referenced by MoveX(), MoveY(), MoveZ(), and Rotate().

QUAT OBJECT::Orientation
 

Definition at line 30 of file object.h.

Referenced by CAMERA::ApplyCamera(), GetXUnit(), GetYUnit(), GetZUnit(), MoveX(), MoveY(), MoveZ(), Rotate(), Set(), and CAMERA::Set().

VECTOR OBJECT::Position
 

Definition at line 31 of file object.h.

Referenced by CAMERA::ApplyCamera(), POLYGON::CheckForCollision(), MoveX(), MoveY(), MoveZ(), Set(), and CAMERA::Set().


The documentation for this class was generated from the following files:
Generated on Fri Dec 23 05:19:35 2005 for OpenGL MDI 2 by doxygen1.2.15