celtool/camera.h
00001 /* 00002 Crystal Space Entity Layer 00003 Copyright (C) 2005 by Jorrit Tyberghein 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 00020 #ifndef __CEL_PF_CAMFACT__ 00021 #define __CEL_PF_CAMFACT__ 00022 00023 #include "celtool/celtoolextern.h" 00024 #include "cstypes.h" 00025 #include "csutil/scf.h" 00026 #include "physicallayer/propclas.h" 00027 #include "physicallayer/propfact.h" 00028 #include "physicallayer/facttmpl.h" 00029 #include "celtool/stdpcimp.h" 00030 #include "ivaria/reporter.h" 00031 #include "propclass/camera.h" 00032 00033 struct iCelEntity; 00034 struct iObjectRegistry; 00035 struct iGraphics3D; 00036 struct iEngine; 00037 struct iVirtualClock; 00038 struct iCamera; 00039 struct iView; 00040 struct iPcRegion; 00041 struct iPcZoneManager; 00042 class csView; 00043 00047 struct CEL_CELTOOL_EXPORT celPcCameraCommon : public celPcCommon 00048 { 00049 protected: 00050 csRef<iGraphics3D> g3d; 00051 csRef<iEngine> engine; 00052 csRef<iVirtualClock> vc; 00053 csRef<iView> view; 00054 bool rect_set; 00055 int rect_x, rect_y, rect_w, rect_h; 00056 bool center_set; 00057 float center_x, center_y; 00058 00059 // Fields for the far plane. 00060 struct 00061 { 00062 #define FP_MAX_DIST 10000.0 // Maximum visibile distance. 00063 #define FP_INIT_DIST 200.0 // We start from this value. 00064 bool use_farplane; // If true then we use a farplane. 00065 float fixed_distance; // If < 0 then we use adaptive system. 00066 // All fields below are for adaptive only. 00067 float min_fps, max_fps; // Acceptable FPS interval. 00068 float min_dist; // Minimum acceptiable distance. 00069 bool fps_valid; // First frame we don't know fps yet. 00070 float smooth_fps; // To have less chaotic FPS changes. 00071 float current_distance; // Remember current distance. 00072 csTicks accumulated_elapsed;// Accumulated elapsed time. 00073 } fp; 00074 00075 csWeakRef<iPcRegion> region; 00076 csWeakRef<iPcZoneManager> zonemgr; 00077 00078 bool clear_zbuf, clear_screen; 00079 00080 public: 00081 static void Report(iObjectRegistry* reg, const char* msg, ...); 00082 00083 celPcCameraCommon (iObjectRegistry* object_reg); 00084 virtual ~celPcCameraCommon (); 00085 00086 bool SetRegion (iPcRegion* region, bool point, const char* name); 00087 bool SetZoneManager (iPcZoneManager* zonemgr, bool point, 00088 const char* regionname, const char* name); 00089 bool SetZoneManager (const char* entityname, bool point, 00090 const char* regionname, const char* name); 00091 void SetRectangle (int x, int y, int w, int h); 00092 void SetPerspectiveCenter (float x, float y); 00093 00094 iCamera* GetCamera () const; 00095 iView* GetView () const { return view; } 00096 00097 void SetClearZBuffer (bool flag) { clear_zbuf = flag; } 00098 bool GetClearZBuffer () const { return clear_zbuf; } 00099 void SetClearScreen (bool flag) { clear_screen = flag; } 00100 bool GetClearScreen () const { return clear_screen; } 00101 00102 // For distance clipping. 00103 void SetDistanceClipping (float dist); 00104 void AdaptDistanceClipping (csTicks elapsed_time); 00105 00106 void DisableDistanceClipping (); 00107 void EnableFixedDistanceClipping (float dist); 00108 void EnableAdaptiveDistanceClipping (float min_fps, 00109 float max_fps, float min_dist); 00110 bool UseDistanceClipping () const { return fp.use_farplane; } 00111 bool UseFixedDistanceClipping () const 00112 { 00113 return fp.use_farplane && fp.fixed_distance >= 0.0f; 00114 } 00115 float GetFixedDistance () const { return fp.fixed_distance; } 00116 float GetAdaptiveMinFPS () const { return fp.min_fps; } 00117 float GetAdaptiveMaxFPS () const { return fp.max_fps; } 00118 float GetAdaptiveMinDistance () const { return fp.min_dist; } 00119 00120 void SetAutoDraw (bool auto_draw); 00121 00126 void SaveCommon (iCelDataBuffer* databuf); 00131 bool LoadCommon (iCelDataBuffer* databuf); 00132 00133 virtual void Draw (); 00134 00135 virtual csPtr<iCelDataBuffer> Save (); 00136 virtual bool Load (iCelDataBuffer* databuf); 00137 virtual void TickEveryFrame (); 00138 }; 00139 00140 #endif // __CEL_PF_CAMFACT__
Generated for CEL: Crystal Entity Layer 1.4.1 by doxygen 1.7.1