CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

polygon.h

00001 /*
00002     Copyright (C) 1998-2001 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_THING_POLYGON_H__
00020 #define __CS_THING_POLYGON_H__
00021 
00022 #include "csutil/scf.h"
00023 #include "csgeom/plane3.h"
00024 #include "csgeom/vector3.h"
00025 #include "csgeom/matrix3.h"
00026 #include "csutil/flags.h"
00027 
00028 struct iMaterialHandle;
00029 struct iMaterialWrapper;
00030 struct iPolygon3D;
00031 struct iPolygonTexture;
00032 struct iPolyTexLightMap;
00033 struct iLight;
00034 struct iLightMap;
00035 struct iPortal;
00036 struct iSector;
00037 struct iThingState;
00038 struct iThingFactoryState;
00039 struct iPolyTexType;
00040 struct iRendererLightmap;
00041 
00042 class csReversibleTransform;
00043 class csPlane3;
00044 class csPolygon3D;
00045 class csPolygon3DStatic;
00046 class csVector3;
00047 class csVector2;
00048 class csMatrix3;
00049 class csColor;
00050 
00055 #define CS_POLY_LIGHTING 0x00000001
00056 
00060 #define CS_POLY_COLLDET 0x00000002
00061 
00065 #define CS_POLY_VISCULL 0x00000004
00066 
00067 
00068 SCF_VERSION (iPolygon3DStatic, 0, 2, 0);
00069 
00073 struct iPolygon3DStatic : public iBase
00074 {
00076   virtual csPolygon3DStatic *GetPrivateObject () = 0;
00077 
00079   virtual const char* GetName () const = 0;
00081   virtual void SetName (const char* name) = 0;
00082 
00087   virtual iThingFactoryState *GetParent () = 0;
00089   virtual iMaterialHandle *GetMaterialHandle () = 0;
00097   virtual void SetMaterial (iMaterialWrapper* mat) = 0;
00099   virtual iMaterialWrapper* GetMaterial () = 0;
00100 
00102   virtual int GetVertexCount () = 0;
00104   virtual int* GetVertexIndices () = 0;
00106   virtual const csVector3 &GetVertex (int idx) const = 0;
00108   virtual int CreateVertex (int idx) = 0;
00110   virtual int CreateVertex (const csVector3 &iVertex) = 0;
00111 
00113   virtual int GetAlpha () = 0;
00120   virtual void SetAlpha (int iAlpha) = 0;
00121 
00123   virtual void CreatePlane (const csVector3 &iOrigin,
00124     const csMatrix3 &iMatrix) = 0;
00125 
00127   virtual csFlags& GetFlags () = 0;
00128 
00134   virtual iPortal* CreateNullPortal () = 0;
00136   virtual iPortal *CreatePortal (iSector *iTarget) = 0;
00140   virtual iPortal* GetPortal () = 0;
00141 
00146   virtual void SetTextureSpace (
00147         const csVector3& p1, const csVector2& uv1,
00148         const csVector3& p2, const csVector2& uv2,
00149         const csVector3& p3, const csVector2& uv3) = 0;
00150 
00166   virtual void SetTextureSpace (const csVector3& v_orig,
00167     const csVector3& v1, float l1) = 0;
00168 
00173   virtual void SetTextureSpace (
00174     const csVector3& v_orig,
00175     const csVector3& v1, float len1,
00176     const csVector3& v2, float len2) = 0;
00177 
00182   virtual void SetTextureSpace (const csMatrix3&, const csVector3&) = 0;
00183 
00187   virtual void GetTextureSpace (csMatrix3&, csVector3&) = 0;
00188 
00193   virtual void EnableTextureMapping (bool enable) = 0;
00197   virtual bool IsTextureMappingEnabled () const = 0;
00203   virtual void CopyTextureType (iPolygon3DStatic* other_polygon) = 0;
00204 
00206   virtual const csPlane3& GetObjectPlane () = 0;
00207 
00211   virtual bool IsTransparent () = 0;
00212 
00214   virtual void SetMixMode (uint m) = 0;
00216   virtual uint GetMixMode () = 0;
00217 
00222   virtual bool IntersectSegment (const csVector3& start, const csVector3& end,
00223                           csVector3& isect, float* pr = 0) = 0;
00224 
00232   virtual bool IntersectRay (const csVector3& start, const csVector3& end) = 0;
00233 
00241   virtual bool IntersectRayNoBackFace (const csVector3& start,
00242     const csVector3& end) = 0;
00243 
00251   virtual bool IntersectRayPlane (const csVector3& start, const csVector3& end,
00252         csVector3& isect) = 0;
00253 
00258   virtual bool PointOnPolygon (const csVector3& v) = 0;
00259 };
00260 
00261 SCF_VERSION (iPolygon3D, 0, 3, 1);
00262 
00266 struct iPolygon3D : public iBase
00267 {
00269   virtual csPolygon3D *GetPrivateObject () = 0;
00270 
00275   virtual iThingState *GetParent () = 0;
00277   virtual iLightMap *GetLightMap () = 0;
00279   virtual iPolygonTexture *GetTexture () = 0;
00280 
00284   virtual iPolygon3DStatic* GetStaticData () const = 0;
00285 
00287   virtual const csVector3 &GetVertexW (int idx) const = 0;
00289   virtual const csVector3 &GetVertexC (int idx) const = 0;
00290 
00292   virtual const csPlane3& GetWorldPlane () = 0;
00294   virtual void ComputeCameraPlane (const csReversibleTransform& t,
00295         csPlane3& pl) = 0;
00296 
00302   virtual void SetMaterial (iMaterialWrapper* mat) = 0;
00304   virtual iMaterialWrapper* GetMaterial () = 0;
00305 };
00306 
00311 struct csPolyTextureMapping
00312 {
00314   csMatrix3 m_obj2tex;
00316   csVector3 v_obj2tex;
00317 
00318   // @@@ some entries really rather belong to csPolyLightMapMapping.
00319   float fdu, fdv;
00320 
00326   int Imin_u, Imin_v;
00327 
00329   float Fmin_u, Fmin_v, Fmax_u, Fmax_v;
00330 
00332   uint16 shf_u;
00333 
00339   int GetShiftU () const { return shf_u; }
00340 
00342   int GetIMinU () const { return Imin_u; }
00344   int GetIMinV () const { return Imin_v; }
00346   void GetTextureBox (float& fMinU, float& fMinV,
00347     float& fMaxU, float& fMaxV) const
00348   {
00349     fMinU = Fmin_u;
00350     fMaxU = Fmax_u;
00351     fMinV = Fmin_v;
00352     fMaxV = Fmax_v;
00353   }
00354 
00356   float GetFDU () const { return fdu; }
00358   float GetFDV () const { return fdv; }
00359 };
00360 
00365 struct csPolyLightMapMapping
00366 {
00367   /*
00368    * New texture data with lighting added. This is an untiled texture
00369    * so it is more efficient to draw. This texture data is allocated
00370    * and maintained by the texture cache. If a PolyTexture is in the
00371    * cache it will be allocated, otherwise it won't.
00372    */
00373 
00375   int w; //@@@ renderer specific
00376 
00378   int h; //@@@ renderer specific 
00379 
00381   int w_orig;  //@@@ renderer specific
00382   
00384   //int lightCellSize;
00386   //int lightCellShift;
00387 
00389   int GetWidth () const { return w; }
00391   int GetHeight () const { return h; }
00392 
00394   int GetOriginalWidth () const { return w_orig; }
00395 };
00396 
00397 SCF_VERSION (iPolygonTexture, 1, 3, 0);
00398 
00403 struct iPolygonTexture : public iBase
00404 {
00406   virtual iMaterialHandle *GetMaterialHandle () = 0;
00408   virtual csPolyTextureMapping* GetTMapping () const = 0;
00410   virtual csPolyLightMapMapping* GetLMapping () const = 0;
00411 
00413   virtual iLightMap *GetLightMap () = 0;
00415   virtual int GetLightCellSize () = 0;
00417   virtual int GetLightCellShift () = 0;
00418 
00420   virtual void *GetCacheData (int idx) = 0;
00422   virtual void SetCacheData (int idx, void *d) = 0;
00423 };
00424 
00425 #endif // __CS_THING_POLYGON_H__
00426 

Generated for Crystal Space by doxygen 1.2.14