Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members
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 "cstypes.h" 00024 #include "csutil/scf.h" 00025 #include "physicallayer/propclas.h" 00026 #include "physicallayer/propfact.h" 00027 #include "physicallayer/facttmpl.h" 00028 #include "celtool/stdpcimp.h" 00029 #include "ivaria/reporter.h" 00030 #include "propclass/camera.h" 00031 00032 struct iCelEntity; 00033 struct iObjectRegistry; 00034 struct iGraphics3D; 00035 struct iEngine; 00036 struct iVirtualClock; 00037 struct iCamera; 00038 struct iView; 00039 struct iPcRegion; 00040 struct iPcZoneManager; 00041 class csView; 00042 00043 //--------------------------------------------------------------------------- 00044 00045 static void Report (iObjectRegistry* object_reg, const char* msg, ...) 00046 { 00047 va_list arg; 00048 va_start (arg, msg); 00049 00050 csRef<iReporter> rep (CS_QUERY_REGISTRY (object_reg, iReporter)); 00051 if (rep) 00052 rep->ReportV (CS_REPORTER_SEVERITY_ERROR, "cel.persistence", 00053 msg, arg); 00054 else 00055 { 00056 csPrintfV (msg, arg); 00057 csPrintf ("\n"); 00058 fflush (stdout); 00059 } 00060 00061 va_end (arg); 00062 } 00063 00064 //--------------------------------------------------------------------------- 00065 00069 struct celPcCameraCommon: public celPcCommon 00070 { 00071 protected: 00072 csRef<iGraphics3D> g3d; 00073 csRef<iEngine> engine; 00074 csRef<iVirtualClock> vc; 00075 csRef<iView> view; 00076 bool rect_set; 00077 int rect_x, rect_y, rect_w, rect_h; 00078 00079 // Fields for the far plane. 00080 struct 00081 { 00082 #define FP_MAX_DIST 10000.0 // Maximum visibile distance. 00083 #define FP_INIT_DIST 200.0 // We start from this value. 00084 bool use_farplane; // If true then we use a farplane. 00085 float fixed_distance; // If < 0 then we use adaptive system. 00086 // All fields below are for adaptive only. 00087 float min_fps, max_fps; // Acceptable FPS interval. 00088 float min_dist; // Minimum acceptiable distance. 00089 bool fps_valid; // First frame we don't know fps yet. 00090 float smooth_fps; // To have less chaotic FPS changes. 00091 float current_distance; // Remember current distance. 00092 csTicks accumulated_elapsed;// Accumulated elapsed time. 00093 } fp; 00094 00095 csWeakRef<iPcRegion> region; 00096 csWeakRef<iPcZoneManager> zonemgr; 00097 00098 bool clear_zbuf, clear_screen; 00099 00100 public: 00101 celPcCameraCommon (iObjectRegistry* object_reg); 00102 virtual ~celPcCameraCommon (); 00103 00104 bool SetRegion (iPcRegion* region, bool point, const char* name); 00105 bool SetZoneManager (iPcZoneManager* zonemgr, bool point, 00106 const char* regionname, const char* name); 00107 bool SetZoneManager (const char* entityname, bool point, 00108 const char* regionname, const char* name); 00109 void SetRectangle (int x, int y, int w, int h); 00110 00111 iCamera* GetCamera () const; 00112 iView* GetView () const { return view; } 00113 00114 void SetClearZBuffer (bool flag) { clear_zbuf = flag; } 00115 bool GetClearZBuffer () const { return clear_zbuf; } 00116 void SetClearScreen (bool flag) { clear_screen = flag; } 00117 bool GetClearScreen () const { return clear_screen; } 00118 00119 // For distance clipping. 00120 void SetDistanceClipping (float dist); 00121 void AdaptDistanceClipping (csTicks elapsed_time); 00122 00123 void DisableDistanceClipping (); 00124 void EnableFixedDistanceClipping (float dist); 00125 void EnableAdaptiveDistanceClipping (float min_fps, 00126 float max_fps, float min_dist); 00127 bool UseDistanceClipping () const { return fp.use_farplane; } 00128 bool UseFixedDistanceClipping () const 00129 { 00130 return fp.use_farplane && fp.fixed_distance >= 0.0f; 00131 } 00132 float GetFixedDistance () const { return fp.fixed_distance; } 00133 float GetAdaptiveMinFPS () const { return fp.min_fps; } 00134 float GetAdaptiveMaxFPS () const { return fp.max_fps; } 00135 float GetAdaptiveMinDistance () const { return fp.min_dist; } 00136 00137 void SetAutoDraw (bool auto_draw); 00138 00143 void SaveCommon (iCelDataBuffer* databuf); 00148 bool LoadCommon (iCelDataBuffer* databuf); 00149 00150 virtual void Draw (); 00151 00152 virtual const char* GetName () const { return "pccamera"; } 00153 virtual csPtr<iCelDataBuffer> Save (); 00154 virtual bool Load (iCelDataBuffer* databuf); 00155 virtual void TickEveryFrame (); 00156 }; 00157 00158 #endif // __CEL_PF_CAMFACT__ 00159
Generated for CEL: Crystal Entity Layer by doxygen 1.4.4