Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

portal.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_PORTAL_H__
00020 #define __CS_PORTAL_H__
00021 
00022 #include "csgeom/transfrm.h"
00023 #include "csutil/flags.h"
00024 #include "csutil/csobject.h"
00025 #include "imesh/thing/portal.h"
00026 
00027 class csPolygon2D;
00028 class csPolygon3D;
00029 class csStatLight;
00030 class csObject;
00031 class csMeshWrapper;
00032 struct iRenderView;
00033 struct iFrustumView;
00034 
00039 class csPortal : public csObject
00040 {
00041 private:
00043   iSector* sector;
00044 
00045 public:
00047   csFlags flags;
00048 
00049 protected:
00051   csReversibleTransform warp_obj;
00053   csReversibleTransform warp_wor;
00055   iPortalCallback* sector_cb;
00057   iPortalCallback* portal_cb;
00059   int max_sector_visit;
00060 
00065   iTextureHandle* filter_texture;
00066 
00070   float filter_r, filter_g, filter_b;
00071 
00072 public:
00074   csPortal ();
00075 
00077   virtual ~csPortal ();
00078 
00079   //---- misc. manipulation functions ---------------------------------------
00080 
00082   iReferencedObject* GetReferencedObject () const;
00083 
00085   void SetReferencedObject (iReferencedObject* b);
00086 
00088   iSector* GetSector () const;
00089 
00094   void SetSector (iSector* s);
00095 
00097   csFlags& GetFlags ();
00098 
00100   void SetMaximumSectorVisit (int msv)
00101   {
00102     max_sector_visit = msv;
00103   }
00104 
00106   int GetMaximumSectorVisit () const
00107   {
00108     return max_sector_visit;
00109   }
00110 
00112   void SetPortalCallback (iPortalCallback* cb);
00113 
00115   iPortalCallback* GetPortalCallback () const;
00116 
00118   void SetMissingSectorCallback (iPortalCallback* cb);
00119 
00121   iPortalCallback* GetMissingSectorCallback () const;
00122 
00124   void SetFilter (iTextureHandle* ft);
00126   iTextureHandle* GetTextureFilter () const;
00127 
00129   void SetFilter (float r, float g, float b);
00131   void GetColorFilter (float &r, float &g, float &b) const;
00132 
00133   //---- space warping ------------------------------------------------------
00134 
00136   const csReversibleTransform& GetWarp () const;
00137 
00142   void SetWarp (const csTransform& t);
00143 
00144   /*
00145    * Set the warping transformation for this portal in object space and world
00146    * space.
00147    */
00148   void SetWarp (const csMatrix3 &m_w, const csVector3 &v_w_before,
00149     const csVector3 &v_w_after);
00150 
00152   void SetMirror (iPolygon3D *iPoly);
00153 
00155   void ObjectToWorld (const csReversibleTransform& t);
00156 
00158   void HardTransform (const csReversibleTransform& t);
00159 
00161   csVector3 Warp (const csVector3& pos) const;
00162 
00173   void WarpSpace (csReversibleTransform& t, bool& mirror) const;
00174 
00175   //-------------------------------------------------------------------------
00176 
00195   bool Draw (csPolygon2D* new_clipper, csPolygon3D* portal_polygon,
00196         iRenderView* rview);
00197 
00205   csPolygon3D* HitBeam (const csVector3& start, const csVector3& end,
00206         csVector3& isect);
00207 
00215   csMeshWrapper* HitBeam (const csVector3& start, const csVector3& end,
00216         csVector3& isect, csPolygon3D** polygonPtr);
00217 
00223   bool CompleteSector (iBase* context);
00224 
00230   void CheckFrustum (iFrustumView* lview, int alpha);
00231 
00232   SCF_DECLARE_IBASE_EXT (csObject);
00233 
00234   //------------------- iPortal implementation -----------------------
00235   struct Portal : public iPortal
00236   {
00237     SCF_DECLARE_EMBEDDED_IBASE (csPortal);
00238     virtual iReferencedObject* GetReferencedObject () const
00239     { return scfParent->GetReferencedObject (); }
00240     virtual void SetReferencedObject (iReferencedObject* b)
00241     { scfParent->SetReferencedObject (b); }
00242     virtual iObject *QueryObject () { return scfParent; }
00243     virtual iSector* GetSector () const { return scfParent->GetSector (); }
00244     virtual void SetSector (iSector* s) { scfParent->SetSector (s); }
00245     virtual csFlags& GetFlags () { return scfParent->GetFlags (); }
00246     virtual void SetMaximumSectorVisit (int msv)
00247     {
00248       scfParent->SetMaximumSectorVisit (msv);
00249     }
00250     virtual int GetMaximumSectorVisit () const
00251     {
00252       return scfParent->GetMaximumSectorVisit ();
00253     }
00254     virtual void SetPortalCallback (iPortalCallback* cb)
00255     {
00256       scfParent->SetPortalCallback (cb);
00257     }
00258     virtual iPortalCallback* GetPortalCallback () const
00259     {
00260       return scfParent->GetPortalCallback ();
00261     }
00262     virtual void SetMissingSectorCallback (iPortalCallback* cb)
00263     {
00264       scfParent->SetMissingSectorCallback (cb);
00265     }
00266     virtual iPortalCallback* GetMissingSectorCallback () const
00267     {
00268       return scfParent->GetMissingSectorCallback ();
00269     }
00270     virtual void SetFilter (iTextureHandle* ft)
00271     {
00272       scfParent->SetFilter (ft);
00273     }
00274     virtual iTextureHandle* GetTextureFilter () const
00275     {
00276       return scfParent->GetTextureFilter ();
00277     }
00278     virtual void SetFilter (float r, float g, float b)
00279     {
00280       scfParent->SetFilter (r, g, b);
00281     }
00282     virtual void GetColorFilter (float &r, float &g, float &b) const
00283     {
00284       scfParent->GetColorFilter (r, g, b);
00285     }
00286     virtual void SetWarp (const csMatrix3 &m_w, const csVector3 &v_w_before,
00287       const csVector3 &v_w_after)
00288     {
00289       scfParent->SetWarp (m_w, v_w_before, v_w_after);
00290     }
00291     virtual void SetWarp (const csTransform& t)
00292     {
00293       scfParent->SetWarp (t);
00294     }
00295     virtual void SetMirror (iPolygon3D *iPoly)
00296     {
00297       scfParent->SetMirror (iPoly);
00298     }
00299     virtual const csReversibleTransform &GetWarp () const
00300     {
00301       return scfParent->GetWarp ();
00302     }
00303     virtual void ObjectToWorld (const csReversibleTransform& t)
00304     {
00305       scfParent->ObjectToWorld (t);
00306     }
00307     virtual void HardTransform (const csReversibleTransform& t)
00308     {
00309       scfParent->HardTransform (t);
00310     }
00311     virtual csVector3 Warp (const csVector3& pos) const
00312     {
00313       return scfParent->Warp (pos);
00314     }
00315     virtual void WarpSpace (csReversibleTransform& t, bool& mirror) const
00316     {
00317       scfParent->WarpSpace (t, mirror);
00318     }
00319     virtual bool CompleteSector (iBase* context)
00320     {
00321       return scfParent->CompleteSector (context);
00322     }
00323     virtual void CheckFrustum (iFrustumView* lview, int alpha)
00324     {
00325       scfParent->CheckFrustum (lview, alpha);
00326     }
00327   } scfiPortal;
00328 };
00329 
00330 #endif // __CS_PORTAL_H__

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000