cstool/csview.h
Go to the documentation of this file.00001 /* 00002 CrystalSpace 3D renderer view 00003 Copyright (C) 1998-2001 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., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 #ifndef __CS_CSVIEW_H__ 00021 #define __CS_CSVIEW_H__ 00022 00027 #include "csextern.h" 00028 00029 #include "csutil/ref.h" 00030 #include "csutil/scf_implementation.h" 00031 #include "csutil/set.h" 00032 #include "igeom/clip2d.h" 00033 #include "iengine/mesh.h" 00034 #include "ivaria/view.h" 00035 00036 class csBox2; 00037 class csPoly2D; 00038 00043 class CS_CRYSTALSPACE_EXPORT csView : 00044 public scfImplementation1<csView, iView> 00045 { 00046 private: 00048 csRef<iEngine> Engine; 00050 csRef<iGraphics3D> G3D; 00052 int OldWidth, OldHeight; 00053 00055 csRef<iCamera> Camera; 00056 00058 csBox2* RectView; 00060 csPoly2D* PolyView; 00062 csRef<iClipper2D> Clipper; 00063 00065 void UpdateView (); 00066 00068 bool AutoResize; 00069 00070 CS::Utility::MeshFilter meshFilter; 00071 00072 // View width. 00073 int viewWidth; 00074 00075 // View height. 00076 int viewHeight; 00077 00078 public: 00080 csView (iEngine *iEngine, iGraphics3D* ig3d); 00082 virtual ~csView (); 00083 00085 virtual iEngine* GetEngine (); 00087 virtual void SetEngine (iEngine* e); 00088 00090 virtual iCamera* GetCamera (); 00092 virtual void SetCamera (iCamera* c); 00093 00094 virtual iPerspectiveCamera* GetPerspectiveCamera (); 00095 virtual void SetPerspectiveCamera (iPerspectiveCamera* c); 00096 00097 virtual iCustomMatrixCamera* GetCustomMatrixCamera (); 00098 virtual void SetCustomMatrixCamera (iCustomMatrixCamera* c); 00099 00101 virtual iGraphics3D* GetContext (); 00103 virtual void SetContext (iGraphics3D *ig3d); 00104 00106 virtual void SetRectangle (int x, int y, int w, int h, bool restrictToScreen = true); 00108 virtual void ClearView (); 00110 virtual void AddViewVertex (int x, int y); 00112 virtual void RestrictClipperToScreen (); 00113 00115 virtual void SetAutoResize (bool state) { AutoResize = state; } 00116 00118 virtual void UpdateClipper(); 00120 virtual iClipper2D* GetClipper (); 00122 virtual void Draw (iMeshWrapper* mesh = 0); 00123 00124 00125 virtual CS::Utility::MeshFilter& GetMeshFilter () 00126 { 00127 return meshFilter; 00128 } 00129 00130 // Get the view width. 00131 virtual int GetWidth () const 00132 { 00133 return viewWidth; 00134 } 00135 00136 // Get the view height. 00137 virtual int GetHeight () const 00138 { 00139 return viewHeight; 00140 } 00141 00142 // Set the view width. 00143 virtual void SetWidth (int w) 00144 { 00145 viewWidth = w; 00146 } 00147 00148 // Set the view height. 00149 virtual void SetHeight (int h) 00150 { 00151 viewHeight = h; 00152 } 00153 00154 virtual csVector2 NormalizedToScreen (const csVector2& pos) 00155 { 00156 return csVector2 ( 00157 (pos.x + 1.0f) * float (viewWidth) / 2.0f, 00158 (pos.y + 1.0f) * float (viewHeight) / 2.0f 00159 ); 00160 } 00161 00162 virtual csVector2 ScreenToNormalized (const csVector2& pos) 00163 { 00164 return csVector2 ( 00165 pos.x * 2.0f / float (viewWidth) - 1.0f, 00166 pos.y * 2.0f / float (viewHeight) - 1.0f 00167 ); 00168 } 00169 }; 00170 00171 #endif // __CS_CSVIEW_H__
Generated for Crystal Space 2.0 by doxygen 1.6.1
