| ## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# 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 "imesh/objmodel.h"
    00036 #include "igeom/polymesh.h"
    00037
    00038 struct iTerraFormer;
    00039
    00045 class csObjectModel : public scfImplementation1<csObjectModel,iObjectModel>
    00046 {
    00047 private:
    00048   long shapenr;
    00049   iPolygonMesh* polymesh_base;
    00050   csRef<iPolygonMesh> polymesh_colldet;
    00051   csRef<iPolygonMesh> polymesh_viscull;
    00052   csRef<iPolygonMesh> polymesh_shadows;
    00053   csRefArray<iObjectModelListener> listeners;
    00054
    00055 public:
    00060   csObjectModel (iBase* parent = 0)
    00061     : scfImplementationType (this, parent), shapenr (-1), polymesh_base (0)
    00062   {
    00063   }
    00064
    00065   virtual ~csObjectModel () {}
    00066
    00070   void SetPolygonMeshBase (iPolygonMesh* base)
    00071   {
    00072     polymesh_base = base;
    00073   }
    00074
    00078   void ShapeChanged ()
    00079   {
    00080     shapenr++;
    00081     FireListeners ();
    00082   }
    00083
    00087   void SetShapeNumber (long n)
    00088   {
    00089     shapenr = n;
    00090   }
    00091
    00095   void FireListeners ()
    00096   {
    00097     size_t i;
    00098     for (i = 0 ; i < listeners.Length () ; i++)
    00099       listeners[i]->ObjectModelChanged (this);
    00100   }
    00101
    00102   virtual long GetShapeNumber () const { return shapenr; }
    00103   virtual iPolygonMesh* GetPolygonMeshBase () { return polymesh_base; }
    00104   virtual iPolygonMesh* GetPolygonMeshColldet () { return polymesh_colldet; }
    00105   virtual void SetPolygonMeshColldet (iPolygonMesh* polymesh)
    00106   {
    00107     polymesh_colldet = polymesh;
    00108   }
    00109   virtual iPolygonMesh* GetPolygonMeshViscull () { return polymesh_viscull; }
    00110   virtual void SetPolygonMeshViscull (iPolygonMesh* polymesh)
    00111   {
    00112     polymesh_viscull = polymesh;
    00113   }
    00114   virtual iPolygonMesh* GetPolygonMeshShadows () { return polymesh_shadows; }
    00115   virtual void SetPolygonMeshShadows (iPolygonMesh* polymesh)
    00116   {
    00117     polymesh_shadows = polymesh;
    00118   }
    00119   virtual csPtr<iPolygonMesh> CreateLowerDetailPolygonMesh (float)
    00120   {
    00121     return 0;
    00122   }
    00123   virtual void AddListener (iObjectModelListener* listener)
    00124   {
    00125     RemoveListener (listener);
    00126     listeners.Push (listener);
    00127   }
    00128   virtual void RemoveListener (iObjectModelListener* listener)
    00129   {
    00130     listeners.Delete (listener);
    00131   }
    00132   virtual iTerraFormer* GetTerraFormerColldet()
    00133   {
    00134     return 0;
    00135   }
    00136 };
    00137
    00140 #endif // __CS_CSTOOL_OBJMODEL_H__
    00141