CrystalSpace

Public API Reference

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

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 
00213 #ifndef CS_USE_NEW_RENDERER
00214 
00219   virtual csFogInfo* GetFirstFogInfo () { return ctxt->fog_info; }
00223   virtual void SetFirstFogInfo (csFogInfo* fi)
00224   {
00225     ctxt->fog_info = fi;
00226     ctxt->added_fog_info = true;
00227   }
00231   virtual bool AddedFogInfo () { return ctxt->added_fog_info; }
00235   virtual void ResetFogInfo () { ctxt->added_fog_info = false; }
00236 
00237 #endif // CS_USE_NEW_RENDERER
00238 
00241   virtual iCamera* GetCamera () { return ctxt->icamera; }
00245 #ifndef CS_USE_NEW_RENDERER
00246   virtual void CalculateFogPolygon (G3DPolygonDP& poly);
00250   virtual void CalculateFogPolygon (G3DPolygonDPFX& poly);
00257   virtual void CalculateFogMesh (const csTransform& tr_o2c,
00258     G3DTriangleMesh& mesh);
00259 
00267   virtual void CalculateFogMesh (const csTransform &tr_o2c, 
00268     G3DPolygonMesh &mesh);
00269 #endif // CS_USE_NEW_RENDERER
00270 
00271 
00272 
00278   virtual bool TestBSphere (const csReversibleTransform& o2c,
00279     const csSphere& sphere);
00288   virtual bool ClipBSphere (const csReversibleTransform& o2c,
00289     const csSphere& sphere,
00290   int& clip_portal, int& clip_plane, int& clip_z_plane);
00298   virtual bool ClipBBox (const csBox2& sbox, const csBox3& cbox,
00299         int& clip_portal, int& clip_plane, int& clip_z_plane);
00300 
00304   virtual iSector* GetThisSector () { return ctxt->this_sector; }
00305 
00309   virtual void SetThisSector (iSector* s) { ctxt->this_sector = s; }
00310 
00314   virtual iSector* GetPreviousSector () { return ctxt->previous_sector; }
00315 
00319   virtual void SetPreviousSector (iSector* s) { ctxt->previous_sector = s; }
00320 
00322   virtual iPolygon3D* GetPortalPolygon () { return ctxt->portal_polygon; }
00324   virtual void SetPortalPolygon (iPolygon3D* por)
00325   { ctxt->portal_polygon = por; }
00326 
00330   virtual int GetRenderRecursionLevel () { return ctxt->draw_rec_level; }
00334   virtual void SetRenderRecursionLevel (int rec)
00335   {
00336     ctxt->draw_rec_level = rec;
00337   }
00338 
00342   virtual void AttachRenderContextData (void* key, iBase* data);
00346   virtual iBase* FindRenderContextData (void* key);
00351   virtual void DeleteRenderContextData (void* key);
00352 };
00353 
00354 #endif // __CS_RVIEW_H__

Generated for Crystal Space by doxygen 1.2.14