Page MenuHome

blender_keyobject_patch_2005_05_26

Authored By
Pontus Lidman (pontus)
Nov 13 2013, 1:02 PM
Size
27 KB
Subscribers
None

blender_keyobject_patch_2005_05_26

diff -urN --exclude=CVS blenderorig/blender/source/blender/python/SConscript blendercvs/blender/source/blender/python/SConscript
--- blenderorig/blender/source/blender/python/SConscript 2005-05-23 21:03:08.000000000 +0200
+++ blendercvs/blender/source/blender/python/SConscript 2005-05-21 16:23:35.000000000 +0200
@@ -22,6 +22,7 @@
'api2_2x/EXPP_interface.c',
'api2_2x/Ipocurve.c',
'api2_2x/Ipo.c',
+ 'api2_2x/Key.c',
'api2_2x/Lamp.c',
'api2_2x/Lattice.c',
'api2_2x/Library.c',
diff -urN --exclude=CVS blenderorig/blender/source/blender/python/api2_2x/Blender.c blendercvs/blender/source/blender/python/api2_2x/Blender.c
--- blenderorig/blender/source/blender/python/api2_2x/Blender.c 2005-05-23 21:03:08.000000000 +0200
+++ blendercvs/blender/source/blender/python/api2_2x/Blender.c 2005-05-21 17:17:20.000000000 +0200
@@ -799,6 +799,7 @@
PyDict_SetItemString( dict, "World", World_Init( ) );
PyDict_SetItemString( dict, "Texture", Texture_Init( ) );
PyDict_SetItemString( dict, "NMesh", NMesh_Init( ) );
+ PyDict_SetItemString( dict, "Key", Key_Init( ) );
PyDict_SetItemString( dict, "Noise", Noise_Init( ) );
PyDict_SetItemString( dict, "Mathutils", Mathutils_Init( ) );
PyDict_SetItemString( dict, "Library", Library_Init( ) );
diff -urN --exclude=CVS blenderorig/blender/source/blender/python/api2_2x/Curve.c blendercvs/blender/source/blender/python/api2_2x/Curve.c
--- blenderorig/blender/source/blender/python/api2_2x/Curve.c 2005-05-23 21:01:05.000000000 +0200
+++ blendercvs/blender/source/blender/python/api2_2x/Curve.c 2005-05-26 20:57:37.000000000 +0200
@@ -48,7 +48,7 @@
#include "Material.h"
#include "Object.h"
#include "gen_utils.h"
-
+#include "Key.h"
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
@@ -106,6 +106,7 @@
static PyObject *Curve_getSize( BPy_Curve * self );
static PyObject *Curve_setSize( BPy_Curve * self, PyObject * args );
static PyObject *Curve_getNumCurves( BPy_Curve * self );
+static PyObject *Curve_getKey( BPy_Curve * self );
static PyObject *Curve_isNurb( BPy_Curve * self, PyObject * args );
static PyObject *Curve_isCyclic( BPy_Curve * self, PyObject * args);
static PyObject *Curve_getNumPoints( BPy_Curve * self, PyObject * args );
@@ -204,6 +205,8 @@
METH_NOARGS, "() - Gets curve size"},
{"setSize", ( PyCFunction ) Curve_setSize,
METH_VARARGS, "(3-tuple) - Sets curve size"},
+ {"getKey", ( PyCFunction ) Curve_getKey,
+ METH_VARARGS, "Get curve key"},
{"getNumCurves", ( PyCFunction ) Curve_getNumCurves,
METH_NOARGS, "() - Gets number of curves in Curve"},
{"isNurb", ( PyCFunction ) Curve_isNurb,
@@ -967,6 +970,13 @@
return Py_None;
}
+static PyObject *Curve_getKey( BPy_Curve * self )
+{
+
+ int i;
+ PyObject *keyObj = Key_CreatePyObject(self->curve->key);
+ return keyObj;
+}
/*
* Count the number of splines in a Curve Object
@@ -1464,6 +1474,8 @@
return Curve_getSize( self );
if( strcmp( name, "bevob" ) == 0 )
return Curve_getBevOb( self );
+ if( strcmp( name, "key" ) == 0 )
+ return Curve_getKey( self );
#if 0
if( strcmp( name, "numpts" ) == 0 )
return Curve_getNumPoints( self );
diff -urN --exclude=CVS blenderorig/blender/source/blender/python/api2_2x/Key.c blendercvs/blender/source/blender/python/api2_2x/Key.c
--- blenderorig/blender/source/blender/python/api2_2x/Key.c 1970-01-01 01:00:00.000000000 +0100
+++ blendercvs/blender/source/blender/python/api2_2x/Key.c 2005-05-26 21:42:36.000000000 +0200
@@ -0,0 +1,414 @@
+/*
+ * $Id$
+ *
+ * ***** 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): Pontus Lidman
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+#include <BLI_blenlib.h>
+
+#include "Key.h"
+#include "NMesh.h" /* we create NMesh.NMVert objects */
+#include "Ipo.h"
+#include "BezTriple.h"
+
+#include "constant.h"
+
+#define KEY_TYPE_MESH 0
+#define KEY_TYPE_CURVE 1
+#define KEY_TYPE_LATTICE 2
+
+/* macro from blenkernel/intern/key.c:98 */
+#define GS(a) (*((short *)(a)))
+
+static void Key_dealloc( PyObject * self );
+static PyObject *Key_getattr( PyObject * self, char *name );
+static void KeyBlock_dealloc( PyObject * self );
+static PyObject *KeyBlock_getattr( PyObject * self, char *name );
+static PyObject *Key_repr( BPy_Key * self );
+
+PyTypeObject Key_Type = {
+ PyObject_HEAD_INIT( NULL ) 0, /*ob_size */
+ "Blender Key", /*tp_name */
+ sizeof( BPy_Key ), /*tp_basicsize */
+ 0, /*tp_itemsize */
+ /* methods */
+ ( destructor ) Key_dealloc, /*tp_dealloc */
+ ( printfunc ) 0, /*tp_print */
+ ( getattrfunc ) Key_getattr, /*tp_getattr */
+ ( setattrfunc ) 0, /*tp_setattr */
+ 0, /*tp_compare*/
+ ( reprfunc ) Key_repr, /* tp_repr */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+};
+
+PyTypeObject KeyBlock_Type = {
+ PyObject_HEAD_INIT( NULL ) 0, /*ob_size */
+ "Blender KeyBlock", /*tp_name */
+ sizeof( BPy_KeyBlock ), /*tp_basicsize */
+ 0, /*tp_itemsize */
+ /* methods */
+ ( destructor ) KeyBlock_dealloc, /*tp_dealloc */
+ ( printfunc ) 0, /*tp_print */
+ ( getattrfunc ) KeyBlock_getattr, /*tp_getattr */
+ ( setattrfunc ) 0, /*tp_setattr */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+};
+
+static PyObject *Key_getBlocks( PyObject * self );
+static PyObject *Key_getType( PyObject * self );
+static PyObject *Key_getIpo( PyObject * self );
+static PyObject *Key_getValue( PyObject * self );
+
+static struct PyMethodDef Key_methods[] = {
+ { "getType", (PyCFunction) Key_getType, METH_NOARGS, "Get key type." },
+ { "getValue", (PyCFunction) Key_getValue, METH_NOARGS, "Get key value." },
+ { "getBlocks", (PyCFunction) Key_getBlocks, METH_NOARGS, "Get key blocks." },
+ { "getIpo", (PyCFunction) Key_getIpo, METH_NOARGS, "Get key Ipo." },
+ { 0, 0, 0, 0 }
+};
+
+static PyObject *KeyBlock_getData( PyObject * self );
+static PyObject *KeyBlock_getPos( PyObject * self );
+
+static struct PyMethodDef KeyBlock_methods[] = {
+ { "getPos", (PyCFunction) KeyBlock_getPos, METH_NOARGS, "Get keyblock position."},
+ { "getData", (PyCFunction) KeyBlock_getData, METH_NOARGS, "Get keyblock data." },
+ { 0, 0, 0, 0 }
+};
+
+static void Key_dealloc( PyObject * self )
+{
+ PyObject_DEL( self );
+}
+
+static PyObject *new_Key( Key * oldkey)
+{
+ BPy_Key *k = PyObject_NEW( BPy_Key, &Key_Type );
+
+ if( !oldkey ) {
+ k->key = 0;
+ } else {
+ k->key = oldkey;
+ }
+ return ( PyObject * ) k;
+}
+
+PyObject *Key_CreatePyObject( Key * k )
+{
+ BPy_Key *key = ( BPy_Key * ) new_Key( k );
+
+ return ( PyObject * ) key;
+}
+
+static PyObject *Key_getattr( PyObject * self, char *name )
+{
+ BPy_Key *k = ( BPy_Key * ) self;
+ if ( strcmp( name, "id" ) == 0 ) {
+ return PyString_FromString( k->key->id.name );
+ } else if ( strcmp( name, "type" ) == 0 ) {
+ return Key_getType(self);
+ } else if ( strcmp( name, "value" ) == 0 ) {
+ return Key_getValue(self);
+ } else if ( strcmp( name, "blocks" ) == 0 ) {
+ return Key_getBlocks(self);
+ } else if ( strcmp( name, "ipo" ) == 0 ) {
+ return Key_getIpo(self);
+ }
+ return Py_FindMethod( Key_methods, ( PyObject * ) self, name );
+
+}
+
+static PyObject *Key_repr( BPy_Key * self )
+{
+
+ return PyString_FromFormat( "[Key \"%s\"]",
+ self->key->id.name + 2 );
+}
+
+static PyObject *Key_getValue( PyObject * self )
+{
+ BPy_Key *k = ( BPy_Key * ) self;
+
+ return PyFloat_FromDouble( k->key->curval );
+}
+
+static PyObject *Key_getIpo( PyObject * self )
+{
+ BPy_Key *k = ( BPy_Key * ) self;
+ BPy_Ipo *new_ipo;
+
+ if (k->key->ipo) {
+ new_ipo = ( BPy_Ipo * ) PyObject_NEW( BPy_Ipo, &Ipo_Type );
+ new_ipo->ipo = k->key->ipo;
+ return (PyObject *) new_ipo;
+ } else {
+ return EXPP_incr_ret( Py_None );
+ }
+}
+
+static PyObject *Key_getType( PyObject * self )
+{
+ BPy_Key *k = ( BPy_Key * ) self;
+ int idcode;
+ int type = -1;
+
+ idcode = GS( k->key->from->name );
+
+ switch( idcode ) {
+ case ID_ME:
+ type = KEY_TYPE_MESH;
+ break;
+ case ID_CU:
+ type = KEY_TYPE_CURVE;
+ break;
+ case ID_LT:
+ type = KEY_TYPE_LATTICE;
+ break;
+ }
+
+ return PyInt_FromLong( type );
+}
+
+static PyObject *Key_getBlocks( PyObject * self )
+{
+ BPy_Key *k = ( BPy_Key * ) self;
+ Key *key = k->key;
+ KeyBlock *kb;
+ PyObject *keyblock_object;
+ PyObject *l = PyList_New( 0 );
+
+ for (kb = key->block.first; kb; kb = kb->next) {
+
+ keyblock_object = KeyBlock_CreatePyObject( kb, key );
+ PyList_Append( l, keyblock_object );
+ }
+
+ return l;
+}
+
+static void KeyBlock_dealloc( PyObject * self )
+{
+ PyObject_DEL( self );
+}
+
+static PyObject *new_KeyBlock( KeyBlock * oldkeyBlock, Key *parentKey)
+{
+ BPy_KeyBlock *kb = PyObject_NEW( BPy_KeyBlock, &KeyBlock_Type );
+
+ kb->key = parentKey;
+
+ if( !oldkeyBlock ) {
+ kb->keyblock = 0;
+ } else {
+ kb->keyblock = oldkeyBlock;
+ }
+ return ( PyObject * ) kb;
+}
+
+PyObject *KeyBlock_CreatePyObject( KeyBlock * kb, Key *parentKey )
+{
+ BPy_KeyBlock *keyBlock = ( BPy_KeyBlock * ) new_KeyBlock( kb, parentKey );
+
+ return ( PyObject * ) keyBlock;
+}
+
+static PyObject *KeyBlock_getattr( PyObject * self, char *name )
+{
+ if ( strcmp( name, "pos" ) == 0 ) {
+ return KeyBlock_getPos(self);
+ } else if ( strcmp( name, "data" ) == 0 ) {
+ return KeyBlock_getData(self);
+ } else if ( strcmp( name, "pos" ) == 0 ) {
+ return KeyBlock_getPos(self);
+ }
+ return Py_FindMethod( KeyBlock_methods, ( PyObject * ) self, name );
+}
+
+static PyObject *KeyBlock_getPos( PyObject * self )
+{
+ BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
+ return PyFloat_FromDouble( kb->keyblock->pos );
+}
+
+static PyObject *KeyBlock_getData( PyObject * self )
+{
+ /* If this is a mesh key, data is an array of MVert.
+ If lattice, data is an array of BPoint
+ If curve, data is an array of BezTriple */
+
+ BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
+ Key *key = kb->key;
+ char *datap;
+ int datasize;
+ int idcode;
+ int i;
+
+ PyObject *l = PyList_New( kb->keyblock->totelem );
+
+ idcode = GS( key->from->name );
+
+ if (!kb->keyblock->data) {
+ return EXPP_incr_ret( Py_None );
+ }
+
+ switch(idcode) {
+ case ID_ME:
+
+ datasize = sizeof(MVert);
+
+ for (i=0, datap = kb->keyblock->data; i<kb->keyblock->totelem; i++) {
+
+ BPy_NMVert *mv = PyObject_NEW( BPy_NMVert, &NMVert_Type );
+ MVert *vert = (MVert *) datap;
+
+ mv->co[0]=vert->co[0];
+ mv->co[1]=vert->co[1];
+ mv->co[2]=vert->co[2];
+ mv->no[0] = vert->no[0] / 32767.0;
+ mv->no[1] = vert->no[1] / 32767.0;
+ mv->no[2] = vert->no[2] / 32767.0;
+
+ mv->uvco[0] = mv->uvco[1] = mv->uvco[2] = 0.0;
+ mv->index = i;
+ mv->flag = 0;
+
+ PyList_SetItem(l, i, ( PyObject * ) mv);
+
+ datap += datasize;
+ }
+ break;
+
+ case ID_CU:
+
+ datasize = sizeof(BezTriple);
+
+ for (i=0, datap = kb->keyblock->data; i<kb->keyblock->totelem; i++) {
+
+ BezTriple *bt = (BezTriple *) datap;
+ PyObject *pybt = BezTriple_CreatePyObject( bt );
+
+ PyList_SetItem( l, i, pybt );
+
+ datap += datasize;
+ }
+ break;
+
+ case ID_LT:
+
+ datasize = sizeof(BPoint);
+
+ for (i=0, datap = kb->keyblock->data; i<kb->keyblock->totelem; i++) {
+ /* Lacking a python class for BPoint, use a list of four floats */
+ BPoint *bp = (BPoint *) datap;
+ PyObject *bpoint = PyList_New( 4 );
+
+ PyList_SetItem( bpoint, 0, PyFloat_FromDouble( bp->vec[0] ) );
+ PyList_SetItem( bpoint, 1, PyFloat_FromDouble( bp->vec[1] ) );
+ PyList_SetItem( bpoint, 2, PyFloat_FromDouble( bp->vec[2] ) );
+ PyList_SetItem( bpoint, 3, PyFloat_FromDouble( bp->vec[3] ) );
+
+ PyList_SetItem( l, i, bpoint );
+
+ datap += datasize;
+ }
+ break;
+ }
+
+ return l;
+}
+
+static PyObject *M_Key_Get( PyObject * self, PyObject * args )
+{
+ char *name = NULL;
+ Key *key_iter;
+ char error_msg[64];
+ int i;
+
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument (or nothing)" ) );
+
+ if ( name ) {
+ for (key_iter = G.main->key.first; key_iter; key_iter=key_iter->id.next) {
+ if (strcmp ( key_iter->id.name, name ) == 0 ) {
+ return Key_CreatePyObject( key_iter );
+
+ }
+ }
+
+ PyOS_snprintf( error_msg, sizeof( error_msg ),
+ "Key \"%s\" not found", name );
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_NameError, error_msg ) );
+
+ }
+
+ PyObject *keylist;
+
+ keylist = PyList_New( BLI_countlist( &( G.main->key ) ) );
+
+ for ( i=0, key_iter = G.main->key.first; key_iter; key_iter=key_iter->id.next, i++ ) {
+ PyList_SetItem(keylist, i, Key_CreatePyObject(key_iter));
+ }
+ return keylist;
+}
+
+
+struct PyMethodDef M_Key_methods[] = {
+ {"Get", M_Key_Get, METH_VARARGS, "Get a key or all key names"},
+ {NULL, NULL, 0, NULL}
+};
+
+PyObject *Key_Init( void )
+{
+ PyObject *submodule, *KeyTypes;
+
+ Key_Type.ob_type = &PyType_Type;
+ KeyBlock_Type.ob_type = &PyType_Type;
+
+ submodule =
+ Py_InitModule3( "Blender.Key", M_Key_methods, "Key module" );
+
+ KeyTypes = M_constant_New( );
+
+ constant_insert(( BPy_constant * ) KeyTypes, "TYPE_MESH", PyInt_FromLong(KEY_TYPE_MESH));
+ constant_insert(( BPy_constant * ) KeyTypes, "TYPE_CURVE", PyInt_FromLong(KEY_TYPE_CURVE));
+ constant_insert(( BPy_constant * ) KeyTypes, "TYPE_LATTICE", PyInt_FromLong(KEY_TYPE_LATTICE));
+
+ PyModule_AddObject( submodule, "KeyTypes", KeyTypes);
+
+ /*
+ PyModule_AddIntConstant( submodule, "TYPE_MESH", KEY_TYPE_MESH );
+ PyModule_AddIntConstant( submodule, "TYPE_CURVE", KEY_TYPE_CURVE );
+ PyModule_AddIntConstant( submodule, "TYPE_LATTICE", KEY_TYPE_LATTICE );
+ */
+ return submodule;
+}
diff -urN --exclude=CVS blenderorig/blender/source/blender/python/api2_2x/Key.h blendercvs/blender/source/blender/python/api2_2x/Key.h
--- blenderorig/blender/source/blender/python/api2_2x/Key.h 1970-01-01 01:00:00.000000000 +0100
+++ blendercvs/blender/source/blender/python/api2_2x/Key.h 2005-05-21 20:18:50.000000000 +0200
@@ -0,0 +1,69 @@
+/*
+ * $Id$
+ *
+ * ***** 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): Pontus Lidman
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+#ifndef EXPP_KEY_H
+#define EXPP_KEY_H
+
+#include "Python.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <DNA_key_types.h>
+#include <DNA_curve_types.h>
+
+extern PyTypeObject Key_Type;
+extern PyTypeObject KeyBlock_Type;
+
+typedef struct {
+ PyObject_HEAD /* required python macro */
+ Key * key;
+ // Object *object; /* for vertex grouping info, since it's stored on the object */
+ //PyObject *keyBlock;
+ PyObject *ipo;
+} BPy_Key;
+
+typedef struct {
+ PyObject_HEAD /* required python macro */
+ Key *key;
+ KeyBlock * keyblock;
+ // Object *object; /* for vertex grouping info, since it's stored on the object */
+} BPy_KeyBlock;
+
+PyObject *Key_CreatePyObject( Key * k );
+PyObject *KeyBlock_CreatePyObject( KeyBlock * k, Key *parentKey );
+
+PyObject *Key_Init( void );
+
+
+#endif /* EXPP_KEY_H */
diff -urN --exclude=CVS blenderorig/blender/source/blender/python/api2_2x/Lattice.c blendercvs/blender/source/blender/python/api2_2x/Lattice.c
--- blenderorig/blender/source/blender/python/api2_2x/Lattice.c 2005-05-23 21:03:08.000000000 +0200
+++ blendercvs/blender/source/blender/python/api2_2x/Lattice.c 2005-05-23 20:55:47.000000000 +0200
@@ -31,7 +31,7 @@
*/
#include "Lattice.h"
-
+#include "Key.h"
#include <BKE_main.h>
#include <BKE_global.h>
@@ -92,6 +92,7 @@
static PyObject *Lattice_getPartitions( BPy_Lattice * self, PyObject * args );
static PyObject *Lattice_setKeyTypes( BPy_Lattice * self, PyObject * args );
static PyObject *Lattice_getKeyTypes( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_getKey( BPy_Lattice * self, PyObject * args );
static PyObject *Lattice_setMode( BPy_Lattice * self, PyObject * args );
static PyObject *Lattice_getMode( BPy_Lattice * self, PyObject * args );
static PyObject *Lattice_setPoint( BPy_Lattice * self, PyObject * args );
@@ -121,6 +122,9 @@
static char Lattice_getKeyTypes_doc[] =
"(str) - Get the key types for x,y,z dimensions";
+static char Lattice_getKey_doc[] =
+ "Get the Key object attached to this lattice.";
+
static char Lattice_setMode_doc[] = "(str) - Make an outside or grid lattice";
static char Lattice_getMode_doc[] = "(str) - Get lattice mode type";
@@ -159,6 +163,8 @@
Lattice_setKeyTypes_doc},
{"getKeyTypes", ( PyCFunction ) Lattice_getKeyTypes, METH_NOARGS,
Lattice_getKeyTypes_doc},
+ {"getKey", ( PyCFunction ) Lattice_getKey, METH_NOARGS,
+ Lattice_getKey_doc},
{"setMode", ( PyCFunction ) Lattice_setMode, METH_VARARGS,
Lattice_setMode_doc},
{"getMode", ( PyCFunction ) Lattice_getMode, METH_NOARGS,
@@ -444,6 +450,17 @@
( int ) bl_Lattice->pntsw );
}
+static PyObject *Lattice_getKey( BPy_Lattice * self, PyObject * args )
+{
+ Key *key = self->Lattice->key;
+ if (key)
+ return Key_CreatePyObject(key);
+ else {
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
+}
+
static PyObject *Lattice_getKeyTypes( BPy_Lattice * self, PyObject * args )
{
Lattice *bl_Lattice;
@@ -826,12 +843,14 @@
} else if( strcmp( name, "users" ) == 0 ) {
attr = PyInt_FromLong( self->Lattice->id.us );
- } else if( strcmp( name, "__members__" ) == 0 )
+ } else if( strcmp( name, "__members__" ) == 0 ) {
attr = Py_BuildValue( "[s,s,s,s,s,s,s,s,s]", "name", "width",
"height", "depth", "widthType",
"heightType", "depthType", "mode",
"latSize", "users" );
-
+ } else if ( strcmp( name, "key" ) == 0 ) {
+ return Lattice_getKey( self, 0 );
+ }
if( !attr )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create PyObject" ) );
diff -urN --exclude=CVS blenderorig/blender/source/blender/python/api2_2x/NMesh.c blendercvs/blender/source/blender/python/api2_2x/NMesh.c
--- blenderorig/blender/source/blender/python/api2_2x/NMesh.c 2005-05-23 21:03:09.000000000 +0200
+++ blendercvs/blender/source/blender/python/api2_2x/NMesh.c 2005-05-26 21:19:25.000000000 +0200
@@ -63,6 +63,8 @@
#include "mydevice.h"
#include "Object.h"
+#include "Key.h"
+
#include "vector.h"
#include "constant.h"
#include "gen_utils.h"
@@ -112,6 +114,9 @@
static char NMesh_printDebug_doc[] =
"print debug info about the mesh.";
+static char NMesh_getKey_doc[] =
+ "get mesh key.";
+
static char NMesh_addEdge_doc[] =
"create an edge between two vertices.\n\
If an edge already exists between those vertices, it is returned.\n\
@@ -1107,6 +1112,20 @@
return EXPP_incr_ret( Py_None );
}
+static PyObject *NMesh_getKey( BPy_NMesh * self )
+{
+ PyObject *key_object;
+
+ key_object = Key_CreatePyObject(self->mesh->key);
+
+ if( key_object == NULL ) {
+ Py_INCREF( Py_None );
+ return ( Py_None );
+ } else {
+ return ( key_object );
+ }
+}
+
static PyObject *NMesh_removeAllKeys( PyObject * self, PyObject * args )
{
BPy_NMesh *nm = ( BPy_NMesh * ) self;
@@ -1598,6 +1617,7 @@
MethodDef( getVertGroupNames ),
MethodDef( getActiveFace ),
MethodDef( getMode ),
+ MethodDef( getKey ),
MethodDef( getMaxSmoothAngle ),
MethodDef( getSubDivLevels ),
@@ -1630,6 +1650,9 @@
else if( strcmp( name, "verts" ) == 0 )
return EXPP_incr_ret( me->verts );
+ else if ( strcmp( name, "key" ) == 0 )
+ return NMesh_getKey( self );
+
else if( strcmp( name, "maxSmoothAngle" ) == 0 )
return PyInt_FromLong( me->smoothresh );
diff -urN --exclude=CVS blenderorig/blender/source/blender/python/api2_2x/doc/Curve.py blendercvs/blender/source/blender/python/api2_2x/doc/Curve.py
--- blenderorig/blender/source/blender/python/api2_2x/doc/Curve.py 2005-05-23 21:00:50.000000000 +0200
+++ blendercvs/blender/source/blender/python/api2_2x/doc/Curve.py 2005-05-26 21:03:55.000000000 +0200
@@ -74,6 +74,7 @@
@cvar rot: The Curve Data rotation(from the center).
@cvar size: The Curve Data size(from the center).
@cvar bevob: The Curve Bevel Object
+ @cvar key: The L{Key.Key} object associated with this curve, if any.
"""
def getName():
@@ -368,6 +369,13 @@
@raise AttributeError: throws exception if curve_num is out of range.
"""
+ def getKey():
+ """
+ Return the L{Key.Key} object containing the keyframes for this
+ curve, if any.
+ @rtype: L{Key.Key} object
+ """
+
class CurNurb:
"""
The CurNurb Object
diff -urN --exclude=CVS blenderorig/blender/source/blender/python/api2_2x/doc/Key.py blendercvs/blender/source/blender/python/api2_2x/doc/Key.py
--- blenderorig/blender/source/blender/python/api2_2x/doc/Key.py 1970-01-01 01:00:00.000000000 +0100
+++ blendercvs/blender/source/blender/python/api2_2x/doc/Key.py 2005-05-26 21:50:43.000000000 +0200
@@ -0,0 +1,94 @@
+# Blender.Key module and the Key and KeyBlock PyType objects
+
+"""
+The Blender.Key submodule.
+
+This module provides access to B{Key} objects in Blender.
+
+@type KeyTypes: readonly dictionary
+@var KeyTypes: The type of a key, indicating the type of data in the
+data blocks.
+ - TYPE_MESH - the key is a Mesh key; data blocks contain
+ L{NMesh.NMVert} vertices.
+ - TYPE_CURVE - the key is a Curve key; data blocks contain
+ L{Ipo.BezTriple} points.
+ - TYPE_LATTICE - the key is a Lattice key; data blocks contain
+ BPoints, each point represented as a list of 4 floating point numbers.
+
+"""
+
+def Get(name = None):
+ """
+ Get the named Key object from Blender. If the name is omitted, it
+ will retrieve a list of all keys in Blender.
+ @type name: string
+ @param name: the name of the requested key
+ @return: If name was given, return that Key object (or None if not
+ found). If a name was not given, return a list of every Key object
+ in Blender.
+ """
+
+class Key:
+ """
+ The Key object
+ ==============
+ An object with keyframes (L{Lattice.Lattice}, L{NMesh.NMesh} or
+ L{Curve.Curve}) will contain a Key object representing the
+ keyframe data.
+ @cvar blocks: A list of KeyBlocks.
+ @cvar ipo: The L{Ipo.Ipo} object associated with this key.
+ @cvar type: An integer from the L{KeyTypes} dictionary
+ representing the Key type.
+ """
+
+ def getType():
+ """
+ Get the type of this Key object. It will be one of the
+ integers defined in the L{KeyTypes} dictionary.
+ """
+ def getIpo():
+ """
+ Get the L{Ipo.Ipo} object associated with this key.
+ """
+ def getBlocks():
+ """
+ Get a list of L{KeyBlock}s, containing the keyframes defined for
+ this Key.
+ """
+
+class KeyBlock:
+ """
+ The KeyBlock object
+ ===================
+ Each Key object has a list of KeyBlocks attached, each KeyBlock
+ representing a keyframe.
+
+ @cvar data: The data of the KeyBlock (see L{getData}). This
+ attribute is read-only.
+ @cvar pos: The position of the keyframe (see L{getPos}). This
+ attribute is read-only.
+ """
+ def getData():
+ """
+ Get the data of a KeyBlock, as a list of data items. Each item
+ will have a different data type depending on the type of this
+ Key.
+
+ Mesh keys have a list of L{NMesh.NMVert} objects in the data
+ block.
+
+ Lattice keys have a list of BPoints in the data block. These
+ don't have corresponding Python objects yet, so each BPoint is
+ represented using a list of four floating-point numbers.
+
+ Curve keys have a list of L{Ipo.BezTriple} objects in the data
+ block.
+ """
+
+ def getPos():
+ """
+ Get the position of the keyframe represented by this KeyBlock,
+ normally between 0.0 and 1.0. The time point when the Speed
+ Ipo intersects the KeyBlock position is the actual time of the
+ keyframe.
+ """
diff -urN --exclude=CVS blenderorig/blender/source/blender/python/api2_2x/doc/Lattice.py blendercvs/blender/source/blender/python/api2_2x/doc/Lattice.py
--- blenderorig/blender/source/blender/python/api2_2x/doc/Lattice.py 2005-05-23 21:00:52.000000000 +0200
+++ blendercvs/blender/source/blender/python/api2_2x/doc/Lattice.py 2005-05-26 21:53:28.000000000 +0200
@@ -76,6 +76,7 @@
@cvar depthType: The z dimension key type.
@cvar mode: The current mode of the Lattice.
@cvar latSize: The number of points in this Lattice.
+ @cvar key: The L{Key.Key} object attached to this Lattice.
"""
def getName():
@@ -120,6 +121,13 @@
@return: A list corresponding to the key types will be returned: [x,y,z]
"""
+ def getKey():
+ """
+ Returns the L{Key.Key} object associated with this Lattice.
+ @rtype: L{Key.Key}
+ @return: A key object representing the keyframes of the lattice is returned.
+ """
+
def setKeyTypes(xType,yType,zType):
"""
Sets the deformation key types for the x, y, and z dimensions of the
diff -urN --exclude=CVS blenderorig/blender/source/blender/python/api2_2x/doc/NMesh.py blendercvs/blender/source/blender/python/api2_2x/doc/NMesh.py
--- blenderorig/blender/source/blender/python/api2_2x/doc/NMesh.py 2005-05-23 21:03:10.000000000 +0200
+++ blendercvs/blender/source/blender/python/api2_2x/doc/NMesh.py 2005-05-26 21:54:04.000000000 +0200
@@ -351,6 +351,7 @@
@cvar mode: The mode flags for this mesh. See L{setMode}.
@cvar subDivLevels: The [display, rendering] subdivision levels in [1, 6].
@cvar maxSmoothAngle: The max angle for auto smoothing. See L{setMode}.
+ @cvar key: The L{Key.Key} object attached to this mesh.
"""
def addEdge(v1, v2):
@@ -559,6 +560,13 @@
add them.
"""
+ def getKey():
+ """
+ Get the Key object representing the Vertex Keys (absolute or
+ relative) assigned to this mesh.
+ @rtype: L{Key.Key} object
+ """
+
def update(recalc_normals = 0, store_edges = 0, vertex_shade = 0):
"""
Update the mesh in Blender. The changes made are put back to the mesh in
diff -urN --exclude=CVS blenderorig/blender/source/blender/python/api2_2x/modules.h blendercvs/blender/source/blender/python/api2_2x/modules.h
--- blenderorig/blender/source/blender/python/api2_2x/modules.h 2005-05-23 21:03:09.000000000 +0200
+++ blendercvs/blender/source/blender/python/api2_2x/modules.h 2005-05-21 17:17:57.000000000 +0200
@@ -54,6 +54,7 @@
#include "Effect.h"
#include "Ipo.h"
#include "Ipocurve.h"
+#include "Key.h"
#include "Lamp.h"
#include "Lattice.h"
/* #include "Library.h" */

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
15/fb/13630965677eff955266d6886adc

Event Timeline