00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CS_IENGINE_RVIEW_H__
00020 #define __CS_IENGINE_RVIEW_H__
00021
00028 #include "csutil/scf.h"
00029 #include "csgeom/plane3.h"
00030 #include "csgeom/transfrm.h"
00031 #include "csgeom/box.h"
00032 #include "iengine/engine.h"
00033
00034 #ifndef CS_USE_NEW_RENDERER
00035 #include "ivideo/graph3d.h"
00036 #else
00037 #include "ivideo/render3d.h"
00038 #define iGraphics3D iRender3D
00039 #endif // CS_USE_NEW_RENDERER
00040
00041 #ifndef CS_USE_NEW_RENDERER
00042 struct csFog;
00043 #endif // CS_USE_NEW_RENDERER
00044 struct iEngine;
00045 struct iClipper2D;
00046 struct iGraphics2D;
00047 struct iGraphics3D;
00048 struct iCamera;
00049 struct iSector;
00050 struct iPolygon3D;
00051 class csRenderView;
00052 class csReversibleTransform;
00053 class csVector3;
00054 class csSphere;
00055
00063 class csFogInfo
00064 {
00065 public:
00067 csFogInfo* next;
00068
00070 csPlane3 incoming_plane;
00072 csPlane3 outgoing_plane;
00077 bool has_incoming_plane;
00078
00084 bool has_outgoing_plane;
00085
00086 #ifndef CS_USE_NEW_RENDERER
00087
00088 csFog* fog;
00089 #endif // CS_USE_NEW_RENDERER
00090 };
00091
00096 class csRenderContextFrustum
00097 {
00098 class csRenderContext;
00099 friend class csRenderContext;
00100
00101 private:
00102 int ref_count;
00103
00104 ~csRenderContextFrustum () { }
00105
00106 public:
00111 csVector3 frustum[4];
00112
00113 csRenderContextFrustum () : ref_count (1) { }
00114 void IncRef () { ref_count++; }
00115 void DecRef () { --ref_count; if (ref_count <= 0) delete this; }
00116 };
00117
00124 class csRenderContext
00125 {
00126 friend class csRenderView;
00127
00128 private:
00132 void* rcdata;
00133
00134 public:
00136 iCamera* icamera;
00138 iClipper2D* iview;
00140 csRenderContextFrustum* iview_frustum;
00141
00143 iPolygon3D* portal_polygon;
00145 iSector* previous_sector;
00147 iSector* this_sector;
00148
00153 csPlane3 clip_plane;
00154
00165 bool do_clip_plane;
00166
00175 bool do_clip_frustum;
00176
00177 #ifndef CS_USE_NEW_RENDERER
00178
00182 csFogInfo* fog_info;
00183
00188 bool added_fog_info;
00189 #endif // CS_USE_NEW_RENDERER
00190
00196 int draw_rec_level;
00197 };
00198
00199 SCF_VERSION (iRenderView, 0, 4, 0);
00200
00205 struct iRenderView : public iBase
00206 {
00208 virtual csRenderContext* GetRenderContext () = 0;
00216 virtual void CreateRenderContext () = 0;
00222 virtual void RestoreRenderContext (csRenderContext* original) = 0;
00228 virtual iCamera* CreateNewCamera () = 0;
00229
00231 virtual iEngine* GetEngine () = 0;
00233 virtual iGraphics2D* GetGraphics2D () = 0;
00235 virtual iGraphics3D* GetGraphics3D () = 0;
00237 virtual void SetFrustum (float lx, float rx, float ty, float by) = 0;
00239 virtual void GetFrustum (float& lx, float& rx, float& ty, float& by) = 0;
00241 virtual csRenderContextFrustum* GetTopFrustum () = 0;
00242
00243
00244
00245
00246
00248 virtual iClipper2D* GetClipper () = 0;
00250 virtual void SetClipper (iClipper2D* clip) = 0;
00257 virtual bool IsClipperRequired () = 0;
00264 virtual bool GetClipPlane (csPlane3& pl) = 0;
00266 virtual csPlane3& GetClipPlane () = 0;
00270 virtual void SetClipPlane (const csPlane3& pl) = 0;
00272 virtual void UseClipPlane (bool u) = 0;
00274 virtual void UseClipFrustum (bool u) = 0;
00275
00276 #ifndef CS_USE_NEW_RENDERER
00277
00282 virtual csFogInfo* GetFirstFogInfo () = 0;
00286 virtual void SetFirstFogInfo (csFogInfo* fi) = 0;
00290 virtual bool AddedFogInfo () = 0;
00294 virtual void ResetFogInfo () = 0;
00295 #endif // CS_USE_NEW_RENDERER
00296
00299 virtual iCamera* GetCamera () = 0;
00300 #ifndef CS_USE_NEW_RENDERER
00301
00304 virtual void CalculateFogPolygon (G3DPolygonDP& poly) = 0;
00308 virtual void CalculateFogPolygon (G3DPolygonDPFX& poly) = 0;
00315 virtual void CalculateFogMesh (const csTransform& tr_o2c,
00316 G3DTriangleMesh& mesh) = 0;
00317
00325 virtual void CalculateFogMesh (const csTransform &tr_o2c,
00326 G3DPolygonMesh &mesh) = 0;
00327 #endif // CS_USE_NEW_RENDERER
00328
00329
00335 virtual bool TestBSphere (const csReversibleTransform& o2c,
00336 const csSphere& sphere) = 0;
00345 virtual bool ClipBSphere (const csReversibleTransform& o2c,
00346 const csSphere& sphere,
00347 int& clip_portal, int& clip_plane, int& clip_z_plane) = 0;
00348
00356 virtual bool ClipBBox (const csBox2& sbox, const csBox3& cbox,
00357 int& clip_portal, int& clip_plane, int& clip_z_plane) = 0;
00358
00362 virtual iSector* GetThisSector () = 0;
00363
00367 virtual void SetThisSector (iSector* s) = 0;
00368
00372 virtual iSector* GetPreviousSector () = 0;
00373
00377 virtual void SetPreviousSector (iSector* s) = 0;
00378
00382 virtual iPolygon3D* GetPortalPolygon () = 0;
00383
00387 virtual void SetPortalPolygon (iPolygon3D* poly) = 0;
00388
00392 virtual int GetRenderRecursionLevel () = 0;
00396 virtual void SetRenderRecursionLevel (int rec) = 0;
00397
00401 virtual void AttachRenderContextData (void* key, iBase* data) = 0;
00405 virtual iBase* FindRenderContextData (void* key) = 0;
00410 virtual void DeleteRenderContextData (void* key) = 0;
00411
00416 virtual iCamera* GetOriginalCamera () const = 0;
00417 };
00418
00421 #endif // __CS_IENGINE_RVIEW_H__
00422