cstool/genmeshbuilder.h Source File (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

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

- File List
- File Members

cstool/genmeshbuilder.h
Go to the documentation of this file.

    00001 /*
    00002     Copyright (C) 2007 by Jorrit Tyberghein
    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_GENMESHPRIM_H__
    00020 #define __CS_GENMESHPRIM_H__
    00021
    00026 #include "csextern.h"
    00027
    00028 #include "csgeom/sphere.h"
    00029 #include "cstool/primitives.h"
    00030 #include "iengine/mesh.h"
    00031 #include "imesh/object.h"
    00032 #include "imesh/genmesh.h"
    00033
    00034 struct iEngine;
    00035 struct iSector;
    00036
    00037 namespace CS
    00038 {
    00039 namespace Geometry
    00040 {
    00041
    00045 struct Primitive
    00046 {
    00047 public:
    00048   virtual ~Primitive () { }
    00049
    00051   virtual void Append (iGeneralFactoryState* factory) = 0;
    00052
    00057   virtual bool Append (iMeshFactoryWrapper* factory)
    00058   {
    00059     csRef<iGeneralFactoryState> state = scfQueryInterface<
    00060       iGeneralFactoryState> (factory->GetMeshObjectFactory ());
    00061     if (!state) return false;
    00062     Append (state);
    00063     return true;
    00064   }
    00065 };
    00066
    00070 class CS_CRYSTALSPACE_EXPORT TesselatedQuad : public Primitive
    00071 {
    00072 private:
    00073   csVector3 v0, v1, v2;
    00074   int tesselations;
    00075   TextureMapper* mapper;
    00076
    00077 public:
    00085   TesselatedQuad (const csVector3& v0, const csVector3& v1, const csVector3& v2);
    00086   virtual ~TesselatedQuad () { }
    00087
    00089   void SetLevel (int level) { tesselations = level; }
    00090
    00092   int GetLevel () const { return tesselations; }
    00093
    00098   void SetMapper (TextureMapper* mapper)
    00099   {
    00100     TesselatedQuad::mapper = mapper;
    00101   }
    00102
    00103   virtual void Append (iGeneralFactoryState* state);
    00104   virtual bool Append (iMeshFactoryWrapper* factory)
    00105   {
    00106     return Primitive::Append (factory);
    00107   }
    00108 };
    00109
    00113 class CS_CRYSTALSPACE_EXPORT TesselatedBox : public Primitive
    00114 {
    00115 private:
    00116   csBox3 box;
    00117   int tesselations;
    00118   TextureMapper* mapper;
    00119   uint32 flags;
    00120
    00121   void Init (const csBox3& box);
    00122
    00123 public:
    00129   TesselatedBox (const csBox3& box)
    00130   {
    00131     Init (box);
    00132   }
    00138   TesselatedBox (const csVector3& v1, const csVector3& v2)
    00139   {
    00140     Init (csBox3 (v1, v2));
    00141   }
    00142   virtual ~TesselatedBox () { }
    00143
    00145   void SetLevel (int level) { tesselations = level; }
    00146
    00148   int GetLevel () const { return tesselations; }
    00149
    00154   void SetMapper (TextureMapper* mapper)
    00155   {
    00156     TesselatedBox::mapper = mapper;
    00157   }
    00158
    00164   void SetFlags (uint32 flags)
    00165   {
    00166     TesselatedBox::flags = flags;
    00167   }
    00168
    00170   uint32 GetFlags () const { return flags; }
    00171
    00172   virtual void Append (iGeneralFactoryState* state);
    00173   virtual bool Append (iMeshFactoryWrapper* factory)
    00174   {
    00175     return Primitive::Append (factory);
    00176   }
    00177 };
    00178
    00182 class CS_CRYSTALSPACE_EXPORT Box : public Primitive
    00183 {
    00184 private:
    00185   csBox3 box;
    00186   TextureMapper* mapper;
    00187   uint32 flags;
    00188
    00189   void Init (const csBox3& box);
    00190
    00191 public:
    00192   Box (const csBox3& box)
    00193   {
    00194     Init (box);
    00195   }
    00196   Box (const csVector3& v1, const csVector3& v2)
    00197   {
    00198     Init (csBox3 (v1, v2));
    00199   }
    00200   virtual ~Box () { }
    00201
    00206   void SetMapper (TextureMapper* mapper)
    00207   {
    00208     Box::mapper = mapper;
    00209   }
    00210
    00215   void SetFlags (uint32 flags)
    00216   {
    00217     Box::flags = flags;
    00218   }
    00219
    00221   uint32 GetFlags () const { return flags; }
    00222
    00223   virtual void Append (iGeneralFactoryState* state);
    00224   virtual bool Append (iMeshFactoryWrapper* factory)
    00225   {
    00226     return Primitive::Append (factory);
    00227   }
    00228 };
    00229
    00233 class CS_CRYSTALSPACE_EXPORT Capsule : public Primitive
    00234 {
    00235 private:
    00236   float l, r;
    00237   uint sides;
    00238   TextureMapper* mapper;
    00239
    00240 public:
    00247   Capsule (float l, float r, uint sides);
    00248   virtual ~Capsule () { }
    00249
    00253   void SetMapper (TextureMapper* mapper)
    00254   {
    00255     Capsule::mapper = mapper;
    00256   }
    00257
    00258   virtual void Append (iGeneralFactoryState* state);
    00259   virtual bool Append (iMeshFactoryWrapper* factory)
    00260   {
    00261     return Primitive::Append (factory);
    00262   }
    00263 };
    00264
    00268 class CS_CRYSTALSPACE_EXPORT Sphere : public Primitive
    00269 {
    00270 private:
    00271   csEllipsoid ellips;
    00272   int num;
    00273   TextureMapper* mapper;
    00274   bool cyl_mapping;
    00275   bool toponly;
    00276   bool reversed;
    00277
    00278 public:
    00284   Sphere (const csEllipsoid& ellips, int num);
    00285   virtual ~Sphere () { }
    00286
    00291   void SetCylindricalMapping (bool cyl) { cyl_mapping = cyl; }
    00293   bool HasCylindricalMapping () const { return cyl_mapping; }
    00294
    00299   void SetTopOnly (bool top) { toponly = top; }
    00301   bool IsTopOnly () const { return toponly; }
    00302
    00307   void SetReversed (bool rev) { reversed  = rev; }
    00309   bool IsReversed () const { return reversed; }
    00310
    00315   void SetMapper (TextureMapper* mapper)
    00316   {
    00317     Sphere::mapper = mapper;
    00318   }
    00319
    00320   virtual void Append (iGeneralFactoryState* state);
    00321   virtual bool Append (iMeshFactoryWrapper* factory)
    00322   {
    00323     return Primitive::Append (factory);
    00324   }
    00325 };
    00326
    00330 class CS_CRYSTALSPACE_EXPORT Cone : public Primitive
    00331 {
    00332 private:
    00333   float l, r;
    00334   uint sides;
    00335   TextureMapper* mapper;
    00336
    00337 public:
    00344   Cone (float h, float r, uint sides);
    00345   virtual ~Cone () { }
    00346
    00350   void SetMapper (TextureMapper* mapper)
    00351   {
    00352     Cone::mapper = mapper;
    00353   }
    00354
    00355   virtual void Append (iGeneralFactoryState* state);
    00356   virtual bool Append (iMeshFactoryWrapper* factory)
    00357   {
    00358     return Primitive::Append (factory);
    00359   }
    00360 };
    00361
    00365 class CS_CRYSTALSPACE_EXPORT GeneralMeshBuilder
    00366 {
    00367 public:
    00374   static csPtr<iMeshFactoryWrapper> CreateFactory (iEngine* engine,
    00375     const char* name, Primitive* primitive = 0);
    00376
    00387   static csPtr<iMeshWrapper> CreateMesh (iEngine* engine, iSector* sector,
    00388     const char* name, iMeshFactoryWrapper* factory);
    00389
    00400   static csPtr<iMeshWrapper> CreateMesh (iEngine* engine, iSector* sector,
    00401     const char* name, const char* factoryname);
    00402
    00417   static csPtr<iMeshWrapper> CreateFactoryAndMesh (iEngine* engine,
    00418       iSector* sector, const char* name, const char* factoryname,
    00419       Primitive* primitive = 0);
    00420 };
    00421 } // namespace Geometry
    00422 } // namespace CS
    00423
    00426 #endif // __CS_GENMESHPRIM_H__
    00427