Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

Rigid.cpp

00001 /*************************************************************************** 00002 * This file is part of OpenCAL: Open Computer Animation Library * 00003 * I created OpenCAL as my master's thesis Computer Science (multimedia) * 00004 * at the tUL university in Diepenbeek, Belgium * 00005 * * 00006 * Copyright (C) 2003-2004 by Jeroen Dierckx * 00007 * jeroen.dierckx@student.luc.ac.be * 00008 * * 00009 ***************************************************************************/ 00010 00011 // Includes 00012 #include "Rigid.h" 00013 using namespace OpenCAL; 00014 00015 #include <OpenCAL/Vector3.h> 00016 using namespace Utils; 00017 00018 using namespace std; 00019 00020 00021 /****************************** 00022 * Constructors and destructor * 00023 ******************************/ 00024 00025 Rigid::Rigid() 00026 { 00027 #ifdef VERBOSE 00028 Debug::print("Rigid constructor", 2); 00029 #endif // VERBOSE 00030 00031 /* 00032 #ifdef USE_OPENGL 00033 m_displayList = 0; 00034 #endif // USE_OPENGL 00035 */ 00036 } 00037 00038 Rigid::~Rigid() 00039 { 00040 #ifdef VERBOSE 00041 Debug::print("Rigid destructor", 2); 00042 #endif // VERBOSE 00043 00044 /* 00045 #ifdef USE_OPENGL 00046 if(m_displayList) 00047 glDeleteLists(m_displayList, 1); 00048 m_displayList = 0; 00049 #endif // USE_OPENGL 00050 */ 00051 } 00052 00053 00054 /******************** 00055 * Movement function * 00056 ********************/ 00057 00058 void Rigid::rotate(const Vector3 &axis, float degrees) 00059 { 00060 Quaternion rot; 00061 rot.fromAxisAngle(axis, degrees); 00062 m_rotation = rot * m_rotation; 00063 } 00064 00065 void Rigid::rotateX(float degrees) 00066 { 00067 rotate(Vector3(1.0f, 0.0f, 0.0f), degrees); 00068 } 00069 00070 void Rigid::rotateY(float degrees) 00071 { 00072 rotate(Vector3(0.0f, 1.0f, 0.0f), degrees); 00073 } 00074 00075 void Rigid::rotateZ(float degrees) 00076 { 00077 rotate(Vector3(0.0f, 0.0f, 1.0f), degrees); 00078 } 00079 00080 00081 /****************** 00082 * Other functions * 00083 ******************/ 00084 00085 /* 00086 #ifdef USE_OPENGL 00087 void Rigid::initializeGL() 00088 { 00089 #ifdef VERBOSE 00090 Debug::print("Rigid initializeGL", 2); 00091 #endif // VERBOSE 00092 00093 // Generate the display list 00094 m_displayList = glGenLists(1); 00095 } 00096 00097 void Rigid::rotateGL() 00098 { 00099 #ifdef VERBOSE 00100 Debug::print("Rigid rotateGL", Debug::maxLevel); 00101 #endif // VERBOSE 00102 00103 // Rotate 00104 Vector3 axis; 00105 float angle; 00106 m_rotation.toAxisAngle(&axis, &angle); 00107 if(angle != 0.0f) 00108 glRotatef(angle, axis.getX(), axis.getY(), axis.getZ()); 00109 } 00110 00111 void Rigid::renderGL() 00112 { 00113 #ifdef VERBOSE 00114 Debug::print("Rigid renderGL", Debug::maxLevel); 00115 #endif // VERBOSE 00116 00117 // Setup some OpenGL states 00118 glLineWidth(1.0f); 00119 00120 // Draw the object 00121 glCallList(m_displayList); 00122 } 00123 #endif // USE_OPENGL 00124 */

Generated on Sun Aug 15 19:19:23 2004 for OpenCAL: Open Computer Animation Library by doxygen 1.3.8