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 00073 class CS_CRYSTALSPACE_EXPORT csMeshObject : 00074 public scfImplementationExt1<csMeshObject, csObjectModel, iMeshObject> 00075 { 00076 protected: 00078 csRef<iMeshObjectDrawCallback> VisCallback; 00079 00081 iMeshWrapper *LogParent; 00082 00084 iEngine *Engine; 00085 00087 void WantToDie (); 00088 00090 csFlags flags; 00091 00093 csBox3 boundingbox; 00094 00095 public: 00096 00098 csMeshObject (iEngine *engine); 00099 00101 virtual ~csMeshObject (); 00102 00107 virtual iMeshObjectFactory* GetFactory () const = 0; 00108 00113 virtual csPtr<iMeshObject> Clone () { return 0; } 00114 00118 virtual csFlags& GetFlags () { return flags; } 00119 00124 virtual CS::Graphics::RenderMesh** GetRenderMeshes (int& num, iRenderView*, iMovable*, 00125 uint32) 00126 { 00127 num = 0; 00128 return 0; 00129 } 00130 00136 virtual void SetVisibleCallback (iMeshObjectDrawCallback* cb); 00137 00142 virtual iMeshObjectDrawCallback* GetVisibleCallback () const; 00143 00148 virtual void NextFrame (csTicks current_time,const csVector3& pos, 00149 uint currentFrame); 00150 00155 virtual void HardTransform (const csReversibleTransform& t); 00156 00161 virtual bool SupportsHardTransform () const; 00162 00167 virtual bool HitBeamOutline (const csVector3& start, 00168 const csVector3& end, csVector3& isect, float* pr); 00169 00174 virtual bool HitBeamObject (const csVector3& start, const csVector3& end, 00175 csVector3& isect, float* pr, int* polygon_idx = 0, 00176 iMaterialWrapper** = 0); 00177 00182 virtual void SetMeshWrapper (iMeshWrapper* logparent); 00183 00188 virtual iMeshWrapper* GetMeshWrapper () const; 00189 00193 virtual iObjectModel* GetObjectModel () { return this; } 00194 00199 virtual bool SetColor (const csColor& color); 00200 00205 virtual bool GetColor (csColor& color) const; 00206 00211 virtual bool SetMaterialWrapper (iMaterialWrapper* material); 00212 00217 virtual iMaterialWrapper* GetMaterialWrapper () const; 00218 00220 virtual void SetMixMode (uint) { } 00222 virtual uint GetMixMode () const { return CS_FX_COPY; } 00223 00228 virtual void PositionChild (iMeshObject* /*child*/,csTicks /*current_time*/) { } 00229 00234 virtual void BuildDecal(const csVector3* pos, float decalRadius, 00235 iDecalBuilder* decalBuilder) 00236 { 00237 } 00238 00243 virtual const csBox3& GetObjectBoundingBox (); 00244 00249 virtual void SetObjectBoundingBox (const csBox3& bbox); 00250 00255 virtual void GetRadius (float& radius, csVector3& center); 00256 00261 virtual iTerraFormer* GetTerraFormerColldet () { return 0; } 00262 00263 virtual iTerrainSystem* GetTerrainColldet () { return 0; } 00264 }; 00265 00270 class CS_CRYSTALSPACE_EXPORT csMeshFactory : 00271 public scfImplementation1<csMeshFactory, iMeshObjectFactory> 00272 { 00273 protected: 00275 iMeshFactoryWrapper *LogParent; 00276 00278 iMeshObjectType* mesh_type; 00279 00281 iEngine *Engine; 00282 00284 iObjectRegistry* object_reg; 00285 00287 csFlags flags; 00288 00289 public: 00290 00292 csMeshFactory (iEngine *engine, iObjectRegistry* object_reg, 00293 iMeshObjectType* parent); 00294 00296 iObjectRegistry* GetObjectRegistry () { return object_reg; } 00297 00299 virtual ~csMeshFactory (); 00300 00304 virtual csFlags& GetFlags () { return flags; } 00305 00310 virtual csPtr<iMeshObject> NewInstance () = 0; 00311 00316 virtual void HardTransform (const csReversibleTransform& t); 00317 00322 virtual bool SupportsHardTransform () const; 00323 00328 virtual void SetMeshFactoryWrapper (iMeshFactoryWrapper* logparent); 00329 00334 virtual iMeshFactoryWrapper* GetMeshFactoryWrapper () const; 00335 00339 virtual iMeshObjectType* GetMeshObjectType () const; 00340 00344 virtual iObjectModel* GetObjectModel () { return 0; } 00345 00346 virtual bool SetMaterialWrapper (iMaterialWrapper*) { return false; } 00347 virtual iMaterialWrapper* GetMaterialWrapper () const { return 0; } 00348 virtual void SetMixMode (uint) { } 00349 virtual uint GetMixMode () const { return 0; } 00350 }; 00351 00355 class CS_CRYSTALSPACE_EXPORT csMeshType : 00356 public scfImplementation2<csMeshType, iMeshObjectType, iComponent> 00357 { 00358 protected: 00360 iEngine *Engine; 00361 00363 iObjectRegistry* object_reg; 00364 00365 public: 00366 00368 csMeshType (iBase *p); 00369 00371 virtual ~csMeshType (); 00372 00376 bool Initialize (iObjectRegistry* reg); 00377 00382 virtual csPtr<iMeshObjectFactory> NewFactory () = 0; 00383 00384 }; 00385 00386 #endif // __CS_MESHOBJTMPL_H__
Generated for Crystal Space 2.0 by doxygen 1.6.1