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