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 BuildDecal(const csVector3* pos, float decalRadius, 00243 iDecalBuilder* decalBuilder) 00244 { 00245 } 00246 00251 virtual void GetObjectBoundingBox (csBox3& bbox); 00252 00257 virtual const csBox3& GetObjectBoundingBox (); 00258 00263 virtual void SetObjectBoundingBox (const csBox3& bbox); 00264 00269 virtual void GetRadius (float& radius, csVector3& center); 00270 00275 virtual iTerraFormer* GetTerraFormerColldet () { return 0; } 00276 00277 virtual iTerrainSystem* GetTerrainColldet () { return 0; } 00278 }; 00279 00280 #include "csutil/win32/msvc_deprecated_warn_on.h" 00281 00286 class CS_CRYSTALSPACE_EXPORT csMeshFactory : 00287 public scfImplementation1<csMeshFactory, iMeshObjectFactory> 00288 { 00289 protected: 00291 iMeshFactoryWrapper *LogParent; 00292 00294 iMeshObjectType* mesh_type; 00295 00297 iEngine *Engine; 00298 00300 iObjectRegistry* object_reg; 00301 00303 csFlags flags; 00304 00305 public: 00306 00308 csMeshFactory (iEngine *engine, iObjectRegistry* object_reg, 00309 iMeshObjectType* parent); 00310 00312 iObjectRegistry* GetObjectRegistry () { return object_reg; } 00313 00315 virtual ~csMeshFactory (); 00316 00320 virtual csFlags& GetFlags () { return flags; } 00321 00326 virtual csPtr<iMeshObject> NewInstance () = 0; 00327 00332 virtual void HardTransform (const csReversibleTransform& t); 00333 00338 virtual bool SupportsHardTransform () const; 00339 00344 virtual void SetMeshFactoryWrapper (iMeshFactoryWrapper* logparent); 00345 00350 virtual iMeshFactoryWrapper* GetMeshFactoryWrapper () const; 00351 00355 virtual iMeshObjectType* GetMeshObjectType () const; 00356 00360 virtual iObjectModel* GetObjectModel () { return 0; } 00361 00362 virtual bool SetMaterialWrapper (iMaterialWrapper*) { return false; } 00363 virtual iMaterialWrapper* GetMaterialWrapper () const { return 0; } 00364 virtual void SetMixMode (uint) { } 00365 virtual uint GetMixMode () const { return 0; } 00366 }; 00367 00371 class CS_CRYSTALSPACE_EXPORT csMeshType : 00372 public scfImplementation2<csMeshType, iMeshObjectType, iComponent> 00373 { 00374 protected: 00376 iEngine *Engine; 00377 00379 iObjectRegistry* object_reg; 00380 00381 public: 00382 00384 csMeshType (iBase *p); 00385 00387 virtual ~csMeshType (); 00388 00392 bool Initialize (iObjectRegistry* reg); 00393 00398 virtual csPtr<iMeshObjectFactory> NewFactory () = 0; 00399 00400 }; 00401 00402 #endif // __CS_MESHOBJTMPL_H__
Generated for Crystal Space 1.2.1 by doxygen 1.5.3