diff options
author | Ken Hughes <khughes@pacific.edu> | 2006-05-29 09:01:07 +0400 |
---|---|---|
committer | Ken Hughes <khughes@pacific.edu> | 2006-05-29 09:01:07 +0400 |
commit | d7a21ed220e7e2904f5b9098b70be1954bf3d531 (patch) | |
tree | 5d2535d8f9146a8f18b0256a348a2957e2e5f8ce /source/blender/python/api2_2x/sceneRender.c | |
parent | 649dcd94bb119e44336f7bc55963c92fea957a94 (diff) |
===Python API===
First pass at sceneRender.c / Scene.Render API clean-up. Mainly implementing
attribute via tp_getset, but a few new features too.
Diffstat (limited to 'source/blender/python/api2_2x/sceneRender.c')
-rw-r--r-- | source/blender/python/api2_2x/sceneRender.c | 2639 |
1 files changed, 1721 insertions, 918 deletions
diff --git a/source/blender/python/api2_2x/sceneRender.c b/source/blender/python/api2_2x/sceneRender.c index 8bd1ec510aa..f7ec9e0b459 100644 --- a/source/blender/python/api2_2x/sceneRender.c +++ b/source/blender/python/api2_2x/sceneRender.c @@ -37,6 +37,7 @@ struct View3D; /* keep me up here */ #include "BKE_image.h" #include "BKE_global.h" +#include "BKE_screen.h" #include "BIF_drawscene.h" #include "BIF_renderwin.h" @@ -50,7 +51,7 @@ struct View3D; /* keep me up here */ #include "blendef.h" #include "gen_utils.h" -//local defines +/* local defines */ #define PY_NONE 0 #define PY_LOW 1 #define PY_MEDIUM 2 @@ -60,548 +61,80 @@ struct View3D; /* keep me up here */ #define PY_SKYDOME 1 #define PY_FULL 2 -extern void waitcursor(int); +enum rend_constants { + EXPP_RENDER_ATTR_XPARTS = 0, + EXPP_RENDER_ATTR_YPARTS, + EXPP_RENDER_ATTR_ASPECTX, + EXPP_RENDER_ATTR_ASPECTY, + EXPP_RENDER_ATTR_CFRAME, + EXPP_RENDER_ATTR_SFRAME, + EXPP_RENDER_ATTR_EFRAME, + EXPP_RENDER_ATTR_FPS, + EXPP_RENDER_ATTR_SIZEX, + EXPP_RENDER_ATTR_SIZEY, +/* EXPP_RENDER_ATTR_, */ +}; + +#define EXPP_RENDER_ATTR_CFRA 2 +#define EXPP_RENDER_ATTR_ANTISHIFT 3 +#define EXPP_RENDER_ATTR_EDGEINT 4 +#define EXPP_RENDER_ATTR_EFRA 5 +#define EXPP_RENDER_ATTR_QUALITY 11 +#define EXPP_RENDER_ATTR_GAUSS 13 +#define EXPP_RENDER_ATTR_BLURFAC 14 +#define EXPP_RENDER_ATTR_POSTADD 15 +#define EXPP_RENDER_ATTR_POSTGAMMA 16 +#define EXPP_RENDER_ATTR_POSTMUL 17 +#define EXPP_RENDER_ATTR_POSTHUE 18 +#define EXPP_RENDER_ATTR_POSTSAT 19 +#define EXPP_RENDER_ATTR_YF_EXPOSURE 20 +#define EXPP_RENDER_ATTR_YF_GAMMA 21 +#define EXPP_RENDER_ATTR_YF_GIDEPTH 22 +#define EXPP_RENDER_ATTR_YF_GICDEPTH 23 +#define EXPP_RENDER_ATTR_YF_GIPHOTONCOUNT 24 +#define EXPP_RENDER_ATTR_YF_GIPHOTONMIXCOUNT 25 +#define EXPP_RENDER_ATTR_YF_GIPHOTONRADIUS 26 +#define EXPP_RENDER_ATTR_YF_GIPIXPERSAMPLE 27 +#define EXPP_RENDER_ATTR_YF_GIPOWER 28 +#define EXPP_RENDER_ATTR_YF_GIREFINE 29 +#define EXPP_RENDER_ATTR_YF_GISHADOWQUAL 30 +#define EXPP_RENDER_ATTR_YF_RAYBIAS 31 +#define EXPP_RENDER_ATTR_YF_PROCCOUNT 32 +#define EXPP_RENDER_ATTR_YF_RAYDEPTH 33 +#define EXPP_RENDER_ATTR_YF_GIMETHOD 34 +#define EXPP_RENDER_ATTR_YF_GIQUALITY 35 + extern void save_rendered_image_cb_real(char *name, int zbuf, int confirm); -//---------------------------------------Render prototypes------------- -static PyObject *M_Render_CloseRenderWindow( PyObject * self ); -static PyObject *M_Render_EnableDispView( PyObject * self ); -static PyObject *M_Render_EnableDispWin( PyObject * self ); -static PyObject *M_Render_SetRenderWinPos( PyObject * self, PyObject * args ); -static PyObject *M_Render_EnableEdgeShift( PyObject * self, PyObject * args ); -static PyObject *M_Render_EnableEdgeAll( PyObject * self, PyObject * args ); -//----------------------------------------------Render doc strings------ +/* Render doc strings */ static char M_Render_doc[] = "The Blender Render module"; -//----------------------------------------------Render method def------- -struct PyMethodDef M_Render_methods[] = { - {"CloseRenderWindow", ( PyCFunction ) M_Render_CloseRenderWindow, - METH_NOARGS, - "() - close the rendering window\n"}, - {"EnableDispView", ( PyCFunction ) M_Render_EnableDispView, - METH_NOARGS, - "(bool) - enable Sceneing in view\n"}, - {"EnableDispWin", ( PyCFunction ) M_Render_EnableDispWin, METH_NOARGS, - "(bool) - enable Sceneing in new window\n"}, - {"SetRenderWinPos", ( PyCFunction ) M_Render_SetRenderWinPos, - METH_VARARGS, - "([string list]) - position the rendering window in around the edge of the screen\n"}, - {"EnableEdgeShift", ( PyCFunction ) M_Render_EnableEdgeShift, - METH_VARARGS, - "(bool) - with the unified renderer the outlines are shifted a bit.\n"}, - {"EnableEdgeAll", ( PyCFunction ) M_Render_EnableEdgeAll, METH_VARARGS, - "(bool) - also consider transparent faces for edge-rendering with the unified renderer\n"}, - {NULL, NULL, 0, NULL} -}; -//------------------------------------BPy_RenderData methods/callbacks-- -static PyObject *RenderData_Render( BPy_RenderData * self ); -static PyObject *RenderData_SaveRenderedImage( BPy_RenderData *self, PyObject *args); -static PyObject *RenderData_RenderAnim( BPy_RenderData * self ); -static PyObject *RenderData_Play( BPy_RenderData * self ); -static PyObject *RenderData_SetRenderPath( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_GetRenderPath( BPy_RenderData * self ); -static PyObject *RenderData_SetBackbufPath( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_GetBackbufPath( BPy_RenderData * self ); -static PyObject *RenderData_EnableBackbuf( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableThreads( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_SetFtypePath( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_GetFtypePath( BPy_RenderData * self ); -static PyObject *RenderData_EnableExtensions( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableSequencer( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableRenderDaemon( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableToonShading( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EdgeIntensity( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_SetEdgeColor( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_GetEdgeColor( BPy_RenderData * self ); -static PyObject *RenderData_EdgeAntiShift( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableOversampling( BPy_RenderData * self, - PyObject * args ); + +/* deprecated callbacks */ +static PyObject *RenderData_SetRenderPath( BPy_RenderData *self, + PyObject *args ); +static PyObject *RenderData_SetBackbufPath( BPy_RenderData *self, + PyObject *args ); +static PyObject *RenderData_SetFtypePath( BPy_RenderData *self, + PyObject *args ); static PyObject *RenderData_SetOversamplingLevel( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableMotionBlur( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_MotionBlurLevel( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_PartsX( BPy_RenderData * self, PyObject * args ); -static PyObject *RenderData_PartsY( BPy_RenderData * self, PyObject * args ); -static PyObject *RenderData_EnableSky( BPy_RenderData * self ); -static PyObject *RenderData_EnablePremultiply( BPy_RenderData * self ); -static PyObject *RenderData_EnableKey( BPy_RenderData * self ); -static PyObject *RenderData_EnableShadow( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnablePanorama( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableEnvironmentMap( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableRayTracing( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableRadiosityRender( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_GetRenderWinSize( BPy_RenderData * self ); + PyObject * args ); static PyObject *RenderData_SetRenderWinSize( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableFieldRendering( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableOddFieldFirst( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableFieldTimeDisable( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableGaussFilter( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableBorderRender( BPy_RenderData * self, - PyObject * args ); + PyObject * args ); static PyObject *RenderData_SetBorder( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableGammaCorrection( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_GaussFilterSize( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_StartFrame( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_CurrentFrame( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EndFrame( BPy_RenderData * self, PyObject * args ); -static PyObject *RenderData_ImageSizeX( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_ImageSizeY( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_AspectRatioX( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_AspectRatioY( BPy_RenderData * self, - PyObject * args ); + PyObject * args ); static PyObject *RenderData_SetRenderer( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableCropping( BPy_RenderData * self, - PyObject * args ); + PyObject * args ); static PyObject *RenderData_SetImageType( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_Quality( BPy_RenderData * self, PyObject * args ); -static PyObject *RenderData_FramesPerSec( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableGrayscale( BPy_RenderData * self ); -static PyObject *RenderData_EnableRGBColor( BPy_RenderData * self ); -static PyObject *RenderData_EnableRGBAColor( BPy_RenderData * self ); -static PyObject *RenderData_SizePreset( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableUnifiedRenderer( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_SetYafrayGIQuality( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_SetYafrayGIMethod( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_YafrayGIPower( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_YafrayGIDepth( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_YafrayGICDepth( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableYafrayGICache( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableYafrayGIPhotons( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_YafrayGIPhotonCount( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_YafrayGIPhotonRadius( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_YafrayGIPhotonMixCount( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableYafrayGITunePhotons( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_YafrayGIShadowQuality( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_YafrayGIPixelsPerSample( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_YafrayGIRefinement( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_YafrayRayBias( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_YafrayRayDepth( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_YafrayGamma( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_YafrayExposure( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_YafrayProcessorCount( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableGameFrameStretch( BPy_RenderData * self ); -static PyObject *RenderData_EnableGameFrameExpose( BPy_RenderData * self ); -static PyObject *RenderData_EnableGameFrameBars( BPy_RenderData * self ); -static PyObject *RenderData_SetGameFrameColor( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_GetGameFrameColor( BPy_RenderData * self ); -static PyObject *RenderData_GammaLevel( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_PostProcessAdd( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_PostProcessMultiply( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_PostProcessGamma( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_SGIMaxsize( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_EnableSGICosmo( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_OldMapValue( BPy_RenderData * self, - PyObject * args ); -static PyObject *RenderData_NewMapValue( BPy_RenderData * self, - PyObject * args ); - -static PyObject *RenderData_getTimeCode( BPy_RenderData * self); - -static void RenderData_dealloc( BPy_RenderData * self ); -static PyObject *RenderData_getAttr( BPy_RenderData * self, char *name ); -static PyObject *RenderData_repr( BPy_RenderData * self ); -//------------------------------------BPy_RenderData method def-------- -static PyMethodDef BPy_RenderData_methods[] = { - {"render", ( PyCFunction ) RenderData_Render, METH_NOARGS, - "() - render the scene\n"}, - {"saveRenderedImage", (PyCFunction)RenderData_SaveRenderedImage, METH_VARARGS, - "(filename) - save an image generated by a call to render() (set output path first)\n"}, - {"renderAnim", ( PyCFunction ) RenderData_RenderAnim, METH_NOARGS, - "() - render a sequence from start frame to end frame\n"}, - {"play", ( PyCFunction ) RenderData_Play, METH_NOARGS, - "() - play animation of rendered images/avi (searches Pics: field)\n"}, - {"setRenderPath", ( PyCFunction ) RenderData_SetRenderPath, - METH_VARARGS, - "(string) - get/set the path to output the rendered images to\n"}, - {"getRenderPath", ( PyCFunction ) RenderData_GetRenderPath, - METH_NOARGS, - "() - get the path to directory where rendered images will go\n"}, - {"setBackbufPath", ( PyCFunction ) RenderData_SetBackbufPath, - METH_VARARGS, - "(string) - get/set the path to a background image and load it\n"}, - {"getBackbufPath", ( PyCFunction ) RenderData_GetBackbufPath, - METH_NOARGS, - "() - get the path to background image file\n"}, - {"enableBackbuf", ( PyCFunction ) RenderData_EnableBackbuf, - METH_VARARGS, - "(bool) - enable/disable the backbuf image\n"}, - {"enableThreads", ( PyCFunction ) RenderData_EnableThreads, - METH_VARARGS, - "(bool) - enable/disable threaded rendering\n"}, - {"setFtypePath", ( PyCFunction ) RenderData_SetFtypePath, METH_VARARGS, - "(string) - get/set the path to output the Ftype file\n"}, - {"getFtypePath", ( PyCFunction ) RenderData_GetFtypePath, METH_NOARGS, - "() - get the path to Ftype file\n"}, - {"enableExtensions", ( PyCFunction ) RenderData_EnableExtensions, - METH_VARARGS, - "(bool) - enable/disable windows extensions for output files\n"}, - {"enableSequencer", ( PyCFunction ) RenderData_EnableSequencer, - METH_VARARGS, - "(bool) - enable/disable Do Sequence\n"}, - {"enableRenderDaemon", ( PyCFunction ) RenderData_EnableRenderDaemon, - METH_VARARGS, - "(bool) - enable/disable Scene daemon\n"}, - {"enableToonShading", ( PyCFunction ) RenderData_EnableToonShading, - METH_VARARGS, - "(bool) - enable/disable Edge rendering\n"}, - {"edgeIntensity", ( PyCFunction ) RenderData_EdgeIntensity, - METH_VARARGS, - "(int) - get/set edge intensity for toon shading\n"}, - {"setEdgeColor", ( PyCFunction ) RenderData_SetEdgeColor, METH_VARARGS, - "(f,f,f) - set the edge color for toon shading - Red,Green,Blue expected.\n"}, - {"getEdgeColor", ( PyCFunction ) RenderData_GetEdgeColor, METH_NOARGS, - "() - get the edge color for toon shading - Red,Green,Blue expected.\n"}, - {"edgeAntiShift", ( PyCFunction ) RenderData_EdgeAntiShift, - METH_VARARGS, - "(int) - with the unified renderer to reduce intensity on boundaries.\n"}, - {"enableOversampling", ( PyCFunction ) RenderData_EnableOversampling, - METH_VARARGS, - "(bool) - enable/disable oversampling (anit-aliasing).\n"}, - {"setOversamplingLevel", - ( PyCFunction ) RenderData_SetOversamplingLevel, METH_VARARGS, - "(enum) - get/set the level of oversampling (anit-aliasing).\n"}, - {"enableMotionBlur", ( PyCFunction ) RenderData_EnableMotionBlur, - METH_VARARGS, - "(bool) - enable/disable MBlur.\n"}, - {"motionBlurLevel", ( PyCFunction ) RenderData_MotionBlurLevel, - METH_VARARGS, - "(float) - get/set the length of shutter time for motion blur.\n"}, - {"partsX", ( PyCFunction ) RenderData_PartsX, METH_VARARGS, - "(int) - get/set the number of parts to divide the render in the X direction\n"}, - {"partsY", ( PyCFunction ) RenderData_PartsY, METH_VARARGS, - "(int) - get/set the number of parts to divide the render in the Y direction\n"}, - {"enableSky", ( PyCFunction ) RenderData_EnableSky, METH_NOARGS, - "() - enable render background with sky\n"}, - {"enablePremultiply", ( PyCFunction ) RenderData_EnablePremultiply, - METH_NOARGS, - "() - enable premultiply alpha\n"}, - {"enableKey", ( PyCFunction ) RenderData_EnableKey, METH_NOARGS, - "() - enable alpha and colour values remain unchanged\n"}, - {"enableShadow", ( PyCFunction ) RenderData_EnableShadow, METH_VARARGS, - "(bool) - enable/disable shadow calculation\n"}, - {"enablePanorama", ( PyCFunction ) RenderData_EnablePanorama, - METH_VARARGS, - "(bool) - enable/disable panorama rendering (output width is multiplied by Xparts)\n"}, - {"enableEnvironmentMap", - ( PyCFunction ) RenderData_EnableEnvironmentMap, METH_VARARGS, - "(bool) - enable/disable environment map rendering\n"}, - {"enableRayTracing", ( PyCFunction ) RenderData_EnableRayTracing, - METH_VARARGS, - "(bool) - enable/disable ray tracing\n"}, - {"enableRadiosityRender", - ( PyCFunction ) RenderData_EnableRadiosityRender, METH_VARARGS, - "(bool) - enable/disable radiosity rendering\n"}, - {"getRenderWinSize", ( PyCFunction ) RenderData_GetRenderWinSize, - METH_NOARGS, - "() - get the size of the render window\n"}, - {"setRenderWinSize", ( PyCFunction ) RenderData_SetRenderWinSize, - METH_VARARGS, - "(int) - set the size of the render window\n"}, - {"enableFieldRendering", - ( PyCFunction ) RenderData_EnableFieldRendering, METH_VARARGS, - "(bool) - enable/disable field rendering\n"}, - {"enableOddFieldFirst", ( PyCFunction ) RenderData_EnableOddFieldFirst, - METH_VARARGS, - "(bool) - enable/disable Odd field first rendering (Default: Even field)\n"}, - {"enableFieldTimeDisable", - ( PyCFunction ) RenderData_EnableFieldTimeDisable, METH_VARARGS, - "(bool) - enable/disable time difference in field calculations\n"}, - {"enableGaussFilter", ( PyCFunction ) RenderData_EnableGaussFilter, - METH_VARARGS, - "(bool) - enable/disable Gauss sampling filter for antialiasing\n"}, - {"enableBorderRender", ( PyCFunction ) RenderData_EnableBorderRender, - METH_VARARGS, - "(bool) - enable/disable small cut-out rendering\n"}, - {"setBorder", ( PyCFunction ) RenderData_SetBorder, METH_VARARGS, - "(f,f,f,f) - set the border for border rendering\n"}, - {"enableGammaCorrection", - ( PyCFunction ) RenderData_EnableGammaCorrection, METH_VARARGS, - "(bool) - enable/disable gamma correction\n"}, - {"gaussFilterSize", ( PyCFunction ) RenderData_GaussFilterSize, - METH_VARARGS, - "(float) - get/sets the Gauss filter size\n"}, - {"startFrame", ( PyCFunction ) RenderData_StartFrame, METH_VARARGS, - "(int) - get/set the starting frame for rendering\n"}, - {"currentFrame", ( PyCFunction ) RenderData_CurrentFrame, METH_VARARGS, - "(int) - get/set the current frame for rendering\n"}, - {"endFrame", ( PyCFunction ) RenderData_EndFrame, METH_VARARGS, - "(int) - get/set the ending frame for rendering\n"}, - {"getTimeCode", ( PyCFunction ) RenderData_getTimeCode, METH_NOARGS, - "get the current frame in HH:MM:SS:FF format\n"}, - {"imageSizeX", ( PyCFunction ) RenderData_ImageSizeX, METH_VARARGS, - "(int) - get/set the image width in pixels\n"}, - {"imageSizeY", ( PyCFunction ) RenderData_ImageSizeY, METH_VARARGS, - "(int) - get/set the image height in pixels\n"}, - {"aspectRatioX", ( PyCFunction ) RenderData_AspectRatioX, METH_VARARGS, - "(int) - get/set the horizontal aspect ratio\n"}, - {"aspectRatioY", ( PyCFunction ) RenderData_AspectRatioY, METH_VARARGS, - "(int) - get/set the vertical aspect ratio\n"}, - {"setRenderer", ( PyCFunction ) RenderData_SetRenderer, METH_VARARGS, - "(enum) - get/set which renderer to render the output\n"}, - {"enableCropping", ( PyCFunction ) RenderData_EnableCropping, - METH_VARARGS, - "(bool) - enable/disable exclusion of border rendering from total image\n"}, - {"setImageType", ( PyCFunction ) RenderData_SetImageType, METH_VARARGS, - "(enum) - get/set the type of image to output from the render\n"}, - {"quality", ( PyCFunction ) RenderData_Quality, METH_VARARGS, - "(int) - get/set quality get/setting for JPEG images, AVI Jpeg and SGI movies\n"}, - {"framesPerSec", ( PyCFunction ) RenderData_FramesPerSec, METH_VARARGS, - "(int) - get/set frames per second\n"}, - {"enableGrayscale", ( PyCFunction ) RenderData_EnableGrayscale, - METH_NOARGS, - "() - images are saved with BW (grayscale) data\n"}, - {"enableRGBColor", ( PyCFunction ) RenderData_EnableRGBColor, - METH_NOARGS, - "() - images are saved with RGB (color) data\n"}, - {"enableRGBAColor", ( PyCFunction ) RenderData_EnableRGBAColor, - METH_NOARGS, - "() - images are saved with RGB and Alpha data (if supported)\n"}, - {"sizePreset", ( PyCFunction ) RenderData_SizePreset, METH_VARARGS, - "(enum) - get/set the render to one of a few preget/sets\n"}, - {"enableUnifiedRenderer", - ( PyCFunction ) RenderData_EnableUnifiedRenderer, METH_VARARGS, - "(bool) - use the unified renderer\n"}, - {"setYafrayGIQuality", ( PyCFunction ) RenderData_SetYafrayGIQuality, - METH_VARARGS, - "(enum) - get/set yafray global Illumination quality\n"}, - {"setYafrayGIMethod", ( PyCFunction ) RenderData_SetYafrayGIMethod, - METH_VARARGS, - "(enum) - get/set yafray global Illumination method\n"}, - {"yafrayGIPower", ( PyCFunction ) RenderData_YafrayGIPower, - METH_VARARGS, - "(float) - get/set GI lighting intensity scale\n"}, - {"yafrayGIDepth", ( PyCFunction ) RenderData_YafrayGIDepth, - METH_VARARGS, - "(int) - get/set number of bounces of the indirect light\n"}, - {"yafrayGICDepth", ( PyCFunction ) RenderData_YafrayGICDepth, - METH_VARARGS, - "(int) - get/set number of bounces inside objects (for caustics)\n"}, - {"enableYafrayGICache", ( PyCFunction ) RenderData_EnableYafrayGICache, - METH_VARARGS, - "(bool) - enable/disable cache irradiance samples (faster)\n"}, - {"enableYafrayGIPhotons", - ( PyCFunction ) RenderData_EnableYafrayGIPhotons, METH_VARARGS, - "(bool) - enable/disable use global photons to help in GI\n"}, - {"yafrayGIPhotonCount", ( PyCFunction ) RenderData_YafrayGIPhotonCount, - METH_VARARGS, - "(int) - get/set number of photons to shoot\n"}, - {"yafrayGIPhotonRadius", - ( PyCFunction ) RenderData_YafrayGIPhotonRadius, METH_VARARGS, - "(float) - get/set radius to search for photons to mix (blur)\n"}, - {"yafrayGIPhotonMixCount", - ( PyCFunction ) RenderData_YafrayGIPhotonMixCount, METH_VARARGS, - "(int) - get/set number of photons to shoot\n"}, - {"enableYafrayGITunePhotons", - ( PyCFunction ) RenderData_EnableYafrayGITunePhotons, METH_VARARGS, - "(bool) - enable/disable show the photonmap directly in the render for tuning\n"}, - {"yafrayGIShadowQuality", - ( PyCFunction ) RenderData_YafrayGIShadowQuality, METH_VARARGS, - "(float) - get/set the shadow quality, keep it under 0.95\n"}, - {"yafrayGIPixelsPerSample", - ( PyCFunction ) RenderData_YafrayGIPixelsPerSample, METH_VARARGS, - "(int) - get/set maximum number of pixels without samples, the lower the better and slower\n"}, - {"yafrayGIRefinement", ( PyCFunction ) RenderData_YafrayGIRefinement, - METH_VARARGS, - "(float) - get/setthreshold to refine shadows EXPERIMENTAL. 1 = no refinement\n"}, - {"yafrayRayBias", ( PyCFunction ) RenderData_YafrayRayBias, - METH_VARARGS, - "(float) - get/set shadow ray bias to avoid self shadowing\n"}, - {"yafrayRayDepth", ( PyCFunction ) RenderData_YafrayRayDepth, - METH_VARARGS, - "(int) - get/set maximum render ray depth from the camera\n"}, - {"yafrayGamma", ( PyCFunction ) RenderData_YafrayGamma, METH_VARARGS, - "(float) - get/set gamma correction, 1 is off\n"}, - {"yafrayExposure", ( PyCFunction ) RenderData_YafrayExposure, - METH_VARARGS, - "(float) - get/set exposure adjustment, 0 is off\n"}, - {"yafrayProcessorCount", - ( PyCFunction ) RenderData_YafrayProcessorCount, METH_VARARGS, - "(int) - get/set number of processors to use\n"}, - {"enableGameFrameStretch", - ( PyCFunction ) RenderData_EnableGameFrameStretch, METH_NOARGS, - "(l) - enble stretch or squeeze the viewport to fill the display window\n"}, - {"enableGameFrameExpose", - ( PyCFunction ) RenderData_EnableGameFrameExpose, METH_NOARGS, - "(l) - enable show the entire viewport in the display window, viewing more horizontally or vertically\n"}, - {"enableGameFrameBars", ( PyCFunction ) RenderData_EnableGameFrameBars, - METH_NOARGS, - "() - enable show the entire viewport in the display window, using bar horizontally or vertically\n"}, - {"setGameFrameColor", ( PyCFunction ) RenderData_SetGameFrameColor, - METH_VARARGS, - "(f,f,f) - set the red, green, blue component of the bars\n"}, - {"getGameFrameColor", ( PyCFunction ) RenderData_GetGameFrameColor, - METH_NOARGS, - "() - get the red, green, blue component of the bars\n"}, - {"gammaLevel", ( PyCFunction ) RenderData_GammaLevel, METH_VARARGS, - "(float) - get/set the gamma value for blending oversampled images (1.0 = no correction\n"}, - {"postProcessAdd", ( PyCFunction ) RenderData_PostProcessAdd, - METH_VARARGS, - "(float) - get/set post processing add\n"}, - {"postProcessMultiply", ( PyCFunction ) RenderData_PostProcessMultiply, - METH_VARARGS, - "(float) - get/set post processing multiply\n"}, - {"postProcessGamma", ( PyCFunction ) RenderData_PostProcessGamma, - METH_VARARGS, - "(float) - get/set post processing gamma\n"}, - {"SGIMaxsize", ( PyCFunction ) RenderData_SGIMaxsize, METH_VARARGS, - "(int) - get/set maximum size per frame to save in an SGI movie\n"}, - {"enableSGICosmo", ( PyCFunction ) RenderData_EnableSGICosmo, - METH_VARARGS, - "(bool) - enable/disable attempt to save SGI movies using Cosmo hardware\n"}, - {"oldMapValue", ( PyCFunction ) RenderData_OldMapValue, METH_VARARGS, - "(int) - get/set specify old map value in frames\n"}, - {"newMapValue", ( PyCFunction ) RenderData_NewMapValue, METH_VARARGS, - "(int) - get/set specify new map value in frames\n"}, - {NULL, NULL, 0, NULL} -}; -//------------------------------------BPy_RenderData Type defintion------ -PyTypeObject RenderData_Type = { - PyObject_HEAD_INIT( NULL ) 0, /* ob_size */ - "Blender RenderData", /* tp_name */ - sizeof( BPy_RenderData ), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - ( destructor ) RenderData_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - ( getattrfunc ) RenderData_getAttr, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - ( reprfunc ) RenderData_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_as_hash */ - 0, 0, 0, 0, 0, 0, - 0, /* tp_doc */ - 0, 0, 0, 0, 0, 0, - BPy_RenderData_methods, /* tp_methods */ - 0, /* tp_members */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -}; -//---------------------------------------------------Render Module Init-- -PyObject *Render_Init( void ) -{ - PyObject *submodule; - - RenderData_Type.ob_type = &PyType_Type; - - submodule = Py_InitModule3( "Blender.Scene.Render", - M_Render_methods, M_Render_doc ); - - PyModule_AddIntConstant( submodule, "INTERNAL", R_INTERN ); - PyModule_AddIntConstant( submodule, "YAFRAY", R_YAFRAY ); - PyModule_AddIntConstant( submodule, "AVIRAW", R_AVIRAW ); - PyModule_AddIntConstant( submodule, "AVIJPEG", R_AVIJPEG ); - PyModule_AddIntConstant( submodule, "AVICODEC", R_AVICODEC ); - PyModule_AddIntConstant( submodule, "QUICKTIME", R_QUICKTIME ); - PyModule_AddIntConstant( submodule, "TARGA", R_TARGA ); - PyModule_AddIntConstant( submodule, "RAWTGA", R_RAWTGA ); - PyModule_AddIntConstant( submodule, "HDR", R_RADHDR ); - PyModule_AddIntConstant( submodule, "PNG", R_PNG ); - PyModule_AddIntConstant( submodule, "BMP", R_BMP ); - PyModule_AddIntConstant( submodule, "JPEG", R_JPEG90 ); - PyModule_AddIntConstant( submodule, "HAMX", R_HAMX ); - PyModule_AddIntConstant( submodule, "IRIS", R_IRIS ); - PyModule_AddIntConstant( submodule, "IRISZ", R_IRIZ ); - PyModule_AddIntConstant( submodule, "FTYPE", R_FTYPE ); - PyModule_AddIntConstant( submodule, "PAL", B_PR_PAL ); - PyModule_AddIntConstant( submodule, "NTSC", B_PR_NTSC ); - PyModule_AddIntConstant( submodule, "DEFAULT", B_PR_PRESET ); - PyModule_AddIntConstant( submodule, "PREVIEW", B_PR_PRV ); - PyModule_AddIntConstant( submodule, "PC", B_PR_PC ); - PyModule_AddIntConstant( submodule, "PAL169", B_PR_PAL169 ); - PyModule_AddIntConstant( submodule, "PANO", B_PR_PANO ); - PyModule_AddIntConstant( submodule, "FULL", B_PR_FULL ); - PyModule_AddIntConstant( submodule, "NONE", PY_NONE ); - PyModule_AddIntConstant( submodule, "LOW", PY_LOW ); - PyModule_AddIntConstant( submodule, "MEDIUM", PY_MEDIUM ); - PyModule_AddIntConstant( submodule, "HIGH", PY_HIGH ); - PyModule_AddIntConstant( submodule, "HIGHER", PY_HIGHER ); - PyModule_AddIntConstant( submodule, "BEST", PY_BEST ); - PyModule_AddIntConstant( submodule, "SKYDOME", PY_SKYDOME ); - PyModule_AddIntConstant( submodule, "GIFULL", PY_FULL ); - PyModule_AddIntConstant( submodule, "OPENEXR", R_OPENEXR ); + PyObject * args ); +static PyObject *RenderData_Render( BPy_RenderData * self ); - return ( submodule ); -} +/* BPy_RenderData Internal Protocols */ -//-----------------------------------BPy_RenderData Internal Protocols--- -//-------------------------------------------------dealloc--------------- static void RenderData_dealloc( BPy_RenderData * self ) { PyObject_DEL( self ); } -//-------------------------------------------------getAttr--------------- -static PyObject *RenderData_getAttr( BPy_RenderData * self, char *name ) -{ - return Py_FindMethod( BPy_RenderData_methods, ( PyObject * ) self, - name ); -} - -//-------------------------------------------------repr------------------ static PyObject *RenderData_repr( BPy_RenderData * self ) { if( self->renderContext ) @@ -611,32 +144,9 @@ static PyObject *RenderData_repr( BPy_RenderData * self ) return PyString_FromString( "NULL" ); } -//------------------------------BPy_RenderData Callbacks----------------- -//--------------------------------------CreatePyObject------------------- -PyObject *RenderData_CreatePyObject( struct Scene * scene ) -{ - BPy_RenderData *py_renderdata; - - py_renderdata = - ( BPy_RenderData * ) PyObject_NEW( BPy_RenderData, - &RenderData_Type ); - - if( py_renderdata == NULL ) { - return ( NULL ); - } - py_renderdata->renderContext = &scene->r; - py_renderdata->scene = scene; - - return ( ( PyObject * ) py_renderdata ); -} - -//------------------------------CheckPyObject---------------------------- -int RenderData_CheckPyObject( PyObject * py_obj ) -{ - return ( py_obj->ob_type == &RenderData_Type ); -} - -//------------------------------------BitToggleInt----------------------- +/***************************************************************************/ +/* local utility routines for manipulating data */ +/***************************************************************************/ static PyObject *M_Render_BitToggleInt( PyObject * args, int setting, int *structure ) { @@ -662,7 +172,6 @@ static PyObject *M_Render_BitToggleInt( PyObject * args, int setting, } -//------------------------------------BitToggleShort--------------------- static PyObject *M_Render_BitToggleShort( PyObject * args, short setting, short *structure ) { @@ -688,7 +197,6 @@ static PyObject *M_Render_BitToggleShort( PyObject * args, short setting, } -//------------------------------------GetSetAttributeFloat--------------- static PyObject *M_Render_GetSetAttributeFloat( PyObject * args, float *structure, float min, float max ) @@ -715,7 +223,6 @@ static PyObject *M_Render_GetSetAttributeFloat( PyObject * args, return Py_BuildValue( "f", *structure ); } -//------------------------------------GetSetAttributeShort--------------- static PyObject *M_Render_GetSetAttributeShort( PyObject * args, short *structure, int min, int max ) @@ -742,7 +249,6 @@ static PyObject *M_Render_GetSetAttributeShort( PyObject * args, return Py_BuildValue( "h", *structure ); } -//------------------------------------GetSetAttributeInt----------------- static PyObject *M_Render_GetSetAttributeInt( PyObject * args, int *structure, int min, int max ) { @@ -768,7 +274,7 @@ static PyObject *M_Render_GetSetAttributeInt( PyObject * args, int *structure, return Py_BuildValue( "i", *structure ); } -//------------------------------------DoSizePrese ----------------------- + static void M_Render_DoSizePreset( BPy_RenderData * self, short xsch, short ysch, short xasp, short yasp, short size, short xparts, short yparts, @@ -789,15 +295,16 @@ static void M_Render_DoSizePreset( BPy_RenderData * self, short xsch, EXPP_allqueue( REDRAWVIEWCAM, 0 ); } -//------------------------------------Render Module Function Definitions- -//------------------------------------Render.CloseRenderWindow() -------- +/***************************************************************************/ +/* Render Module Function Definitions */ +/***************************************************************************/ + PyObject *M_Render_CloseRenderWindow( PyObject * self ) { BIF_close_render_display( ); return EXPP_incr_ret( Py_None ); } -//------------------------------------Render.SetRenderWinPos() ---------- PyObject *M_Render_SetRenderWinPos( PyObject * self, PyObject * args ) { PyObject *list = NULL; @@ -812,7 +319,7 @@ PyObject *M_Render_SetRenderWinPos( PyObject * self, PyObject * args ) for( x = 0; x < PyList_Size( list ); x++ ) { if( !PyArg_Parse( PyList_GetItem( list, x ), "s", &loc ) ) { return EXPP_ReturnPyObjError( PyExc_TypeError, - "python list not parseable\n" ); + "python list not parseable" ); } if( strcmp( loc, "SW" ) == 0 || strcmp( loc, "sw" ) == 0 ) G.winpos |= 1; @@ -834,14 +341,13 @@ PyObject *M_Render_SetRenderWinPos( PyObject * self, PyObject * args ) G.winpos |= 256; else return EXPP_ReturnPyObjError( PyExc_AttributeError, - "list contains unknown string\n" ); + "list contains unknown string" ); } EXPP_allqueue( REDRAWBUTSSCENE, 0 ); return EXPP_incr_ret( Py_None ); } -//------------------------------------Render.EnableDispView() ----------- PyObject *M_Render_EnableDispView( PyObject * self ) { G.displaymode = R_DISPLAYVIEW; @@ -850,7 +356,6 @@ PyObject *M_Render_EnableDispView( PyObject * self ) return EXPP_incr_ret( Py_None ); } -//------------------------------------Render.EnableDispWin() ------------ PyObject *M_Render_EnableDispWin( PyObject * self ) { G.displaymode = R_DISPLAYWIN; @@ -859,21 +364,20 @@ PyObject *M_Render_EnableDispWin( PyObject * self ) return EXPP_incr_ret( Py_None ); } -//------------------------------------Render.EnableEdgeShift() ---------- PyObject *M_Render_EnableEdgeShift( PyObject * self, PyObject * args ) { return M_Render_BitToggleInt( args, 1, &G.compat ); } -//------------------------------------Render.EnableEdgeAll() ------------ PyObject *M_Render_EnableEdgeAll( PyObject * self, PyObject * args ) { return M_Render_BitToggleInt( args, 1, &G.notonlysolid ); } -//----------------------------BPy_RenderData Function Definitions-------- +/***************************************************************************/ +/* BPy_RenderData Function Definitions */ +/***************************************************************************/ -//------------------------------------RenderData.Render() --------------- PyObject *RenderData_Render( BPy_RenderData * self ) { Scene *oldsce; @@ -903,8 +407,10 @@ PyObject *RenderData_Render( BPy_RenderData * self ) return EXPP_incr_ret( Py_None ); } -//------------------------------------RenderData.saveRenderedImage() --------------- -//This will save the rendered image to an output file path already defined + +/* + * This will save the rendered image to an output file path already defined. + */ PyObject *RenderData_SaveRenderedImage ( BPy_RenderData * self, PyObject *args ) { char dir[FILE_MAXDIR * 2], str[FILE_MAXFILE * 2]; @@ -913,12 +419,15 @@ PyObject *RenderData_SaveRenderedImage ( BPy_RenderData * self, PyObject *args ) int zbuff = 0; if( !PyArg_ParseTuple( args, "s|i", &name_str, &zbuff ) ) - return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a filename (string) and optional int" ); + return EXPP_ReturnPyObjError( PyExc_TypeError, + "expected a filename (string) and optional int" ); - if( strlen(self->renderContext->pic) + strlen(name_str) > sizeof(filepath)-1 ) - return EXPP_ReturnPyObjError( PyExc_ValueError, "full filename too long" ); + if( strlen(self->renderContext->pic) + strlen(name_str) + >= sizeof(filepath) ) + return EXPP_ReturnPyObjError( PyExc_ValueError, + "full filename too long" ); - if (zbuff !=0 ) zbuff = 1; //required 1/0 + if (zbuff !=0 ) zbuff = 1; /*required 1/0 */ BLI_strncpy( filepath, self->renderContext->pic, sizeof(filepath) ); strcat(filepath, name_str); @@ -936,7 +445,7 @@ PyObject *RenderData_SaveRenderedImage ( BPy_RenderData * self, PyObject *args ) } return EXPP_incr_ret(Py_None); } -//------------------------------------RenderData.RenderAnim() ----------- + PyObject *RenderData_RenderAnim( BPy_RenderData * self ) { Scene *oldsce; @@ -963,7 +472,6 @@ PyObject *RenderData_RenderAnim( BPy_RenderData * self ) return EXPP_incr_ret( Py_None ); } -//------------------------------------RenderData.Play() ----------------- PyObject *RenderData_Play( BPy_RenderData * self ) { char file[FILE_MAXDIR + FILE_MAXFILE]; @@ -1019,117 +527,30 @@ PyObject *RenderData_Play( BPy_RenderData * self ) return EXPP_incr_ret( Py_None ); } -//------------------------------------RenderData.StRenderPath() --------- -PyObject *RenderData_SetRenderPath( BPy_RenderData * self, PyObject * args ) -{ - char *name; - - if( !PyArg_ParseTuple( args, "s", &name ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected a string" ) ); - - if( strlen( name ) > 160 ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "path is too long (SetRenderPath)" ) ); - - strcpy( self->renderContext->pic, name ); - EXPP_allqueue( REDRAWBUTSSCENE, 0 ); - - return EXPP_incr_ret( Py_None ); -} - -//------------------------------------RenderData.GetRenderPath() -------- -PyObject *RenderData_GetRenderPath( BPy_RenderData * self ) -{ - return Py_BuildValue( "s", self->renderContext->pic ); -} - -//------------------------------------RenderData.SetBackbufPath() ------- -PyObject *RenderData_SetBackbufPath( BPy_RenderData * self, PyObject * args ) -{ - char *name; - Image *ima; - - if( !PyArg_ParseTuple( args, "s", &name ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected a string" ) ); - - if( strlen( name ) > 160 ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "path is too long (SetBackbufPath)" ) ); - - strcpy( self->renderContext->backbuf, name ); - EXPP_allqueue( REDRAWBUTSSCENE, 0 ); - - ima = add_image( name ); - if( ima ) { - free_image_buffers( ima ); - ima->ok = 1; - } - - return EXPP_incr_ret( Py_None ); -} - -//------------------------------------RenderData.GetBackbufPath() ------- -PyObject *RenderData_GetBackbufPath( BPy_RenderData * self ) -{ - return Py_BuildValue( "s", self->renderContext->backbuf ); -} - -//------------------------------------RenderData.EnableBackbuf() -------- PyObject *RenderData_EnableBackbuf( BPy_RenderData * self, PyObject * args ) { return M_Render_BitToggleShort( args, 1, &self->renderContext->bufflag ); } -//------------------------------------RenderData.EnableThreads() -------- PyObject *RenderData_EnableThreads( BPy_RenderData * self, PyObject * args ) { return M_Render_BitToggleInt( args, R_THREADS, &self->renderContext->mode ); } -//------------------------------------RenderData.SetFtypePath() --------- -PyObject *RenderData_SetFtypePath( BPy_RenderData * self, PyObject * args ) -{ - char *name; - - if( !PyArg_ParseTuple( args, "s", &name ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected a string" ) ); - - if( strlen( name ) > 160 ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "path is too long (SetFtypePath)" ) ); - - strcpy( self->renderContext->ftype, name ); - EXPP_allqueue( REDRAWBUTSSCENE, 0 ); - - return EXPP_incr_ret( Py_None ); -} - -//------------------------------------RenderData.GetFtypePath() --------- -PyObject *RenderData_GetFtypePath( BPy_RenderData * self ) -{ - return Py_BuildValue( "s", self->renderContext->ftype ); -} - -//------------------------------------RenderData.EnableExtensions() ----- PyObject *RenderData_EnableExtensions( BPy_RenderData * self, PyObject * args ) { return M_Render_BitToggleShort( args, R_EXTENSION, &self->renderContext->scemode ); } -//------------------------------------RenderData.EnableSequencer() ------ PyObject *RenderData_EnableSequencer( BPy_RenderData * self, PyObject * args ) { return M_Render_BitToggleShort( args, R_DOSEQ, &self->renderContext->scemode ); } -//------------------------------------RenderData.EnableRenderDaemon() --- PyObject *RenderData_EnableRenderDaemon( BPy_RenderData * self, PyObject * args ) { @@ -1137,7 +558,6 @@ PyObject *RenderData_EnableRenderDaemon( BPy_RenderData * self, &self->renderContext->scemode ); } -//------------------------------------RenderData.EnableToonShading() ---- PyObject *RenderData_EnableToonShading( BPy_RenderData * self, PyObject * args ) { @@ -1145,7 +565,6 @@ PyObject *RenderData_EnableToonShading( BPy_RenderData * self, &self->renderContext->mode ); } -//------------------------------------RenderData.EdgeIntensity() -------- PyObject *RenderData_EdgeIntensity( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeShort( args, @@ -1153,12 +572,9 @@ PyObject *RenderData_EdgeIntensity( BPy_RenderData * self, PyObject * args ) 255 ); } -//------------------------------------RenderData.SetEdgeColor() --------- PyObject *RenderData_SetEdgeColor( BPy_RenderData * self, PyObject * args ) { - float red = 0.0f; - float green = 0.0f; - float blue = 0.0f; + float red, green, blue; if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) ) return ( EXPP_ReturnPyObjError( PyExc_AttributeError, @@ -1181,17 +597,15 @@ PyObject *RenderData_SetEdgeColor( BPy_RenderData * self, PyObject * args ) return EXPP_incr_ret( Py_None ); } -//------------------------------------RenderData.GetEdgeColor() --------- PyObject *RenderData_GetEdgeColor( BPy_RenderData * self ) { char rgb[24]; - sprintf( rgb, "[%.3f,%.3f,%.3f]\n", self->renderContext->edgeR, + sprintf( rgb, "[%.3f,%.3f,%.3f]", self->renderContext->edgeR, self->renderContext->edgeG, self->renderContext->edgeB ); return PyString_FromString( rgb ); } -//------------------------------------RenderData.EdgeAntiShift() -------- PyObject *RenderData_EdgeAntiShift( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeShort( args, @@ -1199,7 +613,6 @@ PyObject *RenderData_EdgeAntiShift( BPy_RenderData * self, PyObject * args ) same_mat_redux, 0, 255 ); } -//------------------------------------RenderData.EnableOversampling() --- PyObject *RenderData_EnableOversampling( BPy_RenderData * self, PyObject * args ) { @@ -1207,34 +620,32 @@ PyObject *RenderData_EnableOversampling( BPy_RenderData * self, &self->renderContext->mode ); } -//------------------------------------RenderData.SetOversamplingLevel() - -PyObject *RenderData_SetOversamplingLevel( BPy_RenderData * self, - PyObject * args ) +static int RenderData_setOSALevel( BPy_RenderData * self, + PyObject * value ) { int level; - if( !PyArg_ParseTuple( args, "i", &level ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected int" ) ); + if( !PyInt_CheckExact( value ) ) + return EXPP_ReturnIntError( PyExc_TypeError, + "expected int argument" ); + level = PyInt_AsLong( value ); if( level != 5 && level != 8 && level != 11 && level != 16 ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected 5,8,11, or 16" ) ); + return EXPP_ReturnIntError( PyExc_ValueError, + "expected 5, 8, 11, or 16" ); self->renderContext->osa = (short)level; EXPP_allqueue( REDRAWBUTSSCENE, 0 ); - return EXPP_incr_ret( Py_None ); + return 0; } -//------------------------------------RenderData.EnableMotionBlur() ----- PyObject *RenderData_EnableMotionBlur( BPy_RenderData * self, PyObject * args ) { return M_Render_BitToggleInt( args, R_MBLUR, &self->renderContext->mode ); } -//------------------------------------RenderData.MotionBlurLevel() ------ PyObject *RenderData_MotionBlurLevel( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeFloat( args, @@ -1242,7 +653,6 @@ PyObject *RenderData_MotionBlurLevel( BPy_RenderData * self, PyObject * args ) 0.01f, 5.0f ); } -//------------------------------------RenderData.PartsX() --------------- PyObject *RenderData_PartsX( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeShort( args, @@ -1250,7 +660,6 @@ PyObject *RenderData_PartsX( BPy_RenderData * self, PyObject * args ) 64 ); } -//------------------------------------RenderData.PartsY() --------------- PyObject *RenderData_PartsY( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeShort( args, @@ -1258,7 +667,6 @@ PyObject *RenderData_PartsY( BPy_RenderData * self, PyObject * args ) 64 ); } -//------------------------------------RenderData.EnableSky() ------------ PyObject *RenderData_EnableSky( BPy_RenderData * self ) { self->renderContext->alphamode = R_ADDSKY; @@ -1267,7 +675,6 @@ PyObject *RenderData_EnableSky( BPy_RenderData * self ) return EXPP_incr_ret( Py_None ); } -//------------------------------------RenderData.EnablePremultiply() ---- PyObject *RenderData_EnablePremultiply( BPy_RenderData * self ) { self->renderContext->alphamode = R_ALPHAPREMUL; @@ -1276,7 +683,6 @@ PyObject *RenderData_EnablePremultiply( BPy_RenderData * self ) return EXPP_incr_ret( Py_None ); } -//------------------------------------RenderData.EnableKey() ------------ PyObject *RenderData_EnableKey( BPy_RenderData * self ) { self->renderContext->alphamode = R_ALPHAKEY; @@ -1285,14 +691,12 @@ PyObject *RenderData_EnableKey( BPy_RenderData * self ) return EXPP_incr_ret( Py_None ); } -//------------------------------------RenderData.EnableShadow() --------- PyObject *RenderData_EnableShadow( BPy_RenderData * self, PyObject * args ) { return M_Render_BitToggleInt( args, R_SHADOW, &self->renderContext->mode ); } -//------------------------------------RenderData.EnvironmentMap() ------- PyObject *RenderData_EnableEnvironmentMap( BPy_RenderData * self, PyObject * args ) { @@ -1300,54 +704,24 @@ PyObject *RenderData_EnableEnvironmentMap( BPy_RenderData * self, &self->renderContext->mode ); } -//------------------------------------RenderData.EnablePanorama() ------- PyObject *RenderData_EnablePanorama( BPy_RenderData * self, PyObject * args ) { return M_Render_BitToggleInt( args, R_PANORAMA, &self->renderContext->mode ); } -//------------------------------------RenderData.EnableRayTracing() ----- PyObject *RenderData_EnableRayTracing( BPy_RenderData * self, PyObject * args ) { return M_Render_BitToggleInt( args, R_RAYTRACE, &self->renderContext->mode ); } -//------------------------------------RenderData.EnableRadiosityRender() PyObject *RenderData_EnableRadiosityRender( BPy_RenderData * self, PyObject * args ) { return M_Render_BitToggleInt( args, R_RADIO, &self->renderContext->mode ); } - -//------------------------------------RenderData.SetRenderWinSize() ----- -PyObject *RenderData_SetRenderWinSize( BPy_RenderData * self, PyObject * args ) -{ - int size; - - if( !PyArg_ParseTuple( args, "i", &size ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected int" ) ); - - if( size != 25 && size != 50 && size != 75 && size != 100 ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected 25, 50, 75, or 100" ) ); - - self->renderContext->size = (short)size; - EXPP_allqueue( REDRAWBUTSSCENE, 0 ); - - return EXPP_incr_ret( Py_None ); -} -// -//------------------------------------RenderData.GetRenderWinSize() ----- -PyObject *RenderData_GetRenderWinSize( BPy_RenderData * self ) -{ - return PyInt_FromLong( (long) self->renderContext->size ); -} - -//------------------------------------RenderData.EnableFieldRendering() - PyObject *RenderData_EnableFieldRendering( BPy_RenderData * self, PyObject * args ) { @@ -1355,7 +729,6 @@ PyObject *RenderData_EnableFieldRendering( BPy_RenderData * self, &self->renderContext->mode ); } -//------------------------------------RenderData.EnableOddFieldFirst() -- PyObject *RenderData_EnableOddFieldFirst( BPy_RenderData * self, PyObject * args ) { @@ -1363,7 +736,6 @@ PyObject *RenderData_EnableOddFieldFirst( BPy_RenderData * self, &self->renderContext->mode ); } -//------------------------------------RenderData.EnableFieldTimeDisable() PyObject *RenderData_EnableFieldTimeDisable( BPy_RenderData * self, PyObject * args ) { @@ -1371,7 +743,6 @@ PyObject *RenderData_EnableFieldTimeDisable( BPy_RenderData * self, &self->renderContext->mode ); } -//------------------------------------RenderData.EnableGaussFilter() ---- PyObject *RenderData_EnableGaussFilter( BPy_RenderData * self, PyObject * args ) { @@ -1383,7 +754,6 @@ PyObject *RenderData_EnableGaussFilter( BPy_RenderData * self, /* choices are listed in DNA_scene_types.h (search filtertype) */ } -//------------------------------------RenderData.EnableBorderRender() --- PyObject *RenderData_EnableBorderRender( BPy_RenderData * self, PyObject * args ) { @@ -1391,49 +761,41 @@ PyObject *RenderData_EnableBorderRender( BPy_RenderData * self, &self->renderContext->mode ); } -//------------------------------------RenderData.SetBorder() ------------ -PyObject *RenderData_SetBorder( BPy_RenderData * self, PyObject * args ) +static int RenderData_setBorder( BPy_RenderData * self, PyObject * args ) { - float xmin = 0.0f, ymin = 0.0f, xmax = 0.0f, ymax = 0.0f; - int status = 0; - PyObject *ob_args; + float xmin, ymin, xmax, ymax; - //left,botton | right,top coords - in that order - if( PyObject_Length( args ) == 4 ) { - status = PyArg_ParseTuple( args, "ffff", &xmin, &ymin, &xmax, - &ymax ); - } else { - if( PyArg_ParseTuple( args, "O", &ob_args ) ) { - if( PyList_Check( ob_args ) ) - status = PyArg_ParseTuple( args, "(ffff)", - &xmin, &ymin, &xmax, - &ymax ); - else { - status = 0; - } - } else { - status = 0; - } + if( PyList_Check( args ) ) + args = PySequence_Tuple( args ); + else + Py_INCREF( args ); + + if( !PyArg_ParseTuple( args, "ffff", &xmin, &ymin, &xmax, &ymax ) ) { + Py_DECREF( args ); + return EXPP_ReturnIntError( PyExc_TypeError, + "expected four floats" ); } - if( !status ) /* parsing args failed */ - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected four floats" ) ); - if( xmin > 1.0 || xmin < 0.0 || ymin > 1.0 || ymin < 0.0 || - xmax > 1.0 || xmax < 0.0 || ymax > 1.0 || ymax < 0.0 ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "all values must be between 0.0 and 1.0" ) ); - self->renderContext->border.xmin = xmin; - self->renderContext->border.ymin = ymin; - self->renderContext->border.xmax = xmax; - self->renderContext->border.ymax = ymax; + self->renderContext->border.xmin = EXPP_ClampFloat( xmin, 0.0, 1.0 ); + self->renderContext->border.xmax = EXPP_ClampFloat( xmax, 0.0, 1.0 ); + self->renderContext->border.ymin = EXPP_ClampFloat( ymin, 0.0, 1.0 ); + self->renderContext->border.ymax = EXPP_ClampFloat( ymax, 0.0, 1.0 ); EXPP_allqueue( REDRAWVIEWCAM, 1 ); - return EXPP_incr_ret( Py_None ); + Py_DECREF( args ); + return 0; +} + +static PyObject *RenderData_getBorder( BPy_RenderData * self ) +{ + return Py_BuildValue( "[ffff]", + self->renderContext->border.xmin, + self->renderContext->border.ymin, + self->renderContext->border.xmax, + self->renderContext->border.ymax ); } -//------------------------------------RenderData.EnableGammaCorrection() PyObject *RenderData_EnableGammaCorrection( BPy_RenderData * self, PyObject * args ) { @@ -1441,7 +803,6 @@ PyObject *RenderData_EnableGammaCorrection( BPy_RenderData * self, &self->renderContext->mode ); } -//------------------------------------RenderData.GaussFilterSize() ------ PyObject *RenderData_GaussFilterSize( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeFloat( args, @@ -1449,78 +810,70 @@ PyObject *RenderData_GaussFilterSize( BPy_RenderData * self, PyObject * args ) 0.5f, 1.5f ); } -//------------------------------------RenderData.StartFrame() ----------- PyObject *RenderData_StartFrame( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeInt( args, &self->renderContext->sfra, 1, MAXFRAME ); } -//------------------------------------RenderData.CurrentFrame() --------- PyObject *RenderData_CurrentFrame( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeInt( args, &self->renderContext->cfra, 1, MAXFRAME ); } -//------------------------------------RenderData.EndFrame() ------------- PyObject *RenderData_EndFrame( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeInt( args, &self->renderContext->efra, 1, MAXFRAME ); } - //------------------------------------RenderData.ImageSizeX() ---------- PyObject *RenderData_ImageSizeX( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeShort( args, &self->renderContext->xsch, 4, 10000 ); } -//------------------------------------RenderData.ImageSizeY() ----------- PyObject *RenderData_ImageSizeY( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeShort( args, &self->renderContext->ysch, 4, 10000 ); } -//------------------------------------RenderData.AspectRatioX() --------- PyObject *RenderData_AspectRatioX( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeShort( args, &self->renderContext->xasp, 1, 200 ); } -//------------------------------------RenderData.AspectRatioY() --------- PyObject *RenderData_AspectRatioY( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeShort( args, &self->renderContext->yasp, 1, 200 ); } -//------------------------------------RenderData.SetRenderer() ---------- -PyObject *RenderData_SetRenderer( BPy_RenderData * self, PyObject * args ) +static int RenderData_setRenderer( BPy_RenderData * self, PyObject * value ) { int type; - if( !PyArg_ParseTuple( args, "i", &type ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected constant INTERN or YAFRAY" ) ); + if( !PyInt_CheckExact( value ) ) + return EXPP_ReturnIntError( PyExc_TypeError, + "expected constant INTERNAL or YAFRAY" ); + type = PyInt_AsLong( value ); if( type == R_INTERN ) self->renderContext->renderer = R_INTERN; else if( type == R_YAFRAY ) self->renderContext->renderer = R_YAFRAY; else - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected INTERN or YAFRAY" ) ); + return EXPP_ReturnIntError( PyExc_ValueError, + "expected constant INTERNAL or YAFRAY" ); EXPP_allqueue( REDRAWBUTSSCENE, 0 ); - return EXPP_incr_ret( Py_None ); + return 0; } -//------------------------------------RenderData.EnableCropping() ------- -PyObject *RenderData_EnableCropping( BPy_RenderData * self, PyObject * args ) +PyObject *RenderData_EnableCropping( void ) { /* return M_Render_BitToggleInt( args, R_MOVIECROP, &self->renderContext->mode ); @@ -1529,64 +882,63 @@ PyObject *RenderData_EnableCropping( BPy_RenderData * self, PyObject * args ) Py_RETURN_NONE; } -//------------------------------------RenderData.SetImageType() --------- -PyObject *RenderData_SetImageType( BPy_RenderData * self, PyObject * args ) + +static int RenderData_setImageType( BPy_RenderData *self, PyObject *value ) { int type; - if( !PyArg_ParseTuple( args, "i", &type ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected constant" ) ); - - //this same logic and more is in buttons_scene.c imegetype_pup code - //but only in generating strings for the popup menu, no way to reuse that :( - - if( type == R_AVIRAW ) - self->renderContext->imtype = R_AVIRAW; - else if( type == R_AVIJPEG ) - self->renderContext->imtype = R_AVIJPEG; + if( !PyInt_CheckExact( value ) ) + return EXPP_ReturnIntError( PyExc_TypeError, + "expected int constant" ); + + type = PyInt_AS_LONG( value ); + + /* + * this same logic and more is in buttons_scene.c imagetype_pup code but + * only in generating strings for the popup menu, no way to reuse that :( + */ + + switch( type ) { + case R_AVIRAW : + case R_AVIJPEG : + case R_TARGA : + case R_RAWTGA : + case R_RADHDR : + case R_PNG : + case R_BMP : + case R_JPEG90 : + case R_HAMX : + case R_IRIS : + case R_IRIZ : + case R_FTYPE : + case R_TIFF : + case R_CINEON : + case R_DPX : #ifdef _WIN32 - else if( type == R_AVICODEC ) - self->renderContext->imtype = R_AVICODEC; + case R_AVICODEC : #endif - - else if( type == R_QUICKTIME && G.have_quicktime ) - self->renderContext->imtype = R_QUICKTIME; - else if( type == R_TARGA ) - self->renderContext->imtype = R_TARGA; - else if( type == R_RAWTGA ) - self->renderContext->imtype = R_RAWTGA; - else if( type == R_RADHDR ) - self->renderContext->imtype = R_RADHDR; - else if( type == R_PNG ) - self->renderContext->imtype = R_PNG; - else if( type == R_BMP ) - self->renderContext->imtype = R_BMP; - else if( type == R_JPEG90 ) - self->renderContext->imtype = R_JPEG90; - else if( type == R_HAMX ) - self->renderContext->imtype = R_HAMX; - else if( type == R_IRIS ) - self->renderContext->imtype = R_IRIS; - else if( type == R_IRIZ ) - self->renderContext->imtype = R_IRIZ; - else if( type == R_FTYPE ) - self->renderContext->imtype = R_FTYPE; - #ifdef WITH_OPENEXR - else if( type == R_OPENEXR) - self->renderContext->imtype = R_OPENEXR; + case R_OPENEXR : #endif - - else - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "unknown constant - see modules dict for help" ) ); +#ifdef WITH_FFMPEG + case R_FFMPEG : +#endif + self->renderContext->imtype = type; + break; + case R_QUICKTIME : + if( G.have_quicktime ) { + self->renderContext->imtype = R_QUICKTIME; + break; + } + default: + return EXPP_ReturnIntError( PyExc_ValueError, + "unknown constant - see modules dict for help" ); + } EXPP_allqueue( REDRAWBUTSSCENE, 0 ); - return EXPP_incr_ret( Py_None ); + return 0; } -//------------------------------------RenderData.Quality() -------------- PyObject *RenderData_Quality( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeShort( args, @@ -1594,7 +946,6 @@ PyObject *RenderData_Quality( BPy_RenderData * self, PyObject * args ) 10, 100 ); } -//------------------------------------RenderData.FramesPerSec() --------- PyObject *RenderData_FramesPerSec( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeShort( args, @@ -1602,7 +953,6 @@ PyObject *RenderData_FramesPerSec( BPy_RenderData * self, PyObject * args ) 120 ); } -//------------------------------------RenderData.EnableGrayscale() ------ PyObject *RenderData_EnableGrayscale( BPy_RenderData * self ) { self->renderContext->planes = R_PLANESBW; @@ -1611,7 +961,6 @@ PyObject *RenderData_EnableGrayscale( BPy_RenderData * self ) return EXPP_incr_ret( Py_None ); } -//------------------------------------RenderData.EnableRGBColor() ------- PyObject *RenderData_EnableRGBColor( BPy_RenderData * self ) { self->renderContext->planes = R_PLANES24; @@ -1620,7 +969,6 @@ PyObject *RenderData_EnableRGBColor( BPy_RenderData * self ) return EXPP_incr_ret( Py_None ); } -//------------------------------------RenderData.EnableRGBAColor() ------ PyObject *RenderData_EnableRGBAColor( BPy_RenderData * self ) { self->renderContext->planes = R_PLANES32; @@ -1629,7 +977,6 @@ PyObject *RenderData_EnableRGBAColor( BPy_RenderData * self ) return EXPP_incr_ret( Py_None ); } -//------------------------------------RenderData.SizePreset() ----------- PyObject *RenderData_SizePreset( BPy_RenderData * self, PyObject * args ) { int type; @@ -1702,7 +1049,6 @@ PyObject *RenderData_SizePreset( BPy_RenderData * self, PyObject * args ) return EXPP_incr_ret( Py_None ); } -//------------------------------------RenderData.EnableUnifiedRenderer() PyObject *RenderData_EnableUnifiedRenderer( BPy_RenderData * self, PyObject * args ) { @@ -1710,7 +1056,6 @@ PyObject *RenderData_EnableUnifiedRenderer( BPy_RenderData * self, &self->renderContext->mode ); } -//------------------------------------RenderData.SetYafrayGIQuality() --- PyObject *RenderData_SetYafrayGIQuality( BPy_RenderData * self, PyObject * args ) { @@ -1732,7 +1077,6 @@ PyObject *RenderData_SetYafrayGIQuality( BPy_RenderData * self, return EXPP_incr_ret( Py_None ); } -//------------------------------------RenderData.SetYafrayGIMethod() ---- PyObject *RenderData_SetYafrayGIMethod( BPy_RenderData * self, PyObject * args ) { @@ -1752,7 +1096,6 @@ PyObject *RenderData_SetYafrayGIMethod( BPy_RenderData * self, return EXPP_incr_ret( Py_None ); } -//------------------------------------RenderData.YafrayGIPower() -------- PyObject *RenderData_YafrayGIPower( BPy_RenderData * self, PyObject * args ) { if( self->renderContext->GImethod > 0 ) { @@ -1765,7 +1108,6 @@ PyObject *RenderData_YafrayGIPower( BPy_RenderData * self, PyObject * args ) "YafrayGIMethod must be set to 'SKYDOME' or 'FULL'" ) ); } -//------------------------------------RenderData.YafrayGIDepth() -------- PyObject *RenderData_YafrayGIDepth( BPy_RenderData * self, PyObject * args ) { if( self->renderContext->GImethod == 2 ) { @@ -1777,7 +1119,6 @@ PyObject *RenderData_YafrayGIDepth( BPy_RenderData * self, PyObject * args ) "YafrayGIMethod must be set to 'FULL'" ) ); } -//------------------------------------RenderData.afrayGICDepth() -------- PyObject *RenderData_YafrayGICDepth( BPy_RenderData * self, PyObject * args ) { if( self->renderContext->GImethod == 2 ) { @@ -1789,7 +1130,6 @@ PyObject *RenderData_YafrayGICDepth( BPy_RenderData * self, PyObject * args ) "YafrayGIMethod must be set to 'FULL'" ) ); } -//------------------------------------RenderData.EnableYafrayGICache() -- PyObject *RenderData_EnableYafrayGICache( BPy_RenderData * self, PyObject * args ) { @@ -1802,7 +1142,6 @@ PyObject *RenderData_EnableYafrayGICache( BPy_RenderData * self, "YafrayGIMethod must be set to 'FULL'" ) ); } -//------------------------------------RenderData.EnableYafrayGIPhotons() PyObject *RenderData_EnableYafrayGIPhotons( BPy_RenderData * self, PyObject * args ) { @@ -1815,7 +1154,6 @@ PyObject *RenderData_EnableYafrayGIPhotons( BPy_RenderData * self, "YafrayGIMethod must be set to 'FULL'" ) ); } -//------------------------------------RenderData.YafrayGIPhotonCount() -- PyObject *RenderData_YafrayGIPhotonCount( BPy_RenderData * self, PyObject * args ) { @@ -1827,10 +1165,9 @@ PyObject *RenderData_YafrayGIPhotonCount( BPy_RenderData * self, 10000000 ); } else return ( EXPP_ReturnPyObjError( PyExc_StandardError, - "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled\n" ) ); + "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) ); } -//------------------------------------RenderData.YafrayGIPhotonRadius() - PyObject *RenderData_YafrayGIPhotonRadius( BPy_RenderData * self, PyObject * args ) { @@ -1842,10 +1179,9 @@ PyObject *RenderData_YafrayGIPhotonRadius( BPy_RenderData * self, 100.0f ); } else return ( EXPP_ReturnPyObjError( PyExc_StandardError, - "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled\n" ) ); + "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) ); } -//------------------------------------RenderData.YafrayGIPhotonMixCount() PyObject *RenderData_YafrayGIPhotonMixCount( BPy_RenderData * self, PyObject * args ) { @@ -1856,10 +1192,9 @@ PyObject *RenderData_YafrayGIPhotonMixCount( BPy_RenderData * self, GImixphotons, 0, 1000 ); } else return ( EXPP_ReturnPyObjError( PyExc_StandardError, - "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled\n" ) ); + "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) ); } -//--------------------------RenderData.EnableYafrayGITunePhotons() ------ PyObject *RenderData_EnableYafrayGITunePhotons( BPy_RenderData * self, PyObject * args ) { @@ -1873,7 +1208,6 @@ PyObject *RenderData_EnableYafrayGITunePhotons( BPy_RenderData * self, "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) ); } -//------------------------------------RenderData.YafrayGIShadowQuality() PyObject *RenderData_YafrayGIShadowQuality( BPy_RenderData * self, PyObject * args ) { @@ -1885,10 +1219,9 @@ PyObject *RenderData_YafrayGIShadowQuality( BPy_RenderData * self, 1.0f ); } else return ( EXPP_ReturnPyObjError( PyExc_StandardError, - "YafrayGIMethod must be set to 'FULL' and GICache must be enabled\n" ) ); + "YafrayGIMethod must be set to 'FULL' and GICache must be enabled" ) ); } -//------------------------------------RenderData.YafrayGIPixelsPerSample() PyObject *RenderData_YafrayGIPixelsPerSample( BPy_RenderData * self, PyObject * args ) { @@ -1899,10 +1232,9 @@ PyObject *RenderData_YafrayGIPixelsPerSample( BPy_RenderData * self, GIpixelspersample, 1, 50 ); } else return ( EXPP_ReturnPyObjError( PyExc_StandardError, - "YafrayGIMethod must be set to 'FULL' and GICache must be enabled\n" ) ); + "YafrayGIMethod must be set to 'FULL' and GICache must be enabled" ) ); } -//------------------------------------RenderData.YafrayGIRefinement() ---- PyObject *RenderData_YafrayGIRefinement( BPy_RenderData * self, PyObject * args ) { @@ -1914,10 +1246,9 @@ PyObject *RenderData_YafrayGIRefinement( BPy_RenderData * self, 1.0f ); } else return ( EXPP_ReturnPyObjError( PyExc_StandardError, - "YafrayGIMethod must be set to 'FULL' and GICache must be enabled\n" ) ); + "YafrayGIMethod must be set to 'FULL' and GICache must be enabled" ) ); } -//------------------------------------RenderData.YafrayRayBias() --------- PyObject *RenderData_YafrayRayBias( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeFloat( args, @@ -1925,7 +1256,6 @@ PyObject *RenderData_YafrayRayBias( BPy_RenderData * self, PyObject * args ) 0.0f, 10.0f ); } -//------------------------------------RenderData.YafrayRayDepth() -------- PyObject *RenderData_YafrayRayDepth( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeInt( args, @@ -1933,7 +1263,6 @@ PyObject *RenderData_YafrayRayDepth( BPy_RenderData * self, PyObject * args ) 1, 80 ); } -//------------------------------------RenderData.YafrayGamma() ----------- PyObject *RenderData_YafrayGamma( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeFloat( args, @@ -1941,7 +1270,6 @@ PyObject *RenderData_YafrayGamma( BPy_RenderData * self, PyObject * args ) 0.001f, 5.0f ); } -//------------------------------------RenderData.YafrayExposure() -------- PyObject *RenderData_YafrayExposure( BPy_RenderData * self, PyObject * args ) { return M_Render_GetSetAttributeFloat( args, @@ -1949,7 +1277,6 @@ PyObject *RenderData_YafrayExposure( BPy_RenderData * self, PyObject * args ) YF_exposure, 0.0f, 10.0f ); } -//------------------------------------RenderData.YafrayProcessorCount() -- PyObject *RenderData_YafrayProcessorCount( BPy_RenderData * self, PyObject * args ) { @@ -1958,28 +1285,24 @@ PyObject *RenderData_YafrayProcessorCount( BPy_RenderData * self, 1, 8 ); } -//------------------------------------RenderData.EnableGameFrameStretch() ----------------------------------------------------------- PyObject *RenderData_EnableGameFrameStretch( BPy_RenderData * self ) { self->scene->framing.type = SCE_GAMEFRAMING_SCALE; return EXPP_incr_ret( Py_None ); } -//------------------------------------RenderData.EnableGameFrameExpose() - PyObject *RenderData_EnableGameFrameExpose( BPy_RenderData * self ) { self->scene->framing.type = SCE_GAMEFRAMING_EXTEND; return EXPP_incr_ret( Py_None ); } -//------------------------------------RenderData.EnableGameFrameBars() --- PyObject *RenderData_EnableGameFrameBars( BPy_RenderData * self ) { self->scene->framing.type = SCE_GAMEFRAMING_BARS; return EXPP_incr_ret( Py_None ); } -//------------------------------------RenderData.SetGameFrameColor() ----- PyObject *RenderData_SetGameFrameColor( BPy_RenderData * self, PyObject * args ) { @@ -2008,17 +1331,15 @@ PyObject *RenderData_SetGameFrameColor( BPy_RenderData * self, return EXPP_incr_ret( Py_None ); } -//------------------------------------RenderData.GetGameFrameColor() ----- PyObject *RenderData_GetGameFrameColor( BPy_RenderData * self ) { char rgb[24]; - sprintf( rgb, "[%.3f,%.3f,%.3f]\n", self->scene->framing.col[0], + sprintf( rgb, "[%.3f,%.3f,%.3f]", self->scene->framing.col[0], self->scene->framing.col[1], self->scene->framing.col[2] ); return PyString_FromString( rgb ); } -//------------------------------------RenderData.GammaLevel() ------------ PyObject *RenderData_GammaLevel( BPy_RenderData * self, PyObject * args ) { if( self->renderContext->mode & R_UNIFIED ) { @@ -2030,7 +1351,6 @@ PyObject *RenderData_GammaLevel( BPy_RenderData * self, PyObject * args ) "Unified Render must be enabled" ) ); } -//------------------------------------RenderData.PostProcessAdd() -------- PyObject *RenderData_PostProcessAdd( BPy_RenderData * self, PyObject * args ) { if( self->renderContext->mode & R_UNIFIED ) { @@ -2042,7 +1362,6 @@ PyObject *RenderData_PostProcessAdd( BPy_RenderData * self, PyObject * args ) "Unified Render must be enabled" ) ); } -//------------------------------------RenderData.PostProcessMultiply() --- PyObject *RenderData_PostProcessMultiply( BPy_RenderData * self, PyObject * args ) { @@ -2055,7 +1374,6 @@ PyObject *RenderData_PostProcessMultiply( BPy_RenderData * self, "Unified Render must be enabled" ) ); } -//------------------------------------RenderData.PostProcessGamma() ------ PyObject *RenderData_PostProcessGamma( BPy_RenderData * self, PyObject * args ) { if( self->renderContext->mode & R_UNIFIED ) { @@ -2067,32 +1385,33 @@ PyObject *RenderData_PostProcessGamma( BPy_RenderData * self, PyObject * args ) "Unified Render must be enabled" ) ); } -//------------------------------------RenderData.SGIMaxsize() ------------ +#ifdef __sgi PyObject *RenderData_SGIMaxsize( BPy_RenderData * self, PyObject * args ) { -#ifdef __sgi return M_Render_GetSetAttributeShort( args, &self->renderContext->maximsize, 0, 500 ); -#else - return ( EXPP_ReturnPyObjError( PyExc_StandardError, - "SGI is not defined on this machine" ) ); -#endif } -//------------------------------------RenderData.EnableSGICosmo() -------- -PyObject *RenderData_EnableSGICosmo( BPy_RenderData * self, PyObject * args ) +PyObject *RenderData_EnableSGICosmo( BPy_RenderData *self, PyObject *args ) { -#ifdef __sgi return M_Render_BitToggleInt( args, R_COSMO, &self->renderContext->mode ); +} #else - return ( EXPP_ReturnPyObjError( PyExc_StandardError, - "SGI is not defined on this machine" ) ); -#endif +PyObject *RenderData_SGIMaxsize( void ) +{ + return EXPP_ReturnPyObjError( PyExc_StandardError, + "SGI is not defined on this machine" ); } -//------------------------------------RenderData.OldMapValue() ----------- +PyObject *RenderData_EnableSGICosmo( void ) +{ + return EXPP_ReturnPyObjError( PyExc_StandardError, + "SGI is not defined on this machine" ); +} +#endif + PyObject *RenderData_OldMapValue( BPy_RenderData * self, PyObject * args ) { PyObject *tmp = M_Render_GetSetAttributeInt(args, @@ -2102,7 +1421,6 @@ PyObject *RenderData_OldMapValue( BPy_RenderData * self, PyObject * args ) return tmp; } -//------------------------------------RenderData.NewMapValue() ----------- PyObject *RenderData_NewMapValue( BPy_RenderData * self, PyObject * args ) { PyObject *tmp = M_Render_GetSetAttributeInt(args, @@ -2112,45 +1430,1530 @@ PyObject *RenderData_NewMapValue( BPy_RenderData * self, PyObject * args ) return tmp; } -//------------------------------------RenderData.getTimeCode() ----------- -PyObject *RenderData_getTimeCode( BPy_RenderData * self){ - PyObject *ret = NULL; +static PyObject *RenderData_getTimeCode( BPy_RenderData * self) { char tc[12]; - char h[3],m[3],s[3],f[3]; - int hi,mi,si,fi,hold,fps,cfa; + int h, m, s, fps, cfa; fps = self->renderContext->frs_sec; cfa = self->renderContext->cfra-1; - fi = cfa % fps; - - hi = (cfa) / (fps*60*60); - hold = (cfa) % (fps*60*60); - mi = hold / (fps*60); - hold = hold % (fps*60); - si = hold / fps; - - if(hi > 99){ - ret = PyString_FromString("Time Greater than 99 Hours!"); - } - else{ - if(hi > 9) - sprintf(h,"%d",hi); - else - sprintf(h,"0%d",hi); - if(mi > 9) - sprintf(m,"%d",mi); - else - sprintf(m,"0%d",mi); - if(si > 9) - sprintf(s,"%d",si); - else - sprintf(s,"0%d",si); - if(fi > 9) - sprintf(f,"%d",fi); - else - sprintf(f,"0%d",fi); - sprintf(tc,"%s:%s:%s:%s",h,m,s,f); - ret = PyString_FromString(tc); - } - return ret; + s = cfa / fps; + m = s / 60; + h = m / 60; + if( h > 99 ) + return PyString_FromString("Time Greater than 99 Hours!"); + + sprintf( tc, "%02d:%02d:%02d:%02d", h%60, m%60, s%60, cfa%fps); + return PyString_FromString(tc); } + +/***************************************************************************/ +/* generic handlers for getting/setting attributes */ +/***************************************************************************/ + +/* + * get floating point attributes + */ + +#if 0 +static PyObject *RenderData_getFloatAttr( BPy_RenderData *self, void *type ) +{ + float param; + + switch( (int)type ) { + case EXPP_RENDER_ATTR_GAUSS: + param = self->renderContext->gauss; + break; + case EXPP_RENDER_ATTR_BLURFAC: + param = self->renderContext->blurfac; + break; + case EXPP_RENDER_ATTR_POSTADD: + param = self->renderContext->postadd; + break; + case EXPP_RENDER_ATTR_POSTGAMMA: + param = self->renderContext->postgamma; + break; + case EXPP_RENDER_ATTR_POSTMUL: + param = self->renderContext->postmul; + break; + case EXPP_RENDER_ATTR_POSTHUE: + param = self->renderContext->posthue; + break; + case EXPP_RENDER_ATTR_POSTSAT: + param = self->renderContext->postsat; + break; + case EXPP_RENDER_ATTR_YF_EXPOSURE : + param = self->renderContext->YF_exposure; + break; + case EXPP_RENDER_ATTR_YF_GAMMA : + param = self->renderContext->YF_gamma; + break; + case EXPP_RENDER_ATTR_YF_GIPHOTONRADIUS : + param = self->renderContext->GIphotonradius; + break; + case EXPP_RENDER_ATTR_YF_GIPOWER: + param = self->renderContext->GIpower; + break; + case EXPP_RENDER_ATTR_YF_GIREFINE: + param = self->renderContext->GIrefinement; + break; + case EXPP_RENDER_ATTR_YF_GISHADOWQUAL: + param = self->renderContext->GIshadowquality; + break; + case EXPP_RENDER_ATTR_YF_RAYBIAS: + param = self->renderContext->YF_raybias; + break; + default: + { + char errstr[1024]; + sprintf (errstr, "undefined type in %s",__FUNCTION__); + return EXPP_ReturnPyObjError( PyExc_RuntimeError, errstr ); + } + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "undefined type constant in RenderData_getFloatAttr" ); + } + return PyFloat_FromDouble( param ); +} + +/* + * set floating point attributes which require clamping + */ + +static int RenderData_setFloatAttrClamp( BPy_RenderData *self, PyObject *value, + void *type ) +{ + float *param; + float min, max; + + switch( (int)type ) { + case EXPP_RENDER_ATTR_GAUSS: + min = 0.5f; + max = 1.5f; + param = &self->renderContext->gauss; + break; + case EXPP_RENDER_ATTR_BLURFAC: + min = 0.01f; + max = 5.0f; + param = &self->renderContext->blurfac; + break; + case EXPP_RENDER_ATTR_POSTADD: + min = -1.0f; + max = 1.0f; + param = &self->renderContext->postadd; + break; + case EXPP_RENDER_ATTR_POSTGAMMA: + min = 0.1f; + max = 4.0f; + param = &self->renderContext->postgamma; + break; + case EXPP_RENDER_ATTR_POSTMUL: + min = 0.01f; + max = 4.0f; + param = &self->renderContext->postmul; + break; + case EXPP_RENDER_ATTR_POSTHUE: + min = -0.5f; + max = 0.5f; + param = &self->renderContext->posthue; + break; + case EXPP_RENDER_ATTR_POSTSAT: + min = 0.0f; + max = 4.0f; + param = &self->renderContext->postsat; + break; + case EXPP_RENDER_ATTR_YF_EXPOSURE : + min = 0.0f; + max = 10.0f; + param = &self->renderContext->YF_exposure; + break; + case EXPP_RENDER_ATTR_YF_GAMMA : + min = 0.001f; + max = 5.0f; + param = &self->renderContext->YF_gamma; + break; + case EXPP_RENDER_ATTR_YF_GIPHOTONRADIUS : + min = 0.00001f; + max = 100.0f; + param = &self->renderContext->GIphotonradius; + break; + case EXPP_RENDER_ATTR_YF_GIPOWER: + min = 0.01f; + max = 100.0f; + param = &self->renderContext->GIpower; + break; + case EXPP_RENDER_ATTR_YF_GIREFINE: + min = 0.001f; + max = 1.0f; + param = &self->renderContext->GIrefinement; + break; + case EXPP_RENDER_ATTR_YF_GISHADOWQUAL: + min = 0.01f; + max = 1.0f; + param = &self->renderContext->GIshadowquality; + break; + case EXPP_RENDER_ATTR_YF_RAYBIAS: + min = 0.0f; + max = 10.0f; + param = &self->renderContext->YF_raybias; + break; + default: + return EXPP_ReturnIntError( PyExc_RuntimeError, + "undefined type constant in RenderData_setFloatAttrClamp" ); + } + return EXPP_setFloatClamped( value, param, min, max ); +} +#endif + +/* + * get integer attributes + */ + +static PyObject *RenderData_getIValueAttr( BPy_RenderData *self, void *type ) +{ + long param; + + switch( (int)type ) { + case EXPP_RENDER_ATTR_XPARTS: + param = (long)self->renderContext->xparts; + break; + case EXPP_RENDER_ATTR_YPARTS: + param = (long)self->renderContext->yparts; + break; + case EXPP_RENDER_ATTR_ASPECTX: + param = (long)self->renderContext->xasp; + break; + case EXPP_RENDER_ATTR_ASPECTY: + param = (long)self->renderContext->yasp; + break; + case EXPP_RENDER_ATTR_CFRAME: + param = (long)self->renderContext->cfra; + break; + case EXPP_RENDER_ATTR_EFRAME: + param = (long)self->renderContext->efra; + break; + case EXPP_RENDER_ATTR_SFRAME: + param = (long)self->renderContext->sfra; + break; + case EXPP_RENDER_ATTR_FPS: + param = self->renderContext->frs_sec; + break; + case EXPP_RENDER_ATTR_SIZEX: + param = self->renderContext->xsch; + break; + case EXPP_RENDER_ATTR_SIZEY: + param = self->renderContext->ysch; + break; + +#if 0 + case EXPP_RENDER_ATTR_ANTISHIFT: + param = self->renderContext->same_mat_redux; + break; + case EXPP_RENDER_ATTR_EDGEINT: + param = self->renderContext->edgeint; + break; + case EXPP_RENDER_ATTR_QUALITY: + param = self->renderContext->quality; + break; + case EXPP_RENDER_ATTR_YF_GIDEPTH: + param = self->renderContext->GIdepth; + break; + case EXPP_RENDER_ATTR_YF_GICDEPTH: + param = self->renderContext->GIcausdepth; + break; + case EXPP_RENDER_ATTR_YF_GIPHOTONCOUNT: + param = self->renderContext->GIphotoncount; + break; + case EXPP_RENDER_ATTR_YF_GIPHOTONMIXCOUNT: + param = self->renderContext->GImixphotons; + break; + case EXPP_RENDER_ATTR_YF_GIPIXPERSAMPLE: + param = self->renderContext->GIpixelspersample; + break; + case EXPP_RENDER_ATTR_YF_PROCCOUNT: + param = self->renderContext->YF_numprocs; + break; + case EXPP_RENDER_ATTR_YF_RAYDEPTH: + param = self->renderContext->YF_raydepth; + break; + case EXPP_RENDER_ATTR_YF_GIMETHOD: + param = self->renderContext->GImethod; + break; + case EXPP_RENDER_ATTR_YF_GIQUALITY: + param = self->renderContext->GIquality; + break; +#endif + default: + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "undefined type constant in RenderData_setIValueAttrClamp" ); + } + return PyInt_FromLong( param ); +} + +/* + * set integer attributes which require clamping + */ + +static int RenderData_setIValueAttrClamp( BPy_RenderData *self, PyObject *value, + void *type ) +{ + void *param; + int min, max, size; + + switch( (int)type ) { + case EXPP_RENDER_ATTR_XPARTS: + min = 2; + max = 512; + size = 'h'; + param = &self->renderContext->xparts; + break; + case EXPP_RENDER_ATTR_YPARTS: + min = 2; + max = 512; + size = 'h'; + param = &self->renderContext->yparts; + break; + case EXPP_RENDER_ATTR_ASPECTX: + min = 1; + max = 200; + size = 'h'; + param = &self->renderContext->xasp; + break; + case EXPP_RENDER_ATTR_ASPECTY: + min = 1; + max = 200; + size = 'h'; + param = &self->renderContext->yasp; + break; + case EXPP_RENDER_ATTR_CFRAME: + min = 1; + max = MAXFRAME; + size = 'h'; + param = &self->renderContext->cfra; + break; + case EXPP_RENDER_ATTR_EFRAME: + min = 1; + max = MAXFRAME; + size = 'h'; + param = &self->renderContext->efra; + break; + case EXPP_RENDER_ATTR_SFRAME: + min = 1; + max = MAXFRAME; + size = 'h'; + param = &self->renderContext->sfra; + break; + case EXPP_RENDER_ATTR_FPS: + min = 1; + max = 120; + size = 'h'; + param = &self->renderContext->frs_sec; + break; + case EXPP_RENDER_ATTR_SIZEX: + min = 4; + max = 10000; + size = 'h'; + param = &self->renderContext->xsch; + break; + case EXPP_RENDER_ATTR_SIZEY: + min = 4; + max = 10000; + size = 'h'; + param = &self->renderContext->ysch; + break; + +#if 0 + case EXPP_RENDER_ATTR_ANTISHIFT: + min = 0; + max = 255; + size = 'h'; + param = &self->renderContext->same_mat_redux; + break; + case EXPP_RENDER_ATTR_EDGEINT: + min = 0; + max = 255; + size = 'h'; + param = &self->renderContext->edgeint; + break; + case EXPP_RENDER_ATTR_QUALITY: + min = 10; + max = 100; + size = 'h'; + param = &self->renderContext->quality; + break; + case EXPP_RENDER_ATTR_YF_GIDEPTH: + min = 1; + max = 100; + size = 'i'; + param = &self->renderContext->GIdepth; + break; + case EXPP_RENDER_ATTR_YF_GICDEPTH: + min = 1; + max = 100; + size = 'i'; + param = &self->renderContext->GIcausdepth; + break; + case EXPP_RENDER_ATTR_YF_GIPHOTONCOUNT: + min = 0; + max = 10000000; + size = 'i'; + param = &self->renderContext->GIphotoncount; + break; + case EXPP_RENDER_ATTR_YF_GIPHOTONMIXCOUNT: + min = 0; + max = 1000; + size = 'i'; + param = &self->renderContext->GImixphotons; + break; + case EXPP_RENDER_ATTR_YF_GIPIXPERSAMPLE: + min = 1; + max = 50; + size = 'i'; + param = &self->renderContext->GIpixelspersample; + break; + case EXPP_RENDER_ATTR_YF_PROCCOUNT: + min = 1; + max = 8; + size = 'i'; + param = &self->renderContext->YF_numprocs; + break; + case EXPP_RENDER_ATTR_YF_RAYDEPTH: + min = 1; + max = 80; + size = 'i'; + param = &self->renderContext->YF_raydepth; + break; +#endif + default: + return EXPP_ReturnIntError( PyExc_RuntimeError, + "undefined type constant in RenderData_setIValueAttrClamp" ); + } + return EXPP_setIValueClamped( value, param, min, max, size ); +} + +/***************************************************************************/ +/* handlers for other getting/setting attributes */ +/***************************************************************************/ + +static PyObject *RenderData_getModeBit( BPy_RenderData *self, void* type ) +{ + return EXPP_getBitfield( &self->renderContext->mode, + (int)type, 'i' ); +} + +static int RenderData_setModeBit( BPy_RenderData* self, PyObject *value, + void* type ) +{ + return EXPP_setBitfield( value, &self->renderContext->mode, + (int)type, 'i' ); +} + +#define MODE_MASK ( R_OSA | R_SHADOW | R_GAMMA | R_ENVMAP | R_EDGE | \ + R_FIELDS | R_FIELDSTILL | R_RADIO | R_BORDER | R_PANORAMA | R_CROP | \ + R_ODDFIELD | R_MBLUR | R_UNIFIED | R_RAYTRACE | R_THREADS ) + +static PyObject *RenderData_getMode( BPy_RenderData *self ) +{ + return PyInt_FromLong( (long)(self->renderContext->mode & MODE_MASK) ); +} + +static int RenderData_setMode( BPy_RenderData* self, PyObject *arg ) +{ + int value; + + if( !PyInt_CheckExact( arg ) ) + return EXPP_ReturnIntError( PyExc_TypeError, + "expected int argument" ); + + value = PyInt_AsLong( arg ); + if( value & ~MODE_MASK ) + return EXPP_ReturnIntError( PyExc_ValueError, + "unexpected bits set in argument" ); + + self->renderContext->mode = (short)value; + EXPP_allqueue( REDRAWBUTSSCENE, 0 ); + + return 0; +} + +static PyObject *RenderData_getSceModeBits( BPy_RenderData *self, void* type ) +{ + return EXPP_getBitfield( &self->renderContext->scemode, (int)type, 'h' ); +} + +static int RenderData_setSceModeBits( BPy_RenderData* self, PyObject *value, + void* type ) +{ + return EXPP_setBitfield( value, &self->renderContext->scemode, + (int)type, 'h' ); +} + +static PyObject *RenderData_getSceMode( BPy_RenderData *self ) +{ + return PyInt_FromLong ( (long)self->renderContext->scemode ); +} + +static int RenderData_setSceMode( BPy_RenderData* self, PyObject *arg ) +{ + int value; + + if( !PyInt_CheckExact( arg ) ) + return EXPP_ReturnIntError( PyExc_TypeError, + "expected int argument" ); + + value = PyInt_AsLong( arg ); + if( value & ~( R_EXTENSION | R_DOSEQ ) ) + return EXPP_ReturnIntError( PyExc_ValueError, + "unexpected bits set in argument" ); + + self->renderContext->scemode = (short)value; + EXPP_allqueue( REDRAWBUTSSCENE, 0 ); + + return 0; +} + +static PyObject *RenderData_getFramingType( BPy_RenderData *self ) +{ + return PyInt_FromLong( (long)self->scene->framing.type ); +} + +static int RenderData_setFramingType( BPy_RenderData *self, PyObject *value ) +{ + return EXPP_setIValueRange( value, &self->scene->framing.type, + SCE_GAMEFRAMING_BARS, SCE_GAMEFRAMING_SCALE, 'b' ); +} + +static PyObject *RenderData_getEdgeColor( BPy_RenderData * self ) +{ + return Py_BuildValue( "[fff]", self->renderContext->edgeR, + self->renderContext->edgeG, self->renderContext->edgeB ); +} + +static int RenderData_setEdgeColor( BPy_RenderData * self, PyObject * args ) +{ + float red, green, blue; + + /* if we get a list, convert to a tuple; otherwise hope for the best */ + if( PyList_Check( args ) ) + args = PySequence_Tuple( args ); + else + Py_INCREF( args ); + + if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) ) { + Py_DECREF( args ); + return EXPP_ReturnIntError( PyExc_TypeError, "expected three floats" ); + } + Py_DECREF( args ); + + self->renderContext->edgeR = EXPP_ClampFloat( red, 0.0, 1.0 ); + self->renderContext->edgeG = EXPP_ClampFloat( green, 0.0, 1.0 ); + self->renderContext->edgeB = EXPP_ClampFloat( blue, 0.0, 1.0 ); + return 0; +} + +static PyObject *RenderData_getOSALevel( BPy_RenderData * self ) +{ + return PyInt_FromLong( (long)self->renderContext->osa ); +} + +static PyObject *RenderData_getRenderer( BPy_RenderData * self ) +{ + return PyInt_FromLong( (long)self->renderContext->renderer ); +} + +static PyObject *RenderData_getImageType( BPy_RenderData * self ) +{ + return PyInt_FromLong( (long) self->renderContext->imtype ); +} + +static int RenderData_setGameFrameColor( BPy_RenderData * self, + PyObject * args ) +{ + float red, green, blue; + + /* if we get a list, convert to a tuple; otherwise hope for the best */ + if( PyList_Check( args ) ) + args = PySequence_Tuple( args ); + else + Py_INCREF( args ); + + if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) ) { + Py_DECREF( args ); + return EXPP_ReturnIntError( PyExc_TypeError, "expected three floats" ); + } + Py_DECREF( args ); + + self->scene->framing.col[0] = EXPP_ClampFloat( red, 0.0, 1.0 ); + self->scene->framing.col[1] = EXPP_ClampFloat( green, 0.0, 1.0 ); + self->scene->framing.col[2] = EXPP_ClampFloat( blue, 0.0, 1.0 ); + return 0; +} + +static PyObject *RenderData_getGameFrameColor( BPy_RenderData * self ) +{ + return Py_BuildValue( "[fff]", self->scene->framing.col[0], + self->scene->framing.col[1], self->scene->framing.col[2] ); +} + +static PyObject *RenderData_getBackbuf( BPy_RenderData * self ) +{ + return EXPP_getBitfield( &self->renderContext->bufflag, + R_BACKBUF, 'h' ); +} + +static int RenderData_setBackbuf( BPy_RenderData* self, PyObject *value ) +{ + return EXPP_setBitfield( value, &self->renderContext->bufflag, + R_BACKBUF, 'h' ); +} + +static int RenderData_setImagePlanes( BPy_RenderData *self, PyObject *value ) +{ + int depth; + char *errstr = "expected int argument of 8, 24, or 32"; + + if( !PyInt_CheckExact( value ) ) + return EXPP_ReturnIntError( PyExc_TypeError, errstr ); + + depth = PyInt_AsLong( value ); + if( depth != 8 && depth != 24 && depth != 32 ) + return EXPP_ReturnIntError( PyExc_ValueError, errstr ); + + self->renderContext->planes = (short)depth; + + return 0; +} + +static PyObject *RenderData_getImagePlanes( BPy_RenderData * self ) +{ + return PyInt_FromLong( (long) self->renderContext->planes ); +} + +static int RenderData_setAlphaMode( BPy_RenderData *self, PyObject *value ) +{ + return EXPP_setIValueRange( value, &self->renderContext->alphamode, + R_ADDSKY, R_ALPHAKEY, 'h' ); +} + +static PyObject *RenderData_getAlphaMode( BPy_RenderData * self ) +{ + return PyInt_FromLong( (long) self->renderContext->alphamode ); +} + +static PyObject *RenderData_getDisplayMode( void ) +{ + return PyInt_FromLong( (long) G.displaymode ); +} + +static int RenderData_setDisplayMode( BPy_RenderData *self, + PyObject *value ) +{ + return EXPP_setIValueRange( value, &G.displaymode, + R_DISPLAYVIEW, R_DISPLAYWIN, 'h' ); +} + +static PyObject *RenderData_getRenderPath( BPy_RenderData * self ) +{ + return PyString_FromString( self->renderContext->pic ); +} + +static int RenderData_setRenderPath( BPy_RenderData * self, PyObject * value ) +{ + char *name; + + name = PyString_AsString( value ); + if( !name ) + return EXPP_ReturnIntError( PyExc_TypeError, + "expected a string" ); + + if( strlen( name ) >= sizeof(self->renderContext->pic) ) + return EXPP_ReturnIntError( PyExc_ValueError, + "render path is too long" ); + + strcpy( self->renderContext->pic, name ); + EXPP_allqueue( REDRAWBUTSSCENE, 0 ); + + return 0; +} + +PyObject *RenderData_getBackbufPath( BPy_RenderData * self ) +{ + return PyString_FromString( self->renderContext->backbuf ); +} + +static int RenderData_setBackbufPath( BPy_RenderData *self, PyObject *value ) +{ + char *name; + Image *ima; + + name = PyString_AsString( value ); + if( !name ) + return EXPP_ReturnIntError( PyExc_TypeError, "expected a string" ); + + if( strlen( name ) >= sizeof(self->renderContext->backbuf) ) + return EXPP_ReturnIntError( PyExc_ValueError, + "backbuf path is too long" ); + + strcpy( self->renderContext->backbuf, name ); + EXPP_allqueue( REDRAWBUTSSCENE, 0 ); + + ima = add_image( name ); + if( ima ) { + free_image_buffers( ima ); + ima->ok = 1; + } + + return 0; +} + +PyObject *RenderData_getFtypePath( BPy_RenderData * self ) +{ + return PyString_FromString( self->renderContext->ftype ); +} + +static int RenderData_setFtypePath( BPy_RenderData *self, PyObject *value ) +{ + char *name; + + name = PyString_AsString( value ); + if( !name ) + return EXPP_ReturnIntError( PyExc_TypeError, "expected a string" ); + + if( strlen( name ) >= sizeof(self->renderContext->ftype) ) + return EXPP_ReturnIntError( PyExc_ValueError, + "ftype path is too long" ); + + strcpy( self->renderContext->ftype, name ); + EXPP_allqueue( REDRAWBUTSSCENE, 0 ); + + return 0; +} + +PyObject *RenderData_getRenderWinSize( BPy_RenderData * self ) +{ + return PyInt_FromLong( (long) self->renderContext->size ); +} + +static int RenderData_setRenderWinSize( BPy_RenderData *self, PyObject *value ) +{ + int size; + char *errstr = "expected int argument of 25, 50, 75, or 100"; + + if( !PyInt_CheckExact( value ) ) + return EXPP_ReturnIntError( PyExc_TypeError, errstr ); + + size = PyInt_AsLong( value ); + if( size != 25 && size != 50 && size != 75 && size != 100 ) + return EXPP_ReturnIntError( PyExc_ValueError, errstr ); + + self->renderContext->size = (short)size; + EXPP_allqueue( REDRAWBUTSSCENE, 0 ); + + return 0; +} + +#if 0 +/* unedited methods :-( */ +edgeIntensity", ( PyCFunction ) RenderData_EdgeIntensity, +gammaLevel", ( PyCFunction ) RenderData_GammaLevel, METH_VARARGS, +gaussFilterSize", ( PyCFunction ) RenderData_GaussFilterSize, +motionBlurLevel", ( PyCFunction ) RenderData_MotionBlurLevel, +newMapValue", ( PyCFunction ) RenderData_NewMapValue, METH_VARARGS, +oldMapValue", ( PyCFunction ) RenderData_OldMapValue, METH_VARARGS, +postProcessAdd", ( PyCFunction ) RenderData_PostProcessAdd, +postProcessGamma", ( PyCFunction ) RenderData_PostProcessGamma, +postProcessMultiply", ( PyCFunction ) RenderData_PostProcessMultiply, +quality", ( PyCFunction ) RenderData_Quality, METH_VARARGS, +SGIMaxsize", ( PyCFunction ) RenderData_SGIMaxsize, METH_VARARGS, +sizePreset", ( PyCFunction ) RenderData_SizePreset, METH_VARARGS, + +setYafrayGIQuality", ( PyCFunction ) RenderData_SetYafrayGIQuality, +setYafrayGIMethod", ( PyCFunction ) RenderData_SetYafrayGIMethod, +yafrayExposure", ( PyCFunction ) RenderData_YafrayExposure, +yafrayGamma", ( PyCFunction ) RenderData_YafrayGamma, METH_VARARGS, +yafrayGICDepth", ( PyCFunction ) RenderData_YafrayGICDepth, +yafrayGIDepth", ( PyCFunction ) RenderData_YafrayGIDepth, +yafrayGIPhotonCount", ( PyCFunction ) RenderData_YafrayGIPhotonCount, +yafrayGIPhotonMixCount", +yafrayGIPhotonRadius", +yafrayGIPixelsPerSample", +yafrayGIPower", ( PyCFunction ) RenderData_YafrayGIPower, +yafrayGIRefinement", ( PyCFunction ) RenderData_YafrayGIRefinement, +yafrayGIShadowQuality", +yafrayProcessorCount", +yafrayRayBias", ( PyCFunction ) RenderData_YafrayRayBias, +yafrayRayDepth", ( PyCFunction ) RenderData_YafrayRayDepth, +enableYafrayGICache", ( PyCFunction ) RenderData_EnableYafrayGICache, +enableYafrayGIPhotons", +enableYafrayGITunePhotons", + +swapDispWinImagePrimary(image)" --> BIF_swap_render_rects() + +#endif + +/***************************************************************************/ +/* BPy_RenderData attribute def */ +/***************************************************************************/ +static PyGetSetDef BPy_RenderData_getseters[] = { + {"oversampling", + (getter)RenderData_getModeBit, (setter)RenderData_setModeBit, + "Oversampling (anti-aliasing) enabled", + (void *)R_OSA}, + {"shadow", + (getter)RenderData_getModeBit, (setter)RenderData_setModeBit, + "Shadow calculation enabled", + (void *)R_SHADOW}, + {"gammaCorrection", + (getter)RenderData_getModeBit, (setter)RenderData_setModeBit, + "Gamma correction enabled", + (void *)R_GAMMA}, +/* R_ORTHO unused */ + {"environmentMap", + (getter)RenderData_getModeBit, (setter)RenderData_setModeBit, + "Environment map rendering enabled", + (void *)R_ENVMAP}, + {"toonShading", + (getter)RenderData_getModeBit, (setter)RenderData_setModeBit, + "Toon edge shading enabled", + (void *)R_EDGE}, + {"fieldRendering", + (getter)RenderData_getModeBit, (setter)RenderData_setModeBit, + "Field rendering enabled", + (void *)R_FIELDS}, + {"fieldTimeDisable", + (getter)RenderData_getModeBit, (setter)RenderData_setModeBit, + "Time difference in field calculations disabled ('X' in UI)", + (void *)R_FIELDSTILL}, + {"radiosityRender", + (getter)RenderData_getModeBit, (setter)RenderData_setModeBit, + "Radiosity rendering enabled", + (void *)R_RADIO}, + {"borderRender", + (getter)RenderData_getModeBit, (setter)RenderData_setModeBit, + "Small cut-out rendering enabled", + (void *)R_BORDER}, + {"panorama", + (getter)RenderData_getModeBit, (setter)RenderData_setModeBit, + "Panorama rendering enabled", + (void *)R_PANORAMA}, + {"crop", + (getter)RenderData_getModeBit, (setter)RenderData_setModeBit, + "Crop image during border renders", + (void *)R_CROP}, +/* R_COSMO unsupported */ + {"oddFieldFirst", + (getter)RenderData_getModeBit, (setter)RenderData_setModeBit, + "Odd field first rendering enabled", + (void *)R_ODDFIELD}, + {"motionBlur", + (getter)RenderData_getModeBit, (setter)RenderData_setModeBit, + "Motion blur enabled", + (void *)R_MBLUR}, + {"unified", + (getter)RenderData_getModeBit, (setter)RenderData_setModeBit, + "Unified Renderer enabled", + (void *)R_UNIFIED}, + {"rayTracing", + (getter)RenderData_getModeBit, (setter)RenderData_setModeBit, + "Ray tracing enabled", + (void *)R_RAYTRACE}, +/* R_GAUSS unused */ +/* R_FBUF unused */ + {"threads", + (getter)RenderData_getModeBit, (setter)RenderData_setModeBit, + "Render in two threads enabled", + (void *)R_THREADS}, +/* R_SPEED unused */ + {"mode", + (getter)RenderData_getMode, (setter)RenderData_setMode, + "Mode bitfield", + NULL}, + + {"extensions", + (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits, + "Add extensions to output (when rendering animations) enabled", + (void *)R_EXTENSION}, + {"sequencer", + (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits, + "'Do Sequence' enabled", + (void *)R_DOSEQ}, + {"sceneMode", + (getter)RenderData_getSceMode, (setter)RenderData_setSceMode, + "Scene mode bitfield", + NULL}, +/* R_BG_RENDER unused */ + + {"gameFrame", + (getter)RenderData_getFramingType, (setter)RenderData_setFramingType, + "Game framing type", + NULL}, + + {"renderPath", + (getter)RenderData_getRenderPath, (setter)RenderData_setRenderPath, + "The path to output the rendered images to", + NULL}, + {"backbufPath", + (getter)RenderData_getBackbufPath, (setter)RenderData_setBackbufPath, + "Path to a background image (setting loads image)", + NULL}, + {"ftypePath", + (getter)RenderData_getFtypePath, (setter)RenderData_setFtypePath, + "The path to Ftype file", + NULL}, + {"edgeColor", + (getter)RenderData_getEdgeColor, (setter)RenderData_setEdgeColor, + "RGB color triplet for edges in Toon shading (unified renderer)", + NULL}, + {"OSALevel", + (getter)RenderData_getOSALevel, (setter)RenderData_setOSALevel, + "Oversampling (anti-aliasing) level", + NULL}, + {"renderwinSize", + (getter)RenderData_getRenderWinSize, (setter)RenderData_setRenderWinSize, + "Size of the rendering window (25, 50, 75, or 100)", + NULL}, + {"border", + (getter)RenderData_getBorder, (setter)RenderData_setBorder, + "The border for border rendering", + NULL}, + {"timeCode", + (getter)RenderData_getTimeCode, (setter)NULL, + "Get the current frame in HH:MM:SS:FF format", + NULL}, + {"renderer", + (getter)RenderData_getRenderer, (setter)RenderData_setRenderer, + "Rendering engine choice", + NULL}, + {"imageType", + (getter)RenderData_getImageType, (setter)RenderData_setImageType, + "File format for saving images", + NULL}, + {"gameFrameColor", + (getter)RenderData_getGameFrameColor,(setter)RenderData_setGameFrameColor, + "RGB color triplet for bars", + NULL}, + {"backbuf", + (getter)RenderData_getBackbuf, (setter)RenderData_setBackbuf, + "Backbuffer image enabled", + NULL}, + {"imagePlanes", + (getter)RenderData_getImagePlanes, (setter)RenderData_setImagePlanes, + "Image depth (8, 24, or 32 bits)", + NULL}, + {"alphaMode", + (getter)RenderData_getAlphaMode, (setter)RenderData_setAlphaMode, + "Setting for sky/background.", + NULL}, + {"displayMode", + (getter)RenderData_getDisplayMode, (setter)RenderData_setDisplayMode, + "Render output in separate window or 3D view", + NULL}, + + {"xParts", + (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp, + "Number of horizontal parts for image render", + (void *)EXPP_RENDER_ATTR_XPARTS}, + {"yParts", + (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp, + "Number of vertical parts for image render", + (void *)EXPP_RENDER_ATTR_YPARTS}, + {"aspectX", + (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp, + "Horizontal aspect ratio", + (void *)EXPP_RENDER_ATTR_ASPECTX}, + {"aspectY", + (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp, + "Vertical aspect ratio", + (void *)EXPP_RENDER_ATTR_ASPECTY}, + {"cFrame", + (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp, + "The current frame for rendering", + (void *)EXPP_RENDER_ATTR_CFRAME}, + {"sFrame", + (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp, + "Starting frame for rendering", + (void *)EXPP_RENDER_ATTR_SFRAME}, + {"eFrame", + (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp, + "Ending frame for rendering", + (void *)EXPP_RENDER_ATTR_EFRAME}, + {"fps", + (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp, + "Frames per second", + (void *)EXPP_RENDER_ATTR_FPS}, + {"sizeX", + (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp, + "Image width (in pixels)", + (void *)EXPP_RENDER_ATTR_SIZEX}, + {"sizeY", + (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp, + "Image height (in pixels)", + (void *)EXPP_RENDER_ATTR_SIZEY}, + + {NULL,NULL,NULL,NULL,NULL} +}; + +/***************************************************************************/ +/* BPy_RenderData method def */ +/***************************************************************************/ +static PyMethodDef BPy_RenderData_methods[] = { + {"render", ( PyCFunction ) RenderData_Render, METH_NOARGS, + "() - render the scene"}, + {"saveRenderedImage", (PyCFunction)RenderData_SaveRenderedImage, METH_VARARGS, + "(filename) - save an image generated by a call to render() (set output path first)"}, + {"renderAnim", ( PyCFunction ) RenderData_RenderAnim, METH_NOARGS, + "() - render a sequence from start frame to end frame"}, + {"play", ( PyCFunction ) RenderData_Play, METH_NOARGS, + "() - play animation of rendered images/avi (searches Pics: field)"}, + {"setRenderPath", ( PyCFunction ) RenderData_SetRenderPath, + METH_VARARGS, + "(string) - get/set the path to output the rendered images to"}, + {"getRenderPath", ( PyCFunction ) RenderData_getRenderPath, + METH_NOARGS, + "() - get the path to directory where rendered images will go"}, + {"setBackbufPath", ( PyCFunction ) RenderData_SetBackbufPath, + METH_VARARGS, + "(string) - get/set the path to a background image and load it"}, + {"getBackbufPath", ( PyCFunction ) RenderData_getBackbufPath, + METH_NOARGS, + "() - get the path to background image file"}, + {"enableBackbuf", ( PyCFunction ) RenderData_EnableBackbuf, + METH_VARARGS, + "(bool) - enable/disable the backbuf image"}, + {"enableThreads", ( PyCFunction ) RenderData_EnableThreads, + METH_VARARGS, + "(bool) - enable/disable threaded rendering"}, + {"setFtypePath", ( PyCFunction ) RenderData_SetFtypePath, METH_VARARGS, + "(string) - get/set the path to output the Ftype file"}, + {"getFtypePath", ( PyCFunction ) RenderData_getFtypePath, METH_NOARGS, + "() - get the path to Ftype file"}, + {"enableExtensions", ( PyCFunction ) RenderData_EnableExtensions, + METH_VARARGS, + "(bool) - enable/disable windows extensions for output files"}, + {"enableSequencer", ( PyCFunction ) RenderData_EnableSequencer, + METH_VARARGS, + "(bool) - enable/disable Do Sequence"}, + {"enableRenderDaemon", ( PyCFunction ) RenderData_EnableRenderDaemon, + METH_VARARGS, + "(bool) - enable/disable Scene daemon"}, + {"enableToonShading", ( PyCFunction ) RenderData_EnableToonShading, + METH_VARARGS, + "(bool) - enable/disable Edge rendering"}, + {"edgeIntensity", ( PyCFunction ) RenderData_EdgeIntensity, + METH_VARARGS, + "(int) - get/set edge intensity for toon shading"}, + {"setEdgeColor", ( PyCFunction ) RenderData_SetEdgeColor, METH_VARARGS, + "(f,f,f) - set the edge color for toon shading - Red,Green,Blue expected."}, + {"getEdgeColor", ( PyCFunction ) RenderData_GetEdgeColor, METH_NOARGS, + "() - get the edge color for toon shading - Red,Green,Blue expected."}, + {"edgeAntiShift", ( PyCFunction ) RenderData_EdgeAntiShift, + METH_VARARGS, + "(int) - with the unified renderer to reduce intensity on boundaries."}, + {"enableOversampling", ( PyCFunction ) RenderData_EnableOversampling, + METH_VARARGS, + "(bool) - enable/disable oversampling (anit-aliasing)."}, + {"setOversamplingLevel", + ( PyCFunction ) RenderData_SetOversamplingLevel, METH_VARARGS, + "(enum) - get/set the level of oversampling (anit-aliasing)."}, + {"enableMotionBlur", ( PyCFunction ) RenderData_EnableMotionBlur, + METH_VARARGS, + "(bool) - enable/disable MBlur."}, + {"motionBlurLevel", ( PyCFunction ) RenderData_MotionBlurLevel, + METH_VARARGS, + "(float) - get/set the length of shutter time for motion blur."}, + {"partsX", ( PyCFunction ) RenderData_PartsX, METH_VARARGS, + "(int) - get/set the number of parts to divide the render in the X direction"}, + {"partsY", ( PyCFunction ) RenderData_PartsY, METH_VARARGS, + "(int) - get/set the number of parts to divide the render in the Y direction"}, + {"enableSky", ( PyCFunction ) RenderData_EnableSky, METH_NOARGS, + "() - enable render background with sky"}, + {"enablePremultiply", ( PyCFunction ) RenderData_EnablePremultiply, + METH_NOARGS, + "() - enable premultiply alpha"}, + {"enableKey", ( PyCFunction ) RenderData_EnableKey, METH_NOARGS, + "() - enable alpha and colour values remain unchanged"}, + {"enableShadow", ( PyCFunction ) RenderData_EnableShadow, METH_VARARGS, + "(bool) - enable/disable shadow calculation"}, + {"enablePanorama", ( PyCFunction ) RenderData_EnablePanorama, + METH_VARARGS, + "(bool) - enable/disable panorama rendering (output width is multiplied by Xparts)"}, + {"enableEnvironmentMap", + ( PyCFunction ) RenderData_EnableEnvironmentMap, METH_VARARGS, + "(bool) - enable/disable environment map rendering"}, + {"enableRayTracing", ( PyCFunction ) RenderData_EnableRayTracing, + METH_VARARGS, + "(bool) - enable/disable ray tracing"}, + {"enableRadiosityRender", + ( PyCFunction ) RenderData_EnableRadiosityRender, METH_VARARGS, + "(bool) - enable/disable radiosity rendering"}, + {"getRenderWinSize", ( PyCFunction ) RenderData_getRenderWinSize, + METH_NOARGS, + "() - get the size of the render window"}, + {"setRenderWinSize", ( PyCFunction ) RenderData_SetRenderWinSize, + METH_VARARGS, + "(int) - set the size of the render window"}, + {"enableFieldRendering", + ( PyCFunction ) RenderData_EnableFieldRendering, METH_VARARGS, + "(bool) - enable/disable field rendering"}, + {"enableOddFieldFirst", ( PyCFunction ) RenderData_EnableOddFieldFirst, + METH_VARARGS, + "(bool) - enable/disable Odd field first rendering (Default: Even field)"}, + {"enableFieldTimeDisable", + ( PyCFunction ) RenderData_EnableFieldTimeDisable, METH_VARARGS, + "(bool) - enable/disable time difference in field calculations"}, + {"enableGaussFilter", ( PyCFunction ) RenderData_EnableGaussFilter, + METH_VARARGS, + "(bool) - enable/disable Gauss sampling filter for antialiasing"}, + {"enableBorderRender", ( PyCFunction ) RenderData_EnableBorderRender, + METH_VARARGS, + "(bool) - enable/disable small cut-out rendering"}, + {"setBorder", ( PyCFunction ) RenderData_SetBorder, METH_VARARGS, + "(f,f,f,f) - set the border for border rendering"}, + {"enableGammaCorrection", + ( PyCFunction ) RenderData_EnableGammaCorrection, METH_VARARGS, + "(bool) - enable/disable gamma correction"}, + {"gaussFilterSize", ( PyCFunction ) RenderData_GaussFilterSize, + METH_VARARGS, + "(float) - get/sets the Gauss filter size"}, + {"startFrame", ( PyCFunction ) RenderData_StartFrame, METH_VARARGS, + "(int) - get/set the starting frame for rendering"}, + {"currentFrame", ( PyCFunction ) RenderData_CurrentFrame, METH_VARARGS, + "(int) - get/set the current frame for rendering"}, + {"endFrame", ( PyCFunction ) RenderData_EndFrame, METH_VARARGS, + "(int) - get/set the ending frame for rendering"}, + {"getTimeCode", ( PyCFunction ) RenderData_getTimeCode, METH_NOARGS, + "get the current frame in HH:MM:SS:FF format"}, + {"imageSizeX", ( PyCFunction ) RenderData_ImageSizeX, METH_VARARGS, + "(int) - get/set the image width in pixels"}, + {"imageSizeY", ( PyCFunction ) RenderData_ImageSizeY, METH_VARARGS, + "(int) - get/set the image height in pixels"}, + {"aspectRatioX", ( PyCFunction ) RenderData_AspectRatioX, METH_VARARGS, + "(int) - get/set the horizontal aspect ratio"}, + {"aspectRatioY", ( PyCFunction ) RenderData_AspectRatioY, METH_VARARGS, + "(int) - get/set the vertical aspect ratio"}, + {"setRenderer", ( PyCFunction ) RenderData_SetRenderer, METH_VARARGS, + "(enum) - get/set which renderer to render the output"}, + {"enableCropping", ( PyCFunction ) RenderData_EnableCropping, + METH_VARARGS, + "(bool) - enable/disable exclusion of border rendering from total image"}, + {"setImageType", ( PyCFunction ) RenderData_SetImageType, METH_VARARGS, + "(enum) - get/set the type of image to output from the render"}, + {"quality", ( PyCFunction ) RenderData_Quality, METH_VARARGS, + "(int) - get/set quality get/setting for JPEG images, AVI Jpeg and SGI movies"}, + {"framesPerSec", ( PyCFunction ) RenderData_FramesPerSec, METH_VARARGS, + "(int) - get/set frames per second"}, + {"enableGrayscale", ( PyCFunction ) RenderData_EnableGrayscale, + METH_NOARGS, + "() - images are saved with BW (grayscale) data"}, + {"enableRGBColor", ( PyCFunction ) RenderData_EnableRGBColor, + METH_NOARGS, + "() - images are saved with RGB (color) data"}, + {"enableRGBAColor", ( PyCFunction ) RenderData_EnableRGBAColor, + METH_NOARGS, + "() - images are saved with RGB and Alpha data (if supported)"}, + {"sizePreset", ( PyCFunction ) RenderData_SizePreset, METH_VARARGS, + "(enum) - get/set the render to one of a few preget/sets"}, + {"enableUnifiedRenderer", + ( PyCFunction ) RenderData_EnableUnifiedRenderer, METH_VARARGS, + "(bool) - use the unified renderer"}, + {"setYafrayGIQuality", ( PyCFunction ) RenderData_SetYafrayGIQuality, + METH_VARARGS, + "(enum) - get/set yafray global Illumination quality"}, + {"setYafrayGIMethod", ( PyCFunction ) RenderData_SetYafrayGIMethod, + METH_VARARGS, + "(enum) - get/set yafray global Illumination method"}, + {"yafrayGIPower", ( PyCFunction ) RenderData_YafrayGIPower, + METH_VARARGS, + "(float) - get/set GI lighting intensity scale"}, + {"yafrayGIDepth", ( PyCFunction ) RenderData_YafrayGIDepth, + METH_VARARGS, + "(int) - get/set number of bounces of the indirect light"}, + {"yafrayGICDepth", ( PyCFunction ) RenderData_YafrayGICDepth, + METH_VARARGS, + "(int) - get/set number of bounces inside objects (for caustics)"}, + {"enableYafrayGICache", ( PyCFunction ) RenderData_EnableYafrayGICache, + METH_VARARGS, + "(bool) - enable/disable cache irradiance samples (faster)"}, + {"enableYafrayGIPhotons", + ( PyCFunction ) RenderData_EnableYafrayGIPhotons, METH_VARARGS, + "(bool) - enable/disable use global photons to help in GI"}, + {"yafrayGIPhotonCount", ( PyCFunction ) RenderData_YafrayGIPhotonCount, + METH_VARARGS, + "(int) - get/set number of photons to shoot"}, + {"yafrayGIPhotonRadius", + ( PyCFunction ) RenderData_YafrayGIPhotonRadius, METH_VARARGS, + "(float) - get/set radius to search for photons to mix (blur)"}, + {"yafrayGIPhotonMixCount", + ( PyCFunction ) RenderData_YafrayGIPhotonMixCount, METH_VARARGS, + "(int) - get/set number of photons to shoot"}, + {"enableYafrayGITunePhotons", + ( PyCFunction ) RenderData_EnableYafrayGITunePhotons, METH_VARARGS, + "(bool) - enable/disable show the photonmap directly in the render for tuning"}, + {"yafrayGIShadowQuality", + ( PyCFunction ) RenderData_YafrayGIShadowQuality, METH_VARARGS, + "(float) - get/set the shadow quality, keep it under 0.95"}, + {"yafrayGIPixelsPerSample", + ( PyCFunction ) RenderData_YafrayGIPixelsPerSample, METH_VARARGS, + "(int) - get/set maximum number of pixels without samples, the lower the better and slower"}, + {"yafrayGIRefinement", ( PyCFunction ) RenderData_YafrayGIRefinement, + METH_VARARGS, + "(float) - get/setthreshold to refine shadows EXPERIMENTAL. 1 = no refinement"}, + {"yafrayRayBias", ( PyCFunction ) RenderData_YafrayRayBias, + METH_VARARGS, + "(float) - get/set shadow ray bias to avoid self shadowing"}, + {"yafrayRayDepth", ( PyCFunction ) RenderData_YafrayRayDepth, + METH_VARARGS, + "(int) - get/set maximum render ray depth from the camera"}, + {"yafrayGamma", ( PyCFunction ) RenderData_YafrayGamma, METH_VARARGS, + "(float) - get/set gamma correction, 1 is off"}, + {"yafrayExposure", ( PyCFunction ) RenderData_YafrayExposure, + METH_VARARGS, + "(float) - get/set exposure adjustment, 0 is off"}, + {"yafrayProcessorCount", + ( PyCFunction ) RenderData_YafrayProcessorCount, METH_VARARGS, + "(int) - get/set number of processors to use"}, + {"enableGameFrameStretch", + ( PyCFunction ) RenderData_EnableGameFrameStretch, METH_NOARGS, + "(l) - enble stretch or squeeze the viewport to fill the display window"}, + {"enableGameFrameExpose", + ( PyCFunction ) RenderData_EnableGameFrameExpose, METH_NOARGS, + "(l) - enable show the entire viewport in the display window, viewing more horizontally or vertically"}, + {"enableGameFrameBars", ( PyCFunction ) RenderData_EnableGameFrameBars, + METH_NOARGS, + "() - enable show the entire viewport in the display window, using bar horizontally or vertically"}, + {"setGameFrameColor", ( PyCFunction ) RenderData_SetGameFrameColor, + METH_VARARGS, + "(f,f,f) - set the red, green, blue component of the bars"}, + {"getGameFrameColor", ( PyCFunction ) RenderData_GetGameFrameColor, + METH_NOARGS, + "() - get the red, green, blue component of the bars"}, + {"gammaLevel", ( PyCFunction ) RenderData_GammaLevel, METH_VARARGS, + "(float) - get/set the gamma value for blending oversampled images (1.0 = no correction"}, + {"postProcessAdd", ( PyCFunction ) RenderData_PostProcessAdd, + METH_VARARGS, + "(float) - get/set post processing add"}, + {"postProcessMultiply", ( PyCFunction ) RenderData_PostProcessMultiply, + METH_VARARGS, + "(float) - get/set post processing multiply"}, + {"postProcessGamma", ( PyCFunction ) RenderData_PostProcessGamma, + METH_VARARGS, + "(float) - get/set post processing gamma"}, + {"SGIMaxsize", ( PyCFunction ) RenderData_SGIMaxsize, METH_VARARGS, + "(int) - get/set maximum size per frame to save in an SGI movie"}, + {"enableSGICosmo", ( PyCFunction ) RenderData_EnableSGICosmo, + METH_VARARGS, + "(bool) - enable/disable attempt to save SGI movies using Cosmo hardware"}, + {"oldMapValue", ( PyCFunction ) RenderData_OldMapValue, METH_VARARGS, + "(int) - get/set specify old map value in frames"}, + {"newMapValue", ( PyCFunction ) RenderData_NewMapValue, METH_VARARGS, + "(int) - get/set specify new map value in frames"}, + {NULL, NULL, 0, NULL} +}; + +/*------------------------------------BPy_RenderData Type defintion------ */ +PyTypeObject RenderData_Type = { + PyObject_HEAD_INIT( NULL ) /* required py macro */ + 0, /* ob_size */ + /* For printing, in format "<module>.<name>" */ + "Blender RenderData", /* char *tp_name; */ + sizeof( BPy_RenderData ), /* int tp_basicsize; */ + 0, /* tp_itemsize; For allocation */ + + /* Methods to implement standard operations */ + + ( destructor ) RenderData_dealloc,/* destructor tp_dealloc; */ + NULL, /* printfunc tp_print; */ + NULL, /* getattrfunc tp_getattr; */ + NULL, /* setattrfunc tp_setattr; */ + NULL, /* cmpfunc tp_compare; */ + ( reprfunc ) RenderData_repr, /* reprfunc tp_repr; */ + + /* Method suites for standard classes */ + + NULL, /* PyNumberMethods *tp_as_number; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ + + /* More standard operations (here for binary compatibility) */ + + NULL, /* hashfunc tp_hash; */ + NULL, /* ternaryfunc tp_call; */ + NULL, /* reprfunc tp_str; */ + NULL, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ + + /* Functions to access object as input/output buffer */ + NULL, /* PyBufferProcs *tp_as_buffer; */ + + /*** Flags to define presence of optional/expanded features ***/ + Py_TPFLAGS_DEFAULT, /* long tp_flags; */ + + NULL, /* char *tp_doc; Documentation string */ + /*** Assigned meaning in release 2.0 ***/ + /* call function for all accessible objects */ + NULL, /* traverseproc tp_traverse; */ + + /* delete references to contained objects */ + NULL, /* inquiry tp_clear; */ + + /*** Assigned meaning in release 2.1 ***/ + /*** rich comparisons ***/ + NULL, /* richcmpfunc tp_richcompare; */ + + /*** weak reference enabler ***/ + 0, /* long tp_weaklistoffset; */ + + /*** Added in release 2.2 ***/ + /* Iterators */ + NULL, /* getiterfunc tp_iter; */ + NULL, /* iternextfunc tp_iternext; */ + + /*** Attribute descriptor and subclassing stuff ***/ + BPy_RenderData_methods, /* struct PyMethodDef *tp_methods; */ + NULL, /* struct PyMemberDef *tp_members; */ + BPy_RenderData_getseters, /* struct PyGetSetDef *tp_getset; */ + NULL, /* struct _typeobject *tp_base; */ + NULL, /* PyObject *tp_dict; */ + NULL, /* descrgetfunc tp_descr_get; */ + NULL, /* descrsetfunc tp_descr_set; */ + 0, /* long tp_dictoffset; */ + NULL, /* initproc tp_init; */ + NULL, /* allocfunc tp_alloc; */ + NULL, /* newfunc tp_new; */ + /* Low-level free-memory routine */ + NULL, /* freefunc tp_free; */ + /* For PyObject_IS_GC */ + NULL, /* inquiry tp_is_gc; */ + NULL, /* PyObject *tp_bases; */ + /* method resolution order */ + NULL, /* PyObject *tp_mro; */ + NULL, /* PyObject *tp_cache; */ + NULL, /* PyObject *tp_subclasses; */ + NULL, /* PyObject *tp_weaklist; */ + NULL +}; + +/***************************************************************************/ +/* Render method def */ +/***************************************************************************/ +struct PyMethodDef M_Render_methods[] = { + {"CloseRenderWindow", ( PyCFunction ) M_Render_CloseRenderWindow, + METH_NOARGS, + "() - close the rendering window"}, + {"EnableDispView", ( PyCFunction ) M_Render_EnableDispView, + METH_NOARGS, + "(bool) - enable Sceneing in view"}, + {"EnableDispWin", ( PyCFunction ) M_Render_EnableDispWin, METH_NOARGS, + "(bool) - enable Sceneing in new window"}, + {"SetRenderWinPos", ( PyCFunction ) M_Render_SetRenderWinPos, + METH_VARARGS, + "([string list]) - position the rendering window in around the edge of the screen"}, + {"EnableEdgeShift", ( PyCFunction ) M_Render_EnableEdgeShift, + METH_VARARGS, + "(bool) - with the unified renderer the outlines are shifted a bit."}, + {"EnableEdgeAll", ( PyCFunction ) M_Render_EnableEdgeAll, METH_VARARGS, + "(bool) - also consider transparent faces for edge-rendering with the unified renderer"}, + {NULL, NULL, 0, NULL} +}; + +static PyObject *M_Render_ModesDict( void ) +{ + PyObject *M = PyConstant_New( ); + + if( M ) { + BPy_constant *d = ( BPy_constant * ) M; + PyConstant_Insert( d, "OSA", PyInt_FromLong( R_OSA ) ); + PyConstant_Insert( d, "SHADOW", PyInt_FromLong( R_SHADOW ) ); + PyConstant_Insert( d, "GAMMA", PyInt_FromLong( R_GAMMA ) ); + PyConstant_Insert( d, "ENVMAP", PyInt_FromLong( R_ENVMAP ) ); + PyConstant_Insert( d, "TOONSHADING", PyInt_FromLong( R_EDGE ) ); + PyConstant_Insert( d, "FIELDRENDER", PyInt_FromLong( R_FIELDS ) ); + PyConstant_Insert( d, "FIELDTIME", PyInt_FromLong( R_FIELDSTILL ) ); + PyConstant_Insert( d, "RADIOSITY", PyInt_FromLong( R_RADIO ) ); + PyConstant_Insert( d, "BORDER_RENDER", PyInt_FromLong( R_BORDER ) ); + PyConstant_Insert( d, "PANORAMA", PyInt_FromLong( R_PANORAMA ) ); + PyConstant_Insert( d, "CROP", PyInt_FromLong( R_CROP ) ); + PyConstant_Insert( d, "ODDFIELD", PyInt_FromLong( R_ODDFIELD ) ); + PyConstant_Insert( d, "MBLUR", PyInt_FromLong( R_MBLUR ) ); + PyConstant_Insert( d, "UNIFIED", PyInt_FromLong( R_UNIFIED ) ); + PyConstant_Insert( d, "RAYTRACING", PyInt_FromLong( R_RAYTRACE ) ); + PyConstant_Insert( d, "THREADS", PyInt_FromLong( R_THREADS ) ); + } + return M; +} + +static PyObject *M_Render_SceModesDict( void ) +{ + PyObject *M = PyConstant_New( ); + + if( M ) { + BPy_constant *d = ( BPy_constant * ) M; + PyConstant_Insert( d, "SEQUENCER", PyInt_FromLong( R_DOSEQ ) ); + PyConstant_Insert( d, "EXTENSION", PyInt_FromLong( R_EXTENSION ) ); + } + return M; +} + +static PyObject *M_Render_GameFramingDict( void ) +{ + PyObject *M = PyConstant_New( ); + + if( M ) { + BPy_constant *d = ( BPy_constant * ) M; + PyConstant_Insert( d, "BARS", + PyInt_FromLong( SCE_GAMEFRAMING_BARS ) ); + PyConstant_Insert( d, "EXTEND", + PyInt_FromLong( SCE_GAMEFRAMING_EXTEND ) ); + PyConstant_Insert( d, "SCALE", + PyInt_FromLong( SCE_GAMEFRAMING_SCALE ) ); + } + return M; +} + +/***************************************************************************/ +/* Render Module Init */ +/***************************************************************************/ +PyObject *Render_Init( void ) +{ + PyObject *submodule; + PyObject *ModesDict = M_Render_ModesDict( ); + PyObject *SceModesDict = M_Render_SceModesDict( ); + PyObject *GFramingDict = M_Render_GameFramingDict( ); + + if( PyType_Ready( &RenderData_Type ) < 0 ) + return NULL; + + submodule = Py_InitModule3( "Blender.Scene.Render", + M_Render_methods, M_Render_doc ); + + if( ModesDict ) + PyModule_AddObject( submodule, "Modes", ModesDict ); + if( SceModesDict ) + PyModule_AddObject( submodule, "SceModes", SceModesDict ); + if( GFramingDict ) + PyModule_AddObject( submodule, "FramingModes", GFramingDict ); + + /* ugh: why aren't these in a constant dict? */ + + PyModule_AddIntConstant( submodule, "INTERNAL", R_INTERN ); + PyModule_AddIntConstant( submodule, "YAFRAY", R_YAFRAY ); + PyModule_AddIntConstant( submodule, "AVIRAW", R_AVIRAW ); + PyModule_AddIntConstant( submodule, "AVIJPEG", R_AVIJPEG ); + PyModule_AddIntConstant( submodule, "AVICODEC", R_AVICODEC ); + PyModule_AddIntConstant( submodule, "QUICKTIME", R_QUICKTIME ); + PyModule_AddIntConstant( submodule, "TARGA", R_TARGA ); + PyModule_AddIntConstant( submodule, "RAWTGA", R_RAWTGA ); + PyModule_AddIntConstant( submodule, "HDR", R_RADHDR ); + PyModule_AddIntConstant( submodule, "PNG", R_PNG ); + PyModule_AddIntConstant( submodule, "BMP", R_BMP ); + PyModule_AddIntConstant( submodule, "JPEG", R_JPEG90 ); + PyModule_AddIntConstant( submodule, "HAMX", R_HAMX ); + PyModule_AddIntConstant( submodule, "IRIS", R_IRIS ); + PyModule_AddIntConstant( submodule, "IRISZ", R_IRIZ ); + PyModule_AddIntConstant( submodule, "FTYPE", R_FTYPE ); + PyModule_AddIntConstant( submodule, "PAL", B_PR_PAL ); + PyModule_AddIntConstant( submodule, "NTSC", B_PR_NTSC ); + PyModule_AddIntConstant( submodule, "DEFAULT", B_PR_PRESET ); + PyModule_AddIntConstant( submodule, "PREVIEW", B_PR_PRV ); + PyModule_AddIntConstant( submodule, "PC", B_PR_PC ); + PyModule_AddIntConstant( submodule, "PAL169", B_PR_PAL169 ); + PyModule_AddIntConstant( submodule, "PANO", B_PR_PANO ); + PyModule_AddIntConstant( submodule, "FULL", B_PR_FULL ); + PyModule_AddIntConstant( submodule, "NONE", PY_NONE ); + PyModule_AddIntConstant( submodule, "LOW", PY_LOW ); + PyModule_AddIntConstant( submodule, "MEDIUM", PY_MEDIUM ); + PyModule_AddIntConstant( submodule, "HIGH", PY_HIGH ); + PyModule_AddIntConstant( submodule, "HIGHER", PY_HIGHER ); + PyModule_AddIntConstant( submodule, "BEST", PY_BEST ); + PyModule_AddIntConstant( submodule, "SKYDOME", PY_SKYDOME ); + PyModule_AddIntConstant( submodule, "GIFULL", PY_FULL ); + PyModule_AddIntConstant( submodule, "OPENEXR", R_OPENEXR ); + PyModule_AddIntConstant( submodule, "TIFF", R_TIFF ); + PyModule_AddIntConstant( submodule, "FFMPEG", R_FFMPEG ); + PyModule_AddIntConstant( submodule, "CINEON", R_CINEON ); + PyModule_AddIntConstant( submodule, "DPX", R_DPX ); + + return ( submodule ); +} + +/***************************************************************************/ +/* BPy_RenderData Callbacks */ +/***************************************************************************/ + +PyObject *RenderData_CreatePyObject( struct Scene * scene ) +{ + BPy_RenderData *py_renderdata; + + py_renderdata = + ( BPy_RenderData * ) PyObject_NEW( BPy_RenderData, + &RenderData_Type ); + + if( py_renderdata == NULL ) { + return ( NULL ); + } + py_renderdata->renderContext = &scene->r; + py_renderdata->scene = scene; + + return ( ( PyObject * ) py_renderdata ); +} + +int RenderData_CheckPyObject( PyObject * py_obj ) +{ + return ( py_obj->ob_type == &RenderData_Type ); +} + +/* #####DEPRECATED###### */ + +static PyObject *RenderData_SetRenderPath( BPy_RenderData *self, + PyObject *args ) +{ + return EXPP_setterWrapper( (void *)self, args, + (setter)RenderData_setRenderPath ); +} + +static PyObject *RenderData_SetBackbufPath( BPy_RenderData *self, + PyObject *args ) +{ + return EXPP_setterWrapper( (void *)self, args, + (setter)RenderData_setBackbufPath ); +} + +static PyObject *RenderData_SetFtypePath( BPy_RenderData *self, + PyObject *args ) +{ + return EXPP_setterWrapperTuple( (void *)self, args, + (setter)RenderData_setFtypePath ); +} + +static PyObject *RenderData_SetOversamplingLevel( BPy_RenderData * self, + PyObject * args ) +{ + return EXPP_setterWrapper( (void *)self, args, + (setter)RenderData_setOSALevel ); +} + +static PyObject *RenderData_SetRenderWinSize( BPy_RenderData * self, + PyObject * args ) +{ + return EXPP_setterWrapper( (void *)self, args, + (setter)RenderData_setRenderWinSize ); +} + +static PyObject *RenderData_SetBorder( BPy_RenderData * self, + PyObject * args ) +{ + return EXPP_setterWrapperTuple( (void *)self, args, + (setter)RenderData_setBorder ); +} + +static PyObject *RenderData_SetRenderer( BPy_RenderData * self, + PyObject * args ) +{ + return EXPP_setterWrapper( (void *)self, args, + (setter)RenderData_setRenderer ); +} + +static PyObject *RenderData_SetImageType( BPy_RenderData * self, + PyObject * args ) +{ + return EXPP_setterWrapper( (void *)self, args, + (setter)RenderData_setImageType ); +} |