Home | nevrax.com |
|
cluster.hGo to the documentation of this file.00001 00007 /* Copyright, 2001 Nevrax Ltd. 00008 * 00009 * This file is part of NEVRAX NEL. 00010 * NEVRAX NEL is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2, or (at your option) 00013 * any later version. 00014 00015 * NEVRAX NEL is distributed in the hope that it will be useful, but 00016 * WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * General Public License for more details. 00019 00020 * You should have received a copy of the GNU General Public License 00021 * along with NEVRAX NEL; see the file COPYING. If not, write to the 00022 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00023 * MA 02111-1307, USA. 00024 */ 00025 00026 #ifndef NL_CLUSTER_H 00027 #define NL_CLUSTER_H 00028 00029 #include "nel/misc/types_nl.h" 00030 #include "nel/misc/plane.h" 00031 #include "nel/misc/aabbox.h" 00032 00033 #include "3d/transform.h" 00034 00035 #include <vector> 00036 00037 namespace NLMISC 00038 { 00039 class CRGBA; 00040 class IStream; 00041 struct EStream; 00042 } 00043 00044 namespace NL3D { 00045 00046 00047 class CPortal; 00048 class CClusterClipObs; 00049 class CInstanceGroup; 00050 00051 const NLMISC::CClassId ClusterId=NLMISC::CClassId(0x13f37e46, 0x3e880780); 00052 00062 class CCluster : public CTransform 00063 { 00064 00065 public: 00066 00067 static void registerBasic (); 00068 00069 public: 00070 00071 CCluster(); 00072 00073 ~CCluster(); 00074 00080 bool makeVolume (NLMISC::CVector& p1, NLMISC::CVector& p2, NLMISC::CVector& p3); 00081 00082 00084 void applyMatrix(const NLMISC::CMatrix &m); 00085 00089 bool isIn (NLMISC::CVector& p); 00090 00094 bool isIn (NLMISC::CAABBox& b); 00095 00099 bool isIn (NLMISC::CVector& center, float size); 00100 00101 NLMISC::CAABBox& getBBox() { return _BBox; } 00102 00104 00105 // reset all links to portals. 00106 void resetPortalLinks (); 00107 00108 void link (CPortal* portal); 00109 void unlink (CPortal* portal); 00110 00111 uint32 getNbPortals() {return _Portals.size();} 00112 CPortal* getPortal(uint32 pos) {return _Portals[pos];} 00113 00114 CClusterClipObs *getClipObs(); 00115 00117 00118 void serial (NLMISC::IStream& f); 00119 00120 void setWorldMatrix (const NLMISC::CMatrix &WM); 00121 00122 // Moving cluster 00123 CQuadGrid<CCluster*>::CIterator AccelIt; 00124 00125 // Additionnal properties 00126 std::string Name; 00127 bool FatherVisible; 00128 bool VisibleFromFather; 00129 CCluster *Father; 00130 std::vector<CCluster*> Children; 00131 CInstanceGroup *Group; 00132 00133 bool isRoot() { return _LocalVolume.size() == 0; } 00134 00135 00136 private: 00137 00138 static IModel *creator () {return new CCluster;} 00139 00140 private: 00141 00143 CClusterClipObs *_Obs; 00144 00146 std::vector<CPortal*> _Portals; 00147 00151 NLMISC::CAABBox _LocalBBox; 00153 std::vector<NLMISC::CPlane> _LocalVolume; 00154 00157 NLMISC::CAABBox _BBox; 00159 std::vector<NLMISC::CPlane> _Volume; 00160 private: 00161 // This unlink this cluster from its sons and its parents 00162 void unlinkFromClusterTree(); 00163 // unlink this cluster from its parent 00164 void unlinkFromParent(); 00165 // unlink this cluster sons 00166 void unlinkSons(); 00167 00168 00170 friend class CInstanceGroup; 00171 }; 00172 00180 class CClusterHrcObs : public CTransformHrcObs 00181 { 00182 00183 public: 00184 00185 virtual void traverse (IObs *caller); 00186 00187 static IObs *creator () {return new CClusterHrcObs;} 00188 00190 friend class CCluster; 00191 }; 00192 00200 class CClusterClipObs : public IBaseClipObs 00201 { 00202 00203 public: 00204 CClusterClipObs(); 00205 00207 virtual bool clip (IBaseClipObs *caller); 00208 00210 virtual void traverse (IObs *caller); 00211 00212 private: 00213 00214 bool Visited; 00215 00216 private: 00217 00218 static IObs *creator () {return new CClusterClipObs;} 00219 00221 friend class CCluster; 00222 }; 00223 00224 00225 } // NL3D 00226 00227 00228 #endif // NL_CLUSTER_H 00229 00230 /* End of cluster.h */ |