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 "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 
00046 struct celPcCameraCommon : public celPcCommon
00047 {
00048 protected:
00049   csRef<iGraphics3D> g3d;
00050   csRef<iEngine> engine;
00051   csRef<iVirtualClock> vc;
00052   csRef<iView> view;
00053   bool rect_set;
00054   int rect_x, rect_y, rect_w, rect_h;
00055   bool center_set;
00056   float center_x, center_y;
00057 
00058   // Fields for the far plane.
00059   struct
00060   {
00061 #define FP_MAX_DIST 10000.0     // Maximum visibile distance.
00062 #define FP_INIT_DIST 200.0      // We start from this value.
00063     bool use_farplane;          // If true then we use a farplane.
00064     float fixed_distance;       // If < 0 then we use adaptive system.
00065     // All fields below are for adaptive only.
00066     float min_fps, max_fps;     // Acceptable FPS interval.
00067     float min_dist;             // Minimum acceptiable distance.
00068     bool fps_valid;             // First frame we don't know fps yet.
00069     float smooth_fps;           // To have less chaotic FPS changes.
00070     float current_distance;     // Remember current distance.
00071     csTicks accumulated_elapsed;// Accumulated elapsed time.
00072   } fp;
00073 
00074   csWeakRef<iPcRegion> region;
00075   csWeakRef<iPcZoneManager> zonemgr;
00076 
00077   bool clear_zbuf, clear_screen;
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   iView* GetView () const { return view; }
00095 
00096   void SetClearZBuffer (bool flag) { clear_zbuf = flag; }
00097   bool GetClearZBuffer () const { return clear_zbuf; }
00098   void SetClearScreen (bool flag) { clear_screen = flag; }
00099   bool GetClearScreen () const { return clear_screen; }
00100 
00101   // For distance clipping.
00102   void SetDistanceClipping (float dist);
00103   void AdaptDistanceClipping (csTicks elapsed_time);
00104 
00105   void DisableDistanceClipping ();
00106   void EnableFixedDistanceClipping (float dist);
00107   void EnableAdaptiveDistanceClipping (float min_fps,
00108         float max_fps, float min_dist);
00109   bool UseDistanceClipping () const { return fp.use_farplane; }
00110   bool UseFixedDistanceClipping () const
00111   {
00112     return fp.use_farplane && fp.fixed_distance >= 0.0f;
00113   }
00114   float GetFixedDistance () const { return fp.fixed_distance; }
00115   float GetAdaptiveMinFPS () const { return fp.min_fps; }
00116   float GetAdaptiveMaxFPS () const { return fp.max_fps; }
00117   float GetAdaptiveMinDistance () const { return fp.min_dist; }
00118 
00119   void SetAutoDraw (bool auto_draw);
00120 
00125   void SaveCommon (iCelDataBuffer* databuf);
00130   bool LoadCommon (iCelDataBuffer* databuf);
00131 
00132   virtual void Draw ();
00133 
00134   virtual csPtr<iCelDataBuffer> Save ();
00135   virtual bool Load (iCelDataBuffer* databuf);
00136   virtual void TickEveryFrame ();
00137 };
00138 
00139 #endif // __CEL_PF_CAMFACT__

Generated for CEL: Crystal Entity Layer 1.2 by doxygen 1.4.7