- NMesh: made nmesh.update accept an optional 'vertex_shade' param to init vcols with shading info, like when you enter vpaint mode or press the relevant "make" button for a mesh without vcols.  This is still a test, the functionality was requested by Manuel Bastioni for the SSS script they are working on:
http://www.dedalo-3d.com/index.php?filename=SXCOL/makehuman/articles/subsurface_scattering_in_python.html
- sys: made makename() accept files with max FILE_MAXDIR+FILE_MAXFILE name length, should fix #2192.  Was only FILE_MAXFILE, a mistake;
- Image: added .setFilename(), contributed by Campbell Barton;
- Camera: added camera.get/setScale for the new param added by Ton for ortho cameras.  Requested by Jean-Michel Soler for the Texture Baker script;
- related doc updates.
This commit is contained in:
2005-02-09 05:19:24 +00:00
parent 955d5aa6eb
commit 05bf482f6a
12 changed files with 201 additions and 53 deletions

View File

@@ -65,7 +65,7 @@ Example::\n\
\n\ \n\
from Blender import Camera, Object, Scene\n\ from Blender import Camera, Object, Scene\n\
c = Camera.New('ortho') # create new ortho camera data\n\ c = Camera.New('ortho') # create new ortho camera data\n\
c.lens = 35.0 # set lens value\n\ c.scale = 6.0 # set scale value\n\
cur = Scene.getCurrent() # get current Scene\n\ cur = Scene.getCurrent() # get current Scene\n\
ob = Object.New('Camera') # make camera object\n\ ob = Object.New('Camera') # make camera object\n\
ob.link(c) # link camera data with this object\n\ ob.link(c) # link camera data with this object\n\
@@ -103,6 +103,7 @@ static PyObject *Camera_getLens( BPy_Camera * self );
static PyObject *Camera_getClipStart( BPy_Camera * self ); static PyObject *Camera_getClipStart( BPy_Camera * self );
static PyObject *Camera_getClipEnd( BPy_Camera * self ); static PyObject *Camera_getClipEnd( BPy_Camera * self );
static PyObject *Camera_getDrawSize( BPy_Camera * self ); static PyObject *Camera_getDrawSize( BPy_Camera * self );
static PyObject *Camera_getScale( BPy_Camera * self );
static PyObject *Camera_setIpo( BPy_Camera * self, PyObject * args ); static PyObject *Camera_setIpo( BPy_Camera * self, PyObject * args );
static PyObject *Camera_clearIpo( BPy_Camera * self ); static PyObject *Camera_clearIpo( BPy_Camera * self );
static PyObject *Camera_setName( BPy_Camera * self, PyObject * args ); static PyObject *Camera_setName( BPy_Camera * self, PyObject * args );
@@ -114,6 +115,7 @@ static PyObject *Camera_setLens( BPy_Camera * self, PyObject * args );
static PyObject *Camera_setClipStart( BPy_Camera * self, PyObject * args ); static PyObject *Camera_setClipStart( BPy_Camera * self, PyObject * args );
static PyObject *Camera_setClipEnd( BPy_Camera * self, PyObject * args ); static PyObject *Camera_setClipEnd( BPy_Camera * self, PyObject * args );
static PyObject *Camera_setDrawSize( BPy_Camera * self, PyObject * args ); static PyObject *Camera_setDrawSize( BPy_Camera * self, PyObject * args );
static PyObject *Camera_setScale( BPy_Camera * self, PyObject * args );
static PyObject *Camera_getScriptLinks( BPy_Camera * self, PyObject * args ); static PyObject *Camera_getScriptLinks( BPy_Camera * self, PyObject * args );
static PyObject *Camera_addScriptLink( BPy_Camera * self, PyObject * args ); static PyObject *Camera_addScriptLink( BPy_Camera * self, PyObject * args );
static PyObject *Camera_clearScriptLinks( BPy_Camera * self ); static PyObject *Camera_clearScriptLinks( BPy_Camera * self );
@@ -133,7 +135,9 @@ static PyMethodDef BPy_Camera_methods[] = {
"() - Return Camera mode flags (or'ed value) -\n" "() - Return Camera mode flags (or'ed value) -\n"
" 'showLimits':1, 'showMist':2"}, " 'showLimits':1, 'showMist':2"},
{"getLens", ( PyCFunction ) Camera_getLens, METH_NOARGS, {"getLens", ( PyCFunction ) Camera_getLens, METH_NOARGS,
"() - Return Camera lens value"}, "() - Return *perspective* Camera lens value"},
{"getScale", ( PyCFunction ) Camera_getScale, METH_NOARGS,
"() - Return *ortho* Camera scale value"},
{"getClipStart", ( PyCFunction ) Camera_getClipStart, METH_NOARGS, {"getClipStart", ( PyCFunction ) Camera_getClipStart, METH_NOARGS,
"() - Return Camera clip start value"}, "() - Return Camera clip start value"},
{"getClipEnd", ( PyCFunction ) Camera_getClipEnd, METH_NOARGS, {"getClipEnd", ( PyCFunction ) Camera_getClipEnd, METH_NOARGS,
@@ -151,7 +155,9 @@ static PyMethodDef BPy_Camera_methods[] = {
{"setMode", ( PyCFunction ) Camera_setMode, METH_VARARGS, {"setMode", ( PyCFunction ) Camera_setMode, METH_VARARGS,
"(<s<,s>>) - Set Camera mode flag(s): 'showLimits' and 'showMist'"}, "(<s<,s>>) - Set Camera mode flag(s): 'showLimits' and 'showMist'"},
{"setLens", ( PyCFunction ) Camera_setLens, METH_VARARGS, {"setLens", ( PyCFunction ) Camera_setLens, METH_VARARGS,
"(f) - Set Camera lens value"}, "(f) - Set *perpective* Camera lens value"},
{"setScale", ( PyCFunction ) Camera_setScale, METH_VARARGS,
"(f) - Set *ortho* Camera scale value"},
{"setClipStart", ( PyCFunction ) Camera_setClipStart, METH_VARARGS, {"setClipStart", ( PyCFunction ) Camera_setClipStart, METH_VARARGS,
"(f) - Set Camera clip start value"}, "(f) - Set Camera clip start value"},
{"setClipEnd", ( PyCFunction ) Camera_setClipEnd, METH_VARARGS, {"setClipEnd", ( PyCFunction ) Camera_setClipEnd, METH_VARARGS,
@@ -457,6 +463,17 @@ static PyObject *Camera_getLens( BPy_Camera * self )
"couldn't get Camera.lens attribute" ); "couldn't get Camera.lens attribute" );
} }
static PyObject *Camera_getScale( BPy_Camera * self )
{
PyObject *attr = PyFloat_FromDouble( self->camera->ortho_scale );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Camera.scale attribute" );
}
static PyObject *Camera_getClipStart( BPy_Camera * self ) static PyObject *Camera_getClipStart( BPy_Camera * self )
{ {
PyObject *attr = PyFloat_FromDouble( self->camera->clipsta ); PyObject *attr = PyFloat_FromDouble( self->camera->clipsta );
@@ -680,6 +697,22 @@ static PyObject *Camera_setLens( BPy_Camera * self, PyObject * args )
return Py_None; return Py_None;
} }
static PyObject *Camera_setScale( BPy_Camera * self, PyObject * args )
{
float value;
if( !PyArg_ParseTuple( args, "f", &value ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected float argument" );
self->camera->ortho_scale = EXPP_ClampFloat( value,
EXPP_CAM_SCALE_MIN,
EXPP_CAM_SCALE_MAX );
Py_INCREF( Py_None );
return Py_None;
}
static PyObject *Camera_setClipStart( BPy_Camera * self, PyObject * args ) static PyObject *Camera_setClipStart( BPy_Camera * self, PyObject * args )
{ {
float value; float value;
@@ -788,6 +821,8 @@ static PyObject *Camera_getAttr( BPy_Camera * self, char *name )
attr = PyInt_FromLong( self->camera->flag ); attr = PyInt_FromLong( self->camera->flag );
else if( strcmp( name, "lens" ) == 0 ) else if( strcmp( name, "lens" ) == 0 )
attr = PyFloat_FromDouble( self->camera->lens ); attr = PyFloat_FromDouble( self->camera->lens );
else if( strcmp( name, "scale" ) == 0 )
attr = PyFloat_FromDouble( self->camera->ortho_scale );
else if( strcmp( name, "clipStart" ) == 0 ) else if( strcmp( name, "clipStart" ) == 0 )
attr = PyFloat_FromDouble( self->camera->clipsta ); attr = PyFloat_FromDouble( self->camera->clipsta );
else if( strcmp( name, "clipEnd" ) == 0 ) else if( strcmp( name, "clipEnd" ) == 0 )
@@ -815,8 +850,8 @@ static PyObject *Camera_getAttr( BPy_Camera * self, char *name )
} }
else if( strcmp( name, "__members__" ) == 0 ) { else if( strcmp( name, "__members__" ) == 0 ) {
attr = Py_BuildValue( "[s,s,s,s,s,s,s,s,s,s,s]", attr = Py_BuildValue( "[s,s,s,s,s,s,s,s,s,s,s,s]",
"name", "type", "mode", "lens", "name", "type", "mode", "lens", "scale",
"clipStart", "ipo", "clipEnd", "clipStart", "ipo", "clipEnd",
"drawSize", "Types", "Modes", "users" ); "drawSize", "Types", "Modes", "users" );
} }
@@ -859,6 +894,8 @@ static int Camera_setAttr( BPy_Camera * self, char *name, PyObject * value )
error = Camera_setIntMode( self, valtuple ); /* special case */ error = Camera_setIntMode( self, valtuple ); /* special case */
else if( strcmp( name, "lens" ) == 0 ) else if( strcmp( name, "lens" ) == 0 )
error = Camera_setLens( self, valtuple ); error = Camera_setLens( self, valtuple );
else if( strcmp( name, "scale" ) == 0 )
error = Camera_setScale( self, valtuple );
else if( strcmp( name, "clipStart" ) == 0 ) else if( strcmp( name, "clipStart" ) == 0 )
error = Camera_setClipStart( self, valtuple ); error = Camera_setClipStart( self, valtuple );
else if( strcmp( name, "clipEnd" ) == 0 ) else if( strcmp( name, "clipEnd" ) == 0 )

View File

@@ -66,6 +66,8 @@ typedef struct {
#define EXPP_CAM_LENS_MIN 1.0 #define EXPP_CAM_LENS_MIN 1.0
#define EXPP_CAM_LENS_MAX 250.0 #define EXPP_CAM_LENS_MAX 250.0
#define EXPP_CAM_SCALE_MIN 0.01
#define EXPP_CAM_SCALE_MAX 1000.0
#define EXPP_CAM_CLIPSTART_MIN 0.0 #define EXPP_CAM_CLIPSTART_MIN 0.0
#define EXPP_CAM_CLIPSTART_MAX 100.0 #define EXPP_CAM_CLIPSTART_MAX 100.0
#define EXPP_CAM_CLIPEND_MIN 1.0 #define EXPP_CAM_CLIPEND_MIN 1.0

View File

@@ -247,6 +247,7 @@ static PyObject *Image_getXRep( BPy_Image * self );
static PyObject *Image_getYRep( BPy_Image * self ); static PyObject *Image_getYRep( BPy_Image * self );
static PyObject *Image_getBindCode( BPy_Image * self ); static PyObject *Image_getBindCode( BPy_Image * self );
static PyObject *Image_setName( BPy_Image * self, PyObject * args ); static PyObject *Image_setName( BPy_Image * self, PyObject * args );
static PyObject *Image_setFilename( BPy_Image * self, PyObject * args );
static PyObject *Image_setXRep( BPy_Image * self, PyObject * args ); static PyObject *Image_setXRep( BPy_Image * self, PyObject * args );
static PyObject *Image_setYRep( BPy_Image * self, PyObject * args ); static PyObject *Image_setYRep( BPy_Image * self, PyObject * args );
static PyObject *Image_reload( BPy_Image * self ); /* by Campbell */ static PyObject *Image_reload( BPy_Image * self ); /* by Campbell */
@@ -282,6 +283,8 @@ static PyMethodDef BPy_Image_methods[] = {
see also image.glLoad()."}, see also image.glLoad()."},
{"setName", ( PyCFunction ) Image_setName, METH_VARARGS, {"setName", ( PyCFunction ) Image_setName, METH_VARARGS,
"(str) - Change Image object name"}, "(str) - Change Image object name"},
{"setFilename", ( PyCFunction ) Image_setFilename, METH_VARARGS,
"(str) - Change Image file name"},
{"setXRep", ( PyCFunction ) Image_setXRep, METH_VARARGS, {"setXRep", ( PyCFunction ) Image_setXRep, METH_VARARGS,
"(int) - Change Image object x repetition value"}, "(int) - Change Image object x repetition value"},
{"setYRep", ( PyCFunction ) Image_setYRep, METH_VARARGS, {"setYRep", ( PyCFunction ) Image_setYRep, METH_VARARGS,
@@ -546,6 +549,23 @@ static PyObject *Image_setName( BPy_Image * self, PyObject * args )
return Py_None; return Py_None;
} }
static PyObject *Image_setFilename( BPy_Image * self, PyObject * args )
{
char *name;
char buf[160];
if( !PyArg_ParseTuple( args, "s", &name ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" ) );
PyOS_snprintf( buf, sizeof( buf ), "%s", name );
strcpy(self->image->name, buf);
Py_INCREF( Py_None );
return Py_None;
}
static PyObject *Image_setXRep( BPy_Image * self, PyObject * args ) static PyObject *Image_setXRep( BPy_Image * self, PyObject * args )
{ {
short value; short value;
@@ -648,6 +668,8 @@ static int Image_setAttr( BPy_Image * self, char *name, PyObject * value )
if( strcmp( name, "name" ) == 0 ) if( strcmp( name, "name" ) == 0 )
error = Image_setName( self, valtuple ); error = Image_setName( self, valtuple );
if( strcmp( name, "filename" ) == 0 )
error = Image_setFilename( self, valtuple );
else if( strcmp( name, "xrep" ) == 0 ) else if( strcmp( name, "xrep" ) == 0 )
error = Image_setXRep( self, valtuple ); error = Image_setXRep( self, valtuple );
else if( strcmp( name, "yrep" ) == 0 ) else if( strcmp( name, "yrep" ) == 0 )

View File

@@ -115,8 +115,8 @@ static char NMesh_printDebug_doc[] =
static char NMesh_addEdge_doc[] = static char NMesh_addEdge_doc[] =
"create an edge between two vertices.\n\ "create an edge between two vertices.\n\
If an edge already exists between those vertices, it is returned. (in blender, only zero \ If an edge already exists between those vertices, it is returned.\n\
or one edge can link two vertices.\n\ (In Blender, only zero or one edge can link two vertices.)\n\
Created edge is automatically added to edges list."; Created edge is automatically added to edges list.";
static char NMesh_findEdge_doc[] = static char NMesh_findEdge_doc[] =
@@ -241,9 +241,12 @@ specified by index. The list contains pairs with the \n\
bone name and the weight."; bone name and the weight.";
static char NMesh_update_doc[] = "(recalc_normals = 0, store_edges = 0) - updates the Mesh.\n\ static char NMesh_update_doc[] = \
if recalc_normals is given and is equal to 1, normal vectors are recalculated.\n\ "(recalc_normals = 0, store_edges = 0, vertex_shade = 0) - Updates the Mesh.\n\
if store_edges is given qnd is equal to 1, egdes data are stored."; Optional arguments: if given and nonzero:\n\
'recalc_normals': normal vectors are recalculated;\n\
'store_edges': edges data is stored.\n\
'vertex_shade': vertex colors are added based on the current lamp setup.";
static char NMesh_getMode_doc[] = static char NMesh_getMode_doc[] =
"() - get the mode flags of this nmesh as an or'ed int value."; "() - get the mode flags of this nmesh as an or'ed int value.";
@@ -1269,19 +1272,19 @@ static PyObject *NMesh_hasVertexColours( PyObject * self, PyObject * args )
return EXPP_incr_ret( Py_False ); return EXPP_incr_ret( Py_False );
} }
static PyObject *NMesh_update( PyObject * self, PyObject * args ) static PyObject *NMesh_update( PyObject *self, PyObject *a, PyObject *kwd )
{ {
int recalc_normals = 0, store_edges = 0;
BPy_NMesh *nmesh = ( BPy_NMesh * ) self; BPy_NMesh *nmesh = ( BPy_NMesh * ) self;
Mesh *mesh = nmesh->mesh; Mesh *mesh = nmesh->mesh;
int recalc_normals = 0, store_edges = 0, vertex_shade = 0;
static char *kwlist[] = {"recalc_normals", "store_edges",
"vertex_shade", NULL};
int needs_redraw = 1;
if( !PyArg_ParseTuple( args, "|ii", &recalc_normals, &store_edges ) ) if (!PyArg_ParseTupleAndKeywords(a, kwd, "|iii", kwlist, &recalc_normals,
&store_edges, &vertex_shade ) )
return EXPP_ReturnPyObjError( PyExc_AttributeError, return EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected nothing, one or two int(s) (0 or 1) as argument" ); "expected nothing or one to three bool(s) (0 or 1) as argument" );
if( recalc_normals && recalc_normals != 1 )
return EXPP_ReturnPyObjError( PyExc_ValueError,
"expected 0 or 1 as argument" );
if( mesh ) { if( mesh ) {
unlink_existingMeshData( mesh ); unlink_existingMeshData( mesh );
@@ -1302,7 +1305,33 @@ static PyObject *NMesh_update( PyObject * self, PyObject * args )
new_id( &( G.main->mesh ), &mesh->id, new_id( &( G.main->mesh ), &mesh->id,
PyString_AsString( nmesh->name ) ); PyString_AsString( nmesh->name ) );
if( !during_script( ) ) if (vertex_shade) {
Base *base = FIRSTBASE;
if (!nmesh->object)
return EXPP_ReturnPyObjError(PyExc_RuntimeError,
"link this mesh to an object first with ob.link(mesh)" );
if (G.obedit)
return EXPP_ReturnPyObjError(PyExc_RuntimeError,
"can't shade vertices while in edit mode" );
while (base) {
if (base->object == nmesh->object) {
base->flag |= SELECT;
nmesh->object->flag = base->flag;
set_active_base (base);
needs_redraw = 0; /* already done in make_vertexcol */
break;
}
base = base->next;
}
make_vertexcol();
countall();
}
if( !during_script( ) && needs_redraw)
allqueue( REDRAWVIEW3D, 0 ); allqueue( REDRAWVIEW3D, 0 );
return PyInt_FromLong( 1 ); return PyInt_FromLong( 1 );
@@ -1527,7 +1556,6 @@ static struct PyMethodDef NMesh_methods[] = {
MethodDef( addMaterial ), MethodDef( addMaterial ),
MethodDef( insertKey ), MethodDef( insertKey ),
MethodDef( removeAllKeys ), MethodDef( removeAllKeys ),
MethodDef( update ),
MethodDef( setMode ), MethodDef( setMode ),
MethodDef( setMaxSmoothAngle ), MethodDef( setMaxSmoothAngle ),
MethodDef( setSubDivLevels ), MethodDef( setSubDivLevels ),
@@ -1544,6 +1572,14 @@ static struct PyMethodDef NMesh_methods[] = {
MethodDef( getMode ), MethodDef( getMode ),
MethodDef( getMaxSmoothAngle ), MethodDef( getMaxSmoothAngle ),
MethodDef( getSubDivLevels ), MethodDef( getSubDivLevels ),
/* METH_VARARGS | METH_KEYWORDS:
* function(PyObject *self, PyObject *args, PyObject *keywords) */
#undef MethodDef
#define MethodDef(func) {#func, (PyCFunction)NMesh_##func,\
METH_VARARGS | METH_KEYWORDS, NMesh_##func##_doc}
MethodDef( update ),
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}
}; };

View File

@@ -41,8 +41,12 @@
#include <config.h> #include <config.h>
#endif #endif
#include "DNA_mesh_types.h" #include <DNA_mesh_types.h>
#include "DNA_meshdata_types.h" #include <DNA_meshdata_types.h>
#include <BIF_editview.h> /* for set_active_base */
#include <BSE_edit.h> /* for countall */
#include <BDR_vpaint.h> /* for make_vertexcol */
#include "Material.h" #include "Material.h"
#include "Image.h" #include "Image.h"

View File

@@ -166,9 +166,9 @@ hierarchy (faster)"},
mode\n\t2: Keep object transform\nfast\n\t>0: Don't update scene \ mode\n\t2: Keep object transform\nfast\n\t>0: Don't update scene \
hierarchy (faster)"}, hierarchy (faster)"},
{"getData", ( PyCFunction ) Object_getData, METH_VARARGS | METH_KEYWORDS, {"getData", ( PyCFunction ) Object_getData, METH_VARARGS | METH_KEYWORDS,
"(only_name = 0) - Returns the datablock object containing the object's \ "(name_only = 0) - Returns the datablock object containing the object's \
data, e.g. Mesh.\n\ data, e.g. Mesh.\n\
If 'only_name' is nonzero or True, only the name of the datablock is returned"}, If 'name_only' is nonzero or True, only the name of the datablock is returned"},
{"getDeltaLocation", ( PyCFunction ) Object_getDeltaLocation, {"getDeltaLocation", ( PyCFunction ) Object_getDeltaLocation,
METH_NOARGS, METH_NOARGS,
"Returns the object's delta location (x, y, z)"}, "Returns the object's delta location (x, y, z)"},
@@ -734,12 +734,12 @@ static PyObject *Object_getData( BPy_Object *self, PyObject *a, PyObject *kwd )
{ {
PyObject *data_object; PyObject *data_object;
Object *object = self->object; Object *object = self->object;
int only_name = 0; int name_only = 0;
static char *kwlist[] = {"only_name", NULL}; static char *kwlist[] = {"name_only", NULL};
if (!PyArg_ParseTupleAndKeywords(a, kwd, "|i", kwlist, &only_name)) if (!PyArg_ParseTupleAndKeywords(a, kwd, "|i", kwlist, &name_only))
return EXPP_ReturnPyObjError( PyExc_AttributeError, return EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected nothing or an int (keyword 'only_name') as argument" ); "expected nothing or an int (keyword 'name_only') as argument" );
/* if there's no obdata, try to create it */ /* if there's no obdata, try to create it */
if( object->data == NULL ) { if( object->data == NULL ) {
@@ -750,7 +750,7 @@ static PyObject *Object_getData( BPy_Object *self, PyObject *a, PyObject *kwd )
} }
/* user wants only the name of the data object */ /* user wants only the name of the data object */
if (only_name) { if (name_only) {
ID *id = &object->id; ID *id = &object->id;
data_object = Py_BuildValue("s", id->name+2); data_object = Py_BuildValue("s", id->name+2);

View File

@@ -303,7 +303,7 @@ static PyObject *M_sys_makename( PyObject * self, PyObject * args,
char *path = G.sce, *ext = NULL; char *path = G.sce, *ext = NULL;
int strip = 0; int strip = 0;
static char *kwlist[] = { "path", "ext", "strip", NULL }; static char *kwlist[] = { "path", "ext", "strip", NULL };
char *dot = NULL, *p = NULL, basename[FILE_MAXFILE]; char *dot = NULL, *p = NULL, basename[FILE_MAXDIR + FILE_MAXFILE];
char sep; char sep;
int n, len, lenext = 0; int n, len, lenext = 0;
PyObject *c; PyObject *c;
@@ -317,7 +317,7 @@ static PyObject *M_sys_makename( PyObject * self, PyObject * args,
if( ext ) if( ext )
lenext = strlen( ext ) + 1; lenext = strlen( ext ) + 1;
if( ( len + lenext ) > FILE_MAXFILE ) if( ( len + lenext ) > FILE_MAXDIR + FILE_MAXFILE )
return EXPP_ReturnPyObjError( PyExc_RuntimeError, return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"path too long" ); "path too long" );

View File

@@ -15,8 +15,8 @@ The Blender Python API Reference
- L{Bone} - L{Bone}
- L{NLA} - L{NLA}
- L{BGL} - L{BGL}
- L{Camera} - L{Camera} (*)
- L{Curve} - L{Curve} (*)
- L{Draw} - L{Draw}
- L{Effect} - L{Effect}
- L{Image} (*) - L{Image} (*)
@@ -25,11 +25,11 @@ The Blender Python API Reference
- L{Lattice} - L{Lattice}
- L{Library} - L{Library}
- L{Material} - L{Material}
- L{Mathutils} - L{Mathutils} (*)
- L{Metaball} - L{Metaball}
- L{NMesh} - L{NMesh} (*)
- L{Noise} - L{Noise}
- L{Object} - L{Object} (*)
- L{Registry} - L{Registry}
- L{Scene} - L{Scene}
- L{Radio} - L{Radio}

View File

@@ -3,7 +3,7 @@
""" """
The Blender.Camera submodule. The Blender.Camera submodule.
B{New}: scriptLink methods: L{Camera.getScriptLinks}, ... B{New}: L{Camera.getScale}, L{Camera.setScale} for ortho cameras.
Camera Data Camera Data
=========== ===========
@@ -14,7 +14,7 @@ Example::
from Blender import Camera, Object, Scene from Blender import Camera, Object, Scene
c = Camera.New('ortho') # create new ortho camera data c = Camera.New('ortho') # create new ortho camera data
c.lens = 35.0 # set lens value c.scale = 6.0 # set scale value
cur = Scene.getCurrent() # get current scene cur = Scene.getCurrent() # get current scene
ob = Object.New('Camera') # make camera object ob = Object.New('Camera') # make camera object
ob.link(c) # link camera data with this object ob.link(c) # link camera data with this object
@@ -52,7 +52,10 @@ class Camera:
@cvar name: The Camera Data name. @cvar name: The Camera Data name.
@cvar type: The Camera type: 'persp':0 or 'ortho':1. @cvar type: The Camera type: 'persp':0 or 'ortho':1.
@cvar mode: The mode flags: B{or'ed value}: 'showLimits':1, 'showMist':2. @cvar mode: The mode flags: B{or'ed value}: 'showLimits':1, 'showMist':2.
@cvar lens: The lens value in [1.0, 250.0]. @cvar lens: The lens value in [1.0, 250.0], only relevant to *persp*
cameras.
@cvar scale: The scale value in [0.01, 1000.00], only relevant to *ortho*
cameras.
@cvar clipStart: The clip start value in [0.0, 100.0]. @cvar clipStart: The clip start value in [0.0, 100.0].
@cvar clipEnd: The clip end value in [1.0, 5000.0]. @cvar clipEnd: The clip end value in [1.0, 5000.0].
@cvar drawSize: The draw size value in [0.1, 10.0]. @cvar drawSize: The draw size value in [0.1, 10.0].
@@ -133,6 +136,7 @@ class Camera:
""" """
Get the lens value. Get the lens value.
@rtype: float @rtype: float
@warn: lens is only relevant for perspective (L{getType}) cameras.
""" """
def setLens(lens): def setLens(lens):
@@ -140,6 +144,22 @@ class Camera:
Set the lens value. Set the lens value.
@type lens: float @type lens: float
@param lens: The new lens value. @param lens: The new lens value.
@warn: lens is only relevant for perspective (L{getType}) cameras.
"""
def getScale():
"""
Get the scale value.
@rtype: float
@warn: scale is only relevant for ortho (L{getType}) cameras.
"""
def setScale(scale):
"""
Set the scale value.
@type scale: float
@param scale: The new scale value in [0.01, 1000.00].
@warn: scale is only relevant for ortho (L{getType}) cameras.
""" """
def getClipStart(): def getClipStart():

View File

@@ -6,7 +6,7 @@ The Blender.Image submodule.
Image Image
===== =====
B{New}: L{Image.glLoad}, L{Image.glFree}. B{New}: L{Image.setFilename}.
This module provides access to B{Image} objects in Blender. This module provides access to B{Image} objects in Blender.
@@ -155,6 +155,15 @@ class Image:
@param name: The new name. @param name: The new name.
""" """
def setFilename(name):
"""
Change the filename of this Image object.
@type name: string
@param name: The new full filename.
@warn: use this with caution and note that the filename is truncated if
larger than 160 characters.
"""
def setXRep(xrep): def setXRep(xrep):
""" """
Texture tiling: set the number of x repetitions for this Image. Texture tiling: set the number of x repetitions for this Image.

View File

@@ -3,7 +3,8 @@
""" """
The Blender.NMesh submodule. The Blender.NMesh submodule.
B{New}: L{NMesh.getMaterials}, L{NMesh.setMaterials}. B{New}: edges class (L{NMEdge}) and nmesh methods (L{NMesh.addEdge},
L{NMesh.addEdgesData}, etc.); new optional arguments to L{NMesh.update}.
Mesh Data Mesh Data
========= =========
@@ -13,8 +14,11 @@ This module provides access to B{Mesh Data} objects in Blender.
Example:: Example::
import Blender import Blender
from Blender import NMesh, Material from Blender import NMesh, Material, Window
#
editmode = Window.EditMode() # are we in edit mode? If so ...
if editmode: Window.EditMode(0) # leave edit mode before getting the mesh
me = NMesh.GetRaw("Plane") # get the mesh data called "Plane" me = NMesh.GetRaw("Plane") # get the mesh data called "Plane"
if not me.materials: # if there are no materials ... if not me.materials: # if there are no materials ...
@@ -30,6 +34,8 @@ Example::
v.co[2] *= 2.5 v.co[2] *= 2.5
me.update() # update the real mesh in Blender me.update() # update the real mesh in Blender
if editmode: Window.EditMode(1) # optional, just being nice
@type Modes: readonly dictionary @type Modes: readonly dictionary
@type FaceFlags: readonly dictionary @type FaceFlags: readonly dictionary
@type FaceModes: readonly dictionary @type FaceModes: readonly dictionary
@@ -532,16 +538,28 @@ class NMesh:
add them. add them.
""" """
def update(recalc_normals = 0, store_edges = 0): def update(recalc_normals = 0, store_edges = 0, vertex_shade = 0):
""" """
Update the mesh in Blender. The changes made are put back to the mesh in Update the mesh in Blender. The changes made are put back to the mesh in
Blender, if available, or put in a newly created mesh object if this NMesh Blender, if available, or put in a newly created mesh object if this NMesh
wasn't already linked to one. wasn't already linked to one.
@type recalc_normals: int @type recalc_normals: int (bool)
@param recalc_normals: If given and equal to 1, the vertex normals are @param recalc_normals: if nonzero the vertex normals are recalculated.
recalculated. @type store_edges: int (bool)
@type store_edges: int @param store_edges: if nonzero, then edge data is stored.
@param store_edges: if not 0, then edge data are stored. @type vertex_shade: int (bool)
@param vertex_shade: if nonzero vertices are colored based on the
current lighting setup. To use it, be out of edit mode or else
an error will be returned.
@warn: edit mesh and normal mesh are two different structures in Blender,
synchronized upon leaving or entering edit mode. Always remember to
leave edit mode (L{Window.EditMode}) before calling this update
method, or your changes will be lost. Even better: for the same reason
programmers should leave EditMode B{before} getting a mesh, or changes
made to the editmesh in Blender may not be visible to your script
(check the example at the top of NMesh module doc).
@note: this method also redraws the 3d view and -- if 'vertex_shade' is
nonzero -- the edit buttons window.
@note: if your mesh disappears after it's updated, try @note: if your mesh disappears after it's updated, try
L{Object.Object.makeDisplayList}. 'Subsurf' meshes (see L{getMode}, L{Object.Object.makeDisplayList}. 'Subsurf' meshes (see L{getMode},
L{setMode}) need their display lists updated, too. L{setMode}) need their display lists updated, too.

View File

@@ -186,16 +186,16 @@ class Object:
other value, or no value at all will update the scene hierarchy. other value, or no value at all will update the scene hierarchy.
""" """
def getData(only_name = False): def getData(name_only = False):
""" """
Returns the Datablock object (new: or just its name) containing the Returns the Datablock object (new: or just its name) containing the
object's data. For example the Mesh, Lamp or the Camera. object's data. For example the Mesh, Lamp or the Camera.
@type only_name: bool @type name_only: bool
@param only_name: if True on nonzero, only the name of the data object @param name_only: if True on nonzero, only the name of the data object
is returned. is returned.
@rtype: Object type specific or string @rtype: Object type specific or string
@return: Depending on the type of the Object, it returns a specific object @return: Depending on the type of the Object, it returns a specific object
for the data requested. If only_name is True, it returns a string. for the data requested. If name_only is True, it returns a string.
""" """
def getDeltaLocation(): def getDeltaLocation():