- got tired of str[n]casecmp not declared warnings
[blender-staging.git] / source / blender / python / api2_2x / sceneRender.c
1 /* 
2  * $Id$
3  *
4  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5  *
6  * This program is free software; you can Redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. The Blender
10  * Foundation also sells licenses for use in proprietary software under
11  * the Blender License.  See http://www.blender.org/BL/ for information
12  * about this.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  *
23  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24  * All rights reserved.
25  *
26  * This is a new part of Blender.
27  *
28  * Contributor(s): Joseph Gilbert
29  *
30  * ***** END GPL/BL DUAL LICENSE BLOCK *****
31 */
32
33 #include <BIF_renderwin.h>
34 #include <BKE_utildefines.h>
35 #include <BKE_global.h>
36 #include <DNA_image_types.h>
37 #include <BIF_drawscene.h>
38 #include <BLI_blenlib.h>
39 #include <BKE_image.h>
40 #include <BIF_space.h>
41 #include <DNA_scene_types.h>
42 #include <DNA_space_types.h>
43 #include <mydevice.h>
44 #include <butspace.h>
45 #include <BKE_bad_level_calls.h>
46 #include <render.h> /* RE_animrender() */
47 #include "sceneRender.h"
48 #include "blendef.h"
49 #include "Scene.h"
50 #include "gen_utils.h"
51
52
53 #ifdef HAVE_CONFIG_H
54 #include <config.h>
55 #endif
56
57 //local defines
58 #define PY_NONE         0
59 #define PY_LOW          1
60 #define PY_MEDIUM       2
61 #define PY_HIGH         3
62 #define PY_HIGHER       4
63 #define PY_BEST         5
64 #define PY_SKYDOME      1
65 #define PY_FULL  2
66
67 extern RE_Render R;
68
69 //---------------------------------------Render prototypes-------------
70 static PyObject *M_Render_CloseRenderWindow( PyObject * self );
71 static PyObject *M_Render_EnableDispView( PyObject * self );
72 static PyObject *M_Render_EnableDispWin( PyObject * self );
73 static PyObject *M_Render_SetRenderWinPos( PyObject * self, PyObject * args );
74 static PyObject *M_Render_EnableEdgeShift( PyObject * self, PyObject * args );
75 static PyObject *M_Render_EnableEdgeAll( PyObject * self, PyObject * args );
76 //----------------------------------------------Render doc strings------
77 static char M_Render_doc[] = "The Blender Render module";
78 //----------------------------------------------Render method def-------
79 struct PyMethodDef M_Render_methods[] = {
80         {"CloseRenderWindow", ( PyCFunction ) M_Render_CloseRenderWindow,
81          METH_NOARGS,
82          "() - close the rendering window\n"},
83         {"EnableDispView", ( PyCFunction ) M_Render_EnableDispView,
84          METH_NOARGS,
85          "(bool) - enable Sceneing in view\n"},
86         {"EnableDispWin", ( PyCFunction ) M_Render_EnableDispWin, METH_NOARGS,
87          "(bool) - enable Sceneing in new window\n"},
88         {"SetRenderWinPos", ( PyCFunction ) M_Render_SetRenderWinPos,
89          METH_VARARGS,
90          "([string list]) - position the rendering window in around the edge of the screen\n"},
91         {"EnableEdgeShift", ( PyCFunction ) M_Render_EnableEdgeShift,
92          METH_VARARGS,
93          "(bool) - with the unified renderer the outlines are shifted a bit.\n"},
94         {"EnableEdgeAll", ( PyCFunction ) M_Render_EnableEdgeAll, METH_VARARGS,
95          "(bool) - also consider transparent faces for edge-rendering with the unified renderer\n"},
96         {NULL, NULL, 0, NULL}
97 };
98 //------------------------------------BPy_RenderData methods/callbacks--
99 static PyObject *RenderData_Render( BPy_RenderData * self );
100 static PyObject *RenderData_RenderAnim( BPy_RenderData * self );
101 static PyObject *RenderData_Play( BPy_RenderData * self );
102 static PyObject *RenderData_SetRenderPath( BPy_RenderData * self,
103                                            PyObject * args );
104 static PyObject *RenderData_GetRenderPath( BPy_RenderData * self );
105 static PyObject *RenderData_SetBackbufPath( BPy_RenderData * self,
106                                             PyObject * args );
107 static PyObject *RenderData_GetBackbufPath( BPy_RenderData * self );
108 static PyObject *RenderData_EnableBackbuf( BPy_RenderData * self,
109                                            PyObject * args );
110 static PyObject *RenderData_SetFtypePath( BPy_RenderData * self,
111                                           PyObject * args );
112 static PyObject *RenderData_GetFtypePath( BPy_RenderData * self );
113 static PyObject *RenderData_EnableExtensions( BPy_RenderData * self,
114                                               PyObject * args );
115 static PyObject *RenderData_EnableSequencer( BPy_RenderData * self,
116                                              PyObject * args );
117 static PyObject *RenderData_EnableRenderDaemon( BPy_RenderData * self,
118                                                 PyObject * args );
119 static PyObject *RenderData_EnableToonShading( BPy_RenderData * self,
120                                                PyObject * args );
121 static PyObject *RenderData_EdgeIntensity( BPy_RenderData * self,
122                                            PyObject * args );
123 static PyObject *RenderData_SetEdgeColor( BPy_RenderData * self,
124                                           PyObject * args );
125 static PyObject *RenderData_GetEdgeColor( BPy_RenderData * self );
126 static PyObject *RenderData_EdgeAntiShift( BPy_RenderData * self,
127                                            PyObject * args );
128 static PyObject *RenderData_EnableOversampling( BPy_RenderData * self,
129                                                 PyObject * args );
130 static PyObject *RenderData_SetOversamplingLevel( BPy_RenderData * self,
131                                                   PyObject * args );
132 static PyObject *RenderData_EnableMotionBlur( BPy_RenderData * self,
133                                               PyObject * args );
134 static PyObject *RenderData_MotionBlurLevel( BPy_RenderData * self,
135                                              PyObject * args );
136 static PyObject *RenderData_PartsX( BPy_RenderData * self, PyObject * args );
137 static PyObject *RenderData_PartsY( BPy_RenderData * self, PyObject * args );
138 static PyObject *RenderData_EnableSky( BPy_RenderData * self );
139 static PyObject *RenderData_EnablePremultiply( BPy_RenderData * self );
140 static PyObject *RenderData_EnableKey( BPy_RenderData * self );
141 static PyObject *RenderData_EnableShadow( BPy_RenderData * self,
142                                           PyObject * args );
143 static PyObject *RenderData_EnablePanorama( BPy_RenderData * self,
144                                             PyObject * args );
145 static PyObject *RenderData_EnableEnvironmentMap( BPy_RenderData * self,
146                                                   PyObject * args );
147 static PyObject *RenderData_EnableRayTracing( BPy_RenderData * self,
148                                               PyObject * args );
149 static PyObject *RenderData_EnableRadiosityRender( BPy_RenderData * self,
150                                                    PyObject * args );
151 static PyObject *RenderData_SetRenderWinSize( BPy_RenderData * self,
152                                               PyObject * args );
153 static PyObject *RenderData_EnableFieldRendering( BPy_RenderData * self,
154                                                   PyObject * args );
155 static PyObject *RenderData_EnableOddFieldFirst( BPy_RenderData * self,
156                                                  PyObject * args );
157 static PyObject *RenderData_EnableFieldTimeDisable( BPy_RenderData * self,
158                                                     PyObject * args );
159 static PyObject *RenderData_EnableGaussFilter( BPy_RenderData * self,
160                                                PyObject * args );
161 static PyObject *RenderData_EnableBorderRender( BPy_RenderData * self,
162                                                 PyObject * args );
163 static PyObject *RenderData_SetBorder( BPy_RenderData * self,
164                                        PyObject * args );
165 static PyObject *RenderData_EnableGammaCorrection( BPy_RenderData * self,
166                                                    PyObject * args );
167 static PyObject *RenderData_GaussFilterSize( BPy_RenderData * self,
168                                              PyObject * args );
169 static PyObject *RenderData_StartFrame( BPy_RenderData * self,
170                                         PyObject * args );
171 static PyObject *RenderData_CurrentFrame( BPy_RenderData * self,
172                                           PyObject * args );
173 static PyObject *RenderData_EndFrame( BPy_RenderData * self, PyObject * args );
174 static PyObject *RenderData_ImageSizeX( BPy_RenderData * self,
175                                         PyObject * args );
176 static PyObject *RenderData_ImageSizeY( BPy_RenderData * self,
177                                         PyObject * args );
178 static PyObject *RenderData_AspectRatioX( BPy_RenderData * self,
179                                           PyObject * args );
180 static PyObject *RenderData_AspectRatioY( BPy_RenderData * self,
181                                           PyObject * args );
182 static PyObject *RenderData_SetRenderer( BPy_RenderData * self,
183                                          PyObject * args );
184 static PyObject *RenderData_EnableCropping( BPy_RenderData * self,
185                                             PyObject * args );
186 static PyObject *RenderData_SetImageType( BPy_RenderData * self,
187                                           PyObject * args );
188 static PyObject *RenderData_Quality( BPy_RenderData * self, PyObject * args );
189 static PyObject *RenderData_FramesPerSec( BPy_RenderData * self,
190                                           PyObject * args );
191 static PyObject *RenderData_EnableGrayscale( BPy_RenderData * self );
192 static PyObject *RenderData_EnableRGBColor( BPy_RenderData * self );
193 static PyObject *RenderData_EnableRGBAColor( BPy_RenderData * self );
194 static PyObject *RenderData_SizePreset( BPy_RenderData * self,
195                                         PyObject * args );
196 static PyObject *RenderData_EnableUnifiedRenderer( BPy_RenderData * self,
197                                                    PyObject * args );
198 static PyObject *RenderData_SetYafrayGIQuality( BPy_RenderData * self,
199                                                 PyObject * args );
200 static PyObject *RenderData_SetYafrayGIMethod( BPy_RenderData * self,
201                                                PyObject * args );
202 static PyObject *RenderData_YafrayGIPower( BPy_RenderData * self,
203                                            PyObject * args );
204 static PyObject *RenderData_YafrayGIDepth( BPy_RenderData * self,
205                                            PyObject * args );
206 static PyObject *RenderData_YafrayGICDepth( BPy_RenderData * self,
207                                             PyObject * args );
208 static PyObject *RenderData_EnableYafrayGICache( BPy_RenderData * self,
209                                                  PyObject * args );
210 static PyObject *RenderData_EnableYafrayGIPhotons( BPy_RenderData * self,
211                                                    PyObject * args );
212 static PyObject *RenderData_YafrayGIPhotonCount( BPy_RenderData * self,
213                                                  PyObject * args );
214 static PyObject *RenderData_YafrayGIPhotonRadius( BPy_RenderData * self,
215                                                   PyObject * args );
216 static PyObject *RenderData_YafrayGIPhotonMixCount( BPy_RenderData * self,
217                                                     PyObject * args );
218 static PyObject *RenderData_EnableYafrayGITunePhotons( BPy_RenderData * self,
219                                                        PyObject * args );
220 static PyObject *RenderData_YafrayGIShadowQuality( BPy_RenderData * self,
221                                                    PyObject * args );
222 static PyObject *RenderData_YafrayGIPixelsPerSample( BPy_RenderData * self,
223                                                      PyObject * args );
224 static PyObject *RenderData_YafrayGIRefinement( BPy_RenderData * self,
225                                                 PyObject * args );
226 static PyObject *RenderData_YafrayRayBias( BPy_RenderData * self,
227                                            PyObject * args );
228 static PyObject *RenderData_YafrayRayDepth( BPy_RenderData * self,
229                                             PyObject * args );
230 static PyObject *RenderData_YafrayGamma( BPy_RenderData * self,
231                                          PyObject * args );
232 static PyObject *RenderData_YafrayExposure( BPy_RenderData * self,
233                                             PyObject * args );
234 static PyObject *RenderData_YafrayProcessorCount( BPy_RenderData * self,
235                                                   PyObject * args );
236 static PyObject *RenderData_EnableGameFrameStretch( BPy_RenderData * self );
237 static PyObject *RenderData_EnableGameFrameExpose( BPy_RenderData * self );
238 static PyObject *RenderData_EnableGameFrameBars( BPy_RenderData * self );
239 static PyObject *RenderData_SetGameFrameColor( BPy_RenderData * self,
240                                                PyObject * args );
241 static PyObject *RenderData_GetGameFrameColor( BPy_RenderData * self );
242 static PyObject *RenderData_GammaLevel( BPy_RenderData * self,
243                                         PyObject * args );
244 static PyObject *RenderData_PostProcessAdd( BPy_RenderData * self,
245                                             PyObject * args );
246 static PyObject *RenderData_PostProcessMultiply( BPy_RenderData * self,
247                                                  PyObject * args );
248 static PyObject *RenderData_PostProcessGamma( BPy_RenderData * self,
249                                               PyObject * args );
250 static PyObject *RenderData_SGIMaxsize( BPy_RenderData * self,
251                                         PyObject * args );
252 static PyObject *RenderData_EnableSGICosmo( BPy_RenderData * self,
253                                             PyObject * args );
254 static PyObject *RenderData_OldMapValue( BPy_RenderData * self,
255                                          PyObject * args );
256 static PyObject *RenderData_NewMapValue( BPy_RenderData * self,
257                                          PyObject * args );
258
259 static void RenderData_dealloc( BPy_RenderData * self );
260 static PyObject *RenderData_getAttr( BPy_RenderData * self, char *name );
261 static PyObject *RenderData_repr( BPy_RenderData * self );
262 //------------------------------------BPy_RenderData  method def--------
263 static PyMethodDef BPy_RenderData_methods[] = {
264         {"render", ( PyCFunction ) RenderData_Render, METH_NOARGS,
265          "() - render the scene\n"},
266         {"renderAnim", ( PyCFunction ) RenderData_RenderAnim, METH_NOARGS,
267          "() - render a sequence from start frame to end frame\n"},
268         {"play", ( PyCFunction ) RenderData_Play, METH_NOARGS,
269          "() - play animation of rendered images/avi (searches Pics: field)\n"},
270         {"setRenderPath", ( PyCFunction ) RenderData_SetRenderPath,
271          METH_VARARGS,
272          "(string) - get/set the path to output the rendered images to\n"},
273         {"getRenderPath", ( PyCFunction ) RenderData_GetRenderPath,
274          METH_NOARGS,
275          "() - get the path to directory where rendered images will go\n"},
276         {"setBackbufPath", ( PyCFunction ) RenderData_SetBackbufPath,
277          METH_VARARGS,
278          "(string) - get/set the path to a background image and load it\n"},
279         {"getBackbufPath", ( PyCFunction ) RenderData_GetBackbufPath,
280          METH_NOARGS,
281          "() - get the path to background image file\n"},
282         {"enableBackbuf", ( PyCFunction ) RenderData_EnableBackbuf,
283          METH_VARARGS,
284          "(bool) - enable/disable the backbuf image\n"},
285         {"setFtypePath", ( PyCFunction ) RenderData_SetFtypePath, METH_VARARGS,
286          "(string) - get/set the path to output the Ftype file\n"},
287         {"getFtypePath", ( PyCFunction ) RenderData_GetFtypePath, METH_NOARGS,
288          "() - get the path to Ftype file\n"},
289         {"enableExtensions", ( PyCFunction ) RenderData_EnableExtensions,
290          METH_VARARGS,
291          "(bool) - enable/disable windows extensions for output files\n"},
292         {"enableSequencer", ( PyCFunction ) RenderData_EnableSequencer,
293          METH_VARARGS,
294          "(bool) - enable/disable Do Sequence\n"},
295         {"enableRenderDaemon", ( PyCFunction ) RenderData_EnableRenderDaemon,
296          METH_VARARGS,
297          "(bool) - enable/disable Scene daemon\n"},
298         {"enableToonShading", ( PyCFunction ) RenderData_EnableToonShading,
299          METH_VARARGS,
300          "(bool) - enable/disable Edge rendering\n"},
301         {"edgeIntensity", ( PyCFunction ) RenderData_EdgeIntensity,
302          METH_VARARGS,
303          "(int) - get/set edge intensity for toon shading\n"},
304         {"setEdgeColor", ( PyCFunction ) RenderData_SetEdgeColor, METH_VARARGS,
305          "(f,f,f) - set the edge color for toon shading - Red,Green,Blue expected.\n"},
306         {"getEdgeColor", ( PyCFunction ) RenderData_GetEdgeColor, METH_VARARGS,
307          "() - get the edge color for toon shading - Red,Green,Blue expected.\n"},
308         {"edgeAntiShift", ( PyCFunction ) RenderData_EdgeAntiShift,
309          METH_VARARGS,
310          "(int) - with the unified renderer to reduce intensity on boundaries.\n"},
311         {"enableOversampling", ( PyCFunction ) RenderData_EnableOversampling,
312          METH_VARARGS,
313          "(bool) - enable/disable oversampling (anit-aliasing).\n"},
314         {"setOversamplingLevel",
315          ( PyCFunction ) RenderData_SetOversamplingLevel, METH_VARARGS,
316          "(enum) - get/set the level of oversampling (anit-aliasing).\n"},
317         {"enableMotionBlur", ( PyCFunction ) RenderData_EnableMotionBlur,
318          METH_VARARGS,
319          "(bool) - enable/disable MBlur.\n"},
320         {"motionBlurLevel", ( PyCFunction ) RenderData_MotionBlurLevel,
321          METH_VARARGS,
322          "(float) - get/set the length of shutter time for motion blur.\n"},
323         {"partsX", ( PyCFunction ) RenderData_PartsX, METH_VARARGS,
324          "(int) - get/set the number of parts to divide the render in the X direction\n"},
325         {"partsY", ( PyCFunction ) RenderData_PartsY, METH_VARARGS,
326          "(int) - get/set the number of parts to divide the render in the Y direction\n"},
327         {"enableSky", ( PyCFunction ) RenderData_EnableSky, METH_NOARGS,
328          "() - enable render background with sky\n"},
329         {"enablePremultiply", ( PyCFunction ) RenderData_EnablePremultiply,
330          METH_NOARGS,
331          "() - enable premultiply alpha\n"},
332         {"enableKey", ( PyCFunction ) RenderData_EnableKey, METH_NOARGS,
333          "() - enable alpha and colour values remain unchanged\n"},
334         {"enableShadow", ( PyCFunction ) RenderData_EnableShadow, METH_VARARGS,
335          "(bool) - enable/disable shadow calculation\n"},
336         {"enablePanorama", ( PyCFunction ) RenderData_EnablePanorama,
337          METH_VARARGS,
338          "(bool) - enable/disable panorama rendering (output width is multiplied by Xparts)\n"},
339         {"enableEnvironmentMap",
340          ( PyCFunction ) RenderData_EnableEnvironmentMap, METH_VARARGS,
341          "(bool) - enable/disable environment map rendering\n"},
342         {"enableRayTracing", ( PyCFunction ) RenderData_EnableRayTracing,
343          METH_VARARGS,
344          "(bool) - enable/disable ray tracing\n"},
345         {"enableRadiosityRender",
346          ( PyCFunction ) RenderData_EnableRadiosityRender, METH_VARARGS,
347          "(bool) - enable/disable radiosity rendering\n"},
348         {"setRenderWinSize", ( PyCFunction ) RenderData_SetRenderWinSize,
349          METH_VARARGS,
350          "(enum) - get/set the size of the render window\n"},
351         {"enableFieldRendering",
352          ( PyCFunction ) RenderData_EnableFieldRendering, METH_VARARGS,
353          "(bool) - enable/disable field rendering\n"},
354         {"enableOddFieldFirst", ( PyCFunction ) RenderData_EnableOddFieldFirst,
355          METH_VARARGS,
356          "(bool) - enable/disable Odd field first rendering (Default: Even field)\n"},
357         {"enableFieldTimeDisable",
358          ( PyCFunction ) RenderData_EnableFieldTimeDisable, METH_VARARGS,
359          "(bool) - enable/disable time difference in field calculations\n"},
360         {"enableGaussFilter", ( PyCFunction ) RenderData_EnableGaussFilter,
361          METH_VARARGS,
362          "(bool) - enable/disable Gauss sampling filter for antialiasing\n"},
363         {"enableBorderRender", ( PyCFunction ) RenderData_EnableBorderRender,
364          METH_VARARGS,
365          "(bool) - enable/disable small cut-out rendering\n"},
366         {"setBorder", ( PyCFunction ) RenderData_SetBorder, METH_VARARGS,
367          "(f,f,f,f) - set the border for border rendering\n"},
368         {"enableGammaCorrection",
369          ( PyCFunction ) RenderData_EnableGammaCorrection, METH_VARARGS,
370          "(bool) - enable/disable gamma correction\n"},
371         {"gaussFilterSize", ( PyCFunction ) RenderData_GaussFilterSize,
372          METH_VARARGS,
373          "(float) - get/sets the Gauss filter size\n"},
374         {"startFrame", ( PyCFunction ) RenderData_StartFrame, METH_VARARGS,
375          "(int) - get/set the starting frame for rendering\n"},
376         {"currentFrame", ( PyCFunction ) RenderData_CurrentFrame, METH_VARARGS,
377          "(int) - get/set the current frame for rendering\n"},
378         {"endFrame", ( PyCFunction ) RenderData_EndFrame, METH_VARARGS,
379          "(int) - get/set the ending frame for rendering\n"},
380         {"imageSizeX", ( PyCFunction ) RenderData_ImageSizeX, METH_VARARGS,
381          "(int) - get/set the image width in pixels\n"},
382         {"imageSizeY", ( PyCFunction ) RenderData_ImageSizeY, METH_VARARGS,
383          "(int) - get/set the image height in pixels\n"},
384         {"aspectRatioX", ( PyCFunction ) RenderData_AspectRatioX, METH_VARARGS,
385          "(int) - get/set the horizontal aspect ratio\n"},
386         {"aspectRatioY", ( PyCFunction ) RenderData_AspectRatioY, METH_VARARGS,
387          "(int) - get/set the vertical aspect ratio\n"},
388         {"setRenderer", ( PyCFunction ) RenderData_SetRenderer, METH_VARARGS,
389          "(enum) - get/set which renderer to render the output\n"},
390         {"enableCropping", ( PyCFunction ) RenderData_EnableCropping,
391          METH_VARARGS,
392          "(bool) - enable/disable exclusion of border rendering from total image\n"},
393         {"setImageType", ( PyCFunction ) RenderData_SetImageType, METH_VARARGS,
394          "(enum) - get/set the type of image to output from the render\n"},
395         {"quality", ( PyCFunction ) RenderData_Quality, METH_VARARGS,
396          "(int) - get/set quality get/setting for JPEG images, AVI Jpeg and SGI movies\n"},
397         {"framesPerSec", ( PyCFunction ) RenderData_FramesPerSec, METH_VARARGS,
398          "(int) - get/set frames per second\n"},
399         {"enableGrayscale", ( PyCFunction ) RenderData_EnableGrayscale,
400          METH_NOARGS,
401          "() - images are saved with BW (grayscale) data\n"},
402         {"enableRGBColor", ( PyCFunction ) RenderData_EnableRGBColor,
403          METH_NOARGS,
404          "() - images are saved with RGB (color) data\n"},
405         {"enableRGBAColor", ( PyCFunction ) RenderData_EnableRGBAColor,
406          METH_NOARGS,
407          "() - images are saved with RGB and Alpha data (if supported)\n"},
408         {"sizePreset", ( PyCFunction ) RenderData_SizePreset, METH_VARARGS,
409          "(enum) - get/set the render to one of a few preget/sets\n"},
410         {"enableUnifiedRenderer",
411          ( PyCFunction ) RenderData_EnableUnifiedRenderer, METH_VARARGS,
412          "(bool) - use the unified renderer\n"},
413         {"setYafrayGIQuality", ( PyCFunction ) RenderData_SetYafrayGIQuality,
414          METH_VARARGS,
415          "(enum) - get/set yafray global Illumination quality\n"},
416         {"setYafrayGIMethod", ( PyCFunction ) RenderData_SetYafrayGIMethod,
417          METH_VARARGS,
418          "(enum) - get/set yafray global Illumination method\n"},
419         {"yafrayGIPower", ( PyCFunction ) RenderData_YafrayGIPower,
420          METH_VARARGS,
421          "(float) - get/set GI lighting intensity scale\n"},
422         {"yafrayGIDepth", ( PyCFunction ) RenderData_YafrayGIDepth,
423          METH_VARARGS,
424          "(int) - get/set number of bounces of the indirect light\n"},
425         {"yafrayGICDepth", ( PyCFunction ) RenderData_YafrayGICDepth,
426          METH_VARARGS,
427          "(int) - get/set number of bounces inside objects (for caustics)\n"},
428         {"enableYafrayGICache", ( PyCFunction ) RenderData_EnableYafrayGICache,
429          METH_VARARGS,
430          "(bool) - enable/disable cache irradiance samples (faster)\n"},
431         {"enableYafrayGIPhotons",
432          ( PyCFunction ) RenderData_EnableYafrayGIPhotons, METH_VARARGS,
433          "(bool) - enable/disable use global photons to help in GI\n"},
434         {"yafrayGIPhotonCount", ( PyCFunction ) RenderData_YafrayGIPhotonCount,
435          METH_VARARGS,
436          "(int) - get/set number of photons to shoot\n"},
437         {"yafrayGIPhotonRadius",
438          ( PyCFunction ) RenderData_YafrayGIPhotonRadius, METH_VARARGS,
439          "(float) - get/set radius to search for photons to mix (blur)\n"},
440         {"yafrayGIPhotonMixCount",
441          ( PyCFunction ) RenderData_YafrayGIPhotonMixCount, METH_VARARGS,
442          "(int) - get/set number of photons to shoot\n"},
443         {"enableYafrayGITunePhotons",
444          ( PyCFunction ) RenderData_EnableYafrayGITunePhotons, METH_VARARGS,
445          "(bool) - enable/disable show the photonmap directly in the render for tuning\n"},
446         {"yafrayGIShadowQuality",
447          ( PyCFunction ) RenderData_YafrayGIShadowQuality, METH_VARARGS,
448          "(float) - get/set the shadow quality, keep it under 0.95\n"},
449         {"yafrayGIPixelsPerSample",
450          ( PyCFunction ) RenderData_YafrayGIPixelsPerSample, METH_VARARGS,
451          "(int) - get/set maximum number of pixels without samples, the lower the better and slower\n"},
452         {"yafrayGIRefinement", ( PyCFunction ) RenderData_YafrayGIRefinement,
453          METH_VARARGS,
454          "(float) - get/setthreshold to refine shadows EXPERIMENTAL. 1 = no refinement\n"},
455         {"yafrayRayBias", ( PyCFunction ) RenderData_YafrayRayBias,
456          METH_VARARGS,
457          "(float) - get/set shadow ray bias to avoid self shadowing\n"},
458         {"yafrayRayDepth", ( PyCFunction ) RenderData_YafrayRayDepth,
459          METH_VARARGS,
460          "(int) - get/set maximum render ray depth from the camera\n"},
461         {"yafrayGamma", ( PyCFunction ) RenderData_YafrayGamma, METH_VARARGS,
462          "(float) - get/set gamma correction, 1 is off\n"},
463         {"yafrayExposure", ( PyCFunction ) RenderData_YafrayExposure,
464          METH_VARARGS,
465          "(float) - get/set exposure adjustment, 0 is off\n"},
466         {"yafrayProcessorCount",
467          ( PyCFunction ) RenderData_YafrayProcessorCount, METH_VARARGS,
468          "(int) - get/set number of processors to use\n"},
469         {"enableGameFrameStretch",
470          ( PyCFunction ) RenderData_EnableGameFrameStretch, METH_NOARGS,
471          "(l) - enble stretch or squeeze the viewport to fill the display window\n"},
472         {"enableGameFrameExpose",
473          ( PyCFunction ) RenderData_EnableGameFrameExpose, METH_NOARGS,
474          "(l) - enable show the entire viewport in the display window, viewing more horizontally or vertically\n"},
475         {"enableGameFrameBars", ( PyCFunction ) RenderData_EnableGameFrameBars,
476          METH_NOARGS,
477          "() - enable show the entire viewport in the display window, using bar horizontally or vertically\n"},
478         {"setGameFrameColor", ( PyCFunction ) RenderData_SetGameFrameColor,
479          METH_VARARGS,
480          "(f,f,f) - set the red, green, blue component of the bars\n"},
481         {"getGameFrameColor", ( PyCFunction ) RenderData_GetGameFrameColor,
482          METH_VARARGS,
483          "() - get the red, green, blue component of the bars\n"},
484         {"gammaLevel", ( PyCFunction ) RenderData_GammaLevel, METH_VARARGS,
485          "(float) - get/set the gamma value for blending oversampled images (1.0 = no correction\n"},
486         {"postProcessAdd", ( PyCFunction ) RenderData_PostProcessAdd,
487          METH_VARARGS,
488          "(float) - get/set post processing add\n"},
489         {"postProcessMultiply", ( PyCFunction ) RenderData_PostProcessMultiply,
490          METH_VARARGS,
491          "(float) - get/set post processing multiply\n"},
492         {"postProcessGamma", ( PyCFunction ) RenderData_PostProcessGamma,
493          METH_VARARGS,
494          "(float) - get/set post processing gamma\n"},
495         {"SGIMaxsize", ( PyCFunction ) RenderData_SGIMaxsize, METH_VARARGS,
496          "(int) - get/set maximum size per frame to save in an SGI movie\n"},
497         {"enableSGICosmo", ( PyCFunction ) RenderData_EnableSGICosmo,
498          METH_VARARGS,
499          "(bool) - enable/disable attempt to save SGI movies using Cosmo hardware\n"},
500         {"oldMapValue", ( PyCFunction ) RenderData_OldMapValue, METH_VARARGS,
501          "(int) - get/set specify old map value in frames\n"},
502         {"newMapValue", ( PyCFunction ) RenderData_NewMapValue, METH_VARARGS,
503          "(int) - get/set specify new map value in frames\n"},
504         {NULL, NULL, 0, NULL}
505 };
506 //------------------------------------BPy_RenderData Type defintion------
507 PyTypeObject RenderData_Type = {
508         PyObject_HEAD_INIT( NULL ) 0,   /* ob_size */
509         "Blender RenderData",   /* tp_name */
510         sizeof( BPy_RenderData ),       /* tp_basicsize */
511         0,                      /* tp_itemsize */
512         /* methods */
513         ( destructor ) RenderData_dealloc,      /* tp_dealloc */
514         0,                      /* tp_print */
515         ( getattrfunc ) RenderData_getAttr,     /* tp_getattr */
516         0,                      /* tp_setattr */
517         0,                      /* tp_compare */
518         ( reprfunc ) RenderData_repr,   /* tp_repr */
519         0,                      /* tp_as_number */
520         0,                      /* tp_as_sequence */
521         0,                      /* tp_as_mapping */
522         0,                      /* tp_as_hash */
523         0, 0, 0, 0, 0, 0,
524         0,                      /* tp_doc */
525         0, 0, 0, 0, 0, 0,
526         BPy_RenderData_methods, /* tp_methods */
527         0,                      /* tp_members */
528         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
529 };
530 //---------------------------------------------------Render Module Init--
531 PyObject *Render_Init( void )
532 {
533         PyObject *submodule;
534
535         RenderData_Type.ob_type = &PyType_Type;
536
537         submodule = Py_InitModule3( "Blender.Scene.Render",
538                                     M_Render_methods, M_Render_doc );
539
540         PyModule_AddIntConstant( submodule, "INTERNAL", R_INTERN );
541         PyModule_AddIntConstant( submodule, "YAFRAY", R_YAFRAY );
542         PyModule_AddIntConstant( submodule, "AVIRAW", R_AVIRAW );
543         PyModule_AddIntConstant( submodule, "AVIJPEG", R_AVIJPEG );
544         PyModule_AddIntConstant( submodule, "AVICODEC", R_AVICODEC );
545         PyModule_AddIntConstant( submodule, "QUICKTIME", R_QUICKTIME );
546         PyModule_AddIntConstant( submodule, "TARGA", R_TARGA );
547         PyModule_AddIntConstant( submodule, "RAWTGA", R_RAWTGA );
548         PyModule_AddIntConstant( submodule, "PNG", R_PNG );
549         PyModule_AddIntConstant( submodule, "BMP", R_BMP );
550         PyModule_AddIntConstant( submodule, "JPEG", R_JPEG90 );
551         PyModule_AddIntConstant( submodule, "HAMX", R_HAMX );
552         PyModule_AddIntConstant( submodule, "IRIS", R_IRIS );
553         PyModule_AddIntConstant( submodule, "IRISZ", R_IRIZ );
554         PyModule_AddIntConstant( submodule, "FTYPE", R_FTYPE );
555         PyModule_AddIntConstant( submodule, "PAL", B_PR_PAL );
556         PyModule_AddIntConstant( submodule, "NTSC", B_PR_NTSC );
557         PyModule_AddIntConstant( submodule, "DEFAULT", B_PR_PRESET );
558         PyModule_AddIntConstant( submodule, "PREVIEW", B_PR_PRV );
559         PyModule_AddIntConstant( submodule, "PC", B_PR_PC );
560         PyModule_AddIntConstant( submodule, "PAL169", B_PR_PAL169 );
561         PyModule_AddIntConstant( submodule, "PANO", B_PR_PANO );
562         PyModule_AddIntConstant( submodule, "FULL", B_PR_FULL );
563         PyModule_AddIntConstant( submodule, "NONE", PY_NONE );
564         PyModule_AddIntConstant( submodule, "LOW", PY_LOW );
565         PyModule_AddIntConstant( submodule, "MEDIUM", PY_MEDIUM );
566         PyModule_AddIntConstant( submodule, "HIGH", PY_HIGH );
567         PyModule_AddIntConstant( submodule, "HIGHER", PY_HIGHER );
568         PyModule_AddIntConstant( submodule, "BEST", PY_BEST );
569         PyModule_AddIntConstant( submodule, "SKYDOME", PY_SKYDOME );
570         PyModule_AddIntConstant( submodule, "GIFULL", PY_FULL );
571
572         return ( submodule );
573 }
574
575 //-----------------------------------BPy_RenderData Internal Protocols---
576 //-------------------------------------------------dealloc---------------
577 static void RenderData_dealloc( BPy_RenderData * self )
578 {
579         PyObject_DEL( self );
580 }
581
582 //-------------------------------------------------getAttr---------------
583 static PyObject *RenderData_getAttr( BPy_RenderData * self, char *name )
584 {
585         return Py_FindMethod( BPy_RenderData_methods, ( PyObject * ) self,
586                               name );
587 }
588
589 //-------------------------------------------------repr------------------
590 static PyObject *RenderData_repr( BPy_RenderData * self )
591 {
592         if( self->renderContext )
593                 return PyString_FromFormat( "[RenderData \"%s\"]",
594                                             self->scene->id.name + 2 );
595         else
596                 return PyString_FromString( "NULL" );
597 }
598
599 //------------------------------BPy_RenderData Callbacks-----------------
600 //--------------------------------------CreatePyObject-------------------
601 PyObject *RenderData_CreatePyObject( struct Scene * scene )
602 {
603         BPy_RenderData *py_renderdata;
604
605         py_renderdata =
606                 ( BPy_RenderData * ) PyObject_NEW( BPy_RenderData,
607                                                    &RenderData_Type );
608
609         if( py_renderdata == NULL ) {
610                 return ( NULL );
611         }
612         py_renderdata->renderContext = &scene->r;
613         py_renderdata->scene = scene;
614
615         return ( ( PyObject * ) py_renderdata );
616 }
617
618 //------------------------------CheckPyObject----------------------------
619 int RenderData_CheckPyObject( PyObject * py_obj )
620 {
621         return ( py_obj->ob_type == &RenderData_Type );
622 }
623
624 //------------------------------------BitToggleInt-----------------------
625 static PyObject *M_Render_BitToggleInt( PyObject * args, int setting,
626                                         int *structure )
627 {
628         int flag;
629
630         if( !PyArg_ParseTuple( args, "i", &flag ) )
631                 return ( EXPP_ReturnPyObjError
632                          ( PyExc_AttributeError,
633                            "expected TRUE or FALSE (1 or 0)" ) );
634
635         if( flag < 0 || flag > 1 )
636                 return ( EXPP_ReturnPyObjError
637                          ( PyExc_AttributeError,
638                            "expected TRUE or FALSE (1 or 0)" ) );
639
640         if( flag )
641                 *structure |= setting;
642         else
643                 *structure &= ~setting;
644         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
645
646         return EXPP_incr_ret( Py_None );
647
648 }
649
650 //------------------------------------BitToggleShort---------------------
651 static PyObject *M_Render_BitToggleShort( PyObject * args, short setting,
652                                           short *structure )
653 {
654         int flag;
655
656         if( !PyArg_ParseTuple( args, "i", &flag ) )
657                 return ( EXPP_ReturnPyObjError
658                          ( PyExc_AttributeError,
659                            "expected TRUE or FALSE (1 or 0)" ) );
660
661         if( flag < 0 || flag > 1 )
662                 return ( EXPP_ReturnPyObjError
663                          ( PyExc_AttributeError,
664                            "expected TRUE or FALSE (1 or 0)" ) );
665
666         if( flag )
667                 *structure |= setting;
668         else
669                 *structure &= ~setting;
670         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
671
672         return EXPP_incr_ret( Py_None );
673
674 }
675
676 //------------------------------------GetSetAttributeFloat---------------
677 static PyObject *M_Render_GetSetAttributeFloat( PyObject * args,
678                                                 float *structure, float min,
679                                                 float max )
680 {
681         float property = -10.0f;
682         char error[48];
683
684         if( !PyArg_ParseTuple( args, "|f", &property ) )
685                 return ( EXPP_ReturnPyObjError
686                          ( PyExc_AttributeError, "expected float" ) );
687
688         if( property != -10.0f ) {
689                 if( property < min || property > max ) {
690                         sprintf( error, "out of range - expected %f to %f",
691                                  min, max );
692                         return ( EXPP_ReturnPyObjError
693                                  ( PyExc_AttributeError, error ) );
694                 }
695
696                 *structure = property;
697                 EXPP_allqueue( REDRAWBUTSSCENE, 0 );
698                 return EXPP_incr_ret( Py_None );
699         } else
700                 return Py_BuildValue( "f", *structure );
701 }
702
703 //------------------------------------GetSetAttributeShort---------------
704 static PyObject *M_Render_GetSetAttributeShort( PyObject * args,
705                                                 short *structure, int min,
706                                                 int max )
707 {
708         short property = -10;
709         char error[48];
710
711         if( !PyArg_ParseTuple( args, "|h", &property ) )
712                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
713                                                 "expected int" ) );
714
715         if( property != -10 ) {
716                 if( property < min || property > max ) {
717                         sprintf( error, "out of range - expected %d to %d",
718                                  min, max );
719                         return ( EXPP_ReturnPyObjError
720                                  ( PyExc_AttributeError, error ) );
721                 }
722
723                 *structure = property;
724                 EXPP_allqueue( REDRAWBUTSSCENE, 0 );
725                 return EXPP_incr_ret( Py_None );
726         } else
727                 return Py_BuildValue( "h", *structure );
728 }
729
730 //------------------------------------GetSetAttributeInt-----------------
731 static PyObject *M_Render_GetSetAttributeInt( PyObject * args, int *structure,
732                                               int min, int max )
733 {
734         int property = -10;
735         char error[48];
736
737         if( !PyArg_ParseTuple( args, "|i", &property ) )
738                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
739                                                 "expected int" ) );
740
741         if( property != -10 ) {
742                 if( property < min || property > max ) {
743                         sprintf( error, "out of range - expected %d to %d",
744                                  min, max );
745                         return ( EXPP_ReturnPyObjError
746                                  ( PyExc_AttributeError, error ) );
747                 }
748
749                 *structure = property;
750                 EXPP_allqueue( REDRAWBUTSSCENE, 0 );
751                 return EXPP_incr_ret( Py_None );
752         } else
753                 return Py_BuildValue( "i", *structure );
754 }
755
756 //------------------------------------DoSizePrese -----------------------
757 static void M_Render_DoSizePreset( BPy_RenderData * self, short xsch,
758                                    short ysch, short xasp, short yasp,
759                                    short size, short xparts, short yparts,
760                                    short frames, float a, float b, float c,
761                                    float d )
762 {
763         self->renderContext->xsch = xsch;
764         self->renderContext->ysch = ysch;
765         self->renderContext->xasp = xasp;
766         self->renderContext->yasp = yasp;
767         self->renderContext->size = size;
768         self->renderContext->frs_sec = frames;
769         self->renderContext->xparts = xparts;
770         self->renderContext->yparts = yparts;
771
772         BLI_init_rctf( &self->renderContext->safety, a, b, c, d );
773         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
774         EXPP_allqueue( REDRAWVIEWCAM, 0 );
775 }
776
777 //------------------------------------Render Module Function Definitions-
778 //------------------------------------Render.CloseRenderWindow() --------
779 PyObject *M_Render_CloseRenderWindow( PyObject * self )
780 {
781         BIF_close_render_display(  );
782         return EXPP_incr_ret( Py_None );
783 }
784
785 //------------------------------------Render.SetRenderWinPos() ----------
786 PyObject *M_Render_SetRenderWinPos( PyObject * self, PyObject * args )
787 {
788         PyObject *list = NULL;
789         char *loc = NULL;
790         int x;
791
792         if( !PyArg_ParseTuple( args, "O!", &PyList_Type, &list ) )
793                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
794                                                 "expected a list" ) );
795
796         G.winpos = 0;
797         for( x = 0; x < PyList_Size( list ); x++ ) {
798                 if( !PyArg_Parse( PyList_GetItem( list, x ), "s", &loc ) ) {
799                         return EXPP_ReturnPyObjError( PyExc_TypeError,
800                                                       "python list not parseable\n" );
801                 }
802                 if( strcmp( loc, "SW" ) == 0 || strcmp( loc, "sw" ) == 0 )
803                         G.winpos |= 1;
804                 else if( strcmp( loc, "S" ) == 0 || strcmp( loc, "s" ) == 0 )
805                         G.winpos |= 2;
806                 else if( strcmp( loc, "SE" ) == 0 || strcmp( loc, "se" ) == 0 )
807                         G.winpos |= 4;
808                 else if( strcmp( loc, "W" ) == 0 || strcmp( loc, "w" ) == 0 )
809                         G.winpos |= 8;
810                 else if( strcmp( loc, "C" ) == 0 || strcmp( loc, "c" ) == 0 )
811                         G.winpos |= 16;
812                 else if( strcmp( loc, "E" ) == 0 || strcmp( loc, "e" ) == 0 )
813                         G.winpos |= 32;
814                 else if( strcmp( loc, "NW" ) == 0 || strcmp( loc, "nw" ) == 0 )
815                         G.winpos |= 64;
816                 else if( strcmp( loc, "N" ) == 0 || strcmp( loc, "n" ) == 0 )
817                         G.winpos |= 128;
818                 else if( strcmp( loc, "NE" ) == 0 || strcmp( loc, "ne" ) == 0 )
819                         G.winpos |= 256;
820                 else
821                         return EXPP_ReturnPyObjError( PyExc_AttributeError,
822                                                       "list contains unknown string\n" );
823         }
824         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
825
826         return EXPP_incr_ret( Py_None );
827 }
828
829 //------------------------------------Render.EnableDispView() -----------
830 PyObject *M_Render_EnableDispView( PyObject * self )
831 {
832         G.displaymode = R_DISPLAYVIEW;
833         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
834
835         return EXPP_incr_ret( Py_None );
836 }
837
838 //------------------------------------Render.EnableDispWin() ------------
839 PyObject *M_Render_EnableDispWin( PyObject * self )
840 {
841         G.displaymode = R_DISPLAYWIN;
842         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
843
844         return EXPP_incr_ret( Py_None );
845 }
846
847 //------------------------------------Render.EnableEdgeShift() ----------
848 PyObject *M_Render_EnableEdgeShift( PyObject * self, PyObject * args )
849 {
850         return M_Render_BitToggleInt( args, 1, &G.compat );
851 }
852
853 //------------------------------------Render.EnableEdgeAll() ------------
854 PyObject *M_Render_EnableEdgeAll( PyObject * self, PyObject * args )
855 {
856         return M_Render_BitToggleInt( args, 1, &G.notonlysolid );
857 }
858
859 //----------------------------BPy_RenderData Function Definitions--------
860
861 //------------------------------------RenderData.Render() ---------------
862 PyObject *RenderData_Render( BPy_RenderData * self )
863 {
864         Scene *oldsce;
865
866         if (!G.background) {
867                 oldsce = G.scene;
868                 set_scene( self->scene );
869                 BIF_do_render( 0 );
870                 set_scene( oldsce );
871         }
872
873         else { /* background mode (blender -b file.blend -P script) */
874
875                 int end_frame = G.scene->r.efra; /* is of type short currently */
876
877                 if (G.scene != self->scene)
878                         return EXPP_ReturnPyObjError (PyExc_RuntimeError,
879                                 "scene to render in bg mode must be the active scene");
880
881                 G.scene->r.efra = G.scene->r.sfra;
882
883                 RE_animrender(NULL);
884
885                 G.scene->r.efra = end_frame;
886         }
887
888         return EXPP_incr_ret( Py_None );
889 }
890
891 //------------------------------------RenderData.RenderAnim() -----------
892 PyObject *RenderData_RenderAnim( BPy_RenderData * self )
893 {
894         Scene *oldsce;
895
896         if (!G.background) {
897                 oldsce = G.scene;
898                 set_scene( self->scene );
899                 BIF_do_render( 1 );
900                 set_scene( oldsce );
901         }
902         else { /* background mode (blender -b file.blend -P script) */
903                 if (G.scene != self->scene)
904                         return EXPP_ReturnPyObjError (PyExc_RuntimeError,
905                                 "scene to render in bg mode must be the active scene");
906
907                 if (G.scene->r.sfra > G.scene->r.efra)
908                         return EXPP_ReturnPyObjError (PyExc_RuntimeError,
909                                 "start frame must be less or equal to end frame");
910                 RE_animrender(NULL);
911         }
912         return EXPP_incr_ret( Py_None );
913 }
914
915 //------------------------------------RenderData.Play() -----------------
916 PyObject *RenderData_Play( BPy_RenderData * self )
917 {
918         char file[FILE_MAXDIR + FILE_MAXFILE];
919         extern char bprogname[];
920         char str[FILE_MAXDIR + FILE_MAXFILE];
921         int pos[2], size[2];
922         char txt[64];
923
924 #ifdef WITH_QUICKTIME
925         if( self->renderContext->imtype == R_QUICKTIME ) {
926
927                 strcpy( file, self->renderContext->pic );
928                 BLI_convertstringcode( file, (char *) self->scene,
929                                        self->renderContext->cfra );
930                 RE_make_existing_file( file );
931                 if( BLI_strcasecmp( file + strlen( file ) - 4, ".mov" ) ) {
932                         sprintf( txt, "%04d_%04d.mov",
933                                  ( self->renderContext->sfra ),
934                                  ( self->renderContext->efra ) );
935                         strcat( file, txt );
936                 }
937         } else
938 #endif
939         {
940
941                 strcpy( file, self->renderContext->pic );
942                 BLI_convertstringcode( file, G.sce,
943                                        self->renderContext->cfra );
944                 RE_make_existing_file( file );
945                 if( BLI_strcasecmp( file + strlen( file ) - 4, ".avi" ) ) {
946                         sprintf( txt, "%04d_%04d.avi",
947                                  ( self->renderContext->sfra ),
948                                  ( self->renderContext->efra ) );
949                         strcat( file, txt );
950                 }
951         }
952         if( BLI_exist( file ) ) {
953                 calc_renderwin_rectangle( G.winpos, pos, size );
954                 sprintf( str, "%s -a -p %d %d \"%s\"", bprogname, pos[0],
955                          pos[1], file );
956                 system( str );
957         } else {
958                 makepicstring( file, self->renderContext->sfra );
959                 if( BLI_exist( file ) ) {
960                         calc_renderwin_rectangle( G.winpos, pos, size );
961                         sprintf( str, "%s -a -p %d %d \"%s\"", bprogname,
962                                  pos[0], pos[1], file );
963                         system( str );
964                 } else
965                         sprintf( "Can't find image: %s", file );
966         }
967
968         return EXPP_incr_ret( Py_None );
969 }
970
971 //------------------------------------RenderData.StRenderPath() ---------
972 PyObject *RenderData_SetRenderPath( BPy_RenderData * self, PyObject * args )
973 {
974         char *name;
975
976         if( !PyArg_ParseTuple( args, "s", &name ) )
977                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
978                                                 "expected a string" ) );
979
980         if( strlen( name ) > 160 )
981                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
982                                                 "path is too long (SetRenderPath)" ) );
983
984         strcpy( self->renderContext->pic, name );
985         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
986
987         return EXPP_incr_ret( Py_None );
988 }
989
990 //------------------------------------RenderData.GetRenderPath() --------
991 PyObject *RenderData_GetRenderPath( BPy_RenderData * self )
992 {
993         return Py_BuildValue( "s", self->renderContext->pic );
994 }
995
996 //------------------------------------RenderData.SetBackbufPath() -------
997 PyObject *RenderData_SetBackbufPath( BPy_RenderData * self, PyObject * args )
998 {
999         char *name;
1000         Image *ima;
1001
1002         if( !PyArg_ParseTuple( args, "s", &name ) )
1003                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1004                                                 "expected a string" ) );
1005
1006         if( strlen( name ) > 160 )
1007                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1008                                                 "path is too long (SetBackbufPath)" ) );
1009
1010         strcpy( self->renderContext->backbuf, name );
1011         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1012
1013         ima = add_image( name );
1014         if( ima ) {
1015                 free_image_buffers( ima );
1016                 ima->ok = 1;
1017         }
1018
1019         return EXPP_incr_ret( Py_None );
1020 }
1021
1022 //------------------------------------RenderData.GetBackbufPath() -------
1023 PyObject *RenderData_GetBackbufPath( BPy_RenderData * self )
1024 {
1025         return Py_BuildValue( "s", self->renderContext->backbuf );
1026 }
1027
1028 //------------------------------------RenderData.EnableBackbuf() --------
1029 PyObject *RenderData_EnableBackbuf( BPy_RenderData * self, PyObject * args )
1030 {
1031         return M_Render_BitToggleShort( args, 1,
1032                                         &self->renderContext->bufflag );
1033 }
1034
1035 //------------------------------------RenderData.SetFtypePath() ---------
1036 PyObject *RenderData_SetFtypePath( BPy_RenderData * self, PyObject * args )
1037 {
1038         char *name;
1039
1040         if( !PyArg_ParseTuple( args, "s", &name ) )
1041                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1042                                                 "expected a string" ) );
1043
1044         if( strlen( name ) > 160 )
1045                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1046                                                 "path is too long (SetFtypePath)" ) );
1047
1048         strcpy( self->renderContext->ftype, name );
1049         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1050
1051         return EXPP_incr_ret( Py_None );
1052 }
1053
1054 //------------------------------------RenderData.GetFtypePath() ---------
1055 PyObject *RenderData_GetFtypePath( BPy_RenderData * self )
1056 {
1057         return Py_BuildValue( "s", self->renderContext->ftype );
1058 }
1059
1060 //------------------------------------RenderData.EnableExtensions() -----
1061 PyObject *RenderData_EnableExtensions( BPy_RenderData * self, PyObject * args )
1062 {
1063         return M_Render_BitToggleShort( args, R_EXTENSION,
1064                                         &self->renderContext->scemode );
1065 }
1066
1067 //------------------------------------RenderData.EnableSequencer() ------
1068 PyObject *RenderData_EnableSequencer( BPy_RenderData * self, PyObject * args )
1069 {
1070         return M_Render_BitToggleShort( args, R_DOSEQ,
1071                                         &self->renderContext->scemode );
1072 }
1073
1074 //------------------------------------RenderData.EnableRenderDaemon() ---
1075 PyObject *RenderData_EnableRenderDaemon( BPy_RenderData * self,
1076                                          PyObject * args )
1077 {
1078         return M_Render_BitToggleShort( args, R_BG_RENDER,
1079                                         &self->renderContext->scemode );
1080 }
1081
1082 //------------------------------------RenderData.EnableToonShading() ----
1083 PyObject *RenderData_EnableToonShading( BPy_RenderData * self,
1084                                         PyObject * args )
1085 {
1086         return M_Render_BitToggleInt( args, R_EDGE,
1087                                       &self->renderContext->mode );
1088 }
1089
1090 //------------------------------------RenderData.EdgeIntensity() --------
1091 PyObject *RenderData_EdgeIntensity( BPy_RenderData * self, PyObject * args )
1092 {
1093         return M_Render_GetSetAttributeShort( args,
1094                                               &self->renderContext->edgeint, 0,
1095                                               255 );
1096 }
1097
1098 //------------------------------------RenderData.SetEdgeColor() ---------
1099 PyObject *RenderData_SetEdgeColor( BPy_RenderData * self, PyObject * args )
1100 {
1101         float red = 0.0f;
1102         float green = 0.0f;
1103         float blue = 0.0f;
1104
1105         if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) )
1106                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1107                                                 "expected three floats" ) );
1108
1109         if( red < 0 || red > 1 )
1110                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1111                                                 "value out of range 0.000 - 1.000 (red)" ) );
1112         if( green < 0 || green > 1 )
1113                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1114                                                 "value out of range 0.000 - 1.000 (green)" ) );
1115         if( blue < 0 || blue > 1 )
1116                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1117                                                 "value out of range 0.000 - 1.000 (blue)" ) );
1118
1119         self->renderContext->edgeR = red;
1120         self->renderContext->edgeG = green;
1121         self->renderContext->edgeB = blue;
1122
1123         return EXPP_incr_ret( Py_None );
1124 }
1125
1126 //------------------------------------RenderData.GetEdgeColor() ---------
1127 PyObject *RenderData_GetEdgeColor( BPy_RenderData * self )
1128 {
1129         char rgb[24];
1130
1131         sprintf( rgb, "[%.3f,%.3f,%.3f]\n", self->renderContext->edgeR,
1132                  self->renderContext->edgeG, self->renderContext->edgeB );
1133         return PyString_FromString( rgb );
1134 }
1135
1136 //------------------------------------RenderData.EdgeAntiShift() --------
1137 PyObject *RenderData_EdgeAntiShift( BPy_RenderData * self, PyObject * args )
1138 {
1139         return M_Render_GetSetAttributeShort( args,
1140                                               &self->renderContext->
1141                                               same_mat_redux, 0, 255 );
1142 }
1143
1144 //------------------------------------RenderData.EnableOversampling() ---
1145 PyObject *RenderData_EnableOversampling( BPy_RenderData * self,
1146                                          PyObject * args )
1147 {
1148         return M_Render_BitToggleInt( args, R_OSA,
1149                                       &self->renderContext->mode );
1150 }
1151
1152 //------------------------------------RenderData.SetOversamplingLevel() -
1153 PyObject *RenderData_SetOversamplingLevel( BPy_RenderData * self,
1154                                            PyObject * args )
1155 {
1156         int level;
1157
1158         if( !PyArg_ParseTuple( args, "i", &level ) )
1159                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1160                                                 "expected int" ) );
1161
1162         if( level != 5 && level != 8 && level != 11 && level != 16 )
1163                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1164                                                 "expected 5,8,11, or 16" ) );
1165
1166         self->renderContext->osa = level;
1167         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1168
1169         return EXPP_incr_ret( Py_None );
1170 }
1171
1172 //------------------------------------RenderData.EnableMotionBlur() -----
1173 PyObject *RenderData_EnableMotionBlur( BPy_RenderData * self, PyObject * args )
1174 {
1175         return M_Render_BitToggleInt( args, R_MBLUR,
1176                                       &self->renderContext->mode );
1177 }
1178
1179 //------------------------------------RenderData.MotionBlurLevel() ------
1180 PyObject *RenderData_MotionBlurLevel( BPy_RenderData * self, PyObject * args )
1181 {
1182         return M_Render_GetSetAttributeFloat( args,
1183                                               &self->renderContext->blurfac,
1184                                               0.01f, 5.0f );
1185 }
1186
1187 //------------------------------------RenderData.PartsX() ---------------
1188 PyObject *RenderData_PartsX( BPy_RenderData * self, PyObject * args )
1189 {
1190         return M_Render_GetSetAttributeShort( args,
1191                                               &self->renderContext->xparts, 1,
1192                                               64 );
1193 }
1194
1195 //------------------------------------RenderData.PartsY() ---------------
1196 PyObject *RenderData_PartsY( BPy_RenderData * self, PyObject * args )
1197 {
1198         return M_Render_GetSetAttributeShort( args,
1199                                               &self->renderContext->yparts, 1,
1200                                               64 );
1201 }
1202
1203 //------------------------------------RenderData.EnableSky() ------------
1204 PyObject *RenderData_EnableSky( BPy_RenderData * self )
1205 {
1206         self->renderContext->alphamode = R_ADDSKY;
1207         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1208
1209         return EXPP_incr_ret( Py_None );
1210 }
1211
1212 //------------------------------------RenderData.EnablePremultiply() ----
1213 PyObject *RenderData_EnablePremultiply( BPy_RenderData * self )
1214 {
1215         self->renderContext->alphamode = R_ALPHAPREMUL;
1216         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1217
1218         return EXPP_incr_ret( Py_None );
1219 }
1220
1221 //------------------------------------RenderData.EnableKey() ------------
1222 PyObject *RenderData_EnableKey( BPy_RenderData * self )
1223 {
1224         self->renderContext->alphamode = R_ALPHAKEY;
1225         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1226
1227         return EXPP_incr_ret( Py_None );
1228 }
1229
1230 //------------------------------------RenderData.EnableShadow() ---------
1231 PyObject *RenderData_EnableShadow( BPy_RenderData * self, PyObject * args )
1232 {
1233         return M_Render_BitToggleInt( args, R_SHADOW,
1234                                       &self->renderContext->mode );
1235 }
1236
1237 //------------------------------------RenderData.EnvironmentMap() -------
1238 PyObject *RenderData_EnableEnvironmentMap( BPy_RenderData * self,
1239                                            PyObject * args )
1240 {
1241         return M_Render_BitToggleInt( args, R_ENVMAP,
1242                                       &self->renderContext->mode );
1243 }
1244
1245 //------------------------------------RenderData.EnablePanorama() -------
1246 PyObject *RenderData_EnablePanorama( BPy_RenderData * self, PyObject * args )
1247 {
1248         return M_Render_BitToggleInt( args, R_PANORAMA,
1249                                       &self->renderContext->mode );
1250 }
1251
1252 //------------------------------------RenderData.EnableRayTracing() -----
1253 PyObject *RenderData_EnableRayTracing( BPy_RenderData * self, PyObject * args )
1254 {
1255         return M_Render_BitToggleInt( args, R_RAYTRACE,
1256                                       &self->renderContext->mode );
1257 }
1258
1259 //------------------------------------RenderData.EnableRadiosityRender() 
1260 PyObject *RenderData_EnableRadiosityRender( BPy_RenderData * self,
1261                                             PyObject * args )
1262 {
1263         return M_Render_BitToggleInt( args, R_RADIO,
1264                                       &self->renderContext->mode );
1265 }
1266
1267 //------------------------------------RenderData.SetRenderWinSize() -----
1268 PyObject *RenderData_SetRenderWinSize( BPy_RenderData * self, PyObject * args )
1269 {
1270         int size;
1271
1272         if( !PyArg_ParseTuple( args, "i", &size ) )
1273                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1274                                                 "expected int" ) );
1275
1276         if( size != 25 && size != 50 && size != 75 && size != 100 )
1277                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1278                                                 "expected 25, 50, 75, or 100" ) );
1279
1280         self->renderContext->size = size;
1281         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1282
1283         return EXPP_incr_ret( Py_None );
1284 }
1285
1286 //------------------------------------RenderData.EnableFieldRendering() -
1287 PyObject *RenderData_EnableFieldRendering( BPy_RenderData * self,
1288                                            PyObject * args )
1289 {
1290         return M_Render_BitToggleInt( args, R_FIELDS,
1291                                       &self->renderContext->mode );
1292 }
1293
1294 //------------------------------------RenderData.EnableOddFieldFirst() --
1295 PyObject *RenderData_EnableOddFieldFirst( BPy_RenderData * self,
1296                                           PyObject * args )
1297 {
1298         return M_Render_BitToggleInt( args, R_ODDFIELD,
1299                                       &self->renderContext->mode );
1300 }
1301
1302 //------------------------------------RenderData.EnableFieldTimeDisable()
1303 PyObject *RenderData_EnableFieldTimeDisable( BPy_RenderData * self,
1304                                              PyObject * args )
1305 {
1306         return M_Render_BitToggleInt( args, R_FIELDSTILL,
1307                                       &self->renderContext->mode );
1308 }
1309
1310 //------------------------------------RenderData.EnableGaussFilter() ----
1311 PyObject *RenderData_EnableGaussFilter( BPy_RenderData * self,
1312                                         PyObject * args )
1313 {
1314         return M_Render_BitToggleInt( args, R_GAUSS,
1315                                       &self->renderContext->mode );
1316 }
1317
1318 //------------------------------------RenderData.EnableBorderRender() ---
1319 PyObject *RenderData_EnableBorderRender( BPy_RenderData * self,
1320                                          PyObject * args )
1321 {
1322         return M_Render_BitToggleInt( args, R_BORDER,
1323                                       &self->renderContext->mode );
1324 }
1325
1326 //------------------------------------RenderData.SetBorder() ------------
1327 PyObject *RenderData_SetBorder( BPy_RenderData * self, PyObject * args )
1328 {
1329         float xmin, ymin, xmax, ymax;
1330         int status = 0;
1331         PyObject *ob_args;
1332
1333         //left,botton | right,top coords - in that order
1334         if( PyObject_Length( args ) == 4 ) {
1335                 status = PyArg_ParseTuple( args, "ffff", &xmin, &ymin, &xmax,
1336                                            &ymax );
1337         } else {
1338                 if( PyArg_ParseTuple( args, "O", &ob_args ) ) {
1339                         if( PyList_Check( ob_args ) )
1340                                 status = PyArg_ParseTuple( args, "(ffff)",
1341                                                            &xmin, &ymin, &xmax,
1342                                                            &ymax );
1343                         else {
1344                                 status = 0;
1345                         }
1346                 } else {
1347                         status = 0;
1348                 }
1349         }
1350         if( !status )           /* parsing args failed */
1351                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1352                                                 "expected four floats" ) );
1353         if( xmin > 1.0 || xmin < 0.0 || ymin > 1.0 || ymin < 0.0 ||
1354             xmax > 1.0 || xmax < 0.0 || ymax > 1.0 || ymax < 0.0 )
1355                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1356                                                 "all values must be between 0.0 and 1.0" ) );
1357
1358         self->renderContext->border.xmin = xmin;
1359         self->renderContext->border.ymin = ymin;
1360         self->renderContext->border.xmax = xmax;
1361         self->renderContext->border.ymax = ymax;
1362
1363         EXPP_allqueue( REDRAWVIEWCAM, 1 );
1364
1365         return EXPP_incr_ret( Py_None );
1366 }
1367
1368 //------------------------------------RenderData.EnableGammaCorrection() 
1369 PyObject *RenderData_EnableGammaCorrection( BPy_RenderData * self,
1370                                             PyObject * args )
1371 {
1372         return M_Render_BitToggleInt( args, R_GAMMA,
1373                                       &self->renderContext->mode );
1374 }
1375
1376 //------------------------------------RenderData.GaussFilterSize() ------
1377 PyObject *RenderData_GaussFilterSize( BPy_RenderData * self, PyObject * args )
1378 {
1379         return M_Render_GetSetAttributeFloat( args,
1380                                               &self->renderContext->gauss,
1381                                               0.5f, 1.5f );
1382 }
1383
1384 //------------------------------------RenderData.StartFrame() -----------
1385 PyObject *RenderData_StartFrame( BPy_RenderData * self, PyObject * args )
1386 {
1387         return M_Render_GetSetAttributeShort( args, &self->renderContext->sfra,
1388                                               1, MAXFRAME );
1389 }
1390
1391 //------------------------------------RenderData.CurrentFrame() ---------
1392 PyObject *RenderData_CurrentFrame( BPy_RenderData * self, PyObject * args )
1393 {
1394         return M_Render_GetSetAttributeShort( args, &self->renderContext->cfra,
1395                                               1, MAXFRAME );
1396 }
1397
1398 //------------------------------------RenderData.EndFrame() -------------
1399 PyObject *RenderData_EndFrame( BPy_RenderData * self, PyObject * args )
1400 {
1401         return M_Render_GetSetAttributeShort( args, &self->renderContext->efra,
1402                                               1, MAXFRAME );
1403 }
1404
1405  //------------------------------------RenderData.ImageSizeX() ----------
1406 PyObject *RenderData_ImageSizeX( BPy_RenderData * self, PyObject * args )
1407 {
1408         return M_Render_GetSetAttributeShort( args, &self->renderContext->xsch,
1409                                               4, 10000 );
1410 }
1411
1412 //------------------------------------RenderData.ImageSizeY() -----------
1413 PyObject *RenderData_ImageSizeY( BPy_RenderData * self, PyObject * args )
1414 {
1415         return M_Render_GetSetAttributeShort( args, &self->renderContext->ysch,
1416                                               4, 10000 );
1417 }
1418
1419 //------------------------------------RenderData.AspectRatioX() ---------
1420 PyObject *RenderData_AspectRatioX( BPy_RenderData * self, PyObject * args )
1421 {
1422         return M_Render_GetSetAttributeShort( args, &self->renderContext->xasp,
1423                                               1, 200 );
1424 }
1425
1426 //------------------------------------RenderData.AspectRatioY() ---------
1427 PyObject *RenderData_AspectRatioY( BPy_RenderData * self, PyObject * args )
1428 {
1429         return M_Render_GetSetAttributeShort( args, &self->renderContext->yasp,
1430                                               1, 200 );
1431 }
1432
1433 //------------------------------------RenderData.SetRenderer() ----------
1434 PyObject *RenderData_SetRenderer( BPy_RenderData * self, PyObject * args )
1435 {
1436         int type;
1437
1438         if( !PyArg_ParseTuple( args, "i", &type ) )
1439                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1440                                                 "expected constant INTERN or YAFRAY" ) );
1441
1442         if( type == R_INTERN )
1443                 self->renderContext->renderer = R_INTERN;
1444         else if( type == R_YAFRAY )
1445                 self->renderContext->renderer = R_YAFRAY;
1446         else
1447                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1448                                                 "expected INTERN or YAFRAY" ) );
1449
1450         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1451         return EXPP_incr_ret( Py_None );
1452 }
1453
1454 //------------------------------------RenderData.EnableCropping() -------
1455 PyObject *RenderData_EnableCropping( BPy_RenderData * self, PyObject * args )
1456 {
1457         return M_Render_BitToggleInt( args, R_MOVIECROP,
1458                                       &self->renderContext->mode );
1459 }
1460
1461 //------------------------------------RenderData.SetImageType() ---------
1462 PyObject *RenderData_SetImageType( BPy_RenderData * self, PyObject * args )
1463 {
1464         int type;
1465
1466         if( !PyArg_ParseTuple( args, "i", &type ) )
1467                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1468                                                 "expected constant" ) );
1469
1470         if( type == R_AVIRAW )
1471                 self->renderContext->imtype = R_AVIRAW;
1472         else if( type == R_AVIJPEG )
1473                 self->renderContext->imtype = R_AVIJPEG;
1474 #ifdef _WIN32
1475         else if( type == R_AVICODEC )
1476                 self->renderContext->imtype = R_AVICODEC;
1477 #endif
1478         else if( type == R_QUICKTIME && G.have_quicktime )
1479                 self->renderContext->imtype = R_QUICKTIME;
1480         else if( type == R_TARGA )
1481                 self->renderContext->imtype = R_TARGA;
1482         else if( type == R_RAWTGA )
1483                 self->renderContext->imtype = R_RAWTGA;
1484         else if( type == R_PNG )
1485                 self->renderContext->imtype = R_PNG;
1486         else if( type == R_BMP )
1487                 self->renderContext->imtype = R_BMP;
1488         else if( type == R_JPEG90 )
1489                 self->renderContext->imtype = R_JPEG90;
1490         else if( type == R_HAMX )
1491                 self->renderContext->imtype = R_HAMX;
1492         else if( type == R_IRIS )
1493                 self->renderContext->imtype = R_IRIS;
1494         else if( type == R_IRIZ )
1495                 self->renderContext->imtype = R_IRIZ;
1496         else if( type == R_FTYPE )
1497                 self->renderContext->imtype = R_FTYPE;
1498         else
1499                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1500                                                 "unknown constant - see modules dict for help" ) );
1501
1502         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1503         return EXPP_incr_ret( Py_None );
1504 }
1505
1506 //------------------------------------RenderData.Quality() --------------
1507 PyObject *RenderData_Quality( BPy_RenderData * self, PyObject * args )
1508 {
1509         return M_Render_GetSetAttributeShort( args,
1510                                               &self->renderContext->quality,
1511                                               10, 100 );
1512 }
1513
1514 //------------------------------------RenderData.FramesPerSec() ---------
1515 PyObject *RenderData_FramesPerSec( BPy_RenderData * self, PyObject * args )
1516 {
1517         return M_Render_GetSetAttributeShort( args,
1518                                               &self->renderContext->frs_sec, 1,
1519                                               120 );
1520 }
1521
1522 //------------------------------------RenderData.EnableGrayscale() ------
1523 PyObject *RenderData_EnableGrayscale( BPy_RenderData * self )
1524 {
1525         self->renderContext->planes = R_PLANESBW;
1526         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1527
1528         return EXPP_incr_ret( Py_None );
1529 }
1530
1531 //------------------------------------RenderData.EnableRGBColor() -------
1532 PyObject *RenderData_EnableRGBColor( BPy_RenderData * self )
1533 {
1534         self->renderContext->planes = R_PLANES24;
1535         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1536
1537         return EXPP_incr_ret( Py_None );
1538 }
1539
1540 //------------------------------------RenderData.EnableRGBAColor() ------
1541 PyObject *RenderData_EnableRGBAColor( BPy_RenderData * self )
1542 {
1543         self->renderContext->planes = R_PLANES32;
1544         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1545
1546         return EXPP_incr_ret( Py_None );
1547 }
1548
1549 //------------------------------------RenderData.SizePreset() -----------
1550 PyObject *RenderData_SizePreset( BPy_RenderData * self, PyObject * args )
1551 {
1552         int type;
1553
1554         if( !PyArg_ParseTuple( args, "i", &type ) )
1555                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1556                                                 "expected constant" ) );
1557
1558         if( type == B_PR_PAL ) {
1559                 M_Render_DoSizePreset( self, 720, 576, 54, 51, 100,
1560                                        self->renderContext->xparts,
1561                                        self->renderContext->yparts, 25, 0.1,
1562                                        0.9, 0.1, 0.9 );
1563                 self->renderContext->mode &= ~R_PANORAMA;
1564                 BLI_init_rctf( &self->renderContext->safety, 0.1, 0.9, 0.1,
1565                                0.9 );
1566         } else if( type == B_PR_NTSC ) {
1567                 M_Render_DoSizePreset( self, 720, 480, 10, 11, 100, 1, 1,
1568                                        30, 0.1, 0.9, 0.1, 0.9 );
1569                 self->renderContext->mode &= ~R_PANORAMA;
1570                 BLI_init_rctf( &self->renderContext->safety, 0.1, 0.9, 0.1,
1571                                0.9 );
1572         } else if( type == B_PR_PRESET ) {
1573                 M_Render_DoSizePreset( self, 720, 576, 54, 51, 100, 1, 1,
1574                                        self->renderContext->frs_sec, 0.1, 0.9,
1575                                        0.1, 0.9 );
1576                 self->renderContext->mode = R_OSA + R_SHADOW + R_FIELDS;
1577                 self->renderContext->imtype = R_TARGA;
1578                 BLI_init_rctf( &self->renderContext->safety, 0.1, 0.9, 0.1,
1579                                0.9 );
1580         } else if( type == B_PR_PRV ) {
1581                 M_Render_DoSizePreset( self, 640, 512, 1, 1, 50, 1, 1,
1582                                        self->renderContext->frs_sec, 0.1, 0.9,
1583                                        0.1, 0.9 );
1584                 self->renderContext->mode &= ~R_PANORAMA;
1585                 BLI_init_rctf( &self->renderContext->safety, 0.1, 0.9, 0.1,
1586                                0.9 );
1587         } else if( type == B_PR_PC ) {
1588                 M_Render_DoSizePreset( self, 640, 480, 100, 100, 100, 1, 1,
1589                                        self->renderContext->frs_sec, 0.0, 1.0,
1590                                        0.0, 1.0 );
1591                 self->renderContext->mode &= ~R_PANORAMA;
1592                 BLI_init_rctf( &self->renderContext->safety, 0.0, 1.0, 0.0,
1593                                1.0 );
1594         } else if( type == B_PR_PAL169 ) {
1595                 M_Render_DoSizePreset( self, 720, 576, 64, 45, 100, 1, 1,
1596                                        25, 0.1, 0.9, 0.1, 0.9 );
1597                 self->renderContext->mode &= ~R_PANORAMA;
1598                 BLI_init_rctf( &self->renderContext->safety, 0.1, 0.9, 0.1,
1599                                0.9 );
1600         } else if( type == B_PR_PANO ) {
1601                 M_Render_DoSizePreset( self, 36, 176, 115, 100, 100, 16, 1,
1602                                        self->renderContext->frs_sec, 0.1, 0.9,
1603                                        0.1, 0.9 );
1604                 self->renderContext->mode |= R_PANORAMA;
1605                 BLI_init_rctf( &self->renderContext->safety, 0.1, 0.9, 0.1,
1606                                0.9 );
1607         } else if( type == B_PR_FULL ) {
1608                 M_Render_DoSizePreset( self, 1280, 1024, 1, 1, 100, 1, 1,
1609                                        self->renderContext->frs_sec, 0.1, 0.9,
1610                                        0.1, 0.9 );
1611                 self->renderContext->mode &= ~R_PANORAMA;
1612                 BLI_init_rctf( &self->renderContext->safety, 0.1, 0.9, 0.1,
1613                                0.9 );
1614         } else
1615                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1616                                                 "unknown constant - see modules dict for help" ) );
1617
1618         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1619         return EXPP_incr_ret( Py_None );
1620 }
1621
1622 //------------------------------------RenderData.EnableUnifiedRenderer() 
1623 PyObject *RenderData_EnableUnifiedRenderer( BPy_RenderData * self,
1624                                             PyObject * args )
1625 {
1626         return M_Render_BitToggleInt( args, R_UNIFIED,
1627                                       &self->renderContext->mode );
1628 }
1629
1630 //------------------------------------RenderData.SetYafrayGIQuality() ---
1631 PyObject *RenderData_SetYafrayGIQuality( BPy_RenderData * self,
1632                                          PyObject * args )
1633 {
1634         int type;
1635
1636         if( !PyArg_ParseTuple( args, "i", &type ) )
1637                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1638                                                 "expected constant" ) );
1639
1640         if( type == PY_NONE || type == PY_LOW ||
1641             type == PY_MEDIUM || type == PY_HIGH ||
1642             type == PY_HIGHER || type == PY_BEST ) {
1643                 self->renderContext->GIquality = type;
1644         } else
1645                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1646                                                 "unknown constant - see modules dict for help" ) );
1647
1648         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1649         return EXPP_incr_ret( Py_None );
1650 }
1651
1652 //------------------------------------RenderData.SetYafrayGIMethod() ----
1653 PyObject *RenderData_SetYafrayGIMethod( BPy_RenderData * self,
1654                                         PyObject * args )
1655 {
1656         int type;
1657
1658         if( !PyArg_ParseTuple( args, "i", &type ) )
1659                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1660                                                 "expected constant" ) );
1661
1662         if( type == PY_NONE || type == PY_SKYDOME || type == PY_FULL ) {
1663                 self->renderContext->GImethod = type;
1664         } else
1665                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1666                                                 "unknown constant - see modules dict for help" ) );
1667
1668         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1669         return EXPP_incr_ret( Py_None );
1670 }
1671
1672 //------------------------------------RenderData.YafrayGIPower() --------
1673 PyObject *RenderData_YafrayGIPower( BPy_RenderData * self, PyObject * args )
1674 {
1675         if( self->renderContext->GImethod > 0 ) {
1676                 return M_Render_GetSetAttributeFloat( args,
1677                                                       &self->renderContext->
1678                                                       GIpower, 0.01f,
1679                                                       100.00f );
1680         } else
1681                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1682                                                 "YafrayGIMethod must be set to 'SKYDOME' or 'FULL'" ) );
1683 }
1684
1685 //------------------------------------RenderData.YafrayGIDepth() --------
1686 PyObject *RenderData_YafrayGIDepth( BPy_RenderData * self, PyObject * args )
1687 {
1688         if( self->renderContext->GImethod == 2 ) {
1689                 return M_Render_GetSetAttributeInt( args,
1690                                                     &self->renderContext->
1691                                                     GIdepth, 1, 8 );
1692         } else
1693                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1694                                                 "YafrayGIMethod must be set to 'FULL'" ) );
1695 }
1696
1697 //------------------------------------RenderData.afrayGICDepth() --------
1698 PyObject *RenderData_YafrayGICDepth( BPy_RenderData * self, PyObject * args )
1699 {
1700         if( self->renderContext->GImethod == 2 ) {
1701                 return M_Render_GetSetAttributeInt( args,
1702                                                     &self->renderContext->
1703                                                     GIcausdepth, 1, 8 );
1704         } else
1705                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1706                                                 "YafrayGIMethod must be set to 'FULL'" ) );
1707 }
1708
1709 //------------------------------------RenderData.EnableYafrayGICache() --
1710 PyObject *RenderData_EnableYafrayGICache( BPy_RenderData * self,
1711                                           PyObject * args )
1712 {
1713         if( self->renderContext->GImethod == 2 ) {
1714                 return M_Render_BitToggleShort( args, 1,
1715                                                 &self->renderContext->
1716                                                 GIcache );
1717         } else
1718                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1719                                                 "YafrayGIMethod must be set to 'FULL'" ) );
1720 }
1721
1722 //------------------------------------RenderData.EnableYafrayGIPhotons() 
1723 PyObject *RenderData_EnableYafrayGIPhotons( BPy_RenderData * self,
1724                                             PyObject * args )
1725 {
1726         if( self->renderContext->GImethod == 2 ) {
1727                 return M_Render_BitToggleShort( args, 1,
1728                                                 &self->renderContext->
1729                                                 GIphotons );;
1730         } else
1731                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1732                                                 "YafrayGIMethod must be set to 'FULL'" ) );
1733 }
1734
1735 //------------------------------------RenderData.YafrayGIPhotonCount() --
1736 PyObject *RenderData_YafrayGIPhotonCount( BPy_RenderData * self,
1737                                           PyObject * args )
1738 {
1739         if( self->renderContext->GImethod == 2
1740             && self->renderContext->GIphotons == 1 ) {
1741                 return M_Render_GetSetAttributeInt( args,
1742                                                     &self->renderContext->
1743                                                     GIphotoncount, 0,
1744                                                     10000000 );
1745         } else
1746                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1747                                                 "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled\n" ) );
1748 }
1749
1750 //------------------------------------RenderData.YafrayGIPhotonRadius() -
1751 PyObject *RenderData_YafrayGIPhotonRadius( BPy_RenderData * self,
1752                                            PyObject * args )
1753 {
1754         if( self->renderContext->GImethod == 2
1755             && self->renderContext->GIphotons == 1 ) {
1756                 return M_Render_GetSetAttributeFloat( args,
1757                                                       &self->renderContext->
1758                                                       GIphotonradius, 0.00001f,
1759                                                       100.0f );
1760         } else
1761                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1762                                                 "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled\n" ) );
1763 }
1764
1765 //------------------------------------RenderData.YafrayGIPhotonMixCount()
1766 PyObject *RenderData_YafrayGIPhotonMixCount( BPy_RenderData * self,
1767                                              PyObject * args )
1768 {
1769         if( self->renderContext->GImethod == 2
1770             && self->renderContext->GIphotons == 1 ) {
1771                 return M_Render_GetSetAttributeInt( args,
1772                                                     &self->renderContext->
1773                                                     GImixphotons, 0, 1000 );
1774         } else
1775                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1776                                                 "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled\n" ) );
1777 }
1778
1779 //--------------------------RenderData.EnableYafrayGITunePhotons() ------
1780 PyObject *RenderData_EnableYafrayGITunePhotons( BPy_RenderData * self,
1781                                                 PyObject * args )
1782 {
1783         if( self->renderContext->GImethod == 2
1784             && self->renderContext->GIphotons == 1 ) {
1785                 return M_Render_BitToggleShort( args, 1,
1786                                                 &self->renderContext->
1787                                                 GIdirect );;
1788         } else
1789                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1790                                                 "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) );
1791 }
1792
1793 //------------------------------------RenderData.YafrayGIShadowQuality() 
1794 PyObject *RenderData_YafrayGIShadowQuality( BPy_RenderData * self,
1795                                             PyObject * args )
1796 {
1797         if( self->renderContext->GImethod == 2
1798             && self->renderContext->GIcache == 1 ) {
1799                 return M_Render_GetSetAttributeFloat( args,
1800                                                       &self->renderContext->
1801                                                       GIshadowquality, 0.01f,
1802                                                       1.0f );
1803         } else
1804                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1805                                                 "YafrayGIMethod must be set to 'FULL' and GICache must be enabled\n" ) );
1806 }
1807
1808 //------------------------------------RenderData.YafrayGIPixelsPerSample()
1809 PyObject *RenderData_YafrayGIPixelsPerSample( BPy_RenderData * self,
1810                                               PyObject * args )
1811 {
1812         if( self->renderContext->GImethod == 2
1813             && self->renderContext->GIcache == 1 ) {
1814                 return M_Render_GetSetAttributeInt( args,
1815                                                     &self->renderContext->
1816                                                     GIpixelspersample, 1, 50 );
1817         } else
1818                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1819                                                 "YafrayGIMethod must be set to 'FULL' and GICache must be enabled\n" ) );
1820 }
1821
1822 //------------------------------------RenderData.YafrayGIRefinement() ----
1823 PyObject *RenderData_YafrayGIRefinement( BPy_RenderData * self,
1824                                          PyObject * args )
1825 {
1826         if( self->renderContext->GImethod == 2
1827             && self->renderContext->GIcache == 1 ) {
1828                 return M_Render_GetSetAttributeFloat( args,
1829                                                       &self->renderContext->
1830                                                       GIrefinement, 0.001f,
1831                                                       1.0f );
1832         } else
1833                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1834                                                 "YafrayGIMethod must be set to 'FULL' and GICache must be enabled\n" ) );
1835 }
1836
1837 //------------------------------------RenderData.YafrayRayBias() ---------
1838 PyObject *RenderData_YafrayRayBias( BPy_RenderData * self, PyObject * args )
1839 {
1840         return M_Render_GetSetAttributeFloat( args,
1841                                               &self->renderContext->YF_raybias,
1842                                               0.0f, 10.0f );
1843 }
1844
1845 //------------------------------------RenderData.YafrayRayDepth() --------
1846 PyObject *RenderData_YafrayRayDepth( BPy_RenderData * self, PyObject * args )
1847 {
1848         return M_Render_GetSetAttributeInt( args,
1849                                             &self->renderContext->YF_raydepth,
1850                                             1, 80 );
1851 }
1852
1853 //------------------------------------RenderData.YafrayGamma() -----------
1854 PyObject *RenderData_YafrayGamma( BPy_RenderData * self, PyObject * args )
1855 {
1856         return M_Render_GetSetAttributeFloat( args,
1857                                               &self->renderContext->YF_gamma,
1858                                               0.001f, 5.0f );
1859 }
1860
1861 //------------------------------------RenderData.YafrayExposure() --------
1862 PyObject *RenderData_YafrayExposure( BPy_RenderData * self, PyObject * args )
1863 {
1864         return M_Render_GetSetAttributeFloat( args,
1865                                               &self->renderContext->
1866                                               YF_exposure, 0.0f, 10.0f );
1867 }
1868
1869 //------------------------------------RenderData.YafrayProcessorCount() --
1870 PyObject *RenderData_YafrayProcessorCount( BPy_RenderData * self,
1871                                            PyObject * args )
1872 {
1873         return M_Render_GetSetAttributeInt( args,
1874                                             &self->renderContext->YF_numprocs,
1875                                             1, 8 );
1876 }
1877
1878 //------------------------------------RenderData.EnableGameFrameStretch() -----------------------------------------------------------
1879 PyObject *RenderData_EnableGameFrameStretch( BPy_RenderData * self )
1880 {
1881         self->scene->framing.type = SCE_GAMEFRAMING_SCALE;
1882         return EXPP_incr_ret( Py_None );
1883 }
1884
1885 //------------------------------------RenderData.EnableGameFrameExpose() -
1886 PyObject *RenderData_EnableGameFrameExpose( BPy_RenderData * self )
1887 {
1888         self->scene->framing.type = SCE_GAMEFRAMING_EXTEND;
1889         return EXPP_incr_ret( Py_None );
1890 }
1891
1892 //------------------------------------RenderData.EnableGameFrameBars() ---
1893 PyObject *RenderData_EnableGameFrameBars( BPy_RenderData * self )
1894 {
1895         self->scene->framing.type = SCE_GAMEFRAMING_BARS;
1896         return EXPP_incr_ret( Py_None );
1897 }
1898
1899 //------------------------------------RenderData.SetGameFrameColor() -----
1900 PyObject *RenderData_SetGameFrameColor( BPy_RenderData * self,
1901                                         PyObject * args )
1902 {
1903         float red = 0.0f;
1904         float green = 0.0f;
1905         float blue = 0.0f;
1906
1907         if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) )
1908                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1909                                                 "expected three floats" ) );
1910
1911         if( red < 0 || red > 1 )
1912                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1913                                                 "value out of range 0.000 - 1.000 (red)" ) );
1914         if( green < 0 || green > 1 )
1915                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1916                                                 "value out of range 0.000 - 1.000 (green)" ) );
1917         if( blue < 0 || blue > 1 )
1918                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1919                                                 "value out of range 0.000 - 1.000 (blue)" ) );
1920
1921         self->scene->framing.col[0] = red;
1922         self->scene->framing.col[1] = green;
1923         self->scene->framing.col[2] = blue;
1924
1925         return EXPP_incr_ret( Py_None );
1926 }
1927
1928 //------------------------------------RenderData.GetGameFrameColor() -----
1929 PyObject *RenderData_GetGameFrameColor( BPy_RenderData * self )
1930 {
1931         char rgb[24];
1932
1933         sprintf( rgb, "[%.3f,%.3f,%.3f]\n", self->scene->framing.col[0],
1934                  self->scene->framing.col[1], self->scene->framing.col[2] );
1935         return PyString_FromString( rgb );
1936 }
1937
1938 //------------------------------------RenderData.GammaLevel() ------------
1939 PyObject *RenderData_GammaLevel( BPy_RenderData * self, PyObject * args )
1940 {
1941         if( self->renderContext->mode & R_UNIFIED ) {
1942                 return M_Render_GetSetAttributeFloat( args,
1943                                                       &self->renderContext->
1944                                                       gamma, 0.2f, 5.0f );
1945         } else
1946                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1947                                                 "Unified Render must be enabled" ) );
1948 }
1949
1950 //------------------------------------RenderData.PostProcessAdd() --------
1951 PyObject *RenderData_PostProcessAdd( BPy_RenderData * self, PyObject * args )
1952 {
1953         if( self->renderContext->mode & R_UNIFIED ) {
1954                 return M_Render_GetSetAttributeFloat( args,
1955                                                       &self->renderContext->
1956                                                       postadd, -1.0f, 1.0f );
1957         } else
1958                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1959                                                 "Unified Render must be enabled" ) );
1960 }
1961
1962 //------------------------------------RenderData.PostProcessMultiply() ---
1963 PyObject *RenderData_PostProcessMultiply( BPy_RenderData * self,
1964                                           PyObject * args )
1965 {
1966         if( self->renderContext->mode & R_UNIFIED ) {
1967                 return M_Render_GetSetAttributeFloat( args,
1968                                                       &self->renderContext->
1969                                                       postmul, 0.01f, 4.0f );
1970         } else
1971                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1972                                                 "Unified Render must be enabled" ) );
1973 }
1974
1975 //------------------------------------RenderData.PostProcessGamma() ------
1976 PyObject *RenderData_PostProcessGamma( BPy_RenderData * self, PyObject * args )
1977 {
1978         if( self->renderContext->mode & R_UNIFIED ) {
1979                 return M_Render_GetSetAttributeFloat( args,
1980                                                       &self->renderContext->
1981                                                       postgamma, 0.2f, 2.0f );
1982         } else
1983                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1984                                                 "Unified Render must be enabled" ) );
1985 }
1986
1987 //------------------------------------RenderData.SGIMaxsize() ------------
1988 PyObject *RenderData_SGIMaxsize( BPy_RenderData * self, PyObject * args )
1989 {
1990 #ifdef __sgi
1991         return M_Render_GetSetAttributeShort( args,
1992                                               &self->renderContext->maximsize,
1993                                               0, 500 );
1994 #else
1995         return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1996                                         "SGI is not defined on this machine" ) );
1997 #endif
1998 }
1999
2000 //------------------------------------RenderData.EnableSGICosmo() --------
2001 PyObject *RenderData_EnableSGICosmo( BPy_RenderData * self, PyObject * args )
2002 {
2003 #ifdef __sgi
2004         return M_Render_BitToggleInt( args, R_COSMO,
2005                                       &self->renderContext->mode );
2006 #else
2007         return ( EXPP_ReturnPyObjError( PyExc_StandardError,
2008                                         "SGI is not defined on this machine" ) );
2009 #endif
2010 }
2011
2012 //------------------------------------RenderData.OldMapValue() -----------
2013 PyObject *RenderData_OldMapValue( BPy_RenderData * self, PyObject * args )
2014 {
2015         return M_Render_GetSetAttributeShort( args,
2016                                               &self->renderContext->framapto,
2017                                               1, 900 );
2018 }
2019
2020 //------------------------------------RenderData.NewMapValue() -----------
2021 PyObject *RenderData_NewMapValue( BPy_RenderData * self, PyObject * args )
2022 {
2023         return M_Render_GetSetAttributeShort( args,
2024                                               &self->renderContext->images, 1,
2025                                               900 );
2026 }