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