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