00001 #ifndef TE_OBJECT_H 00002 #define TE_OBJECT_H 00003 00004 /*****************************************************************************\ 00005 * 00006 * TeObject.h 00007 * 00008 * TeObject abstract class 00009 * 00010 * Author: Martin Havlíček (xhavli15 AT stud.fit.vutbr.cz) 00011 * Contributors: 00012 * 00013 * Some code taken from SpaceGame objects written by Petr Mastera and PCJohn. 00014 * 00015 * ---------------------------------------------------------------------------- 00016 * 00017 * THIS SOFTWARE IS NOT COPYRIGHTED 00018 * 00019 * This source code is offered for use in the public domain. 00020 * You may use, modify or distribute it freely. 00021 * 00022 * This source code is distributed in the hope that it will be useful but 00023 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 00024 * DISCLAIMED. This includes but is not limited to warranties of 00025 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00026 * 00027 * If you find the source code useful, authors will kindly welcome 00028 * if you give them credit and keep their names with their source code. 00029 * 00030 \*****************************************************************************/ 00031 00039 #include <Inventor/SbLinear.h> 00040 #include "TePatch.h" 00041 00042 class SoSeparator; 00043 class SoTranslation; 00044 class SoRotation; 00045 class SoEvent; 00046 class TeEngine; 00047 00084 class TeObject { 00085 00086 friend class TeEngine; 00087 00088 public: 00090 enum MODEL_SET { RENDER = 0x01, 00091 COLLISION = 0x02, 00092 ALL = 0x03 00093 }; 00094 00095 protected: 00096 00097 // these attributes are managed by TeEngine friend class and should be never 00098 // hacked some other way 00100 TeEngine *engine; 00102 SbBool initialized; 00104 SbVec2f patchPosUnder; 00106 TePatch::Direction posInsidePatch; 00107 00109 SoSeparator *root; 00110 00112 SoTranslation *translation; 00114 SoRotation *rotation; 00115 00117 SbVec3f camDistance; 00118 00119 // models stuff 00121 SoNode *model; 00123 SoNode *collisionModel; 00124 00125 void createHiddenScene(); 00126 void releaseHiddenScene(); 00127 00128 virtual void createHUD(); 00129 00130 // these functions are called internally in each timeTick() 00131 virtual void updateHUD(); 00132 virtual void updateCamera(); 00133 00134 virtual void timeTick(const SbTime delta); 00135 00136 public: 00137 00139 SbVec3f position; 00141 SbVec3f speed; 00142 00143 TeObject(); 00144 virtual ~TeObject(); 00145 00146 SoSeparator *getSceneGraph(); 00147 SoTranslation* getTranslation(); 00148 00149 SoNode* getModel(); 00150 SoNode* getCollisionModel(); 00151 void setModel(SoNode *model, MODEL_SET which = ALL); 00152 SbBool setModel(const char *filename, MODEL_SET which = ALL); 00153 00154 virtual void handleEvent(const SoEvent *event); 00155 00156 }; 00157 00158 00159 #endif /* TE_OBJECT_H */