Merged 15170:15635 from trunk (no conflicts or even merges)
[blender.git] / source / blender / python / api2_2x / sceneRender.c
1 /* 
2  * $Id$
3  *
4  * ***** BEGIN GPL 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.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21  * All rights reserved.
22  *
23  * This is a new part of Blender.
24  *
25  * Contributor(s): Joseph Gilbert, Dietrich Bollmann
26  *
27  * ***** END GPL LICENSE BLOCK *****
28 */
29 struct View3D; /* keep me up here */
30
31 #include "sceneRender.h" /*This must come first*/
32
33 #include "MEM_guardedalloc.h"
34                                  
35 #include "DNA_image_types.h"
36 #include "DNA_node_types.h"
37
38 #include "BKE_image.h"
39 #include "BKE_global.h"
40 #include "BKE_screen.h"
41 #include "BKE_scene.h"
42 #include "BKE_node.h"
43
44 #include "BIF_drawscene.h"
45 #include "BIF_renderwin.h"
46 #include "BIF_writeimage.h"
47 #include "BIF_meshtools.h"
48
49 #include "BLI_blenlib.h"
50
51 #include "RE_pipeline.h"
52
53 #include "mydevice.h"
54 #include "butspace.h"
55 #include "blendef.h"
56 #include "gen_utils.h"
57 #include "gen_library.h"
58
59 #include "Scene.h"
60 #include "Group.h"
61
62 /* local defines */
63 #define PY_NONE              0
64 #define PY_LOW               1
65 #define PY_MEDIUM            2
66 #define PY_HIGH              3
67 #define PY_HIGHER            4
68 #define PY_BEST              5
69 #define PY_USEAOSETTINGS 6
70 #define PY_SKYDOME           1
71 #define PY_FULL          2
72
73 enum rend_constants {
74         EXPP_RENDER_ATTR_XPARTS = 0,
75         EXPP_RENDER_ATTR_YPARTS,
76         EXPP_RENDER_ATTR_ASPECTX,
77         EXPP_RENDER_ATTR_ASPECTY,
78         EXPP_RENDER_ATTR_CFRAME,
79         EXPP_RENDER_ATTR_SFRAME,
80         EXPP_RENDER_ATTR_EFRAME,
81         EXPP_RENDER_ATTR_FPS,
82         EXPP_RENDER_ATTR_FPS_BASE,
83         EXPP_RENDER_ATTR_SIZEX,
84         EXPP_RENDER_ATTR_SIZEY,
85         EXPP_RENDER_ATTR_GAUSSFILTER,
86         EXPP_RENDER_ATTR_MBLURFACTOR,
87         EXPP_RENDER_ATTR_BAKEMARGIN,
88         EXPP_RENDER_ATTR_BAKEMODE,
89         EXPP_RENDER_ATTR_BAKEDIST,
90         EXPP_RENDER_ATTR_BAKENORMALSPACE,
91         EXPP_RENDER_ATTR_BAKEBIAS
92 };
93
94 #define EXPP_RENDER_ATTR_CFRA                 2
95 #define EXPP_RENDER_ATTR_ANTISHIFT            3
96 #define EXPP_RENDER_ATTR_EDGEINT              4
97 #define EXPP_RENDER_ATTR_EFRA                 5
98 #define EXPP_RENDER_ATTR_QUALITY             11
99 #define EXPP_RENDER_ATTR_GAUSS               13
100 #define EXPP_RENDER_ATTR_BLURFAC             14
101
102 #define EXPP_RENDER_ATTR_YF_EXPOSURE         20
103 #define EXPP_RENDER_ATTR_YF_GAMMA            21
104 #define EXPP_RENDER_ATTR_YF_GIDEPTH          22
105 #define EXPP_RENDER_ATTR_YF_GICDEPTH         23
106 #define EXPP_RENDER_ATTR_YF_GIPHOTONCOUNT    24
107 #define EXPP_RENDER_ATTR_YF_GIPHOTONMIXCOUNT 25
108 #define EXPP_RENDER_ATTR_YF_GIPHOTONRADIUS   26
109 #define EXPP_RENDER_ATTR_YF_GIPIXPERSAMPLE   27
110 #define EXPP_RENDER_ATTR_YF_GIPOWER          28
111 #define EXPP_RENDER_ATTR_YF_GIREFINE         29
112 #define EXPP_RENDER_ATTR_YF_GISHADOWQUAL     30
113 #define EXPP_RENDER_ATTR_YF_RAYBIAS          31
114 #define EXPP_RENDER_ATTR_YF_PROCCOUNT        32
115 #define EXPP_RENDER_ATTR_YF_RAYDEPTH         33
116 #define EXPP_RENDER_ATTR_YF_GIMETHOD         34
117 #define EXPP_RENDER_ATTR_YF_GIQUALITY        35
118
119
120 /* Render doc strings */
121 static char M_Render_doc[] = "The Blender Render module";
122
123 /* deprecated callbacks */
124 static PyObject *RenderData_SetRenderPath( BPy_RenderData *self,
125                 PyObject *args );
126 static PyObject *RenderData_SetBackbufPath( BPy_RenderData *self,
127                 PyObject *args );
128 static PyObject *RenderData_SetOversamplingLevel( BPy_RenderData * self,
129                 PyObject * args );
130 static PyObject *RenderData_SetRenderWinSize( BPy_RenderData * self,
131                 PyObject * args );
132 static PyObject *RenderData_SetBorder( BPy_RenderData * self,
133                 PyObject * args );
134 static PyObject *RenderData_SetRenderer( BPy_RenderData * self,
135                 PyObject * args );
136 static PyObject *RenderData_SetImageType( BPy_RenderData * self,
137                 PyObject * args );
138 static PyObject *RenderData_Render( BPy_RenderData * self );
139 static PyObject *RenderData_Bake( BPy_RenderData * self );
140
141 /* BPy_RenderData Internal Protocols */
142
143 static PyObject *RenderData_repr( BPy_RenderData * self )
144 {
145         if( self->renderContext )
146                 return PyString_FromFormat( "[RenderData \"%s\"]",
147                                             self->scene->id.name + 2 );
148         else
149                 return PyString_FromString( "NULL" );
150 }
151
152 /***************************************************************************/
153 /* local utility routines for manipulating data                            */
154 /***************************************************************************/
155 static PyObject *M_Render_BitToggleInt( PyObject * args, int setting,
156                                         int *structure )
157 {
158         int flag;
159
160         if( !PyArg_ParseTuple( args, "i", &flag ) )
161                 return ( EXPP_ReturnPyObjError
162                          ( PyExc_AttributeError,
163                            "expected TRUE or FALSE (1 or 0)" ) );
164
165         if( flag < 0 || flag > 1 )
166                 return ( EXPP_ReturnPyObjError
167                          ( PyExc_AttributeError,
168                            "expected TRUE or FALSE (1 or 0)" ) );
169
170         if( flag )
171                 *structure |= setting;
172         else
173                 *structure &= ~setting;
174         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
175
176         Py_RETURN_NONE;
177
178 }
179
180 static PyObject *M_Render_BitToggleShort( PyObject * args, short setting,
181                                           short *structure )
182 {
183         int flag;
184
185         if( !PyArg_ParseTuple( args, "i", &flag ) )
186                 return ( EXPP_ReturnPyObjError
187                          ( PyExc_AttributeError,
188                            "expected TRUE or FALSE (1 or 0)" ) );
189
190         if( flag < 0 || flag > 1 )
191                 return ( EXPP_ReturnPyObjError
192                          ( PyExc_AttributeError,
193                            "expected TRUE or FALSE (1 or 0)" ) );
194
195         if( flag )
196                 *structure |= setting;
197         else
198                 *structure &= ~setting;
199         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
200
201         Py_RETURN_NONE;
202
203 }
204
205 static PyObject *M_Render_GetSetAttributeFloat( PyObject * args,
206                                                 float *structure, float min,
207                                                 float max )
208 {
209         float property = -10.0f;
210         char error[48];
211
212         if( !PyArg_ParseTuple( args, "|f", &property ) )
213                 return ( EXPP_ReturnPyObjError
214                          ( PyExc_AttributeError, "expected float" ) );
215
216         if( property != -10.0f ) {
217                 if( property < min || property > max ) {
218                         sprintf( error, "out of range - expected %f to %f",
219                                  min, max );
220                         return ( EXPP_ReturnPyObjError
221                                  ( PyExc_AttributeError, error ) );
222                 }
223
224                 *structure = property;
225                 EXPP_allqueue( REDRAWBUTSSCENE, 0 );
226                 Py_RETURN_NONE;
227         } else
228                 return PyFloat_FromDouble( *structure );
229 }
230
231 static PyObject *M_Render_GetSetAttributeShort( PyObject * args,
232                                                 short *structure, int min,
233                                                 int max )
234 {
235         short property = -10;
236         char error[48];
237
238         if( !PyArg_ParseTuple( args, "|h", &property ) )
239                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
240                                                 "expected int" ) );
241
242         if( property != -10 ) {
243                 if( property < min || property > max ) {
244                         sprintf( error, "out of range - expected %d to %d",
245                                  min, max );
246                         return ( EXPP_ReturnPyObjError
247                                  ( PyExc_AttributeError, error ) );
248                 }
249
250                 *structure = property;
251                 EXPP_allqueue( REDRAWBUTSSCENE, 0 );
252                 Py_RETURN_NONE;
253         } else
254                 return PyInt_FromLong( (long int)*structure );
255 }
256
257 static PyObject *M_Render_GetSetAttributeInt( PyObject * args, int *structure,
258                                               int min, int max )
259 {
260         int property = -10;
261         char error[48];
262
263         if( !PyArg_ParseTuple( args, "|i", &property ) )
264                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
265                                                 "expected int" ) );
266
267         if( property != -10 ) {
268                 if( property < min || property > max ) {
269                         sprintf( error, "out of range - expected %d to %d",
270                                  min, max );
271                         return ( EXPP_ReturnPyObjError
272                                  ( PyExc_AttributeError, error ) );
273                 }
274
275                 *structure = property;
276                 
277                 /* compare memory locations, not values */
278                 if (&G.scene->r.cfra == structure) {
279                         /* are we changing the current frame?
280                         update all objects, so python scripts can export all objects
281                         in a scene without worrying about the view layers */
282                         scene_update_for_newframe(G.scene, (1<<20) - 1);
283                 }
284                 
285                 /*I dont think this should be here, whatif the scene is not the current scene - campbell*/
286                 EXPP_allqueue( REDRAWBUTSSCENE, 0 );
287                 
288                 Py_RETURN_NONE;
289         } else
290                 return  PyInt_FromLong( *structure );
291 }
292
293
294 static void M_Render_DoSizePreset( BPy_RenderData * self, short xsch,
295                                    short ysch, short xasp, short yasp,
296                                    short size, short xparts, short yparts,
297                                    short fps, float fps_base,
298                                    float a, float b, float c,
299                                    float d )
300 {
301         self->renderContext->xsch = xsch;
302         self->renderContext->ysch = ysch;
303         self->renderContext->xasp = xasp;
304         self->renderContext->yasp = yasp;
305         self->renderContext->size = size;
306         self->renderContext->frs_sec = fps;
307         self->renderContext->frs_sec_base = fps_base;
308         self->renderContext->xparts = xparts;
309         self->renderContext->yparts = yparts;
310
311         BLI_init_rctf( &self->renderContext->safety, a, b, c, d );
312         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
313         EXPP_allqueue( REDRAWVIEWCAM, 0 );
314 }
315
316 /** set / get boolean */
317
318 static int M_Render_setBooleanShort( BPy_RenderData * self, PyObject *value, short* var )
319 {
320         if( !PyInt_Check( value ) )
321                 return EXPP_ReturnIntError( PyExc_TypeError,
322                                                                         "expected boolean value" );
323
324         *var = (PyInt_AsLong( value )) ? 1 : 0;
325
326         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
327         return 0;
328 }
329
330 static PyObject *M_Render_getBooleanShort( BPy_RenderData * self, short var )
331 {
332         return PyInt_FromLong( (long) var );
333 }
334
335 /** set / get float */
336
337 static int M_Render_setFloat( BPy_RenderData *self, PyObject *value, float *var, float min, float max )
338 {
339         float val;
340         char error[48];
341
342         if( !PyFloat_Check( value ) )
343                 return EXPP_ReturnIntError( PyExc_TypeError,
344                                                                         "expected float value" );
345
346         val = (float) PyFloat_AsDouble( value );
347
348         /* check range */
349         if ( val < min || val > max ) {
350                 sprintf( error, "out of range - expected %f to %f", min, max );
351                 return EXPP_ReturnIntError( PyExc_TypeError,error );
352         }
353
354         *var = val;
355
356         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
357         return 0;
358 }
359
360 static PyObject *M_Render_getFloat( BPy_RenderData *self, float var )
361 {
362         return PyFloat_FromDouble( (double) var );
363 }
364
365 /** set / get integer */
366
367 static int M_Render_setInt( BPy_RenderData *self, PyObject *value, int *var, int min, int max )
368 {
369         int val;
370         char error[48];
371
372         if( !PyInt_Check( value ) )
373                 return EXPP_ReturnIntError( PyExc_TypeError,
374                                                                         "expected integer value" );
375
376         val = (int) PyInt_AsLong( value );
377
378         /* check range */
379         if ( val < min || val > max ) {
380                 sprintf( error, "out of range - expected %d to %d", min, max );
381                 return EXPP_ReturnIntError( PyExc_TypeError,error );
382         }
383
384         *var = val;
385
386         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
387         return 0;
388 }
389
390 static PyObject *M_Render_getInt( BPy_RenderData *self, int var )
391 {
392         return PyInt_FromLong( (long) var );
393 }
394
395 /***************************************************************************/
396 /* Render Module Function Definitions                                      */
397 /***************************************************************************/
398
399 PyObject *M_Render_CloseRenderWindow( PyObject * self )
400 {
401         BIF_close_render_display(  );
402         Py_RETURN_NONE;
403 }
404
405 PyObject *M_Render_SetRenderWinPos( PyObject * self, PyObject * args )
406 {
407         PyObject *list = NULL;
408         char *loc = NULL;
409         int x;
410
411         if( !PyArg_ParseTuple( args, "O!", &PyList_Type, &list ) )
412                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
413                                                 "expected a list" ) );
414
415         G.winpos = 0;
416         for( x = 0; x < PyList_Size( list ); x++ ) {
417                 if( !PyArg_Parse( PyList_GetItem( list, x ), "s", &loc ) ) {
418                         return EXPP_ReturnPyObjError( PyExc_TypeError,
419                                                       "python list not parseable" );
420                 }
421                 if( strcmp( loc, "SW" ) == 0 || strcmp( loc, "sw" ) == 0 )
422                         G.winpos |= 1;
423                 else if( strcmp( loc, "S" ) == 0 || strcmp( loc, "s" ) == 0 )
424                         G.winpos |= 2;
425                 else if( strcmp( loc, "SE" ) == 0 || strcmp( loc, "se" ) == 0 )
426                         G.winpos |= 4;
427                 else if( strcmp( loc, "W" ) == 0 || strcmp( loc, "w" ) == 0 )
428                         G.winpos |= 8;
429                 else if( strcmp( loc, "C" ) == 0 || strcmp( loc, "c" ) == 0 )
430                         G.winpos |= 16;
431                 else if( strcmp( loc, "E" ) == 0 || strcmp( loc, "e" ) == 0 )
432                         G.winpos |= 32;
433                 else if( strcmp( loc, "NW" ) == 0 || strcmp( loc, "nw" ) == 0 )
434                         G.winpos |= 64;
435                 else if( strcmp( loc, "N" ) == 0 || strcmp( loc, "n" ) == 0 )
436                         G.winpos |= 128;
437                 else if( strcmp( loc, "NE" ) == 0 || strcmp( loc, "ne" ) == 0 )
438                         G.winpos |= 256;
439                 else
440                         return EXPP_ReturnPyObjError( PyExc_AttributeError,
441                                                       "list contains unknown string" );
442         }
443         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
444
445         Py_RETURN_NONE;
446 }
447
448 PyObject *M_Render_EnableDispView( PyObject * self )
449 {
450         G.displaymode = R_DISPLAYIMAGE;
451         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
452
453         Py_RETURN_NONE;
454 }
455
456 PyObject *M_Render_EnableDispWin( PyObject * self )
457 {
458         G.displaymode = R_DISPLAYWIN;
459         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
460
461         Py_RETURN_NONE;
462 }
463
464
465 /***************************************************************************/
466 /* BPy_RenderData Function Definitions                                     */
467 /***************************************************************************/
468
469 PyObject *RenderData_Render( BPy_RenderData * self )
470 {
471         Scene *oldsce;
472
473         if (!G.background) {
474                 oldsce = G.scene;
475                 set_scene( self->scene );
476                 BIF_do_render( 0 );
477                 set_scene( oldsce );
478         }
479
480         else { /* background mode (blender -b file.blend -P script) */
481                 Render *re= RE_NewRender(G.scene->id.name);
482
483
484
485                 int end_frame = G.scene->r.efra;
486
487                 if (G.scene != self->scene)
488                         return EXPP_ReturnPyObjError (PyExc_RuntimeError,
489                                 "scene to render in bg mode must be the active scene");
490
491                 G.scene->r.efra = G.scene->r.sfra;
492
493                 RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
494
495                 G.scene->r.efra = end_frame;
496         }
497
498         Py_RETURN_NONE;
499 }
500
501 /***************************************************************************/
502 /* BPy_Bake Function Definitions                                           */
503 /***************************************************************************/
504
505 PyObject *RenderData_Bake( BPy_RenderData * self )
506 {
507         char *error_msg = NULL;
508         Scene *oldsce;
509
510         oldsce = G.scene;
511         set_scene( self->scene );
512         
513         objects_bake_render(0, &error_msg);
514         
515         set_scene( oldsce );
516         
517         if (error_msg)
518                 return EXPP_ReturnPyObjError( PyExc_RuntimeError, error_msg );
519         
520         Py_RETURN_NONE;
521 }
522
523 /* 
524  * This will save the rendered image to an output file path already defined.
525  */
526 PyObject *RenderData_SaveRenderedImage ( BPy_RenderData * self, PyObject *args )
527 {
528         char dir[FILE_MAXDIR * 2], str[FILE_MAXFILE * 2];
529         char *name_str, filepath[FILE_MAXDIR+FILE_MAXFILE];
530         RenderResult *rr = NULL;
531         int zbuff;
532         
533         if( !PyArg_ParseTuple( args, "s|i", &name_str, &zbuff ) )
534                 return EXPP_ReturnPyObjError( PyExc_TypeError,
535                                 "expected a filename (string) and optional int" );
536         
537         if (G.background)
538                 return EXPP_ReturnPyObjError( PyExc_RuntimeError,
539                                 "saveRenderedImage does not work in background mode, use renderAnim() instead" );
540         
541         if( strlen(self->renderContext->pic) + strlen(name_str)
542                         >= sizeof(filepath) )
543                 return EXPP_ReturnPyObjError( PyExc_ValueError,
544                                 "full filename too long" );
545
546         if (zbuff !=0   ) zbuff = 1; /*required 1/0 */ /* removed! (ton) */
547
548         BLI_strncpy( filepath, self->renderContext->pic, sizeof(filepath) );
549         strcat(filepath, name_str);
550
551         rr = RE_GetResult(RE_GetRender(G.scene->id.name));
552         if(!rr) {
553                 return EXPP_ReturnPyObjError (PyExc_ValueError, "No image rendered");
554         } else {
555                 if(G.ima[0]==0) {
556                         strcpy(dir, G.sce);
557                         BLI_splitdirstring(dir, str);
558                         strcpy(G.ima, dir);
559                 }
560                 BIF_save_rendered_image(filepath);
561         }
562         Py_RETURN_NONE;
563 }
564
565 PyObject *RenderData_RenderAnim( BPy_RenderData * self )
566 {
567         Scene *oldsce;
568
569         if (!G.background) {
570                 oldsce = G.scene;
571                 set_scene( self->scene );
572                 BIF_do_render( 1 );
573                 set_scene( oldsce );
574         }
575         else { /* background mode (blender -b file.blend -P script) */
576                 Render *re= RE_NewRender(G.scene->id.name);
577                 
578                 if (G.scene != self->scene)
579                         return EXPP_ReturnPyObjError (PyExc_RuntimeError,
580                                 "scene to render in bg mode must be the active scene");
581
582                 if (G.scene->r.sfra > G.scene->r.efra)
583                         return EXPP_ReturnPyObjError (PyExc_RuntimeError,
584                                 "start frame must be less or equal to end frame");
585                 
586                 RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
587         }
588         Py_RETURN_NONE;
589 }
590
591 PyObject *RenderData_Play( BPy_RenderData * self )
592 {
593         char file[FILE_MAXDIR + FILE_MAXFILE];
594         extern char bprogname[];
595         char str[FILE_MAXDIR + FILE_MAXFILE];
596         int pos[2], size[2];
597         char txt[64];
598
599 #ifdef WITH_QUICKTIME
600         if( self->renderContext->imtype == R_QUICKTIME ) {
601
602                 strcpy( file, self->renderContext->pic );
603                 BLI_convertstringcode( file, G.sce );
604                 BLI_make_existing_file( file );
605                 if( BLI_strcasecmp( file + strlen( file ) - 4, ".mov" ) ) {
606                         sprintf( txt, "%04d_%04d.mov",
607                                  ( self->renderContext->sfra ),
608                                  ( self->renderContext->efra ) );
609                         strcat( file, txt );
610                 }
611         } else
612 #endif
613         {
614
615                 strcpy( file, self->renderContext->pic );
616                 BLI_convertstringcode( file, G.sce );
617                 
618                 BLI_make_existing_file( file );
619                 if( BLI_strcasecmp( file + strlen( file ) - 4, ".avi" ) ) {
620                         sprintf( txt, "%04d_%04d.avi",
621                                  ( self->renderContext->sfra ),
622                                  ( self->renderContext->efra ) );
623                         strcat( file, txt );
624                 }
625         }
626         if( BLI_exist( file ) ) {
627                 calc_renderwin_rectangle(640, 480, G.winpos, pos, size);
628                 sprintf( str, "%s -a -p %d %d \"%s\"", bprogname, pos[0],
629                          pos[1], file );
630                 system( str );
631         } else {
632                 BKE_makepicstring( file, G.scene->r.pic, self->renderContext->sfra, G.scene->r.imtype);
633                 if( BLI_exist( file ) ) {
634                         calc_renderwin_rectangle(640, 480, G.winpos, pos, size);
635 #ifdef WIN32
636                         sprintf( str, "%s -a -p %d %d \"%s\"", bprogname,
637                                  pos[0], pos[1], file );
638 #else
639                         sprintf( str, "\"%s\" -a -p %d %d \"%s\"", bprogname,
640                                  pos[0], pos[1], file );
641 #endif
642                         system( str );
643                 } else
644                         sprintf( "Can't find image: %s", file );
645         }
646
647         Py_RETURN_NONE;
648 }
649
650 PyObject *RenderData_EnableBackbuf( BPy_RenderData * self, PyObject * args )
651 {
652         return M_Render_BitToggleShort( args, 1,
653                                         &self->renderContext->bufflag );
654 }
655
656 PyObject *RenderData_EnableExtensions( BPy_RenderData * self, PyObject * args )
657 {
658         return M_Render_BitToggleInt( args, R_EXTENSION,
659                                         &self->renderContext->scemode );
660 }
661
662 PyObject *RenderData_EnableSequencer( BPy_RenderData * self, PyObject * args )
663 {
664         return M_Render_BitToggleInt( args, R_DOSEQ,
665                                         &self->renderContext->scemode );
666 }
667
668 PyObject *RenderData_EnableRenderDaemon( BPy_RenderData * self,
669                                          PyObject * args )
670 {
671         return M_Render_BitToggleInt( args, R_BG_RENDER,
672                                         &self->renderContext->scemode );
673 }
674
675 PyObject *RenderData_EnableToonShading( BPy_RenderData * self,
676                                         PyObject * args )
677 {
678         return M_Render_BitToggleInt( args, R_EDGE,
679                                       &self->renderContext->mode );
680 }
681
682 PyObject *RenderData_EdgeIntensity( BPy_RenderData * self, PyObject * args )
683 {
684         return M_Render_GetSetAttributeShort( args,
685                                               &self->renderContext->edgeint, 0,
686                                               255 );
687 }
688
689 PyObject *RenderData_SetEdgeColor( BPy_RenderData * self, PyObject * args )
690 {
691         float red, green, blue;
692
693         if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) )
694                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
695                                                 "expected three floats" ) );
696
697         if( red < 0 || red > 1 )
698                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
699                                                 "value out of range 0.000 - 1.000 (red)" ) );
700         if( green < 0 || green > 1 )
701                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
702                                                 "value out of range 0.000 - 1.000 (green)" ) );
703         if( blue < 0 || blue > 1 )
704                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
705                                                 "value out of range 0.000 - 1.000 (blue)" ) );
706
707         self->renderContext->edgeR = red;
708         self->renderContext->edgeG = green;
709         self->renderContext->edgeB = blue;
710
711         Py_RETURN_NONE;
712 }
713
714 PyObject *RenderData_GetEdgeColor( BPy_RenderData * self )
715 {
716         char rgb[24];
717
718         sprintf( rgb, "[%.3f,%.3f,%.3f]", self->renderContext->edgeR,
719                  self->renderContext->edgeG, self->renderContext->edgeB );
720         return PyString_FromString( rgb );
721 }
722
723 PyObject *RenderData_EnableOversampling( BPy_RenderData * self,
724                                          PyObject * args )
725 {
726         return M_Render_BitToggleInt( args, R_OSA,
727                                       &self->renderContext->mode );
728 }
729
730 static int RenderData_setOSALevel( BPy_RenderData * self,
731                 PyObject * value )
732 {
733         int level;
734
735         if( !PyInt_Check( value ) )
736                 return EXPP_ReturnIntError( PyExc_TypeError,
737                                 "expected int argument" );
738
739         level = PyInt_AsLong( value );
740         if( level != 5 && level != 8 && level != 11 && level != 16 )
741                 return EXPP_ReturnIntError( PyExc_ValueError,
742                                 "expected 5, 8, 11, or 16" );
743
744         self->renderContext->osa = (short)level;
745         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
746
747         return 0;
748 }
749
750 PyObject *RenderData_EnableMotionBlur( BPy_RenderData * self, PyObject * args )
751 {
752         return M_Render_BitToggleInt( args, R_MBLUR,
753                                       &self->renderContext->mode );
754 }
755
756 PyObject *RenderData_MotionBlurLevel( BPy_RenderData * self, PyObject * args )
757 {
758         return M_Render_GetSetAttributeFloat( args,
759                                               &self->renderContext->blurfac,
760                                               0.01f, 5.0f );
761 }
762
763 PyObject *RenderData_PartsX( BPy_RenderData * self, PyObject * args )
764 {
765         return M_Render_GetSetAttributeShort( args,
766                                               &self->renderContext->xparts, 1,
767                                               512 );
768 }
769
770 PyObject *RenderData_PartsY( BPy_RenderData * self, PyObject * args )
771 {
772         return M_Render_GetSetAttributeShort( args,
773                                               &self->renderContext->yparts, 1,
774                                               64 );
775 }
776
777 PyObject *RenderData_EnableSky( BPy_RenderData * self )
778 {
779         self->renderContext->alphamode = R_ADDSKY;
780         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
781
782         Py_RETURN_NONE;
783 }
784
785 PyObject *RenderData_EnablePremultiply( BPy_RenderData * self )
786 {
787         self->renderContext->alphamode = R_ALPHAPREMUL;
788         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
789
790         Py_RETURN_NONE;
791 }
792
793 PyObject *RenderData_EnableKey( BPy_RenderData * self )
794 {
795         self->renderContext->alphamode = R_ALPHAKEY;
796         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
797
798         Py_RETURN_NONE;
799 }
800
801 PyObject *RenderData_EnableShadow( BPy_RenderData * self, PyObject * args )
802 {
803         return M_Render_BitToggleInt( args, R_SHADOW,
804                                       &self->renderContext->mode );
805 }
806
807 PyObject *RenderData_EnableEnvironmentMap( BPy_RenderData * self,
808                                            PyObject * args )
809 {
810         return M_Render_BitToggleInt( args, R_ENVMAP,
811                                       &self->renderContext->mode );
812 }
813
814 PyObject *RenderData_EnablePanorama( BPy_RenderData * self, PyObject * args )
815 {
816         return M_Render_BitToggleInt( args, R_PANORAMA,
817                                       &self->renderContext->mode );
818 }
819
820 PyObject *RenderData_EnableRayTracing( BPy_RenderData * self, PyObject * args )
821 {
822         return M_Render_BitToggleInt( args, R_RAYTRACE,
823                                       &self->renderContext->mode );
824 }
825
826 PyObject *RenderData_EnableRadiosityRender( BPy_RenderData * self,
827                                             PyObject * args )
828 {
829         return M_Render_BitToggleInt( args, R_RADIO,
830                                       &self->renderContext->mode );
831 }
832 PyObject *RenderData_EnableFieldRendering( BPy_RenderData * self,
833                                            PyObject * args )
834 {
835         return M_Render_BitToggleInt( args, R_FIELDS,
836                                       &self->renderContext->mode );
837 }
838
839 PyObject *RenderData_EnableOddFieldFirst( BPy_RenderData * self,
840                                           PyObject * args )
841 {
842         return M_Render_BitToggleInt( args, R_ODDFIELD,
843                                       &self->renderContext->mode );
844 }
845
846 PyObject *RenderData_EnableFieldTimeDisable( BPy_RenderData * self,
847                                              PyObject * args )
848 {
849         return M_Render_BitToggleInt( args, R_FIELDSTILL,
850                                       &self->renderContext->mode );
851 }
852
853 PyObject *RenderData_EnableGaussFilter( BPy_RenderData * self,
854                                         PyObject * args )
855 {
856         return M_Render_BitToggleInt( args, R_GAUSS,
857                                       &self->renderContext->mode );
858         
859         /* note, this now is obsolete (ton) */
860         /* we now need a call like RenderData_SetFilter() or so */
861         /* choices are listed in DNA_scene_types.h (search filtertype) */
862 }
863
864 PyObject *RenderData_EnableBorderRender( BPy_RenderData * self,
865                                          PyObject * args )
866 {
867         return M_Render_BitToggleInt( args, R_BORDER,
868                                       &self->renderContext->mode );
869 }
870
871 static int RenderData_setBorder( BPy_RenderData * self, PyObject * args )
872 {
873         float xmin, ymin, xmax, ymax;
874
875         if( PyList_Check( args ) )
876                 args = PySequence_Tuple( args );
877         else
878                 Py_INCREF( args );
879
880         if( !PyArg_ParseTuple( args, "ffff", &xmin, &ymin, &xmax, &ymax ) ) {
881                 Py_DECREF( args );
882                 return EXPP_ReturnIntError( PyExc_TypeError,
883                                                 "expected four floats" );
884         }
885
886         self->renderContext->border.xmin = EXPP_ClampFloat( xmin, 0.0, 1.0 );
887         self->renderContext->border.xmax = EXPP_ClampFloat( xmax, 0.0, 1.0 );
888         self->renderContext->border.ymin = EXPP_ClampFloat( ymin, 0.0, 1.0 );
889         self->renderContext->border.ymax = EXPP_ClampFloat( ymax, 0.0, 1.0 );
890
891         EXPP_allqueue( REDRAWVIEWCAM, 1 );
892
893         Py_DECREF( args );
894         return 0;
895 }
896
897 static PyObject *RenderData_getBorder( BPy_RenderData * self )
898 {
899         return Py_BuildValue( "[ffff]", 
900                         self->renderContext->border.xmin,
901                         self->renderContext->border.ymin,
902                         self->renderContext->border.xmax,
903                         self->renderContext->border.ymax );
904 }
905
906 PyObject *RenderData_EnableGammaCorrection( BPy_RenderData * self,
907                                             PyObject * args )
908 {
909         return M_Render_BitToggleInt( args, R_GAMMA,
910                                       &self->renderContext->mode );
911 }
912
913 PyObject *RenderData_GaussFilterSize( BPy_RenderData * self, PyObject * args )
914 {
915         return M_Render_GetSetAttributeFloat( args,
916                                               &self->renderContext->gauss,
917                                               0.5f, 1.5f );
918 }
919
920 PyObject *RenderData_AspectRatioX( BPy_RenderData * self, PyObject * args )
921 {
922         return M_Render_GetSetAttributeFloat( args, &self->renderContext->xasp,
923                                               1.0f, 200.0f );
924 }
925
926 PyObject *RenderData_AspectRatioY( BPy_RenderData * self, PyObject * args )
927 {
928         return M_Render_GetSetAttributeFloat( args, &self->renderContext->yasp,
929                                               1.0f, 200.0f );
930 }
931
932 PyObject *RenderData_StartFrame( BPy_RenderData * self, PyObject * args )
933 {
934         return M_Render_GetSetAttributeInt( args, &self->renderContext->sfra,
935                                             1, MAXFRAME );
936 }
937
938 PyObject *RenderData_CurrentFrame( BPy_RenderData * self, PyObject * args )
939 {
940         return M_Render_GetSetAttributeInt( args, &self->renderContext->cfra,
941                                             1, MAXFRAME );
942 }
943
944 PyObject *RenderData_EndFrame( BPy_RenderData * self, PyObject * args )
945 {
946         return M_Render_GetSetAttributeInt( args, &self->renderContext->efra,
947                                             1, MAXFRAME );
948 }
949
950 PyObject *RenderData_ImageSizeX( BPy_RenderData * self, PyObject * args )
951 {
952         return M_Render_GetSetAttributeShort( args, &self->renderContext->xsch,
953                                               4, 10000 );
954 }
955
956 PyObject *RenderData_ImageSizeY( BPy_RenderData * self, PyObject * args )
957 {
958         return M_Render_GetSetAttributeShort( args, &self->renderContext->ysch,
959                                               4, 10000 );
960 }
961
962 static int RenderData_setRenderer( BPy_RenderData * self, PyObject * value )
963 {
964         int type;
965
966         if( !PyInt_Check( value ) )
967                 return EXPP_ReturnIntError( PyExc_TypeError,
968                                 "expected constant INTERNAL or YAFRAY" );
969
970         type = PyInt_AsLong( value );
971         if( type == R_INTERN )
972                 self->renderContext->renderer = R_INTERN;
973         else if( type == R_YAFRAY )
974                 self->renderContext->renderer = R_YAFRAY;
975         else
976                 return EXPP_ReturnIntError( PyExc_ValueError,
977                                 "expected constant INTERNAL or YAFRAY" );
978
979         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
980         return 0;
981 }
982
983 PyObject *RenderData_EnableCropping( void )
984 {
985 /*      return M_Render_BitToggleInt( args, R_MOVIECROP,
986                                       &self->renderContext->mode );
987 */
988         printf("obsolete: movie cropping option is now default\n");
989         Py_RETURN_NONE;
990 }
991
992
993 static int RenderData_setImageType( BPy_RenderData *self, PyObject *value )
994 {
995         int type;
996
997         if( !PyInt_Check( value ) )
998                 return EXPP_ReturnIntError( PyExc_TypeError,
999                                 "expected int constant" );
1000
1001         type = PyInt_AS_LONG( value );
1002
1003         /*
1004          * this same logic and more is in buttons_scene.c imagetype_pup code but
1005          * only in generating strings for the popup menu, no way to reuse that :(
1006          */
1007
1008         switch( type ) {
1009         case R_AVIRAW :
1010         case R_AVIJPEG :
1011         case R_TARGA :
1012         case R_RAWTGA :
1013         case R_RADHDR :
1014         case R_PNG :
1015         case R_BMP :
1016         case R_JPEG90 :
1017         case R_HAMX :
1018         case R_IRIS :
1019         case R_IRIZ :
1020         case R_TIFF :
1021         case R_CINEON :
1022         case R_DPX :
1023 #ifdef _WIN32
1024         case R_AVICODEC :
1025 #endif
1026 #ifdef WITH_OPENEXR
1027         case R_OPENEXR :
1028         case R_MULTILAYER :
1029 #endif
1030 #ifdef WITH_FFMPEG
1031         case R_FFMPEG :
1032 #endif
1033                 self->renderContext->imtype = type;
1034                 break;
1035         case R_QUICKTIME :
1036                 if( G.have_quicktime ) {
1037                         self->renderContext->imtype = R_QUICKTIME;
1038                         break;
1039                 }
1040         default:
1041                 return EXPP_ReturnIntError( PyExc_ValueError,
1042                                 "unknown constant - see modules dict for help" );
1043         }
1044
1045         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1046         return 0;
1047 }
1048
1049 PyObject *RenderData_Quality( BPy_RenderData * self, PyObject * args )
1050 {
1051         return M_Render_GetSetAttributeShort( args,
1052                                               &self->renderContext->quality,
1053                                               10, 100 );
1054 }
1055
1056 PyObject *RenderData_FramesPerSec( BPy_RenderData * self, PyObject * args )
1057 {
1058         return M_Render_GetSetAttributeShort( args,
1059                                               &self->renderContext->frs_sec, 1,
1060                                               120 );
1061 }
1062
1063 PyObject *RenderData_EnableGrayscale( BPy_RenderData * self )
1064 {
1065         self->renderContext->planes = R_PLANESBW;
1066         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1067
1068         Py_RETURN_NONE;
1069 }
1070
1071 PyObject *RenderData_EnableRGBColor( BPy_RenderData * self )
1072 {
1073         self->renderContext->planes = R_PLANES24;
1074         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1075
1076         Py_RETURN_NONE;
1077 }
1078
1079 PyObject *RenderData_EnableRGBAColor( BPy_RenderData * self )
1080 {
1081         self->renderContext->planes = R_PLANES32;
1082         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1083
1084         Py_RETURN_NONE;
1085 }
1086
1087 PyObject *RenderData_SizePreset( BPy_RenderData * self, PyObject * args )
1088 {
1089         int type;
1090
1091         if( !PyArg_ParseTuple( args, "i", &type ) )
1092                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1093                                                 "expected constant" ) );
1094
1095         if( type == B_PR_PAL ) {
1096                 M_Render_DoSizePreset( self, 720, 576, 54, 51, 100,
1097                                        self->renderContext->xparts,
1098                                        self->renderContext->yparts, 25, 1.0f,
1099                                        0.1f,
1100                                        0.9f, 0.1f, 0.9f );
1101                 self->renderContext->mode &= ~R_PANORAMA;
1102                 BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
1103                                0.9f );
1104         } else if( type == B_PR_NTSC ) {
1105                 M_Render_DoSizePreset( self, 720, 480, 10, 11, 100, 1, 1,
1106                                        30, 1.001f, 
1107                                        0.1f, 0.9f, 0.1f, 0.9f );
1108                 self->renderContext->mode &= ~R_PANORAMA;
1109                 BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
1110                                0.9f );
1111         } else if( type == B_PR_PRESET ) {
1112                 M_Render_DoSizePreset( self, 720, 576, 54, 51, 100, 1, 1,
1113                                        self->renderContext->frs_sec, 
1114                                        self->renderContext->frs_sec_base, 
1115                                        0.1f, 0.9f,
1116                                        0.1f, 0.9f );
1117                 self->renderContext->mode = R_OSA + R_SHADOW + R_FIELDS;
1118                 self->renderContext->imtype = R_TARGA;
1119                 BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
1120                                0.9f );
1121         } else if( type == B_PR_PRV ) {
1122                 M_Render_DoSizePreset( self, 640, 512, 1, 1, 50, 1, 1,
1123                                        self->renderContext->frs_sec, 
1124                                        self->renderContext->frs_sec_base, 
1125                                        0.1f, 0.9f,
1126                                        0.1f, 0.9f );
1127                 self->renderContext->mode &= ~R_PANORAMA;
1128                 BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
1129                                0.9f );
1130         } else if( type == B_PR_PC ) {
1131                 M_Render_DoSizePreset( self, 640, 480, 100, 100, 100, 1, 1,
1132                                        self->renderContext->frs_sec, 
1133                                        self->renderContext->frs_sec_base, 
1134                                        0.0f, 1.0f,
1135                                        0.0f, 1.0f );
1136                 self->renderContext->mode &= ~R_PANORAMA;
1137                 BLI_init_rctf( &self->renderContext->safety, 0.0f, 1.0f, 0.0f,
1138                                1.0f );
1139         } else if( type == B_PR_PAL169 ) {
1140                 M_Render_DoSizePreset( self, 720, 576, 64, 45, 100, 1, 1,
1141                                        25, 1.0f, 0.1f, 0.9f, 0.1f, 0.9f );
1142                 self->renderContext->mode &= ~R_PANORAMA;
1143                 BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
1144                                0.9f );
1145         } else if( type == B_PR_PANO ) {
1146                 M_Render_DoSizePreset( self, 36, 176, 115, 100, 100, 16, 1,
1147                                        self->renderContext->frs_sec, 
1148                                        self->renderContext->frs_sec_base, 
1149                                        0.1f, 0.9f,
1150                                        0.1f, 0.9f );
1151                 self->renderContext->mode |= R_PANORAMA;
1152                 BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
1153                                0.9f );
1154         } else if( type == B_PR_FULL ) {
1155                 M_Render_DoSizePreset( self, 1280, 1024, 1, 1, 100, 1, 1,
1156                                        self->renderContext->frs_sec, 
1157                                        self->renderContext->frs_sec_base, 
1158                                        0.1f, 0.9f,
1159                                        0.1f, 0.9f );
1160                 self->renderContext->mode &= ~R_PANORAMA;
1161                 BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
1162                                0.9f );
1163         } else
1164                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1165                                                 "unknown constant - see modules dict for help" ) );
1166
1167         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1168         Py_RETURN_NONE;
1169 }
1170
1171 /*
1172
1173 PyObject *RenderData_SetYafrayGIQuality( BPy_RenderData * self,
1174                                          PyObject * args )
1175 {
1176         int type;
1177
1178         if( !PyArg_ParseTuple( args, "i", &type ) )
1179                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1180                                                 "expected constant" ) );
1181
1182         if( type == PY_NONE || type == PY_LOW ||
1183             type == PY_MEDIUM || type == PY_HIGH ||
1184             type == PY_HIGHER || type == PY_BEST ) {
1185                 self->renderContext->GIquality = (short)type;
1186         } else
1187                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1188                                                 "unknown constant - see modules dict for help" ) );
1189
1190         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1191         Py_RETURN_NONE;
1192 }
1193
1194 PyObject *RenderData_SetYafrayGIMethod( BPy_RenderData * self,
1195                                         PyObject * args )
1196 {
1197         int type;
1198
1199         if( !PyArg_ParseTuple( args, "i", &type ) )
1200                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1201                                                 "expected constant" ) );
1202
1203         if( type == PY_NONE || type == PY_SKYDOME || type == PY_FULL ) {
1204                 self->renderContext->GImethod = (short)type;
1205         } else
1206                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1207                                                 "unknown constant - see modules dict for help" ) );
1208
1209         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1210         Py_RETURN_NONE;
1211 }
1212 */
1213
1214 /* (die) beg */
1215
1216 /* YafRay - Yafray GI Method */
1217
1218 static int RenderData_setYafrayGIQuality( BPy_RenderData * self, PyObject * value )
1219 {
1220         long type;
1221
1222         if( !PyInt_Check( value ) )
1223                 return EXPP_ReturnIntError( PyExc_TypeError,
1224                                                                         "expected constant" );
1225
1226         type = PyInt_AsLong( value );
1227
1228         if( type == PY_NONE   || type == PY_LOW  ||
1229             type == PY_MEDIUM || type == PY_HIGH ||
1230             type == PY_HIGHER || type == PY_BEST ||
1231             type == PY_USEAOSETTINGS
1232                 ) {
1233                 self->renderContext->GIquality = (short)type;
1234         } else {
1235                 return EXPP_ReturnIntError( PyExc_TypeError,
1236                                                                         "expected constant NONE, LOW, MEDIUM, HIGHER or BEST" );
1237         }
1238
1239         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1240         return 0;
1241 }
1242
1243 static PyObject *RenderData_getYafrayGIQuality( BPy_RenderData * self )
1244 {
1245         return PyInt_FromLong( (long) self->renderContext->GIquality );
1246 }
1247
1248 static PyObject *RenderData_SetYafrayGIQuality( BPy_RenderData * self,
1249                                                                                                 PyObject * args )
1250 {
1251         return EXPP_setterWrapper( (void*) self, args,
1252                                                            (setter) RenderData_setYafrayGIQuality );
1253 }
1254
1255 static PyObject *RenderData_GetYafrayGIQuality( BPy_RenderData * self )
1256 {
1257         return RenderData_getYafrayGIQuality(self);
1258 }
1259
1260 /* YafRay - Yafray GI Method */
1261
1262 static int RenderData_setYafrayGIMethod( BPy_RenderData * self, PyObject * value )
1263 {
1264         int type;
1265
1266         if( !PyInt_Check( value ) )
1267                 return EXPP_ReturnIntError( PyExc_TypeError,
1268                                 "expected constant NONE, SKYDOME or FULL" );
1269
1270         type = PyInt_AsLong( value );
1271         if( type == PY_NONE || type == PY_SKYDOME || type == PY_FULL ) {
1272                 self->renderContext->GImethod = (short)type;
1273         } else {
1274                 return EXPP_ReturnIntError( PyExc_TypeError,
1275                                                                         "expected constant NONE, SKYDOME or FULL" );
1276         }
1277
1278         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
1279         return 0;
1280 }
1281
1282 static PyObject *RenderData_getYafrayGIMethod( BPy_RenderData * self )
1283 {
1284         return PyInt_FromLong( (long)self->renderContext->GImethod );
1285 }
1286
1287 static PyObject *RenderData_GetYafrayGIMethod( BPy_RenderData * self )
1288 {
1289         return RenderData_getYafrayGIMethod(self);
1290 }
1291
1292 static PyObject *RenderData_SetYafrayGIMethod( BPy_RenderData * self,
1293                                                                                            PyObject * args )
1294 {
1295         return EXPP_setterWrapper( (void *)self, args,
1296                         (setter)RenderData_setYafrayGIMethod );
1297 }
1298
1299
1300 /* YafRay - Export to XML */
1301
1302 static int RenderData_setYafrayExportToXML( BPy_RenderData * self, PyObject * value )
1303 {
1304         return M_Render_setBooleanShort( self, value, &self->renderContext->YFexportxml );
1305 }
1306
1307 static PyObject *RenderData_getYafrayExportToXML( BPy_RenderData * self )
1308 {
1309         return M_Render_getBooleanShort( self, self->renderContext->YFexportxml );
1310 }
1311
1312 /** Auto AA */
1313
1314 static int RenderData_setYafrayAutoAntiAliasing( BPy_RenderData * self, PyObject * value )
1315 {
1316         return M_Render_setBooleanShort( self, value, &self->renderContext->YF_AA );
1317 }
1318
1319 static PyObject *RenderData_getYafrayAutoAntiAliasing( BPy_RenderData * self )
1320 {
1321         return M_Render_getBooleanShort( self, self->renderContext->YF_AA );
1322 }
1323
1324 /** Clamp RGB */
1325
1326 static int RenderData_setYafrayClampRGB( BPy_RenderData * self, PyObject * value )
1327 {
1328         return M_Render_setBooleanShort( self, value, &self->renderContext->YF_clamprgb );
1329 }
1330
1331 static PyObject *RenderData_getYafrayClampRGB( BPy_RenderData * self )
1332 {
1333         return M_Render_getBooleanShort( self, self->renderContext->YF_clamprgb );
1334 }
1335
1336 /** YafRay - Anti-Aliasing Passes */
1337
1338 static int RenderData_setYafrayAntiAliasingPasses( BPy_RenderData * self, PyObject * value )
1339 {
1340         return M_Render_setInt( self, value, &self->renderContext->YF_AApasses, 0, 64 );
1341 }
1342
1343 static PyObject *RenderData_getYafrayAntiAliasingPasses( BPy_RenderData * self )
1344 {
1345         return M_Render_getInt( self, self->renderContext->YF_AApasses );
1346 }
1347
1348 /** YafRay - Anti-Aliasing Samples */
1349
1350 static int RenderData_setYafrayAntiAliasingSamples( BPy_RenderData * self, PyObject * value )
1351 {
1352         return M_Render_setInt( self, value, &self->renderContext->YF_AAsamples, 0, 2048 );
1353 }
1354
1355 static PyObject *RenderData_getYafrayAntiAliasingSamples( BPy_RenderData * self )
1356 {
1357         return M_Render_getInt( self, self->renderContext->YF_AAsamples );
1358 }
1359
1360 /* YafRay - Anti-Aliasing Pixel Filter Size */
1361
1362 static int RenderData_setYafrayAntiAliasingPixelSize( BPy_RenderData * self, PyObject * value )
1363 {
1364         return M_Render_setFloat( self, value, &self->renderContext->YF_AApixelsize, 1.0, 2.0 );
1365 }
1366
1367 static PyObject *RenderData_getYafrayAntiAliasingPixelSize( BPy_RenderData * self )
1368 {
1369         return M_Render_getFloat( self, self->renderContext->YF_AApixelsize );
1370 }
1371
1372 /* YafRay - Anti-Aliasing threshold */
1373
1374 static int RenderData_setYafrayAntiAliasingThreshold( BPy_RenderData * self, PyObject * value )
1375 {
1376         return M_Render_setFloat( self, value, &self->renderContext->YF_AAthreshold, 0.05, 1.0 );
1377 }
1378
1379 static PyObject *RenderData_getYafrayAntiAliasingThreshold( BPy_RenderData * self )
1380 {
1381         return M_Render_getFloat( self, self->renderContext->YF_AAthreshold );
1382 }
1383
1384 /* YafRay - Cache occlusion/irradiance samples (faster) */
1385
1386 static int RenderData_setYafrayGICache( BPy_RenderData * self, PyObject * value )
1387 {
1388         return M_Render_setBooleanShort( self, value, &self->renderContext->GIcache );
1389 }
1390
1391 static PyObject *RenderData_getYafrayGICache( BPy_RenderData * self )
1392 {
1393         return M_Render_getBooleanShort( self, self->renderContext->GIcache );
1394 }
1395
1396 /* YafRay - Enable/disable bumpnormals for cache
1397    (faster, but no bumpmapping in total indirectly lit areas) */
1398
1399 static int RenderData_setYafrayGICacheBumpNormals( BPy_RenderData * self, PyObject * value )
1400 {
1401         return M_Render_setBooleanShort( self, value, &self->renderContext->YF_nobump );
1402 }
1403
1404 static PyObject *RenderData_getYafrayGICacheBumpNormals( BPy_RenderData * self )
1405 {
1406         return M_Render_getBooleanShort( self, self->renderContext->YF_nobump );
1407 }
1408
1409 /* YafRay - Shadow quality, keep it under 0.95 :-) */
1410
1411 static int RenderData_setYafrayGICacheShadowQuality( BPy_RenderData * self, PyObject * value )
1412 {
1413         return M_Render_setFloat( self, value, &self->renderContext->GIshadowquality, 0.01, 1.0 );
1414 }
1415
1416 static PyObject *RenderData_getYafrayGICacheShadowQuality( BPy_RenderData * self )
1417 {
1418         return M_Render_getFloat( self, self->renderContext->GIshadowquality );
1419 }
1420
1421 /* YafRay - Threshold to refine shadows EXPERIMENTAL. 1 = no refinement */
1422
1423 static int RenderData_setYafrayGICacheRefinement( BPy_RenderData * self, PyObject * value )
1424 {
1425         return M_Render_setFloat( self, value, &self->renderContext->GIrefinement, 0.001, 1.0 );
1426 }
1427
1428 static PyObject *RenderData_getYafrayGICacheRefinement( BPy_RenderData * self )
1429 {
1430         return M_Render_getFloat( self, self->renderContext->GIrefinement );
1431 }
1432
1433 /* YafRay - Maximum number of pixels without samples, the lower the better and slower */
1434
1435 static int RenderData_setYafrayGICachePixelsPerSample( BPy_RenderData * self, PyObject * value )
1436 {
1437         return M_Render_setInt( self, value, &self->renderContext->GIpixelspersample, 1, 50 );
1438 }
1439
1440 static PyObject *RenderData_getYafrayGICachePixelsPerSample( BPy_RenderData * self )
1441 {
1442         return M_Render_getInt( self, self->renderContext->GIpixelspersample );
1443 }
1444
1445 /** YafRay - Enable/disable use of global photons to help in GI */
1446
1447 static int RenderData_setYafrayGIPhotons( BPy_RenderData * self, PyObject * value )
1448 {
1449         return M_Render_setBooleanShort( self, value, &self->renderContext->GIphotons );
1450 }
1451
1452 static PyObject *RenderData_getYafrayGIPhotons( BPy_RenderData * self )
1453 {
1454         return M_Render_getBooleanShort( self, self->renderContext->GIphotons );
1455 }
1456
1457 /** YafRay - If true the photonmap is shown directly in the render for tuning */
1458
1459 static int RenderData_setYafrayGITunePhotons( BPy_RenderData * self, PyObject * value )
1460 {
1461         return M_Render_setBooleanShort( self, value, &self->renderContext->GIdirect );
1462 }
1463
1464 static PyObject *RenderData_getYafrayGITunePhotons( BPy_RenderData * self )
1465 {
1466         return M_Render_getBooleanShort( self, self->renderContext->GIdirect );
1467 }
1468
1469 /* (die) end */
1470
1471 PyObject *RenderData_YafrayGIPower( BPy_RenderData * self, PyObject * args )
1472 {
1473         if( self->renderContext->GImethod > 0 ) {
1474                 return M_Render_GetSetAttributeFloat( args,
1475                                                       &self->renderContext->
1476                                                       GIpower, 0.01f,
1477                                                       100.00f );
1478         } else
1479                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1480                                                 "YafrayGIMethod must be set to 'SKYDOME' or 'FULL'" ) );
1481 }
1482
1483 PyObject *RenderData_YafrayGIIndirPower( BPy_RenderData * self, PyObject * args )
1484 {
1485         return M_Render_GetSetAttributeFloat( args,
1486                                                   &self->renderContext->
1487                                                   GIindirpower, 0.01f,
1488                                                   100.00f );
1489 }
1490
1491 PyObject *RenderData_YafrayGIDepth( BPy_RenderData * self, PyObject * args )
1492 {
1493         if( self->renderContext->GImethod == 2 ) {
1494                 return M_Render_GetSetAttributeInt( args,
1495                                                     &self->renderContext->
1496                                                     GIdepth, 1, 100 );
1497         } else
1498                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1499                                                 "YafrayGIMethod must be set to 'FULL'" ) );
1500 }
1501
1502 PyObject *RenderData_YafrayGICDepth( BPy_RenderData * self, PyObject * args )
1503 {
1504         if( self->renderContext->GImethod == 2 ) {
1505                 return M_Render_GetSetAttributeInt( args,
1506                                                     &self->renderContext->
1507                                                     GIcausdepth, 1, 100 );
1508         } else
1509                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1510                                                 "YafrayGIMethod must be set to 'FULL'" ) );
1511 }
1512
1513 PyObject *RenderData_EnableYafrayGICache( BPy_RenderData * self,
1514                                           PyObject * args )
1515 {
1516         if( self->renderContext->GImethod == 2 ) {
1517                 return M_Render_BitToggleShort( args, 1,
1518                                                 &self->renderContext->
1519                                                 GIcache );
1520         } else
1521                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1522                                                 "YafrayGIMethod must be set to 'FULL'" ) );
1523 }
1524
1525 PyObject *RenderData_EnableYafrayGIPhotons( BPy_RenderData * self,
1526                                             PyObject * args )
1527 {
1528         if( self->renderContext->GImethod == 2 ) {
1529                 return M_Render_BitToggleShort( args, 1,
1530                                                 &self->renderContext->
1531                                                 GIphotons );;
1532         } else
1533                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1534                                                 "YafrayGIMethod must be set to 'FULL'" ) );
1535 }
1536
1537 PyObject *RenderData_YafrayGIPhotonCount( BPy_RenderData * self,
1538                                           PyObject * args )
1539 {
1540         if( self->renderContext->GImethod == 2
1541             && self->renderContext->GIphotons == 1 ) {
1542                 return M_Render_GetSetAttributeInt( args,
1543                                                     &self->renderContext->
1544                                                     GIphotoncount, 100000,
1545                                                     10000000 );
1546         } else
1547                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1548                                                 "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) );
1549 }
1550
1551 PyObject *RenderData_YafrayGIPhotonRadius( BPy_RenderData * self,
1552                                            PyObject * args )
1553 {
1554         if( self->renderContext->GImethod == 2
1555             && self->renderContext->GIphotons == 1 ) {
1556                 return M_Render_GetSetAttributeFloat( args,
1557                                                       &self->renderContext->
1558                                                       GIphotonradius, 0.00001f,
1559                                                       100.0f );
1560         } else
1561                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1562                                                 "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) );
1563 }
1564
1565 PyObject *RenderData_YafrayGIPhotonMixCount( BPy_RenderData * self,
1566                                              PyObject * args )
1567 {
1568         if( self->renderContext->GImethod == 2
1569             && self->renderContext->GIphotons == 1 ) {
1570                 return M_Render_GetSetAttributeInt( args,
1571                                                     &self->renderContext->
1572                                                     GImixphotons, 100, 1000 );
1573         } else
1574                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1575                                                 "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) );
1576 }
1577
1578 PyObject *RenderData_EnableYafrayGITunePhotons( BPy_RenderData * self,
1579                                                 PyObject * args )
1580 {
1581         if( self->renderContext->GImethod == 2
1582             && self->renderContext->GIphotons == 1 ) {
1583                 return M_Render_BitToggleShort( args, 1,
1584                                                 &self->renderContext->
1585                                                 GIdirect );;
1586         } else
1587                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1588                                                 "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) );
1589 }
1590
1591 PyObject *RenderData_YafrayGIShadowQuality( BPy_RenderData * self,
1592                                             PyObject * args )
1593 {
1594         if( self->renderContext->GImethod == 2
1595             && self->renderContext->GIcache == 1 ) {
1596                 return M_Render_GetSetAttributeFloat( args,
1597                                                       &self->renderContext->
1598                                                       GIshadowquality, 0.01f,
1599                                                       1.0f );
1600         } else
1601                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1602                                                 "YafrayGIMethod must be set to 'FULL' and GICache must be enabled" ) );
1603 }
1604
1605 PyObject *RenderData_YafrayGIPixelsPerSample( BPy_RenderData * self,
1606                                               PyObject * args )
1607 {
1608         if( self->renderContext->GImethod == 2
1609             && self->renderContext->GIcache == 1 ) {
1610                 return M_Render_GetSetAttributeInt( args,
1611                                                     &self->renderContext->
1612                                                     GIpixelspersample, 1, 50 );
1613         } else
1614                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1615                                                 "YafrayGIMethod must be set to 'FULL' and GICache must be enabled" ) );
1616 }
1617
1618 PyObject *RenderData_YafrayGIRefinement( BPy_RenderData * self,
1619                                          PyObject * args )
1620 {
1621         if( self->renderContext->GImethod == 2
1622             && self->renderContext->GIcache == 1 ) {
1623                 return M_Render_GetSetAttributeFloat( args,
1624                                                       &self->renderContext->
1625                                                       GIrefinement, 0.001f,
1626                                                       1.0f );
1627         } else
1628                 return ( EXPP_ReturnPyObjError( PyExc_StandardError,
1629                                                 "YafrayGIMethod must be set to 'FULL' and GICache must be enabled" ) );
1630 }
1631
1632 PyObject *RenderData_YafrayRayBias( BPy_RenderData * self, PyObject * args )
1633 {
1634         return M_Render_GetSetAttributeFloat( args,
1635                                               &self->renderContext->YF_raybias,
1636                                               0.0f, 10.0f );
1637 }
1638
1639 PyObject *RenderData_YafrayRayDepth( BPy_RenderData * self, PyObject * args )
1640 {
1641         return M_Render_GetSetAttributeInt( args,
1642                                             &self->renderContext->YF_raydepth,
1643                                             1, 80 );
1644 }
1645
1646 PyObject *RenderData_YafrayGamma( BPy_RenderData * self, PyObject * args )
1647 {
1648         return M_Render_GetSetAttributeFloat( args,
1649                                               &self->renderContext->YF_gamma,
1650                                               0.001f, 5.0f );
1651 }
1652
1653 PyObject *RenderData_YafrayExposure( BPy_RenderData * self, PyObject * args )
1654 {
1655         return M_Render_GetSetAttributeFloat( args,
1656                                               &self->renderContext->
1657                                               YF_exposure, 0.0f, 10.0f );
1658 }
1659
1660 PyObject *RenderData_EnableGameFrameStretch( BPy_RenderData * self )
1661 {
1662         self->scene->framing.type = SCE_GAMEFRAMING_SCALE;
1663         Py_RETURN_NONE;
1664 }
1665
1666 PyObject *RenderData_EnableGameFrameExpose( BPy_RenderData * self )
1667 {
1668         self->scene->framing.type = SCE_GAMEFRAMING_EXTEND;
1669         Py_RETURN_NONE;
1670 }
1671
1672 PyObject *RenderData_EnableGameFrameBars( BPy_RenderData * self )
1673 {
1674         self->scene->framing.type = SCE_GAMEFRAMING_BARS;
1675         Py_RETURN_NONE;
1676 }
1677
1678 PyObject *RenderData_SetGameFrameColor( BPy_RenderData * self,
1679                                         PyObject * args )
1680 {
1681         float red = 0.0f;
1682         float green = 0.0f;
1683         float blue = 0.0f;
1684
1685         if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) )
1686                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1687                                                 "expected three floats" ) );
1688
1689         if( red < 0 || red > 1 )
1690                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1691                                                 "value out of range 0.000 - 1.000 (red)" ) );
1692         if( green < 0 || green > 1 )
1693                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1694                                                 "value out of range 0.000 - 1.000 (green)" ) );
1695         if( blue < 0 || blue > 1 )
1696                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1697                                                 "value out of range 0.000 - 1.000 (blue)" ) );
1698
1699         self->scene->framing.col[0] = red;
1700         self->scene->framing.col[1] = green;
1701         self->scene->framing.col[2] = blue;
1702
1703         Py_RETURN_NONE;
1704 }
1705
1706 PyObject *RenderData_GetGameFrameColor( BPy_RenderData * self )
1707 {
1708         char rgb[24];
1709
1710         sprintf( rgb, "[%.3f,%.3f,%.3f]", self->scene->framing.col[0],
1711                  self->scene->framing.col[1], self->scene->framing.col[2] );
1712         return PyString_FromString( rgb );
1713 }
1714
1715 #ifdef __sgi
1716 PyObject *RenderData_SGIMaxsize( BPy_RenderData * self, PyObject * args )
1717 {
1718         return M_Render_GetSetAttributeShort( args,
1719                                               &self->renderContext->maximsize,
1720                                               0, 500 );
1721 }
1722
1723 PyObject *RenderData_EnableSGICosmo( BPy_RenderData *self, PyObject *args )
1724 {
1725         return M_Render_BitToggleInt( args, R_COSMO,
1726                                       &self->renderContext->mode );
1727 }
1728 #else
1729 PyObject *RenderData_SGIMaxsize( void )
1730 {
1731         return EXPP_ReturnPyObjError( PyExc_StandardError,
1732                         "SGI is not defined on this machine" );
1733 }
1734
1735 PyObject *RenderData_EnableSGICosmo( void )
1736 {
1737         return EXPP_ReturnPyObjError( PyExc_StandardError,
1738                         "SGI is not defined on this machine" );
1739 }
1740 #endif
1741
1742 PyObject *RenderData_OldMapValue( BPy_RenderData * self, PyObject * args )
1743 {
1744         PyObject *tmp = M_Render_GetSetAttributeInt(args,
1745                 &self->renderContext->framapto, 1, 900);
1746         self->renderContext->framelen =
1747                 (float)self->renderContext->framapto / self->renderContext->images;
1748         return tmp;
1749 }
1750
1751 PyObject *RenderData_NewMapValue( BPy_RenderData * self, PyObject * args )
1752 {
1753         PyObject *tmp = M_Render_GetSetAttributeInt(args,
1754                         &self->renderContext->images, 1, 900);
1755         self->renderContext->framelen =
1756                 (float)self->renderContext->framapto / self->renderContext->images;
1757         return tmp;
1758 }
1759
1760 static PyObject *RenderData_getTimeCode( BPy_RenderData * self) {
1761     char tc[12];
1762     int h, m, s, cfa;
1763     double fps;
1764     
1765     fps = (double) self->renderContext->frs_sec / 
1766             self->renderContext->frs_sec_base;
1767     cfa = self->renderContext->cfra-1;
1768         s = cfa / fps;
1769         m = s / 60;
1770         h = m / 60;
1771     if( h > 99 )
1772         return PyString_FromString("Time Greater than 99 Hours!");      
1773
1774         sprintf( tc, "%02d:%02d:%02d:%02d", h%60, m%60, s%60, 
1775                  (int) (cfa - ((int) (cfa / fps) * fps)));
1776         return PyString_FromString(tc);
1777 }            
1778
1779
1780 /***************************************************************************/
1781 /* Render layer functions                                                  */
1782 /***************************************************************************/
1783 PyObject *RenderData_getRenderLayers(BPy_RenderData * self)
1784 {
1785         PyObject *list, *layer;
1786         SceneRenderLayer *srl;
1787         
1788         list = PyList_New(0);
1789         
1790         for(srl= self->renderContext->layers.first; srl; srl= srl->next) {      
1791                 layer = RenderLayer_CreatePyObject( self->scene, srl );
1792                 PyList_Append(list, layer);
1793                 Py_DECREF(layer);
1794         }
1795         return list;
1796 }
1797
1798 PyObject *RenderData_removeRenderLayer(BPy_RenderData * self, BPy_RenderLayer *value)
1799 {
1800         int index;
1801         if (!BPy_RenderLayer_Check(value))
1802                 return EXPP_ReturnPyObjError( PyExc_TypeError,
1803                         "can only remove a render layer" );
1804         
1805         index = BLI_findindex(&self->renderContext->layers, value->renderLayer);
1806         
1807         if (index == -1)
1808                 return EXPP_ReturnPyObjError( PyExc_ValueError,
1809                         "render layer is not in this scene" );
1810         
1811         if (BLI_countlist(&self->renderContext->layers)<=1)
1812                 return EXPP_ReturnPyObjError( PyExc_RuntimeError,
1813                         "cannot remove the last render layer" );
1814         
1815         BLI_remlink(&self->scene->r.layers, value->renderLayer);
1816         MEM_freeN(value->renderLayer);
1817         self->scene->r.actlay= 0;
1818         
1819         if(self->scene->nodetree) {
1820                 bNode *node;
1821                 for(node= self->scene->nodetree->nodes.first; node; node= node->next) {
1822                         if(node->type==CMP_NODE_R_LAYERS && node->id==NULL) {
1823                                 if(node->custom1==index)
1824                                         node->custom1= 0;
1825                                 else if(node->custom1 > index)
1826                                         node->custom1--;
1827                         }
1828                 }
1829         }
1830         
1831         value->renderLayer = NULL;
1832         Py_RETURN_NONE;
1833 }
1834
1835 PyObject *RenderData_addRenderLayer(BPy_RenderData * self ) {
1836         scene_add_render_layer(self->scene);
1837         return RenderLayer_CreatePyObject( self->scene, self->renderContext->layers.last );
1838         
1839 }
1840
1841 /***************************************************************************/
1842 /* generic handlers for getting/setting attributes                         */
1843 /***************************************************************************/
1844
1845 /*
1846  * get floating point attributes
1847  */
1848
1849 static PyObject *RenderData_getFloatAttr( BPy_RenderData *self, void *type )
1850 {
1851         float param;
1852
1853         switch( (int)type ) {
1854         case EXPP_RENDER_ATTR_GAUSSFILTER:
1855                 param = self->renderContext->gauss;
1856                 break;
1857         case EXPP_RENDER_ATTR_MBLURFACTOR:
1858                 param = self->renderContext->blurfac;
1859                 break;
1860         case EXPP_RENDER_ATTR_FPS_BASE:
1861                 param = self->renderContext->frs_sec_base;
1862                 break;
1863         case EXPP_RENDER_ATTR_BAKEDIST:
1864                 param = self->renderContext->bake_maxdist;
1865                 break;
1866         case EXPP_RENDER_ATTR_BAKEBIAS:
1867                 param = self->renderContext->bake_biasdist;
1868                 break;
1869         case EXPP_RENDER_ATTR_ASPECTX:
1870                 param = (long)self->renderContext->xasp;
1871                 break;
1872         case EXPP_RENDER_ATTR_ASPECTY:
1873                 param = (long)self->renderContext->yasp;
1874                 break;
1875         default:
1876                 return EXPP_ReturnPyObjError( PyExc_RuntimeError,
1877                                 "undefined type constant in RenderData_getFloatAttr" );
1878         }
1879         return PyFloat_FromDouble( param );
1880 }
1881
1882 /*
1883  * set floating point attributes which require clamping
1884  */
1885
1886 static int RenderData_setFloatAttrClamp( BPy_RenderData *self, PyObject *value,
1887                 void *type )
1888 {
1889         float *param;
1890         float min, max;
1891
1892         switch( (int)type ) {
1893         case EXPP_RENDER_ATTR_GAUSSFILTER:
1894                 min = 0.5f;
1895                 max = 1.5f;
1896                 param = &self->renderContext->gauss;
1897                 break;
1898         case EXPP_RENDER_ATTR_MBLURFACTOR:
1899             min = 0.01f;
1900                 max = 5.0f;
1901                 param = &self->renderContext->blurfac;
1902                 break;
1903         case EXPP_RENDER_ATTR_FPS_BASE:
1904                 min = 1.0f;
1905                 max = 120.0f;
1906                 param = &self->renderContext->frs_sec_base;
1907                 break;
1908         case EXPP_RENDER_ATTR_BAKEDIST:
1909                 min = 0.0f;
1910                 max = 1000.0f;
1911                 param = &self->renderContext->bake_maxdist;
1912                 break;
1913         case EXPP_RENDER_ATTR_BAKEBIAS:
1914                 min = 0.0f;
1915                 max = 1000.0f;
1916                 param = &self->renderContext->bake_biasdist;
1917                 break;
1918         case EXPP_RENDER_ATTR_ASPECTX:
1919                 min = 1.0f;
1920                 max = 200.0f;
1921                 param = &self->renderContext->xasp;
1922                 break;
1923         case EXPP_RENDER_ATTR_ASPECTY:
1924                 min = 1.0f;
1925                 max = 200.0f;
1926                 param = &self->renderContext->yasp;
1927                 break;
1928         default:
1929                 return EXPP_ReturnIntError( PyExc_RuntimeError,
1930                                 "undefined type constant in RenderData_setFloatAttrClamp" );
1931         }
1932         return EXPP_setFloatClamped( value, param, min, max );
1933 }
1934
1935 /*
1936  * get integer attributes
1937  */
1938
1939 static PyObject *RenderData_getIValueAttr( BPy_RenderData *self, void *type )
1940 {
1941         long param;
1942
1943         switch( (int)type ) {
1944         case EXPP_RENDER_ATTR_XPARTS:
1945                 param = (long)self->renderContext->xparts;
1946                 break;
1947         case EXPP_RENDER_ATTR_YPARTS:
1948                 param = (long)self->renderContext->yparts;
1949                 break;
1950         case EXPP_RENDER_ATTR_CFRAME:
1951                 param = (long)self->renderContext->cfra;
1952                 break;
1953         case EXPP_RENDER_ATTR_EFRAME:
1954                 param = (long)self->renderContext->efra;
1955                 break;
1956         case EXPP_RENDER_ATTR_SFRAME:
1957                 param = (long)self->renderContext->sfra;
1958                 break;
1959         case EXPP_RENDER_ATTR_FPS:
1960                 param = self->renderContext->frs_sec;
1961                 break;
1962         case EXPP_RENDER_ATTR_SIZEX:
1963                 param = self->renderContext->xsch;
1964                 break;
1965         case EXPP_RENDER_ATTR_SIZEY:
1966                 param = self->renderContext->ysch;
1967                 break;
1968         case EXPP_RENDER_ATTR_BAKEMARGIN:
1969                 param = self->renderContext->bake_filter;
1970                 break;
1971         case EXPP_RENDER_ATTR_BAKEMODE:
1972                 param = self->renderContext->bake_mode;
1973                 break;
1974         case EXPP_RENDER_ATTR_BAKENORMALSPACE:
1975                 param = self->renderContext->bake_normal_space;
1976                 break;
1977         default:
1978                 return EXPP_ReturnPyObjError( PyExc_RuntimeError,
1979                                 "undefined type constant in RenderData_setIValueAttrClamp" );
1980         }
1981         return PyInt_FromLong( param );
1982 }
1983
1984 /*
1985  * set integer attributes which require clamping
1986  */
1987
1988 static int RenderData_setIValueAttrClamp( BPy_RenderData *self, PyObject *value,
1989                 void *type )
1990 {
1991         void *param;
1992         int min, max, size;
1993
1994         switch( (int)type ) {
1995         case EXPP_RENDER_ATTR_XPARTS:
1996                 min = 1;
1997                 max = 512;
1998                 size = 'h';
1999                 param = &self->renderContext->xparts;
2000                 break;
2001         case EXPP_RENDER_ATTR_YPARTS:
2002                 min = 1;
2003                 max = 64;
2004                 size = 'h';
2005                 param = &self->renderContext->yparts;
2006                 break;
2007         case EXPP_RENDER_ATTR_CFRAME:
2008                 min = 1;
2009                 max = MAXFRAME;
2010                 size = 'i';
2011                 param = &self->renderContext->cfra;
2012                 break;
2013         case EXPP_RENDER_ATTR_EFRAME:
2014                 min = 1;
2015                 max = MAXFRAME;
2016                 size = 'i';
2017                 param = &self->renderContext->efra;
2018                 break;
2019         case EXPP_RENDER_ATTR_SFRAME:
2020                 min = 1;
2021             max = MAXFRAME;
2022                 size = 'i';
2023                 param = &self->renderContext->sfra;
2024                 break;
2025         case EXPP_RENDER_ATTR_FPS:
2026                 min = 1;
2027                 max = 120;
2028                 size = 'h';
2029                 param = &self->renderContext->frs_sec;
2030                 break;
2031         case EXPP_RENDER_ATTR_SIZEX:
2032                 min = 4;
2033                 max = 10000;
2034                 size = 'h';
2035                 param = &self->renderContext->xsch;
2036                 break;
2037         case EXPP_RENDER_ATTR_SIZEY:
2038                 min = 4;
2039                 max = 10000;
2040                 size = 'h';
2041                 param = &self->renderContext->ysch;
2042                 break;
2043         case EXPP_RENDER_ATTR_BAKEMARGIN:
2044                 min = 0;
2045                 max = 32;
2046                 size = 'h';
2047                 param = &self->renderContext->bake_filter;
2048                 break;
2049         case EXPP_RENDER_ATTR_BAKEMODE:
2050                 min = RE_BAKE_LIGHT;
2051                 max = RE_BAKE_SHADOW;
2052                 size = 'h';
2053                 param = &self->renderContext->bake_mode;
2054                 break;
2055         case EXPP_RENDER_ATTR_BAKENORMALSPACE:
2056                 min = R_BAKE_SPACE_CAMERA;
2057                 max = R_BAKE_SPACE_TANGENT;
2058                 size = 'h';
2059                 param = &self->renderContext->bake_normal_space;
2060                 break;
2061         default:
2062                 return EXPP_ReturnIntError( PyExc_RuntimeError,
2063                                 "undefined type constant in RenderData_setIValueAttrClamp" );
2064         }
2065         return EXPP_setIValueClamped( value, param, min, max, size );
2066 }
2067
2068 /***************************************************************************/
2069 /* handlers for other getting/setting attributes                           */
2070 /***************************************************************************/
2071
2072 static PyObject *RenderData_getSubImTypeBits( BPy_RenderData *self, void* type )
2073 {
2074         return EXPP_getBitfield( &self->renderContext->subimtype, (int)type, 'h' );
2075 }
2076
2077 static int RenderData_setSubImTypeBits( BPy_RenderData* self, PyObject *value,
2078                 void* type )
2079 {
2080         return EXPP_setBitfield( value, &self->renderContext->subimtype,
2081                         (int)type, 'h' );
2082 }
2083
2084 static PyObject *RenderData_getModeBit( BPy_RenderData *self, void* type )
2085 {
2086         return EXPP_getBitfield( &self->renderContext->mode,
2087                         (int)type, 'i' );
2088 }
2089
2090 static int RenderData_setModeBit( BPy_RenderData* self, PyObject *value,
2091                 void* type )
2092 {
2093         return EXPP_setBitfield( value, &self->renderContext->mode,
2094                         (int)type, 'i' );
2095 }
2096
2097 #define MODE_MASK ( R_OSA | R_SHADOW | R_GAMMA | R_ENVMAP | R_EDGE | \
2098         R_FIELDS | R_FIELDSTILL | R_RADIO | R_BORDER | R_PANORAMA | R_CROP | \
2099         R_ODDFIELD | R_MBLUR | R_RAYTRACE | R_FIXED_THREADS )
2100
2101 static PyObject *RenderData_getMode( BPy_RenderData *self )
2102 {
2103         return PyInt_FromLong( (long)(self->renderContext->mode & MODE_MASK) );
2104 }
2105
2106 static int RenderData_setMode( BPy_RenderData* self, PyObject *arg )
2107 {
2108         int value;
2109
2110         if( !PyInt_Check( arg ) )
2111                 return EXPP_ReturnIntError( PyExc_TypeError,
2112                                 "expected int argument" );
2113
2114         value = PyInt_AsLong( arg );
2115         if( value & ~MODE_MASK )
2116                 return EXPP_ReturnIntError( PyExc_ValueError, 
2117                                 "unexpected bits set in argument" );
2118
2119         self->renderContext->mode = (short)value;
2120         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
2121
2122         return 0;
2123 }
2124
2125 static PyObject *RenderData_getSceModeBits( BPy_RenderData *self, void* type )
2126 {
2127         return EXPP_getBitfield( &self->renderContext->scemode, (int)type, 'i' );
2128 }
2129
2130 static int RenderData_setSceModeBits( BPy_RenderData* self, PyObject *value,
2131                 void* type )
2132 {
2133         return EXPP_setBitfield( value, &self->renderContext->scemode,
2134                         (int)type, 'i' );
2135 }
2136
2137 static PyObject *RenderData_getSceMode( BPy_RenderData *self )
2138 {
2139         return PyInt_FromLong ( (long)self->renderContext->scemode );
2140 }
2141
2142 static int RenderData_setSceMode( BPy_RenderData* self, PyObject *arg )
2143 {
2144         int value;
2145
2146         if( !PyInt_Check( arg ) )
2147                 return EXPP_ReturnIntError( PyExc_TypeError,
2148                                 "expected int argument" );
2149
2150         value = PyInt_AsLong( arg );
2151         if( value & ~( R_EXTENSION | R_DOSEQ ) )
2152                 return EXPP_ReturnIntError( PyExc_ValueError, 
2153                                 "unexpected bits set in argument" );
2154
2155         self->renderContext->scemode = (int)value;
2156         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
2157
2158         return 0;
2159 }
2160  
2161 static PyObject *RenderData_getFramingType( BPy_RenderData *self )
2162 {
2163         return PyInt_FromLong( (long)self->scene->framing.type );
2164 }
2165
2166 static int RenderData_setFramingType( BPy_RenderData *self, PyObject *value )
2167 {
2168         return EXPP_setIValueRange( value, &self->scene->framing.type,
2169                         SCE_GAMEFRAMING_BARS, SCE_GAMEFRAMING_SCALE, 'b' );
2170 }
2171
2172 static PyObject *RenderData_getEdgeColor( BPy_RenderData * self )
2173 {
2174         return Py_BuildValue( "[fff]", self->renderContext->edgeR,
2175                         self->renderContext->edgeG, self->renderContext->edgeB );
2176 }
2177
2178 static int RenderData_setEdgeColor( BPy_RenderData * self, PyObject * args )
2179 {
2180         float red, green, blue;
2181
2182         /* if we get a list, convert to a tuple; otherwise hope for the best */
2183         if( PyList_Check( args ) )
2184                 args = PySequence_Tuple( args );
2185         else
2186                 Py_INCREF( args );
2187
2188         if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) ) {
2189                 Py_DECREF( args );
2190                 return EXPP_ReturnIntError( PyExc_TypeError, "expected three floats" );
2191         }
2192         Py_DECREF( args );
2193
2194         self->renderContext->edgeR = EXPP_ClampFloat( red, 0.0, 1.0 );
2195         self->renderContext->edgeG = EXPP_ClampFloat( green, 0.0, 1.0 );
2196         self->renderContext->edgeB = EXPP_ClampFloat( blue, 0.0, 1.0 );
2197         return 0;
2198 }
2199
2200 static PyObject *RenderData_getOSALevel( BPy_RenderData * self )
2201 {
2202         return PyInt_FromLong( (long)self->renderContext->osa );
2203 }
2204
2205 static PyObject *RenderData_getRenderer( BPy_RenderData * self )
2206 {
2207         return PyInt_FromLong( (long)self->renderContext->renderer ); 
2208 }
2209
2210 static PyObject *RenderData_getImageType( BPy_RenderData * self )
2211 {
2212         return PyInt_FromLong( (long) self->renderContext->imtype );
2213 }
2214
2215 static int RenderData_setGameFrameColor( BPy_RenderData * self,
2216                 PyObject * args )
2217 {
2218         float red, green, blue;
2219
2220         /* if we get a list, convert to a tuple; otherwise hope for the best */
2221         if( PyList_Check( args ) )
2222                 args = PySequence_Tuple( args );
2223         else
2224                 Py_INCREF( args );
2225
2226         if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) ) {
2227                 Py_DECREF( args );
2228                 return EXPP_ReturnIntError( PyExc_TypeError, "expected three floats" );
2229         }
2230         Py_DECREF( args );
2231
2232         self->scene->framing.col[0] = EXPP_ClampFloat( red, 0.0, 1.0 );
2233         self->scene->framing.col[1] = EXPP_ClampFloat( green, 0.0, 1.0 );
2234         self->scene->framing.col[2] = EXPP_ClampFloat( blue, 0.0, 1.0 );
2235         return 0;
2236 }
2237
2238 static PyObject *RenderData_getGameFrameColor( BPy_RenderData * self )
2239 {
2240         return Py_BuildValue( "[fff]", self->scene->framing.col[0],
2241                  self->scene->framing.col[1], self->scene->framing.col[2] );
2242 }
2243
2244 static PyObject *RenderData_getBackbuf( BPy_RenderData * self )
2245 {
2246         return EXPP_getBitfield( &self->renderContext->bufflag,
2247                         R_BACKBUF, 'h' );
2248 }
2249
2250 static int RenderData_setBackbuf( BPy_RenderData* self, PyObject *value )
2251 {
2252         return EXPP_setBitfield( value, &self->renderContext->bufflag,
2253                         R_BACKBUF, 'h' );
2254 }
2255
2256 static int RenderData_setImagePlanes( BPy_RenderData *self, PyObject *value )
2257 {
2258         int depth;
2259         char *errstr = "expected int argument of 8, 24, or 32";
2260
2261         if( !PyInt_Check( value ) )
2262                 return EXPP_ReturnIntError( PyExc_TypeError, errstr );
2263
2264         depth = PyInt_AsLong( value );
2265         if( depth != 8 && depth != 24 && depth != 32 )
2266                 return EXPP_ReturnIntError( PyExc_ValueError, errstr );
2267
2268         self->renderContext->planes = (short)depth;
2269
2270         return 0;
2271 }
2272
2273 static PyObject *RenderData_getImagePlanes( BPy_RenderData * self )
2274 {
2275         return PyInt_FromLong( (long) self->renderContext->planes );
2276 }
2277
2278 static int RenderData_setAlphaMode( BPy_RenderData *self, PyObject *value )
2279 {
2280         return EXPP_setIValueRange( value, &self->renderContext->alphamode,
2281                         R_ADDSKY, R_ALPHAKEY, 'h' );
2282 }
2283
2284 static PyObject *RenderData_getAlphaMode( BPy_RenderData * self )
2285 {
2286         return PyInt_FromLong( (long) self->renderContext->alphamode );
2287 }
2288
2289 static PyObject *RenderData_getDisplayMode( void )
2290 {
2291         return PyInt_FromLong( (long) G.displaymode );
2292 }
2293
2294 static int RenderData_setDisplayMode( BPy_RenderData *self,
2295                 PyObject *value )
2296 {
2297         return EXPP_setIValueRange( value, &G.displaymode,
2298                         R_DISPLAYIMAGE, R_DISPLAYSCREEN, 'h' );
2299 }
2300
2301 static PyObject *RenderData_getRenderPath( BPy_RenderData * self )
2302 {
2303         return PyString_FromString( self->renderContext->pic );
2304 }
2305
2306 static int RenderData_setRenderPath( BPy_RenderData * self, PyObject * value )
2307 {
2308         char *name;
2309
2310         name = PyString_AsString( value );
2311         if( !name )
2312                 return EXPP_ReturnIntError( PyExc_TypeError,
2313                                                 "expected a string" );
2314
2315         if( strlen( name ) >= sizeof(self->renderContext->pic) )
2316                 return EXPP_ReturnIntError( PyExc_ValueError,
2317                                                 "render path is too long" );
2318
2319         strcpy( self->renderContext->pic, name );
2320         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
2321
2322         return 0;
2323 }
2324
2325 static PyObject *RenderData_getFrameFilename( BPy_RenderData * self, PyObject *args )
2326 {
2327         char name[FILE_MAX];
2328         int frame = self->renderContext->cfra;
2329         
2330         if( !PyArg_ParseTuple( args, "|i", &( frame ) ) )
2331                 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
2332                                                                                 "expected int argument or nothing" ) );
2333         
2334         BKE_makepicstring(name, self->renderContext->pic, frame, self->renderContext->imtype);
2335         return PyString_FromString( name );
2336 }
2337
2338 PyObject *RenderData_getBackbufPath( BPy_RenderData * self )
2339 {
2340         return PyString_FromString( self->renderContext->backbuf );
2341 }
2342
2343 static int RenderData_setBackbufPath( BPy_RenderData *self, PyObject *value )
2344 {
2345         char *name;
2346         Image *ima;
2347
2348         name = PyString_AsString( value );
2349         if( !name )
2350                 return EXPP_ReturnIntError( PyExc_TypeError, "expected a string" );
2351
2352         if( strlen( name ) >= sizeof(self->renderContext->backbuf) )
2353                 return EXPP_ReturnIntError( PyExc_ValueError,
2354                                 "backbuf path is too long" );
2355
2356         strcpy( self->renderContext->backbuf, name );
2357         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
2358
2359         ima = BKE_add_image_file( name );
2360         if( ima )
2361                 BKE_image_signal( ima, NULL, IMA_SIGNAL_RELOAD );
2362
2363         return 0;
2364 }
2365
2366 PyObject *RenderData_getRenderWinSize( BPy_RenderData * self )
2367 {
2368         return PyInt_FromLong( (long) self->renderContext->size );
2369 }
2370
2371 static int RenderData_setRenderWinSize( BPy_RenderData *self, PyObject *value )
2372 {
2373         int size;
2374         char *errstr = "expected int argument of 25, 50, 75, or 100";
2375
2376         if( !PyInt_Check( value ) )
2377                 return EXPP_ReturnIntError( PyExc_TypeError, errstr );
2378
2379         size = PyInt_AsLong( value );
2380         if( size != 25 && size != 50 && size != 75 && size != 100 )
2381                 return EXPP_ReturnIntError( PyExc_ValueError, errstr );
2382
2383         self->renderContext->size = (short)size;
2384         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
2385
2386         return 0;
2387 }
2388
2389 static PyObject *RenderData_getMapOld( BPy_RenderData *self )
2390 {
2391         return PyInt_FromLong( (long)self->renderContext->framapto );
2392 }
2393
2394 static int RenderData_setMapOld( BPy_RenderData *self, PyObject *value )
2395 {
2396         int result = EXPP_setIValueClamped( value, &self->renderContext->framapto,
2397                         1, 900, 'h' );
2398         self->renderContext->framelen =
2399                 (float)self->renderContext->framapto / self->renderContext->images;
2400         return result;
2401 }
2402
2403 static PyObject *RenderData_getMapNew( BPy_RenderData *self )
2404 {
2405         return PyInt_FromLong( (long)self->renderContext->images );
2406 }
2407
2408 static int RenderData_setMapNew( BPy_RenderData *self, PyObject *value )
2409 {
2410         int result = EXPP_setIValueClamped( value, &self->renderContext->images,
2411                         1, 900, 'h' );
2412         self->renderContext->framelen =
2413                 (float)self->renderContext->framapto / self->renderContext->images;
2414         return result;
2415 }
2416
2417 static PyObject *RenderData_getSet( BPy_RenderData *self )
2418 {
2419         if( self->scene->set )
2420                 return Scene_CreatePyObject( self->scene->set );
2421         Py_RETURN_NONE;
2422 }
2423
2424 static int RenderData_setSet( BPy_RenderData *self, PyObject *value )
2425 {
2426         BPy_Scene *sc;
2427
2428         /* if "None", delete the link to the scene */
2429         if( value == Py_None ) {
2430                 self->scene->set = NULL;
2431                 return 0;
2432         }
2433
2434         /* be sure argument is a Scene */
2435         if( !BPy_Scene_Check( value ) )
2436                 return EXPP_ReturnIntError( PyExc_TypeError,
2437                                 "expected Scene as argument" );
2438
2439         /* check for attempt to link to ourselves */
2440         sc = (BPy_Scene *)value;
2441         if( self->scene == sc->scene )
2442                 return EXPP_ReturnIntError( PyExc_ValueError,
2443                                 "cannot link a scene to itself" );
2444
2445         /*
2446          * Accept the set link, then check for a circular link.  If circular link
2447          * exists, scene_check_setscene() sets self->scene->set to NULL.
2448          */
2449
2450         self->scene->set = sc->scene;
2451         if( !scene_check_setscene( self->scene ) )
2452                 return EXPP_ReturnIntError( PyExc_ValueError,
2453                                 "linking scene would create a cycle" );
2454
2455         return 0;
2456 }
2457
2458
2459 PyObject *RenderData_getThreads( BPy_RenderData * self )
2460 {
2461         return PyInt_FromLong( (long) self->renderContext->threads );
2462 }
2463
2464 static int RenderData_setThreads( BPy_RenderData *self, PyObject *value )
2465 {
2466         int threads;
2467
2468         if( !PyInt_Check( value ) )
2469                 return EXPP_ReturnIntError( PyExc_TypeError, "Error, threads must be an int" );
2470
2471         threads = PyInt_AsLong( value );
2472         if (threads<1) threads = 1;
2473         else if (threads>8) threads = 8;
2474         
2475         self->renderContext->threads = (short)threads;
2476         EXPP_allqueue( REDRAWBUTSSCENE, 0 );
2477         return 0;
2478 }
2479
2480 PyObject *RenderData_getActiveLayer( BPy_RenderData * self )
2481 {
2482         return PyInt_FromLong( (long) self->renderContext->actlay );
2483 }
2484
2485 static int RenderData_setActiveLayer( BPy_RenderData *self, PyObject *value )
2486 {
2487         int layer;
2488         short nr;
2489     SceneRenderLayer *srl;
2490
2491         if( !PyInt_Check( value ) )
2492                 return EXPP_ReturnIntError( PyExc_TypeError, "active layer must be an int" );
2493
2494         layer = PyInt_AsLong( value );
2495     for(nr=0, srl= self->renderContext->layers.first; srl; srl= srl->next, nr++) {
2496         }
2497         if(layer >= nr)
2498                 return EXPP_ReturnIntError( PyExc_ValueError, "value larger than number of render layers" );
2499
2500         self->renderContext->actlay = layer;
2501         EXPP_allqueue(REDRAWBUTSSCENE, 0);
2502         EXPP_allqueue(REDRAWNODE, 0);
2503         return 0;
2504 }
2505
2506 static int RenderData_setBakeMode( BPy_RenderData *self, PyObject *value,
2507                 void *type )
2508 {
2509         /* use negative numbers to flip truth */
2510         int param = PyObject_IsTrue( value );
2511         
2512         if( param == -1 )
2513                 return EXPP_ReturnIntError( PyExc_TypeError,
2514                                 "expected True/False or 0/1" );
2515         
2516         if (param) {
2517                 self->renderContext->bake_flag |= (int)type;
2518         } else {
2519                 self->renderContext->bake_flag &= ~(int)type;
2520         }
2521         return 0;
2522 }
2523
2524 static PyObject *RenderData_getBakeMode( BPy_RenderData *self, void *type )
2525 {
2526         int itype = (int)type;
2527         /* use negative numbers to flip truth */
2528         if (self->renderContext->bake_flag & itype)     Py_RETURN_TRUE;
2529         else                                                                            Py_RETURN_FALSE;
2530 }
2531
2532 /***************************************************************************/
2533 /* BPy_RenderData attribute def                                            */
2534 /***************************************************************************/
2535 static PyGetSetDef BPy_RenderData_getseters[] = {
2536         {"oversampling",
2537          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2538          "Oversampling (anti-aliasing) enabled",
2539          (void *)R_OSA},
2540         {"shadow",
2541          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2542          "Shadow calculation enabled",
2543          (void *)R_SHADOW},
2544         {"gammaCorrection",
2545          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2546          "Gamma correction enabled",
2547          (void *)R_GAMMA},
2548 /* R_ORTHO      unused */
2549         {"environmentMap",
2550          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2551          "Environment map rendering enabled",
2552          (void *)R_ENVMAP},
2553         {"toonShading",
2554          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2555          "Toon edge shading enabled",
2556          (void *)R_EDGE},
2557         {"fieldRendering", 
2558          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2559          "Field rendering enabled",
2560          (void *)R_FIELDS},
2561         {"fieldTimeDisable",
2562          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2563          "Time difference in field calculations disabled ('X' in UI)",
2564          (void *)R_FIELDSTILL},
2565         {"radiosityRender",
2566          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2567          "Radiosity rendering enabled",
2568          (void *)R_RADIO},
2569         {"borderRender",
2570          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2571          "Small cut-out rendering enabled",
2572          (void *)R_BORDER},
2573         {"panorama",
2574          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2575          "Panorama rendering enabled",
2576          (void *)R_PANORAMA},
2577         {"crop",
2578          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2579          "Crop image during border renders",
2580          (void *)R_CROP},
2581 /* R_COSMO      unsupported */
2582         {"oddFieldFirst",
2583          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2584          "Odd field first rendering enabled",
2585          (void *)R_ODDFIELD},
2586         {"motionBlur",
2587          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2588          "Motion blur enabled",
2589          (void *)R_MBLUR},
2590         {"rayTracing",
2591          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2592          "Ray tracing enabled",
2593          (void *)R_RAYTRACE},
2594           
2595         {"touch",
2596          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2597          "Create an empry file with the frame name before rendering",
2598          (void *)R_TOUCH},
2599         {"noOverwrite",
2600          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2601          "Skip rendering existing image files",
2602          (void *)R_NO_OVERWRITE},
2603         {"fixedThreads",
2604          (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
2605          "Use the number of threads defined by the blend file",
2606          (void *)R_FIXED_THREADS},
2607 /* R_GAUSS unused */
2608 /* R_FBUF unused */
2609         {"threads",
2610          (getter)RenderData_getThreads, (setter)RenderData_setThreads,
2611          "Number of threads used to render",
2612          NULL},
2613 /* R_SPEED unused */
2614         {"mode",
2615          (getter)RenderData_getMode, (setter)RenderData_setMode,
2616          "Mode bitfield",
2617          NULL},
2618
2619         /* scene modes */
2620         {"sequencer",
2621      (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits,
2622      "'Do Sequence' enabled",
2623      (void *)R_DOSEQ},
2624         {"extensions",
2625      (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits,
2626      "Add extensions to output (when rendering animations) enabled",
2627      (void *)R_EXTENSION},
2628         {"compositor",
2629      (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits,
2630      "'Do Compositor' enabled.",
2631      (void *)R_DOCOMP},
2632         {"freeImages",
2633      (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits,
2634      "Free texture images after render.",
2635      (void *)R_FREE_IMAGE},
2636         {"singleLayer",
2637      (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits,
2638      "Only render the active layer.",
2639      (void *)R_SINGLE_LAYER},
2640         {"saveBuffers",
2641      (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits,
2642      "Save render buffers to disk while rendering, saves memory.",
2643      (void *)R_EXR_TILE_FILE},
2644         {"compositeFree",
2645      (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits,
2646      "Free nodes that are not used while composite.",
2647      (void *)R_COMP_FREE},
2648
2649         {"sceneMode",
2650      (getter)RenderData_getSceMode, (setter)RenderData_setSceMode,
2651      "Scene mode bitfield",
2652      NULL},
2653 /* R_BG_RENDER unused */
2654
2655         {"gameFrame",
2656          (getter)RenderData_getFramingType, (setter)RenderData_setFramingType,
2657          "Game framing type",
2658          NULL},
2659
2660         {"renderPath",
2661          (getter)RenderData_getRenderPath, (setter)RenderData_setRenderPath,
2662          "The path to output the rendered images to",
2663          NULL},
2664         {"backbufPath",
2665          (getter)RenderData_getBackbufPath, (setter)RenderData_setBackbufPath,
2666          "Path to a background image (setting loads image)",
2667          NULL},
2668         {"edgeColor",
2669          (getter)RenderData_getEdgeColor, (setter)RenderData_setEdgeColor,
2670          "RGB color triplet for edges in Toon shading",
2671          NULL},
2672         {"OSALevel",
2673          (getter)RenderData_getOSALevel, (setter)RenderData_setOSALevel,
2674          "Oversampling (anti-aliasing) level",
2675          NULL},
2676         {"renderwinSize",
2677          (getter)RenderData_getRenderWinSize, (setter)RenderData_setRenderWinSize,
2678          "Size of the rendering window (25, 50, 75, or 100)",
2679          NULL},
2680         {"border",
2681          (getter)RenderData_getBorder, (setter)RenderData_setBorder,
2682          "The border for border rendering",
2683          NULL},
2684         {"timeCode",
2685          (getter)RenderData_getTimeCode, (setter)NULL,
2686          "Get the current frame in HH:MM:SS:FF format",
2687          NULL},
2688         {"renderer",
2689          (getter)RenderData_getRenderer, (setter)RenderData_setRenderer,
2690          "Rendering engine choice",
2691          NULL},
2692         {"imageType",
2693          (getter)RenderData_getImageType, (setter)RenderData_setImageType,
2694          "File format for saving images",
2695          NULL},
2696         {"gameFrameColor",
2697          (getter)RenderData_getGameFrameColor,(setter)RenderData_setGameFrameColor,
2698          "RGB color triplet for bars",
2699          NULL},
2700         {"backbuf",
2701          (getter)RenderData_getBackbuf, (setter)RenderData_setBackbuf,
2702          "Backbuffer image enabled",
2703          NULL},
2704         {"imagePlanes",
2705          (getter)RenderData_getImagePlanes, (setter)RenderData_setImagePlanes,
2706          "Image depth (8, 24, or 32 bits)",
2707          NULL},
2708         {"alphaMode",
2709          (getter)RenderData_getAlphaMode, (setter)RenderData_setAlphaMode,
2710          "Setting for sky/background.",
2711          NULL},
2712         {"displayMode",
2713          (getter)RenderData_getDisplayMode, (setter)RenderData_setDisplayMode,
2714          "Render output in separate window or 3D view",
2715          NULL},
2716
2717         {"xParts",
2718          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2719          "Number of horizontal parts for image render",
2720          (void *)EXPP_RENDER_ATTR_XPARTS},
2721         {"yParts",
2722          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2723          "Number of vertical parts for image render",
2724          (void *)EXPP_RENDER_ATTR_YPARTS},
2725         {"cFrame",
2726          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2727          "The current frame for rendering",
2728          (void *)EXPP_RENDER_ATTR_CFRAME},
2729         {"sFrame",
2730          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2731          "Starting frame for rendering",
2732          (void *)EXPP_RENDER_ATTR_SFRAME},
2733         {"eFrame",
2734          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2735          "Ending frame for rendering",
2736          (void *)EXPP_RENDER_ATTR_EFRAME},
2737         {"fps",
2738          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2739          "Frames per second",
2740          (void *)EXPP_RENDER_ATTR_FPS},
2741         {"fpsBase",
2742          (getter)RenderData_getFloatAttr, (setter)RenderData_setFloatAttrClamp,
2743          "Frames per second base",
2744          (void *)EXPP_RENDER_ATTR_FPS_BASE},
2745         {"sizeX",
2746          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2747          "Image width (in pixels)",
2748          (void *)EXPP_RENDER_ATTR_SIZEX},
2749         {"sizeY",
2750          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2751          "Image height (in pixels)",
2752          (void *)EXPP_RENDER_ATTR_SIZEY},
2753
2754         {"gaussFilter",
2755          (getter)RenderData_getFloatAttr, (setter)RenderData_setFloatAttrClamp,
2756          "Gauss filter size",
2757          (void *)EXPP_RENDER_ATTR_GAUSSFILTER},
2758         {"mblurFactor",
2759          (getter)RenderData_getFloatAttr, (setter)RenderData_setFloatAttrClamp,
2760          "Motion blur factor",
2761          (void *)EXPP_RENDER_ATTR_MBLURFACTOR},
2762         {"aspectX",
2763          (getter)RenderData_getFloatAttr, (setter)RenderData_setFloatAttrClamp,
2764          "Horizontal aspect ratio",
2765          (void *)EXPP_RENDER_ATTR_ASPECTX},
2766         {"aspectY",
2767          (getter)RenderData_getFloatAttr, (setter)RenderData_setFloatAttrClamp,
2768          "Vertical aspect ratio",
2769          (void *)EXPP_RENDER_ATTR_ASPECTY},
2770         {"mapOld",
2771          (getter)RenderData_getMapOld, (setter)RenderData_setMapOld,
2772          "Number of frames the Map Old will last",
2773          NULL},
2774         {"mapNew",
2775          (getter)RenderData_getMapNew, (setter)RenderData_setMapNew,
2776          "New mapping value (in frames)",
2777          NULL},
2778         {"set",
2779          (getter)RenderData_getSet, (setter)RenderData_setSet,
2780          "Scene link 'set' value",
2781          NULL},
2782
2783         /* renderlayers */
2784         {"activeLayer",
2785          (getter)RenderData_getActiveLayer, (setter)RenderData_setActiveLayer,
2786          "Active rendering layer",
2787          NULL},
2788         {"renderLayers",
2789          (getter)RenderData_getRenderLayers, (setter)NULL,
2790          "Active rendering layer",
2791          NULL},
2792   
2793         {"halfFloat",
2794      (getter)RenderData_getSubImTypeBits, (setter)RenderData_setSubImTypeBits,
2795      "'Half' openexr option enabled",
2796      (void *)R_OPENEXR_HALF},
2797         {"zbuf",
2798      (getter)RenderData_getSubImTypeBits, (setter)RenderData_setSubImTypeBits,
2799      "'ZBuf' openexr option enabled",
2800      (void *)R_OPENEXR_ZBUF},
2801         {"preview",
2802      (getter)RenderData_getSubImTypeBits, (setter)RenderData_setSubImTypeBits,
2803      "'preview' openexr option enabled",
2804      (void *)R_PREVIEW_JPG},
2805
2806         {"yafrayGIMethod",
2807          (getter)RenderData_getYafrayGIMethod, (setter)RenderData_setYafrayGIMethod,
2808          "Global illumination method",
2809          NULL},
2810         {"yafrayGIQuality",
2811          (getter)RenderData_getYafrayGIQuality, (setter)RenderData_setYafrayGIQuality,
2812          "Global Illumination quality",
2813          NULL},
2814         {"yafrayExportToXML",
2815          (getter)RenderData_getYafrayExportToXML, (setter)RenderData_setYafrayExportToXML,
2816          "If true export to an xml file and call yafray instead of plugin",
2817          NULL},
2818         {"yafrayAutoAntiAliasing",
2819          (getter)RenderData_getYafrayAutoAntiAliasing, (setter)RenderData_setYafrayAutoAntiAliasing,
2820          "Automatic anti-aliasing enabled/disabled",
2821          NULL},
2822         {"yafrayClampRGB",
2823          (getter)RenderData_getYafrayClampRGB, (setter)RenderData_setYafrayClampRGB,
2824          "Clamp RGB enabled/disabled",
2825          NULL},
2826         {"yafrayAntiAliasingPasses",
2827          (getter)RenderData_getYafrayAntiAliasingPasses, (setter)RenderData_setYafrayAntiAliasingPasses,
2828          "Number of anti-aliasing passes (0 is no anti-aliasing)",
2829          NULL},
2830         {"yafrayAntiAliasingSamples",
2831          (getter)RenderData_getYafrayAntiAliasingSamples, (setter)RenderData_setYafrayAntiAliasingSamples,
2832          "Number of samples per pass",
2833          NULL},
2834         {"yafrayAntiAliasingPixelSize",
2835          (getter)RenderData_getYafrayAntiAliasingPixelSize, (setter)RenderData_setYafrayAntiAliasingPixelSize,
2836          "Anti-aliasing pixel filter size",
2837          NULL},
2838         {"yafrayAntiAliasingThreshold",
2839          (getter)RenderData_getYafrayAntiAliasingThreshold, (setter)RenderData_setYafrayAntiAliasingThreshold,
2840          "Anti-aliasing threshold",
2841          NULL},
2842         {"yafrayGICache",
2843          (getter)RenderData_getYafrayGICache, (setter)RenderData_setYafrayGICache,
2844          "Cache occlusion/irradiance samples (faster)",
2845          NULL},
2846         {"yafrayGICacheBumpNormals",
2847          (getter)RenderData_getYafrayGICacheBumpNormals, (setter)RenderData_setYafrayGICacheBumpNormals,
2848          "Enable/disable bumpnormals for cache",
2849          NULL},
2850         {"yafrayGICacheShadowQuality",
2851          (getter)RenderData_getYafrayGICacheShadowQuality, (setter)RenderData_setYafrayGICacheShadowQuality,
2852          "Shadow quality, keep it under 0.95 :-)",
2853          NULL},
2854         {"yafrayGICachePixelsPerSample",
2855          (getter)RenderData_getYafrayGICachePixelsPerSample, (setter)RenderData_setYafrayGICachePixelsPerSample,
2856          "Maximum number of pixels without samples, the lower the better and slower",
2857          NULL},
2858         {"yafrayGICacheRefinement",
2859          (getter)RenderData_getYafrayGICacheRefinement, (setter)RenderData_setYafrayGICacheRefinement,
2860          "Threshold to refine shadows EXPERIMENTAL. 1 = no refinement",
2861          NULL},
2862         {"yafrayGIPhotons",
2863          (getter)RenderData_getYafrayGIPhotons, (setter)RenderData_setYafrayGIPhotons,
2864          "Enable/disable use of global photons to help in GI",
2865          NULL},
2866         {"yafrayGITunePhotons",
2867          (getter)RenderData_getYafrayGITunePhotons, (setter)RenderData_setYafrayGITunePhotons,
2868          "If true the photonmap is shown directly in the render for tuning",
2869          NULL},
2870   
2871         /* Bake stuff */
2872         {"bakeClear",
2873          (getter)RenderData_getBakeMode, (setter)RenderData_setBakeMode,
2874          "Clear the image before baking",
2875          (void *)R_BAKE_CLEAR},
2876         {"bakeToActive",
2877          (getter)RenderData_getBakeMode, (setter)RenderData_setBakeMode,
2878          "Bake selection to active",
2879          (void *)R_BAKE_TO_ACTIVE},
2880         {"bakeNormalize",
2881          (getter)RenderData_getBakeMode, (setter)RenderData_setBakeMode,
2882          "Normalize AO and displacement to the dist range",
2883          (void *)R_BAKE_NORMALIZE},
2884         {"bakeMargin",
2885          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2886          "number of pixels to use as a margin for the edges of the image",
2887          (void *)EXPP_RENDER_ATTR_BAKEMARGIN},
2888         {"bakeMode",
2889          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2890          "The mode for baking, see Blender.Scene.Render.BakeModes",
2891          (void *)EXPP_RENDER_ATTR_BAKEMODE},
2892         {"bakeNormalSpace",
2893          (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
2894          "The mode for baking, see Blender.Scene.Render.BakeNormalSpaceModes",
2895          (void *)EXPP_RENDER_ATTR_BAKENORMALSPACE},
2896         {"bakeDist",
2897          (getter)RenderData_getFloatAttr, (setter)RenderData_setFloatAttrClamp,
2898          "Distance (in blender units)",
2899          (void *)EXPP_RENDER_ATTR_BAKEDIST},
2900         {"bakeBias",
2901          (getter)RenderData_getFloatAttr, (setter)RenderData_setFloatAttrClamp,
2902          "Bias towards faces further away from the object (in blender units)",
2903          (void *)EXPP_RENDER_ATTR_BAKEDIST},
2904         {NULL,NULL,NULL,NULL,NULL}
2905 };
2906
2907 /***************************************************************************/
2908 /* BPy_RenderData method def                                               */
2909 /***************************************************************************/
2910 static PyMethodDef BPy_RenderData_methods[] = {
2911         {"render", ( PyCFunction ) RenderData_Render, METH_NOARGS,
2912          "() - render the scene"},
2913         {"bake", ( PyCFunction ) RenderData_Bake, METH_NOARGS,
2914          "() - bake current selection"},
2915         {"saveRenderedImage", (PyCFunction)RenderData_SaveRenderedImage, METH_VARARGS,
2916          "(filename) - save an image generated by a call to render() (set output path first)"},
2917         {"renderAnim", ( PyCFunction ) RenderData_RenderAnim, METH_NOARGS,
2918          "() - render a sequence from start frame to end frame"},
2919         {"play", ( PyCFunction ) RenderData_Play, METH_NOARGS,
2920          "() - play animation of rendered images/avi (searches Pics: field)"},
2921         {"setRenderPath", ( PyCFunction ) RenderData_SetRenderPath,
2922          METH_VARARGS,
2923          "(string) - get/set the path to output the rendered images to"},
2924         {"getRenderPath", ( PyCFunction ) RenderData_getRenderPath,
2925          METH_NOARGS,
2926          "() - get the path to directory where rendered images will go"},
2927         {"getFrameFilename", ( PyCFunction ) RenderData_getFrameFilename,
2928          METH_VARARGS,
2929          "() - get the filename of the frame this will be rendered, taking into account extension and frame range"},
2930         {"setBackbufPath", ( PyCFunction ) RenderData_SetBackbufPath,
2931          METH_VARARGS,
2932          "(string) - get/set the path to a background image and load it"},
2933         {"getBackbufPath", ( PyCFunction ) RenderData_getBackbufPath,
2934          METH_NOARGS,
2935          "() - get the path to background image file"},
2936         {"enableBackbuf", ( PyCFunction ) RenderData_EnableBackbuf,
2937          METH_VARARGS,
2938          "(bool) - enable/disable the backbuf image"},
2939         {"enableExtensions", ( PyCFunction ) RenderData_EnableExtensions,
2940          METH_VARARGS,
2941          "(bool) - enable/disable windows extensions for output files"},
2942         {"enableSequencer", ( PyCFunction ) RenderData_EnableSequencer,
2943          METH_VARARGS,
2944          "(bool) - enable/disable Do Sequence"},
2945         {"enableRenderDaemon", ( PyCFunction ) RenderData_EnableRenderDaemon,
2946          METH_VARARGS,
2947          "(bool) - enable/disable Scene daemon"},
2948         {"enableToonShading", ( PyCFunction ) RenderData_EnableToonShading,
2949          METH_VARARGS,
2950          "(bool) - enable/disable Edge rendering"},
2951         {"edgeIntensity", ( PyCFunction ) RenderData_EdgeIntensity,
2952          METH_VARARGS,
2953          "(int) - get/set edge intensity for toon shading"},
2954         {"setEdgeColor", ( PyCFunction ) RenderData_SetEdgeColor, METH_VARARGS,
2955          "(f,f,f) - set the edge color for toon shading - Red,Green,Blue expected."},
2956         {"getEdgeColor", ( PyCFunction ) RenderData_GetEdgeColor, METH_NOARGS,
2957          "() - get the edge color for toon shading - Red,Green,Blue expected."},
2958         {"enableOversampling", ( PyCFunction ) RenderData_EnableOversampling,
2959          METH_VARARGS,
2960          "(bool) - enable/disable oversampling (anit-aliasing)."},
2961         {"setOversamplingLevel",
2962          ( PyCFunction ) RenderData_SetOversamplingLevel, METH_VARARGS,
2963          "(enum) - get/set the level of oversampling (anit-aliasing)."},
2964         {"enableMotionBlur", ( PyCFunction ) RenderData_EnableMotionBlur,
2965          METH_VARARGS,
2966          "(bool) - enable/disable MBlur."},
2967         {"motionBlurLevel", ( PyCFunction ) RenderData_MotionBlurLevel,
2968          METH_VARARGS,
2969          "(float) - get/set the length of shutter time for motion blur."},
2970         {"partsX", ( PyCFunction ) RenderData_PartsX, METH_VARARGS,
2971          "(int) - get/set the number of parts to divide the render in the X direction"},
2972         {"partsY", ( PyCFunction ) RenderData_PartsY, METH_VARARGS,
2973          "(int) - get/set the number of parts to divide the render in the Y direction"},
2974         {"enableSky", ( PyCFunction ) RenderData_EnableSky, METH_NOARGS,
2975          "() - enable render background with sky"},
2976         {"enablePremultiply", ( PyCFunction ) RenderData_EnablePremultiply,
2977          METH_NOARGS,
2978          "() - enable premultiply alpha"},
2979         {"enableKey", ( PyCFunction ) RenderData_EnableKey, METH_NOARGS,
2980          "() - enable alpha and color values remain unchanged"},
2981         {"enableShadow", ( PyCFunction ) RenderData_EnableShadow, METH_VARARGS,
2982          "(bool) - enable/disable shadow calculation"},
2983         {"enablePanorama", ( PyCFunction ) RenderData_EnablePanorama,
2984          METH_VARARGS,
2985          "(bool) - enable/disable panorama rendering (output width is multiplied by Xparts)"},
2986         {"enableEnvironmentMap",
2987          ( PyCFunction ) RenderData_EnableEnvironmentMap, METH_VARARGS,
2988          "(bool) - enable/disable environment map rendering"},
2989         {"enableRayTracing", ( PyCFunction ) RenderData_EnableRayTracing,
2990          METH_VARARGS,
2991          "(bool) - enable/disable ray tracing"},
2992         {"enableRadiosityRender",
2993          ( PyCFunction ) RenderData_EnableRadiosityRender, METH_VARARGS,
2994          "(bool) - enable/disable radiosity rendering"},
2995         {"getRenderWinSize", ( PyCFunction ) RenderData_getRenderWinSize,
2996          METH_NOARGS,
2997          "() - get the size of the render window"},
2998         {"setRenderWinSize", ( PyCFunction ) RenderData_SetRenderWinSize,
2999          METH_VARARGS,
3000          "(int) - set the size of the render window"},
3001         {"enableFieldRendering",
3002          ( PyCFunction ) RenderData_EnableFieldRendering, METH_VARARGS,
3003          "(bool) - enable/disable field rendering"},
3004         {"enableOddFieldFirst", ( PyCFunction ) RenderData_EnableOddFieldFirst,
3005          METH_VARARGS,
3006          "(bool) - enable/disable Odd field first rendering (Default: Even field)"},
3007         {"enableFieldTimeDisable",
3008          ( PyCFunction ) RenderData_EnableFieldTimeDisable, METH_VARARGS,
3009          "(bool) - enable/disable time difference in field calculations"},
3010         {"enableGaussFilter", ( PyCFunction ) RenderData_EnableGaussFilter,
3011          METH_VARARGS,
3012          "(bool) - enable/disable Gauss sampling filter for antialiasing"},
3013         {"enableBorderRender", ( PyCFunction ) RenderData_EnableBorderRender,
3014          METH_VARARGS,
3015          "(bool) - enable/disable small cut-out rendering"},
3016         {"setBorder", ( PyCFunction ) RenderData_SetBorder, METH_VARARGS,
3017          "(f,f,f,f) - set the border for border rendering"},
3018         {"gaussFilterSize", ( PyCFunction ) RenderData_GaussFilterSize,
3019          METH_VARARGS,
3020          "(float) - get/sets the Gauss filter size"},
3021         {"startFrame", ( PyCFunction ) RenderData_StartFrame, METH_VARARGS,
3022          "(int) - get/set the starting frame for rendering"},
3023         {"currentFrame", ( PyCFunction ) RenderData_CurrentFrame, METH_VARARGS,
3024          "(int) - get/set the current frame for rendering"},
3025         {"endFrame", ( PyCFunction ) RenderData_EndFrame, METH_VARARGS,
3026          "(int) - get/set the ending frame for rendering"},
3027         {"getTimeCode", ( PyCFunction ) RenderData_getTimeCode, METH_NOARGS,
3028          "get the current frame in HH:MM:SS:FF format"},
3029         {"imageSizeX", ( PyCFunction ) RenderData_ImageSizeX, METH_VARARGS,
3030          "(int) - get/set the image width in pixels"},
3031         {"imageSizeY", ( PyCFunction ) RenderData_ImageSizeY, METH_VARARGS,
3032          "(int) - get/set the image height in pixels"},
3033         {"aspectRatioX", ( PyCFunction ) RenderData_AspectRatioX, METH_VARARGS,
3034          "(int) - get/set the horizontal aspect ratio"},
3035         {"aspectRatioY", ( PyCFunction ) RenderData_AspectRatioY, METH_VARARGS,
3036          "(int) - get/set the vertical aspect ratio"},
3037         {"setRenderer", ( PyCFunction ) RenderData_SetRenderer, METH_VARARGS,
3038          "(enum) - get/set which renderer to render the output"},
3039         {"enableCropping", ( PyCFunction ) RenderData_EnableCropping,
3040          METH_VARARGS,
3041          "(bool) - enable/disable exclusion of border rendering from total image"},
3042         {"setImageType", ( PyCFunction ) RenderData_SetImageType, METH_VARARGS,
3043          "(enum) - get/set the type of image to output from the render"},
3044         {"quality", ( PyCFunction ) RenderData_Quality, METH_VARARGS,
3045          "(int) - get/set quality get/setting for JPEG images, AVI Jpeg and SGI movies"},
3046         {"framesPerSec", ( PyCFunction ) RenderData_FramesPerSec, METH_VARARGS,
3047          "(int) - get/set frames per second"},
3048         {"enableGrayscale", ( PyCFunction ) RenderData_EnableGrayscale,
3049          METH_NOARGS,
3050          "() - images are saved with BW (grayscale) data"},
3051         {"enableRGBColor", ( PyCFunction ) RenderData_EnableRGBColor,
3052          METH_NOARGS,
3053          "() - images are saved with RGB (color) data"},
3054         {"enableRGBAColor", ( PyCFunction ) RenderData_EnableRGBAColor,
3055          METH_NOARGS,
3056          "() - images are saved with RGB and Alpha data (if supported)"},
3057         {"sizePreset", ( PyCFunction ) RenderData_SizePreset, METH_VARARGS,
3058          "(enum) - get/set the render to one of a few preget/sets"},
3059         {"setYafrayGIQuality", ( PyCFunction ) RenderData_SetYafrayGIQuality,
3060          METH_VARARGS,
3061          "(enum) - set yafray global Illumination quality"},
3062         {"getYafrayGIQuality", ( PyCFunction ) RenderData_GetYafrayGIQuality,
3063          METH_VARARGS,
3064          "(enum) - get yafray global Illumination quality"},
3065         {"setYafrayGIMethod", ( PyCFunction ) RenderData_SetYafrayGIMethod,
3066          METH_VARARGS,
3067          "(enum) - set yafray global Illumination method"},
3068         {"getYafrayGIMethod", ( PyCFunction ) RenderData_GetYafrayGIMethod,
3069          METH_VARARGS,
3070          "(enum) - get yafray global Illumination method"},
3071         {"yafrayGIPower", ( PyCFunction ) RenderData_YafrayGIPower,
3072          METH_VARARGS,
3073          "(float) - get/set GI lighting intensity scale"},
3074         {"yafrayGIIndirPower", ( PyCFunction ) RenderData_YafrayGIIndirPower,
3075          METH_VARARGS,
3076          "(float) - get/set GI indifect lighting intensity scale"},
3077         {"yafrayGIDepth", ( PyCFunction ) RenderData_YafrayGIDepth,
3078          METH_VARARGS,
3079          "(int) - get/set number of bounces of the indirect light"},
3080         {"yafrayGICDepth", ( PyCFunction ) RenderData_YafrayGICDepth,
3081          METH_VARARGS,
3082          "(int) - get/set number of bounces inside objects (for caustics)"},
3083         {"enableYafrayGICache", ( PyCFunction ) RenderData_EnableYafrayGICache,
3084          METH_VARARGS,
3085          "(bool) - enable/disable cache irradiance samples (faster)"},
3086         {"enableYafrayGIPhotons",
3087          ( PyCFunction ) RenderData_EnableYafrayGIPhotons, METH_VARARGS,
3088          "(bool) - enable/disable use global photons to help in GI"},
3089         {"yafrayGIPhotonCount", ( PyCFunction ) RenderData_YafrayGIPhotonCount,
3090          METH_VARARGS,
3091          "(int) - get/set number of photons to shoot"},
3092         {"yafrayGIPhotonRadius",
3093          ( PyCFunction ) RenderData_YafrayGIPhotonRadius, METH_VARARGS,
3094          "(float) - get/set radius to search for photons to mix (blur)"},
3095         {"yafrayGIPhotonMixCount",
3096          ( PyCFunction ) RenderData_YafrayGIPhotonMixCount, METH_VARARGS,
3097          "(int) - get/set number of photons to mix"},
3098         {"enableYafrayGITunePhotons",
3099          ( PyCFunction ) RenderData_EnableYafrayGITunePhotons, METH_VARARGS,
3100          "(bool) - enable/disable show the photonmap directly in the render for tuning"},
3101         {"yafrayGIShadowQuality",
3102          ( PyCFunction ) RenderData_YafrayGIShadowQuality, METH_VARARGS,
3103          "(float) - get/set the shadow quality, keep it under 0.95"},
3104         {"yafrayGIPixelsPerSample",
3105          ( PyCFunction ) RenderData_YafrayGIPixelsPerSample, METH_VARARGS,
3106          "(int) - get/set maximum number of pixels without samples, the lower the better and slower"},
3107         {"yafrayGIRefinement", ( PyCFunction ) RenderData_YafrayGIRefinement,
3108          METH_VARARGS,
3109          "(float) - get/setthreshold to refine shadows EXPERIMENTAL. 1 = no refinement"},
3110         {"yafrayRayBias", ( PyCFunction ) RenderData_YafrayRayBias,
3111          METH_VARARGS,
3112          "(float) - get/set shadow ray bias to avoid self shadowing"},
3113         {"yafrayRayDepth", ( PyCFunction ) RenderData_YafrayRayDepth,
3114          METH_VARARGS,
3115          "(int) - get/set maximum render ray depth from the camera"},
3116         {"yafrayGamma", ( PyCFunction ) RenderData_YafrayGamma, METH_VARARGS,
3117          "(float) - get/set gamma correction, 1 is off"},
3118         {"yafrayExposure", ( PyCFunction ) RenderData_YafrayExposure,
3119          METH_VARARGS,
3120          "(float) - get/set exposure adjustment, 0 is off"},
3121         {"enableGameFrameStretch",
3122          ( PyCFunction ) RenderData_EnableGameFrameStretch, METH_NOARGS,
3123          "(l) - enble stretch or squeeze the viewport to fill the display window"},
3124         {"enableGameFrameExpose",
3125          ( PyCFunction ) RenderData_EnableGameFrameExpose, METH_NOARGS,
3126          "(l) - enable show the entire viewport in the display window, viewing more horizontally or vertically"},
3127         {"enableGameFrameBars", ( PyCFunction ) RenderData_EnableGameFrameBars,
3128          METH_NOARGS,
3129          "() - enable show the entire viewport in the display window, using bar horizontally or vertically"},
3130         {"setGameFrameColor", ( PyCFunction ) RenderData_SetGameFrameColor,
3131          METH_VARARGS,
3132          "(f,f,f) - set the red, green, blue component of the bars"},
3133         {"getGameFrameColor", ( PyCFunction ) RenderData_GetGameFrameColor,
3134          METH_NOARGS,
3135          "() - get the red, green, blue component of the bars"},
3136         {"SGIMaxsize", ( PyCFunction ) RenderData_SGIMaxsize, METH_VARARGS,
3137          "(int) - get/set maximum size per frame to save in an SGI movie"},
3138         {"enableSGICosmo", ( PyCFunction ) RenderData_EnableSGICosmo,
3139          METH_VARARGS,
3140          "(bool) - enable/disable attempt to save SGI movies using Cosmo hardware"},
3141         {"oldMapValue", ( PyCFunction ) RenderData_OldMapValue, METH_VARARGS,
3142          "(int) - get/set specify old map value in frames"},
3143         {"newMapValue", ( PyCFunction ) RenderData_NewMapValue, METH_VARARGS,
3144          "(int) - get/set specify new map value in frames"},
3145   /* renderlayers */
3146         {"addRenderLayer", ( PyCFunction ) RenderData_addRenderLayer, METH_VARARGS,
3147          "(string) - add a new render layer"},
3148         {"removeRenderLayer", ( PyCFunction ) RenderData_removeRenderLayer, METH_O,
3149          "(renderLayer) - remove a render layer from this scene"},
3150         {NULL, NULL, 0, NULL}
3151 };
3152  
3153 /*------------------------------------BPy_RenderData Type defintion------ */
3154 PyTypeObject RenderData_Type = {
3155         PyObject_HEAD_INIT( NULL )  /* required py macro */
3156         0,                          /* ob_size */
3157         /*  For printing, in format "<module>.<name>" */
3158         "Blender RenderData",       /* char *tp_name; */
3159         sizeof( BPy_RenderData ),   /* int tp_basicsize; */
3160         0,                          /* tp_itemsize;  For allocation */
3161
3162         /* Methods to implement standard operations */
3163
3164         NULL,                                           /* destructor tp_dealloc; */
3165         NULL,                       /* printfunc tp_print; */
3166         NULL,                       /* getattrfunc tp_getattr; */
3167         NULL,                       /* setattrfunc tp_setattr; */
3168         NULL,                       /* cmpfunc tp_compare; */
3169         ( reprfunc ) RenderData_repr,     /* reprfunc tp_repr; */
3170
3171         /* Method suites for standard classes */
3172
3173         NULL,                       /* PyNumberMethods *tp_as_number; */
3174         NULL,                       /* PySequenceMethods *tp_as_sequence; */
3175         NULL,                       /* PyMappingMethods *tp_as_mapping; */
3176
3177         /* More standard operations (here for binary compatibility) */
3178
3179         NULL,                       /* hashfunc tp_hash; */
3180         NULL,                       /* ternaryfunc tp_call; */
3181         NULL,                       /* reprfunc tp_str; */
3182         NULL,                       /* getattrofunc tp_getattro; */
3183         NULL,                       /* setattrofunc tp_setattro; */
3184
3185         /* Functions to access object as input/output buffer */
3186         NULL,                       /* PyBufferProcs *tp_as_buffer; */
3187
3188   /*** Flags to define presence of optional/expanded features ***/
3189         Py_TPFLAGS_DEFAULT,         /* long tp_flags; */
3190
3191         NULL,                       /*  char *tp_doc;  Documentation string */
3192   /*** Assigned meaning in release 2.0 ***/
3193         /* call function for all accessible objects */
3194         NULL,                       /* traverseproc tp_traverse; */
3195
3196         /* delete references to contained objects */
3197         NULL,                       /* inquiry tp_clear; */
3198
3199   /***  Assigned meaning in release 2.1 ***/
3200   /*** rich comparisons ***/
3201         NULL,                       /* richcmpfunc tp_richcompare; */
3202
3203   /***  weak reference enabler ***/
3204         0,                          /* long tp_weaklistoffset; */
3205
3206   /*** Added in release 2.2 ***/
3207         /*   Iterators */
3208         NULL,                       /* getiterfunc tp_iter; */
3209         NULL,                       /* iternextfunc tp_iternext; */
3210
3211   /*** Attribute descriptor and subclassing stuff ***/
3212         BPy_RenderData_methods,     /* struct PyMethodDef *tp_methods; */
3213         NULL,                       /* struct PyMemberDef *tp_members; */
3214         BPy_RenderData_getseters,   /* struct PyGetSetDef *tp_getset; */
3215         NULL,                       /* struct _typeobject *tp_base; */
3216         NULL,                       /* PyObject *tp_dict; */
3217         NULL,                       /* descrgetfunc tp_descr_get; */
3218         NULL,                       /* descrsetfunc tp_descr_set; */
3219         0,                          /* long tp_dictoffset; */
3220         NULL,                       /* initproc tp_init; */
3221         NULL,                       /* allocfunc tp_alloc; */
3222         NULL,                       /* newfunc tp_new; */
3223         /*  Low-level free-memory routine */
3224         NULL,                       /* freefunc tp_free;  */
3225         /* For PyObject_IS_GC */
3226         NULL,                       /* inquiry tp_is_gc;  */
3227         NULL,                       /* PyObject *tp_bases; */
3228         /* method resolution order */
3229         NULL,                       /* PyObject *tp_mro;  */
3230         NULL,                       /* PyObject *tp_cache; */
3231         NULL,                       /* PyObject *tp_subclasses; */
3232         NULL,                       /* PyObject *tp_weaklist; */
3233         NULL
3234 };
3235
3236
3237
3238
3239 /* render layers */
3240
3241 static PyObject *RenderLayer_repr( BPy_RenderLayer * self )
3242 {
3243         if( self->renderLayer )
3244                 return PyString_FromFormat( "[RenderLayer \"%s\"]",
3245                                             self->renderLayer->name  );
3246         else
3247                 return PyString_FromString( "NULL" );
3248 }
3249
3250 static PyObject *RenderLayer_getName( BPy_RenderLayer * self )
3251 {
3252         if( !self->renderLayer )
3253                 return EXPP_ReturnPyObjError( PyExc_RuntimeError,
3254                                 "This render layer has been removed!" );
3255         
3256         return PyString_FromString( self->renderLayer->name );
3257 }
3258
3259 static int RenderLayer_setName( BPy_RenderLayer * self, PyObject *value )
3260 {
3261         char *name = NULL;
3262         int index = BLI_findindex(&self->scene->r.layers, self->renderLayer);
3263         
3264         if( !self->renderLayer )
3265                 return EXPP_ReturnIntError( PyExc_RuntimeError,
3266                      &nbs