## Public API Reference

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

- File List
- File Members

# cstool/meshobjtmpl.h

Go to the documentation of this file.

    00001 /*
    00002     Copyright (C) 2003 by Martin Geisse <mgeisse@gmx.net>
    00003
    00004     This library is free software; you can redistribute it and/or
    00005     modify it under the terms of the GNU Library General Public
    00006     License as published by the Free Software Foundation; either
    00007     version 2 of the License, or (at your option) any later version.
    00008
    00009     This library is distributed in the hope that it will be useful,
    00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012     Library General Public License for more details.
    00013
    00014     You should have received a copy of the GNU Library General Public
    00015     License along with this library; if not, write to the Free
    00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    00017 */
    00018
    00019 #ifndef __CS_MESHOBJTMPL_H__
    00020 #define __CS_MESHOBJTMPL_H__
    00021
    00026 #include "csextern.h"
    00027
    00028 #include "csgeom/box.h"
    00029 #include "cstool/objmodel.h"
    00030 #include "csutil/flags.h"
    00031 #include "csutil/refarr.h"
    00032 #include "csutil/scf_implementation.h"
    00033
    00034 #include "ivideo/graph3d.h"
    00035 #include "imesh/object.h"
    00036 #include "iutil/comp.h"
    00037
    00038 struct iEngine;
    00039 struct iMaterialWrapper;
    00040
    00041 //Deprecate these when possible!
    00043 #define CS_DECLARE_SIMPLE_MESH_FACTORY(name,meshclass)                      \
    00044   class name : public csMeshFactory {                                       \
    00045   public:                                                                   \
    00046     name (iEngine *e, iObjectRegistry* reg, iMeshObjectType* type)          \
    00047     : csMeshFactory (e, reg, type) {}                                       \
    00048     virtual csPtr<iMeshObject> NewInstance ()                               \
    00049     { return new meshclass (Engine, this); }                                \
    00050     virtual csPtr<iMeshObjectFactory> Clone () { return 0; }                \
    00051   };
    00052
    00054 #define CS_DECLARE_SIMPLE_MESH_PLUGIN(name,factclass)                       \
    00055   class name : public csMeshType {                                          \
    00056   public:                                                                   \
    00057     name (iBase *p) : csMeshType (p) {}                                     \
    00058     virtual csPtr<iMeshObjectFactory> NewFactory ()                         \
    00059     { return new factclass (Engine, object_reg, this); }                    \
    00060   };
    00061
    00062 #include "csutil/win32/msvc_deprecated_warn_off.h"
    00063
    00075 class CS_CRYSTALSPACE_EXPORT csMeshObject :
    00076   public scfImplementationExt1<csMeshObject, csObjectModel, iMeshObject>
    00077 {
    00078 protected:
    00080   csRef<iMeshObjectDrawCallback> VisCallback;
    00081
    00083   iMeshWrapper *LogParent;
    00084
    00086   iEngine *Engine;
    00087
    00089   void WantToDie ();
    00090
    00092   csFlags flags;
    00093
    00095   csBox3 boundingbox;
    00096
    00097 public:
    00098
    00100   csMeshObject (iEngine *engine);
    00101
    00103   virtual ~csMeshObject ();
    00104
    00109   virtual iMeshObjectFactory* GetFactory () const = 0;
    00110
    00115   virtual csPtr<iMeshObject> Clone () { return 0; }
    00116
    00120   virtual csFlags& GetFlags () { return flags; }
    00121
    00126   virtual csRenderMesh** GetRenderMeshes (int& num, iRenderView*, iMovable*,
    00127         uint32)
    00128   {
    00129     num = 0;
    00130     return 0;
    00131   }
    00132
    00138   virtual void SetVisibleCallback (iMeshObjectDrawCallback* cb);
    00139
    00144   virtual iMeshObjectDrawCallback* GetVisibleCallback () const;
    00145
    00150   virtual void NextFrame (csTicks current_time,const csVector3& pos,
    00151     uint currentFrame);
    00152
    00157   virtual void HardTransform (const csReversibleTransform& t);
    00158
    00163   virtual bool SupportsHardTransform () const;
    00164
    00169   virtual bool HitBeamOutline (const csVector3& start,
    00170         const csVector3& end, csVector3& isect, float* pr);
    00171
    00176   virtual bool HitBeamObject (const csVector3& start, const csVector3& end,
    00177         csVector3& isect, float* pr, int* polygon_idx = 0,
    00178         iMaterialWrapper** = 0);
    00179
    00184   virtual void SetMeshWrapper (iMeshWrapper* logparent);
    00185
    00190   virtual iMeshWrapper* GetMeshWrapper () const;
    00191
    00195   virtual iObjectModel* GetObjectModel () { return this; }
    00196
    00201   virtual bool SetColor (const csColor& color);
    00202
    00207   virtual bool GetColor (csColor& color) const;
    00208
    00213   virtual bool SetMaterialWrapper (iMaterialWrapper* material);
    00214
    00219   virtual iMaterialWrapper* GetMaterialWrapper () const;
    00220
    00222   virtual void SetMixMode (uint) { }
    00224   virtual uint GetMixMode () const { return CS_FX_COPY; }
    00225
    00230   virtual void InvalidateMaterialHandles () { }
    00231
    00236   virtual void PositionChild (iMeshObject* /*child*/,csTicks /*current_time*/) { }
    00237
    00242   virtual void GetObjectBoundingBox (csBox3& bbox);
    00243
    00248   virtual const csBox3& GetObjectBoundingBox ();
    00249
    00254   virtual void SetObjectBoundingBox (const csBox3& bbox);
    00255
    00260   virtual void GetRadius (float& radius, csVector3& center);
    00261
    00266   virtual iTerraFormer* GetTerraFormerColldet () { return 0; }
    00267
    00268 };
    00269
    00270 #include "csutil/win32/msvc_deprecated_warn_on.h"
    00271
    00276 class CS_CRYSTALSPACE_EXPORT csMeshFactory :
    00277   public scfImplementation1<csMeshFactory, iMeshObjectFactory>
    00278 {
    00279 protected:
    00281   iMeshFactoryWrapper *LogParent;
    00282
    00284   iMeshObjectType* mesh_type;
    00285
    00287   iEngine *Engine;
    00288
    00290   iObjectRegistry* object_reg;
    00291
    00293   csFlags flags;
    00294
    00295 public:
    00296
    00298   csMeshFactory (iEngine *engine, iObjectRegistry* object_reg,
    00299     iMeshObjectType* parent);
    00300
    00302   iObjectRegistry* GetObjectRegistry () { return object_reg; }
    00303
    00305   virtual ~csMeshFactory ();
    00306
    00310   virtual csFlags& GetFlags () { return flags; }
    00311
    00316   virtual csPtr<iMeshObject> NewInstance () = 0;
    00317
    00322   virtual void HardTransform (const csReversibleTransform& t);
    00323
    00328   virtual bool SupportsHardTransform () const;
    00329
    00334   virtual void SetMeshFactoryWrapper (iMeshFactoryWrapper* logparent);
    00335
    00340   virtual iMeshFactoryWrapper* GetMeshFactoryWrapper () const;
    00341
    00345   virtual iMeshObjectType* GetMeshObjectType () const;
    00346
    00350   virtual iObjectModel* GetObjectModel () { return 0; }
    00351
    00352   virtual bool SetMaterialWrapper (iMaterialWrapper*) { return false; }
    00353   virtual iMaterialWrapper* GetMaterialWrapper () const { return 0; }
    00354   virtual void SetMixMode (uint) { }
    00355   virtual uint GetMixMode () const { return 0; }
    00356 };
    00357
    00361 class CS_CRYSTALSPACE_EXPORT csMeshType :
    00362   public scfImplementation2<csMeshType, iMeshObjectType, iComponent>
    00363 {
    00364 protected:
    00366   iEngine *Engine;
    00367
    00369   iObjectRegistry* object_reg;
    00370
    00371 public:
    00372
    00374   csMeshType (iBase *p);
    00375
    00377   virtual ~csMeshType ();
    00378
    00382   bool Initialize (iObjectRegistry* reg);
    00383
    00388   virtual csPtr<iMeshObjectFactory> NewFactory () = 0;
    00389
    00390 };
    00391
    00392 #endif // __CS_MESHOBJTMPL_H__