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 // For InvalidateMaterialHandles 00063 #include "csutil/deprecated_warn_off.h" 00064 00076 class CS_CRYSTALSPACE_EXPORT csMeshObject : 00077 public scfImplementationExt1<csMeshObject, csObjectModel, iMeshObject> 00078 { 00079 protected: 00081 csRef<iMeshObjectDrawCallback> VisCallback; 00082 00084 iMeshWrapper *LogParent; 00085 00087 iEngine *Engine; 00088 00090 void WantToDie (); 00091 00093 csFlags flags; 00094 00096 csBox3 boundingbox; 00097 00098 public: 00099 00101 csMeshObject (iEngine *engine); 00102 00104 virtual ~csMeshObject (); 00105 00110 virtual iMeshObjectFactory* GetFactory () const = 0; 00111 00116 virtual csPtr<iMeshObject> Clone () { return 0; } 00117 00121 virtual csFlags& GetFlags () { return flags; } 00122 00127 virtual CS::Graphics::RenderMesh** GetRenderMeshes (int& num, iRenderView*, iMovable*, 00128 uint32) 00129 { 00130 num = 0; 00131 return 0; 00132 } 00133 00139 virtual void SetVisibleCallback (iMeshObjectDrawCallback* cb); 00140 00145 virtual iMeshObjectDrawCallback* GetVisibleCallback () const; 00146 00151 virtual void NextFrame (csTicks current_time,const csVector3& pos, 00152 uint currentFrame); 00153 00158 virtual void HardTransform (const csReversibleTransform& t); 00159 00164 virtual bool SupportsHardTransform () const; 00165 00170 virtual bool HitBeamOutline (const csVector3& start, 00171 const csVector3& end, csVector3& isect, float* pr); 00172 00177 virtual bool HitBeamObject (const csVector3& start, const csVector3& end, 00178 csVector3& isect, float* pr, int* polygon_idx = 0, 00179 iMaterialWrapper** = 0); 00180 00185 virtual void SetMeshWrapper (iMeshWrapper* logparent); 00186 00191 virtual iMeshWrapper* GetMeshWrapper () const; 00192 00196 virtual iObjectModel* GetObjectModel () { return this; } 00197 00202 virtual bool SetColor (const csColor& color); 00203 00208 virtual bool GetColor (csColor& color) const; 00209 00214 virtual bool SetMaterialWrapper (iMaterialWrapper* material); 00215 00220 virtual iMaterialWrapper* GetMaterialWrapper () const; 00221 00223 virtual void SetMixMode (uint) { } 00225 virtual uint GetMixMode () const { return CS_FX_COPY; } 00226 00231 virtual void InvalidateMaterialHandles () { } 00232 00237 virtual void PositionChild (iMeshObject* /*child*/,csTicks /*current_time*/) { } 00238 00243 virtual void BuildDecal(const csVector3* pos, float decalRadius, 00244 iDecalBuilder* decalBuilder) 00245 { 00246 } 00247 00252 virtual const csBox3& GetObjectBoundingBox (); 00253 00258 virtual void SetObjectBoundingBox (const csBox3& bbox); 00259 00264 virtual void GetRadius (float& radius, csVector3& center); 00265 00270 virtual iTerraFormer* GetTerraFormerColldet () { return 0; } 00271 00272 virtual iTerrainSystem* GetTerrainColldet () { return 0; } 00273 }; 00274 00275 #include "csutil/deprecated_warn_on.h" 00276 00281 class CS_CRYSTALSPACE_EXPORT csMeshFactory : 00282 public scfImplementation1<csMeshFactory, iMeshObjectFactory> 00283 { 00284 protected: 00286 iMeshFactoryWrapper *LogParent; 00287 00289 iMeshObjectType* mesh_type; 00290 00292 iEngine *Engine; 00293 00295 iObjectRegistry* object_reg; 00296 00298 csFlags flags; 00299 00300 public: 00301 00303 csMeshFactory (iEngine *engine, iObjectRegistry* object_reg, 00304 iMeshObjectType* parent); 00305 00307 iObjectRegistry* GetObjectRegistry () { return object_reg; } 00308 00310 virtual ~csMeshFactory (); 00311 00315 virtual csFlags& GetFlags () { return flags; } 00316 00321 virtual csPtr<iMeshObject> NewInstance () = 0; 00322 00327 virtual void HardTransform (const csReversibleTransform& t); 00328 00333 virtual bool SupportsHardTransform () const; 00334 00339 virtual void SetMeshFactoryWrapper (iMeshFactoryWrapper* logparent); 00340 00345 virtual iMeshFactoryWrapper* GetMeshFactoryWrapper () const; 00346 00350 virtual iMeshObjectType* GetMeshObjectType () const; 00351 00355 virtual iObjectModel* GetObjectModel () { return 0; } 00356 00357 virtual bool SetMaterialWrapper (iMaterialWrapper*) { return false; } 00358 virtual iMaterialWrapper* GetMaterialWrapper () const { return 0; } 00359 virtual void SetMixMode (uint) { } 00360 virtual uint GetMixMode () const { return 0; } 00361 }; 00362 00366 class CS_CRYSTALSPACE_EXPORT csMeshType : 00367 public scfImplementation2<csMeshType, iMeshObjectType, iComponent> 00368 { 00369 protected: 00371 iEngine *Engine; 00372 00374 iObjectRegistry* object_reg; 00375 00376 public: 00377 00379 csMeshType (iBase *p); 00380 00382 virtual ~csMeshType (); 00383 00387 bool Initialize (iObjectRegistry* reg); 00388 00393 virtual csPtr<iMeshObjectFactory> NewFactory () = 0; 00394 00395 }; 00396 00397 #endif // __CS_MESHOBJTMPL_H__
Generated for Crystal Space 1.4.1 by doxygen 1.7.1