|
Blender
V2.59
|
00001 /* 00002 * $Id: RAS_FramingManager.h 35072 2011-02-22 12:42:55Z jesterking $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): none yet. 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00034 #ifndef RAS_FRAMINGMANAGER_H 00035 #define RAS_FRAMINGMANAGER_H 00036 00037 #ifdef WITH_CXX_GUARDEDALLOC 00038 #include "MEM_guardedalloc.h" 00039 #endif 00040 00041 class RAS_Rect; 00042 00064 class RAS_FrameSettings 00065 { 00066 public : 00071 enum RAS_FrameType { 00072 e_frame_scale, 00073 e_frame_extend, 00074 e_frame_bars 00075 }; 00076 00081 RAS_FrameSettings( 00082 RAS_FrameType frame_type, 00083 float bar_r, 00084 float bar_g, 00085 float bar_b, 00086 unsigned int design_aspect_width, 00087 unsigned int design_aspect_height 00088 ): 00089 m_frame_type(frame_type), 00090 m_bar_r(bar_r), 00091 m_bar_g(bar_g), 00092 m_bar_b(bar_b), 00093 m_design_aspect_width(design_aspect_width), 00094 m_design_aspect_height(design_aspect_height) 00095 { 00096 }; 00097 00098 RAS_FrameSettings( 00099 ): 00100 m_frame_type(e_frame_scale), 00101 m_bar_r(0), 00102 m_bar_g(0), 00103 m_bar_b(0), 00104 m_design_aspect_width(1), 00105 m_design_aspect_height(1) 00106 { 00107 }; 00108 00113 const 00114 RAS_FrameType & 00115 FrameType( 00116 ) const { 00117 return m_frame_type; 00118 }; 00119 00120 void 00121 SetFrameType( 00122 RAS_FrameType type 00123 ) { 00124 m_frame_type = type; 00125 }; 00126 00127 float 00128 BarRed( 00129 ) const { 00130 return m_bar_r; 00131 }; 00132 00133 float 00134 BarGreen( 00135 ) const { 00136 return m_bar_g; 00137 }; 00138 00139 float 00140 BarBlue( 00141 ) const { 00142 return m_bar_b; 00143 }; 00144 00145 unsigned int 00146 DesignAspectWidth( 00147 ) const { 00148 return m_design_aspect_width; 00149 }; 00150 00151 unsigned int 00152 DesignAspectHeight( 00153 ) const { 00154 return m_design_aspect_height; 00155 }; 00156 00157 private : 00158 00159 RAS_FrameType m_frame_type; 00160 float m_bar_r; 00161 float m_bar_g; 00162 float m_bar_b; 00163 unsigned int m_design_aspect_width; 00164 unsigned int m_design_aspect_height; 00165 00166 00167 #ifdef WITH_CXX_GUARDEDALLOC 00168 public: 00169 void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_FrameSettings"); } 00170 void operator delete( void *mem ) { MEM_freeN(mem); } 00171 #endif 00172 }; 00173 00174 struct RAS_FrameFrustum 00175 { 00176 float camnear,camfar; 00177 float x1,y1; 00178 float x2,y2; 00179 }; 00180 00181 /* must match R_CULLING_... from DNA_scene_types.h */ 00182 enum RAS_CullingMode 00183 { 00184 RAS_CULLING_DBVT = 0, 00185 RAS_CULLING_NORMAL, 00186 RAS_CULLING_NONE 00187 }; 00188 00200 class RAS_FramingManager 00201 { 00202 public : 00203 00210 static 00211 void 00212 ComputeViewport( 00213 const RAS_FrameSettings &settings, 00214 const RAS_Rect &availableViewport, 00215 RAS_Rect &viewport 00216 ); 00217 00218 00225 static 00226 void 00227 ComputeOrtho( 00228 const RAS_FrameSettings &settings, 00229 const RAS_Rect &availableViewport, 00230 const RAS_Rect &viewport, 00231 const float scale, 00232 const float camnear, 00233 const float camfar, 00234 RAS_FrameFrustum &frustum 00235 ); 00236 00237 static 00238 void 00239 ComputeFrustum( 00240 const RAS_FrameSettings &settings, 00241 const RAS_Rect &availableViewport, 00242 const RAS_Rect &viewport, 00243 const float lens, 00244 const float camnear, 00245 const float camfar, 00246 RAS_FrameFrustum &frustum 00247 ); 00248 00249 static 00250 void 00251 ComputeDefaultFrustum( 00252 const float camnear, 00253 const float camfar, 00254 const float lens, 00255 const float design_aspect_ratio, 00256 RAS_FrameFrustum & frustum 00257 ); 00258 00259 static 00260 void 00261 ComputeDefaultOrtho( 00262 const float camnear, 00263 const float camfar, 00264 const float scale, 00265 const float design_aspect_ratio, 00266 RAS_FrameFrustum & frustum 00267 ); 00268 00269 private : 00270 00271 static 00272 void 00273 ComputeBestFitViewRect( 00274 const RAS_Rect &availableViewport, 00275 const float design_aspect_ratio, 00276 RAS_Rect &viewport 00277 ); 00278 00279 00280 00286 RAS_FramingManager( 00287 ); 00288 00289 RAS_FramingManager( 00290 const RAS_FramingManager & 00291 ); 00292 00293 00294 #ifdef WITH_CXX_GUARDEDALLOC 00295 public: 00296 void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_FramingManager"); } 00297 void operator delete( void *mem ) { MEM_freeN(mem); } 00298 #endif 00299 }; 00300 00301 #endif 00302