CrystalSpace

Public API Reference

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/trimesh.h"
00040 
00041 struct iTerraFormer;
00042 
00043 class csTMIterator;
00044 
00050 class CS_CRYSTALSPACE_EXPORT csObjectModel : 
00051   public scfImplementation1<csObjectModel,iObjectModel>
00052 {
00053   friend class csTMIterator;
00054 
00055 private:
00056   long shapenr;
00057   csRefArray<iObjectModelListener> listeners;
00058 
00059   csHash<csRef<iTriangleMesh>,csStringID> trimesh;
00060 
00061 public:
00066   csObjectModel (iBase* parent = 0)
00067     : scfImplementationType (this, parent), shapenr (-1)
00068   {
00069   }
00070 
00071   virtual ~csObjectModel () {}
00072 
00077   csRef<iStringSet> GetStandardStringSet (iObjectRegistry* object_reg)
00078   {
00079     return csQueryRegistryTagInterface<iStringSet> (object_reg,
00080         "crystalspace.shared.stringset");
00081   }
00082 
00087   csStringID GetBaseID (iObjectRegistry* object_reg)
00088   {
00089     csRef<iStringSet> strings = GetStandardStringSet (object_reg);
00090     return strings->Request ("base");
00091   }
00092 
00096   void ShapeChanged ()
00097   {
00098     shapenr++;
00099     FireListeners ();
00100   }
00101 
00105   void SetShapeNumber (long n)
00106   {
00107     shapenr = n;
00108   }
00109 
00113   void FireListeners ()
00114   {
00115     size_t i;
00116     for (i = 0 ; i < listeners.GetSize () ; i++)
00117       listeners[i]->ObjectModelChanged (this);
00118   }
00119 
00120   virtual long GetShapeNumber () const { return shapenr; }
00121   virtual iTriangleMesh* GetTriangleData (csStringID);
00122   virtual csPtr<iTriangleMeshIterator> GetTriangleDataIterator ();
00123   virtual void SetTriangleData (csStringID, iTriangleMesh*);
00124   virtual bool IsTriangleDataSet (csStringID);
00125   virtual void ResetTriangleData (csStringID);
00126 
00127   virtual void AddListener (iObjectModelListener* listener)
00128   {
00129     RemoveListener (listener);
00130     listeners.Push (listener);
00131   }
00132   virtual void RemoveListener (iObjectModelListener* listener)
00133   {
00134     listeners.Delete (listener);
00135   }
00136   virtual iTerraFormer* GetTerraFormerColldet()
00137   {
00138     return 0;
00139   }
00140   virtual iTerrainSystem* GetTerrainColldet () { return 0; }
00141 };
00142 
00145 #endif // __CS_CSTOOL_OBJMODEL_H__
00146 

Generated for Crystal Space 2.0 by doxygen 1.7.6.1