CrystalSpace

Public API Reference

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

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 
00041 class csReversibleTransform;
00042 class csPlane3;
00043 class csPolygon3D;
00044 class csPolygon3DStatic;
00045 class csVector3;
00046 class csVector2;
00047 class csMatrix3;
00048 class csColor;
00049 
00054 #define CS_POLY_LIGHTING 0x00000001
00055 
00059 #define CS_POLY_COLLDET 0x00000002
00060 
00064 #define CS_POLY_VISCULL 0x00000004
00065 
00066 
00067 SCF_VERSION (iPolygon3DStatic, 0, 2, 0);
00068 
00072 struct iPolygon3DStatic : public iBase
00073 {
00075   virtual csPolygon3DStatic *GetPrivateObject () = 0;
00076 
00078   virtual const char* GetName () const = 0;
00080   virtual void SetName (const char* name) = 0;
00081 
00086   virtual iThingFactoryState *GetParent () = 0;
00088   virtual iMaterialHandle *GetMaterialHandle () = 0;
00096   virtual void SetMaterial (iMaterialWrapper* mat) = 0;
00098   virtual iMaterialWrapper* GetMaterial () = 0;
00099 
00101   virtual int GetVertexCount () = 0;
00103   virtual int* GetVertexIndices () = 0;
00105   virtual const csVector3 &GetVertex (int idx) const = 0;
00107   virtual int CreateVertex (int idx) = 0;
00109   virtual int CreateVertex (const csVector3 &iVertex) = 0;
00110 
00112   virtual int GetAlpha () = 0;
00119   virtual void SetAlpha (int iAlpha) = 0;
00120 
00122   virtual void CreatePlane (const csVector3 &iOrigin,
00123     const csMatrix3 &iMatrix) = 0;
00124 
00126   virtual csFlags& GetFlags () = 0;
00127 
00133   virtual iPortal* CreateNullPortal () = 0;
00135   virtual iPortal *CreatePortal (iSector *iTarget) = 0;
00139   virtual iPortal* GetPortal () = 0;
00140 
00145   virtual void SetTextureSpace (
00146         const csVector3& p1, const csVector2& uv1,
00147         const csVector3& p2, const csVector2& uv2,
00148         const csVector3& p3, const csVector2& uv3) = 0;
00149 
00165   virtual void SetTextureSpace (const csVector3& v_orig,
00166     const csVector3& v1, float l1) = 0;
00167 
00172   virtual void SetTextureSpace (
00173     const csVector3& v_orig,
00174     const csVector3& v1, float len1,
00175     const csVector3& v2, float len2) = 0;
00176 
00181   virtual void SetTextureSpace (const csMatrix3&, const csVector3&) = 0;
00182 
00186   virtual void GetTextureSpace (csMatrix3&, csVector3&) = 0;
00187 
00192   virtual void EnableTextureMapping (bool enable) = 0;
00196   virtual bool IsTextureMappingEnabled () const = 0;
00202   virtual void CopyTextureType (iPolygon3DStatic* other_polygon) = 0;
00203 
00205   virtual const csPlane3& GetObjectPlane () = 0;
00206 
00210   virtual bool IsTransparent () = 0;
00211 
00213   virtual void SetMixMode (uint m) = 0;
00215   virtual uint GetMixMode () = 0;
00216 
00221   virtual bool IntersectSegment (const csVector3& start, const csVector3& end,
00222                           csVector3& isect, float* pr = NULL) = 0;
00223 
00231   virtual bool IntersectRay (const csVector3& start, const csVector3& end) = 0;
00232 
00240   virtual bool IntersectRayNoBackFace (const csVector3& start,
00241     const csVector3& end) = 0;
00242 
00250   virtual bool IntersectRayPlane (const csVector3& start, const csVector3& end,
00251         csVector3& isect) = 0;
00252 
00257   virtual bool PointOnPolygon (const csVector3& v) = 0;
00258 };
00259 
00260 SCF_VERSION (iPolygon3D, 0, 3, 1);
00261 
00265 struct iPolygon3D : public iBase
00266 {
00268   virtual csPolygon3D *GetPrivateObject () = 0;
00269 
00274   virtual iThingState *GetParent () = 0;
00276   virtual iLightMap *GetLightMap () = 0;
00278   virtual iPolygonTexture *GetTexture () = 0;
00279 
00283   virtual iPolygon3DStatic* GetStaticData () const = 0;
00284 
00286   virtual const csVector3 &GetVertexW (int idx) const = 0;
00288   virtual const csVector3 &GetVertexC (int idx) const = 0;
00289 
00291   virtual const csPlane3& GetWorldPlane () = 0;
00293   virtual void ComputeCameraPlane (const csReversibleTransform& t,
00294         csPlane3& pl) = 0;
00295 
00301   virtual void SetMaterial (iMaterialWrapper* mat) = 0;
00303   virtual iMaterialWrapper* GetMaterial () = 0;
00304 };
00305 
00310 struct csLightMapMapping
00311 {
00313   csMatrix3 m_obj2tex;
00315   csVector3 v_obj2tex;
00316 
00317   float fdu, fdv;
00318 
00324   int Imin_u, Imin_v;
00325 
00327   float Fmin_u, Fmin_v, Fmax_u, Fmax_v;
00328 
00330   uint16 shf_u;
00331 
00332   /*
00333    * New texture data with lighting added. This is an untiled texture
00334    * so it is more efficient to draw. This texture data is allocated
00335    * and maintained by the texture cache. If a PolyTexture is in the
00336    * cache it will be allocated, otherwise it won't.
00337    */
00338 
00340   int w;
00341 
00343   int h;
00344 
00346   int w_orig;
00347 
00349   float GetFDU () const { return fdu; }
00351   float GetFDV () const { return fdv; }
00353   int GetWidth () const { return w; }
00355   int GetHeight () const { return h; }
00361   int GetShiftU () const { return shf_u; }
00362 
00364   int GetIMinU () const { return Imin_u; }
00366   int GetIMinV () const { return Imin_v; }
00368   void GetTextureBox (float& fMinU, float& fMinV,
00369     float& fMaxU, float& fMaxV) const
00370   {
00371     fMinU = Fmin_u;
00372     fMaxU = Fmax_u;
00373     fMinV = Fmin_v;
00374     fMaxV = Fmax_v;
00375   }
00376 
00378   int GetOriginalWidth () const { return w_orig; }
00379 };
00380 
00381 SCF_VERSION (iPolygonTexture, 1, 1, 0);
00382 
00387 struct iPolygonTexture : public iBase
00388 {
00390   virtual iMaterialHandle *GetMaterialHandle () = 0;
00392   virtual const csLightMapMapping& GetMapping () const = 0;
00393 
00395   virtual bool DynamicLightsDirty () = 0;
00402   virtual bool RecalculateDynamicLights () = 0;
00403 
00405   virtual iLightMap *GetLightMap () = 0;
00407   virtual int GetLightCellSize () = 0;
00409   virtual int GetLightCellShift () = 0;
00410 
00412   virtual void *GetCacheData (int idx) = 0;
00414   virtual void SetCacheData (int idx, void *d) = 0;
00415 };
00416 
00417 #endif // __CS_THING_POLYGON_H__
00418 

Generated for Crystal Space by doxygen 1.2.14