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 "csextern.h"
00031 
00032 #include "igeom/polymesh.h"
00033 #include "igeom/objmodel.h"
00034 #include "csutil/refarr.h"
00035 
00042 class csObjectModel : public iObjectModel
00043 {
00044 private:
00045   long shapenr;
00046   iPolygonMesh* polymesh_base;
00047   csRef<iPolygonMesh> polymesh_colldet;
00048   csRef<iPolygonMesh> polymesh_viscull;
00049   csRef<iPolygonMesh> polymesh_shadows;
00050   csRefArray<iObjectModelListener> listeners;
00051 
00052 public:
00057   csObjectModel ()
00058   {
00059     shapenr = -1;
00060     polymesh_base = 0;
00061   }
00062 
00063   virtual ~csObjectModel () { }
00064 
00068   void SetPolygonMeshBase (iPolygonMesh* base)
00069   {
00070     polymesh_base = base;
00071   }
00072 
00076   void ShapeChanged ()
00077   {
00078     shapenr++;
00079     FireListeners ();
00080   }
00081 
00085   void SetShapeNumber (long n)
00086   {
00087     shapenr = n;
00088   }
00089 
00093   void FireListeners ()
00094   {
00095     int i;
00096     for (i = 0 ; i < listeners.Length () ; i++)
00097       listeners[i]->ObjectModelChanged (this);
00098   }
00099 
00100   virtual long GetShapeNumber () const { return shapenr; }
00101   virtual iPolygonMesh* GetPolygonMeshBase () { return polymesh_base; }
00102   virtual iPolygonMesh* GetPolygonMeshColldet () { return polymesh_colldet; }
00103   virtual void SetPolygonMeshColldet (iPolygonMesh* polymesh)
00104   {
00105     polymesh_colldet = polymesh;
00106   }
00107   virtual iPolygonMesh* GetPolygonMeshViscull () { return polymesh_viscull; }
00108   virtual void SetPolygonMeshViscull (iPolygonMesh* polymesh)
00109   {
00110     polymesh_viscull = polymesh;
00111   }
00112   virtual iPolygonMesh* GetPolygonMeshShadows () { return polymesh_shadows; }
00113   virtual void SetPolygonMeshShadows (iPolygonMesh* polymesh)
00114   {
00115     polymesh_shadows = polymesh;
00116   }
00117   virtual csPtr<iPolygonMesh> CreateLowerDetailPolygonMesh (float)
00118   {
00119     return 0;
00120   }
00121   virtual void AddListener (iObjectModelListener* listener)
00122   {
00123     RemoveListener (listener);
00124     listeners.Push (listener);
00125   }
00126   virtual void RemoveListener (iObjectModelListener* listener)
00127   {
00128     listeners.Delete (listener);
00129   }
00130 };
00131 
00134 #endif // __CS_CSGEOM_OBJMODEL_H__
00135 

Generated for Crystal Space by doxygen 1.2.18