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

Object.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 "Object.h" 00013 #include <OpenCAL/System.h> 00014 using namespace OpenCAL; 00015 00016 #include <OpenCAL/NullParentException.h> 00017 using Exceptions::NullParentException; 00018 00019 00020 /****************************** 00021 * Constructors and destructor * 00022 ******************************/ 00023 00024 Object::Object(System *parent) 00025 : m_parent(parent), m_initialized(false), m_draw(true), m_enabled(true) 00026 { 00027 #ifdef VERBOSE 00028 Debug::print("Object constructor", 2); 00029 #endif // VERBOSE 00030 00031 if(!parent) 00032 throw NullParentException(__FILE__, __LINE__); 00033 00034 #ifdef VERBOSE 00035 Debug::print("Parent is given, adding to the the parent's object list...", 2); 00036 #endif // VERBOSE 00037 00038 parent->addObject(this); 00039 } 00040 00041 Object::~Object() 00042 { 00043 #ifdef VERBOSE 00044 Debug::print("Object destructor", 2); 00045 #endif // VERBOSE 00046 00047 m_parent->deleteObject(this); 00048 } 00049 00050 00051 /******************** 00052 * Movement function * 00053 ********************/ 00054 00055 void Object::move(const Vector3 &direction, float distance) 00056 { 00057 m_position += direction * distance; 00058 } 00059 00060 void Object::moveTo(const Vector3 &position) 00061 { 00062 m_position = position; 00063 } 00064 00065 00066 /****************** 00067 * Other functions * 00068 ******************/ 00069 00070 Matrix44 Object::getMatrix() const 00071 { 00072 Matrix44 result; 00073 00074 getMatrix(&result); 00075 00076 return result; 00077 } 00078 00079 void Object::getMatrix(Matrix44 *matrix) const 00080 { 00081 matrix->identity(); 00082 00083 // Set the translation 00084 matrix->set(0,3, m_position.getX()); 00085 matrix->set(1,3, m_position.getY()); 00086 matrix->set(2,3, m_position.getZ()); 00087 } 00088 00089 void Object::initialize() 00090 { 00091 #ifdef VERBOSE 00092 Debug::print("Object initialize", 2); 00093 #endif // VERBOSE 00094 00095 m_initialized = true; 00096 } 00097 00098 /* 00099 #ifdef USE_OPENGL 00100 void Object::translateGL() 00101 { 00102 // Translate 00103 glTranslatef(m_position.getX(), m_position.getY(), m_position.getZ()); 00104 } 00105 #endif // USE_OPENGL 00106 */ 00107 00108 00109 /********************** 00110 * Protected functions * 00111 **********************/ 00112 00113 void Object::assureInit() 00114 { 00115 if(!isInitialized()) 00116 { 00117 #ifdef VERBOSE 00118 Debug::initWarning("object"); 00119 #endif // VERBOSE 00120 initialize(); 00121 } 00122 }

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