CrystalSpace

Public API Reference

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

rview.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_RVIEW_H__
00020 #define __CS_RVIEW_H__
00021 
00022 #include "csgeom/math3d.h"
00023 #include "csgeom/frustum.h"
00024 #include "csengine/camera.h"
00025 #include "iengine/rview.h"
00026 #include "iengine/engine.h"
00027 
00028 class csMatrix3;
00029 class csVector3;
00030 class csRenderView;
00031 struct csFog;
00032 struct iGraphics3D;
00033 struct iGraphics2D;
00034 struct iPolygon3D;
00035 struct iSector;
00036 struct iClipper2D;
00037 
00043 class csRenderView : public iRenderView
00044 {
00045 private:
00052   struct csRenderContextData
00053   {
00055     csRenderContextData* next;
00056 
00058     void* key;
00063     iBase* data;
00064   };
00065 
00067   csRenderContext* ctxt;
00068 
00070   iEngine* iengine;
00072   iGraphics3D* g3d;
00074   iGraphics2D* g2d;
00078   iCamera* original_camera;
00079 
00081   float leftx, rightx, topy, boty;
00083   csRenderContextFrustum* top_frustum;
00084 
00088   void DeleteRenderContextData (csRenderContext* rc);
00089 
00093   void UpdateFrustum (iClipper2D* clip, csRenderContextFrustum*
00094     frust);
00095 
00100   static void TestSphereFrustum (csRenderContextFrustum* frust,
00101     const csVector3& center, float radius, bool& inside, bool& outside);
00102 
00103 public:
00105   csRenderView ();
00107   csRenderView (iCamera* c);
00109   csRenderView (iCamera* c, iClipper2D* v, iGraphics3D* ig3d,
00110     iGraphics2D* ig2d);
00111 
00112   virtual ~csRenderView ();
00113 
00115   void SetEngine (iEngine* engine);
00117   void SetCamera (iCamera* camera);
00119   void SetOriginalCamera (iCamera* camera);
00121   virtual iCamera* GetOriginalCamera () const { return original_camera; }
00122 
00123   SCF_DECLARE_IBASE;
00124 
00126   virtual csRenderContext* GetRenderContext () { return ctxt; }
00127 
00135   virtual void CreateRenderContext ();
00136 
00142   virtual void RestoreRenderContext (csRenderContext* original);
00143 
00149   virtual iCamera* CreateNewCamera ();
00150 
00152   virtual iEngine* GetEngine () { return iengine; }
00154   virtual iGraphics2D* GetGraphics2D () { return g2d; }
00156   virtual iGraphics3D* GetGraphics3D () { return g3d; }
00158   virtual void SetFrustum (float lx, float rx, float ty, float by);
00160   virtual void GetFrustum (float& lx, float& rx, float& ty, float& by)
00161   {
00162     lx = leftx;
00163     rx = rightx;
00164     ty = topy;
00165     by = boty;
00166   }
00168   virtual csRenderContextFrustum* GetTopFrustum ()
00169   {
00170     return top_frustum;
00171   }
00172 
00173   //-----------------------------------------------------------------
00174   // The following functions operate on the current render context.
00175   //-----------------------------------------------------------------
00176 
00178   virtual iClipper2D* GetClipper () { return ctxt->iview; }
00180   virtual void SetClipper (iClipper2D* clip);
00181 
00188   virtual bool IsClipperRequired () { return ctxt->do_clip_frustum; }
00195   virtual bool GetClipPlane (csPlane3& pl)
00196   {
00197     pl = ctxt->clip_plane;
00198     return ctxt->do_clip_plane;
00199   }
00201   virtual csPlane3& GetClipPlane ()
00202   {
00203     return ctxt->clip_plane;
00204   }
00206   virtual void SetClipPlane (const csPlane3& p) { ctxt->clip_plane = p; }
00208   virtual void UseClipPlane (bool u) { ctxt->do_clip_plane = u; }
00210   virtual void UseClipFrustum (bool u) { ctxt->do_clip_frustum = u; }
00211 
00212 
00218   virtual csFogInfo* GetFirstFogInfo () { return ctxt->fog_info; }
00222   virtual void SetFirstFogInfo (csFogInfo* fi)
00223   {
00224     ctxt->fog_info = fi;
00225     ctxt->added_fog_info = true;
00226   }
00230   virtual bool AddedFogInfo () { return ctxt->added_fog_info; }
00234   virtual void ResetFogInfo () { ctxt->added_fog_info = false; }
00235 
00239   virtual iCamera* GetCamera () { return ctxt->icamera; }
00240 
00245   virtual void CalculateFogPolygon (G3DPolygonDP& poly);
00250   virtual void CalculateFogPolygon (G3DPolygonDPFX& poly);
00258   virtual void CalculateFogMesh (const csTransform& tr_o2c,
00259     G3DTriangleMesh& mesh);
00260 
00269   virtual void CalculateFogMesh (const csTransform &tr_o2c, 
00270     G3DPolygonMesh &mesh);
00271 
00272 
00273 
00279   virtual bool TestBSphere (const csReversibleTransform& o2c,
00280     const csSphere& sphere);
00289   virtual bool ClipBSphere (const csReversibleTransform& o2c,
00290     const csSphere& sphere,
00291   int& clip_portal, int& clip_plane, int& clip_z_plane);
00299   virtual bool ClipBBox (const csBox2& sbox, const csBox3& cbox,
00300         int& clip_portal, int& clip_plane, int& clip_z_plane);
00301 
00305   virtual iSector* GetThisSector () { return ctxt->this_sector; }
00306 
00310   virtual void SetThisSector (iSector* s) { ctxt->this_sector = s; }
00311 
00315   virtual iSector* GetPreviousSector () { return ctxt->previous_sector; }
00316 
00320   virtual void SetPreviousSector (iSector* s) { ctxt->previous_sector = s; }
00321 
00323   virtual iPolygon3D* GetPortalPolygon () { return ctxt->portal_polygon; }
00325   virtual void SetPortalPolygon (iPolygon3D* por)
00326   { ctxt->portal_polygon = por; }
00327 
00331   virtual int GetRenderRecursionLevel () { return ctxt->draw_rec_level; }
00335   virtual void SetRenderRecursionLevel (int rec)
00336   {
00337     ctxt->draw_rec_level = rec;
00338   }
00339 
00343   virtual void AttachRenderContextData (void* key, iBase* data);
00347   virtual iBase* FindRenderContextData (void* key);
00352   virtual void DeleteRenderContextData (void* key);
00353 };
00354 
00355 #endif // __CS_RVIEW_H__

Generated for Crystal Space by doxygen 1.2.14