[ #4786 ] if space in the Application path name, system() doesn't work on some platforms
[blender.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 struct View3D; /* keep me up here */
33
34 #include "sceneRender.h" /*This must come first*/
35
36 #include "DNA_image_types.h"
37
38 #include "BKE_image.h"
39 #include "BKE_global.h"
40 #include "BKE_screen.h"
41 #include "BKE_scene.h"
42
43 #include "BIF_drawscene.h"
44 #include "BIF_renderwin.h"
45 #include "BIF_writeimage.h"
46
47 #include "BLI_blenlib.h"
48
49 #include "RE_pipeline.h"
50
51 #include "mydevice.h"
52 #include "butspace.h"
53 #include "blendef.h"
54 #include "gen_utils.h"
55
56 #include "Scene.h"
57
58 /* local defines */
59 #define PY_NONE         0
60 #define PY_LOW          1
61 #define PY_MEDIUM       2
62 #define PY_HIGH         3
63 #define PY_HIGHER       4
64 #define PY_BEST         5
65 #define PY_SKYDOME      1
66 #define PY_FULL  2
67
68 enum rend_constants {
69         EXPP_RENDER_ATTR_XPARTS = 0,
70         EXPP_RENDER_ATTR_YPARTS,
71         EXPP_RENDER_ATTR_ASPECTX,
72         EXPP_RENDER_ATTR_ASPECTY,
73         EXPP_RENDER_ATTR_CFRAME,
74         EXPP_RENDER_ATTR_SFRAME,
75         EXPP_RENDER_ATTR_EFRAME,
76         EXPP_RENDER_ATTR_FPS,
77         EXPP_RENDER_ATTR_SIZEX,
78         EXPP_RENDER_ATTR_SIZEY,
79         EXPP_RENDER_ATTR_GAUSSFILTER,
80         EXPP_RENDER_ATTR_MBLURFACTOR,
81 };
82
83 #define EXPP_RENDER_ATTR_CFRA                 2
84 #define EXPP_RENDER_ATTR_ANTISHIFT            3
85 #define EXPP_RENDER_ATTR_EDGEINT              4
86 #define EXPP_RENDER_ATTR_EFRA                 5
87 #define EXPP_RENDER_ATTR_QUALITY             11
88 #define EXPP_RENDER_ATTR_GAUSS               13
89 #define EXPP_RENDER_ATTR_BLURFAC             14
90
91 #define EXPP_RENDER_ATTR_YF_EXPOSURE         20
92 #define EXPP_RENDER_ATTR_YF_GAMMA            21
93 #define EXPP_RENDER_ATTR_YF_GIDEPTH          22
94 #define EXPP_RENDER_ATTR_YF_GICDEPTH         23
95 #define EXPP_RENDER_ATTR_YF_GIPHOTONCOUNT    24
96 #define EXPP_RENDER_ATTR_YF_GIPHOTONMIXCOUNT 25
97 #define EXPP_RENDER_ATTR_YF_GIPHOTONRADIUS   26
98 #define EXPP_RENDER_ATTR_YF_GIPIXPERSAMPLE   27
99 #define EXPP_RENDER_ATTR_YF_GIPOWER          28
100 #define EXPP_RENDER_ATTR_YF_GIREFINE         29
101 #define EXPP_RENDER_ATTR_YF_GISHADOWQUAL     30
102 #define EXPP_RENDER_ATTR_YF_RAYBIAS          31
103 #define EXPP_RENDER_ATTR_YF_PROCCOUNT        32
104 #define EXPP_RENDER_ATTR_YF_RAYDEPTH         33
105 #define EXPP_RENDER_ATTR_YF_GIMETHOD         34
106 #define EXPP_RENDER_ATTR_YF_GIQUALITY        35
107
108
109 /* Render doc strings */
110 static char M_Render_doc[] = "The Blender Render module";
111
112 /* deprecated callbacks */
113 static PyObject *RenderData_SetRenderPath( BPy_RenderData *self,
114                 PyObject *args );
115 static PyObject *RenderData_SetBackbufPath( BPy_RenderData *self,
116                 PyObject *args );
117 static PyObject *RenderData_SetFtypePath( BPy_RenderData *self,
118                 PyObject *args );
119 static PyObject *RenderData_SetOversamplingLevel( BPy_RenderData * self,
120                 PyObject * args );
121 static PyObject *RenderData_SetRenderWinSize( BPy_RenderData * self,
122                 PyObject * args );
123 static PyObject *RenderData_SetBorder( BPy_RenderData * self,
124                 PyObject * args );
125 static PyObject *RenderData_SetRenderer( BPy_RenderData * self,
126                 PyObject * args );
127 static PyObject *RenderData_SetImageType( BPy_RenderData * self,
128                 PyObject * args );
129 static PyObject *RenderData_Render( BPy_RenderData * self );
130
131 /* BPy_RenderData Internal Protocols */
132
133 static void RenderData_dealloc( BPy_RenderData * self )
134 {
135         PyObject_DEL( self );
136 }
137
138 static PyObject *RenderData_repr( BPy_RenderData * self )
139 {
140         if( self->renderContext )
141                 return PyString_FromFormat( "[RenderData \"%s\"]",
142                                             self->scene->id.name + 2 );
143         else
144                 return PyString_FromString( "NULL" );
145 }
146
147 /***************************************************************************/
148 /* local utility routines for manipulating data                            */
149 /***************************************************************************/
150 static PyObject *M_Render_BitToggleInt( PyObject * args, int setting,
151                                         int *structure )
152 {
153         int flag;
154
155         if( !PyArg_ParseTuple( args, "i", &flag ) )
156                 return ( EXPP_ReturnPyObjError
157                          ( PyExc_AttributeError,
158                            "expected TRUE or FALSE (1 or 0)" ) );
159
160         if( flag < 0 || flag > 1 )
161                 return ( EXPP_ReturnPyObjError
162                          ( PyExc_AttributeError,
163                            "expected TRUE or FALSE (1 or 0)" ) );
164
165         if( flag )
166                 *structure |= setting;
167         else
168                 *structure &= ~setting;
169         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
170
171         return EXPP_incr_ret( Py_None );
172
173 }
174
175 static PyObject *M_Render_BitToggleShort( PyObject * args, short setting,
176                                           short *structure )
177 {
178         int flag;
179
180         if( !PyArg_ParseTuple( args, "i", &flag ) )
181                 return ( EXPP_ReturnPyObjError
182                          ( PyExc_AttributeError,
183                            "expected TRUE or FALSE (1 or 0)" ) );
184
185         if( flag < 0 || flag > 1 )
186                 return ( EXPP_ReturnPyObjError
187                          ( PyExc_AttributeError,
188                            "expected TRUE or FALSE (1 or 0)" ) );
189
190         if( flag )
191                 *structure |= setting;
192         else
193                 *structure &= ~setting;
194         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
195
196         return EXPP_incr_ret( Py_None );
197
198 }
199
200 static PyObject *M_Render_GetSetAttributeFloat( PyObject * args,
201                                                 float *structure, float min,
202                                                 float max )
203 {
204         float property = -10.0f;
205         char error[48];
206
207         if( !PyArg_ParseTuple( args, "|f", &property ) )
208                 return ( EXPP_ReturnPyObjError
209                          ( PyExc_AttributeError, "expected float" ) );
210
211         if( property != -10.0f ) {
212                 if( property < min || property > max ) {
213                         sprintf( error, "out of range - expected %f to %f",
214                                  min, max );
215                         return ( EXPP_ReturnPyObjError
216                                  ( PyExc_AttributeError, error ) );
217                 }
218
219                 *structure = property;
220                 EXPP_allqueue( REDRAWBUTSSCENE, 0 );
221                 return EXPP_incr_ret( Py_None );
222         } else
223                 return Py_BuildValue( "f", *structure );
224 }
225
226 static PyObject *M_Render_GetSetAttributeShort( PyObject * args,
227                                                 short *structure, int min,
228                                                 int max )
229 {
230         short property = -10;
231         char error[48];
232
233         if( !PyArg_ParseTuple( args, "|h", &property ) )
234                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
235                                                 "expected int" ) );
236
237         if( property != -10 ) {
238                 if( property < min || property > max ) {
239                         sprintf( error, "out of range - expected %d to %d",
240                                  min, max );
241                         return ( EXPP_ReturnPyObjError
242                                  ( PyExc_AttributeError, error ) );
243                 }
244
245                 *structure = property;
246                 EXPP_allqueue( REDRAWBUTSSCENE, 0 );
247                 return EXPP_incr_ret( Py_None );
248         } else
249                 return Py_BuildValue( "h", *structure );
250 }
251
252 static PyObject *M_Render_GetSetAttributeInt( PyObject * args, int *structure,
253                                               int min, int max )
254 {
255         int property = -10;
256         char error[48];
257
258         if( !PyArg_ParseTuple( args, "|i", &property ) )
259                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
260                                                 "expected int" ) );
261
262         if( property != -10 ) {
263                 if( property < min || property > max ) {
264                         sprintf( error, "out of range - expected %d to %d",
265                                  min, max );
266                         return ( EXPP_ReturnPyObjError
267                                  ( PyExc_AttributeError, error ) );
268                 }
269
270                 *structure = property;
271                 EXPP_allqueue( REDRAWBUTSSCENE, 0 );
272                 return EXPP_incr_ret( Py_None );
273         } else
274                 return Py_BuildValue( "i", *structure );
275 }
276
277
278 static void M_Render_DoSizePreset( BPy_RenderData * self, short xsch,
279                                    short ysch, short xasp, short yasp,
280                                    short size, short xparts, short yparts,
281                                    short frames, float a, float b, float c,
282                                    float d )
283 {
284         self->renderContext->xsch = xsch;
285         self->renderContext->ysch = ysch;
286         self->renderContext->xasp = xasp;
287         self->renderContext->yasp = yasp;
288         self->renderContext->size = size;
289         self->renderContext->frs_sec = frames;
290         self->renderContext->xparts = xparts;
291         self->renderContext->yparts = yparts;
292
293         BLI_init_rctf( &self->renderContext->safety, a, b, c, d );
294         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
295         EXPP_allqueue( REDRAWVIEWCAM, 0 );
296 }
297
298 /***************************************************************************/
299 /* Render Module Function Definitions                                      */
300 /***************************************************************************/
301
302 PyObject *M_Render_CloseRenderWindow( PyObject * self )
303 {
304         BIF_close_render_display(  );
305         return EXPP_incr_ret( Py_None );
306 }
307
308 PyObject *M_Render_SetRenderWinPos( PyObject * self, PyObject * args )
309 {
310         PyObject *list = NULL;
311         char *loc = NULL;
312         int x;
313
314         if( !PyArg_ParseTuple( args, "O!", &PyList_Type, &list ) )
315                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
316                                                 "expected a list" ) );
317
318         G.winpos = 0;
319         for( x = 0; x < PyList_Size( list ); x++ ) {
320                 if( !PyArg_Parse( PyList_GetItem( list, x ), "s", &loc ) ) {
321                         return EXPP_ReturnPyObjError( PyExc_TypeError,
322                                                       "python list not parseable" );
323                 }
324                 if( strcmp( loc, "SW" ) == 0 || strcmp( loc, "sw" ) == 0 )
325                         G.winpos |= 1;
326                 else if( strcmp( loc, "S" ) == 0 || strcmp( loc, "s" ) == 0 )
327                         G.winpos |= 2;
328                 else if( strcmp( loc, "SE" ) == 0 || strcmp( loc, "se" ) == 0 )
329                         G.winpos |= 4;
330                 else if( strcmp( loc, "W" ) == 0 || strcmp( loc, "w" ) == 0 )
331                         G.winpos |= 8;
332                 else if( strcmp( loc, "C" ) == 0 || strcmp( loc, "c" ) == 0 )
333                         G.winpos |= 16;
334                 else if( strcmp( loc, "E" ) == 0 || strcmp( loc, "e" ) == 0 )
335                         G.winpos |= 32;
336                 else if( strcmp( loc, "NW" ) == 0 || strcmp( loc, "nw" ) == 0 )
337                         G.winpos |= 64;
338                 else if( strcmp( loc, "N" ) == 0 || strcmp( loc, "n" ) == 0 )
339                         G.winpos |= 128;
340                 else if( strcmp( loc, "NE" ) == 0 || strcmp( loc, "ne" ) == 0 )
341                         G.winpos |= 256;
342                 else
343                         return EXPP_ReturnPyObjError( PyExc_AttributeError,
344                                                       "list contains unknown string" );
345         }
346         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
347
348         return EXPP_incr_ret( Py_None );
349 }
350
351 PyObject *M_Render_EnableDispView( PyObject * self )
352 {
353         G.displaymode = R_DISPLAYIMAGE;
354         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
355
356         return EXPP_incr_ret( Py_None );
357 }
358
359 PyObject *M_Render_EnableDispWin( PyObject * self )
360 {
361         G.displaymode = R_DISPLAYWIN;
362         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
363
364         return EXPP_incr_ret( Py_None );
365 }
366
367
368 /***************************************************************************/
369 /* BPy_RenderData Function Definitions                                     */
370 /***************************************************************************/
371
372 PyObject *RenderData_Render( BPy_RenderData * self )
373 {
374         Scene *oldsce;
375
376         if (!G.background) {
377                 oldsce = G.scene;
378                 set_scene( self->scene );
379                 BIF_do_render( 0 );
380                 set_scene( oldsce );
381         }
382
383         else { /* background mode (blender -b file.blend -P script) */
384                 Render *re= RE_NewRender("Render");
385
386                 int end_frame = G.scene->r.efra; /* is of type short currently */
387
388                 if (G.scene != self->scene)
389                         return EXPP_ReturnPyObjError (PyExc_RuntimeError,
390                                 "scene to render in bg mode must be the active scene");
391
392                 G.scene->r.efra = G.scene->r.sfra;
393
394                 RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
395
396                 G.scene->r.efra = (short)end_frame;
397         }
398
399         return EXPP_incr_ret( Py_None );
400 }
401
402 /* 
403  * This will save the rendered image to an output file path already defined.
404  */
405 PyObject *RenderData_SaveRenderedImage ( BPy_RenderData * self, PyObject *args )
406 {
407         char dir[FILE_MAXDIR * 2], str[FILE_MAXFILE * 2];
408         char *name_str, filepath[FILE_MAXDIR+FILE_MAXFILE];
409         RenderResult *rr = NULL;
410         int zbuff;
411         
412         if( !PyArg_ParseTuple( args, "s|i", &name_str, &zbuff ) )
413                 return EXPP_ReturnPyObjError( PyExc_TypeError,
414                                 "expected a filename (string) and optional int" );
415
416         if( strlen(self->renderContext->pic) + strlen(name_str)
417                         >= sizeof(filepath) )
418                 return EXPP_ReturnPyObjError( PyExc_ValueError,
419                                 "full filename too long" );
420
421         if (zbuff !=0   ) zbuff = 1; /*required 1/0 */ /* removed! (ton) */
422
423         BLI_strncpy( filepath, self->renderContext->pic, sizeof(filepath) );
424         strcat(filepath, name_str);
425
426         rr = RE_GetResult(RE_GetRender(G.scene->id.name));
427         if(!rr) {
428                 return EXPP_ReturnPyObjError (PyExc_ValueError, "No image rendered");
429         } else {
430                 if(G.ima[0]==0) {
431                         strcpy(dir, G.sce);
432                         BLI_splitdirstring(dir, str);
433                         strcpy(G.ima, dir);
434                 }
435                 BIF_save_rendered_image(filepath);
436         }
437         return EXPP_incr_ret(Py_None);
438 }
439
440 PyObject *RenderData_RenderAnim( BPy_RenderData * self )
441 {
442         Scene *oldsce;
443
444         if (!G.background) {
445                 oldsce = G.scene;
446                 set_scene( self->scene );
447                 BIF_do_render( 1 );
448                 set_scene( oldsce );
449         }
450         else { /* background mode (blender -b file.blend -P script) */
451                 Render *re= RE_NewRender("Render");
452                 
453                 if (G.scene != self->scene)
454                         return EXPP_ReturnPyObjError (PyExc_RuntimeError,
455                                 "scene to render in bg mode must be the active scene");
456
457                 if (G.scene->r.sfra > G.scene->r.efra)
458                         return EXPP_ReturnPyObjError (PyExc_RuntimeError,
459                                 "start frame must be less or equal to end frame");
460                 
461                 RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
462         }
463         return EXPP_incr_ret( Py_None );
464 }
465
466 PyObject *RenderData_Play( BPy_RenderData * self )
467 {
468         char file[FILE_MAXDIR + FILE_MAXFILE];
469         extern char bprogname[];
470         char str[FILE_MAXDIR + FILE_MAXFILE];
471         int pos[2], size[2];
472         char txt[64];
473
474 #ifdef WITH_QUICKTIME
475         if( self->renderContext->imtype == R_QUICKTIME ) {
476
477                 strcpy( file, self->renderContext->pic );
478                 BLI_convertstringcode( file, (char *) self->scene,
479                                        self->renderContext->cfra );
480                 BLI_make_existing_file( file );
481                 if( BLI_strcasecmp( file + strlen( file ) - 4, ".mov" ) ) {
482                         sprintf( txt, "%04d_%04d.mov",
483                                  ( self->renderContext->sfra ),
484                                  ( self->renderContext->efra ) );
485                         strcat( file, txt );
486                 }
487         } else
488 #endif
489         {
490
491                 strcpy( file, self->renderContext->pic );
492                 BLI_convertstringcode( file, G.sce,
493                                        self->renderContext->cfra );
494                 BLI_make_existing_file( file );
495                 if( BLI_strcasecmp( file + strlen( file ) - 4, ".avi" ) ) {
496                         sprintf( txt, "%04d_%04d.avi",
497                                  ( self->renderContext->sfra ),
498                                  ( self->renderContext->efra ) );
499                         strcat( file, txt );
500                 }
501         }
502         if( BLI_exist( file ) ) {
503                 calc_renderwin_rectangle(640, 480, G.winpos, pos, size);
504                 sprintf( str, "%s -a -p %d %d \"%s\"", bprogname, pos[0],
505                          pos[1], file );
506                 system( str );
507         } else {
508                 BKE_makepicstring( file, G.scene->r.pic, self->renderContext->sfra, G.scene->r.imtype);
509                 if( BLI_exist( file ) ) {
510                         calc_renderwin_rectangle(640, 480, G.winpos, pos, size);
511 #ifdef WIN32
512                         sprintf( str, "%s -a -p %d %d \"%s\"", bprogname,
513                                  pos[0], pos[1], file );
514 #else
515                         sprintf( str, "\"%s\" -a -p %d %d \"%s\"", bprogname,
516                                  pos[0], pos[1], file );
517 #endif
518                         system( str );
519                 } else
520                         sprintf( "Can't find image: %s", file );
521         }
522
523         return EXPP_incr_ret( Py_None );
524 }
525
526 PyObject *RenderData_EnableBackbuf( BPy_RenderData * self, PyObject * args )
527 {
528         return M_Render_BitToggleShort( args, 1,
529                                         &self->renderContext->bufflag );
530 }
531
532 PyObject *RenderData_EnableThreads( BPy_RenderData * self, PyObject * args )
533 {
534         return M_Render_BitToggleInt( args, R_THREADS,
535                                         &self->renderContext->mode );
536 }
537
538 PyObject *RenderData_EnableExtensions( BPy_RenderData * self, PyObject * args )
539 {
540         return M_Render_BitToggleShort( args, R_EXTENSION,
541                                         &self->renderContext->scemode );
542 }
543
544 PyObject *RenderData_EnableSequencer( BPy_RenderData * self, PyObject * args )
545 {
546         return M_Render_BitToggleShort( args, R_DOSEQ,
547                                         &self->renderContext->scemode );
548 }
549
550 PyObject *RenderData_EnableRenderDaemon( BPy_RenderData * self,
551                                          PyObject * args )
552 {
553         return M_Render_BitToggleShort( args, R_BG_RENDER,
554                                         &self->renderContext->scemode );
555 }
556
557 PyObject *RenderData_EnableToonShading( BPy_RenderData * self,
558                                         PyObject * args )
559 {
560         return M_Render_BitToggleInt( args, R_EDGE,
561                                       &self->renderContext->mode );
562 }
563
564 PyObject *RenderData_EdgeIntensity( BPy_RenderData * self, PyObject * args )
565 {
566         return M_Render_GetSetAttributeShort( args,
567                                               &self->renderContext->edgeint, 0,
568                                               255 );
569 }
570
571 PyObject *RenderData_SetEdgeColor( BPy_RenderData * self, PyObject * args )
572 {
573         float red, green, blue;
574
575         if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) )
576                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
577                                                 "expected three floats" ) );
578
579         if( red < 0 || red > 1 )
580                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
581                                                 "value out of range 0.000 - 1.000 (red)" ) );
582         if( green < 0 || green > 1 )
583                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
584                                                 "value out of range 0.000 - 1.000 (green)" ) );
585         if( blue < 0 || blue > 1 )
586                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
587                                                 "value out of range 0.000 - 1.000 (blue)" ) );
588
589         self->renderContext->edgeR = red;
590         self->renderContext->edgeG = green;
591         self->renderContext->edgeB = blue;
592
593         return EXPP_incr_ret( Py_None );
594 }
595
596 PyObject *RenderData_GetEdgeColor( BPy_RenderData * self )
597 {
598         char rgb[24];
599
600         sprintf( rgb, "[%.3f,%.3f,%.3f]", self->renderContext->edgeR,
601                  self->renderContext->edgeG, self->renderContext->edgeB );
602         return PyString_FromString( rgb );
603 }
604
605 PyObject *RenderData_EnableOversampling( BPy_RenderData * self,
606                                          PyObject * args )
607 {
608         return M_Render_BitToggleInt( args, R_OSA,
609                                       &self->renderContext->mode );
610 }
611
612 static int RenderData_setOSALevel( BPy_RenderData * self,
613                 PyObject * value )
614 {
615         int level;
616
617         if( !PyInt_CheckExact( value ) )
618                 return EXPP_ReturnIntError( PyExc_TypeError,
619                                 "expected int argument" );
620
621         level = PyInt_AsLong( value );
622         if( level != 5 && level != 8 && level != 11 && level != 16 )
623                 return EXPP_ReturnIntError( PyExc_ValueError,
624                                 "expected 5, 8, 11, or 16" );
625
626         self->renderContext->osa = (short)level;
627         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
628
629         return 0;
630 }
631
632 PyObject *RenderData_EnableMotionBlur( BPy_RenderData * self, PyObject * args )
633 {
634         return M_Render_BitToggleInt( args, R_MBLUR,
635                                       &self->renderContext->mode );
636 }
637
638 PyObject *RenderData_MotionBlurLevel( BPy_RenderData * self, PyObject * args )
639 {
640         return M_Render_GetSetAttributeFloat( args,
641                                               &self->renderContext->blurfac,
642                                               0.01f, 5.0f );
643 }
644
645 PyObject *RenderData_PartsX( BPy_RenderData * self, PyObject * args )
646 {
647         return M_Render_GetSetAttributeShort( args,
648                                               &self->renderContext->xparts, 1,
649                                               512 );
650 }
651
652 PyObject *RenderData_PartsY( BPy_RenderData * self, PyObject * args )
653 {
654         return M_Render_GetSetAttributeShort( args,
655                                               &self->renderContext->yparts, 1,
656                                               64 );
657 }
658
659 PyObject *RenderData_EnableSky( BPy_RenderData * self )
660 {
661         self->renderContext->alphamode = R_ADDSKY;
662         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
663
664         return EXPP_incr_ret( Py_None );
665 }
666
667 PyObject *RenderData_EnablePremultiply( BPy_RenderData * self )
668 {
669         self->renderContext->alphamode = R_ALPHAPREMUL;
670         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
671
672         return EXPP_incr_ret( Py_None );
673 }
674
675 PyObject *RenderData_EnableKey( BPy_RenderData * self )
676 {
677         self->renderContext->alphamode = R_ALPHAKEY;
678         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
679
680         return EXPP_incr_ret( Py_None );
681 }
682
683 PyObject *RenderData_EnableShadow( BPy_RenderData * self, PyObject * args )
684 {
685         return M_Render_BitToggleInt( args, R_SHADOW,
686                                       &self->renderContext->mode );
687 }
688
689 PyObject *RenderData_EnableEnvironmentMap( BPy_RenderData * self,
690                                            PyObject * args )
691 {
692         return M_Render_BitToggleInt( args, R_ENVMAP,
693                                       &self->renderContext->mode );
694 }
695
696 PyObject *RenderData_EnablePanorama( BPy_RenderData * self, PyObject * args )
697 {
698         return M_Render_BitToggleInt( args, R_PANORAMA,
699                                       &self->renderContext->mode );
700 }
701
702 PyObject *RenderData_EnableRayTracing( BPy_RenderData * self, PyObject * args )
703 {
704         return M_Render_BitToggleInt( args, R_RAYTRACE,
705                                       &self->renderContext->mode );
706 }
707
708 PyObject *RenderData_EnableRadiosityRender( BPy_RenderData * self,
709                                             PyObject * args )
710 {
711         return M_Render_BitToggleInt( args, R_RADIO,
712                                       &self->renderContext->mode );
713 }
714 PyObject *RenderData_EnableFieldRendering( BPy_RenderData * self,
715                                            PyObject * args )
716 {
717         return M_Render_BitToggleInt( args, R_FIELDS,
718                                       &self->renderContext->mode );
719 }
720
721 PyObject *RenderData_EnableOddFieldFirst( BPy_RenderData * self,
722                                           PyObject * args )
723 {
724         return M_Render_BitToggleInt( args, R_ODDFIELD,
725                                       &self->renderContext->mode );
726 }
727
728 PyObject *RenderData_EnableFieldTimeDisable( BPy_RenderData * self,
729                                              PyObject * args )
730 {
731         return M_Render_BitToggleInt( args, R_FIELDSTILL,
732                                       &self->renderContext->mode );
733 }
734
735 PyObject *RenderData_EnableGaussFilter( BPy_RenderData * self,
736                                         PyObject * args )
737 {
738         return M_Render_BitToggleInt( args, R_GAUSS,
739                                       &self->renderContext->mode );
740         
741         /* note, this now is obsolete (ton) */
742         /* we now need a call like RenderData_SetFilter() or so */
743         /* choices are listed in DNA_scene_types.h (search filtertype) */
744 }
745
746 PyObject *RenderData_EnableBorderRender( BPy_RenderData * self,
747                                          PyObject * args )
748 {
749         return M_Render_BitToggleInt( args, R_BORDER,
750                                       &self->renderContext->mode );
751 }
752
753 static int RenderData_setBorder( BPy_RenderData * self, PyObject * args )
754 {
755         float xmin, ymin, xmax, ymax;
756
757         if( PyList_Check( args ) )
758                 args = PySequence_Tuple( args );
759         else
760                 Py_INCREF( args );
761
762         if( !PyArg_ParseTuple( args, "ffff", &xmin, &ymin, &xmax, &ymax ) ) {
763                 Py_DECREF( args );
764                 return EXPP_ReturnIntError( PyExc_TypeError,
765                                                 "expected four floats" );
766         }
767
768         self->renderContext->border.xmin = EXPP_ClampFloat( xmin, 0.0, 1.0 );
769         self->renderContext->border.xmax = EXPP_ClampFloat( xmax, 0.0, 1.0 );
770         self->renderContext->border.ymin = EXPP_ClampFloat( ymin, 0.0, 1.0 );
771         self->renderContext->border.ymax = EXPP_ClampFloat( ymax, 0.0, 1.0 );
772
773         EXPP_allqueue( REDRAWVIEWCAM, 1 );
774
775         Py_DECREF( args );
776         return 0;
777 }
778
779 static PyObject *RenderData_getBorder( BPy_RenderData * self )
780 {
781         return Py_BuildValue( "[ffff]", 
782                         self->renderContext->border.xmin,
783                         self->renderContext->border.ymin,
784                         self->renderContext->border.xmax,
785                         self->renderContext->border.ymax );
786 }
787
788 PyObject *RenderData_EnableGammaCorrection( BPy_RenderData * self,
789                                             PyObject * args )
790 {
791         return M_Render_BitToggleInt( args, R_GAMMA,
792                                       &self->renderContext->mode );
793 }
794
795 PyObject *RenderData_GaussFilterSize( BPy_RenderData * self, PyObject * args )
796 {
797         return M_Render_GetSetAttributeFloat( args,
798                                               &self->renderContext->gauss,
799                                               0.5f, 1.5f );
800 }
801
802 PyObject *RenderData_StartFrame( BPy_RenderData * self, PyObject * args )
803 {
804         return M_Render_GetSetAttributeInt( args, &self->renderContext->sfra,
805                                             1, MAXFRAME );
806 }
807
808 PyObject *RenderData_CurrentFrame( BPy_RenderData * self, PyObject * args )
809 {
810         return M_Render_GetSetAttributeInt( args, &self->renderContext->cfra,
811                                             1, MAXFRAME );
812 }
813
814 PyObject *RenderData_EndFrame( BPy_RenderData * self, PyObject * args )
815 {
816         return M_Render_GetSetAttributeInt( args, &self->renderContext->efra,
817                                             1, MAXFRAME );
818 }
819
820 PyObject *RenderData_ImageSizeX( BPy_RenderData * self, PyObject * args )
821 {
822         return M_Render_GetSetAttributeShort( args, &self->renderContext->xsch,
823                                               4, 10000 );
824 }
825
826 PyObject *RenderData_ImageSizeY( BPy_RenderData * self, PyObject * args )
827 {
828         return M_Render_GetSetAttributeShort( args, &self->renderContext->ysch,
829                                               4, 10000 );
830 }
831
832 PyObject *RenderData_AspectRatioX( BPy_RenderData * self, PyObject * args )
833 {
834         return M_Render_GetSetAttributeShort( args, &self->renderContext->xasp,
835                                               1, 200 );
836 }
837
838 PyObject *RenderData_AspectRatioY( BPy_RenderData * self, PyObject * args )
839 {
840         return M_Render_GetSetAttributeShort( args, &self->renderContext->yasp,
841                                               1, 200 );
842 }
843
844 static int RenderData_setRenderer( BPy_RenderData * self, PyObject * value )
845 {
846         int type;
847
848         if( !PyInt_CheckExact( value ) )
849                 return EXPP_ReturnIntError( PyExc_TypeError,
850                                 "expected constant INTERNAL or YAFRAY" );
851
852         type = PyInt_AsLong( value );
853         if( type == R_INTERN )
854                 self->renderContext->renderer = R_INTERN;
855         else if( type == R_YAFRAY )
856                 self->renderContext->renderer = R_YAFRAY;
857         else
858                 return EXPP_ReturnIntError( PyExc_ValueError,
859                                 "expected constant INTERNAL or YAFRAY" );
860
861         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
862         return 0;
863 }
864
865 PyObject *RenderData_EnableCropping( void )
866 {
867 /*      return M_Render_BitToggleInt( args, R_MOVIECROP,
868                                       &self->renderContext->mode );
869 */
870         printf("cropping option is now default, obsolete\n");
871         Py_RETURN_NONE;
872 }
873
874
875 static int RenderData_setImageType( BPy_RenderData *self, PyObject *value )
876 {
877         int type;
878
879         if( !PyInt_CheckExact( value ) )
880                 return EXPP_ReturnIntError( PyExc_TypeError,
881                                 "expected int constant" );
882
883         type = PyInt_AS_LONG( value );
884
885         /*
886          * this same logic and more is in buttons_scene.c imagetype_pup code but
887          * only in generating strings for the popup menu, no way to reuse that :(
888          */
889
890         switch( type ) {
891         case R_AVIRAW :
892         case R_AVIJPEG :
893         case R_TARGA :
894         case R_RAWTGA :
895         case R_RADHDR :
896         case R_PNG :
897         case R_BMP :
898         case R_JPEG90 :
899         case R_HAMX :
900         case R_IRIS :
901         case R_IRIZ :
902         case R_FTYPE :
903         case R_TIFF :
904         case R_CINEON :
905         case R_DPX :
906 #ifdef _WIN32
907         case R_AVICODEC :
908 #endif
909 #ifdef WITH_OPENEXR
910         case R_OPENEXR :
911 #endif
912 #ifdef WITH_FFMPEG
913         case R_FFMPEG :
914 #endif
915                 self->renderContext->imtype = type;
916                 break;
917         case R_QUICKTIME :
918                 if( G.have_quicktime ) {
919                         self->renderContext->imtype = R_QUICKTIME;
920                         break;
921                 }
922         default:
923                 return EXPP_ReturnIntError( PyExc_ValueError,
924                                 "unknown constant - see modules dict for help" );
925         }
926
927         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
928         return 0;
929 }
930
931 PyObject *RenderData_Quality( BPy_RenderData * self, PyObject * args )
932 {
933         return M_Render_GetSetAttributeShort( args,
934                                               &self->renderContext->quality,
935                                               10, 100 );
936 }
937
938 PyObject *RenderData_FramesPerSec( BPy_RenderData * self, PyObject * args )
939 {
940         return M_Render_GetSetAttributeShort( args,
941                                               &self->renderContext->frs_sec, 1,
942                                               120 );
943 }
944
945 PyObject *RenderData_EnableGrayscale( BPy_RenderData * self )
946 {
947         self->renderContext->planes = R_PLANESBW;
948         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
949
950         return EXPP_incr_ret( Py_None );
951 }
952
953 PyObject *RenderData_EnableRGBColor( BPy_RenderData * self )
954 {
955         self->renderContext->planes = R_PLANES24;
956         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
957
958         return EXPP_incr_ret( Py_None );
959 }
960
961 PyObject *RenderData_EnableRGBAColor( BPy_RenderData * self )
962 {
963         self->renderContext->planes = R_PLANES32;
964         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
965
966         return EXPP_incr_ret( Py_None );
967 }
968
969 PyObject *RenderData_SizePreset( BPy_RenderData * self, PyObject * args )
970 {
971         int type;
972
973         if( !PyArg_ParseTuple( args, "i", &type ) )
974                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
975                                                 "expected constant" ) );
976
977         if( type == B_PR_PAL ) {
978                 M_Render_DoSizePreset( self, 720, 576, 54, 51, 100,
979                                        self->renderContext->xparts,
980                                        self->renderContext->yparts, 25, 0.1f,
981                                        0.9f, 0.1f, 0.9f );
982                 self->renderContext->mode &= ~R_PANORAMA;
983                 BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
984                                0.9f );
985         } else if( type == B_PR_NTSC ) {
986                 M_Render_DoSizePreset( self, 720, 480, 10, 11, 100, 1, 1,
987                                        30, 0.1f, 0.9f, 0.1f, 0.9f );
988                 self->renderContext->mode &= ~R_PANORAMA;
989                 BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
990                                0.9f );
991         } else if( type == B_PR_PRESET ) {
992                 M_Render_DoSizePreset( self, 720, 576, 54, 51, 100, 1, 1,
993                                        self->renderContext->frs_sec, 0.1f, 0.9f,
994                                        0.1f, 0.9f );
995                 self->renderContext->mode = R_OSA + R_SHADOW + R_FIELDS;
996                 self->renderContext->imtype = R_TARGA;
997                 BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
998                                0.9f );
999         } else if( type == B_PR_PRV ) {
1000                 M_Render_DoSizePreset( self, 640, 512, 1, 1, 50, 1, 1,
1001                                        self->renderContext->frs_sec, 0.1f, 0.9f,
1002                                        0.1f, 0.9f );
1003                 self->renderContext->mode &= ~R_PANORAMA;
1004                 BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
1005                                0.9f );
1006         } else if( type == B_PR_PC ) {
1007                 M_Render_DoSizePreset( self, 640, 480, 100, 100, 100, 1, 1,
1008                                        self->renderContext->frs_sec, 0.0f, 1.0f,
1009                                        0.0f, 1.0f );
1010                 self->renderContext->mode &= ~R_PANORAMA;
1011                 BLI_init_rctf( &self->renderContext->safety, 0.0f, 1.0f, 0.0f,
1012                                1.0f );
1013         } else if( type == B_PR_PAL169 ) {
1014                 M_Render_DoSizePreset( self, 720, 576, 64, 45, 100, 1, 1,
1015                                        25, 0.1f, 0.9f, 0.1f, 0.9f );
1016                 self->renderContext->mode &= ~R_PANORAMA;
1017                 BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
1018                                0.9f );
1019         } else if( type == B_PR_PANO ) {
1020                 M_Render_DoSizePreset( self, 36, 176, 115, 100, 100, 16, 1,
1021                                        self->renderContext->frs_sec, 0.1f, 0.9f,
1022                                        0.1f, 0.9f );
1023                 self->renderContext->mode |= R_PANORAMA;
1024                 BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
1025                                0.9f );
1026         } else if( type == B_PR_FULL ) {
1027                 M_Render_DoSizePreset( self, 1280, 1024, 1, 1, 100, 1, 1,
1028                                        self->renderContext->frs_sec, 0.1f, 0.9f,
1029                                        0.1f, 0.9f );
1030                 self->renderContext->mode &= ~R_PANORAMA;
1031                 BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
1032                                0.9f );
1033         } else
1034                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1035                                                 "unknown constant - see modules dict for help" ) );
1036
1037         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1038         return EXPP_incr_ret( Py_None );
1039 }
1040
1041 PyObject *RenderData_SetYafrayGIQuality( BPy_RenderData * self,
1042                                          PyObject * args )
1043 {
1044         int type;
1045
1046         if( !PyArg_ParseTuple( args, "i", &type ) )
1047                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1048                                                 "expected constant" ) );
1049
1050         if( type == PY_NONE || type == PY_LOW ||
1051             type == PY_MEDIUM || type == PY_HIGH ||
1052             type == PY_HIGHER || type == PY_BEST ) {
1053                 self->renderContext->GIquality = (short)type;
1054         } else
1055                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1056                                                 "unknown constant - see modules dict for help" ) );
1057
1058         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1059         return EXPP_incr_ret( Py_None );
1060 }
1061
1062 PyObject *RenderData_SetYafrayGIMethod( BPy_RenderData * self,
1063                                         PyObject * args )
1064 {
1065         int type;
1066
1067         if( !PyArg_ParseTuple( args, "i", &type ) )
1068                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1069                                                 "expected constant" ) );
1070
1071         if( type == PY_NONE || type == PY_SKYDOME || type == PY_FULL ) {
1072                 self->renderContext->GImethod = (short)type;
1073         } else
1074                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1075                                                 "unknown constant - see modules dict for help" ) );
1076
1077         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1078         return EXPP_incr_ret( Py_None );
1079 }
1080
1081 PyObject *RenderData_YafrayGIPower( BPy_RenderData * self, PyObject * args )
1082 {
1083         if( self->renderContext->GImethod > 0 ) {
1084                 return M_Render_GetSetAttributeFloat( args,
1085                                                       &self->renderContext->
1086                                                       GIpower, 0.01f,
1087                                                       100.00f );
1088         } else
1089                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1090                                                 "YafrayGIMethod must be set to 'SKYDOME' or 'FULL'" ) );
1091 }
1092
1093 PyObject *RenderData_YafrayGIIndirPower( BPy_RenderData * self, PyObject * args )
1094 {
1095         return M_Render_GetSetAttributeFloat( args,
1096                                                   &self->renderContext->
1097                                                   GIindirpower, 0.01f,
1098                                                   100.00f );
1099 }
1100
1101 PyObject *RenderData_YafrayGIDepth( BPy_RenderData * self, PyObject * args )
1102 {
1103         if( self->renderContext->GImethod == 2 ) {
1104                 return M_Render_GetSetAttributeInt( args,
1105                                                     &self->renderContext->
1106                                                     GIdepth, 1, 8 );
1107         } else
1108                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1109                                                 "YafrayGIMethod must be set to 'FULL'" ) );
1110 }
1111
1112 PyObject *RenderData_YafrayGICDepth( BPy_RenderData * self, PyObject * args )
1113 {
1114         if( self->renderContext->GImethod == 2 ) {
1115                 return M_Render_GetSetAttributeInt( args,
1116                                                     &self->renderContext->
1117                                                     GIcausdepth, 1, 8 );
1118         } else
1119                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1120                                                 "YafrayGIMethod must be set to 'FULL'" ) );
1121 }
1122
1123 PyObject *RenderData_EnableYafrayGICache( BPy_RenderData * self,
1124                                           PyObject * args )
1125 {
1126         if( self->renderContext->GImethod == 2 ) {
1127                 return M_Render_BitToggleShort( args, 1,
1128                                                 &self->renderContext->
1129                                                 GIcache );
1130         } else
1131                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1132                                                 "YafrayGIMethod must be set to 'FULL'" ) );
1133 }
1134
1135 PyObject *RenderData_EnableYafrayGIPhotons( BPy_RenderData * self,
1136                                             PyObject * args )
1137 {
1138         if( self->renderContext->GImethod == 2 ) {
1139                 return M_Render_BitToggleShort( args, 1,
1140                                                 &self->renderContext->
1141                                                 GIphotons );;
1142         } else
1143                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1144                                                 "YafrayGIMethod must be set to 'FULL'" ) );
1145 }
1146
1147 PyObject *RenderData_YafrayGIPhotonCount( BPy_RenderData * self,
1148                                           PyObject * args )
1149 {
1150         if( self->renderContext->GImethod == 2
1151             && self->renderContext->GIphotons == 1 ) {
1152                 return M_Render_GetSetAttributeInt( args,
1153                                                     &self->renderContext->
1154                                                     GIphotoncount, 0,
1155                                                     10000000 );
1156         } else
1157                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1158                                                 "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) );
1159 }
1160
1161 PyObject *RenderData_YafrayGIPhotonRadius( BPy_RenderData * self,
1162                                            PyObject * args )
1163 {
1164         if( self->renderContext->GImethod == 2
1165             && self->renderContext->GIphotons == 1 ) {
1166                 return M_Render_GetSetAttributeFloat( args,
1167                                                       &self->renderContext->
1168                                                       GIphotonradius, 0.00001f,
1169                                                       100.0f );
1170         } else
1171                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1172                                                 "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) );
1173 }
1174
1175 PyObject *RenderData_YafrayGIPhotonMixCount( BPy_RenderData * self,
1176                                              PyObject * args )
1177 {
1178         if( self->renderContext->GImethod == 2
1179             && self->renderContext->GIphotons == 1 ) {
1180                 return M_Render_GetSetAttributeInt( args,
1181                                                     &self->renderContext->
1182                                                     GImixphotons, 0, 1000 );
1183         } else
1184                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1185                                                 "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) );
1186 }
1187
1188 PyObject *RenderData_EnableYafrayGITunePhotons( BPy_RenderData * self,
1189                                                 PyObject * args )
1190 {
1191         if( self->renderContext->GImethod == 2
1192             && self->renderContext->GIphotons == 1 ) {
1193                 return M_Render_BitToggleShort( args, 1,
1194                                                 &self->renderContext->
1195                                                 GIdirect );;
1196         } else
1197                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1198                                                 "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) );
1199 }
1200
1201 PyObject *RenderData_YafrayGIShadowQuality( BPy_RenderData * self,
1202                                             PyObject * args )
1203 {
1204         if( self->renderContext->GImethod == 2
1205             && self->renderContext->GIcache == 1 ) {
1206                 return M_Render_GetSetAttributeFloat( args,
1207                                                       &self->renderContext->
1208                                                       GIshadowquality, 0.01f,
1209                                                       1.0f );
1210         } else
1211                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1212                                                 "YafrayGIMethod must be set to 'FULL' and GICache must be enabled" ) );
1213 }
1214
1215 PyObject *RenderData_YafrayGIPixelsPerSample( BPy_RenderData * self,
1216                                               PyObject * args )
1217 {
1218         if( self->renderContext->GImethod == 2
1219             && self->renderContext->GIcache == 1 ) {
1220                 return M_Render_GetSetAttributeInt( args,
1221                                                     &self->renderContext->
1222                                                     GIpixelspersample, 1, 50 );
1223         } else
1224                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1225                                                 "YafrayGIMethod must be set to 'FULL' and GICache must be enabled" ) );
1226 }
1227
1228 PyObject *RenderData_YafrayGIRefinement( BPy_RenderData * self,
1229                                          PyObject * args )
1230 {
1231         if( self->renderContext->GImethod == 2
1232             && self->renderContext->GIcache == 1 ) {
1233                 return M_Render_GetSetAttributeFloat( args,
1234                                                       &self->renderContext->
1235                                                       GIrefinement, 0.001f,
1236                                                       1.0f );
1237         } else
1238                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1239                                                 "YafrayGIMethod must be set to 'FULL' and GICache must be enabled" ) );
1240 }
1241
1242 PyObject *RenderData_YafrayRayBias( BPy_RenderData * self, PyObject * args )
1243 {
1244         return M_Render_GetSetAttributeFloat( args,
1245                                               &self->renderContext->YF_raybias,
1246                                               0.0f, 10.0f );
1247 }
1248
1249 PyObject *RenderData_YafrayRayDepth( BPy_RenderData * self, PyObject * args )
1250 {
1251         return M_Render_GetSetAttributeInt( args,
1252                                             &self->renderContext->YF_raydepth,
1253                                             1, 80 );
1254 }
1255
1256 PyObject *RenderData_YafrayGamma( BPy_RenderData * self, PyObject * args )
1257 {
1258         return M_Render_GetSetAttributeFloat( args,
1259                                               &self->renderContext->YF_gamma,
1260                                               0.001f, 5.0f );
1261 }
1262
1263 PyObject *RenderData_YafrayExposure( BPy_RenderData * self, PyObject * args )
1264 {
1265         return M_Render_GetSetAttributeFloat( args,
1266                                               &self->renderContext->
1267                                               YF_exposure, 0.0f, 10.0f );
1268 }
1269
1270 PyObject *RenderData_YafrayProcessorCount( BPy_RenderData * self,
1271                                            PyObject * args )
1272 {
1273         return M_Render_GetSetAttributeInt( args,
1274                                             &self->renderContext->YF_numprocs,
1275                                             1, 8 );
1276 }
1277
1278 PyObject *RenderData_EnableGameFrameStretch( BPy_RenderData * self )
1279 {
1280         self->scene->framing.type = SCE_GAMEFRAMING_SCALE;
1281         return EXPP_incr_ret( Py_None );
1282 }
1283
1284 PyObject *RenderData_EnableGameFrameExpose( BPy_RenderData * self )
1285 {
1286         self->scene->framing.type = SCE_GAMEFRAMING_EXTEND;
1287         return EXPP_incr_ret( Py_None );
1288 }
1289
1290 PyObject *RenderData_EnableGameFrameBars( BPy_RenderData * self )
1291 {
1292         self->scene->framing.type = SCE_GAMEFRAMING_BARS;
1293         return EXPP_incr_ret( Py_None );
1294 }
1295
1296 PyObject *RenderData_SetGameFrameColor( BPy_RenderData * self,
1297                                         PyObject * args )
1298 {
1299         float red = 0.0f;
1300         float green = 0.0f;
1301         float blue = 0.0f;
1302
1303         if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) )
1304                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1305                                                 "expected three floats" ) );
1306
1307         if( red < 0 || red > 1 )
1308                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1309                                                 "value out of range 0.000 - 1.000 (red)" ) );
1310         if( green < 0 || green > 1 )
1311                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1312                                                 "value out of range 0.000 - 1.000 (green)" ) );
1313         if( blue < 0 || blue > 1 )
1314                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1315                                                 "value out of range 0.000 - 1.000 (blue)" ) );
1316
1317         self->scene->framing.col[0] = red;
1318         self->scene->framing.col[1] = green;
1319         self->scene->framing.col[2] = blue;
1320
1321         return EXPP_incr_ret( Py_None );
1322 }
1323
1324 PyObject *RenderData_GetGameFrameColor( BPy_RenderData * self )
1325 {
1326         char rgb[24];
1327
1328         sprintf( rgb, "[%.3f,%.3f,%.3f]", self->scene->framing.col[0],
1329                  self->scene->framing.col[1], self->scene->framing.col[2] );
1330         return PyString_FromString( rgb );
1331 }
1332
1333 #ifdef __sgi
1334 PyObject *RenderData_SGIMaxsize( BPy_RenderData * self, PyObject * args )
1335 {
1336         return M_Render_GetSetAttributeShort( args,
1337                                               &self->renderContext->maximsize,
1338                                               0, 500 );
1339 }
1340
1341 PyObject *RenderData_EnableSGICosmo( BPy_RenderData *self, PyObject *args )
1342 {
1343         return M_Render_BitToggleInt( args, R_COSMO,
1344                                       &self->renderContext->mode );
1345 }
1346 #else
1347 PyObject *RenderData_SGIMaxsize( void )
1348 {
1349         return EXPP_ReturnPyObjError( PyExc_StandardError,
1350                         "SGI is not defined on this machine" );
1351 }
1352
1353 PyObject *RenderData_EnableSGICosmo( void )
1354 {
1355         return EXPP_ReturnPyObjError( PyExc_StandardError,
1356                         "SGI is not defined on this machine" );
1357 }
1358 #endif
1359
1360 PyObject *RenderData_OldMapValue( BPy_RenderData * self, PyObject * args )
1361 {
1362         PyObject *tmp = M_Render_GetSetAttributeInt(args,
1363                 &self->renderContext->framapto, 1, 900);
1364         self->renderContext->framelen =
1365                 (float)self->renderContext->framapto / self->renderContext->images;
1366         return tmp;
1367 }
1368
1369 PyObject *RenderData_NewMapValue( BPy_RenderData * self, PyObject * args )
1370 {
1371         PyObject *tmp = M_Render_GetSetAttributeInt(args,
1372                         &self->renderContext->images, 1, 900);
1373         self->renderContext->framelen =
1374                 (float)self->renderContext->framapto / self->renderContext->images;
1375         return tmp;
1376 }
1377
1378 static PyObject *RenderData_getTimeCode( BPy_RenderData * self) {
1379     char tc[12];
1380     int h, m, s, fps, cfa;
1381     
1382     fps = self->renderContext->frs_sec;
1383     cfa = self->renderContext->cfra-1;
1384         s = cfa / fps;
1385         m = s / 60;
1386         h = m / 60;
1387     if( h > 99 )
1388         return PyString_FromString("Time Greater than 99 Hours!");      
1389
1390         sprintf( tc, "%02d:%02d:%02d:%02d", h%60, m%60, s%60, cfa%fps);
1391         return PyString_FromString(tc);
1392 }            
1393
1394 /***************************************************************************/
1395 /* generic handlers for getting/setting attributes                         */
1396 /***************************************************************************/
1397
1398 /*
1399  * get floating point attributes
1400  */
1401
1402 static PyObject *RenderData_getFloatAttr( BPy_RenderData *self, void *type )
1403 {
1404         float param;
1405
1406         switch( (int)type ) {
1407         case EXPP_RENDER_ATTR_GAUSSFILTER:
1408                 param = self->renderContext->gauss;
1409                 break;
1410         case EXPP_RENDER_ATTR_MBLURFACTOR:
1411                 param = self->renderContext->blurfac;
1412                 break;
1413         default:
1414                 return EXPP_ReturnPyObjError( PyExc_RuntimeError,
1415                                 "undefined type constant in RenderData_getFloatAttr" );
1416         }
1417         return PyFloat_FromDouble( param );
1418 }
1419
1420 /*
1421  * set floating point attributes which require clamping
1422  */
1423
1424 static int RenderData_setFloatAttrClamp( BPy_RenderData *self, PyObject *value,
1425                 void *type )
1426 {
1427         float *param;
1428         float min, max;
1429
1430         switch( (int)type ) {
1431         case EXPP_RENDER_ATTR_GAUSSFILTER:
1432                 min = 0.5f;
1433                 max = 1.5f;
1434                 param = &self->renderContext->gauss;
1435                 break;
1436         case EXPP_RENDER_ATTR_MBLURFACTOR:
1437             min = 0.01f;
1438                 max = 5.0f;
1439                 param = &self->renderContext->blurfac;
1440                 break;
1441         default:
1442                 return EXPP_ReturnIntError( PyExc_RuntimeError,
1443                                 "undefined type constant in RenderData_setFloatAttrClamp" );
1444         }
1445         return EXPP_setFloatClamped( value, param, min, max );
1446 }
1447
1448 /*
1449  * get integer attributes
1450  */
1451
1452 static PyObject *RenderData_getIValueAttr( BPy_RenderData *self, void *type )
1453 {
1454         long param;
1455
1456         switch( (int)type ) {
1457         case EXPP_RENDER_ATTR_XPARTS:
1458                 param = (long)self->renderContext->xparts;
1459                 break;
1460         case EXPP_RENDER_ATTR_YPARTS:
1461                 param = (long)self->renderContext->yparts;
1462                 break;
1463         case EXPP_RENDER_ATTR_ASPECTX:
1464                 param = (long)self->renderContext->xasp;
1465                 break;
1466         case EXPP_RENDER_ATTR_ASPECTY:
1467                 param = (long)self->renderContext->yasp;
1468                 break;
1469         case EXPP_RENDER_ATTR_CFRAME:
1470                 param = (long)self->renderContext->cfra;
1471                 break;
1472         case EXPP_RENDER_ATTR_EFRAME:
1473                 param = (long)self->renderContext->efra;
1474                 break;
1475         case EXPP_RENDER_ATTR_SFRAME:
1476                 param = (long)self->renderContext->sfra;
1477                 break;
1478         case EXPP_RENDER_ATTR_FPS:
1479                 param = self->renderContext->frs_sec;
1480                 break;
1481         case EXPP_RENDER_ATTR_SIZEX:
1482                 param = self->renderContext->xsch;
1483                 break;
1484         case EXPP_RENDER_ATTR_SIZEY:
1485                 param = self->renderContext->ysch;
1486                 break;
1487         default:
1488                 return EXPP_ReturnPyObjError( PyExc_RuntimeError,
1489                                 "undefined type constant in RenderData_setIValueAttrClamp" );
1490         }
1491         return PyInt_FromLong( param );
1492 }
1493
1494 /*
1495  * set integer attributes which require clamping
1496  */
1497
1498 static int RenderData_setIValueAttrClamp( BPy_RenderData *self, PyObject *value,
1499                 void *type )
1500 {
1501         void *param;
1502         int min, max, size;
1503
1504         switch( (int)type ) {
1505         case EXPP_RENDER_ATTR_XPARTS:
1506                 min = 1;
1507                 max = 512;
1508                 size = 'h';
1509                 param = &self->renderContext->xparts;
1510                 break;
1511         case EXPP_RENDER_ATTR_YPARTS:
1512                 min = 1;
1513                 max = 64;
1514                 size = 'h';
1515                 param = &self->renderContext->yparts;
1516                 break;
1517         case EXPP_RENDER_ATTR_ASPECTX:
1518                 min = 1;
1519                 max = 200;
1520                 size = 'h';
1521                 param = &self->renderContext->xasp;
1522                 break;
1523         case EXPP_RENDER_ATTR_ASPECTY:
1524                 min = 1;
1525                 max = 200;
1526                 size = 'h';
1527                 param = &self->renderContext->yasp;
1528                 break;
1529         case EXPP_RENDER_ATTR_CFRAME:
1530                 min = 1;
1531                 max = MAXFRAME;
1532                 size = 'h';
1533                 param = &self->renderContext->cfra;
1534                 break;
1535         case EXPP_RENDER_ATTR_EFRAME:
1536                 min = 1;
1537                 max = MAXFRAME;
1538                 size = 'h';
1539                 param = &self->renderContext->efra;
1540                 break;
1541         case EXPP_RENDER_ATTR_SFRAME:
1542                 min = 1;
1543             max = MAXFRAME;
1544                 size = 'h';
1545                 param = &self->renderContext->sfra;
1546                 break;
1547         case EXPP_RENDER_ATTR_FPS:
1548                 min = 1;
1549                 max = 120;
1550                 size = 'h';
1551                 param = &self->renderContext->frs_sec;
1552                 break;
1553         case EXPP_RENDER_ATTR_SIZEX:
1554                 min = 4;
1555                 max = 10000;
1556                 size = 'h';
1557                 param = &self->renderContext->xsch;
1558                 break;
1559         case EXPP_RENDER_ATTR_SIZEY:
1560                 min = 4;
1561                 max = 10000;
1562                 size = 'h';
1563                 param = &self->renderContext->ysch;
1564                 break;
1565         default:
1566                 return EXPP_ReturnIntError( PyExc_RuntimeError,
1567                                 "undefined type constant in RenderData_setIValueAttrClamp" );
1568         }
1569         return EXPP_setIValueClamped( value, param, min, max, size );
1570 }
1571
1572 /***************************************************************************/
1573 /* handlers for other getting/setting attributes                           */
1574 /***************************************************************************/
1575
1576 static PyObject *RenderData_getModeBit( BPy_RenderData *self, void* type )
1577 {
1578         return EXPP_getBitfield( &self->renderContext->mode,
1579                         (int)type, 'i' );
1580 }
1581
1582 static int RenderData_setModeBit( BPy_RenderData* self, PyObject *value,
1583                 void* type )
1584 {
1585         return EXPP_setBitfield( value, &self->renderContext->mode,
1586                         (int)type, 'i' );
1587 }
1588
1589 #define MODE_MASK ( R_OSA | R_SHADOW | R_GAMMA | R_ENVMAP | R_EDGE | \
1590         R_FIELDS | R_FIELDSTILL | R_RADIO | R_BORDER | R_PANORAMA | R_CROP | \
1591         R_ODDFIELD | R_MBLUR | R_RAYTRACE | R_THREADS )
1592
1593 static PyObject *RenderData_getMode( BPy_RenderData *self )
1594 {
1595         return PyInt_FromLong( (long)(self->renderContext->mode & MODE_MASK) );
1596 }
1597
1598 static int RenderData_setMode( BPy_RenderData* self, PyObject *arg )
1599 {
1600         int value;
1601
1602         if( !PyInt_CheckExact( arg ) )
1603                 return EXPP_ReturnIntError( PyExc_TypeError,
1604                                 "expected int argument" );
1605
1606         value = PyInt_AsLong( arg );
1607         if( value & ~MODE_MASK )
1608                 return EXPP_ReturnIntError( PyExc_ValueError, 
1609                                 "unexpected bits set in argument" );
1610
1611         self->renderContext->mode = (short)value;
1612         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1613
1614         return 0;
1615 }
1616
1617 static PyObject *RenderData_getSceModeBits( BPy_RenderData *self, void* type )
1618 {
1619         return EXPP_getBitfield( &self->renderContext->scemode, (int)type, 'h' );
1620 }
1621
1622 static int RenderData_setSceModeBits( BPy_RenderData* self, PyObject *value,
1623                 void* type )
1624 {
1625         return EXPP_setBitfield( value, &self->renderContext->scemode,
1626                         (int)type, 'h' );
1627 }
1628
1629 static PyObject *RenderData_getSceMode( BPy_RenderData *self )
1630 {
1631         return PyInt_FromLong ( (long)self->renderContext->scemode );
1632 }
1633
1634 static int RenderData_setSceMode( BPy_RenderData* self, PyObject *arg )
1635 {
1636         int value;
1637
1638         if( !PyInt_CheckExact( arg ) )
1639                 return EXPP_ReturnIntError( PyExc_TypeError,
1640                                 "expected int argument" );
1641
1642         value = PyInt_AsLong( arg );
1643         if( value & ~( R_EXTENSION | R_DOSEQ ) )
1644                 return EXPP_ReturnIntError( PyExc_ValueError, 
1645                                 "unexpected bits set in argument" );
1646
1647         self->renderContext->scemode = (short)value;
1648         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1649
1650         return 0;
1651 }
1652  
1653 static PyObject *RenderData_getFramingType( BPy_RenderData *self )
1654 {
1655         return PyInt_FromLong( (long)self->scene->framing.type );
1656 }
1657
1658 static int RenderData_setFramingType( BPy_RenderData *self, PyObject *value )
1659 {
1660         return EXPP_setIValueRange( value, &self->scene->framing.type,
1661                         SCE_GAMEFRAMING_BARS, SCE_GAMEFRAMING_SCALE, 'b' );
1662 }
1663
1664 static PyObject *RenderData_getEdgeColor( BPy_RenderData * self )
1665 {
1666         return Py_BuildValue( "[fff]", self->renderContext->edgeR,
1667                         self->renderContext->edgeG, self->renderContext->edgeB );
1668 }
1669
1670 static int RenderData_setEdgeColor( BPy_RenderData * self, PyObject * args )
1671 {
1672         float red, green, blue;
1673
1674         /* if we get a list, convert to a tuple; otherwise hope for the best */
1675         if( PyList_Check( args ) )
1676                 args = PySequence_Tuple( args );
1677         else
1678                 Py_INCREF( args );
1679
1680         if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) ) {
1681                 Py_DECREF( args );
1682                 return EXPP_ReturnIntError( PyExc_TypeError, "expected three floats" );
1683         }
1684         Py_DECREF( args );
1685
1686         self->renderContext->edgeR = EXPP_ClampFloat( red, 0.0, 1.0 );
1687         self->renderContext->edgeG = EXPP_ClampFloat( green, 0.0, 1.0 );
1688         self->renderContext->edgeB = EXPP_ClampFloat( blue, 0.0, 1.0 );
1689         return 0;
1690 }
1691
1692 static PyObject *RenderData_getOSALevel( BPy_RenderData * self )
1693 {
1694         return PyInt_FromLong( (long)self->renderContext->osa );
1695 }
1696
1697 static PyObject *RenderData_getRenderer( BPy_RenderData * self )
1698 {
1699         return PyInt_FromLong( (long)self->renderContext->renderer ); 
1700 }
1701
1702 static PyObject *RenderData_getImageType( BPy_RenderData * self )
1703 {
1704         return PyInt_FromLong( (long) self->renderContext->imtype );
1705 }
1706
1707 static int RenderData_setGameFrameColor( BPy_RenderData * self,
1708                 PyObject * args )
1709 {
1710         float red, green, blue;
1711
1712         /* if we get a list, convert to a tuple; otherwise hope for the best */
1713         if( PyList_Check( args ) )
1714                 args = PySequence_Tuple( args );
1715         else
1716                 Py_INCREF( args );
1717
1718         if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) ) {
1719                 Py_DECREF( args );
1720                 return EXPP_ReturnIntError( PyExc_TypeError, "expected three floats" );
1721         }
1722         Py_DECREF( args );
1723
1724         self->scene->framing.col[0] = EXPP_ClampFloat( red, 0.0, 1.0 );
1725         self->scene->framing.col[1] = EXPP_ClampFloat( green, 0.0, 1.0 );
1726         self->scene->framing.col[2] = EXPP_ClampFloat( blue, 0.0, 1.0 );
1727         return 0;
1728 }
1729
1730 static PyObject *RenderData_getGameFrameColor( BPy_RenderData * self )
1731 {
1732         return Py_BuildValue( "[fff]", self->scene->framing.col[0],
1733                  self->scene->framing.col[1], self->scene->framing.col[2] );
1734 }
1735
1736 static PyObject *RenderData_getBackbuf( BPy_RenderData * self )
1737 {
1738         return EXPP_getBitfield( &self->renderContext->bufflag,
1739                         R_BACKBUF, 'h' );
1740 }
1741
1742 static int RenderData_setBackbuf( BPy_RenderData* self, PyObject *value )
1743 {
1744         return EXPP_setBitfield( value, &self->renderContext->bufflag,
1745                         R_BACKBUF, 'h' );
1746 }
1747
1748 static int RenderData_setImagePlanes( BPy_RenderData *self, PyObject *value )
1749 {
1750         int depth;
1751         char *errstr = "expected int argument of 8, 24, or 32";
1752
1753         if( !PyInt_CheckExact( value ) )
1754                 return EXPP_ReturnIntError( PyExc_TypeError, errstr );
1755
1756         depth = PyInt_AsLong( value );
1757         if( depth != 8 && depth != 24 && depth != 32 )
1758                 return EXPP_ReturnIntError( PyExc_ValueError, errstr );
1759
1760         self->renderContext->planes = (short)depth;
1761
1762         return 0;
1763 }
1764
1765 static PyObject *RenderData_getImagePlanes( BPy_RenderData * self )
1766 {
1767         return PyInt_FromLong( (long) self->renderContext->planes );
1768 }
1769
1770 static int RenderData_setAlphaMode( BPy_RenderData *self, PyObject *value )
1771 {
1772         return EXPP_setIValueRange( value, &self->renderContext->alphamode,
1773                         R_ADDSKY, R_ALPHAKEY, 'h' );
1774 }
1775
1776 static PyObject *RenderData_getAlphaMode( BPy_RenderData * self )
1777 {
1778         return PyInt_FromLong( (long) self->renderContext->alphamode );
1779 }
1780
1781 static PyObject *RenderData_getDisplayMode( void )
1782 {
1783         return PyInt_FromLong( (long) G.displaymode );
1784 }
1785
1786 static int RenderData_setDisplayMode( BPy_RenderData *self,
1787                 PyObject *value )
1788 {
1789         return EXPP_setIValueRange( value, &G.displaymode,
1790                         R_DISPLAYIMAGE, R_DISPLAYSCREEN, 'h' );
1791 }
1792
1793 static PyObject *RenderData_getRenderPath( BPy_RenderData * self )
1794 {
1795         return PyString_FromString( self->renderContext->pic );
1796 }
1797
1798 static int RenderData_setRenderPath( BPy_RenderData * self, PyObject * value )
1799 {
1800         char *name;
1801
1802         name = PyString_AsString( value );
1803         if( !name )
1804                 return EXPP_ReturnIntError( PyExc_TypeError,
1805                                                 "expected a string" );
1806
1807         if( strlen( name ) >= sizeof(self->renderContext->pic) )
1808                 return EXPP_ReturnIntError( PyExc_ValueError,
1809                                                 "render path is too long" );
1810
1811         strcpy( self->renderContext->pic, name );
1812         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1813
1814         return 0;
1815 }
1816
1817 PyObject *RenderData_getBackbufPath( BPy_RenderData * self )
1818 {
1819         return PyString_FromString( self->renderContext->backbuf );
1820 }
1821
1822 static int RenderData_setBackbufPath( BPy_RenderData *self, PyObject *value )
1823 {
1824         char *name;
1825         Image *ima;
1826
1827         name = PyString_AsString( value );
1828         if( !name )
1829                 return EXPP_ReturnIntError( PyExc_TypeError, "expected a string" );
1830
1831         if( strlen( name ) >= sizeof(self->renderContext->backbuf) )
1832                 return EXPP_ReturnIntError( PyExc_ValueError,
1833                                 "backbuf path is too long" );
1834
1835         strcpy( self->renderContext->backbuf, name );
1836         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1837
1838         ima = BKE_add_image_file( name );
1839         if( ima )
1840                 BKE_image_signal( ima, NULL, IMA_SIGNAL_RELOAD );
1841
1842         return 0;
1843 }
1844
1845 PyObject *RenderData_getFtypePath( BPy_RenderData * self )
1846 {
1847         return PyString_FromString( self->renderContext->ftype );
1848 }
1849
1850 static int RenderData_setFtypePath( BPy_RenderData *self, PyObject *value )
1851 {
1852         char *name;
1853
1854         name = PyString_AsString( value );
1855         if( !name )
1856                 return EXPP_ReturnIntError( PyExc_TypeError, "expected a string" );
1857
1858         if( strlen( name ) >= sizeof(self->renderContext->ftype) )
1859                 return EXPP_ReturnIntError( PyExc_ValueError,
1860                                 "ftype path is too long" );
1861
1862         strcpy( self->renderContext->ftype, name );
1863         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1864
1865         return 0;
1866 }
1867
1868 PyObject *RenderData_getRenderWinSize( BPy_RenderData * self )
1869 {
1870         return PyInt_FromLong( (long) self->renderContext->size );
1871 }
1872
1873 static int RenderData_setRenderWinSize( BPy_RenderData *self, PyObject *value )
1874 {
1875         int size;
1876         char *errstr = "expected int argument of 25, 50, 75, or 100";
1877
1878         if( !PyInt_CheckExact( value ) )
1879                 return EXPP_ReturnIntError( PyExc_TypeError, errstr );
1880
1881         size = PyInt_AsLong( value );
1882         if( size != 25 && size != 50 && size != 75 && size != 100 )
1883                 return EXPP_ReturnIntError( PyExc_ValueError, errstr );
1884
1885         self->renderContext->size = (short)size;
1886         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1887
1888         return 0;
1889 }
1890
1891 static PyObject *RenderData_getMapOld( BPy_RenderData *self )
1892 {
1893         return PyInt_FromLong( (long)self->renderContext->framapto );
1894 }
1895
1896 static int RenderData_setMapOld( BPy_RenderData *self, PyObject *value )
1897 {
1898         int result = EXPP_setIValueClamped( value, &self->renderContext->framapto,
1899                         1, 900, 'h' );
1900         self->renderContext->framelen =
1901                 (float)self->renderContext->framapto / self->renderContext->images;
1902         return result;
1903 }
1904
1905 static PyObject *RenderData_getMapNew( BPy_RenderData *self )
1906 {
1907         return PyInt_FromLong( (long)self->renderContext->images );
1908 }
1909
1910 static int RenderData_setMapNew( BPy_RenderData *self, PyObject *value )
1911 {
1912         int result = EXPP_setIValueClamped( value, &self->renderContext->images,
1913                         1, 900, 'h' );
1914         self->renderContext->framelen =
1915                 (float)self->renderContext->framapto / self->renderContext->images;
1916         return result;
1917 }
1918
1919 static PyObject *RenderData_getSet( BPy_RenderData *self )
1920 {
1921         if( self->scene->set )
1922                 return Scene_CreatePyObject( self->scene->set );
1923         Py_RETURN_NONE;
1924 }
1925
1926 static int RenderData_setSet( BPy_RenderData *self, PyObject *value )
1927 {
1928         BPy_Scene *sc;
1929
1930         /* if "None", delete the link to the scene */
1931         if( value == Py_None ) {
1932                 self->scene->set = NULL;
1933                 return 0;
1934         }
1935
1936         /* be sure argument is a Scene */
1937         if( !BPy_Scene_Check( value ) )
1938                 return EXPP_ReturnIntError( PyExc_TypeError,
1939                                 "expected Scene as argument" );
1940
1941         /* check for attempt to link to ourselves */
1942         sc = (BPy_Scene *)value;
1943         if( self->scene == sc->scene )
1944                 return EXPP_ReturnIntError( PyExc_ValueError,
1945                                 "cannot link a scene to itself" );
1946
1947         /*
1948          * Accept the set link, then check for a circular link.  If circular link
1949          * exists, scene_check_setscene() sets self->scene->set to NULL.
1950          */
1951
1952         self->scene->set = sc->scene;
1953         if( !scene_check_setscene( self->scene ) )
1954                 return EXPP_ReturnIntError( PyExc_ValueError,
1955                                 "linking scene would create a cycle" );
1956
1957         return 0;
1958 }
1959
1960 /***************************************************************************/
1961 /* BPy_RenderData attribute def                                            */
1962 /***************************************************************************/
1963 static PyGetSetDef BPy_RenderData_getseters[] = {
1964         {"oversampling",
1965          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
1966          "Oversampling (anti-aliasing) enabled",
1967          (void *)R_OSA},
1968         {"shadow",
1969          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
1970          "Shadow calculation enabled",
1971          (void *)R_SHADOW},
1972         {"gammaCorrection",
1973          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
1974          "Gamma correction enabled",
1975          (void *)R_GAMMA},
1976 /* R_ORTHO      unused */
1977         {"environmentMap",
1978          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
1979          "Environment map rendering enabled",
1980          (void *)R_ENVMAP},
1981         {"toonShading",
1982          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
1983          "Toon edge shading enabled",
1984          (void *)R_EDGE},
1985         {"fieldRendering", 
1986          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
1987          "Field rendering enabled",
1988          (void *)R_FIELDS},
1989         {"fieldTimeDisable",
1990          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
1991          "Time difference in field calculations disabled ('X' in UI)",
1992          (void *)R_FIELDSTILL},
1993         {"radiosityRender",
1994          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
1995          "Radiosity rendering enabled",
1996          (void *)R_RADIO},
1997         {"borderRender",
1998          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
1999          "Small cut-out rendering enabled",
2000          (void *)R_BORDER},
2001         {"panorama",
2002          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2003          "Panorama rendering enabled",
2004          (void *)R_PANORAMA},
2005         {"crop",
2006          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2007          "Crop image during border renders",
2008          (void *)R_CROP},
2009 /* R_COSMO      unsupported */
2010         {"oddFieldFirst",
2011          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2012          "Odd field first rendering enabled",
2013          (void *)R_ODDFIELD},
2014         {"motionBlur",
2015          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2016          "Motion blur enabled",
2017          (void *)R_MBLUR},
2018         {"rayTracing",
2019          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2020          "Ray tracing enabled",
2021          (void *)R_RAYTRACE},
2022 /* R_GAUSS unused */
2023 /* R_FBUF unused */
2024         {"threads",
2025          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2026          "Render in two threads enabled",
2027          (void *)R_THREADS},
2028 /* R_SPEED unused */
2029         {"mode",
2030          (getter)RenderData_getMode, (setter)RenderData_setMode,
2031          "Mode bitfield",
2032          NULL},
2033
2034         {"extensions",
2035      (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits,
2036      "Add extensions to output (when rendering animations) enabled",
2037      (void *)R_EXTENSION},
2038         {"sequencer",
2039      (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits,
2040      "'Do Sequence' enabled",
2041      (void *)R_DOSEQ},
2042         {"sceneMode",
2043      (getter)RenderData_getSceMode, (setter)RenderData_setSceMode,
2044      "Scene mode bitfield",
2045      NULL},
2046 /* R_BG_RENDER unused */
2047
2048         {"gameFrame",
2049          (getter)RenderData_getFramingType, (setter)RenderData_setFramingType,
2050          "Game framing type",
2051          NULL},
2052
2053         {"renderPath",
2054          (getter)RenderData_getRenderPath, (setter)RenderData_setRenderPath,
2055          "The path to output the rendered images to",
2056          NULL},
2057         {"backbufPath",
2058          (getter)RenderData_getBackbufPath, (setter)RenderData_setBackbufPath,
2059          "Path to a background image (setting loads image)",
2060          NULL},
2061         {"ftypePath",
2062          (getter)RenderData_getFtypePath, (setter)RenderData_setFtypePath,
2063          "The path to Ftype file",
2064          NULL},
2065         {"edgeColor",
2066          (getter)RenderData_getEdgeColor, (setter)RenderData_setEdgeColor,
2067          "RGB color triplet for edges in Toon shading",
2068          NULL},
2069         {"OSALevel",
2070          (getter)RenderData_getOSALevel, (setter)RenderData_setOSALevel,
2071          "Oversampling (anti-aliasing) level",
2072          NULL},
2073         {"renderwinSize",
2074          (getter)RenderData_getRenderWinSize, (setter)RenderData_setRenderWinSize,
2075          "Size of the rendering window (25, 50, 75, or 100)",
2076          NULL},
2077         {"border",
2078          (getter)RenderData_getBorder, (setter)RenderData_setBorder,
2079          "The border for border rendering",
2080          NULL},
2081         {"timeCode",
2082          (getter)RenderData_getTimeCode, (setter)NULL,
2083          "Get the current frame in HH:MM:SS:FF format",
2084          NULL},
2085         {"renderer",
2086          (getter)RenderData_getRenderer, (setter)RenderData_setRenderer,
2087          "Rendering engine choice",
2088          NULL},
2089         {"imageType",
2090          (getter)RenderData_getImageType, (setter)RenderData_setImageType,
2091          "File format for saving images",
2092          NULL},
2093         {"gameFrameColor",
2094          (getter)RenderData_getGameFrameColor,(setter)RenderData_setGameFrameColor,
2095          "RGB color triplet for bars",
2096          NULL},
2097         {"backbuf",
2098          (getter)RenderData_getBackbuf, (setter)RenderData_setBackbuf,
2099          "Backbuffer image enabled",
2100          NULL},
2101         {"imagePlanes",
2102          (getter)RenderData_getImagePlanes, (setter)RenderData_setImagePlanes,
2103          "Image depth (8, 24, or 32 bits)",
2104          NULL},
2105         {"alphaMode",
2106          (getter)RenderData_getAlphaMode, (setter)RenderData_setAlphaMode,
2107          "Setting for sky/background.",
2108          NULL},
2109         {"displayMode",
2110          (getter)RenderData_getDisplayMode, (setter)RenderData_setDisplayMode,
2111          "Render output in separate window or 3D view",
2112          NULL},
2113
2114         {"xParts",
2115          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2116          "Number of horizontal parts for image render",
2117          (void *)EXPP_RENDER_ATTR_XPARTS},
2118         {"yParts",
2119          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2120          "Number of vertical parts for image render",
2121          (void *)EXPP_RENDER_ATTR_YPARTS},
2122         {"aspectX",
2123          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2124          "Horizontal aspect ratio",
2125          (void *)EXPP_RENDER_ATTR_ASPECTX},
2126         {"aspectY",
2127          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2128          "Vertical aspect ratio",
2129          (void *)EXPP_RENDER_ATTR_ASPECTY},
2130         {"cFrame",
2131          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2132          "The current frame for rendering",
2133          (void *)EXPP_RENDER_ATTR_CFRAME},
2134         {"sFrame",
2135          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2136          "Starting frame for rendering",
2137          (void *)EXPP_RENDER_ATTR_SFRAME},
2138         {"eFrame",
2139          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2140          "Ending frame for rendering",
2141          (void *)EXPP_RENDER_ATTR_EFRAME},
2142         {"fps",
2143          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2144          "Frames per second",
2145          (void *)EXPP_RENDER_ATTR_FPS},
2146         {"sizeX",
2147          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2148          "Image width (in pixels)",
2149          (void *)EXPP_RENDER_ATTR_SIZEX},
2150         {"sizeY",
2151          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2152          "Image height (in pixels)",
2153          (void *)EXPP_RENDER_ATTR_SIZEY},
2154
2155         {"gaussFilter",
2156          (getter)RenderData_getFloatAttr, (setter)RenderData_setFloatAttrClamp,
2157          "Gauss filter size",
2158          (void *)EXPP_RENDER_ATTR_GAUSSFILTER},
2159         {"mblurFactor",
2160          (getter)RenderData_getFloatAttr, (setter)RenderData_setFloatAttrClamp,
2161          "Motion blur factor",
2162          (void *)EXPP_RENDER_ATTR_MBLURFACTOR},
2163         {"mapOld",
2164          (getter)RenderData_getMapOld, (setter)RenderData_setMapOld,
2165          "Number of frames the Map Old will last",
2166          NULL},
2167         {"mapNew",
2168          (getter)RenderData_getMapNew, (setter)RenderData_setMapNew,
2169          "New mapping value (in frames)",
2170          NULL},
2171         {"set",
2172          (getter)RenderData_getSet, (setter)RenderData_setSet,
2173          "Scene link 'set' value",
2174          NULL},
2175         {NULL,NULL,NULL,NULL,NULL}
2176 };
2177
2178 /***************************************************************************/
2179 /* BPy_RenderData method def                                               */
2180 /***************************************************************************/
2181 static PyMethodDef BPy_RenderData_methods[] = {
2182         {"render", ( PyCFunction ) RenderData_Render, METH_NOARGS,
2183          "() - render the scene"},
2184         {"saveRenderedImage", (PyCFunction)RenderData_SaveRenderedImage, METH_VARARGS,
2185          "(filename) - save an image generated by a call to render() (set output path first)"},
2186         {"renderAnim", ( PyCFunction ) RenderData_RenderAnim, METH_NOARGS,
2187          "() - render a sequence from start frame to end frame"},
2188         {"play", ( PyCFunction ) RenderData_Play, METH_NOARGS,
2189          "() - play animation of rendered images/avi (searches Pics: field)"},
2190         {"setRenderPath", ( PyCFunction ) RenderData_SetRenderPath,
2191          METH_VARARGS,
2192          "(string) - get/set the path to output the rendered images to"},
2193         {"getRenderPath", ( PyCFunction ) RenderData_getRenderPath,
2194          METH_NOARGS,
2195          "() - get the path to directory where rendered images will go"},
2196         {"setBackbufPath", ( PyCFunction ) RenderData_SetBackbufPath,
2197          METH_VARARGS,
2198          "(string) - get/set the path to a background image and load it"},
2199         {"getBackbufPath", ( PyCFunction ) RenderData_getBackbufPath,
2200          METH_NOARGS,
2201          "() - get the path to background image file"},
2202         {"enableBackbuf", ( PyCFunction ) RenderData_EnableBackbuf,
2203          METH_VARARGS,
2204          "(bool) - enable/disable the backbuf image"},
2205         {"enableThreads", ( PyCFunction ) RenderData_EnableThreads,
2206          METH_VARARGS,
2207          "(bool) - enable/disable threaded rendering"},
2208         {"setFtypePath", ( PyCFunction ) RenderData_SetFtypePath, METH_VARARGS,
2209          "(string) - get/set the path to output the Ftype file"},
2210         {"getFtypePath", ( PyCFunction ) RenderData_getFtypePath, METH_NOARGS,
2211          "() - get the path to Ftype file"},
2212         {"enableExtensions", ( PyCFunction ) RenderData_EnableExtensions,
2213          METH_VARARGS,
2214          "(bool) - enable/disable windows extensions for output files"},
2215         {"enableSequencer", ( PyCFunction ) RenderData_EnableSequencer,
2216          METH_VARARGS,
2217          "(bool) - enable/disable Do Sequence"},
2218         {"enableRenderDaemon", ( PyCFunction ) RenderData_EnableRenderDaemon,
2219          METH_VARARGS,
2220          "(bool) - enable/disable Scene daemon"},
2221         {"enableToonShading", ( PyCFunction ) RenderData_EnableToonShading,
2222          METH_VARARGS,
2223          "(bool) - enable/disable Edge rendering"},
2224         {"edgeIntensity", ( PyCFunction ) RenderData_EdgeIntensity,
2225          METH_VARARGS,
2226          "(int) - get/set edge intensity for toon shading"},
2227         {"setEdgeColor", ( PyCFunction ) RenderData_SetEdgeColor, METH_VARARGS,
2228          "(f,f,f) - set the edge color for toon shading - Red,Green,Blue expected."},
2229         {"getEdgeColor", ( PyCFunction ) RenderData_GetEdgeColor, METH_NOARGS,
2230          "() - get the edge color for toon shading - Red,Green,Blue expected."},
2231         {"enableOversampling", ( PyCFunction ) RenderData_EnableOversampling,
2232          METH_VARARGS,
2233          "(bool) - enable/disable oversampling (anit-aliasing)."},
2234         {"setOversamplingLevel",
2235          ( PyCFunction ) RenderData_SetOversamplingLevel, METH_VARARGS,
2236          "(enum) - get/set the level of oversampling (anit-aliasing)."},
2237         {"enableMotionBlur", ( PyCFunction ) RenderData_EnableMotionBlur,
2238          METH_VARARGS,
2239          "(bool) - enable/disable MBlur."},
2240         {"motionBlurLevel", ( PyCFunction ) RenderData_MotionBlurLevel,
2241          METH_VARARGS,
2242          "(float) - get/set the length of shutter time for motion blur."},
2243         {"partsX", ( PyCFunction ) RenderData_PartsX, METH_VARARGS,
2244          "(int) - get/set the number of parts to divide the render in the X direction"},
2245         {"partsY", ( PyCFunction ) RenderData_PartsY, METH_VARARGS,
2246          "(int) - get/set the number of parts to divide the render in the Y direction"},
2247         {"enableSky", ( PyCFunction ) RenderData_EnableSky, METH_NOARGS,
2248          "() - enable render background with sky"},
2249         {"enablePremultiply", ( PyCFunction ) RenderData_EnablePremultiply,
2250          METH_NOARGS,
2251          "() - enable premultiply alpha"},
2252         {"enableKey", ( PyCFunction ) RenderData_EnableKey, METH_NOARGS,
2253          "() - enable alpha and colour values remain unchanged"},
2254         {"enableShadow", ( PyCFunction ) RenderData_EnableShadow, METH_VARARGS,
2255          "(bool) - enable/disable shadow calculation"},
2256         {"enablePanorama", ( PyCFunction ) RenderData_EnablePanorama,
2257          METH_VARARGS,
2258          "(bool) - enable/disable panorama rendering (output width is multiplied by Xparts)"},
2259         {"enableEnvironmentMap",
2260          ( PyCFunction ) RenderData_EnableEnvironmentMap, METH_VARARGS,
2261          "(bool) - enable/disable environment map rendering"},
2262         {"enableRayTracing", ( PyCFunction ) RenderData_EnableRayTracing,
2263          METH_VARARGS,
2264          "(bool) - enable/disable ray tracing"},
2265         {"enableRadiosityRender",
2266          ( PyCFunction ) RenderData_EnableRadiosityRender, METH_VARARGS,
2267          "(bool) - enable/disable radiosity rendering"},
2268         {"getRenderWinSize", ( PyCFunction ) RenderData_getRenderWinSize,
2269          METH_NOARGS,
2270          "() - get the size of the render window"},
2271         {"setRenderWinSize", ( PyCFunction ) RenderData_SetRenderWinSize,
2272          METH_VARARGS,
2273          "(int) - set the size of the render window"},
2274         {"enableFieldRendering",
2275          ( PyCFunction ) RenderData_EnableFieldRendering, METH_VARARGS,
2276          "(bool) - enable/disable field rendering"},
2277         {"enableOddFieldFirst", ( PyCFunction ) RenderData_EnableOddFieldFirst,
2278          METH_VARARGS,
2279          "(bool) - enable/disable Odd field first rendering (Default: Even field)"},
2280         {"enableFieldTimeDisable",
2281          ( PyCFunction ) RenderData_EnableFieldTimeDisable, METH_VARARGS,
2282          "(bool) - enable/disable time difference in field calculations"},
2283         {"enableGaussFilter", ( PyCFunction ) RenderData_EnableGaussFilter,
2284          METH_VARARGS,
2285          "(bool) - enable/disable Gauss sampling filter for antialiasing"},
2286         {"enableBorderRender", ( PyCFunction ) RenderData_EnableBorderRender,
2287          METH_VARARGS,
2288          "(bool) - enable/disable small cut-out rendering"},
2289         {"setBorder", ( PyCFunction ) RenderData_SetBorder, METH_VARARGS,
2290          "(f,f,f,f) - set the border for border rendering"},
2291         {"gaussFilterSize", ( PyCFunction ) RenderData_GaussFilterSize,
2292          METH_VARARGS,
2293          "(float) - get/sets the Gauss filter size"},
2294         {"startFrame", ( PyCFunction ) RenderData_StartFrame, METH_VARARGS,
2295          "(int) - get/set the starting frame for rendering"},
2296         {"currentFrame", ( PyCFunction ) RenderData_CurrentFrame, METH_VARARGS,
2297          "(int) - get/set the current frame for rendering"},
2298         {"endFrame", ( PyCFunction ) RenderData_EndFrame, METH_VARARGS,
2299          "(int) - get/set the ending frame for rendering"},
2300         {"getTimeCode", ( PyCFunction ) RenderData_getTimeCode, METH_NOARGS,
2301          "get the current frame in HH:MM:SS:FF format"},
2302         {"imageSizeX", ( PyCFunction ) RenderData_ImageSizeX, METH_VARARGS,
2303          "(int) - get/set the image width in pixels"},
2304         {"imageSizeY", ( PyCFunction ) RenderData_ImageSizeY, METH_VARARGS,
2305          "(int) - get/set the image height in pixels"},
2306         {"aspectRatioX", ( PyCFunction ) RenderData_AspectRatioX, METH_VARARGS,
2307          "(int) - get/set the horizontal aspect ratio"},
2308         {"aspectRatioY", ( PyCFunction ) RenderData_AspectRatioY, METH_VARARGS,
2309          "(int) - get/set the vertical aspect ratio"},
2310         {"setRenderer", ( PyCFunction ) RenderData_SetRenderer, METH_VARARGS,
2311          "(enum) - get/set which renderer to render the output"},
2312         {"enableCropping", ( PyCFunction ) RenderData_EnableCropping,
2313          METH_VARARGS,
2314          "(bool) - enable/disable exclusion of border rendering from total image"},
2315         {"setImageType", ( PyCFunction ) RenderData_SetImageType, METH_VARARGS,
2316          "(enum) - get/set the type of image to output from the render"},
2317         {"quality", ( PyCFunction ) RenderData_Quality, METH_VARARGS,
2318          "(int) - get/set quality get/setting for JPEG images, AVI Jpeg and SGI movies"},
2319         {"framesPerSec", ( PyCFunction ) RenderData_FramesPerSec, METH_VARARGS,
2320          "(int) - get/set frames per second"},
2321         {"enableGrayscale", ( PyCFunction ) RenderData_EnableGrayscale,
2322          METH_NOARGS,
2323          "() - images are saved with BW (grayscale) data"},
2324         {"enableRGBColor", ( PyCFunction ) RenderData_EnableRGBColor,
2325          METH_NOARGS,
2326          "() - images are saved with RGB (color) data"},
2327         {"enableRGBAColor", ( PyCFunction ) RenderData_EnableRGBAColor,
2328          METH_NOARGS,
2329          "() - images are saved with RGB and Alpha data (if supported)"},
2330         {"sizePreset", ( PyCFunction ) RenderData_SizePreset, METH_VARARGS,
2331          "(enum) - get/set the render to one of a few preget/sets"},
2332         {"setYafrayGIQuality", ( PyCFunction ) RenderData_SetYafrayGIQuality,
2333          METH_VARARGS,
2334          "(enum) - get/set yafray global Illumination quality"},
2335         {"setYafrayGIMethod", ( PyCFunction ) RenderData_SetYafrayGIMethod,
2336          METH_VARARGS,
2337          "(enum) - get/set yafray global Illumination method"},
2338         {"yafrayGIPower", ( PyCFunction ) RenderData_YafrayGIPower,
2339          METH_VARARGS,
2340          "(float) - get/set GI lighting intensity scale"},
2341         {"yafrayGIIndirPower", ( PyCFunction ) RenderData_YafrayGIIndirPower,
2342          METH_VARARGS,
2343          "(float) - get/set GI indifect lighting intensity scale"},
2344         {"yafrayGIDepth", ( PyCFunction ) RenderData_YafrayGIDepth,
2345          METH_VARARGS,
2346          "(int) - get/set number of bounces of the indirect light"},
2347         {"yafrayGICDepth", ( PyCFunction ) RenderData_YafrayGICDepth,
2348          METH_VARARGS,
2349          "(int) - get/set number of bounces inside objects (for caustics)"},
2350         {"enableYafrayGICache", ( PyCFunction ) RenderData_EnableYafrayGICache,
2351          METH_VARARGS,
2352          "(bool) - enable/disable cache irradiance samples (faster)"},
2353         {"enableYafrayGIPhotons",
2354          ( PyCFunction ) RenderData_EnableYafrayGIPhotons, METH_VARARGS,
2355          "(bool) - enable/disable use global photons to help in GI"},
2356         {"yafrayGIPhotonCount", ( PyCFunction ) RenderData_YafrayGIPhotonCount,
2357          METH_VARARGS,
2358          "(int) - get/set number of photons to shoot"},
2359         {"yafrayGIPhotonRadius",
2360          ( PyCFunction ) RenderData_YafrayGIPhotonRadius, METH_VARARGS,
2361          "(float) - get/set radius to search for photons to mix (blur)"},
2362         {"yafrayGIPhotonMixCount",
2363          ( PyCFunction ) RenderData_YafrayGIPhotonMixCount, METH_VARARGS,
2364          "(int) - get/set number of photons to shoot"},
2365         {"enableYafrayGITunePhotons",
2366          ( PyCFunction ) RenderData_EnableYafrayGITunePhotons, METH_VARARGS,
2367          "(bool) - enable/disable show the photonmap directly in the render for tuning"},
2368         {"yafrayGIShadowQuality",
2369          ( PyCFunction ) RenderData_YafrayGIShadowQuality, METH_VARARGS,
2370          "(float) - get/set the shadow quality, keep it under 0.95"},
2371         {"yafrayGIPixelsPerSample",
2372          ( PyCFunction ) RenderData_YafrayGIPixelsPerSample, METH_VARARGS,
2373          "(int) - get/set maximum number of pixels without samples, the lower the better and slower"},
2374         {"yafrayGIRefinement", ( PyCFunction ) RenderData_YafrayGIRefinement,
2375          METH_VARARGS,
2376          "(float) - get/setthreshold to refine shadows EXPERIMENTAL. 1 = no refinement"},
2377         {"yafrayRayBias", ( PyCFunction ) RenderData_YafrayRayBias,
2378          METH_VARARGS,
2379          "(float) - get/set shadow ray bias to avoid self shadowing"},
2380         {"yafrayRayDepth", ( PyCFunction ) RenderData_YafrayRayDepth,
2381          METH_VARARGS,
2382          "(int) - get/set maximum render ray depth from the camera"},
2383         {"yafrayGamma", ( PyCFunction ) RenderData_YafrayGamma, METH_VARARGS,
2384          "(float) - get/set gamma correction, 1 is off"},
2385         {"yafrayExposure", ( PyCFunction ) RenderData_YafrayExposure,
2386          METH_VARARGS,
2387          "(float) - get/set exposure adjustment, 0 is off"},
2388         {"yafrayProcessorCount",
2389          ( PyCFunction ) RenderData_YafrayProcessorCount, METH_VARARGS,
2390          "(int) - get/set number of processors to use"},
2391         {"enableGameFrameStretch",
2392          ( PyCFunction ) RenderData_EnableGameFrameStretch, METH_NOARGS,
2393          "(l) - enble stretch or squeeze the viewport to fill the display window"},
2394         {"enableGameFrameExpose",
2395          ( PyCFunction ) RenderData_EnableGameFrameExpose, METH_NOARGS,
2396          "(l) - enable show the entire viewport in the display window, viewing more horizontally or vertically"},
2397         {"enableGameFrameBars", ( PyCFunction ) RenderData_EnableGameFrameBars,
2398          METH_NOARGS,
2399          "() - enable show the entire viewport in the display window, using bar horizontally or vertically"},
2400         {"setGameFrameColor", ( PyCFunction ) RenderData_SetGameFrameColor,
2401          METH_VARARGS,
2402          "(f,f,f) - set the red, green, blue component of the bars"},
2403         {"getGameFrameColor", ( PyCFunction ) RenderData_GetGameFrameColor,
2404          METH_NOARGS,
2405          "() - get the red, green, blue component of the bars"},
2406         {"SGIMaxsize", ( PyCFunction ) RenderData_SGIMaxsize, METH_VARARGS,
2407          "(int) - get/set maximum size per frame to save in an SGI movie"},
2408         {"enableSGICosmo", ( PyCFunction ) RenderData_EnableSGICosmo,
2409          METH_VARARGS,
2410          "(bool) - enable/disable attempt to save SGI movies using Cosmo hardware"},
2411         {"oldMapValue", ( PyCFunction ) RenderData_OldMapValue, METH_VARARGS,
2412          "(int) - get/set specify old map value in frames"},
2413         {"newMapValue", ( PyCFunction ) RenderData_NewMapValue, METH_VARARGS,
2414          "(int) - get/set specify new map value in frames"},
2415         {NULL, NULL, 0, NULL}
2416 };
2417  
2418 /*------------------------------------BPy_RenderData Type defintion------ */
2419 PyTypeObject RenderData_Type = {
2420         PyObject_HEAD_INIT( NULL )  /* required py macro */
2421         0,                          /* ob_size */
2422         /*  For printing, in format "<module>.<name>" */
2423         "Blender RenderData",       /* char *tp_name; */
2424         sizeof( BPy_RenderData ),   /* int tp_basicsize; */
2425         0,                          /* tp_itemsize;  For allocation */
2426
2427         /* Methods to implement standard operations */
2428
2429         ( destructor ) RenderData_dealloc,/* destructor tp_dealloc; */
2430         NULL,                       /* printfunc tp_print; */
2431         NULL,                       /* getattrfunc tp_getattr; */
2432         NULL,                       /* setattrfunc tp_setattr; */
2433         NULL,                       /* cmpfunc tp_compare; */
2434         ( reprfunc ) RenderData_repr,     /* reprfunc tp_repr; */
2435
2436         /* Method suites for standard classes */
2437
2438         NULL,                       /* PyNumberMethods *tp_as_number; */
2439         NULL,                       /* PySequenceMethods *tp_as_sequence; */
2440         NULL,                       /* PyMappingMethods *tp_as_mapping; */
2441
2442         /* More standard operations (here for binary compatibility) */
2443
2444         NULL,                       /* hashfunc tp_hash; */
2445         NULL,                       /* ternaryfunc tp_call; */
2446         NULL,                       /* reprfunc tp_str; */
2447         NULL,                       /* getattrofunc tp_getattro; */
2448         NULL,                       /* setattrofunc tp_setattro; */
2449
2450         /* Functions to access object as input/output buffer */
2451         NULL,                       /* PyBufferProcs *tp_as_buffer; */
2452
2453   /*** Flags to define presence of optional/expanded features ***/
2454         Py_TPFLAGS_DEFAULT,         /* long tp_flags; */
2455
2456         NULL,                       /*  char *tp_doc;  Documentation string */
2457   /*** Assigned meaning in release 2.0 ***/
2458         /* call function for all accessible objects */
2459         NULL,                       /* traverseproc tp_traverse; */
2460
2461         /* delete references to contained objects */
2462         NULL,                       /* inquiry tp_clear; */
2463
2464   /***  Assigned meaning in release 2.1 ***/
2465   /*** rich comparisons ***/
2466         NULL,                       /* richcmpfunc tp_richcompare; */
2467
2468   /***  weak reference enabler ***/
2469         0,                          /* long tp_weaklistoffset; */
2470
2471   /*** Added in release 2.2 ***/
2472         /*   Iterators */
2473         NULL,                       /* getiterfunc tp_iter; */
2474         NULL,                       /* iternextfunc tp_iternext; */
2475
2476   /*** Attribute descriptor and subclassing stuff ***/
2477         BPy_RenderData_methods,     /* struct PyMethodDef *tp_methods; */
2478         NULL,                       /* struct PyMemberDef *tp_members; */
2479         BPy_RenderData_getseters,   /* struct PyGetSetDef *tp_getset; */
2480         NULL,                       /* struct _typeobject *tp_base; */
2481         NULL,                       /* PyObject *tp_dict; */
2482         NULL,                       /* descrgetfunc tp_descr_get; */
2483         NULL,                       /* descrsetfunc tp_descr_set; */
2484         0,                          /* long tp_dictoffset; */
2485         NULL,                       /* initproc tp_init; */
2486         NULL,                       /* allocfunc tp_alloc; */
2487         NULL,                       /* newfunc tp_new; */
2488         /*  Low-level free-memory routine */
2489         NULL,                       /* freefunc tp_free;  */
2490         /* For PyObject_IS_GC */
2491         NULL,                       /* inquiry tp_is_gc;  */
2492         NULL,                       /* PyObject *tp_bases; */
2493         /* method resolution order */
2494         NULL,                       /* PyObject *tp_mro;  */
2495         NULL,                       /* PyObject *tp_cache; */
2496         NULL,                       /* PyObject *tp_subclasses; */
2497         NULL,                       /* PyObject *tp_weaklist; */
2498         NULL
2499 };
2500
2501 /***************************************************************************/
2502 /* Render method def                                                       */
2503 /***************************************************************************/
2504 struct PyMethodDef M_Render_methods[] = {
2505         {"CloseRenderWindow", ( PyCFunction ) M_Render_CloseRenderWindow,
2506          METH_NOARGS,
2507          "() - close the rendering window"},
2508         {"EnableDispView", ( PyCFunction ) M_Render_EnableDispView,
2509          METH_NOARGS,
2510          "(bool) - enable Sceneing in view"},
2511         {"EnableDispWin", ( PyCFunction ) M_Render_EnableDispWin, METH_NOARGS,
2512          "(bool) - enable Sceneing in new window"},
2513         {"SetRenderWinPos", ( PyCFunction ) M_Render_SetRenderWinPos,
2514          METH_VARARGS,
2515          "([string list]) - position the rendering window in around the edge of the screen"},
2516         {NULL, NULL, 0, NULL}
2517 };
2518
2519 static PyObject *M_Render_ModesDict( void )
2520 {
2521         PyObject *M = PyConstant_New(  );
2522
2523         if( M ) {
2524                 BPy_constant *d = ( BPy_constant * ) M;
2525                 PyConstant_Insert( d, "OSA", PyInt_FromLong( R_OSA ) );
2526                 PyConstant_Insert( d, "SHADOW", PyInt_FromLong( R_SHADOW ) );
2527                 PyConstant_Insert( d, "GAMMA", PyInt_FromLong( R_GAMMA ) );
2528                 PyConstant_Insert( d, "ENVMAP", PyInt_FromLong( R_ENVMAP ) );
2529                 PyConstant_Insert( d, "TOONSHADING", PyInt_FromLong( R_EDGE ) );
2530                 PyConstant_Insert( d, "FIELDRENDER", PyInt_FromLong( R_FIELDS ) );
2531                 PyConstant_Insert( d, "FIELDTIME", PyInt_FromLong( R_FIELDSTILL ) );
2532                 PyConstant_Insert( d, "RADIOSITY", PyInt_FromLong( R_RADIO ) );
2533                 PyConstant_Insert( d, "BORDER_RENDER", PyInt_FromLong( R_BORDER ) );
2534                 PyConstant_Insert( d, "PANORAMA", PyInt_FromLong( R_PANORAMA ) );
2535                 PyConstant_Insert( d, "CROP", PyInt_FromLong( R_CROP ) );
2536                 PyConstant_Insert( d, "ODDFIELD", PyInt_FromLong( R_ODDFIELD ) );
2537                 PyConstant_Insert( d, "MBLUR", PyInt_FromLong( R_MBLUR ) );
2538                 PyConstant_Insert( d, "RAYTRACING", PyInt_FromLong( R_RAYTRACE ) );
2539                 PyConstant_Insert( d, "THREADS", PyInt_FromLong( R_THREADS ) );
2540         }
2541         return M;
2542 }
2543
2544 static PyObject *M_Render_SceModesDict( void )
2545 {
2546         PyObject *M = PyConstant_New(  );
2547
2548         if( M ) {
2549                 BPy_constant *d = ( BPy_constant * ) M;
2550                 PyConstant_Insert( d, "SEQUENCER", PyInt_FromLong( R_DOSEQ ) );
2551                 PyConstant_Insert( d, "EXTENSION", PyInt_FromLong( R_EXTENSION ) );
2552         }
2553         return M;
2554 }
2555
2556 static PyObject *M_Render_GameFramingDict( void )
2557 {
2558         PyObject *M = PyConstant_New(  );
2559
2560         if( M ) {
2561                 BPy_constant *d = ( BPy_constant * ) M;
2562                 PyConstant_Insert( d, "BARS",
2563                                 PyInt_FromLong( SCE_GAMEFRAMING_BARS ) );
2564                 PyConstant_Insert( d, "EXTEND",
2565                                 PyInt_FromLong( SCE_GAMEFRAMING_EXTEND ) );
2566                 PyConstant_Insert( d, "SCALE",
2567                                 PyInt_FromLong( SCE_GAMEFRAMING_SCALE ) );
2568         }
2569         return M;
2570 }
2571
2572 /***************************************************************************/
2573 /* Render Module Init                                                      */
2574 /***************************************************************************/
2575 PyObject *Render_Init( void )
2576 {
2577         PyObject *submodule;
2578         PyObject *ModesDict = M_Render_ModesDict( );
2579         PyObject *SceModesDict = M_Render_SceModesDict( );
2580         PyObject *GFramingDict = M_Render_GameFramingDict( );
2581
2582         if( PyType_Ready( &RenderData_Type ) < 0 )
2583                 return NULL;
2584
2585         submodule = Py_InitModule3( "Blender.Scene.Render",
2586                                     M_Render_methods, M_Render_doc );
2587
2588         if( ModesDict )
2589                 PyModule_AddObject( submodule, "Modes", ModesDict );
2590         if( SceModesDict )
2591                 PyModule_AddObject( submodule, "SceModes", SceModesDict );
2592         if( GFramingDict )
2593                 PyModule_AddObject( submodule, "FramingModes", GFramingDict );
2594
2595         /* ugh: why aren't these in a constant dict? */
2596
2597         PyModule_AddIntConstant( submodule, "INTERNAL", R_INTERN );
2598         PyModule_AddIntConstant( submodule, "YAFRAY", R_YAFRAY );
2599         PyModule_AddIntConstant( submodule, "AVIRAW", R_AVIRAW );
2600         PyModule_AddIntConstant( submodule, "AVIJPEG", R_AVIJPEG );
2601         PyModule_AddIntConstant( submodule, "AVICODEC", R_AVICODEC );
2602         PyModule_AddIntConstant( submodule, "QUICKTIME", R_QUICKTIME );
2603         PyModule_AddIntConstant( submodule, "TARGA", R_TARGA );
2604         PyModule_AddIntConstant( submodule, "RAWTGA", R_RAWTGA );
2605         PyModule_AddIntConstant( submodule, "HDR", R_RADHDR );
2606         PyModule_AddIntConstant( submodule, "PNG", R_PNG );
2607         PyModule_AddIntConstant( submodule, "BMP", R_BMP );
2608         PyModule_AddIntConstant( submodule, "JPEG", R_JPEG90 );
2609         PyModule_AddIntConstant( submodule, "HAMX", R_HAMX );
2610         PyModule_AddIntConstant( submodule, "IRIS", R_IRIS );
2611         PyModule_AddIntConstant( submodule, "IRISZ", R_IRIZ );
2612         PyModule_AddIntConstant( submodule, "FTYPE", R_FTYPE );
2613         PyModule_AddIntConstant( submodule, "PAL", B_PR_PAL );
2614         PyModule_AddIntConstant( submodule, "NTSC", B_PR_NTSC );
2615         PyModule_AddIntConstant( submodule, "DEFAULT", B_PR_PRESET );
2616         PyModule_AddIntConstant( submodule, "PREVIEW", B_PR_PRV );
2617         PyModule_AddIntConstant( submodule, "PC", B_PR_PC );
2618         PyModule_AddIntConstant( submodule, "PAL169", B_PR_PAL169 );
2619         PyModule_AddIntConstant( submodule, "PANO", B_PR_PANO );
2620         PyModule_AddIntConstant( submodule, "FULL", B_PR_FULL );
2621         PyModule_AddIntConstant( submodule, "NONE", PY_NONE );
2622         PyModule_AddIntConstant( submodule, "LOW", PY_LOW );
2623         PyModule_AddIntConstant( submodule, "MEDIUM", PY_MEDIUM );
2624         PyModule_AddIntConstant( submodule, "HIGH", PY_HIGH );
2625         PyModule_AddIntConstant( submodule, "HIGHER", PY_HIGHER );
2626         PyModule_AddIntConstant( submodule, "BEST", PY_BEST );
2627         PyModule_AddIntConstant( submodule, "SKYDOME", PY_SKYDOME );
2628         PyModule_AddIntConstant( submodule, "GIFULL", PY_FULL );
2629         PyModule_AddIntConstant( submodule, "OPENEXR", R_OPENEXR );
2630         PyModule_AddIntConstant( submodule, "TIFF", R_TIFF );
2631         PyModule_AddIntConstant( submodule, "FFMPEG", R_FFMPEG );
2632         PyModule_AddIntConstant( submodule, "CINEON", R_CINEON );
2633         PyModule_AddIntConstant( submodule, "DPX", R_DPX );
2634
2635         return ( submodule );
2636 }
2637
2638 /***************************************************************************/
2639 /* BPy_RenderData Callbacks                                                */
2640 /***************************************************************************/
2641
2642 PyObject *RenderData_CreatePyObject( struct Scene * scene )
2643 {
2644         BPy_RenderData *py_renderdata;
2645
2646         py_renderdata =
2647                 ( BPy_RenderData * ) PyObject_NEW( BPy_RenderData,
2648                                                    &RenderData_Type );
2649
2650         if( py_renderdata == NULL ) {
2651                 return ( NULL );
2652         }
2653         py_renderdata->renderContext = &scene->r;
2654         py_renderdata->scene = scene;
2655
2656         return ( ( PyObject * ) py_renderdata );
2657 }
2658
2659 int RenderData_CheckPyObject( PyObject * py_obj )
2660 {
2661         return ( py_obj->ob_type == &RenderData_Type );
2662 }
2663
2664 /* #####DEPRECATED###### */
2665
2666 static PyObject *RenderData_SetRenderPath( BPy_RenderData *self,
2667                 PyObject *args )
2668 {
2669         return EXPP_setterWrapper( (void *)self, args,
2670                         (setter)RenderData_setRenderPath );
2671 }
2672
2673 static PyObject *RenderData_SetBackbufPath( BPy_RenderData *self,
2674                 PyObject *args )
2675 {
2676         return EXPP_setterWrapper( (void *)self, args,
2677                         (setter)RenderData_setBackbufPath );
2678 }
2679
2680 static PyObject *RenderData_SetFtypePath( BPy_RenderData *self,
2681                 PyObject *args )
2682 {
2683         return EXPP_setterWrapperTuple( (void *)self, args,
2684                         (setter)RenderData_setFtypePath );
2685 }
2686
2687 static PyObject *RenderData_SetOversamplingLevel( BPy_RenderData * self,
2688                 PyObject * args )
2689 {
2690         return EXPP_setterWrapper( (void *)self, args,
2691                         (setter)RenderData_setOSALevel );
2692 }
2693
2694 static PyObject *RenderData_SetRenderWinSize( BPy_RenderData * self,
2695                 PyObject * args )
2696 {
2697         return EXPP_setterWrapper( (void *)self, args,
2698                         (setter)RenderData_setRenderWinSize );
2699 }
2700
2701 static PyObject *RenderData_SetBorder( BPy_RenderData * self,
2702                 PyObject * args )
2703 {
2704         return EXPP_setterWrapperTuple( (void *)self, args,
2705                         (setter)RenderData_setBorder );
2706 }
2707
2708 static PyObject *RenderData_SetRenderer( BPy_RenderData * self,
2709                 PyObject * args )
2710 {
2711         return EXPP_setterWrapper( (void *)self, args,
2712                         (setter)RenderData_setRenderer );
2713 }
2714
2715 static PyObject *RenderData_SetImageType( BPy_RenderData * self,
2716                 PyObject * args )
2717 {
2718         return EXPP_setterWrapper( (void *)self, args,
2719                         (setter)RenderData_setImageType );
2720 }