|
rview.h00001 /* 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 "csutil/csvector.h" 00026 #include "iengine/rview.h" 00027 #include "iengine/engine.h" 00028 00029 class csMatrix3; 00030 class csVector3; 00031 class csRenderView; 00032 struct csFog; 00033 struct iGraphics3D; 00034 struct iGraphics2D; 00035 struct iPolygon3D; 00036 struct iSector; 00037 struct iClipper2D; 00038 00044 class csRenderView : public iRenderView 00045 { 00046 private: 00053 struct csRenderContextData 00054 { 00056 csRenderContextData* next; 00057 00059 void* key; 00064 iBase* data; 00065 }; 00066 00068 csRenderContext* ctxt; 00069 00071 iEngine* iengine; 00073 iGraphics3D* g3d; 00075 iGraphics2D* g2d; 00079 iCamera* original_camera; 00080 00082 float leftx, rightx, topy, boty; 00084 csRenderContextFrustum* top_frustum; 00085 00090 iDrawFuncCallback* callback; 00091 00095 void DeleteRenderContextData (csRenderContext* rc); 00096 00100 void UpdateFrustum (iClipper2D* clip, csRenderContextFrustum* 00101 frust); 00102 00107 static void TestSphereFrustum (csRenderContextFrustum* frust, 00108 const csVector3& center, float radius, bool& inside, bool& outside); 00109 00110 public: 00112 csRenderView (); 00114 csRenderView (iCamera* c); 00116 csRenderView (iCamera* c, iClipper2D* v, iGraphics3D* ig3d, 00117 iGraphics2D* ig2d); 00118 00119 virtual ~csRenderView (); 00120 00122 void SetEngine (iEngine* engine); 00124 void SetCamera (iCamera* camera); 00126 void SetOriginalCamera (iCamera* camera); 00128 virtual iCamera* GetOriginalCamera () const { return original_camera; } 00129 00131 virtual void SetCallback (iDrawFuncCallback* cb) 00132 { 00133 if (cb) cb->IncRef (); 00134 if (callback) callback->DecRef (); 00135 callback = cb; 00136 } 00138 virtual iDrawFuncCallback* GetCallback () 00139 { 00140 return callback; 00141 } 00142 00144 virtual void CallCallback (int type, void* data) 00145 { 00146 callback->DrawFunc (this, type, data); 00147 } 00148 00149 SCF_DECLARE_IBASE; 00150 00152 virtual csRenderContext* GetRenderContext () { return ctxt; } 00153 00161 virtual void CreateRenderContext (); 00162 00168 virtual void RestoreRenderContext (csRenderContext* original); 00169 00175 virtual iCamera* CreateNewCamera (); 00176 00178 virtual iEngine* GetEngine () { return iengine; } 00180 virtual iGraphics2D* GetGraphics2D () { return g2d; } 00182 virtual iGraphics3D* GetGraphics3D () { return g3d; } 00184 virtual void SetFrustum (float lx, float rx, float ty, float by); 00186 virtual void GetFrustum (float& lx, float& rx, float& ty, float& by) 00187 { 00188 lx = leftx; 00189 rx = rightx; 00190 ty = topy; 00191 by = boty; 00192 } 00194 virtual csRenderContextFrustum* GetTopFrustum () 00195 { 00196 return top_frustum; 00197 } 00198 00199 //----------------------------------------------------------------- 00200 // The following functions operate on the current render context. 00201 //----------------------------------------------------------------- 00202 00204 virtual iClipper2D* GetClipper () { return ctxt->iview; } 00206 virtual void SetClipper (iClipper2D* clip); 00207 00214 virtual bool IsClipperRequired () { return ctxt->do_clip_frustum; } 00221 virtual bool GetClipPlane (csPlane3& pl) 00222 { 00223 pl = ctxt->clip_plane; 00224 return ctxt->do_clip_plane; 00225 } 00227 virtual csPlane3& GetClipPlane () 00228 { 00229 return ctxt->clip_plane; 00230 } 00232 virtual void SetClipPlane (const csPlane3& p) { ctxt->clip_plane = p; } 00234 virtual void UseClipPlane (bool u) { ctxt->do_clip_plane = u; } 00236 virtual void UseClipFrustum (bool u) { ctxt->do_clip_frustum = u; } 00237 00238 00244 virtual csFogInfo* GetFirstFogInfo () { return ctxt->fog_info; } 00248 virtual void SetFirstFogInfo (csFogInfo* fi) 00249 { 00250 ctxt->fog_info = fi; 00251 ctxt->added_fog_info = true; 00252 } 00256 virtual bool AddedFogInfo () { return ctxt->added_fog_info; } 00260 virtual void ResetFogInfo () { ctxt->added_fog_info = false; } 00261 00265 virtual iCamera* GetCamera () { return ctxt->icamera; } 00269 virtual void CalculateFogPolygon (G3DPolygonDP& poly); 00273 virtual void CalculateFogPolygon (G3DPolygonDPFX& poly); 00280 virtual void CalculateFogMesh (const csTransform& tr_o2c, 00281 G3DTriangleMesh& mesh); 00282 00290 virtual void CalculateFogMesh (const csTransform &tr_o2c, 00291 G3DPolygonMesh &mesh); 00292 00293 00294 00300 virtual bool TestBSphere (const csReversibleTransform& o2c, 00301 const csSphere& sphere); 00310 virtual bool ClipBSphere (const csReversibleTransform& o2c, 00311 const csSphere& sphere, 00312 int& clip_portal, int& clip_plane, int& clip_z_plane); 00320 virtual bool ClipBBox (const csBox2& sbox, const csBox3& cbox, 00321 int& clip_portal, int& clip_plane, int& clip_z_plane); 00322 00326 virtual iSector* GetThisSector () { return ctxt->this_sector; } 00327 00331 virtual void SetThisSector (iSector* s) { ctxt->this_sector = s; } 00332 00336 virtual iSector* GetPreviousSector () { return ctxt->previous_sector; } 00337 00341 virtual void SetPreviousSector (iSector* s) { ctxt->previous_sector = s; } 00342 00344 virtual iPolygon3D* GetPortalPolygon () { return ctxt->portal_polygon; } 00346 virtual void SetPortalPolygon (iPolygon3D* por) 00347 { ctxt->portal_polygon = por; } 00348 00352 virtual int GetRenderRecursionLevel () { return ctxt->draw_rec_level; } 00356 virtual void SetRenderRecursionLevel (int rec) 00357 { 00358 ctxt->draw_rec_level = rec; 00359 } 00360 00364 virtual void AttachRenderContextData (void* key, iBase* data); 00368 virtual iBase* FindRenderContextData (void* key); 00373 virtual void DeleteRenderContextData (void* key); 00374 }; 00375 00376 #endif // __CS_RVIEW_H__ Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000 |