cstool/objmodel.h
Go to the documentation of this file.00001 /* 00002 Crystal Space 3D engine 00003 Copyright (C) 2003 by Jorrit Tyberghein 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 #ifndef __CS_CSTOOL_OBJMODEL_H__ 00021 #define __CS_CSTOOL_OBJMODEL_H__ 00022 00031 #include "csextern.h" 00032 00033 #include "csutil/refarr.h" 00034 #include "csutil/scf_implementation.h" 00035 #include "csutil/hash.h" 00036 #include "iutil/strset.h" 00037 #include "iutil/objreg.h" 00038 #include "imesh/objmodel.h" 00039 #include "igeom/polymesh.h" 00040 #include "igeom/trimesh.h" 00041 00042 struct iTerraFormer; 00043 00044 // for iPolygonMesh 00045 #include "csutil/win32/msvc_deprecated_warn_off.h" 00046 00047 class csTMIterator; 00048 00054 class CS_CRYSTALSPACE_EXPORT csObjectModel : 00055 public scfImplementation1<csObjectModel,iObjectModel> 00056 { 00057 friend class csTMIterator; 00058 00059 private: 00060 long shapenr; 00061 iPolygonMesh* polymesh_base; 00062 csRef<iPolygonMesh> polymesh_colldet; 00063 csRef<iPolygonMesh> polymesh_viscull; 00064 csRef<iPolygonMesh> polymesh_shadows; 00065 csRefArray<iObjectModelListener> listeners; 00066 00067 csHash<csRef<iTriangleMesh>,csStringID> trimesh; 00068 00069 public: 00074 csObjectModel (iBase* parent = 0) 00075 : scfImplementationType (this, parent), shapenr (-1), polymesh_base (0) 00076 { 00077 } 00078 00079 virtual ~csObjectModel () {} 00080 00085 csRef<iStringSet> GetStandardStringSet (iObjectRegistry* object_reg) 00086 { 00087 return csQueryRegistryTagInterface<iStringSet> (object_reg, 00088 "crystalspace.shared.stringset"); 00089 } 00090 00095 csStringID GetBaseID (iObjectRegistry* object_reg) 00096 { 00097 csRef<iStringSet> strings = GetStandardStringSet (object_reg); 00098 return strings->Request ("base"); 00099 } 00100 00104 void SetPolygonMeshBase (iPolygonMesh* base) 00105 { 00106 polymesh_base = base; 00107 } 00108 00112 void ShapeChanged () 00113 { 00114 shapenr++; 00115 FireListeners (); 00116 } 00117 00121 void SetShapeNumber (long n) 00122 { 00123 shapenr = n; 00124 } 00125 00129 void FireListeners () 00130 { 00131 size_t i; 00132 for (i = 0 ; i < listeners.GetSize () ; i++) 00133 listeners[i]->ObjectModelChanged (this); 00134 } 00135 00136 virtual long GetShapeNumber () const { return shapenr; } 00137 virtual iTriangleMesh* GetTriangleData (csStringID); 00138 virtual csPtr<iTriangleMeshIterator> GetTriangleDataIterator (); 00139 virtual void SetTriangleData (csStringID, iTriangleMesh*); 00140 virtual bool IsTriangleDataSet (csStringID); 00141 virtual void ResetTriangleData (csStringID); 00142 00143 virtual iPolygonMesh* GetPolygonMeshBase () { return polymesh_base; } 00144 virtual iPolygonMesh* GetPolygonMeshColldet () { return polymesh_colldet; } 00145 virtual void SetPolygonMeshColldet (iPolygonMesh* polymesh) 00146 { 00147 polymesh_colldet = polymesh; 00148 } 00149 virtual iPolygonMesh* GetPolygonMeshViscull () { return polymesh_viscull; } 00150 virtual void SetPolygonMeshViscull (iPolygonMesh* polymesh) 00151 { 00152 polymesh_viscull = polymesh; 00153 } 00154 virtual iPolygonMesh* GetPolygonMeshShadows () { return polymesh_shadows; } 00155 virtual void SetPolygonMeshShadows (iPolygonMesh* polymesh) 00156 { 00157 polymesh_shadows = polymesh; 00158 } 00159 virtual csPtr<iPolygonMesh> CreateLowerDetailPolygonMesh (float) 00160 { 00161 return 0; 00162 } 00163 virtual void AddListener (iObjectModelListener* listener) 00164 { 00165 RemoveListener (listener); 00166 listeners.Push (listener); 00167 } 00168 virtual void RemoveListener (iObjectModelListener* listener) 00169 { 00170 listeners.Delete (listener); 00171 } 00172 virtual iTerraFormer* GetTerraFormerColldet() 00173 { 00174 return 0; 00175 } 00176 virtual iTerrainSystem* GetTerrainColldet () { return 0; } 00177 }; 00178 00181 // for iPolygonMesh 00182 #include "csutil/win32/msvc_deprecated_warn_on.h" 00183 00184 #endif // __CS_CSTOOL_OBJMODEL_H__ 00185
Generated for Crystal Space 1.2 by doxygen 1.4.7