[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13661] trunk/blender/source/blender/ python/api2_2x: Python API
Ken Hughes
khughes at pacific.edu
Tue Feb 12 20:29:13 CET 2008
Revision: 13661
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13661
Author: khughes
Date: 2008-02-12 20:29:12 +0100 (Tue, 12 Feb 2008)
Log Message:
-----------
Python API
----------
Added missing lamp.falloffType attribute. Also fixed typo in Render docs.
Modified Paths:
--------------
trunk/blender/source/blender/python/api2_2x/Lamp.c
trunk/blender/source/blender/python/api2_2x/doc/Lamp.py
trunk/blender/source/blender/python/api2_2x/doc/Render.py
Modified: trunk/blender/source/blender/python/api2_2x/Lamp.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Lamp.c 2008-02-12 18:56:32 UTC (rev 13660)
+++ trunk/blender/source/blender/python/api2_2x/Lamp.c 2008-02-12 19:29:12 UTC (rev 13661)
@@ -1,5 +1,5 @@
/*
- * $Id: Lamp.c 12810 2007-12-06 20:15:03Z khughes $
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -118,6 +118,8 @@
#define EXPP_LAMP_QUAD2_MAX 1.0
#define EXPP_LAMP_COL_MIN 0.0
#define EXPP_LAMP_COL_MAX 1.0
+#define EXPP_LAMP_FALLOFF_MIN LA_FALLOFF_CONSTANT
+#define EXPP_LAMP_FALLOFF_MAX LA_FALLOFF_SLIDERS
/* Raytracing settings */
#define EXPP_LAMP_RAYSAMPLES_MIN 1
@@ -255,6 +257,8 @@
static PyObject *Lamp_addScriptLink( BPy_Lamp * self, PyObject * args );
static PyObject *Lamp_clearScriptLinks( BPy_Lamp * self, PyObject * args );
static int Lamp_setComponent( BPy_Lamp * self, PyObject * value, void * closure );
+static PyObject *Lamp_getFalloffType( BPy_Lamp * self );
+static int Lamp_setFalloffType( BPy_Lamp * self, PyObject * value );
/*****************************************************************************/
/* Python BPy_Lamp methods table: */
@@ -468,6 +472,10 @@
(getter)Lamp_getType, (setter)Lamp_setType,
"Lamp type",
NULL},
+ {"falloffType",
+ (getter)Lamp_getFalloffType, (setter)Lamp_setFalloffType,
+ "Lamp falloff type",
+ NULL},
{"R",
(getter)Lamp_getComponent, (setter)Lamp_setComponent,
"Lamp color red component",
@@ -779,19 +787,42 @@
return Modes;
}
+static PyObject *Lamp_FalloffsDict( void )
+{ /* create the Blender.Lamp.Modes constant dict */
+ PyObject *Falloffs = PyConstant_New( );
+
+ if( Falloffs ) {
+ BPy_constant *c = ( BPy_constant * ) Falloffs;
+
+ PyConstant_Insert( c, "CONSTANT",
+ PyInt_FromLong( LA_FALLOFF_CONSTANT ) );
+ PyConstant_Insert( c, "INVLINEAR",
+ PyInt_FromLong( LA_FALLOFF_INVLINEAR ) );
+ PyConstant_Insert( c, "INVSQUARE",
+ PyInt_FromLong( LA_FALLOFF_INVSQUARE ) );
+ PyConstant_Insert( c, "CUSTOM",
+ PyInt_FromLong( LA_FALLOFF_CURVE ) );
+ PyConstant_Insert( c, "LINQUAD",
+ PyInt_FromLong( LA_FALLOFF_SLIDERS ) );
+ }
+
+ return Falloffs;
+}
+
/*****************************************************************************/
/* Function: Lamp_Init */
/*****************************************************************************/
/* Needed by the Blender module, to register the Blender.Lamp submodule */
PyObject *Lamp_Init( void )
{
- PyObject *submodule, *Types, *Modes;
+ PyObject *submodule, *Types, *Modes, *Falloffs;
if( PyType_Ready( &Lamp_Type ) < 0)
return NULL;
Types = Lamp_TypesDict( );
Modes = Lamp_ModesDict( );
+ Falloffs = Lamp_FalloffsDict( );
submodule =
Py_InitModule3( "Blender.Lamp", M_Lamp_methods, M_Lamp_doc );
@@ -800,6 +831,8 @@
PyModule_AddObject( submodule, "Types", Types );
if( Modes )
PyModule_AddObject( submodule, "Modes", Modes );
+ if( Falloffs )
+ PyModule_AddObject( submodule, "Falloffs", Falloffs );
PyModule_AddIntConstant( submodule, "RGB", IPOKEY_RGB );
PyModule_AddIntConstant( submodule, "ENERGY", IPOKEY_ENERGY );
@@ -967,6 +1000,11 @@
return rgbTuple_getCol( self->color );
}
+static PyObject *Lamp_getFalloffType( BPy_Lamp * self )
+{
+ return PyInt_FromLong( (int)self->lamp->falloff_type );
+}
+
static int Lamp_setType( BPy_Lamp * self, PyObject * value )
{
return EXPP_setIValueRange ( value, &self->lamp->type,
@@ -1131,6 +1169,13 @@
EXPP_LAMP_QUAD2_MAX );
}
+static int Lamp_setFalloffType( BPy_Lamp * self, PyObject * value )
+{
+ return EXPP_setIValueRange ( value, &self->lamp->falloff_type,
+ EXPP_LAMP_FALLOFF_MIN, EXPP_LAMP_FALLOFF_MAX, 'h' );
+}
+
+
static PyObject *Lamp_getComponent( BPy_Lamp * self, void * closure )
{
switch ( (int)closure ) {
Modified: trunk/blender/source/blender/python/api2_2x/doc/Lamp.py
===================================================================
--- trunk/blender/source/blender/python/api2_2x/doc/Lamp.py 2008-02-12 18:56:32 UTC (rev 13660)
+++ trunk/blender/source/blender/python/api2_2x/doc/Lamp.py 2008-02-12 19:29:12 UTC (rev 13661)
@@ -26,6 +26,13 @@
- 'Hemi': 3
- 'Area': 4
- 'Photon': 5
+ at type Falloffs: read-only dictionary
+ at var Falloffs: The lamp falloff types.
+ - CONSTANT - Constant falloff
+ - INVLINEAR - Inverse linear
+ - INVSQUARE - Inverse square
+ - CUSTOM - Custom curve
+ - LINQUAD - Lin/Quad weighted
@type Modes: read-only dictionary
@var Modes: The lamp modes. Modes may be ORed together.
- 'Shadows'
@@ -152,6 +159,8 @@
@type spotSize: float
@ivar type: Lamp type. See L{Types} for values.
@type type: int
+ @ivar falloffType: Lamp falloff type. See L{Falloffs} for values.
+ @type falloffType: int
@warning: Most member variables assume values in some [Min, Max] interval.
When trying to set them, the given parameter will be clamped to lie in
Modified: trunk/blender/source/blender/python/api2_2x/doc/Render.py
===================================================================
--- trunk/blender/source/blender/python/api2_2x/doc/Render.py 2008-02-12 18:56:32 UTC (rev 13660)
+++ trunk/blender/source/blender/python/api2_2x/doc/Render.py 2008-02-12 19:29:12 UTC (rev 13661)
@@ -472,7 +472,7 @@
"""
Get the filename used for the remdered image.
@type frame: int
- @param path: the frame to use in the filename, if no argument given, use the current frame.
+ @param frame: the frame to use in the filename, if no argument given, use the current frame.
@rtype: string
@return: Returns the filename that blender would render to, taking into account output path, extension and frame number.
"""
More information about the Bf-blender-cvs
mailing list