* Added more doc files for epydoc and a test for the camera module.
* Moved public declarations in camera and lamp to a new file: bpy_types.h. * Fixed minor bugs in material, rgbTuple and Lamp + other minor changes. * Made part of the changes to conform to decided naming conventions.
This commit is contained in:
@@ -998,7 +998,7 @@ static struct PyMethodDef BGL_methods[] = {
|
|||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
PyObject *M_BGL_Init(void)
|
PyObject *BGL_Init(void)
|
||||||
{
|
{
|
||||||
PyObject *mod= Py_InitModule("Blender.BGL", BGL_methods);
|
PyObject *mod= Py_InitModule("Blender.BGL", BGL_methods);
|
||||||
PyObject *dict= PyModule_GetDict(mod);
|
PyObject *dict= PyModule_GetDict(mod);
|
||||||
|
@@ -214,22 +214,22 @@ void M_Blender_Init (void)
|
|||||||
|
|
||||||
dict = PyModule_GetDict (module);
|
dict = PyModule_GetDict (module);
|
||||||
g_blenderdict = dict;
|
g_blenderdict = dict;
|
||||||
PyDict_SetItemString (dict, "Scene", M_Scene_Init());
|
PyDict_SetItemString (dict, "Scene", Scene_Init());
|
||||||
PyDict_SetItemString (dict, "Object", M_Object_Init());
|
PyDict_SetItemString (dict, "Object", M_Object_Init());
|
||||||
PyDict_SetItemString (dict, "Types", M_Types_Init());
|
PyDict_SetItemString (dict, "Types", Types_Init());
|
||||||
PyDict_SetItemString (dict, "NMesh", M_NMesh_Init());
|
PyDict_SetItemString (dict, "NMesh", NMesh_Init());
|
||||||
PyDict_SetItemString (dict, "Material", M_Material_Init());
|
PyDict_SetItemString (dict, "Material", Material_Init());
|
||||||
PyDict_SetItemString (dict, "Camera", M_Camera_Init());
|
PyDict_SetItemString (dict, "Camera", Camera_Init());
|
||||||
PyDict_SetItemString (dict, "Lamp", M_Lamp_Init());
|
PyDict_SetItemString (dict, "Lamp", Lamp_Init());
|
||||||
PyDict_SetItemString (dict, "Curve", M_Curve_Init());
|
PyDict_SetItemString (dict, "Curve", M_Curve_Init());
|
||||||
PyDict_SetItemString (dict, "Armature", M_Armature_Init());
|
PyDict_SetItemString (dict, "Armature", M_Armature_Init());
|
||||||
PyDict_SetItemString (dict, "Ipo", M_Ipo_Init());
|
PyDict_SetItemString (dict, "Ipo", M_Ipo_Init());
|
||||||
PyDict_SetItemString (dict, "Metaball", M_Metaball_Init());
|
PyDict_SetItemString (dict, "Metaball", M_Metaball_Init());
|
||||||
PyDict_SetItemString (dict, "Image", M_Image_Init());
|
PyDict_SetItemString (dict, "Image", Image_Init());
|
||||||
PyDict_SetItemString (dict, "Window", M_Window_Init());
|
PyDict_SetItemString (dict, "Window", Window_Init());
|
||||||
PyDict_SetItemString (dict, "Draw", M_Draw_Init());
|
PyDict_SetItemString (dict, "Draw", Draw_Init());
|
||||||
PyDict_SetItemString (dict, "BGL", M_BGL_Init());
|
PyDict_SetItemString (dict, "BGL", BGL_Init());
|
||||||
PyDict_SetItemString (dict, "Effect", M_Effect_Init());
|
PyDict_SetItemString (dict, "Effect", M_Effect_Init());
|
||||||
PyDict_SetItemString (dict, "Text", M_Text_Init());
|
PyDict_SetItemString (dict, "Text", Text_Init());
|
||||||
PyDict_SetItemString (dict, "World", M_World_Init());
|
PyDict_SetItemString (dict, "World", M_World_Init());
|
||||||
}
|
}
|
||||||
|
@@ -71,7 +71,7 @@ PyObject *Blender_ReleaseGlobalDict(PyObject *self, PyObject *args);
|
|||||||
char Blender_Set_doc[] =
|
char Blender_Set_doc[] =
|
||||||
"(request, data) - Update settings in Blender\n\
|
"(request, data) - Update settings in Blender\n\
|
||||||
\n\
|
\n\
|
||||||
(request) A string indentifying the setting to change\n\
|
(request) A string identifying the setting to change\n\
|
||||||
'curframe' - Sets the current frame using the number in data";
|
'curframe' - Sets the current frame using the number in data";
|
||||||
|
|
||||||
char Blender_Get_doc[] =
|
char Blender_Get_doc[] =
|
||||||
|
@@ -29,15 +29,6 @@
|
|||||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
* \file Camera.c
|
|
||||||
* \ingroup scripts
|
|
||||||
* \brief Blender.Camera Module and Camera Data PyObject implementation.
|
|
||||||
*
|
|
||||||
* This file is kept as a reference for new developers. If you want to
|
|
||||||
* create a new Python Module for Blender, Camera.c is a good starting point.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <BKE_main.h>
|
#include <BKE_main.h>
|
||||||
#include <BKE_global.h>
|
#include <BKE_global.h>
|
||||||
#include <BKE_object.h>
|
#include <BKE_object.h>
|
||||||
@@ -47,196 +38,6 @@
|
|||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Python BPy_Camera defaults: */
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
/* Camera types */
|
|
||||||
|
|
||||||
#define EXPP_CAM_TYPE_PERSP 0
|
|
||||||
#define EXPP_CAM_TYPE_ORTHO 1
|
|
||||||
|
|
||||||
/* Camera mode flags */
|
|
||||||
|
|
||||||
#define EXPP_CAM_MODE_SHOWLIMITS 1
|
|
||||||
#define EXPP_CAM_MODE_SHOWMIST 2
|
|
||||||
|
|
||||||
/* Camera MIN, MAX values */
|
|
||||||
|
|
||||||
#define EXPP_CAM_LENS_MIN 1.0
|
|
||||||
#define EXPP_CAM_LENS_MAX 250.0
|
|
||||||
#define EXPP_CAM_CLIPSTART_MIN 0.0
|
|
||||||
#define EXPP_CAM_CLIPSTART_MAX 100.0
|
|
||||||
#define EXPP_CAM_CLIPEND_MIN 1.0
|
|
||||||
#define EXPP_CAM_CLIPEND_MAX 5000.0
|
|
||||||
#define EXPP_CAM_DRAWSIZE_MIN 0.1
|
|
||||||
#define EXPP_CAM_DRAWSIZE_MAX 10.0
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Python API function prototypes for the Camera module. */
|
|
||||||
/*****************************************************************************/
|
|
||||||
static PyObject *M_Camera_New (PyObject *self, PyObject *args,
|
|
||||||
PyObject *keywords);
|
|
||||||
static PyObject *M_Camera_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.Camera.__doc__ */
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \var M_Camera_doc
|
|
||||||
* \brief Doc string for the Blender.Camera module
|
|
||||||
*/
|
|
||||||
|
|
||||||
static char M_Camera_doc[] =
|
|
||||||
"The Blender Camera module\n\
|
|
||||||
\n\
|
|
||||||
This module provides access to **Camera Data** objects in Blender\n\
|
|
||||||
\n\
|
|
||||||
Example::\n\
|
|
||||||
\n\
|
|
||||||
from Blender import Camera, Object, Scene\n\
|
|
||||||
c = Camera.New('ortho') # create new ortho camera data\n\
|
|
||||||
c.lens = 35.0 # set lens value\n\
|
|
||||||
cur = Scene.getCurrent() # get current Scene\n\
|
|
||||||
ob = Object.New('Camera') # make camera object\n\
|
|
||||||
ob.link(c) # link camera data with this object\n\
|
|
||||||
cur.link(ob) # link object into scene\n\
|
|
||||||
cur.setCurrentCamera(ob) # make this camera the active";
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \var M_Camera_New_doc
|
|
||||||
* \brief Doc string for the Blender.Camera.New() module function
|
|
||||||
*/
|
|
||||||
|
|
||||||
static char M_Camera_New_doc[] =
|
|
||||||
"Blender.Camera.New (type = 'persp', name = 'CamData'):\n\
|
|
||||||
\n\
|
|
||||||
(type) - Return a new Camera Data object of type \"type\",\n\
|
|
||||||
which can be 'persp' or 'ortho';\n\
|
|
||||||
() - Return a new Camera Data object of type 'persp'.";
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \var M_Camera_Get_doc
|
|
||||||
* \brief Doc string for the Blender.Camera.Get() module function
|
|
||||||
*/
|
|
||||||
|
|
||||||
static char M_Camera_Get_doc[] =
|
|
||||||
"Blender.Camera.Get (name = None):\n\
|
|
||||||
\n\
|
|
||||||
(name) - Return the Camera Data object with the given 'name',\n\
|
|
||||||
None if not found;\n\
|
|
||||||
() - Return a list with all Camera Data objects in the current scene.";
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Python method structure definition for Blender.Camera module: */
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \var M_Camera_methods
|
|
||||||
* \brief Table of module functions.
|
|
||||||
*
|
|
||||||
* The Blender.Camera functions are registered with this table.
|
|
||||||
* Each entry defines: the method name in Python, the pointer to its C
|
|
||||||
* function, the argument list expected and a doc string.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct PyMethodDef M_Camera_methods[] = {
|
|
||||||
{"New",(PyCFunction)M_Camera_New, METH_VARARGS|METH_KEYWORDS,
|
|
||||||
M_Camera_New_doc},
|
|
||||||
{"Get", M_Camera_Get, METH_VARARGS, M_Camera_Get_doc},
|
|
||||||
{"get", M_Camera_Get, METH_VARARGS, M_Camera_Get_doc},
|
|
||||||
{NULL, NULL, 0, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Python BPy_Camera methods declarations: */
|
|
||||||
/*****************************************************************************/
|
|
||||||
static PyObject *Camera_getName(BPy_Camera *self);
|
|
||||||
static PyObject *Camera_getType(BPy_Camera *self);
|
|
||||||
static PyObject *Camera_getMode(BPy_Camera *self);
|
|
||||||
static PyObject *Camera_getLens(BPy_Camera *self);
|
|
||||||
static PyObject *Camera_getClipStart(BPy_Camera *self);
|
|
||||||
static PyObject *Camera_getClipEnd(BPy_Camera *self);
|
|
||||||
static PyObject *Camera_getDrawSize(BPy_Camera *self);
|
|
||||||
static PyObject *Camera_setName(BPy_Camera *self, PyObject *args);
|
|
||||||
static PyObject *Camera_setType(BPy_Camera *self, PyObject *args);
|
|
||||||
static PyObject *Camera_setIntType(BPy_Camera *self, PyObject *args);
|
|
||||||
static PyObject *Camera_setMode(BPy_Camera *self, PyObject *args);
|
|
||||||
static PyObject *Camera_setIntMode(BPy_Camera *self, PyObject *args);
|
|
||||||
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);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Python BPy_Camera methods table: */
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \var BPy_Camera_methods
|
|
||||||
* \showinitializer
|
|
||||||
* \brief Table of Camera member functions
|
|
||||||
*
|
|
||||||
* This table registers the Camera PyObject methods.
|
|
||||||
* Each entry defines: the method name in Python, the pointer to its C
|
|
||||||
* function, the argument list expected and a doc string.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyMethodDef BPy_Camera_methods[] = {
|
|
||||||
/* name, method, flags, doc */
|
|
||||||
{"getName", (PyCFunction)Camera_getName, METH_NOARGS,
|
|
||||||
"() - Return Camera Data name"},
|
|
||||||
{"getType", (PyCFunction)Camera_getType, METH_NOARGS,
|
|
||||||
"() - Return Camera type - 'persp':0, 'ortho':1"},
|
|
||||||
{"getMode", (PyCFunction)Camera_getMode, METH_NOARGS,
|
|
||||||
"() - Return Camera mode flags (or'ed value) -\n"
|
|
||||||
" 'showLimits':1, 'showMist':2"},
|
|
||||||
{"getLens", (PyCFunction)Camera_getLens, METH_NOARGS,
|
|
||||||
"() - Return Camera lens value"},
|
|
||||||
{"getClipStart", (PyCFunction)Camera_getClipStart, METH_NOARGS,
|
|
||||||
"() - Return Camera clip start value"},
|
|
||||||
{"getClipEnd", (PyCFunction)Camera_getClipEnd, METH_NOARGS,
|
|
||||||
"() - Return Camera clip end value"},
|
|
||||||
{"getDrawSize", (PyCFunction)Camera_getDrawSize, METH_NOARGS,
|
|
||||||
"() - Return Camera draw size value"},
|
|
||||||
{"setName", (PyCFunction)Camera_setName, METH_VARARGS,
|
|
||||||
"(s) - Set Camera Data name"},
|
|
||||||
{"setType", (PyCFunction)Camera_setType, METH_VARARGS,
|
|
||||||
"(s) - Set Camera type, which can be 'persp' or 'ortho'"},
|
|
||||||
{"setMode", (PyCFunction)Camera_setMode, METH_VARARGS,
|
|
||||||
"(<s<,s>>) - Set Camera mode flag(s): 'showLimits' and 'showMist'"},
|
|
||||||
{"setLens", (PyCFunction)Camera_setLens, METH_VARARGS,
|
|
||||||
"(f) - Set Camera lens value"},
|
|
||||||
{"setClipStart", (PyCFunction)Camera_setClipStart, METH_VARARGS,
|
|
||||||
"(f) - Set Camera clip start value"},
|
|
||||||
{"setClipEnd", (PyCFunction)Camera_setClipEnd, METH_VARARGS,
|
|
||||||
"(f) - Set Camera clip end value"},
|
|
||||||
{"setDrawSize", (PyCFunction)Camera_setDrawSize, METH_VARARGS,
|
|
||||||
"(f) - Set Camera draw size value"},
|
|
||||||
{0}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Python Camera_Type callback function prototypes: */
|
|
||||||
/*****************************************************************************/
|
|
||||||
static void Camera_DeAlloc (BPy_Camera *self);
|
|
||||||
static int Camera_Print (BPy_Camera *self, FILE *fp, int flags);
|
|
||||||
static int Camera_SetAttr (BPy_Camera *self, char *name, PyObject *v);
|
|
||||||
static int Camera_Compare (BPy_Camera *a, BPy_Camera *b);
|
|
||||||
static PyObject *Camera_GetAttr (BPy_Camera *self, char *name);
|
|
||||||
static PyObject *Camera_Repr (BPy_Camera *self);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \var Camera_Type
|
|
||||||
* \brief Definition for the Camera PyObject struct
|
|
||||||
*
|
|
||||||
* Here we define the Camera PyType: its name, size, available function
|
|
||||||
* pointers and table of bound methods.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python Camera_Type structure definition: */
|
/* Python Camera_Type structure definition: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -244,7 +45,7 @@ PyTypeObject Camera_Type =
|
|||||||
{
|
{
|
||||||
PyObject_HEAD_INIT(NULL)
|
PyObject_HEAD_INIT(NULL)
|
||||||
0, /* ob_size */
|
0, /* ob_size */
|
||||||
"Camera", /* tp_name */
|
"Blender Camera", /* tp_name */
|
||||||
sizeof (BPy_Camera), /* tp_basicsize */
|
sizeof (BPy_Camera), /* tp_basicsize */
|
||||||
0, /* tp_itemsize */
|
0, /* tp_itemsize */
|
||||||
/* methods */
|
/* methods */
|
||||||
@@ -265,23 +66,6 @@ PyTypeObject Camera_Type =
|
|||||||
0, /* tp_members */
|
0, /* tp_members */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
|
||||||
* \defgroup M_Functions Blender.Camera functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*! @{ */
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Python module function: Blender.Camera.New()
|
|
||||||
*
|
|
||||||
* This is the .New() function of the Blender.Camera submodule. It creates
|
|
||||||
* new Camera Data in Blender and returns its wrapper PyObject. The
|
|
||||||
* parameters are optional and default to type = 'persp' and name = 'CamData'.
|
|
||||||
* \param <type> - string: The Camera type: 'persp' or 'ortho';
|
|
||||||
* \param <name> - string: The Camera Data name.
|
|
||||||
* \return A new Camera PyObject.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *kwords)
|
static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *kwords)
|
||||||
{
|
{
|
||||||
char *type_str = "persp"; /* "persp" is type 0, "ortho" is type 1 */
|
char *type_str = "persp"; /* "persp" is type 0, "ortho" is type 1 */
|
||||||
@@ -292,7 +76,7 @@ static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *kwords)
|
|||||||
char buf[21];
|
char buf[21];
|
||||||
|
|
||||||
printf ("In Camera_New()\n");
|
printf ("In Camera_New()\n");
|
||||||
/* Parse the arguments passed in by the Python interpreter */
|
/* Parse the arguments passed in by the Python interpreter */
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwords, "|ss", kwlist,
|
if (!PyArg_ParseTupleAndKeywords(args, kwords, "|ss", kwlist,
|
||||||
&type_str, &name_str))
|
&type_str, &name_str))
|
||||||
/* We expected string(s) (or nothing) as argument, but we didn't get that. */
|
/* We expected string(s) (or nothing) as argument, but we didn't get that. */
|
||||||
@@ -307,9 +91,9 @@ static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *kwords)
|
|||||||
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||||
"couldn't create Camera Data in Blender");
|
"couldn't create Camera Data in Blender");
|
||||||
|
|
||||||
/* let's return user count to zero, because ... */
|
/* let's return user count to zero, because ... */
|
||||||
blcam->id.us = 0; /* ... add_camera() incref'ed it */
|
blcam->id.us = 0; /* ... add_camera() incref'ed it */
|
||||||
/* XXX XXX Do this in other modules, too */
|
/* XXX XXX Do this in other modules, too */
|
||||||
|
|
||||||
if (pycam == NULL)
|
if (pycam == NULL)
|
||||||
return EXPP_ReturnPyObjError (PyExc_MemoryError,
|
return EXPP_ReturnPyObjError (PyExc_MemoryError,
|
||||||
@@ -333,19 +117,6 @@ static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *kwords)
|
|||||||
return pycam;
|
return pycam;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Python module function: Blender.Camera.Get()
|
|
||||||
*
|
|
||||||
* This is the .Get() function of the Blender.Camera submodule. It searches
|
|
||||||
* the list of current Camera Data objects and returns a Python wrapper for
|
|
||||||
* the one with the name provided by the user. If called with no arguments,
|
|
||||||
* it returns a list with Python wrappers for all current Camera Data objects
|
|
||||||
* in Blender.
|
|
||||||
* \param <name> - string: The name of an existing Blender Camera Data object.
|
|
||||||
* \return () - A list with wrappers for all current Camera Data objects;\n
|
|
||||||
* \return (name) - A wrapper for the Camera Data called 'name' in Blender.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *M_Camera_Get(PyObject *self, PyObject *args)
|
static PyObject *M_Camera_Get(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
@@ -363,10 +134,10 @@ static PyObject *M_Camera_Get(PyObject *self, PyObject *args)
|
|||||||
|
|
||||||
while (cam_iter && !wanted_cam) {
|
while (cam_iter && !wanted_cam) {
|
||||||
|
|
||||||
if (strcmp (name, cam_iter->id.name+2) == 0) {
|
if (strcmp (name, cam_iter->id.name+2) == 0) {
|
||||||
wanted_cam = Camera_CreatePyObject (cam_iter);
|
wanted_cam = Camera_CreatePyObject (cam_iter);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cam_iter = cam_iter->id.next;
|
cam_iter = cam_iter->id.next;
|
||||||
}
|
}
|
||||||
@@ -408,17 +179,7 @@ static PyObject *M_Camera_Get(PyObject *self, PyObject *args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@} Cam_M_Functions */
|
PyObject *Camera_Init (void)
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Initializes the Blender.Camera submodule
|
|
||||||
*
|
|
||||||
* This function is used by Blender_Init() in Blender.c to register the
|
|
||||||
* Blender.Camera submodule in the main Blender module.
|
|
||||||
* \return The initialized submodule.
|
|
||||||
*/
|
|
||||||
|
|
||||||
PyObject *M_Camera_Init (void)
|
|
||||||
{
|
{
|
||||||
PyObject *submodule;
|
PyObject *submodule;
|
||||||
|
|
||||||
@@ -434,15 +195,6 @@ PyObject *M_Camera_Init (void)
|
|||||||
|
|
||||||
/* Three Python Camera_Type helper functions needed by the Object module: */
|
/* Three Python Camera_Type helper functions needed by the Object module: */
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Creates a new Python wrapper from an existing Blender Camera Data obj
|
|
||||||
*
|
|
||||||
* This is also used in Object.c when defining the object.data member variable
|
|
||||||
* for an Object of type 'Camera'.
|
|
||||||
* \param cam - A pointer to an existing Blender Camera Data object.
|
|
||||||
* \return The Camera Data wrapper created.
|
|
||||||
*/
|
|
||||||
|
|
||||||
PyObject *Camera_CreatePyObject (Camera *cam)
|
PyObject *Camera_CreatePyObject (Camera *cam)
|
||||||
{
|
{
|
||||||
BPy_Camera *pycam;
|
BPy_Camera *pycam;
|
||||||
@@ -458,29 +210,11 @@ PyObject *Camera_CreatePyObject (Camera *cam)
|
|||||||
return (PyObject *)pycam;
|
return (PyObject *)pycam;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Checks if the given object is of type BPy_Camera
|
|
||||||
*
|
|
||||||
* This is also used in Object.c when handling the object.data member variable
|
|
||||||
* for an object of type 'Camera'.
|
|
||||||
* \param pyobj - A pointer to a Camera PyObject.
|
|
||||||
* \return True or false.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int Camera_CheckPyObject (PyObject *pyobj)
|
int Camera_CheckPyObject (PyObject *pyobj)
|
||||||
{
|
{
|
||||||
return (pyobj->ob_type == &Camera_Type);
|
return (pyobj->ob_type == &Camera_Type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Returns the Blender Camera object from the given PyObject
|
|
||||||
*
|
|
||||||
* This is also used in Object.c when handling the object.data member variable
|
|
||||||
* for an object of type 'Camera'.
|
|
||||||
* \param pyobj - A pointer to a Camera PyObject.
|
|
||||||
* \return A pointer to the wrapped Blender Camera Data object.
|
|
||||||
*/
|
|
||||||
|
|
||||||
Camera *Camera_FromPyObject (PyObject *pyobj)
|
Camera *Camera_FromPyObject (PyObject *pyobj)
|
||||||
{
|
{
|
||||||
return ((BPy_Camera *)pyobj)->camera;
|
return ((BPy_Camera *)pyobj)->camera;
|
||||||
@@ -489,20 +223,6 @@ Camera *Camera_FromPyObject (PyObject *pyobj)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python BPy_Camera methods: */
|
/* Python BPy_Camera methods: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/*!
|
|
||||||
* \defgroup CamMethods Camera Method Functions
|
|
||||||
*
|
|
||||||
* These are the Camera PyObject methods.
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Camera PyMethod getName
|
|
||||||
*
|
|
||||||
* \return string: The Camera Data name.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Camera_getName(BPy_Camera *self)
|
static PyObject *Camera_getName(BPy_Camera *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyString_FromString(self->camera->id.name+2);
|
PyObject *attr = PyString_FromString(self->camera->id.name+2);
|
||||||
@@ -513,12 +233,6 @@ static PyObject *Camera_getName(BPy_Camera *self)
|
|||||||
"couldn't get Camera.name attribute");
|
"couldn't get Camera.name attribute");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Camera PyMethod getType
|
|
||||||
*
|
|
||||||
* \return int: The Camera Data type.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Camera_getType(BPy_Camera *self)
|
static PyObject *Camera_getType(BPy_Camera *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyInt_FromLong(self->camera->type);
|
PyObject *attr = PyInt_FromLong(self->camera->type);
|
||||||
@@ -529,12 +243,6 @@ static PyObject *Camera_getType(BPy_Camera *self)
|
|||||||
"couldn't get Camera.type attribute");
|
"couldn't get Camera.type attribute");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Camera PyMethod getMode
|
|
||||||
*
|
|
||||||
* \return int: The Camera Data mode flags.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Camera_getMode(BPy_Camera *self)
|
static PyObject *Camera_getMode(BPy_Camera *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyInt_FromLong(self->camera->flag);
|
PyObject *attr = PyInt_FromLong(self->camera->flag);
|
||||||
@@ -545,12 +253,6 @@ static PyObject *Camera_getMode(BPy_Camera *self)
|
|||||||
"couldn't get Camera.Mode attribute");
|
"couldn't get Camera.Mode attribute");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Camera PyMethod getLens
|
|
||||||
*
|
|
||||||
* \return float: The Camera Data lens value
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Camera_getLens(BPy_Camera *self)
|
static PyObject *Camera_getLens(BPy_Camera *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyFloat_FromDouble(self->camera->lens);
|
PyObject *attr = PyFloat_FromDouble(self->camera->lens);
|
||||||
@@ -561,12 +263,6 @@ static PyObject *Camera_getLens(BPy_Camera *self)
|
|||||||
"couldn't get Camera.lens attribute");
|
"couldn't get Camera.lens attribute");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Camera PyMethod getClipStart
|
|
||||||
*
|
|
||||||
* \return float: The Camera Data clip start value.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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);
|
||||||
@@ -577,11 +273,6 @@ static PyObject *Camera_getClipStart(BPy_Camera *self)
|
|||||||
"couldn't get Camera.clipStart attribute");
|
"couldn't get Camera.clipStart attribute");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Camera PyMethod getClipEnd
|
|
||||||
* \return float: The Camera Data clip end value.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Camera_getClipEnd(BPy_Camera *self)
|
static PyObject *Camera_getClipEnd(BPy_Camera *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyFloat_FromDouble(self->camera->clipend);
|
PyObject *attr = PyFloat_FromDouble(self->camera->clipend);
|
||||||
@@ -592,11 +283,6 @@ static PyObject *Camera_getClipEnd(BPy_Camera *self)
|
|||||||
"couldn't get Camera.clipEnd attribute");
|
"couldn't get Camera.clipEnd attribute");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Camera method getDrawSize
|
|
||||||
* \return float: The Camera Data draw size value.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Camera_getDrawSize(BPy_Camera *self)
|
static PyObject *Camera_getDrawSize(BPy_Camera *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyFloat_FromDouble(self->camera->drawsize);
|
PyObject *attr = PyFloat_FromDouble(self->camera->drawsize);
|
||||||
@@ -607,11 +293,6 @@ static PyObject *Camera_getDrawSize(BPy_Camera *self)
|
|||||||
"couldn't get Camera.drawSize attribute");
|
"couldn't get Camera.drawSize attribute");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Camera PyMethod setName
|
|
||||||
* \param name - string: The new Camera Data name.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Camera_setName(BPy_Camera *self, PyObject *args)
|
static PyObject *Camera_setName(BPy_Camera *self, PyObject *args)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
@@ -629,11 +310,6 @@ static PyObject *Camera_setName(BPy_Camera *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Camera PyMethod setType
|
|
||||||
* \param type - string: The new Camera Data type: 'persp' or 'ortho'.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Camera_setType(BPy_Camera *self, PyObject *args)
|
static PyObject *Camera_setType(BPy_Camera *self, PyObject *args)
|
||||||
{
|
{
|
||||||
char *type;
|
char *type;
|
||||||
@@ -660,13 +336,6 @@ static PyObject *Camera_setType(BPy_Camera *self, PyObject *args)
|
|||||||
* the method setType expects a string ('persp' or 'ortho') or an empty
|
* the method setType expects a string ('persp' or 'ortho') or an empty
|
||||||
* argument, this function should receive an int (0 or 1). */
|
* argument, this function should receive an int (0 or 1). */
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Internal helper function
|
|
||||||
*
|
|
||||||
* This one is not a PyMethod. It is just an internal helper function.
|
|
||||||
* \param type - int: The Camera Data type as an int.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Camera_setIntType(BPy_Camera *self, PyObject *args)
|
static PyObject *Camera_setIntType(BPy_Camera *self, PyObject *args)
|
||||||
{
|
{
|
||||||
short value;
|
short value;
|
||||||
@@ -685,17 +354,6 @@ static PyObject *Camera_setIntType(BPy_Camera *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Camera PyMethod setMode
|
|
||||||
*
|
|
||||||
* There are two mode flags for Cameras: 'showLimits' and 'showMist'.
|
|
||||||
* Both can be set at the same time, by providing two arguments to this
|
|
||||||
* method. To clear a flag, call setMode without the respective flag string
|
|
||||||
* in the argument list. For example: .setMode() clears both flags.
|
|
||||||
* \param mode1 - <string>: The first mode flag to set;
|
|
||||||
* \param mode2 - <string>: The second mode flag to set.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Camera_setMode(BPy_Camera *self, PyObject *args)
|
static PyObject *Camera_setMode(BPy_Camera *self, PyObject *args)
|
||||||
{
|
{
|
||||||
char *mode_str1 = NULL, *mode_str2 = NULL;
|
char *mode_str1 = NULL, *mode_str2 = NULL;
|
||||||
@@ -734,13 +392,6 @@ static PyObject *Camera_setMode(BPy_Camera *self, PyObject *args)
|
|||||||
/* Another helper function, for the same reason.
|
/* Another helper function, for the same reason.
|
||||||
* (See comment before Camera_setIntType above). */
|
* (See comment before Camera_setIntType above). */
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Internal helper function
|
|
||||||
*
|
|
||||||
* This one is not a PyMethod. It is just an internal helper function.
|
|
||||||
* \param mode - int: The Camera Data mode as an int.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Camera_setIntMode(BPy_Camera *self, PyObject *args)
|
static PyObject *Camera_setIntMode(BPy_Camera *self, PyObject *args)
|
||||||
{
|
{
|
||||||
short value;
|
short value;
|
||||||
@@ -759,11 +410,6 @@ static PyObject *Camera_setIntMode(BPy_Camera *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Camera PyMethod setLens
|
|
||||||
* \param lens - float: The new Camera Data lens value.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Camera_setLens(BPy_Camera *self, PyObject *args)
|
static PyObject *Camera_setLens(BPy_Camera *self, PyObject *args)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
@@ -779,11 +425,6 @@ static PyObject *Camera_setLens(BPy_Camera *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Camera PyMethod setClipStart
|
|
||||||
* \param clipStart - float: The new Camera Data clip start value.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Camera_setClipStart(BPy_Camera *self, PyObject *args)
|
static PyObject *Camera_setClipStart(BPy_Camera *self, PyObject *args)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
@@ -799,11 +440,6 @@ static PyObject *Camera_setClipStart(BPy_Camera *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Camera PyMethod setClipEnd
|
|
||||||
* \param clipEnd - float: The new Camera Data clip end value.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Camera_setClipEnd(BPy_Camera *self, PyObject *args)
|
static PyObject *Camera_setClipEnd(BPy_Camera *self, PyObject *args)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
@@ -819,11 +455,6 @@ static PyObject *Camera_setClipEnd(BPy_Camera *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Camera PyMethod setDrawSize
|
|
||||||
* \param drawSize - float: The new Camera Data draw size value.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Camera_setDrawSize(BPy_Camera *self, PyObject *args)
|
static PyObject *Camera_setDrawSize(BPy_Camera *self, PyObject *args)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
@@ -839,24 +470,11 @@ static PyObject *Camera_setDrawSize(BPy_Camera *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@} Cam_Methods group */
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief The Camera PyType destructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void Camera_DeAlloc (BPy_Camera *self)
|
static void Camera_DeAlloc (BPy_Camera *self)
|
||||||
{
|
{
|
||||||
PyObject_DEL (self);
|
PyObject_DEL (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief The Camera PyType attribute getter
|
|
||||||
*
|
|
||||||
* This is the callback called when a user tries to retrieve the contents of
|
|
||||||
* Camera PyObject data members. Ex. in Python: "print mycamera.lens".
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Camera_GetAttr (BPy_Camera *self, char *name)
|
static PyObject *Camera_GetAttr (BPy_Camera *self, char *name)
|
||||||
{
|
{
|
||||||
PyObject *attr = Py_None;
|
PyObject *attr = Py_None;
|
||||||
@@ -902,13 +520,6 @@ static PyObject *Camera_GetAttr (BPy_Camera *self, char *name)
|
|||||||
return Py_FindMethod(BPy_Camera_methods, (PyObject *)self, name);
|
return Py_FindMethod(BPy_Camera_methods, (PyObject *)self, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief The Camera PyType attribute setter
|
|
||||||
*
|
|
||||||
* This is the callback called when the user tries to change the value of some
|
|
||||||
* Camera data member. Ex. in Python: "mycamera.lens = 45.0".
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int Camera_SetAttr (BPy_Camera *self, char *name, PyObject *value)
|
static int Camera_SetAttr (BPy_Camera *self, char *name, PyObject *value)
|
||||||
{
|
{
|
||||||
PyObject *valtuple;
|
PyObject *valtuple;
|
||||||
@@ -968,43 +579,18 @@ static int Camera_SetAttr (BPy_Camera *self, char *name, PyObject *value)
|
|||||||
return 0; /* normal exit */
|
return 0; /* normal exit */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief The Camera PyType compare function
|
|
||||||
*
|
|
||||||
* This function compares two given Camera PyObjects, returning 0 for equality
|
|
||||||
* and -1 otherwise. In Python it becomes 1 if they are equal and 0 case not.
|
|
||||||
* The comparison is done with their pointers to Blender Camera Data objects,
|
|
||||||
* so any two wrappers pointing to the same Blender Camera Data will be
|
|
||||||
* considered the same Camera PyObject. Currently, only the "==" and "!="
|
|
||||||
* comparisons are meaninful -- the "<", "<=", ">" or ">=" are not.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int Camera_Compare (BPy_Camera *a, BPy_Camera *b)
|
static int Camera_Compare (BPy_Camera *a, BPy_Camera *b)
|
||||||
{
|
{
|
||||||
Camera *pa = a->camera, *pb = b->camera;
|
Camera *pa = a->camera, *pb = b->camera;
|
||||||
return (pa == pb) ? 0:-1;
|
return (pa == pb) ? 0:-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief The Camera PyType print callback
|
|
||||||
*
|
|
||||||
* This function is called when the user tries to print a PyObject of type
|
|
||||||
* Camera. It builds a string with the name of the wrapped Blender Camera.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int Camera_Print(BPy_Camera *self, FILE *fp, int flags)
|
static int Camera_Print(BPy_Camera *self, FILE *fp, int flags)
|
||||||
{
|
{
|
||||||
fprintf(fp, "[Camera \"%s\"]", self->camera->id.name+2);
|
fprintf(fp, "[Camera \"%s\"]", self->camera->id.name+2);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief The Camera PyType repr callback
|
|
||||||
*
|
|
||||||
* This function is called when the statement "repr(mycamera)" is executed in
|
|
||||||
* Python. Repr gives a string representation of a PyObject.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Camera_Repr (BPy_Camera *self)
|
static PyObject *Camera_Repr (BPy_Camera *self)
|
||||||
{
|
{
|
||||||
return PyString_FromString(self->camera->id.name+2);
|
return PyString_FromString(self->camera->id.name+2);
|
||||||
|
@@ -36,30 +36,149 @@
|
|||||||
#include <DNA_camera_types.h>
|
#include <DNA_camera_types.h>
|
||||||
#include "constant.h"
|
#include "constant.h"
|
||||||
#include "gen_utils.h"
|
#include "gen_utils.h"
|
||||||
|
#include "modules.h"
|
||||||
/* The Camera PyType Object defined in Camera.c */
|
#include "bpy_types.h" /* where the BPy_Camera struct is declared */
|
||||||
extern PyTypeObject Camera_Type;
|
|
||||||
|
|
||||||
#define BPy_Camera_Check(v) \
|
|
||||||
((v)->ob_type == &Camera_Type) /* for type checking */
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python BPy_Camera structure definition: */
|
/* Python BPy_Camera defaults: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
typedef struct {
|
|
||||||
PyObject_HEAD
|
|
||||||
Camera *camera;
|
|
||||||
|
|
||||||
} BPy_Camera;
|
/* Camera types */
|
||||||
|
|
||||||
|
#define EXPP_CAM_TYPE_PERSP 0
|
||||||
|
#define EXPP_CAM_TYPE_ORTHO 1
|
||||||
|
|
||||||
|
/* Camera mode flags */
|
||||||
|
|
||||||
|
#define EXPP_CAM_MODE_SHOWLIMITS 1
|
||||||
|
#define EXPP_CAM_MODE_SHOWMIST 2
|
||||||
|
|
||||||
|
/* Camera MIN, MAX values */
|
||||||
|
|
||||||
|
#define EXPP_CAM_LENS_MIN 1.0
|
||||||
|
#define EXPP_CAM_LENS_MAX 250.0
|
||||||
|
#define EXPP_CAM_CLIPSTART_MIN 0.0
|
||||||
|
#define EXPP_CAM_CLIPSTART_MAX 100.0
|
||||||
|
#define EXPP_CAM_CLIPEND_MIN 1.0
|
||||||
|
#define EXPP_CAM_CLIPEND_MAX 5000.0
|
||||||
|
#define EXPP_CAM_DRAWSIZE_MIN 0.1
|
||||||
|
#define EXPP_CAM_DRAWSIZE_MAX 10.0
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python Camera_Type helper functions needed by Blender (the Init function) */
|
/* Python API function prototypes for the Camera module. */
|
||||||
/* and Object modules. */
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *M_Camera_Init (void);
|
static PyObject *M_Camera_New (PyObject *self, PyObject *args,
|
||||||
PyObject *Camera_CreatePyObject (Camera *cam);
|
PyObject *keywords);
|
||||||
Camera *Camera_FromPyObject (PyObject *pyobj);
|
static PyObject *M_Camera_Get (PyObject *self, PyObject *args);
|
||||||
int Camera_CheckPyObject (PyObject *pyobj);
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* The following string definitions are used for documentation strings. */
|
||||||
|
/* In Python these will be written to the console when doing a */
|
||||||
|
/* Blender.Camera.__doc__ */
|
||||||
|
/*****************************************************************************/
|
||||||
|
static char M_Camera_doc[] =
|
||||||
|
"The Blender Camera module\n\
|
||||||
|
\n\
|
||||||
|
This module provides access to **Camera Data** objects in Blender\n\
|
||||||
|
\n\
|
||||||
|
Example::\n\
|
||||||
|
\n\
|
||||||
|
from Blender import Camera, Object, Scene\n\
|
||||||
|
c = Camera.New('ortho') # create new ortho camera data\n\
|
||||||
|
c.lens = 35.0 # set lens value\n\
|
||||||
|
cur = Scene.getCurrent() # get current Scene\n\
|
||||||
|
ob = Object.New('Camera') # make camera object\n\
|
||||||
|
ob.link(c) # link camera data with this object\n\
|
||||||
|
cur.link(ob) # link object into scene\n\
|
||||||
|
cur.setCurrentCamera(ob) # make this camera the active";
|
||||||
|
|
||||||
|
static char M_Camera_New_doc[] =
|
||||||
|
"Camera.New (type = 'persp', name = 'CamData'):\n\
|
||||||
|
Return a new Camera Data object with the given type and name.";
|
||||||
|
|
||||||
|
static char M_Camera_Get_doc[] =
|
||||||
|
"Camera.Get (name = None):\n\
|
||||||
|
Return the camera data with the given 'name', None if not found, or\n\
|
||||||
|
Return a list with all Camera Data objects in the current scene,\n\
|
||||||
|
if no argument was given.";
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Python method structure definition for Blender.Camera module: */
|
||||||
|
/*****************************************************************************/
|
||||||
|
struct PyMethodDef M_Camera_methods[] = {
|
||||||
|
{"New",(PyCFunction)M_Camera_New, METH_VARARGS|METH_KEYWORDS,
|
||||||
|
M_Camera_New_doc},
|
||||||
|
{"Get", M_Camera_Get, METH_VARARGS, M_Camera_Get_doc},
|
||||||
|
{"get", M_Camera_Get, METH_VARARGS, M_Camera_Get_doc},
|
||||||
|
{NULL, NULL, 0, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Python BPy_Camera methods declarations: */
|
||||||
|
/*****************************************************************************/
|
||||||
|
static PyObject *Camera_getName(BPy_Camera *self);
|
||||||
|
static PyObject *Camera_getType(BPy_Camera *self);
|
||||||
|
static PyObject *Camera_getMode(BPy_Camera *self);
|
||||||
|
static PyObject *Camera_getLens(BPy_Camera *self);
|
||||||
|
static PyObject *Camera_getClipStart(BPy_Camera *self);
|
||||||
|
static PyObject *Camera_getClipEnd(BPy_Camera *self);
|
||||||
|
static PyObject *Camera_getDrawSize(BPy_Camera *self);
|
||||||
|
static PyObject *Camera_setName(BPy_Camera *self, PyObject *args);
|
||||||
|
static PyObject *Camera_setType(BPy_Camera *self, PyObject *args);
|
||||||
|
static PyObject *Camera_setIntType(BPy_Camera *self, PyObject *args);
|
||||||
|
static PyObject *Camera_setMode(BPy_Camera *self, PyObject *args);
|
||||||
|
static PyObject *Camera_setIntMode(BPy_Camera *self, PyObject *args);
|
||||||
|
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);
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Python BPy_Camera methods table: */
|
||||||
|
/*****************************************************************************/
|
||||||
|
static PyMethodDef BPy_Camera_methods[] = {
|
||||||
|
/* name, method, flags, doc */
|
||||||
|
{"getName", (PyCFunction)Camera_getName, METH_NOARGS,
|
||||||
|
"() - Return Camera Data name"},
|
||||||
|
{"getType", (PyCFunction)Camera_getType, METH_NOARGS,
|
||||||
|
"() - Return Camera type - 'persp':0, 'ortho':1"},
|
||||||
|
{"getMode", (PyCFunction)Camera_getMode, METH_NOARGS,
|
||||||
|
"() - Return Camera mode flags (or'ed value) -\n"
|
||||||
|
" 'showLimits':1, 'showMist':2"},
|
||||||
|
{"getLens", (PyCFunction)Camera_getLens, METH_NOARGS,
|
||||||
|
"() - Return Camera lens value"},
|
||||||
|
{"getClipStart", (PyCFunction)Camera_getClipStart, METH_NOARGS,
|
||||||
|
"() - Return Camera clip start value"},
|
||||||
|
{"getClipEnd", (PyCFunction)Camera_getClipEnd, METH_NOARGS,
|
||||||
|
"() - Return Camera clip end value"},
|
||||||
|
{"getDrawSize", (PyCFunction)Camera_getDrawSize, METH_NOARGS,
|
||||||
|
"() - Return Camera draw size value"},
|
||||||
|
{"setName", (PyCFunction)Camera_setName, METH_VARARGS,
|
||||||
|
"(s) - Set Camera Data name"},
|
||||||
|
{"setType", (PyCFunction)Camera_setType, METH_VARARGS,
|
||||||
|
"(s) - Set Camera type, which can be 'persp' or 'ortho'"},
|
||||||
|
{"setMode", (PyCFunction)Camera_setMode, METH_VARARGS,
|
||||||
|
"(<s<,s>>) - Set Camera mode flag(s): 'showLimits' and 'showMist'"},
|
||||||
|
{"setLens", (PyCFunction)Camera_setLens, METH_VARARGS,
|
||||||
|
"(f) - Set Camera lens value"},
|
||||||
|
{"setClipStart", (PyCFunction)Camera_setClipStart, METH_VARARGS,
|
||||||
|
"(f) - Set Camera clip start value"},
|
||||||
|
{"setClipEnd", (PyCFunction)Camera_setClipEnd, METH_VARARGS,
|
||||||
|
"(f) - Set Camera clip end value"},
|
||||||
|
{"setDrawSize", (PyCFunction)Camera_setDrawSize, METH_VARARGS,
|
||||||
|
"(f) - Set Camera draw size value"},
|
||||||
|
{0}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Python Camera_Type callback function prototypes: */
|
||||||
|
/*****************************************************************************/
|
||||||
|
static void Camera_DeAlloc (BPy_Camera *self);
|
||||||
|
static int Camera_Print (BPy_Camera *self, FILE *fp, int flags);
|
||||||
|
static int Camera_SetAttr (BPy_Camera *self, char *name, PyObject *v);
|
||||||
|
static int Camera_Compare (BPy_Camera *a, BPy_Camera *b);
|
||||||
|
static PyObject *Camera_GetAttr (BPy_Camera *self, char *name);
|
||||||
|
static PyObject *Camera_Repr (BPy_Camera *self);
|
||||||
|
|
||||||
|
|
||||||
#endif /* EXPP_CAMERA_H */
|
#endif /* EXPP_CAMERA_H */
|
||||||
|
@@ -634,7 +634,7 @@ static PyObject *Method_Text (PyObject *self, PyObject *args)
|
|||||||
return EXPP_incr_ret(Py_None);
|
return EXPP_incr_ret(Py_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *M_Draw_Init (void)
|
PyObject *Draw_Init (void)
|
||||||
{
|
{
|
||||||
PyObject *submodule, *dict;
|
PyObject *submodule, *dict;
|
||||||
|
|
||||||
|
@@ -204,9 +204,9 @@ static PyObject *M_Image_Load(PyObject *self, PyObject *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: M_Image_Init */
|
/* Function: Image_Init */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *M_Image_Init (void)
|
PyObject *Image_Init (void)
|
||||||
{
|
{
|
||||||
PyObject *submodule;
|
PyObject *submodule;
|
||||||
|
|
||||||
|
@@ -31,6 +31,34 @@
|
|||||||
|
|
||||||
#include "Lamp.h"
|
#include "Lamp.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Python TypeLamp structure definition: */
|
||||||
|
/*****************************************************************************/
|
||||||
|
PyTypeObject Lamp_Type =
|
||||||
|
{
|
||||||
|
PyObject_HEAD_INIT(NULL)
|
||||||
|
0, /* ob_size */
|
||||||
|
"Blender Lamp", /* tp_name */
|
||||||
|
sizeof (BPy_Lamp), /* tp_basicsize */
|
||||||
|
0, /* tp_itemsize */
|
||||||
|
/* methods */
|
||||||
|
(destructor)Lamp_dealloc, /* tp_dealloc */
|
||||||
|
(printfunc)Lamp_print, /* tp_print */
|
||||||
|
(getattrfunc)Lamp_getAttr, /* tp_getattr */
|
||||||
|
(setattrfunc)Lamp_setAttr, /* tp_setattr */
|
||||||
|
(cmpfunc)Lamp_compare, /* tp_compare */
|
||||||
|
(reprfunc)Lamp_repr, /* tp_repr */
|
||||||
|
0, /* tp_as_number */
|
||||||
|
0, /* tp_as_sequence */
|
||||||
|
0, /* tp_as_mapping */
|
||||||
|
0, /* tp_as_hash */
|
||||||
|
0,0,0,0,0,0,
|
||||||
|
0, /* tp_doc */
|
||||||
|
0,0,0,0,0,0,
|
||||||
|
BPy_Lamp_methods, /* tp_methods */
|
||||||
|
0, /* tp_members */
|
||||||
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: M_Lamp_New */
|
/* Function: M_Lamp_New */
|
||||||
/* Python equivalent: Blender.Lamp.New */
|
/* Python equivalent: Blender.Lamp.New */
|
||||||
@@ -40,7 +68,7 @@ static PyObject *M_Lamp_New(PyObject *self, PyObject *args, PyObject *keywords)
|
|||||||
char *type_str = "Lamp";
|
char *type_str = "Lamp";
|
||||||
char *name_str = "LampData";
|
char *name_str = "LampData";
|
||||||
static char *kwlist[] = {"type_str", "name_str", NULL};
|
static char *kwlist[] = {"type_str", "name_str", NULL};
|
||||||
C_Lamp *py_lamp; /* for Lamp Data object wrapper in Python */
|
BPy_Lamp *py_lamp; /* for Lamp Data object wrapper in Python */
|
||||||
Lamp *bl_lamp; /* for actual Lamp Data we create in Blender */
|
Lamp *bl_lamp; /* for actual Lamp Data we create in Blender */
|
||||||
char buf[21];
|
char buf[21];
|
||||||
|
|
||||||
@@ -53,17 +81,18 @@ static PyObject *M_Lamp_New(PyObject *self, PyObject *args, PyObject *keywords)
|
|||||||
|
|
||||||
bl_lamp = add_lamp(); /* first create in Blender */
|
bl_lamp = add_lamp(); /* first create in Blender */
|
||||||
if (bl_lamp) /* now create the wrapper obj in Python */
|
if (bl_lamp) /* now create the wrapper obj in Python */
|
||||||
py_lamp = (C_Lamp *)Lamp_CreatePyObject(bl_lamp);
|
py_lamp = (BPy_Lamp *)Lamp_CreatePyObject(bl_lamp);
|
||||||
else
|
else
|
||||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||||
"couldn't create Lamp Data in Blender"));
|
"couldn't create Lamp Data in Blender"));
|
||||||
|
|
||||||
|
/* let's return user count to zero, because ... */
|
||||||
|
bl_lamp->id.us = 0; /* ... add_lamp() incref'ed it */
|
||||||
|
|
||||||
if (py_lamp == NULL)
|
if (py_lamp == NULL)
|
||||||
return (EXPP_ReturnPyObjError (PyExc_MemoryError,
|
return (EXPP_ReturnPyObjError (PyExc_MemoryError,
|
||||||
"couldn't create Lamp Data object"));
|
"couldn't create Lamp Data object"));
|
||||||
|
|
||||||
py_lamp->lamp = bl_lamp; /* link Python lamp wrapper with Blender Lamp */
|
|
||||||
|
|
||||||
if (strcmp (type_str, "Lamp") == 0)
|
if (strcmp (type_str, "Lamp") == 0)
|
||||||
bl_lamp->type = (short)EXPP_LAMP_TYPE_LAMP;
|
bl_lamp->type = (short)EXPP_LAMP_TYPE_LAMP;
|
||||||
else if (strcmp (type_str, "Sun") == 0)
|
else if (strcmp (type_str, "Sun") == 0)
|
||||||
@@ -107,12 +136,12 @@ static PyObject *M_Lamp_Get(PyObject *self, PyObject *args)
|
|||||||
|
|
||||||
if (name) { /* (name) - Search lamp by name */
|
if (name) { /* (name) - Search lamp by name */
|
||||||
|
|
||||||
C_Lamp *wanted_lamp = NULL;
|
BPy_Lamp *wanted_lamp = NULL;
|
||||||
|
|
||||||
while ((lamp_iter) && (wanted_lamp == NULL)) {
|
while ((lamp_iter) && (wanted_lamp == NULL)) {
|
||||||
|
|
||||||
if (strcmp (name, lamp_iter->id.name+2) == 0)
|
if (strcmp (name, lamp_iter->id.name+2) == 0)
|
||||||
wanted_lamp = (C_Lamp *)Lamp_CreatePyObject(lamp_iter);
|
wanted_lamp = (BPy_Lamp *)Lamp_CreatePyObject(lamp_iter);
|
||||||
|
|
||||||
lamp_iter = lamp_iter->id.next;
|
lamp_iter = lamp_iter->id.next;
|
||||||
}
|
}
|
||||||
@@ -193,10 +222,10 @@ static PyObject *M_Lamp_ModesDict (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: M_Lamp_Init */
|
/* Function: Lamp_Init */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Needed by the Blender module, to register the Blender.Lamp submodule */
|
/* Needed by the Blender module, to register the Blender.Lamp submodule */
|
||||||
PyObject *M_Lamp_Init (void)
|
PyObject *Lamp_Init (void)
|
||||||
{
|
{
|
||||||
PyObject *submodule, *Types, *Modes;
|
PyObject *submodule, *Types, *Modes;
|
||||||
|
|
||||||
@@ -217,19 +246,19 @@ PyObject *M_Lamp_Init (void)
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: Lamp_CreatePyObject */
|
/* Function: Lamp_CreatePyObject */
|
||||||
/* Description: This function will create a new C_Lamp from an existing */
|
/* Description: This function will create a new BPy_Lamp from an existing */
|
||||||
/* Blender lamp structure. */
|
/* Blender lamp structure. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *Lamp_CreatePyObject (Lamp *lamp)
|
PyObject *Lamp_CreatePyObject (Lamp *lamp)
|
||||||
{
|
{
|
||||||
C_Lamp *pylamp;
|
BPy_Lamp *pylamp;
|
||||||
float *rgb[3];
|
float *rgb[3];
|
||||||
|
|
||||||
pylamp = (C_Lamp *)PyObject_NEW (C_Lamp, &Lamp_Type);
|
pylamp = (BPy_Lamp *)PyObject_NEW (BPy_Lamp, &Lamp_Type);
|
||||||
|
|
||||||
if (!pylamp)
|
if (!pylamp)
|
||||||
return EXPP_ReturnPyObjError (PyExc_MemoryError,
|
return EXPP_ReturnPyObjError (PyExc_MemoryError,
|
||||||
"couldn't create C_Lamp object");
|
"couldn't create BPy_Lamp object");
|
||||||
|
|
||||||
pylamp->lamp = lamp;
|
pylamp->lamp = lamp;
|
||||||
|
|
||||||
@@ -237,7 +266,7 @@ PyObject *Lamp_CreatePyObject (Lamp *lamp)
|
|||||||
rgb[1] = &lamp->g;
|
rgb[1] = &lamp->g;
|
||||||
rgb[2] = &lamp->b;
|
rgb[2] = &lamp->b;
|
||||||
|
|
||||||
pylamp->color = (C_rgbTuple *)rgbTuple_New(rgb);
|
pylamp->color = (BPy_rgbTuple *)rgbTuple_New(rgb);
|
||||||
|
|
||||||
return (PyObject *)pylamp;
|
return (PyObject *)pylamp;
|
||||||
}
|
}
|
||||||
@@ -259,13 +288,13 @@ int Lamp_CheckPyObject (PyObject *pyobj)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
Lamp *Lamp_FromPyObject (PyObject *pyobj)
|
Lamp *Lamp_FromPyObject (PyObject *pyobj)
|
||||||
{
|
{
|
||||||
return ((C_Lamp *)pyobj)->lamp;
|
return ((BPy_Lamp *)pyobj)->lamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python C_Lamp methods: */
|
/* Python BPy_Lamp methods: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *Lamp_getName(C_Lamp *self)
|
static PyObject *Lamp_getName(BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyString_FromString(self->lamp->id.name+2);
|
PyObject *attr = PyString_FromString(self->lamp->id.name+2);
|
||||||
|
|
||||||
@@ -275,7 +304,7 @@ static PyObject *Lamp_getName(C_Lamp *self)
|
|||||||
"couldn't get Lamp.name attribute"));
|
"couldn't get Lamp.name attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_getType(C_Lamp *self)
|
static PyObject *Lamp_getType(BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyInt_FromLong(self->lamp->type);
|
PyObject *attr = PyInt_FromLong(self->lamp->type);
|
||||||
|
|
||||||
@@ -285,7 +314,7 @@ static PyObject *Lamp_getType(C_Lamp *self)
|
|||||||
"couldn't get Lamp.type attribute"));
|
"couldn't get Lamp.type attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_getMode(C_Lamp *self)
|
static PyObject *Lamp_getMode(BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyInt_FromLong(self->lamp->mode);
|
PyObject *attr = PyInt_FromLong(self->lamp->mode);
|
||||||
|
|
||||||
@@ -295,7 +324,7 @@ static PyObject *Lamp_getMode(C_Lamp *self)
|
|||||||
"couldn't get Lamp.mode attribute"));
|
"couldn't get Lamp.mode attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_getSamples(C_Lamp *self)
|
static PyObject *Lamp_getSamples(BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyInt_FromLong(self->lamp->samp);
|
PyObject *attr = PyInt_FromLong(self->lamp->samp);
|
||||||
|
|
||||||
@@ -305,7 +334,7 @@ static PyObject *Lamp_getSamples(C_Lamp *self)
|
|||||||
"couldn't get Lamp.samples attribute"));
|
"couldn't get Lamp.samples attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_getBufferSize(C_Lamp *self)
|
static PyObject *Lamp_getBufferSize(BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyInt_FromLong(self->lamp->bufsize);
|
PyObject *attr = PyInt_FromLong(self->lamp->bufsize);
|
||||||
|
|
||||||
@@ -315,7 +344,7 @@ static PyObject *Lamp_getBufferSize(C_Lamp *self)
|
|||||||
"couldn't get Lamp.bufferSize attribute"));
|
"couldn't get Lamp.bufferSize attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_getHaloStep(C_Lamp *self)
|
static PyObject *Lamp_getHaloStep(BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyInt_FromLong(self->lamp->shadhalostep);
|
PyObject *attr = PyInt_FromLong(self->lamp->shadhalostep);
|
||||||
|
|
||||||
@@ -325,7 +354,7 @@ static PyObject *Lamp_getHaloStep(C_Lamp *self)
|
|||||||
"couldn't get Lamp.haloStep attribute"));
|
"couldn't get Lamp.haloStep attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_getEnergy(C_Lamp *self)
|
static PyObject *Lamp_getEnergy(BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyFloat_FromDouble(self->lamp->energy);
|
PyObject *attr = PyFloat_FromDouble(self->lamp->energy);
|
||||||
|
|
||||||
@@ -335,7 +364,7 @@ static PyObject *Lamp_getEnergy(C_Lamp *self)
|
|||||||
"couldn't get Lamp.energy attribute"));
|
"couldn't get Lamp.energy attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_getDist(C_Lamp *self)
|
static PyObject *Lamp_getDist(BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyFloat_FromDouble(self->lamp->dist);
|
PyObject *attr = PyFloat_FromDouble(self->lamp->dist);
|
||||||
|
|
||||||
@@ -345,7 +374,7 @@ static PyObject *Lamp_getDist(C_Lamp *self)
|
|||||||
"couldn't get Lamp.dist attribute"));
|
"couldn't get Lamp.dist attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_getSpotSize(C_Lamp *self)
|
static PyObject *Lamp_getSpotSize(BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyFloat_FromDouble(self->lamp->spotsize);
|
PyObject *attr = PyFloat_FromDouble(self->lamp->spotsize);
|
||||||
|
|
||||||
@@ -355,7 +384,7 @@ static PyObject *Lamp_getSpotSize(C_Lamp *self)
|
|||||||
"couldn't get Lamp.spotSize attribute"));
|
"couldn't get Lamp.spotSize attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_getSpotBlend(C_Lamp *self)
|
static PyObject *Lamp_getSpotBlend(BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyFloat_FromDouble(self->lamp->spotblend);
|
PyObject *attr = PyFloat_FromDouble(self->lamp->spotblend);
|
||||||
|
|
||||||
@@ -365,7 +394,7 @@ static PyObject *Lamp_getSpotBlend(C_Lamp *self)
|
|||||||
"couldn't get Lamp.spotBlend attribute"));
|
"couldn't get Lamp.spotBlend attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_getClipStart(C_Lamp *self)
|
static PyObject *Lamp_getClipStart(BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyFloat_FromDouble(self->lamp->clipsta);
|
PyObject *attr = PyFloat_FromDouble(self->lamp->clipsta);
|
||||||
|
|
||||||
@@ -375,7 +404,7 @@ static PyObject *Lamp_getClipStart(C_Lamp *self)
|
|||||||
"couldn't get Lamp.clipStart attribute"));
|
"couldn't get Lamp.clipStart attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_getClipEnd(C_Lamp *self)
|
static PyObject *Lamp_getClipEnd(BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyFloat_FromDouble(self->lamp->clipend);
|
PyObject *attr = PyFloat_FromDouble(self->lamp->clipend);
|
||||||
|
|
||||||
@@ -385,7 +414,7 @@ static PyObject *Lamp_getClipEnd(C_Lamp *self)
|
|||||||
"couldn't get Lamp.clipEnd attribute"));
|
"couldn't get Lamp.clipEnd attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_getBias(C_Lamp *self)
|
static PyObject *Lamp_getBias(BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyFloat_FromDouble(self->lamp->bias);
|
PyObject *attr = PyFloat_FromDouble(self->lamp->bias);
|
||||||
|
|
||||||
@@ -395,7 +424,7 @@ static PyObject *Lamp_getBias(C_Lamp *self)
|
|||||||
"couldn't get Lamp.bias attribute"));
|
"couldn't get Lamp.bias attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_getSoftness(C_Lamp *self)
|
static PyObject *Lamp_getSoftness(BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyFloat_FromDouble(self->lamp->soft);
|
PyObject *attr = PyFloat_FromDouble(self->lamp->soft);
|
||||||
|
|
||||||
@@ -405,7 +434,7 @@ static PyObject *Lamp_getSoftness(C_Lamp *self)
|
|||||||
"couldn't get Lamp.softness attribute"));
|
"couldn't get Lamp.softness attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_getHaloInt(C_Lamp *self)
|
static PyObject *Lamp_getHaloInt(BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyFloat_FromDouble(self->lamp->haint);
|
PyObject *attr = PyFloat_FromDouble(self->lamp->haint);
|
||||||
|
|
||||||
@@ -415,7 +444,7 @@ static PyObject *Lamp_getHaloInt(C_Lamp *self)
|
|||||||
"couldn't get Lamp.haloInt attribute"));
|
"couldn't get Lamp.haloInt attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_getQuad1(C_Lamp *self)
|
static PyObject *Lamp_getQuad1(BPy_Lamp *self)
|
||||||
{ /* should we complain if Lamp is not of type Quad? */
|
{ /* should we complain if Lamp is not of type Quad? */
|
||||||
PyObject *attr = PyFloat_FromDouble(self->lamp->att1);
|
PyObject *attr = PyFloat_FromDouble(self->lamp->att1);
|
||||||
|
|
||||||
@@ -425,7 +454,7 @@ static PyObject *Lamp_getQuad1(C_Lamp *self)
|
|||||||
"couldn't get Lamp.quad1 attribute"));
|
"couldn't get Lamp.quad1 attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_getQuad2(C_Lamp *self)
|
static PyObject *Lamp_getQuad2(BPy_Lamp *self)
|
||||||
{ /* should we complain if Lamp is not of type Quad? */
|
{ /* should we complain if Lamp is not of type Quad? */
|
||||||
PyObject *attr = PyFloat_FromDouble(self->lamp->att2);
|
PyObject *attr = PyFloat_FromDouble(self->lamp->att2);
|
||||||
|
|
||||||
@@ -435,12 +464,12 @@ static PyObject *Lamp_getQuad2(C_Lamp *self)
|
|||||||
"couldn't get Lamp.quad2 attribute"));
|
"couldn't get Lamp.quad2 attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_getCol(C_Lamp *self)
|
static PyObject *Lamp_getCol(BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
return rgbTuple_getCol(self->color);
|
return rgbTuple_getCol(self->color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setName(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setName(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
char buf[21];
|
char buf[21];
|
||||||
@@ -457,7 +486,7 @@ static PyObject *Lamp_setName(C_Lamp *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setType(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setType(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
char *type;
|
char *type;
|
||||||
|
|
||||||
@@ -486,7 +515,7 @@ static PyObject *Lamp_setType(C_Lamp *self, PyObject *args)
|
|||||||
* the first case t shoud be an int and in the second it should be a string. So
|
* the first case t shoud be an int and in the second it should be a string. So
|
||||||
* while the method setType expects a string ('persp' or 'ortho') or an empty
|
* while the method setType expects a string ('persp' or 'ortho') or an empty
|
||||||
* argument, this function should receive an int (0 or 1). */
|
* argument, this function should receive an int (0 or 1). */
|
||||||
static PyObject *Lamp_setIntType(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setIntType(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
short value;
|
short value;
|
||||||
|
|
||||||
@@ -504,7 +533,7 @@ static PyObject *Lamp_setIntType(C_Lamp *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setMode(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setMode(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
char *m[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
|
char *m[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
|
||||||
short i, flag = 0;
|
short i, flag = 0;
|
||||||
@@ -545,7 +574,7 @@ static PyObject *Lamp_setMode(C_Lamp *self, PyObject *args)
|
|||||||
|
|
||||||
/* Another helper function, for the same reason.
|
/* Another helper function, for the same reason.
|
||||||
* (See comment before Lamp_setIntType above). */
|
* (See comment before Lamp_setIntType above). */
|
||||||
static PyObject *Lamp_setIntMode(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setIntMode(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
short value;
|
short value;
|
||||||
|
|
||||||
@@ -560,7 +589,7 @@ static PyObject *Lamp_setIntMode(C_Lamp *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setSamples(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setSamples(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
short value;
|
short value;
|
||||||
|
|
||||||
@@ -575,7 +604,7 @@ static PyObject *Lamp_setSamples(C_Lamp *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setBufferSize(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setBufferSize(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
short value;
|
short value;
|
||||||
|
|
||||||
@@ -590,7 +619,7 @@ static PyObject *Lamp_setBufferSize(C_Lamp *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setHaloStep(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setHaloStep(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
short value;
|
short value;
|
||||||
|
|
||||||
@@ -605,7 +634,7 @@ static PyObject *Lamp_setHaloStep(C_Lamp *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setEnergy(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setEnergy(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
@@ -620,7 +649,7 @@ static PyObject *Lamp_setEnergy(C_Lamp *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setDist(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setDist(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
@@ -635,7 +664,7 @@ static PyObject *Lamp_setDist(C_Lamp *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setSpotSize(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setSpotSize(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
@@ -650,7 +679,7 @@ static PyObject *Lamp_setSpotSize(C_Lamp *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setSpotBlend(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setSpotBlend(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
@@ -665,7 +694,7 @@ static PyObject *Lamp_setSpotBlend(C_Lamp *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setClipStart(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setClipStart(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
@@ -680,7 +709,7 @@ static PyObject *Lamp_setClipStart(C_Lamp *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setClipEnd(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setClipEnd(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
@@ -695,7 +724,7 @@ static PyObject *Lamp_setClipEnd(C_Lamp *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setBias(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setBias(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
@@ -710,7 +739,7 @@ static PyObject *Lamp_setBias(C_Lamp *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setSoftness(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setSoftness(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
@@ -725,7 +754,7 @@ static PyObject *Lamp_setSoftness(C_Lamp *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setHaloInt(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setHaloInt(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
@@ -740,7 +769,7 @@ static PyObject *Lamp_setHaloInt(C_Lamp *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setQuad1(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setQuad1(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
@@ -755,7 +784,7 @@ static PyObject *Lamp_setQuad1(C_Lamp *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setQuad2(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setQuad2(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
@@ -770,7 +799,7 @@ static PyObject *Lamp_setQuad2(C_Lamp *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setColorComponent(C_Lamp *self, char *key,
|
static PyObject *Lamp_setColorComponent(BPy_Lamp *self, char *key,
|
||||||
PyObject *args)
|
PyObject *args)
|
||||||
{ /* for compatibility with old bpython */
|
{ /* for compatibility with old bpython */
|
||||||
float value;
|
float value;
|
||||||
@@ -793,28 +822,29 @@ static PyObject *Lamp_setColorComponent(C_Lamp *self, char *key,
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Lamp_setCol(C_Lamp *self, PyObject *args)
|
static PyObject *Lamp_setCol(BPy_Lamp *self, PyObject *args)
|
||||||
{
|
{
|
||||||
return rgbTuple_setCol(self->color, args);
|
return rgbTuple_setCol(self->color, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: LampDeAlloc */
|
/* Function: Lamp_dealloc */
|
||||||
/* Description: This is a callback function for the C_Lamp type. It is */
|
/* Description: This is a callback function for the BPy_Lamp type. It is */
|
||||||
/* the destructor function. */
|
/* the destructor function. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static void LampDeAlloc (C_Lamp *self)
|
static void Lamp_dealloc (BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
|
Py_DECREF (self->color);
|
||||||
PyObject_DEL (self);
|
PyObject_DEL (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: LampGetAttr */
|
/* Function: Lamp_getAttr */
|
||||||
/* Description: This is a callback function for the C_Lamp type. It is */
|
/* Description: This is a callback function for the BPy_Lamp type. It is */
|
||||||
/* the function that accesses C_Lamp member variables and */
|
/* the function that accesses BPy_Lamp member variables and */
|
||||||
/* methods. */
|
/* methods. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *LampGetAttr (C_Lamp *self, char *name)
|
static PyObject *Lamp_getAttr (BPy_Lamp *self, char *name)
|
||||||
{
|
{
|
||||||
PyObject *attr = Py_None;
|
PyObject *attr = Py_None;
|
||||||
|
|
||||||
@@ -898,21 +928,21 @@ static PyObject *LampGetAttr (C_Lamp *self, char *name)
|
|||||||
if (attr != Py_None) return attr; /* member attribute found, return it */
|
if (attr != Py_None) return attr; /* member attribute found, return it */
|
||||||
|
|
||||||
/* not an attribute, search the methods table */
|
/* not an attribute, search the methods table */
|
||||||
return Py_FindMethod(C_Lamp_methods, (PyObject *)self, name);
|
return Py_FindMethod(BPy_Lamp_methods, (PyObject *)self, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: LampSetAttr */
|
/* Function: Lamp_setAttr */
|
||||||
/* Description: This is a callback function for the C_Lamp type. It is the */
|
/* Description: This is a callback function for the BPy_Lamp type. It is the */
|
||||||
/* function that changes Lamp Data members values. If this */
|
/* function that changes Lamp Data members values. If this */
|
||||||
/* data is linked to a Blender Lamp, it also gets updated. */
|
/* data is linked to a Blender Lamp, it also gets updated. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static int LampSetAttr (C_Lamp *self, char *name, PyObject *value)
|
static int Lamp_setAttr (BPy_Lamp *self, char *name, PyObject *value)
|
||||||
{
|
{
|
||||||
PyObject *valtuple;
|
PyObject *valtuple;
|
||||||
PyObject *error = NULL;
|
PyObject *error = NULL;
|
||||||
|
|
||||||
valtuple = Py_BuildValue("(O)", value); /* the set* functions expect a tuple */
|
valtuple = Py_BuildValue("(O)", value); /*the set* functions expect a tuple*/
|
||||||
|
|
||||||
if (!valtuple)
|
if (!valtuple)
|
||||||
return EXPP_ReturnIntError(PyExc_MemoryError,
|
return EXPP_ReturnIntError(PyExc_MemoryError,
|
||||||
@@ -983,36 +1013,36 @@ static int LampSetAttr (C_Lamp *self, char *name, PyObject *value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: LampCompare */
|
/* Function: Lamp_compare */
|
||||||
/* Description: This is a callback function for the C_Lamp type. It */
|
/* Description: This is a callback function for the BPy_Lamp type. It */
|
||||||
/* compares two Lamp_Type objects. Only the "==" and "!=" */
|
/* compares two Lamp_Type objects. Only the "==" and "!=" */
|
||||||
/* comparisons are meaninful. Returns 0 for equality and -1 if */
|
/* comparisons are meaninful. Returns 0 for equality and -1 if */
|
||||||
/* they don't point to the same Blender Lamp struct. */
|
/* they don't point to the same Blender Lamp struct. */
|
||||||
/* In Python it becomes 1 if they are equal, 0 otherwise. */
|
/* In Python it becomes 1 if they are equal, 0 otherwise. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static int LampCompare (C_Lamp *a, C_Lamp *b)
|
static int Lamp_compare (BPy_Lamp *a, BPy_Lamp *b)
|
||||||
{
|
{
|
||||||
Lamp *pa = a->lamp, *pb = b->lamp;
|
Lamp *pa = a->lamp, *pb = b->lamp;
|
||||||
return (pa == pb) ? 0:-1;
|
return (pa == pb) ? 0:-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: LampPrint */
|
/* Function: Lamp_print */
|
||||||
/* Description: This is a callback function for the C_Lamp type. It */
|
/* Description: This is a callback function for the BPy_Lamp type. It */
|
||||||
/* builds a meaninful string to 'print' lamp objects. */
|
/* builds a meaninful string to 'print' lamp objects. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static int LampPrint(C_Lamp *self, FILE *fp, int flags)
|
static int Lamp_print(BPy_Lamp *self, FILE *fp, int flags)
|
||||||
{
|
{
|
||||||
fprintf(fp, "[Lamp \"%s\"]", self->lamp->id.name+2);
|
fprintf(fp, "[Lamp \"%s\"]", self->lamp->id.name+2);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: LampRepr */
|
/* Function: Lamp_repr */
|
||||||
/* Description: This is a callback function for the C_Lamp type. It */
|
/* Description: This is a callback function for the BPy_Lamp type. It */
|
||||||
/* builds a meaninful string to represent lamp objects. */
|
/* builds a meaninful string to represent lamp objects. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *LampRepr (C_Lamp *self)
|
static PyObject *Lamp_repr (BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
return PyString_FromString(self->lamp->id.name+2);
|
return PyString_FromString(self->lamp->id.name+2);
|
||||||
}
|
}
|
||||||
|
@@ -46,9 +46,10 @@
|
|||||||
#include "rgbTuple.h"
|
#include "rgbTuple.h"
|
||||||
#include "gen_utils.h"
|
#include "gen_utils.h"
|
||||||
#include "modules.h"
|
#include "modules.h"
|
||||||
|
#include "bpy_types.h" /* for the BPy_Lamp declaration */
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python C_Lamp defaults: */
|
/* Python BPy_Lamp defaults: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/* Lamp types */
|
/* Lamp types */
|
||||||
@@ -121,19 +122,20 @@ char M_Lamp_doc[] =
|
|||||||
This module provides control over **Lamp Data** objects in Blender.\n\n\
|
This module provides control over **Lamp Data** objects in Blender.\n\n\
|
||||||
Example::\n\n\
|
Example::\n\n\
|
||||||
from Blender import Lamp\n\
|
from Blender import Lamp\n\
|
||||||
l = Lamp.New('Spot')\n\
|
l = Lamp.New('Spot') # create new 'Spot' lamp data\n\
|
||||||
l.setMode('square', 'shadow')\n\
|
l.setMode('square', 'shadow') # set these two lamp mode flags\n\
|
||||||
ob = Object.New('Lamp')\n\
|
ob = Object.New('Lamp') # create new lamp object\n\
|
||||||
ob.link(l)\n";
|
ob.link(l) # link lamp obj with lamp data\n";
|
||||||
|
|
||||||
char M_Lamp_New_doc[] =
|
char M_Lamp_New_doc[] =
|
||||||
"(type, name) - return a new Lamp datablock of type 'type'\n\
|
"Lamp.New (type = 'Lamp', name = 'LampData'):\n\
|
||||||
and optional name 'name'.";
|
Return a new Lamp Data object with the given type and name.";
|
||||||
|
|
||||||
char M_Lamp_Get_doc[] =
|
char M_Lamp_Get_doc[] =
|
||||||
"(name) - return the lamp with the name 'name', \
|
"Lamp.Get (name = None):\n\
|
||||||
returns None if not found.\n If 'name' is not specified, \
|
Return the Lamp Data with the given name, None if not found, or\n\
|
||||||
it returns a list of all lamps in the\ncurrent scene.";
|
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: */
|
/* Python method structure definition for Blender.Lamp module: */
|
||||||
@@ -147,64 +149,54 @@ struct PyMethodDef M_Lamp_methods[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python C_Lamp structure definition: */
|
/* Python BPy_Lamp methods declarations: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
typedef struct {
|
static PyObject *Lamp_getName(BPy_Lamp *self);
|
||||||
PyObject_HEAD
|
static PyObject *Lamp_getType(BPy_Lamp *self);
|
||||||
Lamp *lamp;
|
static PyObject *Lamp_getMode(BPy_Lamp *self);
|
||||||
C_rgbTuple *color;
|
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);
|
||||||
|
|
||||||
} C_Lamp;
|
static PyObject *Lamp_setColorComponent(BPy_Lamp *self, char *key,
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Python C_Lamp methods declarations: */
|
|
||||||
/*****************************************************************************/
|
|
||||||
static PyObject *Lamp_getName(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_getType(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_getMode(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_getSamples(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_getBufferSize(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_getHaloStep(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_getEnergy(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_getDist(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_getSpotSize(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_getSpotBlend(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_getClipStart(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_getClipEnd(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_getBias(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_getSoftness(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_getHaloInt(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_getQuad1(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_getQuad2(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_getCol(C_Lamp *self);
|
|
||||||
static PyObject *Lamp_setName(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setType(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setIntType(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setMode(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setIntMode(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setSamples(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setBufferSize(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setHaloStep(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setEnergy(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setDist(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setSpotSize(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setSpotBlend(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setClipStart(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setClipEnd(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setBias(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setSoftness(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setHaloInt(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setQuad1(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setQuad2(C_Lamp *self, PyObject *args);
|
|
||||||
static PyObject *Lamp_setCol(C_Lamp *self, PyObject *args);
|
|
||||||
|
|
||||||
static PyObject *Lamp_setColorComponent(C_Lamp *self, char *key,
|
|
||||||
PyObject *args);
|
PyObject *args);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python C_Lamp methods table: */
|
/* Python BPy_Lamp methods table: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyMethodDef C_Lamp_methods[] = {
|
static PyMethodDef BPy_Lamp_methods[] = {
|
||||||
/* name, method, flags, doc */
|
/* name, method, flags, doc */
|
||||||
{"getName", (PyCFunction)Lamp_getName, METH_NOARGS,
|
{"getName", (PyCFunction)Lamp_getName, METH_NOARGS,
|
||||||
"() - return Lamp name"},
|
"() - return Lamp name"},
|
||||||
@@ -258,7 +250,7 @@ static PyMethodDef C_Lamp_methods[] = {
|
|||||||
"(float) - change Lamp energy value"},
|
"(float) - change Lamp energy value"},
|
||||||
{"setSpotSize", (PyCFunction)Lamp_setSpotSize, METH_VARARGS,
|
{"setSpotSize", (PyCFunction)Lamp_setSpotSize, METH_VARARGS,
|
||||||
"(float) - change Lamp spot size value"},
|
"(float) - change Lamp spot size value"},
|
||||||
{"setSpotBlend", (PyCFunction)Lamp_setHaloStep, METH_VARARGS,
|
{"setSpotBlend", (PyCFunction)Lamp_setSpotBlend, METH_VARARGS,
|
||||||
"(float) - change Lamp spot blend value"},
|
"(float) - change Lamp spot blend value"},
|
||||||
{"setClipStart", (PyCFunction)Lamp_setClipStart, METH_VARARGS,
|
{"setClipStart", (PyCFunction)Lamp_setClipStart, METH_VARARGS,
|
||||||
"(float) - change Lamp clip start value"},
|
"(float) - change Lamp clip start value"},
|
||||||
@@ -282,48 +274,12 @@ static PyMethodDef C_Lamp_methods[] = {
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python TypeLamp callback function prototypes: */
|
/* Python TypeLamp callback function prototypes: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static void LampDeAlloc (C_Lamp *lamp);
|
static void Lamp_dealloc (BPy_Lamp *lamp);
|
||||||
static PyObject *LampGetAttr (C_Lamp *lamp, char *name);
|
static PyObject *Lamp_getAttr (BPy_Lamp *lamp, char *name);
|
||||||
static int LampSetAttr (C_Lamp *lamp, char *name, PyObject *v);
|
static int Lamp_setAttr (BPy_Lamp *lamp, char *name, PyObject *v);
|
||||||
static int LampCompare (C_Lamp *a, C_Lamp *b);
|
static int Lamp_compare (BPy_Lamp *a, BPy_Lamp *b);
|
||||||
static PyObject *LampRepr (C_Lamp *lamp);
|
static PyObject *Lamp_repr (BPy_Lamp *lamp);
|
||||||
static int LampPrint (C_Lamp *lamp, FILE *fp, int flags);
|
static int Lamp_print (BPy_Lamp *lamp, FILE *fp, int flags);
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Python Lamp_Type helper functions needed by Blender (the Init function) */
|
|
||||||
/* and Object modules. */
|
|
||||||
/*****************************************************************************/
|
|
||||||
PyObject *M_Lamp_Init (void);
|
|
||||||
PyObject *LampCreatePyObject (Lamp *lamp);
|
|
||||||
Lamp *LampFromPyObject (PyObject *pyobj);
|
|
||||||
int LampCheckPyObject (PyObject *pyobj);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Python TypeLamp structure definition: */
|
|
||||||
/*****************************************************************************/
|
|
||||||
PyTypeObject Lamp_Type =
|
|
||||||
{
|
|
||||||
PyObject_HEAD_INIT(NULL)
|
|
||||||
0, /* ob_size */
|
|
||||||
"Lamp", /* tp_name */
|
|
||||||
sizeof (C_Lamp), /* tp_basicsize */
|
|
||||||
0, /* tp_itemsize */
|
|
||||||
/* methods */
|
|
||||||
(destructor)LampDeAlloc, /* tp_dealloc */
|
|
||||||
(printfunc)LampPrint, /* tp_print */
|
|
||||||
(getattrfunc)LampGetAttr, /* tp_getattr */
|
|
||||||
(setattrfunc)LampSetAttr, /* tp_setattr */
|
|
||||||
(cmpfunc)LampCompare, /* tp_compare */
|
|
||||||
(reprfunc)LampRepr, /* tp_repr */
|
|
||||||
0, /* tp_as_number */
|
|
||||||
0, /* tp_as_sequence */
|
|
||||||
0, /* tp_as_mapping */
|
|
||||||
0, /* tp_as_hash */
|
|
||||||
0,0,0,0,0,0,
|
|
||||||
0, /* tp_doc */
|
|
||||||
0,0,0,0,0,0,
|
|
||||||
C_Lamp_methods, /* tp_methods */
|
|
||||||
0, /* tp_members */
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* EXPP_LAMP_H */
|
#endif /* EXPP_LAMP_H */
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -39,18 +39,18 @@
|
|||||||
#include "rgbTuple.h"
|
#include "rgbTuple.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python C_Material structure definition: */
|
/* Python BPy_Material structure definition: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
Material *material;
|
Material *material;
|
||||||
C_rgbTuple *rgb, *amb, *spec, *mir;
|
BPy_rgbTuple *col, *amb, *spec, *mir;
|
||||||
|
|
||||||
} C_Material;
|
} BPy_Material;
|
||||||
|
|
||||||
extern PyTypeObject Material_Type; /* The Material PyType Object */
|
extern PyTypeObject Material_Type; /* The Material PyType Object */
|
||||||
|
|
||||||
#define C_Material_Check(v) \
|
#define BPy_Material_Check(v) \
|
||||||
((v)->ob_type == &Material_Type) /* for type checking */
|
((v)->ob_type == &Material_Type) /* for type checking */
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@@ -1340,7 +1340,7 @@ Material **nmesh_updateMaterials(C_NMesh *nmesh)
|
|||||||
|
|
||||||
PyObject *NMesh_assignMaterials_toObject(C_NMesh *nmesh, Object *ob)
|
PyObject *NMesh_assignMaterials_toObject(C_NMesh *nmesh, Object *ob)
|
||||||
{
|
{
|
||||||
C_Material *pymat;
|
BPy_Material *pymat;
|
||||||
Material *ma;
|
Material *ma;
|
||||||
int i;
|
int i;
|
||||||
short old_matmask;
|
short old_matmask;
|
||||||
@@ -1349,7 +1349,7 @@ PyObject *NMesh_assignMaterials_toObject(C_NMesh *nmesh, Object *ob)
|
|||||||
ob->colbits = 0; /* make assign_material work on mesh linked material */
|
ob->colbits = 0; /* make assign_material work on mesh linked material */
|
||||||
|
|
||||||
for (i = 0; i < PySequence_Length(nmesh->materials); i++) {
|
for (i = 0; i < PySequence_Length(nmesh->materials); i++) {
|
||||||
pymat = (C_Material *)PySequence_GetItem(nmesh->materials, i);
|
pymat = (BPy_Material *)PySequence_GetItem(nmesh->materials, i);
|
||||||
|
|
||||||
if (Material_CheckPyObject ((PyObject *)pymat)) {
|
if (Material_CheckPyObject ((PyObject *)pymat)) {
|
||||||
ma = pymat->material;
|
ma = pymat->material;
|
||||||
@@ -1659,7 +1659,7 @@ static PyObject *M_NMesh_FaceTranspModesDict (void)
|
|||||||
return FTM;
|
return FTM;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *M_NMesh_Init (void)
|
PyObject *NMesh_Init (void)
|
||||||
{
|
{
|
||||||
PyObject *submodule;
|
PyObject *submodule;
|
||||||
|
|
||||||
|
@@ -29,12 +29,6 @@
|
|||||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* \file Scene.c
|
|
||||||
* \ingroup scripts
|
|
||||||
* \brief Blender.Scene Module and Scene PyObject implementation.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <BKE_main.h>
|
#include <BKE_main.h>
|
||||||
#include <BKE_global.h>
|
#include <BKE_global.h>
|
||||||
#include <BKE_scene.h>
|
#include <BKE_scene.h>
|
||||||
@@ -47,8 +41,7 @@
|
|||||||
#include <mydevice.h> /* for #define REDRAW */
|
#include <mydevice.h> /* for #define REDRAW */
|
||||||
|
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "Camera.h"
|
#include "bpy_types.h"
|
||||||
#include "modules.h"
|
|
||||||
|
|
||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
|
|
||||||
@@ -204,23 +197,6 @@ PyTypeObject Scene_Type =
|
|||||||
0, /* tp_members */
|
0, /* tp_members */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* \defgroup Scene_Module Blender.Scene module functions
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*@{*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Python module function: Blender.Scene.New()
|
|
||||||
*
|
|
||||||
* This is the .New() function of the Blender.Scene submodule. It creates
|
|
||||||
* new Scene in Blender and returns its Python wrapper object. The
|
|
||||||
* parameter is optional and defaults to name = 'Scene'.
|
|
||||||
* \param <name> - string: The Scene name.
|
|
||||||
* \return A new Scene PyObject.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *M_Scene_New(PyObject *self, PyObject *args, PyObject *kword)
|
static PyObject *M_Scene_New(PyObject *self, PyObject *args, PyObject *kword)
|
||||||
{
|
{
|
||||||
char *name = "Scene";
|
char *name = "Scene";
|
||||||
@@ -249,19 +225,6 @@ static PyObject *M_Scene_New(PyObject *self, PyObject *args, PyObject *kword)
|
|||||||
return pyscene;
|
return pyscene;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Python module function: Blender.Scene.Get()
|
|
||||||
*
|
|
||||||
* This is the .Get() function of the Blender.Scene submodule. It searches
|
|
||||||
* the list of current Scene objects and returns a Python wrapper for
|
|
||||||
* the one with the name provided by the user. If called with no arguments,
|
|
||||||
* it returns a list of all current Scene object names in Blender.
|
|
||||||
* \param <name> - string: The name of an existing Blender Scene object.
|
|
||||||
* \return () - A list with the names of all current Scene objects;\n
|
|
||||||
* \return (name) - A Python wrapper for the Scene called 'name'
|
|
||||||
* in Blender.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *M_Scene_Get(PyObject *self, PyObject *args)
|
static PyObject *M_Scene_Get(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
@@ -322,29 +285,11 @@ static PyObject *M_Scene_Get(PyObject *self, PyObject *args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Python module function: Blender.Scene.getCurrent()
|
|
||||||
*
|
|
||||||
* \return A Python wrapper for the currently active scene.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *M_Scene_getCurrent (PyObject *self)
|
static PyObject *M_Scene_getCurrent (PyObject *self)
|
||||||
{
|
{
|
||||||
return Scene_CreatePyObject ((Scene *)G.scene);
|
return Scene_CreatePyObject ((Scene *)G.scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Python module function: Blender.Scene.unlink()
|
|
||||||
*
|
|
||||||
* This function actually frees the Blender Scene object linked to this
|
|
||||||
* Python wrapper. It calls free_libblock(), which calls free_scene(),
|
|
||||||
* where all objects linked to this scene have their user counts decremented.
|
|
||||||
* But there's no garbage collecting of objects in Blender yet.
|
|
||||||
* NOTE: a SystemError is raised if the user tries to remove the currently
|
|
||||||
* active Scene. Letting it be done would crash Blender.
|
|
||||||
* \param pyobj BPy_Scene*: A Scene PyObject wrapper.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *M_Scene_unlink (PyObject *self, PyObject *args)
|
static PyObject *M_Scene_unlink (PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *pyobj;
|
PyObject *pyobj;
|
||||||
@@ -366,17 +311,7 @@ static PyObject *M_Scene_unlink (PyObject *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@}*/
|
PyObject *Scene_Init (void)
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Initializes the Blender.Scene submodule
|
|
||||||
*
|
|
||||||
* This function is used by Blender_Init() in Blender.c to register the
|
|
||||||
* Blender.Scene submodule in the main Blender module.
|
|
||||||
* \return PyObject*: The initialized submodule.
|
|
||||||
*/
|
|
||||||
|
|
||||||
PyObject *M_Scene_Init (void)
|
|
||||||
{
|
{
|
||||||
PyObject *submodule;
|
PyObject *submodule;
|
||||||
|
|
||||||
@@ -390,13 +325,6 @@ PyObject *M_Scene_Init (void)
|
|||||||
return submodule;
|
return submodule;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Creates a new Python wrapper from an existing Blender Scene obj
|
|
||||||
*
|
|
||||||
* \param scene - Scene*: A pointer to an existing Blender Scene object.
|
|
||||||
* \return PyObject*: The Scene wrapper created.
|
|
||||||
*/
|
|
||||||
|
|
||||||
PyObject *Scene_CreatePyObject (Scene *scene)
|
PyObject *Scene_CreatePyObject (Scene *scene)
|
||||||
{
|
{
|
||||||
BPy_Scene *pyscene;
|
BPy_Scene *pyscene;
|
||||||
@@ -412,25 +340,11 @@ PyObject *Scene_CreatePyObject (Scene *scene)
|
|||||||
return (PyObject *)pyscene;
|
return (PyObject *)pyscene;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Checks if the given object is of type BPy_Scene
|
|
||||||
*
|
|
||||||
* \param pyobj - PyObject*: A pointer to a Scene PyObject.
|
|
||||||
* \return int: True or false.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int Scene_CheckPyObject (PyObject *pyobj)
|
int Scene_CheckPyObject (PyObject *pyobj)
|
||||||
{
|
{
|
||||||
return (pyobj->ob_type == &Scene_Type);
|
return (pyobj->ob_type == &Scene_Type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Returns the Blender Scene object from the given PyObject
|
|
||||||
*
|
|
||||||
* \param pyobj - PyObject*: A pointer to a Scene PyObject.
|
|
||||||
* \return Scene*: A pointer to the wrapped Blender Scene object.
|
|
||||||
*/
|
|
||||||
|
|
||||||
Scene *Scene_FromPyObject (PyObject *pyobj)
|
Scene *Scene_FromPyObject (PyObject *pyobj)
|
||||||
{
|
{
|
||||||
return ((BPy_Scene *)pyobj)->scene;
|
return ((BPy_Scene *)pyobj)->scene;
|
||||||
@@ -439,22 +353,6 @@ Scene *Scene_FromPyObject (PyObject *pyobj)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python BPy_Scene methods: */
|
/* Python BPy_Scene methods: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/**
|
|
||||||
* \defgroup Scene_Methods Scene Method Functions
|
|
||||||
*
|
|
||||||
* These are the Scene PyObject method functions. They are used to get and
|
|
||||||
* set values for the Scene member variables.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*@{*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Scene PyMethod getName
|
|
||||||
*
|
|
||||||
* \return string: The Scene name.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Scene_getName(BPy_Scene *self)
|
static PyObject *Scene_getName(BPy_Scene *self)
|
||||||
{
|
{
|
||||||
PyObject *attr = PyString_FromString(self->scene->id.name+2);
|
PyObject *attr = PyString_FromString(self->scene->id.name+2);
|
||||||
@@ -465,11 +363,6 @@ static PyObject *Scene_getName(BPy_Scene *self)
|
|||||||
"couldn't get Scene.name attribute"));
|
"couldn't get Scene.name attribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Scene PyMethod setName
|
|
||||||
* \param name - string: The new Scene name.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Scene_setName(BPy_Scene *self, PyObject *args)
|
static PyObject *Scene_setName(BPy_Scene *self, PyObject *args)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
@@ -487,15 +380,6 @@ static PyObject *Scene_setName(BPy_Scene *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Scene PyMethod copy
|
|
||||||
*
|
|
||||||
* This function makes a copy of the scene (self). The optional argument
|
|
||||||
* can be:\n 0: Link Objects \n1: Link Object Data (default)\n2: Full copy
|
|
||||||
* \param dup_objs - int: how the scene children are duplicated.
|
|
||||||
* \return PyObject*: A pointer to the created copy of the scene.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Scene_copy (BPy_Scene *self, PyObject *args)
|
static PyObject *Scene_copy (BPy_Scene *self, PyObject *args)
|
||||||
{
|
{
|
||||||
short dup_objs = 1;
|
short dup_objs = 1;
|
||||||
@@ -512,14 +396,6 @@ static PyObject *Scene_copy (BPy_Scene *self, PyObject *args)
|
|||||||
return Scene_CreatePyObject (copy_scene (scene, dup_objs));
|
return Scene_CreatePyObject (copy_scene (scene, dup_objs));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Scene PyMethod currentFrame
|
|
||||||
*
|
|
||||||
* If frame is given, the current frame is set and returned in any case.
|
|
||||||
* \param frame int: The value for the current frame.
|
|
||||||
* \return int: The current frame.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Blender seems to accept any positive value up to 18000 for start, end and
|
/* Blender seems to accept any positive value up to 18000 for start, end and
|
||||||
* current frames, independently. */
|
* current frames, independently. */
|
||||||
|
|
||||||
@@ -537,14 +413,6 @@ static PyObject *Scene_currentFrame (BPy_Scene *self, PyObject *args)
|
|||||||
return PyInt_FromLong (rd->cfra);
|
return PyInt_FromLong (rd->cfra);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Scene PyMethod startFrame
|
|
||||||
*
|
|
||||||
* If frame is given, the start frame is set and returned in any case.
|
|
||||||
* \param frame int: The value for the start frame.
|
|
||||||
* \return int: The start frame.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Scene_startFrame (BPy_Scene *self, PyObject *args)
|
static PyObject *Scene_startFrame (BPy_Scene *self, PyObject *args)
|
||||||
{
|
{
|
||||||
short frame = -1;
|
short frame = -1;
|
||||||
@@ -559,14 +427,6 @@ static PyObject *Scene_startFrame (BPy_Scene *self, PyObject *args)
|
|||||||
return PyInt_FromLong (rd->sfra);
|
return PyInt_FromLong (rd->sfra);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Scene PyMethod endFrame
|
|
||||||
*
|
|
||||||
* If frame is given, the end frame is set and returned in any case.
|
|
||||||
* \param frame int: The value for the end frame.
|
|
||||||
* \return int: The end frame.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Scene_endFrame (BPy_Scene *self, PyObject *args)
|
static PyObject *Scene_endFrame (BPy_Scene *self, PyObject *args)
|
||||||
{
|
{
|
||||||
short frame = -1;
|
short frame = -1;
|
||||||
@@ -581,12 +441,6 @@ static PyObject *Scene_endFrame (BPy_Scene *self, PyObject *args)
|
|||||||
return PyInt_FromLong (rd->efra);
|
return PyInt_FromLong (rd->efra);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Scene PyMethod makeCurrent
|
|
||||||
*
|
|
||||||
* Make self the current scene.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Scene_makeCurrent (BPy_Scene *self)
|
static PyObject *Scene_makeCurrent (BPy_Scene *self)
|
||||||
{
|
{
|
||||||
Scene *scene = self->scene;
|
Scene *scene = self->scene;
|
||||||
@@ -597,13 +451,6 @@ static PyObject *Scene_makeCurrent (BPy_Scene *self)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Scene PyMethod update
|
|
||||||
*
|
|
||||||
* Updates scene self. This function explicitely resorts the base list of
|
|
||||||
* a newly created object hierarchy.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Scene_update (BPy_Scene *self)
|
static PyObject *Scene_update (BPy_Scene *self)
|
||||||
{
|
{
|
||||||
Scene *scene = self->scene;
|
Scene *scene = self->scene;
|
||||||
@@ -614,13 +461,6 @@ static PyObject *Scene_update (BPy_Scene *self)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Scene PyMethod link
|
|
||||||
*
|
|
||||||
* Link the given object to this scene.
|
|
||||||
* \param object PyObject*: A pointer to an Object Python wrapper.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Scene_link (BPy_Scene *self, PyObject *args)
|
static PyObject *Scene_link (BPy_Scene *self, PyObject *args)
|
||||||
{
|
{
|
||||||
Scene *scene = self->scene;
|
Scene *scene = self->scene;
|
||||||
@@ -669,14 +509,6 @@ static PyObject *Scene_link (BPy_Scene *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Scene PyMethod unlink
|
|
||||||
*
|
|
||||||
* Unlink (delete) the given object from this scene.
|
|
||||||
* \param object PyObject*: A pointer to a Blender Object Python wrapper.
|
|
||||||
* \return int: 1 for success, 0 for failure.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Scene_unlink (BPy_Scene *self, PyObject *args)
|
static PyObject *Scene_unlink (BPy_Scene *self, PyObject *args)
|
||||||
{
|
{
|
||||||
C_Object *bpy_obj = NULL;
|
C_Object *bpy_obj = NULL;
|
||||||
@@ -709,12 +541,6 @@ static PyObject *Scene_unlink (BPy_Scene *self, PyObject *args)
|
|||||||
return Py_BuildValue ("i", PyInt_FromLong (retval));
|
return Py_BuildValue ("i", PyInt_FromLong (retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Scene PyMethod getRenderdir
|
|
||||||
*
|
|
||||||
* \return string: The directory where rendered images are saved to.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Scene_getRenderdir (BPy_Scene *self)
|
static PyObject *Scene_getRenderdir (BPy_Scene *self)
|
||||||
{
|
{
|
||||||
if (self->scene)
|
if (self->scene)
|
||||||
@@ -724,12 +550,6 @@ static PyObject *Scene_getRenderdir (BPy_Scene *self)
|
|||||||
"Blender Scene was deleted!");
|
"Blender Scene was deleted!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Scene PyMethod getBackbufdir
|
|
||||||
*
|
|
||||||
* \return string: The backbuffer image location
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Scene_getBackbufdir (BPy_Scene *self)
|
static PyObject *Scene_getBackbufdir (BPy_Scene *self)
|
||||||
{
|
{
|
||||||
if (self->scene)
|
if (self->scene)
|
||||||
@@ -739,17 +559,6 @@ static PyObject *Scene_getBackbufdir (BPy_Scene *self)
|
|||||||
"Blender Scene already deleted");
|
"Blender Scene already deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Scene PyMethod frameSettings
|
|
||||||
*
|
|
||||||
* This method can be used to set (if the values are given) and in any case
|
|
||||||
* get a tuple representing the start, end and current frame values.
|
|
||||||
* \param start int: The optional start frame value;
|
|
||||||
* \param end int: The optional end frame value;
|
|
||||||
* \param current int: The optional current frame value.
|
|
||||||
* \return tuple: (start, end, current) frame values.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Scene_frameSettings (BPy_Scene *self, PyObject *args)
|
static PyObject *Scene_frameSettings (BPy_Scene *self, PyObject *args)
|
||||||
{
|
{
|
||||||
int start = -1;
|
int start = -1;
|
||||||
@@ -775,12 +584,6 @@ static PyObject *Scene_frameSettings (BPy_Scene *self, PyObject *args)
|
|||||||
return Py_BuildValue("(iii)", rd->sfra, rd->efra, rd->cfra);
|
return Py_BuildValue("(iii)", rd->sfra, rd->efra, rd->cfra);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Scene PyMethod getChildren
|
|
||||||
*
|
|
||||||
* \return PyList: a list of all objects linked to Scene self.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Scene_getChildren (BPy_Scene *self)
|
static PyObject *Scene_getChildren (BPy_Scene *self)
|
||||||
{
|
{
|
||||||
Scene *scene = self->scene;
|
Scene *scene = self->scene;
|
||||||
@@ -814,12 +617,6 @@ static PyObject *Scene_getChildren (BPy_Scene *self)
|
|||||||
return pylist;
|
return pylist;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Scene PyMethod getCurrentCamera
|
|
||||||
*
|
|
||||||
* \return PyObject*: A wrapper for the currently active camera
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Scene_getCurrentCamera (BPy_Scene *self)
|
static PyObject *Scene_getCurrentCamera (BPy_Scene *self)
|
||||||
{
|
{
|
||||||
Object *cam_obj;
|
Object *cam_obj;
|
||||||
@@ -838,13 +635,6 @@ static PyObject *Scene_getCurrentCamera (BPy_Scene *self)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Scene PyMethod setCurrentCamera
|
|
||||||
*
|
|
||||||
* Set the currently active Camera Object in Blender.
|
|
||||||
* \param cam_obj PyObject*: A Camera PyObject.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Scene_setCurrentCamera (BPy_Scene *self, PyObject *args)
|
static PyObject *Scene_setCurrentCamera (BPy_Scene *self, PyObject *args)
|
||||||
{
|
{
|
||||||
Object *object;
|
Object *object;
|
||||||
@@ -873,33 +663,11 @@ static PyObject *Scene_setCurrentCamera (BPy_Scene *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@}*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \defgroup Scene_callbacks Callback functions for the Scene PyType
|
|
||||||
*
|
|
||||||
* These callbacks are called by the Python interpreter when dealing with
|
|
||||||
* PyObjects of type Scene.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*@{*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief The Scene PyType destructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void Scene_DeAlloc (BPy_Scene *self)
|
static void Scene_DeAlloc (BPy_Scene *self)
|
||||||
{
|
{
|
||||||
PyObject_DEL (self);
|
PyObject_DEL (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief The Scene PyType attribute getter
|
|
||||||
*
|
|
||||||
* This is the callback called when a user tries to retrieve the contents of
|
|
||||||
* Scene PyObject data members. Ex. in Python: "print myscene.lens".
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Scene_GetAttr (BPy_Scene *self, char *name)
|
static PyObject *Scene_GetAttr (BPy_Scene *self, char *name)
|
||||||
{
|
{
|
||||||
PyObject *attr = Py_None;
|
PyObject *attr = Py_None;
|
||||||
@@ -921,13 +689,6 @@ static PyObject *Scene_GetAttr (BPy_Scene *self, char *name)
|
|||||||
return Py_FindMethod(BPy_Scene_methods, (PyObject *)self, name);
|
return Py_FindMethod(BPy_Scene_methods, (PyObject *)self, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief The Scene PyType attribute setter
|
|
||||||
*
|
|
||||||
* This is the callback called when the user tries to change the value of some
|
|
||||||
* Scene data member. Ex. in Python: "myscene.lens = 45.0".
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int Scene_SetAttr (BPy_Scene *self, char *name, PyObject *value)
|
static int Scene_SetAttr (BPy_Scene *self, char *name, PyObject *value)
|
||||||
{
|
{
|
||||||
PyObject *valtuple;
|
PyObject *valtuple;
|
||||||
@@ -967,61 +728,23 @@ static int Scene_SetAttr (BPy_Scene *self, char *name, PyObject *value)
|
|||||||
return 0; /* normal exit */
|
return 0; /* normal exit */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief The Scene PyType compare function
|
|
||||||
*
|
|
||||||
* This function compares two given Scene PyObjects, returning 0 for equality
|
|
||||||
* and -1 otherwise. In Python it becomes 1 if they are equal and 0 case not.
|
|
||||||
* The comparison is done with their pointers to Blender Scene objects,
|
|
||||||
* so any two wrappers pointing to the same Blender Scene will be
|
|
||||||
* considered the same Scene PyObject. Currently, only the "==" and "!="
|
|
||||||
* comparisons are meaninful -- the "<", "<=", ">" or ">=" are not.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int Scene_Compare (BPy_Scene *a, BPy_Scene *b)
|
static int Scene_Compare (BPy_Scene *a, BPy_Scene *b)
|
||||||
{
|
{
|
||||||
Scene *pa = a->scene, *pb = b->scene;
|
Scene *pa = a->scene, *pb = b->scene;
|
||||||
return (pa == pb) ? 0:-1;
|
return (pa == pb) ? 0:-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief The Scene PyType print callback
|
|
||||||
*
|
|
||||||
* This function is called when the user tries to print a PyObject of type
|
|
||||||
* Scene. It builds a string with the name of the wrapped Blender Scene.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int Scene_Print(BPy_Scene *self, FILE *fp, int flags)
|
static int Scene_Print(BPy_Scene *self, FILE *fp, int flags)
|
||||||
{
|
{
|
||||||
fprintf(fp, "[Scene \"%s\"]", self->scene->id.name+2);
|
fprintf(fp, "[Scene \"%s\"]", self->scene->id.name+2);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief The Scene PyType repr callback
|
|
||||||
*
|
|
||||||
* This function is called when the statement "repr(myscene)" is executed in
|
|
||||||
* Python. Repr gives a string representation of a PyObject.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static PyObject *Scene_Repr (BPy_Scene *self)
|
static PyObject *Scene_Repr (BPy_Scene *self)
|
||||||
{
|
{
|
||||||
return PyString_FromString(self->scene->id.name+2);
|
return PyString_FromString(self->scene->id.name+2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@}*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Internal helper function to search the Base of an Object
|
|
||||||
*
|
|
||||||
* This function looks up the linked list of Bases in a scene, searching
|
|
||||||
* for a given object.
|
|
||||||
* \param scene Scene*: A pointer to a Blender Scene;
|
|
||||||
* \param object Object*: A pointer to a Blender Object.
|
|
||||||
* \return The Base* to the Base where object was stored or NULL if the
|
|
||||||
* object isn't linked to this scene.
|
|
||||||
*/
|
|
||||||
|
|
||||||
Base *EXPP_Scene_getObjectBase(Scene *scene, Object *object)
|
Base *EXPP_Scene_getObjectBase(Scene *scene, Object *object)
|
||||||
{
|
{
|
||||||
Base *base = scene->base.first;
|
Base *base = scene->base.first;
|
||||||
|
@@ -201,9 +201,9 @@ static PyObject *M_Text_unlink(PyObject *self, PyObject *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: M_Text_Init */
|
/* Function: Text_Init */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *M_Text_Init (void)
|
PyObject *Text_Init (void)
|
||||||
{
|
{
|
||||||
PyObject *submodule;
|
PyObject *submodule;
|
||||||
|
|
||||||
|
@@ -34,9 +34,9 @@
|
|||||||
struct PyMethodDef Null_methods[] = {{NULL, NULL}};
|
struct PyMethodDef Null_methods[] = {{NULL, NULL}};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: M_Types_Init */
|
/* Function: Types_Init */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *M_Types_Init (void)
|
PyObject *Types_Init (void)
|
||||||
{
|
{
|
||||||
PyObject *submodule, *dict;
|
PyObject *submodule, *dict;
|
||||||
|
|
||||||
|
@@ -169,10 +169,10 @@ static PyObject *M_Window_ImageSelector(PyObject *self, PyObject *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: M_Window_DrawProgressbar */
|
/* Function: M_Window_DrawProgressBar */
|
||||||
/* Python equivalent: Blender.Window.DrawProgressbar */
|
/* Python equivalent: Blender.Window.DrawProgressBar */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *M_Window_DrawProgressbar(PyObject *self, PyObject *args)
|
static PyObject *M_Window_DrawProgressBar(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
float done;
|
float done;
|
||||||
char *info = 0;
|
char *info = 0;
|
||||||
@@ -188,9 +188,9 @@ static PyObject *M_Window_DrawProgressbar(PyObject *self, PyObject *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: M_Window_Init */
|
/* Function: Window_Init */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *M_Window_Init (void)
|
PyObject *Window_Init (void)
|
||||||
{
|
{
|
||||||
PyObject *submodule, *Types;
|
PyObject *submodule, *Types;
|
||||||
|
|
||||||
|
@@ -67,7 +67,7 @@ static PyObject *M_Window_RedrawAll (PyObject *self, PyObject *args);
|
|||||||
static PyObject *M_Window_QRedrawAll (PyObject *self, PyObject *args);
|
static PyObject *M_Window_QRedrawAll (PyObject *self, PyObject *args);
|
||||||
static PyObject *M_Window_FileSelector (PyObject *self, PyObject *args);
|
static PyObject *M_Window_FileSelector (PyObject *self, PyObject *args);
|
||||||
static PyObject *M_Window_ImageSelector (PyObject *self, PyObject *args);
|
static PyObject *M_Window_ImageSelector (PyObject *self, PyObject *args);
|
||||||
static PyObject *M_Window_DrawProgressbar (PyObject *self, PyObject *args);
|
static PyObject *M_Window_DrawProgressBar (PyObject *self, PyObject *args);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* The following string definitions are used for documentation strings. */
|
/* The following string definitions are used for documentation strings. */
|
||||||
@@ -106,7 +106,7 @@ def my_function(filename):\n\
|
|||||||
print 'The selected image file was: ', filename\n\n\
|
print 'The selected image file was: ', filename\n\n\
|
||||||
Blender.Window.ImageSelector(my_function, 'LOAD IMAGE')\n";
|
Blender.Window.ImageSelector(my_function, 'LOAD IMAGE')\n";
|
||||||
|
|
||||||
char M_Window_DrawProgressbar_doc[] =
|
char M_Window_DrawProgressBar_doc[] =
|
||||||
"(done, text) - Draw a progressbar.\n\
|
"(done, text) - Draw a progressbar.\n\
|
||||||
'done' is a float value <= 1.0, 'text' contains info about what is\n\
|
'done' is a float value <= 1.0, 'text' contains info about what is\n\
|
||||||
currently being done.";
|
currently being done.";
|
||||||
@@ -121,8 +121,10 @@ struct PyMethodDef M_Window_methods[] = {
|
|||||||
{"FileSelector", M_Window_FileSelector, METH_VARARGS, M_Window_FileSelector_doc},
|
{"FileSelector", M_Window_FileSelector, METH_VARARGS, M_Window_FileSelector_doc},
|
||||||
{"ImageSelector", M_Window_ImageSelector, METH_VARARGS,
|
{"ImageSelector", M_Window_ImageSelector, METH_VARARGS,
|
||||||
M_Window_ImageSelector_doc},
|
M_Window_ImageSelector_doc},
|
||||||
{"DrawProgressbar", M_Window_DrawProgressbar, METH_VARARGS,
|
{"DrawProgressBar", M_Window_DrawProgressBar, METH_VARARGS,
|
||||||
M_Window_DrawProgressbar_doc},
|
M_Window_DrawProgressBar_doc},
|
||||||
|
{"drawProgressBar", M_Window_DrawProgressBar, METH_VARARGS,
|
||||||
|
M_Window_DrawProgressBar_doc},
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
76
source/blender/python/api2_2x/bpy_types.h
Normal file
76
source/blender/python/api2_2x/bpy_types.h
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version. The Blender
|
||||||
|
* Foundation also sells licenses for use in proprietary software under
|
||||||
|
* the Blender License. See http://www.blender.org/BL/ for information
|
||||||
|
* about this.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This is a new part of Blender.
|
||||||
|
*
|
||||||
|
* Contributor(s): Willian P. Germano
|
||||||
|
*
|
||||||
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EXPP_bpy_types_h
|
||||||
|
#define EXPP_bpy_types_h
|
||||||
|
|
||||||
|
#include <Python.h>
|
||||||
|
|
||||||
|
#include <DNA_camera_types.h>
|
||||||
|
#include <DNA_lamp_types.h>
|
||||||
|
|
||||||
|
#include "rgbTuple.h" /* for BPy_rgbTuple */
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Camera Data */
|
||||||
|
/*****************************************************************************/
|
||||||
|
extern PyTypeObject Camera_Type;
|
||||||
|
|
||||||
|
#define BPy_Camera_Check(v) \
|
||||||
|
((v)->ob_type == &Camera_Type) /* for type checking */
|
||||||
|
|
||||||
|
/* Python BPy_Camera structure definition */
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
Camera *camera;
|
||||||
|
|
||||||
|
} BPy_Camera;
|
||||||
|
/**/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Lamp Data */
|
||||||
|
/*****************************************************************************/
|
||||||
|
extern PyTypeObject Lamp_Type;
|
||||||
|
|
||||||
|
#define BPy_Lamp_Check(v) \
|
||||||
|
((v)->ob_type == &Lamp_Type) /* for type checking */
|
||||||
|
|
||||||
|
/* Python BPy_Lamp structure definition */
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
Lamp *lamp;
|
||||||
|
BPy_rgbTuple *color;
|
||||||
|
|
||||||
|
} BPy_Lamp;
|
||||||
|
/**/
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* EXPP_bpy_types_h */
|
58
source/blender/python/api2_2x/doc/Blender.py
Normal file
58
source/blender/python/api2_2x/doc/Blender.py
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
# The Blender Module
|
||||||
|
|
||||||
|
"""
|
||||||
|
Here goes the Introduction to Blender Python
|
||||||
|
|
||||||
|
Let's see::
|
||||||
|
- What scripting is, why have it
|
||||||
|
- What is Python, links
|
||||||
|
- More about what scripting can give us
|
||||||
|
- Overview of the Blender Python modules
|
||||||
|
- Links to Blender, Blender Python, later: script lists
|
||||||
|
@author: The Blender Python Team
|
||||||
|
@requires: Blender 2.28 or newer, Python 2.? (2.0, 2.1, 2.2 ???) or newer
|
||||||
|
@version: 0.1
|
||||||
|
@see: U{www.blender.org<http://www.blender.org>}
|
||||||
|
@see: U{projects.blender.org<http://projects.blender.org>}
|
||||||
|
"""
|
||||||
|
|
||||||
|
def Set (request, data):
|
||||||
|
"""
|
||||||
|
Update settings in Blender
|
||||||
|
@type request: string
|
||||||
|
@param request: The setting to change:
|
||||||
|
- 'curframe': the current animation frame
|
||||||
|
@type data: int
|
||||||
|
@param data: The new value.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def Get (request):
|
||||||
|
"""
|
||||||
|
Retrieve settings from Blender.
|
||||||
|
@type request: string
|
||||||
|
@param request: The setting data to be returned:
|
||||||
|
- 'curframe': the current animation frame
|
||||||
|
- 'curtime' : the current animation time
|
||||||
|
- 'staframe': the start frame of the animation
|
||||||
|
- 'endframe': the end frame of the animation
|
||||||
|
- 'filename': the name of the last file read or written
|
||||||
|
- 'version' : the Blender version number
|
||||||
|
@return: The requested data.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def Redraw ():
|
||||||
|
"""
|
||||||
|
Redraw all 3D windows
|
||||||
|
"""
|
||||||
|
|
||||||
|
def ReleaseGlobalDict (bool = None):
|
||||||
|
"""
|
||||||
|
Define whether the global Python Interpreter dictionary should be cleared
|
||||||
|
after the script is run. Default is to clear (non-zero bool).
|
||||||
|
@type bool: an int, actually
|
||||||
|
@param bool: The flag to release (non-zero bool) or not (bool = 0) the dict.
|
||||||
|
if no argument is passed, this function simply returns the current
|
||||||
|
behavior.
|
||||||
|
@rtype: int
|
||||||
|
@return: A bool value (0 or 1) telling the current behavior.
|
||||||
|
"""
|
@@ -9,8 +9,8 @@ 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.lens = 35.0 # set lens 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
|
||||||
cur.link(ob). # link object into scene
|
cur.link(ob). # link object into scene
|
||||||
@@ -24,19 +24,19 @@ def New (type = 'persp', name = 'CamData'):
|
|||||||
@param type: The Camera type: 'persp' or 'ortho'.
|
@param type: The Camera type: 'persp' or 'ortho'.
|
||||||
@type name: string
|
@type name: string
|
||||||
@param name: The Camera Data name.
|
@param name: The Camera Data name.
|
||||||
@rtype: Camera
|
@rtype: Blender Camera
|
||||||
@return: The created Camera Data object.
|
@return: The created Camera Data object.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def Get (name = None):
|
def Get (name = None):
|
||||||
"""
|
"""
|
||||||
Get the Camera Data object(s).rom Blender.
|
Get the Camera Data object(s) from Blender.
|
||||||
@type name: string
|
@type name: string
|
||||||
@param name: The name of the Camera Data.
|
@param name: The name of the Camera Data.
|
||||||
@rtype: Camera or a list of Cameras
|
@rtype: Blender Camera or a list of Blender Cameras
|
||||||
@return: It depends on the 'name' parameter:
|
@return: It depends on the 'name' parameter:
|
||||||
- (name).The Camera Data object with the given name;
|
- (name): The Camera Data object with the given name;
|
||||||
- (). A list with all Camera Data objects in the current Scene.
|
- (): A list with all Camera Data objects in the current scene.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class Camera:
|
class Camera:
|
||||||
@@ -45,42 +45,45 @@ class Camera:
|
|||||||
======================
|
======================
|
||||||
This object gives access to Camera-specific data in Blender.
|
This object gives access to Camera-specific data in Blender.
|
||||||
@cvar name: The Camera Data name.
|
@cvar name: The Camera Data name.
|
||||||
@cvar type: The 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].
|
||||||
@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].
|
||||||
|
@warning: Most member variables assume values in some [Min, Max] interval.
|
||||||
|
When trying to set them, the given parameter will be clamped to lie in
|
||||||
|
that range: if val < Min, then val = Min, if val > Max, then val = Max.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def getName(self):
|
def getName():
|
||||||
"""
|
"""
|
||||||
Get the name of this Camera Data object.
|
Get the name of this Camera Data object.
|
||||||
@rtype: string
|
@rtype: string
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def setName(self, name):
|
def setName(name):
|
||||||
"""
|
"""
|
||||||
Set the name of this Camera Data object.
|
Set the name of this Camera Data object.
|
||||||
@type name: string
|
@type name: string
|
||||||
@param name: The new name.
|
@param name: The new name.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def getType(self):
|
def getType():
|
||||||
"""
|
"""
|
||||||
Get this Camera's type.
|
Get this Camera's type.
|
||||||
@rtype: int
|
@rtype: int
|
||||||
@return: 0 for 'persp' or 1 for 'ortho'.
|
@return: 0 for 'persp' or 1 for 'ortho'.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def setType(self, type):
|
def setType(type):
|
||||||
"""
|
"""
|
||||||
Set this Camera's type.
|
Set this Camera's type.
|
||||||
@type type: string
|
@type type: string
|
||||||
@param type: The Camera type: 'persp' or 'ortho'.
|
@param type: The Camera type: 'persp' or 'ortho'.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def getMode(self):
|
def getMode():
|
||||||
"""
|
"""
|
||||||
Get this Camera's mode flags.
|
Get this Camera's mode flags.
|
||||||
@rtype: int
|
@rtype: int
|
||||||
@@ -88,10 +91,10 @@ class Camera:
|
|||||||
resp. 01 and 10 in binary.
|
resp. 01 and 10 in binary.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def setMode(self, mode1 = None, mode2 = None):
|
def setMode(mode1 = None, mode2 = None):
|
||||||
"""
|
"""
|
||||||
Set this Camera's mode flags. Mode strings given are turned 'on'.
|
Set this Camera's mode flags. Mode strings given are turned 'on'.
|
||||||
Those not provided are turned 'off', so cam.setMode().- without
|
Those not provided are turned 'off', so cam.setMode() -- without
|
||||||
arguments -- turns off all mode flags for Camera cam.
|
arguments -- turns off all mode flags for Camera cam.
|
||||||
@type mode1: string
|
@type mode1: string
|
||||||
@type mode2: string
|
@type mode2: string
|
||||||
@@ -99,58 +102,54 @@ class Camera:
|
|||||||
@param mode2: A mode flag: 'showLimits' or 'showMist'.
|
@param mode2: A mode flag: 'showLimits' or 'showMist'.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def getLens(self):
|
def getLens():
|
||||||
"""
|
"""
|
||||||
Get the lens value.
|
Get the lens value.
|
||||||
@rtype: float
|
@rtype: float
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def setLens(self, lens):
|
def setLens(lens):
|
||||||
"""
|
"""
|
||||||
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.
|
||||||
@warning: The value will be clamped to the min/max limits of this variable.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def getClipStart(self):
|
def getClipStart():
|
||||||
"""
|
"""
|
||||||
Get the clip start value.
|
Get the clip start value.
|
||||||
@rtype: float
|
@rtype: float
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def setClipStart(self, clipStart):
|
def setClipStart(clipstart):
|
||||||
"""
|
"""
|
||||||
Set the clip start value.
|
Set the clip start value.
|
||||||
@type clipStart: float
|
@type clipstart: float
|
||||||
@param clipStart: The new lens value.
|
@param clipstart: The new lens value.
|
||||||
@warning: The value will be clamped to the min/max limits of this variable.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def getClipEnd(self):
|
def getClipEnd():
|
||||||
"""
|
"""
|
||||||
Get the clip end value.
|
Get the clip end value.
|
||||||
@rtype: float
|
@rtype: float
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def setClipEnd(self, clipEnd):
|
def setClipEnd(clipend):
|
||||||
"""
|
"""
|
||||||
Set the clip end value.
|
Set the clip end value.
|
||||||
@type clipEnd: float
|
@type clipend: float
|
||||||
@param clipEnd: The new clip end value.
|
@param clipend: The new clip end value.
|
||||||
@warning: The value will be clamped to the min/max limits of this variable.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def getDrawSize(self):
|
def getDrawSize():
|
||||||
"""
|
"""
|
||||||
Get the draw size value.
|
Get the draw size value.
|
||||||
@rtype: float
|
@rtype: float
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def setDrawSize(self, drawSize):
|
def setDrawSize(drawsize):
|
||||||
"""
|
"""
|
||||||
Set the draw size value.
|
Set the draw size value.
|
||||||
@type drawSize: float
|
@type drawsize: float
|
||||||
@param drawSize: The new draw size value.
|
@param drawsize: The new draw size value.
|
||||||
@warning: The value will be clamped to the min/max limits of this variable.
|
|
||||||
"""
|
"""
|
||||||
|
319
source/blender/python/api2_2x/doc/Lamp.py
Normal file
319
source/blender/python/api2_2x/doc/Lamp.py
Normal file
@@ -0,0 +1,319 @@
|
|||||||
|
# Blender.Lamp module and the Lamp PyType object
|
||||||
|
|
||||||
|
"""
|
||||||
|
The Blender.Lamp submodule
|
||||||
|
|
||||||
|
This module provides control over B{Lamp Data} objects in Blender.
|
||||||
|
|
||||||
|
Example::
|
||||||
|
|
||||||
|
from Blender import Lamp
|
||||||
|
l = Lamp.New('Spot') # create new 'Spot' lamp data
|
||||||
|
l.setMode('square', 'shadow') # set these two lamp mode flags
|
||||||
|
ob = Object.New('Lamp') # create new lamp object
|
||||||
|
ob.link(l) # link lamp obj with lamp data
|
||||||
|
"""
|
||||||
|
|
||||||
|
def New (type = 'Lamp', name = 'LampData'):
|
||||||
|
"""
|
||||||
|
Create a new Lamp Data object.
|
||||||
|
@type type: string
|
||||||
|
@param type: The Lamp type: 'Lamp', 'Sun', 'Spot' or 'Hemi'.
|
||||||
|
@type name: string
|
||||||
|
@param name: The Lamp Data name.
|
||||||
|
@rtype: Blender Lamp
|
||||||
|
@return: The created Lamp Data object.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def Get (name = None):
|
||||||
|
"""
|
||||||
|
Get the Lamp Data object(s) from Blender.
|
||||||
|
@type name: string
|
||||||
|
@param name: The name of the Lamp Data.
|
||||||
|
@rtype: Blender Lamp or a list of Blender Lamps
|
||||||
|
@return: It depends on the 'name' parameter:
|
||||||
|
- (name): The Lamp Data object with the given name;
|
||||||
|
- (): A list with all Lamp Data objects in the current scene.
|
||||||
|
"""
|
||||||
|
|
||||||
|
class Lamp:
|
||||||
|
"""
|
||||||
|
The Lamp Data object
|
||||||
|
====================
|
||||||
|
This object gives access to Lamp-specific data in Blender.
|
||||||
|
@cvar name: The Lamp Data name.
|
||||||
|
@cvar type: The Lamp type (see the Types dict).
|
||||||
|
@cvar Types: The Types dictionary.
|
||||||
|
- 'Lamp': 0
|
||||||
|
- 'Sun' : 1
|
||||||
|
- 'Spot': 2
|
||||||
|
- 'Hemi': 3
|
||||||
|
@cvar mode: The mode flags: B{or'ed value} of the flags in the Modes dict.
|
||||||
|
@cvar Modes: The Modes dictionary.
|
||||||
|
- 'Shadows'
|
||||||
|
- 'Halo'
|
||||||
|
- 'Layer'
|
||||||
|
- 'Quad'
|
||||||
|
- 'Negative'
|
||||||
|
- 'OnlyShadow'
|
||||||
|
- 'Sphere'
|
||||||
|
- 'Square'
|
||||||
|
@cvar samples: The number of shadow map samples in [1, 16].
|
||||||
|
@cvar bufferSize: The size of the shadow buffer in [512, 5120].
|
||||||
|
@cvar haloStep: Volumetric halo sampling frequency in [0, 12].
|
||||||
|
@cvar energy: The intensity of the light in [0.0, 10.0].
|
||||||
|
@cvar dist: The distance value in [0.1, 5000.0].
|
||||||
|
@cvar spotSize: The angle of the spot beam in degrees in [1.0, 180.0].
|
||||||
|
@cvar spotBlend: The softness of the spot edge in [0.0, 1.0].
|
||||||
|
@cvar clipStart: The shadow map clip start in [0.1, 1000.0].
|
||||||
|
@cvar clipEnd: The shadow map clip end in [1.0, 5000.0].
|
||||||
|
@cvar bias: The shadow map sampling bias in [0.01, 5.00].
|
||||||
|
@cvar softness: The size of the shadow sample area in [1.0, 100.0].
|
||||||
|
@cvar haloInt: The intensity of the spot halo in [0.0, 5.0].
|
||||||
|
@cvar quad1: Light intensity value 1 for a Quad lamp in [0.0, 1.0].
|
||||||
|
@cvar quad2: Light intensity value 2 for a Quad lamp in [0.0, 1.0].
|
||||||
|
@cvar col: The color of the light, with each rgb component in [0.0, 1.0].
|
||||||
|
This is an rgb tuple whose values can be accessed in many ways:
|
||||||
|
- as a tuple: lamp.col, lamp.col[0], same for 1 and 2.
|
||||||
|
- as a dictionary: lamp.col['R'], same for 'G' and 'B'.
|
||||||
|
- as an object: lamp.col.R, same for G and B.
|
||||||
|
@warning: Most member variables assume values in some [Min, Max] interval.
|
||||||
|
When trying to set them, the given parameter will be clamped to lie in
|
||||||
|
that range: if val < Min, then val = Min, if val > Max, then val = Max.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getName():
|
||||||
|
"""
|
||||||
|
Get the name of this Lamp Data object.
|
||||||
|
@rtype: string
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setName(name):
|
||||||
|
"""
|
||||||
|
Set the name of this Lamp Data object.
|
||||||
|
@type name: string
|
||||||
|
@param name: The new name.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getType():
|
||||||
|
"""
|
||||||
|
Get this Lamp's type.
|
||||||
|
@rtype: int
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setType(type):
|
||||||
|
"""
|
||||||
|
Set this Lamp's type.
|
||||||
|
@type type: string
|
||||||
|
@param type: The Lamp type: 'Lamp', 'Sun', 'Spot' or 'Hemi'.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getMode():
|
||||||
|
"""
|
||||||
|
Get this Lamp's mode flags.
|
||||||
|
@rtype: int
|
||||||
|
@return: B{OR'ed value}. Use the Modes dictionary to check which flags
|
||||||
|
are 'on'.
|
||||||
|
|
||||||
|
Example::
|
||||||
|
flags = mylamp.getMode()
|
||||||
|
if flags & mylamp.Modes['Shadows']:
|
||||||
|
print "This lamp produces shadows"
|
||||||
|
else:
|
||||||
|
print "The 'Shadows' flag is off"
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setMode(m = None, m2 = None, m3 = None, m4 = None,
|
||||||
|
m5 = None, m6 = None, m7 = None, m8 = None):
|
||||||
|
"""
|
||||||
|
Set this Lamp's mode flags. Mode strings given are turned 'on'.
|
||||||
|
Those not provided are turned 'off', so lamp.setMode() -- without
|
||||||
|
arguments -- turns off all mode flags for Lamp lamp.
|
||||||
|
@type m: string
|
||||||
|
@param m: A mode flag. From 1 to 8 can be set at the same time.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getSamples():
|
||||||
|
"""
|
||||||
|
Get this lamp's samples value.
|
||||||
|
@rtype: int
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setSamples(samples):
|
||||||
|
"""
|
||||||
|
Set the samples value.
|
||||||
|
@type samples: int
|
||||||
|
@param samples: The new samples value.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getBufferSize():
|
||||||
|
"""
|
||||||
|
Get this lamp's buffer size.
|
||||||
|
@rtype: int
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setBufferSize(bufsize):
|
||||||
|
"""
|
||||||
|
Set the buffer size value.
|
||||||
|
@type bufsize: int
|
||||||
|
@param bufsize: The new buffer size value.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getHaloStep():
|
||||||
|
"""
|
||||||
|
Get this lamp's halo step value.
|
||||||
|
@rtype: int
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setHaloStep(hastep):
|
||||||
|
"""
|
||||||
|
Set the halo step value.
|
||||||
|
@type hastep: int
|
||||||
|
@param hastep: The new halo step value.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getEnergy():
|
||||||
|
"""
|
||||||
|
Get this lamp's energy intensity value.
|
||||||
|
@rtype: float
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setEnergy(energy):
|
||||||
|
"""
|
||||||
|
Set the energy intensity value.
|
||||||
|
@type energy: float
|
||||||
|
@param energy: The new energy value.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getDist():
|
||||||
|
"""
|
||||||
|
Get this lamp's distance value.
|
||||||
|
@rtype: float
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setDist(distance):
|
||||||
|
"""
|
||||||
|
Set the distance value.
|
||||||
|
@type distance: float
|
||||||
|
@param distance: The new distance value.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getSpotSize():
|
||||||
|
"""
|
||||||
|
Get this lamp's spot size value.
|
||||||
|
@rtype: float
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setSpotSize(spotsize):
|
||||||
|
"""
|
||||||
|
Set the spot size value.
|
||||||
|
@type spotsize: float
|
||||||
|
@param spotsize: The new spot size value.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getSpotBlend():
|
||||||
|
"""
|
||||||
|
Get this lamp's spot blend value.
|
||||||
|
@rtype: float
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setSpotBlend(spotblend):
|
||||||
|
"""
|
||||||
|
Set the spot blend value.
|
||||||
|
@type spotblend: float
|
||||||
|
@param spotblend: The new spot blend value.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getClipStart():
|
||||||
|
"""
|
||||||
|
Get this lamp's clip start value.
|
||||||
|
@rtype: float
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setClipStart(clipstart):
|
||||||
|
"""
|
||||||
|
Set the clip start value.
|
||||||
|
@type clipstart: float
|
||||||
|
@param clipstart: The new clip start value.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getClipEnd():
|
||||||
|
"""
|
||||||
|
Get this lamp's clip end value.
|
||||||
|
@rtype: float
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setClipEnd(clipend):
|
||||||
|
"""
|
||||||
|
Set the clip end value.
|
||||||
|
@type clipend: float
|
||||||
|
@param clipend: The new clip end value.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getBias():
|
||||||
|
"""
|
||||||
|
Get this lamp's bias value.
|
||||||
|
@rtype: float
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setBias(bias):
|
||||||
|
"""
|
||||||
|
Set the bias value.
|
||||||
|
@type bias: float
|
||||||
|
@param bias: The new bias value.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getSoftness():
|
||||||
|
"""
|
||||||
|
Get this lamp's softness value.
|
||||||
|
@rtype: float
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setSoftness(softness):
|
||||||
|
"""
|
||||||
|
Set the softness value.
|
||||||
|
@type softness: float
|
||||||
|
@param softness: The new softness value.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getHaloInt():
|
||||||
|
"""
|
||||||
|
Get this lamp's halo intensity value.
|
||||||
|
@rtype: float
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setHaloInt(haloint):
|
||||||
|
"""
|
||||||
|
Set the halo intensity value.
|
||||||
|
@type haloint: float
|
||||||
|
@param haloint: The new halo intensity value.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getQuad1():
|
||||||
|
"""
|
||||||
|
Get this lamp's quad 1 value.
|
||||||
|
@rtype: float
|
||||||
|
@warning: this only applies to Lamps with the 'Quad' flag on.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setQuad1(quad1):
|
||||||
|
"""
|
||||||
|
Set the quad 1 value.
|
||||||
|
@type quad1: float
|
||||||
|
@warning: this only applies to Lamps with the 'Quad' flag on.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getQuad2():
|
||||||
|
"""
|
||||||
|
Get this lamp's quad 2 value.
|
||||||
|
@rtype: float
|
||||||
|
@warning: this only applies to Lamps with the 'Quad' flag on.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setQuad2(quad2):
|
||||||
|
"""
|
||||||
|
Set the quad 2 value.
|
||||||
|
@type quad2: float
|
||||||
|
@param quad2: The new quad 2 value.
|
||||||
|
@warning: this only applies to Lamps with the 'Quad' flag on.
|
||||||
|
"""
|
137
source/blender/python/api2_2x/doc/testcamera.py
Normal file
137
source/blender/python/api2_2x/doc/testcamera.py
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
# Blender.Camera module and Camera PyType test file
|
||||||
|
# This also works with Lamp and Material, simply uncomment the right
|
||||||
|
# line below
|
||||||
|
|
||||||
|
MODULE = "Camera"
|
||||||
|
#MODULE = "Lamp"
|
||||||
|
#MODULE = "Material"
|
||||||
|
BPY_OBJECT = MODULE
|
||||||
|
|
||||||
|
LONG_STRING = "Supercalifragilisticspialidous"
|
||||||
|
|
||||||
|
import types, sys
|
||||||
|
import Blender
|
||||||
|
exec ("from Blender import %s" % MODULE)
|
||||||
|
|
||||||
|
def PRINT_HEADER(header, sep):
|
||||||
|
print "\n", sep * 79
|
||||||
|
print header
|
||||||
|
print sep * 79
|
||||||
|
|
||||||
|
def PRINT_UNDERLINED(str):
|
||||||
|
print "\n", str
|
||||||
|
print "-" * len(str)
|
||||||
|
|
||||||
|
def PRINT_AND_RM(arg, branch, d):
|
||||||
|
for a in arg:
|
||||||
|
if a in d:
|
||||||
|
d.remove(a)
|
||||||
|
print "\n%s.%s:" % (branch, a),
|
||||||
|
exec("print %s.%s" % (branch, a))
|
||||||
|
|
||||||
|
PRINT_HEADER("Testing the Blender.%s module" % MODULE, '=')
|
||||||
|
|
||||||
|
exec ("Module_dir = dir (%s)" % MODULE)
|
||||||
|
print "\ndir (%s):" % MODULE
|
||||||
|
print Module_dir
|
||||||
|
|
||||||
|
PRINT_AND_RM (["__name__", "__doc__"], MODULE, Module_dir)
|
||||||
|
|
||||||
|
for item in Module_dir:
|
||||||
|
hooked = 0
|
||||||
|
branch = "%s.%s" % (MODULE, item)
|
||||||
|
PRINT_HEADER(branch, "-")
|
||||||
|
exec ("item_type = type (%s)" % branch)
|
||||||
|
print item_type
|
||||||
|
exec ("sub_dir = dir(%s)" % branch)
|
||||||
|
PRINT_AND_RM (["__name__", "__doc__"], branch, sub_dir)
|
||||||
|
if item_type == types.BuiltinFunctionType:
|
||||||
|
PRINT_UNDERLINED ("Executing %s:" % branch)
|
||||||
|
exec ("result = %s()" % branch)
|
||||||
|
print "Returned value is: ", result
|
||||||
|
if item in ["Get", "get"] and not hooked:
|
||||||
|
if len(result):
|
||||||
|
obj = result[0]
|
||||||
|
hooked = 1
|
||||||
|
|
||||||
|
if hooked:
|
||||||
|
PRINT_HEADER(obj, "=")
|
||||||
|
exec ("obj_dir = dir(obj)")
|
||||||
|
print "\ndir():"
|
||||||
|
print obj_dir
|
||||||
|
|
||||||
|
methods = []
|
||||||
|
member_vars = []
|
||||||
|
|
||||||
|
for item in obj_dir:
|
||||||
|
exec ("item_type = type (obj.%s)" % item)
|
||||||
|
if item_type == types.BuiltinMethodType:
|
||||||
|
methods.append(item)
|
||||||
|
else:
|
||||||
|
member_vars.append(item)
|
||||||
|
|
||||||
|
PRINT_HEADER("%s Methods" % BPY_OBJECT, '-')
|
||||||
|
if methods: print methods
|
||||||
|
else: print "XXX No methods found in %s" % BPY_OBJECT
|
||||||
|
|
||||||
|
PRINT_HEADER("%s Member Variables" % BPY_OBJECT, '-')
|
||||||
|
if member_vars:
|
||||||
|
for m in member_vars:
|
||||||
|
PRINT_UNDERLINED(m)
|
||||||
|
exec ("mvalue = obj.%s" % m)
|
||||||
|
exec ("mtype = type (obj.%s)" % m)
|
||||||
|
mtype = str(mtype).split("'")[1]
|
||||||
|
print "%s: %s" % (mtype, mvalue)
|
||||||
|
|
||||||
|
M = m[0].upper() + m[1:]
|
||||||
|
setM = "set%s" % M
|
||||||
|
getM = "get%s" % M
|
||||||
|
if setM in methods:
|
||||||
|
print "There is a .%s() method." % setM
|
||||||
|
methods.remove(setM)
|
||||||
|
if mtype == 'str':
|
||||||
|
try:
|
||||||
|
print "Trying to set string to %s" % LONG_STRING
|
||||||
|
exec("obj.%s('%s')" % (setM, LONG_STRING))
|
||||||
|
exec("get_str = obj.%s()" % getM)
|
||||||
|
print "It returned:", get_str
|
||||||
|
len_str = len(get_str)
|
||||||
|
if len_str < 100:
|
||||||
|
print "It correctly clamped the string to %s chars." % len_str
|
||||||
|
except:
|
||||||
|
PRINT_HEADER("FAILED in .%s()" % setM, "X")
|
||||||
|
print sys.exc_info()[0]
|
||||||
|
elif mtype == 'float':
|
||||||
|
try:
|
||||||
|
exec("obj.%s(%d)" % (setM, -999999))
|
||||||
|
exec("result = obj.%s()" % getM)
|
||||||
|
print "%s's minimum value is %f" % (m, result)
|
||||||
|
exec("obj.%s(%d)" % (setM, 999999))
|
||||||
|
exec("result = obj.%s()" % getM)
|
||||||
|
print "%s's maximum value is %f" % (m, result)
|
||||||
|
except:
|
||||||
|
PRINT_HEADER("FAILED in %s or %s" % (setM, getM), "X")
|
||||||
|
print sys.exc_info()[0]
|
||||||
|
elif mtype == 'int':
|
||||||
|
try:
|
||||||
|
dict = M+"s"
|
||||||
|
if dict in member_vars:
|
||||||
|
exec("key = obj.%s.keys()[1]" % dict)
|
||||||
|
exec("obj.%s('%s')" % (setM, key))
|
||||||
|
exec("result = obj.%s()" % getM)
|
||||||
|
except:
|
||||||
|
PRINT_HEADER("FAILED in %s or %s" % (setM, getM), "X")
|
||||||
|
print sys.exc_info()[0]
|
||||||
|
|
||||||
|
if getM in methods:
|
||||||
|
print "There is a .%s() method." % getM,
|
||||||
|
methods.remove(getM)
|
||||||
|
exec("result = obj.%s()" % getM)
|
||||||
|
print "It returned:", result
|
||||||
|
|
||||||
|
else: print "XXX No member variables found in %s" % BPY_OBJECT
|
||||||
|
|
||||||
|
else: # the module .Get() function found nothing
|
||||||
|
PRINT_HEADER("Failed trying to %s.Get() a %s object"
|
||||||
|
% (MODULE, BPY_OBJECT), 'X')
|
||||||
|
|
@@ -55,7 +55,7 @@ extern PyObject *g_blenderdict;
|
|||||||
/* Module Init functions and Data Object helper functions (used by the */
|
/* Module Init functions and Data Object helper functions (used by the */
|
||||||
/* Object module to work with its .data field for the various Data objs */
|
/* Object module to work with its .data field for the various Data objs */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void M_Blender_Init (void);
|
void M_Blender_Init (void);
|
||||||
|
|
||||||
/* Object itself */
|
/* Object itself */
|
||||||
PyObject * M_Object_Init (void);
|
PyObject * M_Object_Init (void);
|
||||||
@@ -64,31 +64,31 @@ int M_ObjectCheckPyObject (PyObject *py_obj);
|
|||||||
struct Object * M_ObjectFromPyObject (PyObject *py_obj);
|
struct Object * M_ObjectFromPyObject (PyObject *py_obj);
|
||||||
|
|
||||||
/* Scene */
|
/* Scene */
|
||||||
PyObject * M_Scene_Init (void);
|
PyObject * Scene_Init (void);
|
||||||
PyObject * Scene_CreatePyObject (struct Scene *sce);
|
PyObject * Scene_CreatePyObject (struct Scene *sce);
|
||||||
Scene * Scene_FromPyObject (PyObject *pyobj);
|
Scene * Scene_FromPyObject (PyObject *pyobj);
|
||||||
int Scene_CheckPyObject (PyObject *pyobj);
|
int Scene_CheckPyObject (PyObject *pyobj);
|
||||||
|
|
||||||
/* Types */
|
/* Types */
|
||||||
PyObject * M_Types_Init (void);
|
PyObject * Types_Init (void);
|
||||||
|
|
||||||
/* NMesh Data */
|
/* NMesh Data */
|
||||||
PyObject * M_NMesh_Init (void);
|
PyObject * NMesh_Init (void);
|
||||||
PyObject * NMesh_CreatePyObject (struct Camera *cam);
|
PyObject * NMesh_CreatePyObject (struct Camera *cam);
|
||||||
Camera * NMesh_FromPyObject (PyObject *pyobj);
|
Camera * NMesh_FromPyObject (PyObject *pyobj);
|
||||||
int NMesh_CheckPyObject (PyObject *pyobj);
|
int NMesh_CheckPyObject (PyObject *pyobj);
|
||||||
|
|
||||||
/* Material */
|
/* Material */
|
||||||
PyObject * M_Material_Init (void);
|
PyObject * Material_Init (void);
|
||||||
|
|
||||||
/* Camera Data */
|
/* Camera Data */
|
||||||
PyObject * M_Camera_Init (void);
|
PyObject * Camera_Init (void);
|
||||||
PyObject * Camera_CreatePyObject (struct Camera *cam);
|
PyObject * Camera_CreatePyObject (struct Camera *cam);
|
||||||
Camera * Camera_FromPyObject (PyObject *pyobj);
|
Camera * Camera_FromPyObject (PyObject *pyobj);
|
||||||
int Camera_CheckPyObject (PyObject *pyobj);
|
int Camera_CheckPyObject (PyObject *pyobj);
|
||||||
|
|
||||||
/* Lamp Data */
|
/* Lamp Data */
|
||||||
PyObject * M_Lamp_Init (void);
|
PyObject * Lamp_Init (void);
|
||||||
PyObject * Lamp_CreatePyObject (struct Lamp *lamp);
|
PyObject * Lamp_CreatePyObject (struct Lamp *lamp);
|
||||||
Lamp * Lamp_FromPyObject (PyObject *pyobj);
|
Lamp * Lamp_FromPyObject (PyObject *pyobj);
|
||||||
int Lamp_CheckPyObject (PyObject *pyobj);
|
int Lamp_CheckPyObject (PyObject *pyobj);
|
||||||
@@ -124,15 +124,15 @@ struct Effect * Effect_FromPyObject (PyObject *py_obj);
|
|||||||
int Effect_CheckPyObject (PyObject *py_obj);
|
int Effect_CheckPyObject (PyObject *py_obj);
|
||||||
|
|
||||||
/* Image */
|
/* Image */
|
||||||
PyObject * M_Image_Init (void);
|
PyObject * Image_Init (void);
|
||||||
PyObject * Image_CreatePyObject (Image *image);
|
PyObject * Image_CreatePyObject (Image *image);
|
||||||
int Image_CheckPyObject (PyObject *pyobj);
|
int Image_CheckPyObject (PyObject *pyobj);
|
||||||
|
|
||||||
/* Init functions for other modules */
|
/* Init functions for other modules */
|
||||||
PyObject * M_Window_Init (void);
|
PyObject * Window_Init (void);
|
||||||
PyObject * M_Draw_Init (void);
|
PyObject * Draw_Init (void);
|
||||||
PyObject * M_BGL_Init (void);
|
PyObject * BGL_Init (void);
|
||||||
PyObject * M_Text_Init (void);
|
PyObject * Text_Init (void);
|
||||||
PyObject * M_World_Init (void);
|
PyObject * M_World_Init (void);
|
||||||
|
|
||||||
#endif /* EXPP_modules_h */
|
#endif /* EXPP_modules_h */
|
||||||
|
@@ -37,22 +37,22 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python rgbTuple_Type callback function prototypes: */
|
/* Python rgbTuple_Type callback function prototypes: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static void rgbTupleDeAlloc (C_rgbTuple *self);
|
static void rgbTupleDeAlloc (BPy_rgbTuple *self);
|
||||||
static PyObject *rgbTupleGetAttr (C_rgbTuple *self, char *name);
|
static PyObject *rgbTupleGetAttr (BPy_rgbTuple *self, char *name);
|
||||||
static int rgbTupleSetAttr (C_rgbTuple *self, char *name, PyObject *v);
|
static int rgbTupleSetAttr (BPy_rgbTuple *self, char *name, PyObject *v);
|
||||||
static int rgbTuplePrint(C_rgbTuple *self, FILE *fp, int flags);
|
static int rgbTuplePrint(BPy_rgbTuple *self, FILE *fp, int flags);
|
||||||
static PyObject *rgbTupleRepr (C_rgbTuple *self);
|
static PyObject *rgbTupleRepr (BPy_rgbTuple *self);
|
||||||
|
|
||||||
static int rgbTupleLength(C_rgbTuple *self);
|
static int rgbTupleLength(BPy_rgbTuple *self);
|
||||||
|
|
||||||
static PyObject *rgbTupleSubscript(C_rgbTuple *self, PyObject *key);
|
static PyObject *rgbTupleSubscript(BPy_rgbTuple *self, PyObject *key);
|
||||||
static int rgbTupleAssSubscript(C_rgbTuple *self, PyObject *who,
|
static int rgbTupleAssSubscript(BPy_rgbTuple *self, PyObject *who,
|
||||||
PyObject *cares);
|
PyObject *cares);
|
||||||
|
|
||||||
static PyObject *rgbTupleItem(C_rgbTuple *self, int i);
|
static PyObject *rgbTupleItem(BPy_rgbTuple *self, int i);
|
||||||
static int rgbTupleAssItem(C_rgbTuple *self, int i, PyObject *ob);
|
static int rgbTupleAssItem(BPy_rgbTuple *self, int i, PyObject *ob);
|
||||||
static PyObject *rgbTupleSlice(C_rgbTuple *self, int begin, int end);
|
static PyObject *rgbTupleSlice(BPy_rgbTuple *self, int begin, int end);
|
||||||
static int rgbTupleAssSlice(C_rgbTuple *self, int begin, int end, PyObject *seq);
|
static int rgbTupleAssSlice(BPy_rgbTuple *self, int begin, int end, PyObject *seq);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python rgbTuple_Type Mapping Methods table: */
|
/* Python rgbTuple_Type Mapping Methods table: */
|
||||||
@@ -86,7 +86,7 @@ PyTypeObject rgbTuple_Type =
|
|||||||
PyObject_HEAD_INIT(NULL)
|
PyObject_HEAD_INIT(NULL)
|
||||||
0, /* ob_size */
|
0, /* ob_size */
|
||||||
"rgbTuple", /* tp_name */
|
"rgbTuple", /* tp_name */
|
||||||
sizeof (C_rgbTuple), /* tp_basicsize */
|
sizeof (BPy_rgbTuple), /* tp_basicsize */
|
||||||
0, /* tp_itemsize */
|
0, /* tp_itemsize */
|
||||||
/* methods */
|
/* methods */
|
||||||
(destructor)rgbTupleDeAlloc, /* tp_dealloc */
|
(destructor)rgbTupleDeAlloc, /* tp_dealloc */
|
||||||
@@ -111,13 +111,11 @@ PyTypeObject rgbTuple_Type =
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *rgbTuple_New(float *rgb[3])
|
PyObject *rgbTuple_New(float *rgb[3])
|
||||||
{
|
{
|
||||||
C_rgbTuple *rgbTuple;
|
BPy_rgbTuple *rgbTuple;
|
||||||
|
|
||||||
printf ("In rgbTuple_New()\n");
|
|
||||||
|
|
||||||
rgbTuple_Type.ob_type = &PyType_Type;
|
rgbTuple_Type.ob_type = &PyType_Type;
|
||||||
|
|
||||||
rgbTuple = (C_rgbTuple *)PyObject_NEW(C_rgbTuple, &rgbTuple_Type);
|
rgbTuple = (BPy_rgbTuple *)PyObject_NEW(BPy_rgbTuple, &rgbTuple_Type);
|
||||||
|
|
||||||
if (rgbTuple == NULL)
|
if (rgbTuple == NULL)
|
||||||
return EXPP_ReturnPyObjError (PyExc_MemoryError,
|
return EXPP_ReturnPyObjError (PyExc_MemoryError,
|
||||||
@@ -136,7 +134,7 @@ PyObject *rgbTuple_New(float *rgb[3])
|
|||||||
/* get function returns a tuple, the set one accepts three */
|
/* get function returns a tuple, the set one accepts three */
|
||||||
/* floats (separated or in a tuple) as arguments. */
|
/* floats (separated or in a tuple) as arguments. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *rgbTuple_getCol (C_rgbTuple *self)
|
PyObject *rgbTuple_getCol (BPy_rgbTuple *self)
|
||||||
{
|
{
|
||||||
PyObject *list = PyList_New (3);
|
PyObject *list = PyList_New (3);
|
||||||
|
|
||||||
@@ -144,13 +142,13 @@ PyObject *rgbTuple_getCol (C_rgbTuple *self)
|
|||||||
"couldn't create PyList");
|
"couldn't create PyList");
|
||||||
|
|
||||||
PyList_SET_ITEM (list, 0, Py_BuildValue ("f", *(self->rgb[0]) ));
|
PyList_SET_ITEM (list, 0, Py_BuildValue ("f", *(self->rgb[0]) ));
|
||||||
PyList_SET_ITEM (list, 1, Py_BuildValue ("f", *(self->rgb[0]) ));
|
PyList_SET_ITEM (list, 1, Py_BuildValue ("f", *(self->rgb[1]) ));
|
||||||
PyList_SET_ITEM (list, 2, Py_BuildValue ("f", *(self->rgb[0]) ));
|
PyList_SET_ITEM (list, 2, Py_BuildValue ("f", *(self->rgb[2]) ));
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *rgbTuple_setCol (C_rgbTuple *self, PyObject *args)
|
PyObject *rgbTuple_setCol (BPy_rgbTuple *self, PyObject *args)
|
||||||
{
|
{
|
||||||
int ok;
|
int ok;
|
||||||
float r = 0, g = 0, b = 0;
|
float r = 0, g = 0, b = 0;
|
||||||
@@ -173,21 +171,21 @@ PyObject *rgbTuple_setCol (C_rgbTuple *self, PyObject *args)
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: rgbTupleDeAlloc */
|
/* Function: rgbTupleDeAlloc */
|
||||||
/* Description: This is a callback function for the C_rgbTuple type. It is */
|
/* Description: This is a callback function for the BPy_rgbTuple type. It is */
|
||||||
/* the destructor function. */
|
/* the destructor function. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static void rgbTupleDeAlloc (C_rgbTuple *self)
|
static void rgbTupleDeAlloc (BPy_rgbTuple *self)
|
||||||
{
|
{
|
||||||
PyObject_DEL (self);
|
PyObject_DEL (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: rgbTupleGetAttr */
|
/* Function: rgbTupleGetAttr */
|
||||||
/* Description: This is a callback function for the C_rgbTuple type. It is */
|
/* Description: This is a callback function for the BPy_rgbTuple type. It is */
|
||||||
/* the function that accesses C_rgbTuple member variables and */
|
/* the function that accesses BPy_rgbTuple member variables and */
|
||||||
/* methods. */
|
/* methods. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject* rgbTupleGetAttr (C_rgbTuple *self, char *name)
|
static PyObject* rgbTupleGetAttr (BPy_rgbTuple *self, char *name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -206,10 +204,10 @@ static PyObject* rgbTupleGetAttr (C_rgbTuple *self, char *name)
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: rgbTupleSetAttr */
|
/* Function: rgbTupleSetAttr */
|
||||||
/* Description: This is a callback function for the C_rgbTuple type. It is */
|
/* Description: This is a callback function for the BPy_rgbTuple type. It is */
|
||||||
/* the function that changes C_rgbTuple member variables. */
|
/* the function that changes BPy_rgbTuple member variables. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static int rgbTupleSetAttr (C_rgbTuple *self, char *name, PyObject *v)
|
static int rgbTupleSetAttr (BPy_rgbTuple *self, char *name, PyObject *v)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
@@ -239,12 +237,12 @@ static int rgbTupleSetAttr (C_rgbTuple *self, char *name, PyObject *v)
|
|||||||
/* These functions provide code to access rgbTuple objects as */
|
/* These functions provide code to access rgbTuple objects as */
|
||||||
/* mappings. */
|
/* mappings. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static int rgbTupleLength(C_rgbTuple *self)
|
static int rgbTupleLength(BPy_rgbTuple *self)
|
||||||
{
|
{
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *rgbTupleSubscript(C_rgbTuple *self, PyObject *key)
|
static PyObject *rgbTupleSubscript(BPy_rgbTuple *self, PyObject *key)
|
||||||
{
|
{
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
int i;
|
int i;
|
||||||
@@ -264,7 +262,7 @@ static PyObject *rgbTupleSubscript(C_rgbTuple *self, PyObject *key)
|
|||||||
return Py_BuildValue("f", *(self->rgb[i]));
|
return Py_BuildValue("f", *(self->rgb[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rgbTupleAssSubscript(C_rgbTuple *self, PyObject *key, PyObject *v)
|
static int rgbTupleAssSubscript(BPy_rgbTuple *self, PyObject *key, PyObject *v)
|
||||||
{
|
{
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
int i;
|
int i;
|
||||||
@@ -295,7 +293,7 @@ static int rgbTupleAssSubscript(C_rgbTuple *self, PyObject *key, PyObject *v)
|
|||||||
/* These functions provide code to access rgbTuple objects as */
|
/* These functions provide code to access rgbTuple objects as */
|
||||||
/* sequences. */
|
/* sequences. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *rgbTupleItem(C_rgbTuple *self, int i)
|
static PyObject *rgbTupleItem(BPy_rgbTuple *self, int i)
|
||||||
{
|
{
|
||||||
if (i < 0 || i >= 3)
|
if (i < 0 || i >= 3)
|
||||||
return EXPP_ReturnPyObjError (PyExc_IndexError,
|
return EXPP_ReturnPyObjError (PyExc_IndexError,
|
||||||
@@ -304,7 +302,7 @@ static PyObject *rgbTupleItem(C_rgbTuple *self, int i)
|
|||||||
return Py_BuildValue("f", *(self->rgb[i]));
|
return Py_BuildValue("f", *(self->rgb[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *rgbTupleSlice(C_rgbTuple *self, int begin, int end)
|
static PyObject *rgbTupleSlice(BPy_rgbTuple *self, int begin, int end)
|
||||||
{
|
{
|
||||||
PyObject *list;
|
PyObject *list;
|
||||||
int count;
|
int count;
|
||||||
@@ -322,7 +320,7 @@ static PyObject *rgbTupleSlice(C_rgbTuple *self, int begin, int end)
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rgbTupleAssItem(C_rgbTuple *self, int i, PyObject *ob)
|
static int rgbTupleAssItem(BPy_rgbTuple *self, int i, PyObject *ob)
|
||||||
{
|
{
|
||||||
if (i < 0 || i >= 3)
|
if (i < 0 || i >= 3)
|
||||||
return EXPP_ReturnIntError(PyExc_IndexError,
|
return EXPP_ReturnIntError(PyExc_IndexError,
|
||||||
@@ -337,7 +335,8 @@ static int rgbTupleAssItem(C_rgbTuple *self, int i, PyObject *ob)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rgbTupleAssSlice(C_rgbTuple *self, int begin, int end, PyObject *seq)
|
static int rgbTupleAssSlice(BPy_rgbTuple *self, int begin, int end,
|
||||||
|
PyObject *seq)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
@@ -372,10 +371,10 @@ static int rgbTupleAssSlice(C_rgbTuple *self, int begin, int end, PyObject *seq)
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: rgbTuplePrint */
|
/* Function: rgbTuplePrint */
|
||||||
/* Description: This is a callback function for the C_rgbTuple type. It */
|
/* Description: This is a callback function for the BPy_rgbTuple type. It */
|
||||||
/* builds a meaninful string to 'print' rgbTuple objects. */
|
/* builds a meaninful string to 'print' rgbTuple objects. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static int rgbTuplePrint(C_rgbTuple *self, FILE *fp, int flags)
|
static int rgbTuplePrint(BPy_rgbTuple *self, FILE *fp, int flags)
|
||||||
{
|
{
|
||||||
fprintf(fp, "[%f, %f, %f]",
|
fprintf(fp, "[%f, %f, %f]",
|
||||||
*(self->rgb[0]), *(self->rgb[1]), *(self->rgb[2]));
|
*(self->rgb[0]), *(self->rgb[1]), *(self->rgb[2]));
|
||||||
@@ -384,10 +383,10 @@ static int rgbTuplePrint(C_rgbTuple *self, FILE *fp, int flags)
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: rgbTupleRepr */
|
/* Function: rgbTupleRepr */
|
||||||
/* Description: This is a callback function for the C_rgbTuple type. It */
|
/* Description: This is a callback function for the BPy_rgbTuple type. It */
|
||||||
/* builds a meaninful string to represent rgbTuple objects. */
|
/* builds a meaninful string to represent rgbTuple objects. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *rgbTupleRepr (C_rgbTuple *self)
|
static PyObject *rgbTupleRepr (BPy_rgbTuple *self)
|
||||||
{
|
{
|
||||||
float r, g, b;
|
float r, g, b;
|
||||||
char buf[64];
|
char buf[64];
|
||||||
|
@@ -41,19 +41,19 @@
|
|||||||
* objects, so this header file must contain only 'public' declarations */
|
* objects, so this header file must contain only 'public' declarations */
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python C_rgbTuple structure definition: */
|
/* Python BPy_rgbTuple structure definition: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
float *rgb[3]; /* array of three pointers to floats */
|
float *rgb[3]; /* array of three pointers to floats */
|
||||||
|
|
||||||
} C_rgbTuple;
|
} BPy_rgbTuple;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python API function prototypes for the rgbTuple helper module. */
|
/* Python API function prototypes for the rgbTuple helper module. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *rgbTuple_New (float *rgb[3]);
|
PyObject *rgbTuple_New (float *rgb[3]);
|
||||||
PyObject *rgbTuple_getCol (C_rgbTuple *self);
|
PyObject *rgbTuple_getCol (BPy_rgbTuple *self);
|
||||||
PyObject *rgbTuple_setCol (C_rgbTuple *self, PyObject *args);
|
PyObject *rgbTuple_setCol (BPy_rgbTuple *self, PyObject *args);
|
||||||
|
|
||||||
#endif /* EXPP_rgbTuple_H */
|
#endif /* EXPP_rgbTuple_H */
|
||||||
|
Reference in New Issue
Block a user