118
119
static PyObject *Camera_oldgetClipEnd( BPy_Camera * self );
119
120
static PyObject *Camera_oldgetDrawSize( BPy_Camera * self );
120
121
static PyObject *Camera_oldgetScale( BPy_Camera * self );
122
static PyObject *Camera_getIpo( BPy_Camera * self );
123
static int Camera_setIpo( BPy_Camera * self, PyObject * value );
121
124
static PyObject *Camera_oldsetIpo( BPy_Camera * self, PyObject * args );
122
static PyObject *Camera_oldsetName( BPy_Camera * self, PyObject * args );
123
125
static PyObject *Camera_oldsetType( BPy_Camera * self, PyObject * args );
124
126
static PyObject *Camera_oldsetMode( BPy_Camera * self, PyObject * args );
125
127
static PyObject *Camera_oldsetLens( BPy_Camera * self, PyObject * args );
134
136
static PyObject *Camera_insertIpoKey( BPy_Camera * self, PyObject * args );
135
137
static PyObject *Camera_copy( BPy_Camera * self );
137
Camera *GetCameraByName( char *name );
140
140
/*****************************************************************************/
141
141
/* Python BPy_Camera methods table: */
142
142
/*****************************************************************************/
143
143
static PyMethodDef BPy_Camera_methods[] = {
144
144
/* name, method, flags, doc */
145
{"getIpo", ( PyCFunction ) Camera_oldgetIpo, METH_NOARGS,
145
{"getIpo", ( PyCFunction ) Camera_getIpo, METH_NOARGS,
146
146
"() - Return Camera Data Ipo"},
147
{"getName", ( PyCFunction ) Camera_oldgetName, METH_NOARGS,
147
{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
148
148
"() - Return Camera Data name"},
149
149
{"getType", ( PyCFunction ) Camera_oldgetType, METH_NOARGS,
150
150
"() - Return Camera type - 'persp':0, 'ortho':1"},
167
167
"() - Unlink Ipo from this Camera."},
168
168
{"insertIpoKey", ( PyCFunction ) Camera_insertIpoKey, METH_VARARGS,
169
169
"( Camera IPO type ) - Inserts a key into IPO"},
170
{"setName", ( PyCFunction ) Camera_oldsetName, METH_VARARGS,
170
{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
171
171
"(s) - Set Camera Data name"},
172
172
{"setType", ( PyCFunction ) Camera_oldsetType, METH_VARARGS,
173
173
"(s) - Set Camera type, which can be 'persp' or 'ortho'"},
197
197
"([s1<,s2,s3...>]) - Delete specified scriptlinks from this camera."},
198
198
{"__copy__", ( PyCFunction ) Camera_copy, METH_NOARGS,
199
199
"() - Return a copy of the camera."},
200
{"copy", ( PyCFunction ) Camera_copy, METH_NOARGS,
201
"() - Return a copy of the camera."},
200
202
{NULL, NULL, 0, NULL}
203
205
/*****************************************************************************/
204
206
/* Python Camera_Type callback function prototypes: */
205
207
/*****************************************************************************/
206
static void Camera_dealloc( BPy_Camera * self );
207
//static int Camera_setAttr( BPy_Camera * self, char *name, PyObject * v );
208
208
static int Camera_compare( BPy_Camera * a, BPy_Camera * b );
209
//static PyObject *Camera_getAttr( BPy_Camera * self, char *name );
210
209
static PyObject *Camera_repr( BPy_Camera * self );
213
//~ /*****************************************************************************/
214
//~ /* Python Camera_Type structure definition: */
215
//~ /*****************************************************************************/
216
//~ PyTypeObject Camera_Type = {
217
//~ PyObject_HEAD_INIT( NULL ) /* required macro */
218
//~ NULL, /* ob_size */
219
//~ "Blender Camera", /* tp_name */
220
//~ sizeof( BPy_Camera ), /* tp_basicsize */
221
//~ NULL, /* tp_itemsize */
223
//~ ( destructor ) Camera_dealloc, /* tp_dealloc */
224
//~ NULL, /* tp_print */
225
//~ NULL, /* tp_getattr */
226
//~ NULL, /* tp_setattr */
227
//~ ( cmpfunc ) Camera_compare, /* tp_compare */
228
//~ ( reprfunc ) Camera_repr, /* tp_repr */
229
//~ NULL, /* tp_as_number */
230
//~ NULL, /* tp_as_sequence */
231
//~ NULL, /* tp_as_mapping */
232
//~ NULL, /* tp_as_hash */
233
//~ 0, 0, 0, 0, 0, 0,
235
//~ 0, 0, 0, 0, 0, 0,
236
//~ BPy_Camera_methods, /* tp_methods */
237
//~ 0, /* tp_members */
238
//~ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
260
211
static PyObject *M_Camera_New( PyObject * self, PyObject * args,
261
212
PyObject * kwords )
263
214
char *type_str = "persp"; /* "persp" is type 0, "ortho" is type 1 */
264
char *name_str = "CamData";
215
char *name_str = "Camera";
265
216
static char *kwlist[] = { "type_str", "name_str", NULL };
266
217
PyObject *pycam; /* for Camera Data object wrapper in Python */
267
218
Camera *blcam; /* for actual Camera Data we create in Blender */
270
220
/* Parse the arguments passed in by the Python interpreter */
271
221
if( !PyArg_ParseTupleAndKeywords( args, kwords, "|ss", kwlist,
424
348
"couldn't create BPy_Camera PyObject" );
426
350
pycam->camera = cam;
428
351
return ( PyObject * ) pycam;
431
int Camera_CheckPyObject( PyObject * pyobj )
433
return ( pyobj->ob_type == &Camera_Type );
436
354
Camera *Camera_FromPyObject( PyObject * pyobj )
438
356
return ( ( BPy_Camera * ) pyobj )->camera;
441
359
/*****************************************************************************/
442
/* Description: Returns the object with the name specified by the argument */
443
/* name. Note that the calling function has to remove the first */
444
/* two characters of the object name. These two characters */
445
/* specify the type of the object (OB, ME, WO, ...) */
446
/* The function will return NULL when no object with the given */
448
/*****************************************************************************/
449
Camera *GetCameraByName( char *name )
453
cam_iter = G.main->camera.first;
455
if( StringEqual( name, GetIdName( &( cam_iter->id ) ) ) ) {
458
cam_iter = cam_iter->id.next;
461
/* There is no camera with the given name */
465
/*****************************************************************************/
466
360
/* Python BPy_Camera methods: */
467
361
/*****************************************************************************/
469
static PyObject *Camera_oldgetIpo( BPy_Camera * self )
471
struct Ipo *ipo = self->camera->ipo;
476
return Ipo_CreatePyObject( ipo );
480
static PyObject *Camera_oldgetName( BPy_Camera * self )
483
PyObject *attr = PyString_FromString( self->camera->id.name + 2 );
488
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
489
"couldn't get Camera.name attribute" );
492
363
static PyObject *Camera_oldgetType( BPy_Camera * self )
494
365
PyObject *attr = PyInt_FromLong( self->camera->type );
571
442
static PyObject *Camera_oldsetIpo( BPy_Camera * self, PyObject * args )
577
if( !PyArg_ParseTuple( args, "O!", &Ipo_Type, &pyipo ) )
578
return EXPP_ReturnPyObjError( PyExc_TypeError,
579
"expected Ipo as argument" );
581
ipo = Ipo_FromPyObject( pyipo );
584
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
587
if( ipo->blocktype != ID_CA )
588
return EXPP_ReturnPyObjError( PyExc_TypeError,
589
"this ipo is not a camera data ipo" );
591
oldipo = self->camera->ipo;
593
ID *id = &oldipo->id;
598
id_us_plus(&ipo->id);
600
self->camera->ipo = ipo;
444
return EXPP_setterWrapper( (void *)self, args, (setter)Camera_setIpo );
605
447
static PyObject *Camera_oldclearIpo( BPy_Camera * self )
619
461
return EXPP_incr_ret_False(); /* no ipo found */
622
static PyObject *Camera_oldsetName( BPy_Camera * self, PyObject * args )
626
if( !PyArg_ParseTuple( args, "s", &name ) )
627
return EXPP_ReturnPyObjError( PyExc_TypeError,
628
"expected string argument" );
630
rename_id( &self->camera->id, name );
635
464
static PyObject *Camera_oldsetType( BPy_Camera * self, PyObject * args )
828
static void Camera_dealloc( BPy_Camera * self )
830
PyObject_DEL( self );
833
static PyObject *Camera_getName( BPy_Camera * self )
835
return PyString_FromString( self->camera->id.name + 2 );
838
static int Camera_setName( BPy_Camera * self, PyObject * value )
842
name = PyString_AsString ( value );
844
return EXPP_ReturnIntError( PyExc_TypeError,
845
"expected string argument" );
847
rename_id( &self->camera->id, name);
852
static PyObject *Camera_getUsers( BPy_Camera * self )
854
return PyInt_FromLong( self->camera->id.us );
858
static PyObject *Camera_getFakeUser( BPy_Camera * self )
860
if (self->camera->id.flag & LIB_FAKEUSER)
866
static int Camera_setFakeUser( BPy_Camera * self, PyObject * value )
868
return SetIdFakeUser(&self->camera->id, value);
872
657
static PyObject *Camera_getType( BPy_Camera * self )
874
659
if (self->camera->type == EXPP_CAM_TYPE_PERSP)
930
715
static int Camera_setIpo( BPy_Camera * self, PyObject * value )
933
Ipo *oldipo = self->camera->ipo;
936
/* if parameter is not None, check for valid Ipo */
938
if ( value != Py_None ) {
939
if ( !Ipo_CheckPyObject( value ) )
940
return EXPP_ReturnIntError( PyExc_TypeError,
941
"expected an Ipo object" );
943
ipo = Ipo_FromPyObject( value );
946
return EXPP_ReturnIntError( PyExc_RuntimeError,
949
if( ipo->blocktype != ID_CA )
950
return EXPP_ReturnIntError( PyExc_TypeError,
951
"Ipo is not a camera data Ipo" );
954
/* if already linked to Ipo, delete link */
962
/* assign new Ipo and increment user count, or set to NULL if deleting */
964
self->camera->ipo = ipo;
966
id_us_plus(&ipo->id);
717
return GenericLib_assignData(value, (void **) &self->camera->ipo, 0, 1, ID_IP, ID_CA);
1115
877
/* Python attributes get/set structure: */
1116
878
/*****************************************************************************/
1117
879
static PyGetSetDef BPy_Camera_getseters[] = {
1119
(getter)Camera_getName, (setter)Camera_setName,
1123
(getter)Camera_getUsers, (setter)NULL,
1124
"Number of camera users",
1127
(getter)Camera_getFakeUser, (setter)Camera_setFakeUser,
1128
"Cameras fake user state",
880
GENERIC_LIB_GETSETATTR,
1131
882
(getter)Camera_getType, (setter)Camera_setType,
1132
883
"camera type \"persp\" or \"ortho\"",
1139
890
(getter)Camera_getIpo, (setter)Camera_setIpo,
1143
894
/* float settings */
1145
896
(getter)getFloatAttr, (setter)setFloatAttrClamp,
1146
897
"lens angle for perspective cameras",
1147
898
(void *)EXPP_CAM_ATTR_LENS},
900
(getter)getFloatAttr, (setter)setFloatAttrClamp,
901
"lens angle for perspective cameras",
902
(void *)EXPP_CAM_ATTR_ANGLE},
1149
905
(getter)getFloatAttr, (setter)setFloatAttrClamp,
1150
906
"scale for ortho cameras",
1157
913
(getter)getFloatAttr, (setter)setFloatAttrClamp,
1158
914
"the cameras clip end",
1159
915
(void *)EXPP_CAM_ATTR_CLIPEND},
917
(getter)getFloatAttr, (setter)setFloatAttrClamp,
918
"the cameras X perspective shift",
919
(void *)EXPP_CAM_ATTR_SHIFTX},
921
(getter)getFloatAttr, (setter)setFloatAttrClamp,
922
"the cameras Y perspective shift",
923
(void *)EXPP_CAM_ATTR_SHIFTY},
1161
925
(getter)getFloatAttr, (setter)setFloatAttrClamp,
1162
926
"cameras dof distance",
1191
955
(getter)getFlagAttr, (setter)setFlagAttr,
1192
956
"toggle the passPartOut display flag",
1193
957
(void *)CAM_SHOWPASSEPARTOUT},
1194
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
959
(getter)getFlagAttr, (setter)setFlagAttr,
960
"toggle the camera input unit flag",
961
(void *)CAM_ANGLETOGGLE},
962
{NULL,NULL,NULL,NULL} /* Sentinel */