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