CEL: Crystal Entity Layer: celtool/camera.h Source File (CEL: Crystal Entity Layer Public API Reference)

| ## Public API Reference

- Main Page
- Classes
- Files

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