Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages
meshobjtmpl.h
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 00022 #include "csextern.h" 00023 00024 #include "csgeom/box.h" 00025 #include "csgeom/objmodel.h" 00026 #include "csutil/flags.h" 00027 #include "csutil/refarr.h" 00028 00029 #include "imesh/object.h" 00030 #include "iutil/comp.h" 00031 00032 struct iEngine; 00033 00034 00036 #define CS_DECLARE_SIMPLE_MESH_FACTORY(name,meshclass) \ 00037 class name : public csMeshFactory { \ 00038 public: \ 00039 name (iEngine *e, iObjectRegistry* reg, iMeshObjectType* type) \ 00040 : csMeshFactory (e, reg, type) {} \ 00041 virtual csPtr<iMeshObject> NewInstance () \ 00042 { return new meshclass (Engine, this); } \ 00043 virtual csPtr<iMeshObjectFactory> Clone () { return 0; } \ 00044 }; 00045 00047 #define CS_DECLARE_SIMPLE_MESH_PLUGIN(name,factclass) \ 00048 class name : public csMeshType { \ 00049 public: \ 00050 name (iBase *p) : csMeshType (p) {} \ 00051 virtual csPtr<iMeshObjectFactory> NewFactory () \ 00052 { return new factclass (Engine, object_reg, this); } \ 00053 }; 00054 00068 class CS_CRYSTALSPACE_EXPORT csMeshObject : public iMeshObject 00069 { 00070 protected: 00072 csRef<iMeshObjectDrawCallback> VisCallback; 00073 00075 iBase *LogParent; 00076 00078 iEngine *Engine; 00079 00081 void WantToDie (); 00082 00084 csFlags flags; 00085 00087 csBox3 boundingbox; 00088 00089 public: 00090 SCF_DECLARE_IBASE; 00091 00093 csMeshObject (iEngine *engine); 00094 00096 virtual ~csMeshObject (); 00097 00102 virtual iMeshObjectFactory* GetFactory () const = 0; 00103 00108 virtual csPtr<iMeshObject> Clone () { return 0; } 00109 00113 virtual csFlags& GetFlags () { return flags; } 00114 00121 virtual csRenderMesh** GetRenderMeshes (int& num, iRenderView*, iMovable*, 00122 uint32) 00123 { 00124 num = 0; 00125 return 0; 00126 } 00127 00133 virtual void SetVisibleCallback (iMeshObjectDrawCallback* cb); 00134 00139 virtual iMeshObjectDrawCallback* GetVisibleCallback () const; 00140 00145 virtual void NextFrame (csTicks current_time,const csVector3& pos); 00146 00151 virtual void HardTransform (const csReversibleTransform& t); 00152 00157 virtual bool SupportsHardTransform () const; 00158 00163 virtual bool HitBeamOutline (const csVector3& start, 00164 const csVector3& end, csVector3& isect, float* pr); 00165 00170 virtual bool HitBeamObject (const csVector3& start, const csVector3& end, 00171 csVector3& isect, float* pr, int* polygon_idx = 0); 00172 00177 virtual void SetLogicalParent (iBase* logparent); 00178 00183 virtual iBase* GetLogicalParent () const; 00184 00188 virtual iObjectModel* GetObjectModel () { return &scfiObjectModel; } 00189 00194 virtual bool SetColor (const csColor& color); 00195 00200 virtual bool GetColor (csColor& color) const; 00201 00206 virtual bool SetMaterialWrapper (iMaterialWrapper* material); 00207 00212 virtual iMaterialWrapper* GetMaterialWrapper () const; 00213 00218 virtual void InvalidateMaterialHandles () { } 00219 00224 virtual void PositionChild (iMeshObject* /*child*/,csTicks /*current_time*/) { } 00225 00230 virtual void GetObjectBoundingBox (csBox3& bbox); 00231 00236 virtual void SetObjectBoundingBox (const csBox3& bbox); 00237 00242 virtual void GetRadius (csVector3& radius, csVector3& center); 00243 00244 // implementation of iObjectModel 00245 struct CS_CRYSTALSPACE_EXPORT eiObjectModel : public csObjectModel 00246 { 00247 SCF_DECLARE_EMBEDDED_IBASE (csMeshObject); 00248 virtual void GetObjectBoundingBox (csBox3& bbox) 00249 { 00250 scfParent->GetObjectBoundingBox (bbox); 00251 } 00252 virtual void SetObjectBoundingBox (const csBox3& bbox) 00253 { 00254 scfParent->SetObjectBoundingBox (bbox); 00255 } 00256 virtual void GetRadius (csVector3& radius, csVector3& center) 00257 { 00258 scfParent->GetRadius (radius, center); 00259 } 00260 } scfiObjectModel; 00261 friend struct eiObjectModel; 00262 }; 00263 00268 class CS_CRYSTALSPACE_EXPORT csMeshFactory : public iMeshObjectFactory 00269 { 00270 protected: 00272 iBase *LogParent; 00273 00275 iMeshObjectType* mesh_type; 00276 00278 iEngine *Engine; 00279 00281 iObjectRegistry* object_reg; 00282 00284 csFlags flags; 00285 00286 public: 00287 SCF_DECLARE_IBASE; 00288 00290 csMeshFactory (iEngine *engine, iObjectRegistry* object_reg, 00291 iMeshObjectType* parent); 00292 00294 iObjectRegistry* GetObjectRegistry () { return object_reg; } 00295 00297 virtual ~csMeshFactory (); 00298 00302 virtual csFlags& GetFlags () { return flags; } 00303 00308 virtual csPtr<iMeshObject> NewInstance () = 0; 00309 00314 virtual void HardTransform (const csReversibleTransform& t); 00315 00320 virtual bool SupportsHardTransform () const; 00321 00326 virtual void SetLogicalParent (iBase* logparent); 00327 00332 virtual iBase* GetLogicalParent () const; 00333 00337 virtual iMeshObjectType* GetMeshObjectType () const; 00338 00342 virtual iObjectModel* GetObjectModel () { return 0; } 00343 00344 }; 00345 00349 class CS_CRYSTALSPACE_EXPORT csMeshType : public iMeshObjectType 00350 { 00351 protected: 00353 iEngine *Engine; 00354 00356 iObjectRegistry* object_reg; 00357 00358 public: 00359 SCF_DECLARE_IBASE; 00360 00362 csMeshType (iBase *p); 00363 00365 virtual ~csMeshType (); 00366 00370 bool Initialize (iObjectRegistry* reg); 00371 00376 virtual csPtr<iMeshObjectFactory> NewFactory () = 0; 00377 00381 struct CS_CRYSTALSPACE_EXPORT eiComponent : public iComponent 00382 { 00383 SCF_DECLARE_EMBEDDED_IBASE (csMeshType); 00384 virtual bool Initialize (iObjectRegistry* p) 00385 { return scfParent->Initialize (p); } 00386 } scfiComponent; 00387 }; 00388 00389 #endif // __CS_MESHOBJTMPL_H__
Generated for Crystal Space by doxygen 1.4.4