CEL

Public API Reference

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 iPerspectiveCamera;
00040 struct iView;
00041 struct iPcRegion;
00042 struct iPcZoneManager;
00043 class csView;
00044 
00048 struct CEL_CELTOOL_EXPORT celPcCameraCommon : public celPcCommon
00049 {
00050 protected:
00051   csRef<iGraphics3D> g3d;
00052   csRef<iEngine> engine;
00053   csRef<iVirtualClock> vc;
00054   csRef<iView> view;
00055   bool rect_set;
00056   int rect_x, rect_y, rect_w, rect_h;
00057   bool center_set;
00058   float center_x, center_y;
00059 
00060   // Fields for the far plane.
00061   struct
00062   {
00063 #define FP_MAX_DIST 10000.0     // Maximum visibile distance.
00064 #define FP_INIT_DIST 200.0      // We start from this value.
00065     bool use_farplane;          // If true then we use a farplane.
00066     float fixed_distance;       // If < 0 then we use adaptive system.
00067     // All fields below are for adaptive only.
00068     float min_fps, max_fps;     // Acceptable FPS interval.
00069     float min_dist;             // Minimum acceptiable distance.
00070     bool fps_valid;             // First frame we don't know fps yet.
00071     float smooth_fps;           // To have less chaotic FPS changes.
00072     float current_distance;     // Remember current distance.
00073     csTicks accumulated_elapsed;// Accumulated elapsed time.
00074   } fp;
00075 
00076   csWeakRef<iPcRegion> region;
00077   csWeakRef<iPcZoneManager> zonemgr;
00078 
00079 public:
00080   static void Report(iObjectRegistry* reg, const char* msg, ...);
00081 
00082   celPcCameraCommon (iObjectRegistry* object_reg);
00083   virtual ~celPcCameraCommon ();
00084 
00085   bool SetRegion (iPcRegion* region, bool point, const char* name);
00086   bool SetZoneManager (iPcZoneManager* zonemgr, bool point,
00087         const char* regionname, const char* name);
00088   bool SetZoneManager (const char* entityname, bool point,
00089         const char* regionname, const char* name);
00090   void SetRectangle (int x, int y, int w, int h);
00091   void SetPerspectiveCenter (float x, float y);
00092 
00093   iCamera* GetCamera () const;
00094   iPerspectiveCamera* GetPerspectiveCamera () const;
00095   iView* GetView () const { return view; }
00096 
00097   // For distance clipping.
00098   void SetDistanceClipping (float dist);
00099   void AdaptDistanceClipping (csTicks elapsed_time);
00100 
00101   void DisableDistanceClipping ();
00102   void EnableFixedDistanceClipping (float dist);
00103   void EnableAdaptiveDistanceClipping (float min_fps,
00104         float max_fps, float min_dist);
00105   bool UseDistanceClipping () const { return fp.use_farplane; }
00106   bool UseFixedDistanceClipping () const
00107   {
00108     return fp.use_farplane && fp.fixed_distance >= 0.0f;
00109   }
00110   float GetFixedDistance () const { return fp.fixed_distance; }
00111   float GetAdaptiveMinFPS () const { return fp.min_fps; }
00112   float GetAdaptiveMaxFPS () const { return fp.max_fps; }
00113   float GetAdaptiveMinDistance () const { return fp.min_dist; }
00114 
00115   void SetAutoDraw (bool auto_draw);
00116 
00121   void SaveCommon (iCelDataBuffer* databuf);
00126   bool LoadCommon (iCelDataBuffer* databuf);
00127 
00128   virtual void Draw ();
00129 
00130   virtual csPtr<iCelDataBuffer> Save ();
00131   virtual bool Load (iCelDataBuffer* databuf);
00132   virtual void TickEveryFrame ();
00133 };
00134 
00135 #endif // __CEL_PF_CAMFACT__

Generated for CEL: Crystal Entity Layer 2.0 by doxygen 1.7.6.1