New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms); - bevel_center by Loic Berthe, suggested for inclusion by jms; - doc_browser, by Daniel Dunbar (Zr) Thanks to them for the new contributions! (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?) BPython related: - Added scriptlink methods to object, lamp, camera and world. - Object: added object.makeTrack and object.clearTrack (old track method). - sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither. - doc updates and fixes. - made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data. - Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...) - Draw: added mouse wheel events. - Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate". The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
This commit is contained in:
@@ -32,11 +32,22 @@
|
||||
#include <Python.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* for open, close in Blender_Load */
|
||||
#include <fcntl.h>
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include "BLI_winstuff.h"
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#include <BIF_usiblender.h>
|
||||
#include <BLI_blenlib.h>
|
||||
#include <BLO_writefile.h>
|
||||
#include <BKE_exotic.h>
|
||||
#include <BKE_global.h>
|
||||
#include <BKE_packedFile.h>
|
||||
#include <BKE_object.h>
|
||||
#include <BPI_script.h>
|
||||
#include <BSE_headerbuttons.h>
|
||||
#include <DNA_ID.h>
|
||||
@@ -46,6 +57,7 @@
|
||||
#include <DNA_space_types.h> /* for SPACE_VIEW3D */
|
||||
#include <DNA_userdef_types.h>
|
||||
#include <BKE_ipo.h>
|
||||
#include <blendef.h>
|
||||
|
||||
#include "gen_utils.h"
|
||||
#include "modules.h"
|
||||
@@ -97,19 +109,28 @@ static char Blender_Quit_doc[] =
|
||||
"() - Quit Blender. The current data is saved as 'quit.blend' before leaving.";
|
||||
|
||||
static char Blender_Load_doc[] =
|
||||
"(filename) - Load the given .blend file. If successful, the script is ended\n\
|
||||
immediately.\n\
|
||||
"(filename) - Load the given file.\n\
|
||||
Supported formats:\n\
|
||||
Blender, DXF, Inventor 1.0 ASCII, VRML 1.0 asc, STL, Videoscape, radiogour.\n\
|
||||
\n\
|
||||
Notes:\n\
|
||||
1 - () - an empty argument loads the default .B.blend file;\n\
|
||||
2 - if the substring '.B.blend' occurs inside 'filename', the default\n\
|
||||
.B.blend file is loaded;\n\
|
||||
3 - The current data is always preserved as an autosave file, for safety;\n\
|
||||
4 - This function only works if the script where it's executed is the\n\
|
||||
only one running.";
|
||||
3 - If a Blender file is loaded the script ends immediately.\n\
|
||||
4 - The current data is always preserved as an autosave file, for safety;\n\
|
||||
5 - This function only works if the script where it's executed is the\n\
|
||||
only one running at the moment.";
|
||||
|
||||
static char Blender_Save_doc[] =
|
||||
"(filename) - Save a .blend file with the given filename.\n\
|
||||
(filename) - A file pathname that should not contain \".B.blend\" in it.";
|
||||
"(filename) - Save data to a file based on the filename's extension.\n\
|
||||
Supported are: Blender's .blend and the builtin exporters:\n\
|
||||
VRML 1.0 (.wrl), Videoscape (.obj), DXF (.dxf) and STL (.stl)\n\
|
||||
(filename) - A filename with one of the supported extensions.\n\
|
||||
Note 1: 'filename' should not contain the substring \".B.blend\" in it.\n\
|
||||
Note 2: only .blend raises an error if file wasn't saved.\n\
|
||||
\tYou can use Blender.sys.exists(filename) to make sure the file was saved\n\
|
||||
\twhen writing to one of the other formats.";
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python method structure definition. */
|
||||
@@ -295,10 +316,17 @@ static PyObject *Blender_Quit(PyObject *self)
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blender.Load
|
||||
* loads Blender's .blend, DXF, radiogour(?), STL, Videoscape,
|
||||
* Inventor 1.0 ASCII, VRML 1.0 asc.
|
||||
*/
|
||||
static PyObject *Blender_Load(PyObject *self, PyObject *args)
|
||||
{
|
||||
char *fname = NULL;
|
||||
Script *script = NULL;
|
||||
char str[32];
|
||||
int file, is_blend_file = 0;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|s", &fname))
|
||||
return EXPP_ReturnPyObjError(PyExc_TypeError,
|
||||
@@ -315,12 +343,30 @@ static PyObject *Blender_Load(PyObject *self, PyObject *args)
|
||||
return EXPP_ReturnPyObjError(PyExc_RuntimeError,
|
||||
"there are other scripts running at the Scripts win, close them first!");
|
||||
|
||||
/* trick: mark the script so that its script struct won't be freed after
|
||||
* the script is executed (to avoid a double free warning on exit): */
|
||||
script = G.main->script.first;
|
||||
script->flags |= SCRIPT_GUI;
|
||||
if (fname) {
|
||||
file = open(fname, O_BINARY|O_RDONLY);
|
||||
|
||||
BIF_write_autosave(); /* for safety let's preserve the current data */
|
||||
if (file <= 0) {
|
||||
return EXPP_ReturnPyObjError(PyExc_RuntimeError,
|
||||
"cannot open file!");
|
||||
}
|
||||
else {
|
||||
read(file, str, 31);
|
||||
close(file);
|
||||
|
||||
if (strncmp(str, "BLEN", 4) == 0) is_blend_file = 1;
|
||||
}
|
||||
}
|
||||
else is_blend_file = 1; /* .B.blend */
|
||||
|
||||
if (is_blend_file) {
|
||||
/* trick: mark the script so that its script struct won't be freed after
|
||||
* the script is executed (to avoid a double free warning on exit): */
|
||||
script = G.main->script.first;
|
||||
script->flags |= SCRIPT_GUI;
|
||||
|
||||
BIF_write_autosave(); /* for safety let's preserve the current data */
|
||||
}
|
||||
|
||||
/* for safety, any filename with .B.blend is considered the default one.
|
||||
* It doesn't seem necessary to compare file attributes (like st_ino and
|
||||
@@ -329,7 +375,7 @@ static PyObject *Blender_Load(PyObject *self, PyObject *args)
|
||||
* default one for sure. Taking any .B.blend file as the default is good
|
||||
* enough here. Note: the default file requires extra clean-up done by
|
||||
* BIF_read_homefile: freeing the user theme data. */
|
||||
if (!fname || strstr(fname, ".B.blend"))
|
||||
if (!fname || (strstr(fname, ".B.blend") && is_blend_file))
|
||||
BIF_read_homefile();
|
||||
else
|
||||
BIF_read_file(fname);
|
||||
@@ -341,7 +387,6 @@ static PyObject *Blender_Load(PyObject *self, PyObject *args)
|
||||
static PyObject *Blender_Save(PyObject *self, PyObject *args)
|
||||
{
|
||||
char *fname = NULL;
|
||||
char savefname[FILE_MAXFILE];
|
||||
int overwrite = 0, len = 0;
|
||||
char *error = NULL;
|
||||
Library *li;
|
||||
@@ -365,23 +410,37 @@ static PyObject *Blender_Save(PyObject *self, PyObject *args)
|
||||
|
||||
len = strlen(fname);
|
||||
|
||||
if (len > FILE_MAXFILE - 7) /* 6+1 for eventual .blend added below */
|
||||
if (len > FILE_MAXFILE)
|
||||
return EXPP_ReturnPyObjError(PyExc_AttributeError,
|
||||
"filename is too long!");
|
||||
else
|
||||
BLI_strncpy(savefname, fname, len + 1);
|
||||
|
||||
if (!strstr(fname, ".blend"))
|
||||
BLI_strncpy(savefname + len, ".blend", 7); /* 7: BLI_strncpy adds '\0'*/
|
||||
|
||||
if (BLI_exists(savefname) && !overwrite)
|
||||
else if (BLI_exists(fname) && !overwrite)
|
||||
return EXPP_ReturnPyObjError(PyExc_AttributeError,
|
||||
"file already exists and overwrite flag was not given.");
|
||||
|
||||
if (G.fileflags & G_AUTOPACK) packAll();
|
||||
disable_where_script(1); /* to avoid error popups in the write_* functions */
|
||||
|
||||
if (!BLO_write_file(savefname, G.fileflags, &error))
|
||||
return EXPP_ReturnPyObjError(PyExc_SystemError, error);
|
||||
if (BLI_testextensie(fname, ".blend")) {
|
||||
if (G.fileflags & G_AUTOPACK) packAll();
|
||||
if (!BLO_write_file(fname, G.fileflags, &error)) {
|
||||
disable_where_script(0);
|
||||
return EXPP_ReturnPyObjError(PyExc_SystemError, error);
|
||||
}
|
||||
}
|
||||
else if (BLI_testextensie(fname, ".dxf"))
|
||||
write_dxf(fname);
|
||||
else if (BLI_testextensie(fname, ".stl"))
|
||||
write_stl(fname);
|
||||
else if (BLI_testextensie(fname, ".wrl"))
|
||||
write_vrml(fname);
|
||||
else if (BLI_testextensie(fname, ".obj"))
|
||||
write_videoscape(fname);
|
||||
else {
|
||||
disable_where_script(0);
|
||||
return EXPP_ReturnPyObjError(PyExc_AttributeError,
|
||||
"unknown file extension.");
|
||||
}
|
||||
|
||||
disable_where_script(0);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
|
||||
@@ -113,6 +113,9 @@ static PyObject *Camera_setLens (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_setDrawSize (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_clearScriptLinks(BPy_Camera *self);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python BPy_Camera methods table: */
|
||||
@@ -154,6 +157,16 @@ static PyMethodDef BPy_Camera_methods[] = {
|
||||
"(f) - Set Camera clip end value"},
|
||||
{"setDrawSize", (PyCFunction) Camera_setDrawSize, METH_VARARGS,
|
||||
"(f) - Set Camera draw size value"},
|
||||
{"getScriptLinks", (PyCFunction)Camera_getScriptLinks, METH_VARARGS,
|
||||
"(eventname) - Get a list of this camera's scriptlinks (Text names) "
|
||||
"of the given type\n"
|
||||
"(eventname) - string: FrameChanged or Redraw."},
|
||||
{"addScriptLink", (PyCFunction)Camera_addScriptLink, METH_VARARGS,
|
||||
"(text, evt) - Add a new camera scriptlink.\n"
|
||||
"(text) - string: an existing Blender Text name;\n"
|
||||
"(evt) string: FrameChanged or Redraw."},
|
||||
{"clearScriptLinks", (PyCFunction)Camera_clearScriptLinks, METH_NOARGS,
|
||||
"() - Delete all scriptlinks from this camera."},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
@@ -739,6 +752,44 @@ Camera_setDrawSize (BPy_Camera * self, PyObject * args)
|
||||
Py_INCREF (Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
/* cam.addScriptLink */
|
||||
static PyObject *Camera_addScriptLink (BPy_Camera *self, PyObject *args)
|
||||
{
|
||||
Camera *cam = self->camera;
|
||||
ScriptLink *slink = NULL;
|
||||
|
||||
slink = &(cam)->scriptlink;
|
||||
|
||||
if (!EXPP_addScriptLink(slink, args, 0))
|
||||
return EXPP_incr_ret (Py_None);
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
/* cam.clearScriptLinks */
|
||||
static PyObject *Camera_clearScriptLinks (BPy_Camera *self)
|
||||
{
|
||||
Camera *cam = self->camera;
|
||||
ScriptLink *slink = NULL;
|
||||
|
||||
slink = &(cam)->scriptlink;
|
||||
|
||||
return EXPP_incr_ret(Py_BuildValue("i", EXPP_clearScriptLinks (slink)));
|
||||
}
|
||||
|
||||
/* cam.getScriptLinks */
|
||||
static PyObject *Camera_getScriptLinks (BPy_Camera *self, PyObject *args)
|
||||
{
|
||||
Camera *cam = self->camera;
|
||||
ScriptLink *slink = NULL;
|
||||
PyObject *ret = NULL;
|
||||
|
||||
slink = &(cam)->scriptlink;
|
||||
|
||||
ret = EXPP_getScriptLinks(slink, args, 0);
|
||||
|
||||
if (ret) return ret;
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
Camera_dealloc (BPy_Camera * self)
|
||||
|
||||
@@ -325,12 +325,13 @@ PyTypeObject Button_Type = {
|
||||
(reprfunc) Button_repr, /*tp_repr */
|
||||
};
|
||||
|
||||
|
||||
static void Button_dealloc (PyObject *self)
|
||||
{
|
||||
Button *but = (Button *) self;
|
||||
|
||||
if (but->type == 3) MEM_freeN (but->val.asstr);
|
||||
if (but->type == 3) {
|
||||
if (but->val.asstr) MEM_freeN (but->val.asstr);
|
||||
}
|
||||
|
||||
PyObject_DEL (self);
|
||||
}
|
||||
@@ -1008,7 +1009,7 @@ static PyObject *Method_String (PyObject *self, PyObject *args)
|
||||
but->val.asstr = MEM_mallocN (len + 1, "button string");
|
||||
|
||||
strncpy (but->val.asstr, newstr, len);
|
||||
but->val.asstr[len] = 0;
|
||||
but->val.asstr[len] = '\0';
|
||||
|
||||
block = Get_uiBlock ();
|
||||
if (block)
|
||||
@@ -1189,6 +1190,8 @@ PyObject *Draw_Init (void)
|
||||
EXPP_ADDCONST (LEFTMOUSE);
|
||||
EXPP_ADDCONST (MIDDLEMOUSE);
|
||||
EXPP_ADDCONST (RIGHTMOUSE);
|
||||
EXPP_ADDCONST (WHEELUPMOUSE);
|
||||
EXPP_ADDCONST (WHEELDOWNMOUSE);
|
||||
EXPP_ADDCONST (MOUSEX);
|
||||
EXPP_ADDCONST (MOUSEY);
|
||||
EXPP_ADDCONST (TIMER0);
|
||||
|
||||
@@ -29,7 +29,269 @@
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include "Lamp.h"
|
||||
#include <Python.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <BKE_main.h>
|
||||
#include <BKE_global.h>
|
||||
#include <BKE_object.h>
|
||||
#include <BKE_library.h>
|
||||
#include <BLI_blenlib.h>
|
||||
#include <DNA_lamp_types.h>
|
||||
|
||||
#include "constant.h"
|
||||
#include "rgbTuple.h"
|
||||
#include "gen_utils.h"
|
||||
#include "modules.h"
|
||||
#include "bpy_types.h" /* for the BPy_Lamp declaration */
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python BPy_Lamp defaults: */
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Lamp types */
|
||||
|
||||
#define EXPP_LAMP_TYPE_LAMP 0
|
||||
#define EXPP_LAMP_TYPE_SUN 1
|
||||
#define EXPP_LAMP_TYPE_SPOT 2
|
||||
#define EXPP_LAMP_TYPE_HEMI 3
|
||||
|
||||
/* Lamp mode flags */
|
||||
|
||||
#define EXPP_LAMP_MODE_SHADOWS 1
|
||||
#define EXPP_LAMP_MODE_HALO 2
|
||||
#define EXPP_LAMP_MODE_LAYER 4
|
||||
#define EXPP_LAMP_MODE_QUAD 8
|
||||
#define EXPP_LAMP_MODE_NEGATIVE 16
|
||||
#define EXPP_LAMP_MODE_ONLYSHADOW 32
|
||||
#define EXPP_LAMP_MODE_SPHERE 64
|
||||
#define EXPP_LAMP_MODE_SQUARE 128
|
||||
#define EXPP_LAMP_MODE_TEXTURE 256
|
||||
#define EXPP_LAMP_MODE_OSATEX 512
|
||||
#define EXPP_LAMP_MODE_DEEPSHADOW 1024
|
||||
#define EXPP_LAMP_MODE_NODIFFUSE 2048
|
||||
#define EXPP_LAMP_MODE_NOSPECULAR 4096
|
||||
/* Lamp MIN, MAX values */
|
||||
|
||||
#define EXPP_LAMP_SAMPLES_MIN 1
|
||||
#define EXPP_LAMP_SAMPLES_MAX 16
|
||||
#define EXPP_LAMP_BUFFERSIZE_MIN 512
|
||||
#define EXPP_LAMP_BUFFERSIZE_MAX 5120
|
||||
#define EXPP_LAMP_ENERGY_MIN 0.0
|
||||
#define EXPP_LAMP_ENERGY_MAX 10.0
|
||||
#define EXPP_LAMP_DIST_MIN 0.1
|
||||
#define EXPP_LAMP_DIST_MAX 5000.0
|
||||
#define EXPP_LAMP_SPOTSIZE_MIN 1.0
|
||||
#define EXPP_LAMP_SPOTSIZE_MAX 180.0
|
||||
#define EXPP_LAMP_SPOTBLEND_MIN 0.00
|
||||
#define EXPP_LAMP_SPOTBLEND_MAX 1.00
|
||||
#define EXPP_LAMP_CLIPSTART_MIN 0.1
|
||||
#define EXPP_LAMP_CLIPSTART_MAX 1000.0
|
||||
#define EXPP_LAMP_CLIPEND_MIN 1.0
|
||||
#define EXPP_LAMP_CLIPEND_MAX 5000.0
|
||||
#define EXPP_LAMP_BIAS_MIN 0.01
|
||||
#define EXPP_LAMP_BIAS_MAX 5.00
|
||||
#define EXPP_LAMP_SOFTNESS_MIN 1.0
|
||||
#define EXPP_LAMP_SOFTNESS_MAX 100.0
|
||||
#define EXPP_LAMP_HALOINT_MIN 0.0
|
||||
#define EXPP_LAMP_HALOINT_MAX 5.0
|
||||
#define EXPP_LAMP_HALOSTEP_MIN 0
|
||||
#define EXPP_LAMP_HALOSTEP_MAX 12
|
||||
#define EXPP_LAMP_QUAD1_MIN 0.0
|
||||
#define EXPP_LAMP_QUAD1_MAX 1.0
|
||||
#define EXPP_LAMP_QUAD2_MIN 0.0
|
||||
#define EXPP_LAMP_QUAD2_MAX 1.0
|
||||
#define EXPP_LAMP_COL_MIN 0.0
|
||||
#define EXPP_LAMP_COL_MAX 1.0
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python API function prototypes for the Lamp module. */
|
||||
/*****************************************************************************/
|
||||
static PyObject *M_Lamp_New (PyObject *self, PyObject *args, PyObject *keywords);
|
||||
static PyObject *M_Lamp_Get (PyObject *self, PyObject *args);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* The following string definitions are used for documentation strings. */
|
||||
/* In Python these will be written to the console when doing a */
|
||||
/* Blender.Lamp.__doc__ */
|
||||
/*****************************************************************************/
|
||||
static char M_Lamp_doc[] =
|
||||
"The Blender Lamp module\n\n\
|
||||
This module provides control over **Lamp Data** objects in Blender.\n\n\
|
||||
Example::\n\n\
|
||||
from Blender import Lamp\n\
|
||||
l = Lamp.New('Spot') # create new 'Spot' lamp data\n\
|
||||
l.setMode('square', 'shadow') # set these two lamp mode flags\n\
|
||||
ob = Object.New('Lamp') # create new lamp object\n\
|
||||
ob.link(l) # link lamp obj with lamp data\n";
|
||||
|
||||
static char M_Lamp_New_doc[] =
|
||||
"Lamp.New (type = 'Lamp', name = 'LampData'):\n\
|
||||
Return a new Lamp Data object with the given type and name.";
|
||||
|
||||
static char M_Lamp_Get_doc[] =
|
||||
"Lamp.Get (name = None):\n\
|
||||
Return the Lamp Data with the given name, None if not found, or\n\
|
||||
Return a list with all Lamp Data objects in the current scene,\n\
|
||||
if no argument was given.";
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python method structure definition for Blender.Lamp module: */
|
||||
/*****************************************************************************/
|
||||
struct PyMethodDef M_Lamp_methods[] = {
|
||||
{"New",(PyCFunction)M_Lamp_New, METH_VARARGS|METH_KEYWORDS,
|
||||
M_Lamp_New_doc},
|
||||
{"Get", M_Lamp_Get, METH_VARARGS, M_Lamp_Get_doc},
|
||||
{"get", M_Lamp_Get, METH_VARARGS, M_Lamp_Get_doc},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python BPy_Lamp methods declarations: */
|
||||
/*****************************************************************************/
|
||||
static PyObject *Lamp_getName(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getType(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getMode(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getSamples(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getBufferSize(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getHaloStep(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getEnergy(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getDist(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getSpotSize(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getSpotBlend(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getClipStart(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getClipEnd(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getBias(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getSoftness(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getHaloInt(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getQuad1(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getQuad2(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getCol(BPy_Lamp *self);
|
||||
static PyObject *Lamp_setName(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setType(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setIntType(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setMode(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setIntMode(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setSamples(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setBufferSize(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setHaloStep(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setEnergy(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setDist(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setSpotSize(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setSpotBlend(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setClipStart(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setClipEnd(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setBias(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setSoftness(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setHaloInt(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setQuad1(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setQuad2(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setCol(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setColorComponent(BPy_Lamp *self, char *key,
|
||||
PyObject *args);
|
||||
static PyObject *Lamp_getScriptLinks(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_addScriptLink(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_clearScriptLinks(BPy_Lamp *self);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python BPy_Lamp methods table: */
|
||||
/*****************************************************************************/
|
||||
static PyMethodDef BPy_Lamp_methods[] = {
|
||||
/* name, method, flags, doc */
|
||||
{"getName", (PyCFunction)Lamp_getName, METH_NOARGS,
|
||||
"() - return Lamp name"},
|
||||
{"getType", (PyCFunction)Lamp_getType, METH_NOARGS,
|
||||
"() - return Lamp type - 'Lamp':0, 'Sun':1, 'Spot':2, 'Hemi':3"},
|
||||
{"getMode", (PyCFunction)Lamp_getMode, METH_NOARGS,
|
||||
"() - return Lamp mode flags (or'ed value)"},
|
||||
{"getSamples", (PyCFunction)Lamp_getSamples, METH_NOARGS,
|
||||
"() - return Lamp samples value"},
|
||||
{"getBufferSize", (PyCFunction)Lamp_getBufferSize, METH_NOARGS,
|
||||
"() - return Lamp buffer size value"},
|
||||
{"getHaloStep", (PyCFunction)Lamp_getHaloStep, METH_NOARGS,
|
||||
"() - return Lamp halo step value"},
|
||||
{"getEnergy", (PyCFunction)Lamp_getEnergy, METH_NOARGS,
|
||||
"() - return Lamp energy value"},
|
||||
{"getDist", (PyCFunction)Lamp_getDist, METH_NOARGS,
|
||||
"() - return Lamp clipping distance value"},
|
||||
{"getSpotSize", (PyCFunction)Lamp_getSpotSize, METH_NOARGS,
|
||||
"() - return Lamp spot size value"},
|
||||
{"getSpotBlend", (PyCFunction)Lamp_getSpotBlend, METH_NOARGS,
|
||||
"() - return Lamp spot blend value"},
|
||||
{"getClipStart", (PyCFunction)Lamp_getClipStart, METH_NOARGS,
|
||||
"() - return Lamp clip start value"},
|
||||
{"getClipEnd", (PyCFunction)Lamp_getClipEnd, METH_NOARGS,
|
||||
"() - return Lamp clip end value"},
|
||||
{"getBias", (PyCFunction)Lamp_getBias, METH_NOARGS,
|
||||
"() - return Lamp bias value"},
|
||||
{"getSoftness", (PyCFunction)Lamp_getSoftness, METH_NOARGS,
|
||||
"() - return Lamp softness value"},
|
||||
{"getHaloInt", (PyCFunction)Lamp_getHaloInt, METH_NOARGS,
|
||||
"() - return Lamp halo intensity value"},
|
||||
{"getQuad1", (PyCFunction)Lamp_getQuad1, METH_NOARGS,
|
||||
"() - return light intensity value #1 for a Quad Lamp"},
|
||||
{"getQuad2", (PyCFunction)Lamp_getQuad2, METH_NOARGS,
|
||||
"() - return light intensity value #2 for a Quad Lamp"},
|
||||
{"getCol", (PyCFunction)Lamp_getCol, METH_NOARGS,
|
||||
"() - return light rgb color triplet"},
|
||||
{"setName", (PyCFunction)Lamp_setName, METH_VARARGS,
|
||||
"(str) - rename Lamp"},
|
||||
{"setType", (PyCFunction)Lamp_setType, METH_VARARGS,
|
||||
"(str) - change Lamp type, which can be 'persp' or 'ortho'"},
|
||||
{"setMode", (PyCFunction)Lamp_setMode, METH_VARARGS,
|
||||
"([up to eight str's]) - Set Lamp mode flag(s)"},
|
||||
{"setSamples", (PyCFunction)Lamp_setSamples, METH_VARARGS,
|
||||
"(int) - change Lamp samples value"},
|
||||
{"setBufferSize", (PyCFunction)Lamp_setBufferSize, METH_VARARGS,
|
||||
"(int) - change Lamp buffer size value"},
|
||||
{"setHaloStep", (PyCFunction)Lamp_setHaloStep, METH_VARARGS,
|
||||
"(int) - change Lamp halo step value"},
|
||||
{"setEnergy", (PyCFunction)Lamp_setEnergy, METH_VARARGS,
|
||||
"(float) - change Lamp energy value"},
|
||||
{"setDist", (PyCFunction)Lamp_setDist, METH_VARARGS,
|
||||
"(float) - change Lamp clipping distance value"},
|
||||
{"setSpotSize", (PyCFunction)Lamp_setSpotSize, METH_VARARGS,
|
||||
"(float) - change Lamp spot size value"},
|
||||
{"setSpotBlend", (PyCFunction)Lamp_setSpotBlend, METH_VARARGS,
|
||||
"(float) - change Lamp spot blend value"},
|
||||
{"setClipStart", (PyCFunction)Lamp_setClipStart, METH_VARARGS,
|
||||
"(float) - change Lamp clip start value"},
|
||||
{"setClipEnd", (PyCFunction)Lamp_setClipEnd, METH_VARARGS,
|
||||
"(float) - change Lamp clip end value"},
|
||||
{"setBias", (PyCFunction)Lamp_setBias, METH_VARARGS,
|
||||
"(float) - change Lamp draw size value"},
|
||||
{"setSoftness", (PyCFunction)Lamp_setSoftness, METH_VARARGS,
|
||||
"(float) - change Lamp softness value"},
|
||||
{"setHaloInt", (PyCFunction)Lamp_setHaloInt, METH_VARARGS,
|
||||
"(float) - change Lamp halo intensity value"},
|
||||
{"setQuad1", (PyCFunction)Lamp_setQuad1, METH_VARARGS,
|
||||
"(float) - change light intensity value #1 for a Quad Lamp"},
|
||||
{"setQuad2", (PyCFunction)Lamp_setQuad2, METH_VARARGS,
|
||||
"(float) - change light intensity value #2 for a Quad Lamp"},
|
||||
{"setCol", (PyCFunction)Lamp_setCol, METH_VARARGS,
|
||||
"(f,f,f) or ([f,f,f]) - change light's rgb color triplet"},
|
||||
{"getScriptLinks", (PyCFunction)Lamp_getScriptLinks, METH_VARARGS,
|
||||
"(eventname) - Get a list of this lamp's scriptlinks (Text names) "
|
||||
"of the given type\n"
|
||||
"(eventname) - string: FrameChanged or Redraw."},
|
||||
{"addScriptLink", (PyCFunction)Lamp_addScriptLink, METH_VARARGS,
|
||||
"(text, evt) - Add a new lamp scriptlink.\n"
|
||||
"(text) - string: an existing Blender Text name;\n"
|
||||
"(evt) string: FrameChanged or Redraw."},
|
||||
{"clearScriptLinks", (PyCFunction)Lamp_clearScriptLinks, METH_NOARGS,
|
||||
"() - Delete all scriptlinks from this lamp."},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python TypeLamp callback function prototypes: */
|
||||
/*****************************************************************************/
|
||||
static void Lamp_dealloc (BPy_Lamp *lamp);
|
||||
static PyObject *Lamp_getAttr (BPy_Lamp *lamp, char *name);
|
||||
static int Lamp_setAttr (BPy_Lamp *lamp, char *name, PyObject *v);
|
||||
static int Lamp_compare (BPy_Lamp *a, BPy_Lamp *b);
|
||||
static PyObject *Lamp_repr (BPy_Lamp *lamp);
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python TypeLamp structure definition: */
|
||||
@@ -859,6 +1121,45 @@ static PyObject *Lamp_setCol(BPy_Lamp *self, PyObject *args)
|
||||
return rgbTuple_setCol(self->color, args);
|
||||
}
|
||||
|
||||
/* lamp.addScriptLink */
|
||||
static PyObject *Lamp_addScriptLink (BPy_Lamp *self, PyObject *args)
|
||||
{
|
||||
Lamp *lamp = self->lamp;
|
||||
ScriptLink *slink = NULL;
|
||||
|
||||
slink = &(lamp)->scriptlink;
|
||||
|
||||
if (!EXPP_addScriptLink(slink, args, 0))
|
||||
return EXPP_incr_ret (Py_None);
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
/* lamp.clearScriptLinks */
|
||||
static PyObject *Lamp_clearScriptLinks (BPy_Lamp *self)
|
||||
{
|
||||
Lamp *lamp = self->lamp;
|
||||
ScriptLink *slink = NULL;
|
||||
|
||||
slink = &(lamp)->scriptlink;
|
||||
|
||||
return EXPP_incr_ret(Py_BuildValue("i", EXPP_clearScriptLinks (slink)));
|
||||
}
|
||||
|
||||
/* mat.getScriptLinks */
|
||||
static PyObject *Lamp_getScriptLinks (BPy_Lamp *self, PyObject *args)
|
||||
{
|
||||
Lamp *lamp = self->lamp;
|
||||
ScriptLink *slink = NULL;
|
||||
PyObject *ret = NULL;
|
||||
|
||||
slink = &(lamp)->scriptlink;
|
||||
|
||||
ret = EXPP_getScriptLinks(slink, args, 0);
|
||||
|
||||
if (ret) return ret;
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Lamp_dealloc */
|
||||
/* Description: This is a callback function for the BPy_Lamp type. It is */
|
||||
|
||||
@@ -32,256 +32,4 @@
|
||||
#ifndef EXPP_LAMP_H
|
||||
#define EXPP_LAMP_H
|
||||
|
||||
#include <Python.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <BKE_main.h>
|
||||
#include <BKE_global.h>
|
||||
#include <BKE_object.h>
|
||||
#include <BKE_library.h>
|
||||
#include <BLI_blenlib.h>
|
||||
#include <DNA_lamp_types.h>
|
||||
|
||||
#include "constant.h"
|
||||
#include "rgbTuple.h"
|
||||
#include "gen_utils.h"
|
||||
#include "modules.h"
|
||||
#include "bpy_types.h" /* for the BPy_Lamp declaration */
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python BPy_Lamp defaults: */
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Lamp types */
|
||||
|
||||
#define EXPP_LAMP_TYPE_LAMP 0
|
||||
#define EXPP_LAMP_TYPE_SUN 1
|
||||
#define EXPP_LAMP_TYPE_SPOT 2
|
||||
#define EXPP_LAMP_TYPE_HEMI 3
|
||||
|
||||
/* Lamp mode flags */
|
||||
|
||||
#define EXPP_LAMP_MODE_SHADOWS 1
|
||||
#define EXPP_LAMP_MODE_HALO 2
|
||||
#define EXPP_LAMP_MODE_LAYER 4
|
||||
#define EXPP_LAMP_MODE_QUAD 8
|
||||
#define EXPP_LAMP_MODE_NEGATIVE 16
|
||||
#define EXPP_LAMP_MODE_ONLYSHADOW 32
|
||||
#define EXPP_LAMP_MODE_SPHERE 64
|
||||
#define EXPP_LAMP_MODE_SQUARE 128
|
||||
#define EXPP_LAMP_MODE_TEXTURE 256
|
||||
#define EXPP_LAMP_MODE_OSATEX 512
|
||||
#define EXPP_LAMP_MODE_DEEPSHADOW 1024
|
||||
#define EXPP_LAMP_MODE_NODIFFUSE 2048
|
||||
#define EXPP_LAMP_MODE_NOSPECULAR 4096
|
||||
/* Lamp MIN, MAX values */
|
||||
|
||||
#define EXPP_LAMP_SAMPLES_MIN 1
|
||||
#define EXPP_LAMP_SAMPLES_MAX 16
|
||||
#define EXPP_LAMP_BUFFERSIZE_MIN 512
|
||||
#define EXPP_LAMP_BUFFERSIZE_MAX 5120
|
||||
#define EXPP_LAMP_ENERGY_MIN 0.0
|
||||
#define EXPP_LAMP_ENERGY_MAX 10.0
|
||||
#define EXPP_LAMP_DIST_MIN 0.1
|
||||
#define EXPP_LAMP_DIST_MAX 5000.0
|
||||
#define EXPP_LAMP_SPOTSIZE_MIN 1.0
|
||||
#define EXPP_LAMP_SPOTSIZE_MAX 180.0
|
||||
#define EXPP_LAMP_SPOTBLEND_MIN 0.00
|
||||
#define EXPP_LAMP_SPOTBLEND_MAX 1.00
|
||||
#define EXPP_LAMP_CLIPSTART_MIN 0.1
|
||||
#define EXPP_LAMP_CLIPSTART_MAX 1000.0
|
||||
#define EXPP_LAMP_CLIPEND_MIN 1.0
|
||||
#define EXPP_LAMP_CLIPEND_MAX 5000.0
|
||||
#define EXPP_LAMP_BIAS_MIN 0.01
|
||||
#define EXPP_LAMP_BIAS_MAX 5.00
|
||||
#define EXPP_LAMP_SOFTNESS_MIN 1.0
|
||||
#define EXPP_LAMP_SOFTNESS_MAX 100.0
|
||||
#define EXPP_LAMP_HALOINT_MIN 0.0
|
||||
#define EXPP_LAMP_HALOINT_MAX 5.0
|
||||
#define EXPP_LAMP_HALOSTEP_MIN 0
|
||||
#define EXPP_LAMP_HALOSTEP_MAX 12
|
||||
#define EXPP_LAMP_QUAD1_MIN 0.0
|
||||
#define EXPP_LAMP_QUAD1_MAX 1.0
|
||||
#define EXPP_LAMP_QUAD2_MIN 0.0
|
||||
#define EXPP_LAMP_QUAD2_MAX 1.0
|
||||
#define EXPP_LAMP_COL_MIN 0.0
|
||||
#define EXPP_LAMP_COL_MAX 1.0
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python API function prototypes for the Lamp module. */
|
||||
/*****************************************************************************/
|
||||
static PyObject *M_Lamp_New (PyObject *self, PyObject *args, PyObject *keywords);
|
||||
static PyObject *M_Lamp_Get (PyObject *self, PyObject *args);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* The following string definitions are used for documentation strings. */
|
||||
/* In Python these will be written to the console when doing a */
|
||||
/* Blender.Lamp.__doc__ */
|
||||
/*****************************************************************************/
|
||||
char M_Lamp_doc[] =
|
||||
"The Blender Lamp module\n\n\
|
||||
This module provides control over **Lamp Data** objects in Blender.\n\n\
|
||||
Example::\n\n\
|
||||
from Blender import Lamp\n\
|
||||
l = Lamp.New('Spot') # create new 'Spot' lamp data\n\
|
||||
l.setMode('square', 'shadow') # set these two lamp mode flags\n\
|
||||
ob = Object.New('Lamp') # create new lamp object\n\
|
||||
ob.link(l) # link lamp obj with lamp data\n";
|
||||
|
||||
char M_Lamp_New_doc[] =
|
||||
"Lamp.New (type = 'Lamp', name = 'LampData'):\n\
|
||||
Return a new Lamp Data object with the given type and name.";
|
||||
|
||||
char M_Lamp_Get_doc[] =
|
||||
"Lamp.Get (name = None):\n\
|
||||
Return the Lamp Data with the given name, None if not found, or\n\
|
||||
Return a list with all Lamp Data objects in the current scene,\n\
|
||||
if no argument was given.";
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python method structure definition for Blender.Lamp module: */
|
||||
/*****************************************************************************/
|
||||
struct PyMethodDef M_Lamp_methods[] = {
|
||||
{"New",(PyCFunction)M_Lamp_New, METH_VARARGS|METH_KEYWORDS,
|
||||
M_Lamp_New_doc},
|
||||
{"Get", M_Lamp_Get, METH_VARARGS, M_Lamp_Get_doc},
|
||||
{"get", M_Lamp_Get, METH_VARARGS, M_Lamp_Get_doc},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python BPy_Lamp methods declarations: */
|
||||
/*****************************************************************************/
|
||||
static PyObject *Lamp_getName(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getType(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getMode(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getSamples(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getBufferSize(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getHaloStep(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getEnergy(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getDist(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getSpotSize(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getSpotBlend(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getClipStart(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getClipEnd(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getBias(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getSoftness(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getHaloInt(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getQuad1(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getQuad2(BPy_Lamp *self);
|
||||
static PyObject *Lamp_getCol(BPy_Lamp *self);
|
||||
static PyObject *Lamp_setName(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setType(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setIntType(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setMode(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setIntMode(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setSamples(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setBufferSize(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setHaloStep(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setEnergy(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setDist(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setSpotSize(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setSpotBlend(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setClipStart(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setClipEnd(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setBias(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setSoftness(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setHaloInt(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setQuad1(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setQuad2(BPy_Lamp *self, PyObject *args);
|
||||
static PyObject *Lamp_setCol(BPy_Lamp *self, PyObject *args);
|
||||
|
||||
static PyObject *Lamp_setColorComponent(BPy_Lamp *self, char *key,
|
||||
PyObject *args);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python BPy_Lamp methods table: */
|
||||
/*****************************************************************************/
|
||||
static PyMethodDef BPy_Lamp_methods[] = {
|
||||
/* name, method, flags, doc */
|
||||
{"getName", (PyCFunction)Lamp_getName, METH_NOARGS,
|
||||
"() - return Lamp name"},
|
||||
{"getType", (PyCFunction)Lamp_getType, METH_NOARGS,
|
||||
"() - return Lamp type - 'Lamp':0, 'Sun':1, 'Spot':2, 'Hemi':3"},
|
||||
{"getMode", (PyCFunction)Lamp_getMode, METH_NOARGS,
|
||||
"() - return Lamp mode flags (or'ed value)"},
|
||||
{"getSamples", (PyCFunction)Lamp_getSamples, METH_NOARGS,
|
||||
"() - return Lamp samples value"},
|
||||
{"getBufferSize", (PyCFunction)Lamp_getBufferSize, METH_NOARGS,
|
||||
"() - return Lamp buffer size value"},
|
||||
{"getHaloStep", (PyCFunction)Lamp_getHaloStep, METH_NOARGS,
|
||||
"() - return Lamp halo step value"},
|
||||
{"getEnergy", (PyCFunction)Lamp_getEnergy, METH_NOARGS,
|
||||
"() - return Lamp energy value"},
|
||||
{"getDist", (PyCFunction)Lamp_getDist, METH_NOARGS,
|
||||
"() - return Lamp clipping distance value"},
|
||||
{"getSpotSize", (PyCFunction)Lamp_getSpotSize, METH_NOARGS,
|
||||
"() - return Lamp spot size value"},
|
||||
{"getSpotBlend", (PyCFunction)Lamp_getSpotBlend, METH_NOARGS,
|
||||
"() - return Lamp spot blend value"},
|
||||
{"getClipStart", (PyCFunction)Lamp_getClipStart, METH_NOARGS,
|
||||
"() - return Lamp clip start value"},
|
||||
{"getClipEnd", (PyCFunction)Lamp_getClipEnd, METH_NOARGS,
|
||||
"() - return Lamp clip end value"},
|
||||
{"getBias", (PyCFunction)Lamp_getBias, METH_NOARGS,
|
||||
"() - return Lamp bias value"},
|
||||
{"getSoftness", (PyCFunction)Lamp_getSoftness, METH_NOARGS,
|
||||
"() - return Lamp softness value"},
|
||||
{"getHaloInt", (PyCFunction)Lamp_getHaloInt, METH_NOARGS,
|
||||
"() - return Lamp halo intensity value"},
|
||||
{"getQuad1", (PyCFunction)Lamp_getQuad1, METH_NOARGS,
|
||||
"() - return light intensity value #1 for a Quad Lamp"},
|
||||
{"getQuad2", (PyCFunction)Lamp_getQuad2, METH_NOARGS,
|
||||
"() - return light intensity value #2 for a Quad Lamp"},
|
||||
{"getCol", (PyCFunction)Lamp_getCol, METH_NOARGS,
|
||||
"() - return light rgb color triplet"},
|
||||
{"setName", (PyCFunction)Lamp_setName, METH_VARARGS,
|
||||
"(str) - rename Lamp"},
|
||||
{"setType", (PyCFunction)Lamp_setType, METH_VARARGS,
|
||||
"(str) - change Lamp type, which can be 'persp' or 'ortho'"},
|
||||
{"setMode", (PyCFunction)Lamp_setMode, METH_VARARGS,
|
||||
"([up to eight str's]) - Set Lamp mode flag(s)"},
|
||||
{"setSamples", (PyCFunction)Lamp_setSamples, METH_VARARGS,
|
||||
"(int) - change Lamp samples value"},
|
||||
{"setBufferSize", (PyCFunction)Lamp_setBufferSize, METH_VARARGS,
|
||||
"(int) - change Lamp buffer size value"},
|
||||
{"setHaloStep", (PyCFunction)Lamp_setHaloStep, METH_VARARGS,
|
||||
"(int) - change Lamp halo step value"},
|
||||
{"setEnergy", (PyCFunction)Lamp_setEnergy, METH_VARARGS,
|
||||
"(float) - change Lamp energy value"},
|
||||
{"setDist", (PyCFunction)Lamp_setDist, METH_VARARGS,
|
||||
"(float) - change Lamp clipping distance value"},
|
||||
{"setSpotSize", (PyCFunction)Lamp_setSpotSize, METH_VARARGS,
|
||||
"(float) - change Lamp spot size value"},
|
||||
{"setSpotBlend", (PyCFunction)Lamp_setSpotBlend, METH_VARARGS,
|
||||
"(float) - change Lamp spot blend value"},
|
||||
{"setClipStart", (PyCFunction)Lamp_setClipStart, METH_VARARGS,
|
||||
"(float) - change Lamp clip start value"},
|
||||
{"setClipEnd", (PyCFunction)Lamp_setClipEnd, METH_VARARGS,
|
||||
"(float) - change Lamp clip end value"},
|
||||
{"setBias", (PyCFunction)Lamp_setBias, METH_VARARGS,
|
||||
"(float) - change Lamp draw size value"},
|
||||
{"setSoftness", (PyCFunction)Lamp_setSoftness, METH_VARARGS,
|
||||
"(float) - change Lamp softness value"},
|
||||
{"setHaloInt", (PyCFunction)Lamp_setHaloInt, METH_VARARGS,
|
||||
"(float) - change Lamp halo intensity value"},
|
||||
{"setQuad1", (PyCFunction)Lamp_setQuad1, METH_VARARGS,
|
||||
"(float) - change light intensity value #1 for a Quad Lamp"},
|
||||
{"setQuad2", (PyCFunction)Lamp_setQuad2, METH_VARARGS,
|
||||
"(float) - change light intensity value #2 for a Quad Lamp"},
|
||||
{"setCol", (PyCFunction)Lamp_setCol, METH_VARARGS,
|
||||
"(f,f,f) or ([f,f,f]) - change light's rgb color triplet"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python TypeLamp callback function prototypes: */
|
||||
/*****************************************************************************/
|
||||
static void Lamp_dealloc (BPy_Lamp *lamp);
|
||||
static PyObject *Lamp_getAttr (BPy_Lamp *lamp, char *name);
|
||||
static int Lamp_setAttr (BPy_Lamp *lamp, char *name, PyObject *v);
|
||||
static int Lamp_compare (BPy_Lamp *a, BPy_Lamp *b);
|
||||
static PyObject *Lamp_repr (BPy_Lamp *lamp);
|
||||
|
||||
|
||||
#endif /* EXPP_LAMP_H */
|
||||
|
||||
@@ -99,6 +99,7 @@ struct PyMethodDef M_Object_methods[] = {
|
||||
static PyObject *Object_buildParts (BPy_Object *self);
|
||||
static PyObject *Object_clearIpo (BPy_Object *self);
|
||||
static PyObject *Object_clrParent (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_clearTrack (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_getData (BPy_Object *self);
|
||||
static PyObject *Object_getDeltaLocation (BPy_Object *self);
|
||||
static PyObject *Object_getDrawMode (BPy_Object *self);
|
||||
@@ -133,6 +134,7 @@ static PyObject *Object_setMaterials (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_setName (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_setSize (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_setTimeOffset (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_makeTrack (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_shareFrom (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_Select (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_getAllProperties (BPy_Object *self);
|
||||
@@ -141,6 +143,9 @@ static PyObject *Object_removeProperty(BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_getProperty(BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_removeAllProperties(BPy_Object *self);
|
||||
static PyObject *Object_copyAllPropertiesTo(BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_getScriptLinks(BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_addScriptLink(BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_clearScriptLinks(BPy_Object *self);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python BPy_Object methods table: */
|
||||
@@ -153,6 +158,10 @@ static PyMethodDef BPy_Object_methods[] = {
|
||||
"Returns the ipo of this object (if any) "},
|
||||
{"clrParent", (PyCFunction)Object_clrParent, METH_VARARGS,
|
||||
"Clears parent object. Optionally specify:\n\
|
||||
mode\n\tnonzero: Keep object transform\nfast\n\t>0: Don't update scene \
|
||||
hierarchy (faster)"},
|
||||
{"clearTrack", (PyCFunction)Object_clearTrack, METH_VARARGS,
|
||||
"Make this object not track another anymore. Optionally specify:\n\
|
||||
mode\n\t2: Keep object transform\nfast\n\t>0: Don't update scene \
|
||||
hierarchy (faster)"},
|
||||
{"getData", (PyCFunction)Object_getData, METH_NOARGS,
|
||||
@@ -203,7 +212,7 @@ match the Object's type, so you cannot link a Lamp to a Mesh type object."},
|
||||
"Makes the object the parent of the objects provided in the \n\
|
||||
argument which must be a list of valid Objects. Optional extra arguments:\n\
|
||||
mode:\n\t0: make parent with inverse\n\t1: without inverse\n\
|
||||
fase:\n\t0: update scene hierarchy automatically\n\t\
|
||||
fast:\n\t0: update scene hierarchy automatically\n\t\
|
||||
don't update scene hierarchy (faster). In this case, you must\n\t\
|
||||
explicitely update the Scene hierarchy."},
|
||||
{"materialUsage", (PyCFunction)Object_materialUsage, METH_VARARGS,
|
||||
@@ -237,6 +246,12 @@ objects."},
|
||||
triple."},
|
||||
{"setTimeOffset", (PyCFunction)Object_setTimeOffset, METH_VARARGS,
|
||||
"Set the object's time offset."},
|
||||
{"makeTrack", (PyCFunction)Object_makeTrack, METH_VARARGS,
|
||||
"(trackedobj, fast = 0) - Make this object track another.\n\
|
||||
(trackedobj) - the object that will be tracked.\n\
|
||||
(fast = 0) - if 0: update the scene hierarchy automatically. If you\n\
|
||||
set 'fast' to a nonzero value, don't forget to update the scene yourself\n\
|
||||
(see scene.update())."},
|
||||
{"shareFrom", (PyCFunction)Object_shareFrom, METH_VARARGS,
|
||||
"Link data of self with object specified in the argument. This\n\
|
||||
works only if self and the object specified are of the same type."},
|
||||
@@ -259,6 +274,16 @@ works only if self and the object specified are of the same type."},
|
||||
"() - removeAll a properties from this object"},
|
||||
{"copyAllPropertiesTo", (PyCFunction)Object_copyAllPropertiesTo, METH_VARARGS,
|
||||
"() - copy all properties from this object to another object"},
|
||||
{"getScriptLinks", (PyCFunction)Object_getScriptLinks, METH_VARARGS,
|
||||
"(eventname) - Get a list of this object's scriptlinks (Text names) "
|
||||
"of the given type\n"
|
||||
"(eventname) - string: FrameChanged or Redraw."},
|
||||
{"addScriptLink", (PyCFunction)Object_addScriptLink, METH_VARARGS,
|
||||
"(text, evt) - Add a new object scriptlink.\n"
|
||||
"(text) - string: an existing Blender Text name;\n"
|
||||
"(evt) string: FrameChanged or Redraw."},
|
||||
{"clearScriptLinks", (PyCFunction)Object_clearScriptLinks, METH_NOARGS,
|
||||
"() - Delete all scriptlinks from this object."},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
@@ -620,6 +645,35 @@ static PyObject *Object_clrParent (BPy_Object *self, PyObject *args)
|
||||
return (Py_None);
|
||||
}
|
||||
|
||||
static PyObject *Object_clearTrack (BPy_Object *self, PyObject *args)
|
||||
{
|
||||
int mode=0;
|
||||
int fast=0;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "|ii", &mode, &fast))
|
||||
{
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected one or two integers as arguments"));
|
||||
}
|
||||
|
||||
/* Remove the link only, the object is still in the scene. */
|
||||
self->object->track = NULL;
|
||||
|
||||
if (mode)
|
||||
{
|
||||
/* Keep transform */
|
||||
apply_obmat (self->object);
|
||||
}
|
||||
|
||||
if (!fast)
|
||||
{
|
||||
sort_baselist (G.scene);
|
||||
}
|
||||
|
||||
Py_INCREF (Py_None);
|
||||
return (Py_None);
|
||||
}
|
||||
|
||||
/* adds object data to a Blender object, if object->data = NULL */
|
||||
int EXPP_add_obdata(struct Object *object)
|
||||
{
|
||||
@@ -1600,6 +1654,23 @@ static PyObject *Object_setTimeOffset (BPy_Object *self, PyObject *args)
|
||||
return (Py_None);
|
||||
}
|
||||
|
||||
static PyObject *Object_makeTrack (BPy_Object *self, PyObject *args)
|
||||
{
|
||||
BPy_Object *tracked = NULL;
|
||||
Object *ob = self->object;
|
||||
int fast = 0;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "O!|i", &Object_Type, &tracked, &fast))
|
||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"expected an object and optionally also an int as arguments.");
|
||||
|
||||
ob->track = tracked->object;
|
||||
|
||||
if (!fast) sort_baselist(G.scene);
|
||||
|
||||
return EXPP_incr_ret(Py_None);
|
||||
}
|
||||
|
||||
static PyObject *Object_shareFrom (BPy_Object *self, PyObject *args)
|
||||
{
|
||||
BPy_Object * object;
|
||||
@@ -1608,22 +1679,19 @@ static PyObject *Object_shareFrom (BPy_Object *self, PyObject *args)
|
||||
|
||||
if (!PyArg_ParseTuple (args, "O", &object))
|
||||
{
|
||||
EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
return EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected an object argument");
|
||||
return (NULL);
|
||||
}
|
||||
if (!Object_CheckPyObject ((PyObject*)object))
|
||||
{
|
||||
EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"argument 1 is not of type 'Object'");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (self->object->type != object->object->type)
|
||||
{
|
||||
EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"objects are not of same data type");
|
||||
return (NULL);
|
||||
}
|
||||
switch (self->object->type)
|
||||
{
|
||||
@@ -1659,9 +1727,8 @@ static PyObject *Object_shareFrom (BPy_Object *self, PyObject *args)
|
||||
Py_INCREF (Py_None);
|
||||
return (Py_None);
|
||||
default:
|
||||
EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"type not supported");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
Py_INCREF (Py_None);
|
||||
@@ -1871,6 +1938,45 @@ static PyObject *Object_copyAllPropertiesTo(BPy_Object *self, PyObject *args)
|
||||
return EXPP_incr_ret (Py_None);
|
||||
}
|
||||
|
||||
/* obj.addScriptLink */
|
||||
static PyObject *Object_addScriptLink (BPy_Object *self, PyObject *args)
|
||||
{
|
||||
Object *obj = self->object;
|
||||
ScriptLink *slink = NULL;
|
||||
|
||||
slink = &(obj)->scriptlink;
|
||||
|
||||
if (!EXPP_addScriptLink(slink, args, 0))
|
||||
return EXPP_incr_ret (Py_None);
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
/* obj.clearScriptLinks */
|
||||
static PyObject *Object_clearScriptLinks (BPy_Object *self)
|
||||
{
|
||||
Object *obj = self->object;
|
||||
ScriptLink *slink = NULL;
|
||||
|
||||
slink = &(obj)->scriptlink;
|
||||
|
||||
return EXPP_incr_ret(Py_BuildValue("i", EXPP_clearScriptLinks (slink)));
|
||||
}
|
||||
|
||||
/* obj.getScriptLinks */
|
||||
static PyObject *Object_getScriptLinks (BPy_Object *self, PyObject *args)
|
||||
{
|
||||
Object *obj = self->object;
|
||||
ScriptLink *slink = NULL;
|
||||
PyObject *ret = NULL;
|
||||
|
||||
slink = &(obj)->scriptlink;
|
||||
|
||||
ret = EXPP_getScriptLinks(slink, args, 0);
|
||||
|
||||
if (ret) return ret;
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Object_CreatePyObject */
|
||||
/* Description: This function will create a new BlenObject from an existing */
|
||||
@@ -2231,10 +2337,10 @@ static int Object_setAttr (BPy_Object *obj, char *name, PyObject *value)
|
||||
}
|
||||
if (StringEqual (name, "track"))
|
||||
{
|
||||
/* This is not allowed. */
|
||||
EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"Setting the track is not allowed.");
|
||||
return (0);
|
||||
if (Object_makeTrack (obj, valtuple) != Py_None)
|
||||
return (-1);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
if (StringEqual (name, "data"))
|
||||
{
|
||||
|
||||
@@ -34,9 +34,12 @@
|
||||
#include <BKE_scene.h>
|
||||
#include <BKE_library.h>
|
||||
#include <BLI_blenlib.h>
|
||||
#include <BSE_drawview.h> /* for play_anim */
|
||||
#include <BSE_headerbuttons.h> /* for copy_scene */
|
||||
#include <BIF_drawscene.h> /* for set_scene */
|
||||
#include <BIF_space.h> /* for copy_view3d_lock() */
|
||||
#include <BIF_screen.h> /* curarea */
|
||||
#include <DNA_screen_types.h> /* SPACE_VIEW3D, SPACE_SEQ */
|
||||
#include <DNA_scriptlink_types.h>
|
||||
#include <MEM_guardedalloc.h> /* for MEM_callocN */
|
||||
#include <mydevice.h> /* for #define REDRAW */
|
||||
@@ -101,6 +104,7 @@ static PyObject *Scene_getRenderingContext(BPy_Scene *self);
|
||||
static PyObject *Scene_getScriptLinks(BPy_Scene *self, PyObject *args);
|
||||
static PyObject *Scene_addScriptLink(BPy_Scene *self, PyObject *args);
|
||||
static PyObject *Scene_clearScriptLinks(BPy_Scene *self);
|
||||
static PyObject *Scene_play(BPy_Scene *self, PyObject *args);
|
||||
|
||||
//deprecated methods
|
||||
static PyObject *Scene_currentFrame(BPy_Scene *self, PyObject *args);
|
||||
@@ -180,6 +184,19 @@ static PyMethodDef BPy_Scene_methods[] = {
|
||||
{"currentFrame", (PyCFunction)Scene_currentFrame, METH_VARARGS,
|
||||
"(frame) - If frame is given, the current frame is set and"
|
||||
"\nreturned in any case"},
|
||||
{"play", (PyCFunction)Scene_play, METH_VARARGS,
|
||||
"(mode = 0, win = VIEW3D) - Play realtime animation in Blender"
|
||||
" (not rendered).\n"
|
||||
"(mode) - int:\n"
|
||||
"\t0 - keep playing in biggest given 'win';\n"
|
||||
"\t1 - keep playing in all 'win', VIEW3D and SEQ windows;\n"
|
||||
"\t2 - play once in biggest given 'win';\n"
|
||||
"\t3 - play once in all 'win', VIEW3D and SEQ windows.\n"
|
||||
"(win) - int: see Blender.Window.Types. Only these are meaningful here:"
|
||||
"VIEW3D, SEQ, IPO, ACTION, NLA, SOUND. But others are also accepted, "
|
||||
"since they can be used just as an interruptible timer. If 'win' is not"
|
||||
"available or invalid, VIEW3D is tried, then any bigger window."
|
||||
"Returns 0 for normal exit or 1 when canceled by user input."},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
//-----------------------BPy_Scene method def-------------------------------------------------------------------------
|
||||
@@ -791,6 +808,62 @@ static PyObject *Scene_getScriptLinks (BPy_Scene *self, PyObject *args)
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
static PyObject *Scene_play (BPy_Scene *self, PyObject *args)
|
||||
{
|
||||
Scene *scene = self->scene;
|
||||
int mode = 0, win = SPACE_VIEW3D;
|
||||
PyObject *ret = NULL;
|
||||
ScrArea *sa = NULL, *oldsa = curarea;
|
||||
|
||||
if (!scene)
|
||||
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"Blender Scene was deleted!");
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|ii", &mode, &win))
|
||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"expected nothing, or or two ints as arguments.");
|
||||
|
||||
if (mode < 0 || mode > 3)
|
||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"mode should be in range [0, 3].");
|
||||
|
||||
switch (win) {
|
||||
case SPACE_VIEW3D:
|
||||
case SPACE_SEQ:
|
||||
case SPACE_IPO:
|
||||
case SPACE_ACTION:
|
||||
case SPACE_NLA:
|
||||
case SPACE_SOUND:
|
||||
case SPACE_BUTS: /* from here they don't 'play', but ...*/
|
||||
case SPACE_TEXT: /* ... might be used as a timer. */
|
||||
case SPACE_SCRIPT:
|
||||
case SPACE_OOPS:
|
||||
case SPACE_IMAGE:
|
||||
case SPACE_IMASEL:
|
||||
case SPACE_INFO:
|
||||
case SPACE_FILE:
|
||||
break;
|
||||
default:
|
||||
win = SPACE_VIEW3D;
|
||||
}
|
||||
|
||||
/* we have to move to a proper win */
|
||||
sa = find_biggest_area_of_type(win);
|
||||
if (!sa && win != SPACE_VIEW3D)
|
||||
sa = find_biggest_area_of_type(SPACE_VIEW3D);
|
||||
|
||||
if (!sa) sa = find_biggest_area();
|
||||
|
||||
if (sa) areawinset(sa->win);
|
||||
|
||||
/* play_anim returns 0 for normal exit or 1 if user canceled it */
|
||||
ret = Py_BuildValue("i", play_anim(mode));
|
||||
|
||||
if (sa) areawinset(oldsa->win);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
// DEPRECATED
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <BLI_blenlib.h>
|
||||
#include <PIL_time.h>
|
||||
#include <Python.h>
|
||||
#include <sys/stat.h>
|
||||
#include "gen_utils.h"
|
||||
#include "modules.h"
|
||||
|
||||
@@ -92,7 +93,12 @@ Each successive call is garanteed to return values greater than or\n\
|
||||
equal to the previous call.";
|
||||
|
||||
static char M_sys_exists_doc[] =
|
||||
"(path) - Return 1 if given pathname (file or dir) exists, 0 otherwise.";
|
||||
"(path) - Check if the given pathname exists.\n\
|
||||
The return value is as follows:\n\
|
||||
\t 0: path doesn't exist;\n\
|
||||
\t 1: path is an existing filename;\n\
|
||||
\t 2: path is an existing dirname;\n\
|
||||
\t-1: path exists but is neither a regular file nor a dir.";
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python method structure definition for Blender.sys module: */
|
||||
@@ -337,16 +343,20 @@ static PyObject *M_sys_time (PyObject *self)
|
||||
|
||||
static PyObject *M_sys_exists (PyObject *self, PyObject *args)
|
||||
{
|
||||
struct stat st;
|
||||
char *fname = NULL;
|
||||
int i = 0;
|
||||
int res = 0, i = -1;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s", &fname))
|
||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"expected string (file path) argument");
|
||||
"expected string (pathname) argument");
|
||||
|
||||
i = BLI_exists(fname);
|
||||
res = stat(fname, &st);
|
||||
|
||||
if (i) return Py_BuildValue("i", 1); /* path was found */
|
||||
if (res == -1) i = 0;
|
||||
else if (S_ISREG(st.st_mode)) i = 1;
|
||||
else if (S_ISDIR(st.st_mode)) i = 2;
|
||||
/* i stays as -1 if path exists but is neither a regular file nor a dir */
|
||||
|
||||
return Py_BuildValue("i", 0); /* path doesn't exist */
|
||||
return Py_BuildValue("i", i);
|
||||
}
|
||||
|
||||
@@ -639,7 +639,44 @@ static PyObject *World_setMist(BPy_World *self, PyObject *args )
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
/* world.addScriptLink */
|
||||
static PyObject *World_addScriptLink (BPy_World *self, PyObject *args)
|
||||
{
|
||||
World *world = self->world;
|
||||
ScriptLink *slink = NULL;
|
||||
|
||||
slink = &(world)->scriptlink;
|
||||
|
||||
if (!EXPP_addScriptLink(slink, args, 0))
|
||||
return EXPP_incr_ret (Py_None);
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
/* world.clearScriptLinks */
|
||||
static PyObject *World_clearScriptLinks (BPy_World *self)
|
||||
{
|
||||
World *world = self->world;
|
||||
ScriptLink *slink = NULL;
|
||||
|
||||
slink = &(world)->scriptlink;
|
||||
|
||||
return EXPP_incr_ret(Py_BuildValue("i", EXPP_clearScriptLinks (slink)));
|
||||
}
|
||||
|
||||
/* world.getScriptLinks */
|
||||
static PyObject *World_getScriptLinks (BPy_World *self, PyObject *args)
|
||||
{
|
||||
World *world = self->world;
|
||||
ScriptLink *slink = NULL;
|
||||
PyObject *ret = NULL;
|
||||
|
||||
slink = &(world)->scriptlink;
|
||||
|
||||
ret = EXPP_getScriptLinks(slink, args, 0);
|
||||
|
||||
if (ret) return ret;
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*@{*/
|
||||
|
||||
@@ -105,6 +105,9 @@ static PyObject *World_getStar(BPy_World *self);
|
||||
static PyObject *World_setStar(BPy_World *self, PyObject *args );
|
||||
static PyObject *World_getMist(BPy_World *self);
|
||||
static PyObject *World_setMist(BPy_World *self, PyObject *args );
|
||||
static PyObject *World_getScriptLinks(BPy_World *self, PyObject *args);
|
||||
static PyObject *World_addScriptLink(BPy_World *self, PyObject *args);
|
||||
static PyObject *World_clearScriptLinks(BPy_World *self);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python BPy_World methods table: */
|
||||
@@ -152,6 +155,16 @@ static PyMethodDef BPy_World_methods[] = {
|
||||
"() - Return World Data mist"},
|
||||
{"setMist", (PyCFunction)World_setMist, METH_VARARGS,
|
||||
"() - Return World Data mist"},
|
||||
{"getScriptLinks", (PyCFunction)World_getScriptLinks, METH_VARARGS,
|
||||
"(eventname) - Get a list of this world's scriptlinks (Text names) "
|
||||
"of the given type\n"
|
||||
"(eventname) - string: FrameChanged or Redraw."},
|
||||
{"addScriptLink", (PyCFunction)World_addScriptLink, METH_VARARGS,
|
||||
"(text, evt) - Add a new world scriptlink.\n"
|
||||
"(text) - string: an existing Blender Text name;\n"
|
||||
"(evt) string: FrameChanged or Redraw."},
|
||||
{"clearScriptLinks", (PyCFunction)World_clearScriptLinks, METH_NOARGS,
|
||||
"() - Delete all scriptlinks from this world :)."},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
@@ -160,7 +173,7 @@ static PyMethodDef BPy_World_methods[] = {
|
||||
/* and Object modules. */
|
||||
/*****************************************************************************/
|
||||
PyObject *World_Init (void);
|
||||
PyObject *World_CreatePyObject (World *cam);
|
||||
PyObject *World_CreatePyObject (World *world);
|
||||
World *World_FromPyObject (PyObject *pyobj);
|
||||
int World_CheckPyObject (PyObject *pyobj);
|
||||
|
||||
|
||||
@@ -23,16 +23,27 @@ Example::
|
||||
from Blender import Draw
|
||||
R = G = B = 0
|
||||
A = 1
|
||||
instructions = "Hold mouse buttons to change the background color."
|
||||
title = "Testing BGL + Draw"
|
||||
instructions = "Use mouse buttons or wheel to change the background color."
|
||||
quitting = " Press ESC or q to quit."
|
||||
len1 = Draw.GetStringWidth(title)
|
||||
len2 = Draw.GetStringWidth(instructions + quitting)
|
||||
#
|
||||
def show_win():
|
||||
glClearColor(R,G,B,A) # define color used to clear buffers
|
||||
glClear(GL_COLOR_BUFFER_BIT) # use it to clear the color buffer
|
||||
glColor3f(1,1,1) # change default color
|
||||
glColor3f(0.35,0.18,0.92) # define default color
|
||||
glBegin(GL_POLYGON) # begin a vertex data list
|
||||
glVertex2i(165, 158)
|
||||
glVertex2i(252, 55)
|
||||
glVertex2i(104, 128)
|
||||
glEnd()
|
||||
glColor3f(0.4,0.4,0.4) # change default color
|
||||
glRecti(40, 96, 60+len1, 113)
|
||||
glColor3f(1,1,1)
|
||||
glRasterPos2i(50,100) # move cursor to x = 50, y = 100
|
||||
Draw.Text("Testing BGL + Draw") # draw this text there
|
||||
glRasterPos2i(350,20) # move cursor again
|
||||
Draw.Text(title) # draw this text there
|
||||
glRasterPos2i(350,40) # move cursor again
|
||||
Draw.Text(instructions + quitting) # draw another msg
|
||||
glBegin(GL_LINE_LOOP) # begin a vertex-data list
|
||||
glVertex2i(46,92)
|
||||
@@ -40,29 +51,29 @@ Example::
|
||||
glVertex2i(120,115)
|
||||
glVertex2i(46,115)
|
||||
glEnd() # close this list
|
||||
glColor3f(0.35,0.18,0.92) # change default color again
|
||||
glBegin(GL_POLYGON) # another list, for a polygon
|
||||
glVertex2i(315, 292)
|
||||
glVertex2i(412, 200)
|
||||
glVertex2i(264, 256)
|
||||
glEnd()
|
||||
Draw.Redraw(1) # make changes visible.
|
||||
#
|
||||
def ev(evt, val): # this is a callback for Draw.Register()
|
||||
def ev(evt, val): # event callback for Draw.Register()
|
||||
global R,G,B,A # ... it handles input events
|
||||
if evt == Draw.ESCKEY or evt == Draw.QKEY:
|
||||
Draw.Exit() # this quits the script
|
||||
elif not val: return
|
||||
elif evt == Draw.LEFTMOUSE: R = 1 - R
|
||||
elif evt == Draw.MIDDLEMOUSE: G = 1 - G
|
||||
elif evt == Draw.RIGHTMOUSE: B = 1 - B
|
||||
elif evt == Draw.WHEELUPMOUSE:
|
||||
R += 0.1
|
||||
if R > 1: R = 1
|
||||
elif evt == Draw.WHEELDOWNMOUSE:
|
||||
R -= 0.1
|
||||
if R < 0: R = 0
|
||||
else:
|
||||
Draw.Register(show_win, ev, None)
|
||||
return # don't redraw if nothing changed
|
||||
Draw.Redraw(1) # make changes visible.
|
||||
#
|
||||
Draw.Register(show_win, ev, None) # start the main loop
|
||||
Draw.Register(show_win, ev, None) # start the main loop
|
||||
|
||||
@see: U{www.opengl.org}
|
||||
@see: U{nehe.gamedev.net}
|
||||
|
||||
"""
|
||||
|
||||
def glAccum(op, value):
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
# Doc system used: epydoc - http://epydoc.sf.net
|
||||
# command line:
|
||||
|
||||
# epydoc -o BPY_API_230 --url "http://www.blender.org" -t Blender.py \
|
||||
# epydoc -o BPY_API_23x --url "http://www.blender.org" -t Blender.py \
|
||||
# -n "Blender" --no-private --no-frames Blender.py \
|
||||
# Types.py Scene.py Object.py NMesh.py Material.py Camera.py Lamp.py \
|
||||
# Armature.py Metaball.py Effect.py Curve.py Ipo.py World.py BGL.py Window.py \
|
||||
# Draw.py Image.py Text.py Lattice.py Texture.py Registry.py Sys.py Mathutils.py
|
||||
|
||||
"""
|
||||
The main Blender module.
|
||||
The main Blender module (*).
|
||||
|
||||
The Blender Python API Reference
|
||||
================================
|
||||
@@ -23,30 +23,32 @@ The Blender Python API Reference
|
||||
- L{Bone}
|
||||
- L{NLA}
|
||||
- L{BGL}
|
||||
- L{Camera}
|
||||
- L{Camera} (*)
|
||||
- L{Curve}
|
||||
- L{Draw}
|
||||
- L{Draw} (*)
|
||||
- L{Effect}
|
||||
- L{Image}
|
||||
- L{Image} (*)
|
||||
- L{Ipo}
|
||||
- L{Lamp}
|
||||
- L{Lamp} (*)
|
||||
- L{Lattice}
|
||||
- L{Library}
|
||||
- L{Material}
|
||||
- L{Material} (*)
|
||||
- L{Mathutils}
|
||||
- L{Metaball}
|
||||
- L{Metaball} (*)
|
||||
- L{NMesh}
|
||||
- L{Noise}
|
||||
- L{Object}
|
||||
- L{Object} (*)
|
||||
- L{Registry}
|
||||
- L{Scene}
|
||||
- L{Scene} (*)
|
||||
- L{Render}
|
||||
- L{Text}
|
||||
- L{Texture}
|
||||
- L{Types}
|
||||
- L{Window}
|
||||
- L{World}
|
||||
- L{sys<Sys>}
|
||||
- L{World} (*)
|
||||
- L{sys<Sys>} (*)
|
||||
|
||||
(*) - marks updated.
|
||||
|
||||
Introduction:
|
||||
-------------
|
||||
@@ -104,29 +106,54 @@ def Redraw ():
|
||||
|
||||
def Load (filename = None):
|
||||
"""
|
||||
Load a Blender .blend file.
|
||||
Load a Blender .blend file or any of the other supported file formats.
|
||||
|
||||
Supported formats:
|
||||
- Blender's .blend;
|
||||
- DXF;
|
||||
- Open Inventor 1.0 ASCII;
|
||||
- Radiogour;
|
||||
- STL;
|
||||
- Videoscape;
|
||||
- VRML 1.0 asc.
|
||||
|
||||
@type filename: string
|
||||
@param filename: the pathname to the desired .blend file. If 'filename'
|
||||
@param filename: the pathname to the desired file. If 'filename'
|
||||
isn't given or if it contains the substring '.B.blend', the default
|
||||
.B.blend file is loaded.
|
||||
|
||||
@warn: loading a new .blend file removes the current data in Blender. For
|
||||
safety, this function saves the current data as an autosave file in
|
||||
the temporary dir used by Blender before loading the new file.
|
||||
the temporary dir used by Blender before loading a new Blender file.
|
||||
@warn: after a call to Load(blendfile), current data in Blender is lost,
|
||||
including the Python dictionaries. Any posterior references in the
|
||||
script to previously defined data will generate a NameError. So it's
|
||||
better to put Blender.Load as the last executed command in the script,
|
||||
when this function is used to open .blend files.
|
||||
"""
|
||||
|
||||
def Save (filename, overwrite = 0):
|
||||
"""
|
||||
Save a Blender .blend file with the current program data.
|
||||
Save a Blender .blend file with the current program data or export to
|
||||
one of the builtin file formats.
|
||||
|
||||
Supported formats:
|
||||
- Blender (.blend);
|
||||
- DXF (.dxf);
|
||||
- STL (.stl);
|
||||
- Videoscape (.obj);
|
||||
- VRML 1.0 (.wrl).
|
||||
|
||||
@type filename: string
|
||||
@param filename: the pathname for the desired .blend file. If it doesn't
|
||||
contain ".blend", this extension is automatically appended.
|
||||
@param filename: the filename for the file to be written. It must have one
|
||||
of the supported extensions or an error will be returned.
|
||||
@type overwrite: int (bool)
|
||||
@param overwrite: if non-zero, file 'filename' will be overwritten if it
|
||||
already exists. By default existing files are not overwritten (an error
|
||||
is returned).
|
||||
|
||||
@note: the substring ".B.blend" is not accepted inside 'filename'.
|
||||
@note: The substring ".B.blend" is not accepted inside 'filename'.
|
||||
@note: DXF, STL and Videoscape export only B{selected} meshes.
|
||||
"""
|
||||
|
||||
def Quit ():
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
"""
|
||||
The Blender.Camera submodule.
|
||||
|
||||
B{New}: scriptLink methods: L{Camera.getScriptLinks}, ...
|
||||
|
||||
Camera Data
|
||||
===========
|
||||
|
||||
@@ -178,3 +180,29 @@ class Camera:
|
||||
@type drawsize: float
|
||||
@param drawsize: The new draw size value.
|
||||
"""
|
||||
|
||||
def getScriptLinks (event):
|
||||
"""
|
||||
Get a list with this Camera's script links of type 'event'.
|
||||
@type event: string
|
||||
@param event: "FrameChanged" or "Redraw".
|
||||
@rtype: list
|
||||
@return: a list with Blender L{Text} names (the script links of the given
|
||||
'event' type) or None if there are no script links at all.
|
||||
"""
|
||||
|
||||
def clearScriptLinks ():
|
||||
"""
|
||||
Delete all this Camera's script links.
|
||||
@rtype: bool
|
||||
@return: 0 if some internal problem occurred or 1 if successful.
|
||||
"""
|
||||
|
||||
def addScriptLink (text, event):
|
||||
"""
|
||||
Add a new script link to this Camera.
|
||||
@type text: string
|
||||
@param text: the name of an existing Blender L{Text}.
|
||||
@type event: string
|
||||
@param event: "FrameChanged" or "Redraw".
|
||||
"""
|
||||
|
||||
@@ -6,7 +6,7 @@ The Blender.Draw submodule.
|
||||
Draw
|
||||
====
|
||||
|
||||
B{New}: L{PupIntInput}, L{PupFloatInput}, L{PupStrInput}.
|
||||
B{New}: L{PupIntInput}, L{PupFloatInput}, L{PupStrInput}, mouse wheel events.
|
||||
|
||||
This module provides access to a B{windowing interface} in Blender. Its widgets
|
||||
include many kinds of buttons: push, toggle, menu, number, string, slider,
|
||||
|
||||
@@ -6,6 +6,8 @@ The Blender.Image submodule.
|
||||
Image
|
||||
=====
|
||||
|
||||
B{New}: L{Image.reload}.
|
||||
|
||||
This module provides access to B{Image} objects in Blender.
|
||||
|
||||
Example::
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
"""
|
||||
The Blender.Lamp submodule.
|
||||
|
||||
B{New}: scriptLink methods: L{Lamp.getScriptLinks}, ...
|
||||
|
||||
Lamp Data
|
||||
=========
|
||||
|
||||
@@ -320,3 +322,29 @@ class Lamp:
|
||||
@param quad2: The new quad 2 value.
|
||||
@warning: this only applies to Lamps with the 'Quad' flag on.
|
||||
"""
|
||||
|
||||
def getScriptLinks (event):
|
||||
"""
|
||||
Get a list with this Lamp's script links of type 'event'.
|
||||
@type event: string
|
||||
@param event: "FrameChanged" or "Redraw".
|
||||
@rtype: list
|
||||
@return: a list with Blender L{Text} names (the script links of the given
|
||||
'event' type) or None if there are no script links at all.
|
||||
"""
|
||||
|
||||
def clearScriptLinks ():
|
||||
"""
|
||||
Delete all this Lamp's script links.
|
||||
@rtype: bool
|
||||
@return: 0 if some internal problem occurred or 1 if successful.
|
||||
"""
|
||||
|
||||
def addScriptLink (text, event):
|
||||
"""
|
||||
Add a new script link to this Lamp.
|
||||
@type text: string
|
||||
@param text: the name of an existing Blender L{Text}.
|
||||
@type event: string
|
||||
@param event: "FrameChanged" or "Redraw".
|
||||
"""
|
||||
|
||||
@@ -39,18 +39,6 @@ def Rand (high = 1, low = 0):
|
||||
@param low: The lower range.
|
||||
"""
|
||||
|
||||
def Vector (list = None):
|
||||
"""
|
||||
Create a new Vector object from a list.
|
||||
@type list: PyList of float or int
|
||||
@param list: The list of values for the Vector object.
|
||||
Must be 2, 3, or 4 values.
|
||||
@rtype: Vector object.
|
||||
@return: It depends wheter a parameter was passed:
|
||||
- (list): Vector object initialized with the given values;
|
||||
- (): An empty 3 dimensional vector.
|
||||
"""
|
||||
|
||||
def CopyVec(vector):
|
||||
"""
|
||||
Create a copy of the Vector object.
|
||||
@@ -128,23 +116,6 @@ def ProjectVecs(vec1, vec2):
|
||||
@return: The parallel projection vector.
|
||||
"""
|
||||
|
||||
def Matrix(list1 = None, list2 = None, list3 = None, list4 = None):
|
||||
"""
|
||||
Create a new matrix object from intialized values.
|
||||
@type list1: PyList of int/float
|
||||
@param list1: A 2d,3d or 4d list.
|
||||
@type list2: PyList of int/float
|
||||
@param list2: A 2d,3d or 4d list.
|
||||
@type list3: PyList of int/float
|
||||
@param list3: A 2d,3d or 4d list.
|
||||
@type list4: PyList of int/float
|
||||
@param list4: A 2d,3d or 4d list.
|
||||
@rtype: New matrix object.
|
||||
@return: It depends wheter a parameter was passed:
|
||||
- (list1, etc.): Matrix object initialized with the given values;
|
||||
- (): An empty 3 dimensional matrix.
|
||||
"""
|
||||
|
||||
def RotationMatrix(angle, matSize, axisFlag, axis):
|
||||
"""
|
||||
Create a matrix representing a rotation.
|
||||
@@ -248,21 +219,6 @@ def MatMultVec(mat, vec):
|
||||
@return: The column vector that results from the muliplication.
|
||||
"""
|
||||
|
||||
def Quaternion(list = None, angle = None):
|
||||
"""
|
||||
Create a new matrix object from intialized values.
|
||||
@type list: PyList of int/float
|
||||
@param list: A 3d or 4d list to intialize quaternion.
|
||||
4d if intializing, 3d if will be used as an axis of rotation.
|
||||
@type angle: float (optional)
|
||||
@param angle: An arbitrary rotation amount around 'list'.
|
||||
List is used as an axis of rotation in this case.
|
||||
@rtype: New quaternion object.
|
||||
@return: It depends wheter a parameter was passed:
|
||||
- (list/angle): Quaternion object initialized with the given values;
|
||||
- (): An identity 4 dimensional quaternion.
|
||||
"""
|
||||
|
||||
def CopyQuat(quaternion):
|
||||
"""
|
||||
Create a copy of the Quaternion object.
|
||||
@@ -320,16 +276,6 @@ def Slerp(quat1, quat2, factor):
|
||||
@return: The interpolated rotation.
|
||||
"""
|
||||
|
||||
def Euler(list = None):
|
||||
"""
|
||||
Create a new euler object.
|
||||
@type list: PyList of float/int
|
||||
@param list: 3d list to initalize euler
|
||||
@rtype: Euler object
|
||||
@return: Euler representing heading, pitch, bank.
|
||||
Values are in degrees.
|
||||
"""
|
||||
|
||||
def CopyEuler(euler):
|
||||
"""
|
||||
Create a new euler object.
|
||||
@@ -365,6 +311,21 @@ class Vector:
|
||||
@cvar length: The magnitude of the vector.
|
||||
"""
|
||||
|
||||
def __init__(list = None):
|
||||
"""
|
||||
Create a new Vector object from a list.
|
||||
|
||||
Example::
|
||||
v = Blender.Mathutils.Vector([1,0,0])
|
||||
@type list: PyList of float or int
|
||||
@param list: The list of values for the Vector object.
|
||||
Must be 2, 3, or 4 values.
|
||||
@rtype: Vector object.
|
||||
@return: It depends wheter a parameter was passed:
|
||||
- (list): Vector object initialized with the given values;
|
||||
- (): An empty 3 dimensional vector.
|
||||
"""
|
||||
|
||||
def zero():
|
||||
"""
|
||||
Set all values to zero.
|
||||
@@ -405,6 +366,19 @@ class Euler:
|
||||
@cvar z: The roll value in degrees.
|
||||
"""
|
||||
|
||||
def __init__(list = None):
|
||||
"""
|
||||
Create a new euler object.
|
||||
|
||||
Example::
|
||||
euler = Euler([45,0,0])
|
||||
@type list: PyList of float/int
|
||||
@param list: 3d list to initialize euler
|
||||
@rtype: Euler object
|
||||
@return: Euler representing heading, pitch, bank.
|
||||
@note: Values are in degrees.
|
||||
"""
|
||||
|
||||
def zero():
|
||||
"""
|
||||
Set all values to zero.
|
||||
@@ -446,6 +420,25 @@ class Quaternion:
|
||||
in degrees.
|
||||
"""
|
||||
|
||||
def __init__(list = None, angle = None):
|
||||
"""
|
||||
Create a new quaternion object from initialized values.
|
||||
|
||||
Example::
|
||||
quat = Mathutils.Quaternion()
|
||||
|
||||
@type list: PyList of int/float
|
||||
@param list: A 3d or 4d list to initialize quaternion.
|
||||
4d if intializing, 3d if will be used as an axis of rotation.
|
||||
@type angle: float (optional)
|
||||
@param angle: An arbitrary rotation amount around 'list'.
|
||||
List is used as an axis of rotation in this case.
|
||||
@rtype: New quaternion object.
|
||||
@return: It depends wheter a parameter was passed:
|
||||
- (list/angle): Quaternion object initialized with the given values;
|
||||
- (): An identity 4 dimensional quaternion.
|
||||
"""
|
||||
|
||||
def identity():
|
||||
"""
|
||||
Set the quaternion to the identity quaternion.
|
||||
@@ -496,6 +489,27 @@ class Matrix:
|
||||
@cvar colsize: The column size of the matrix.
|
||||
"""
|
||||
|
||||
def __init__(list1 = None, list2 = None, list3 = None, list4 = None):
|
||||
"""
|
||||
Create a new matrix object from initialized values.
|
||||
|
||||
Example::
|
||||
matrix = Mathutils.Matrix([1,1,1],[0,1,0],[1,0,0])
|
||||
|
||||
@type list1: PyList of int/float
|
||||
@param list1: A 2d,3d or 4d list.
|
||||
@type list2: PyList of int/float
|
||||
@param list2: A 2d,3d or 4d list.
|
||||
@type list3: PyList of int/float
|
||||
@param list3: A 2d,3d or 4d list.
|
||||
@type list4: PyList of int/float
|
||||
@param list4: A 2d,3d or 4d list.
|
||||
@rtype: New matrix object.
|
||||
@return: It depends wheter a parameter was passed:
|
||||
- (list1, etc.): Matrix object initialized with the given values;
|
||||
- (): An empty 3 dimensional matrix.
|
||||
"""
|
||||
|
||||
def zero():
|
||||
"""
|
||||
Set all matrix values to 0.
|
||||
|
||||
@@ -3,7 +3,12 @@
|
||||
"""
|
||||
The Blender.Object submodule
|
||||
|
||||
This module provides access to the B{Object Data} in Blender.
|
||||
B{New}: L{Object.makeTrack}, scriptLink methods: L{Object.getScriptLinks}, ...
|
||||
|
||||
Object
|
||||
======
|
||||
|
||||
This module provides access to the B{Objects} in Blender.
|
||||
|
||||
Example::
|
||||
|
||||
@@ -522,3 +527,53 @@ class Object:
|
||||
are not displayed correctly, try this method function. But if the script
|
||||
works properly without it, there's no reason to use it.
|
||||
"""
|
||||
|
||||
def getScriptLinks (event):
|
||||
"""
|
||||
Get a list with this Object's script links of type 'event'.
|
||||
@type event: string
|
||||
@param event: "FrameChanged" or "Redraw".
|
||||
@rtype: list
|
||||
@return: a list with Blender L{Text} names (the script links of the given
|
||||
'event' type) or None if there are no script links at all.
|
||||
"""
|
||||
|
||||
def clearScriptLinks ():
|
||||
"""
|
||||
Delete all this Object's script links.
|
||||
@rtype: bool
|
||||
@return: 0 if some internal problem occurred or 1 if successful.
|
||||
"""
|
||||
|
||||
def addScriptLink (text, event):
|
||||
"""
|
||||
Add a new script link to this Object.
|
||||
@type text: string
|
||||
@param text: the name of an existing Blender L{Text}.
|
||||
@type event: string
|
||||
@param event: "FrameChanged" or "Redraw".
|
||||
"""
|
||||
|
||||
def makeTrack (tracked, fast = 0):
|
||||
"""
|
||||
Make this Object track another.
|
||||
@type tracked: Blender Object
|
||||
@param tracked: the object to be tracked.
|
||||
@type fast: int (bool)
|
||||
@param fast: if zero, the scene hierarchy is updated automatically. If
|
||||
you set 'fast' to a nonzero value, don't forget to update the scene
|
||||
yourself (see L{Scene.Scene.update}).
|
||||
@note: you also need to clear the rotation (L{setEuler}) of this object
|
||||
if it was not (0,0,0) already.
|
||||
"""
|
||||
|
||||
def clearTrack (mode = 0, fast = 0):
|
||||
"""
|
||||
Make this Object not track another anymore.
|
||||
@type mode: int (bool)
|
||||
@param mode: if nonzero the matrix transformation used for tracking is kept.
|
||||
@type fast: int (bool)
|
||||
@param fast: if zero, the scene hierarchy is updated automatically. If
|
||||
you set 'fast' to a nonzero value, don't forget to update the scene
|
||||
yourself (see L{Scene.Scene.update}).
|
||||
"""
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"""
|
||||
The Blender.Scene submodule.
|
||||
|
||||
B{New}: scriptLink methods: L{Scene.getScriptLinks}, ...
|
||||
B{New}: L{Scene.play}, scriptLink methods: L{Scene.getScriptLinks}, ...
|
||||
|
||||
Scene
|
||||
=====
|
||||
@@ -219,3 +219,24 @@ class Scene:
|
||||
@type event: string
|
||||
@param event: "FrameChanged", "OnLoad" or "Redraw".
|
||||
"""
|
||||
|
||||
def play (mode = 0, win = '<VIEW3D>'):
|
||||
"""
|
||||
Play a realtime animation. This is the "Play Back Animation" function in
|
||||
Blender, different from playing a sequence of rendered images (for that
|
||||
check L{Render.RenderData.play}).
|
||||
@type mode: int
|
||||
@param mode: controls playing:
|
||||
- 0: keep playing in the biggest 'win' window;
|
||||
- 1: keep playing in all 'win', VIEW3D and SEQ windows;
|
||||
- 2: play once in the biggest VIEW3D;
|
||||
- 3: play once in all 'win', VIEW3D and SEQ windows.
|
||||
@type win: int
|
||||
@param win: window type, see L{Window.Types}. Only some of them are
|
||||
meaningful here: VIEW3D, SEQ, IPO, ACTION, NLA, SOUND. But the others
|
||||
are also accepted, since this function can be used simply as an
|
||||
interruptible timer. If 'win' is not visible or invalid, VIEW3D is
|
||||
tried, then any bigger visible window.
|
||||
@rtype: bool
|
||||
@return: 0 on normal exit or 1 when play back is canceled by user input.
|
||||
"""
|
||||
|
||||
@@ -114,14 +114,18 @@ def makename (path = "Blender.Get('filename')", ext = "", strip = 0):
|
||||
def exists(path):
|
||||
"""
|
||||
Tell if the given pathname (file or dir) exists.
|
||||
@rtype: bool
|
||||
@return: 1 if 'path' exists, 0 otherwise.
|
||||
@rtype: int
|
||||
@return:
|
||||
- 0: path does not exist;
|
||||
- 1: path is an existing filename;
|
||||
- 2: path is an existing dirname;
|
||||
- -1: path exists but is neither a regular file nor a dir.
|
||||
"""
|
||||
|
||||
def time ():
|
||||
"""
|
||||
Get the current time in seconds since a fixed value. Successive calls to
|
||||
this function are garanteed to return values greater than the previous call.
|
||||
this function are guaranteed to return values greater than the previous call.
|
||||
@rtype: float
|
||||
@return: the elapsed time in seconds.
|
||||
"""
|
||||
|
||||
@@ -55,19 +55,20 @@ DrawProgressBar::
|
||||
|
||||
@type Types: readonly dictionary
|
||||
@var Types: The available Window Types.
|
||||
- VIEW3D
|
||||
- IPO
|
||||
- OOPS
|
||||
- ACTION
|
||||
- BUTS
|
||||
- FILE
|
||||
- IMAGE
|
||||
- INFO
|
||||
- SEQ
|
||||
- IMASEL
|
||||
- SOUND
|
||||
- ACTION
|
||||
- TEXT
|
||||
- INFO
|
||||
- IPO
|
||||
- NLA
|
||||
- OOPS
|
||||
- SCRIPT
|
||||
- SEQ
|
||||
- SOUND
|
||||
- TEXT
|
||||
- VIEW3D
|
||||
"""
|
||||
|
||||
def Redraw ():
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
"""
|
||||
The Blender.World submodule
|
||||
|
||||
B{New}: scriptLink methods: L{World.getScriptLinks}, ...
|
||||
|
||||
INTRODUCTION
|
||||
============
|
||||
|
||||
The module world allows you to access all the data of a Blender World.
|
||||
|
||||
@@ -80,7 +83,7 @@ class World:
|
||||
|
||||
def getName():
|
||||
"""
|
||||
Retreives the name of an world object
|
||||
Retrieves the name of an world object
|
||||
@rtype: string
|
||||
@return: the name of the world object.
|
||||
"""
|
||||
@@ -116,7 +119,7 @@ class World:
|
||||
|
||||
def getSkytype():
|
||||
"""
|
||||
Retreives the skytype of a world object.
|
||||
Retrieves the skytype of a world object.
|
||||
The skytype is a combination of 3 bits : Bit 0 : Blend; Bit 1 : Real; Bit 2 : paper.
|
||||
@rtype: int
|
||||
@return: the skytype of the world object.
|
||||
@@ -135,7 +138,7 @@ class World:
|
||||
|
||||
def getMode():
|
||||
"""
|
||||
Retreives the mode of a world object.
|
||||
Retrieves the mode of a world object.
|
||||
The mode is a combination of 3 bits : Bit 0 : Blend; Bit 1 : Real; Bit 2 : paper.
|
||||
@rtype: int
|
||||
@return: the mode of the world object.
|
||||
@@ -154,7 +157,7 @@ class World:
|
||||
|
||||
def getMistype():
|
||||
"""
|
||||
Retreives the mist type of a world object.
|
||||
Retrieves the mist type of a world object.
|
||||
The mist type is an integer 0 : quadratic; 1 : linear; 2 : square.
|
||||
@rtype: int
|
||||
@return: the mistype of the world object.
|
||||
@@ -173,7 +176,7 @@ class World:
|
||||
|
||||
def getHor():
|
||||
"""
|
||||
Retreives the horizon color of a world object.
|
||||
Retrieves the horizon color of a world object.
|
||||
This color is a list of 3 floats.
|
||||
@rtype: list of three floats
|
||||
@return: the horizon color of the world object.
|
||||
@@ -191,7 +194,7 @@ class World:
|
||||
|
||||
def getZen():
|
||||
"""
|
||||
Retreives the zenith color of a world object.
|
||||
Retrieves the zenith color of a world object.
|
||||
This color is a list of 3 floats.
|
||||
@rtype: list of three floats
|
||||
@return: the zenith color of the world object.
|
||||
@@ -209,7 +212,7 @@ class World:
|
||||
|
||||
def getAmb():
|
||||
"""
|
||||
Retreives the ambient color of a world object.
|
||||
Retrieves the ambient color of a world object.
|
||||
This color is a list of 3 floats.
|
||||
@rtype: list of three floats
|
||||
@return: the ambient color of the world object.
|
||||
@@ -227,7 +230,7 @@ class World:
|
||||
|
||||
def getStar():
|
||||
"""
|
||||
Retreives the star parameters of a world object.
|
||||
Retrieves the star parameters of a world object.
|
||||
It is a list of nine floats :
|
||||
red component of the color
|
||||
green component of the color
|
||||
@@ -253,7 +256,7 @@ class World:
|
||||
|
||||
def getMist():
|
||||
"""
|
||||
Retreives the mist parameters of a world object.
|
||||
Retrieves the mist parameters of a world object.
|
||||
It is a list of four floats :
|
||||
intensity of the mist
|
||||
start of the mist
|
||||
@@ -273,3 +276,29 @@ class World:
|
||||
@rtype: PyNone
|
||||
@return: PyNone
|
||||
"""
|
||||
|
||||
def getScriptLinks (event):
|
||||
"""
|
||||
Get a list with this World's script links of type 'event'.
|
||||
@type event: string
|
||||
@param event: "FrameChanged" or "Redraw".
|
||||
@rtype: list
|
||||
@return: a list with Blender L{Text} names (the script links of the given
|
||||
'event' type) or None if there are no script links at all.
|
||||
"""
|
||||
|
||||
def clearScriptLinks ():
|
||||
"""
|
||||
Delete all this World's script links!
|
||||
@rtype: bool
|
||||
@return: 0 if some internal problem occurred or 1 if successful.
|
||||
"""
|
||||
|
||||
def addScriptLink (text, event):
|
||||
"""
|
||||
Add a new script link to this World.
|
||||
@type text: string
|
||||
@param text: the name of an existing Blender L{Text}.
|
||||
@type event: string
|
||||
@param event: "FrameChanged" or "Redraw".
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user