![]() |
Public API Reference |
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_CSGEOM_OBJMODEL_H__ 00021 #define __CS_CSGEOM_OBJMODEL_H__ 00022 00030 #include "igeom/polymesh.h" 00031 #include "igeom/objmodel.h" 00032 #include "csutil/refarr.h" 00033 00040 class csObjectModel : public iObjectModel 00041 { 00042 private: 00043 long shapenr; 00044 iPolygonMesh* polymesh_base; 00045 csRef<iPolygonMesh> polymesh_colldet; 00046 csRef<iPolygonMesh> polymesh_viscull; 00047 csRefArray<iObjectModelListener> listeners; 00048 00049 public: 00054 csObjectModel () 00055 { 00056 shapenr = -1; 00057 polymesh_base = NULL; 00058 } 00059 00060 virtual ~csObjectModel () { } 00061 00065 void SetPolygonMeshBase (iPolygonMesh* base) 00066 { 00067 polymesh_base = base; 00068 } 00069 00073 void ShapeChanged () 00074 { 00075 shapenr++; 00076 FireListeners (); 00077 } 00078 00082 void SetShapeNumber (long n) 00083 { 00084 shapenr = n; 00085 } 00086 00090 void FireListeners () 00091 { 00092 int i; 00093 for (i = 0 ; i < listeners.Length () ; i++) 00094 listeners[i]->ObjectModelChanged (this); 00095 } 00096 00097 virtual long GetShapeNumber () const { return shapenr; } 00098 virtual iPolygonMesh* GetPolygonMeshBase () { return polymesh_base; } 00099 virtual iPolygonMesh* GetPolygonMeshColldet () { return polymesh_colldet; } 00100 virtual void SetPolygonMeshColldet (iPolygonMesh* polymesh) 00101 { 00102 polymesh_colldet = polymesh; 00103 } 00104 virtual iPolygonMesh* GetPolygonMeshViscull () { return polymesh_viscull; } 00105 virtual void SetPolygonMeshViscull (iPolygonMesh* polymesh) 00106 { 00107 polymesh_viscull = polymesh; 00108 } 00109 virtual csPtr<iPolygonMesh> CreateLowerDetailPolygonMesh (float) 00110 { 00111 return NULL; 00112 } 00113 virtual void AddListener (iObjectModelListener* listener) 00114 { 00115 RemoveListener (listener); 00116 listeners.Push (listener); 00117 } 00118 virtual void RemoveListener (iObjectModelListener* listener) 00119 { 00120 int idx = listeners.Find (listener); 00121 if (idx == -1) return ; 00122 listeners.Delete (idx); 00123 } 00124 }; 00125 00128 #endif // __CS_CSGEOM_OBJMODEL_H__ 00129