CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

csgeom/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_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   csRef<iPolygonMesh> polymesh_shadows;
00048   csRefArray<iObjectModelListener> listeners;
00049 
00050 public:
00055   csObjectModel ()
00056   {
00057     shapenr = -1;
00058     polymesh_base = 0;
00059   }
00060 
00061   virtual ~csObjectModel () { }
00062 
00066   void SetPolygonMeshBase (iPolygonMesh* base)
00067   {
00068     polymesh_base = base;
00069   }
00070 
00074   void ShapeChanged ()
00075   {
00076     shapenr++;
00077     FireListeners ();
00078   }
00079 
00083   void SetShapeNumber (long n)
00084   {
00085     shapenr = n;
00086   }
00087 
00091   void FireListeners ()
00092   {
00093     int i;
00094     for (i = 0 ; i < listeners.Length () ; i++)
00095       listeners[i]->ObjectModelChanged (this);
00096   }
00097 
00098   virtual long GetShapeNumber () const { return shapenr; }
00099   virtual iPolygonMesh* GetPolygonMeshBase () { return polymesh_base; }
00100   virtual iPolygonMesh* GetPolygonMeshColldet () { return polymesh_colldet; }
00101   virtual void SetPolygonMeshColldet (iPolygonMesh* polymesh)
00102   {
00103     polymesh_colldet = polymesh;
00104   }
00105   virtual iPolygonMesh* GetPolygonMeshViscull () { return polymesh_viscull; }
00106   virtual void SetPolygonMeshViscull (iPolygonMesh* polymesh)
00107   {
00108     polymesh_viscull = polymesh;
00109   }
00110   virtual iPolygonMesh* GetPolygonMeshShadows () { return polymesh_shadows; }
00111   virtual void SetPolygonMeshShadows (iPolygonMesh* polymesh)
00112   {
00113     polymesh_shadows = polymesh;
00114   }
00115   virtual csPtr<iPolygonMesh> CreateLowerDetailPolygonMesh (float)
00116   {
00117     return 0;
00118   }
00119   virtual void AddListener (iObjectModelListener* listener)
00120   {
00121     RemoveListener (listener);
00122     listeners.Push (listener);
00123   }
00124   virtual void RemoveListener (iObjectModelListener* listener)
00125   {
00126     listeners.Delete (listener);
00127   }
00128 };
00129 
00132 #endif // __CS_CSGEOM_OBJMODEL_H__
00133 

Generated for Crystal Space by doxygen 1.2.18