| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | /* 
 | 
					
						
							| 
									
										
										
										
											2004-09-18 18:47:03 +00:00
										 |  |  |  * $Id$ | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ***** 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, | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  |  * Inc., 59 Temple Place - Suite 330, Boston, MA	02111-1307, USA. | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This is a new part of Blender. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-04-21 19:44:52 +00:00
										 |  |  |  * Contributor(s): Willian P. Germano, Johnny Matthews, Ken Hughes | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL/BL DUAL LICENSE BLOCK ***** | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-07-18 03:50:37 +00:00
										 |  |  | #include "Camera.h" /*This must come first */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "BKE_main.h"
 | 
					
						
							|  |  |  | #include "BKE_global.h"
 | 
					
						
							|  |  |  | #include "BKE_object.h"
 | 
					
						
							|  |  |  | #include "BKE_library.h"
 | 
					
						
							|  |  |  | #include "BLI_blenlib.h"
 | 
					
						
							|  |  |  | #include "BSE_editipo.h"
 | 
					
						
							|  |  |  | #include "BIF_space.h"
 | 
					
						
							|  |  |  | #include "mydevice.h"
 | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | #include "gen_utils.h"
 | 
					
						
							| 
									
										
										
										
											2004-10-07 19:25:40 +00:00
										 |  |  | #include "Ipo.h"
 | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-27 13:28:49 +00:00
										 |  |  | #define IPOKEY_LENS 0
 | 
					
						
							|  |  |  | #define IPOKEY_CLIPPING 1
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-05 16:21:44 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | /* Python API function prototypes for the Camera module.                     */ | 
					
						
							| 
									
										
										
										
											2003-06-05 16:21:44 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *M_Camera_New( PyObject * self, PyObject * args, | 
					
						
							|  |  |  | 			       PyObject * keywords ); | 
					
						
							|  |  |  | static PyObject *M_Camera_Get( PyObject * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* 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\ | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  |   c.scale = 6.0                # set scale value\n\ | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  |   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[] = | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	"Camera.New (type = 'persp', name = 'CamData'):\n\
 | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  |         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[] = { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{"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} | 
					
						
							| 
									
										
										
										
											2003-06-05 16:21:44 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python BPy_Camera methods declarations:                                   */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_getIpo( BPy_Camera * self ); | 
					
						
							|  |  |  | 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 ); | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | static PyObject *Camera_getScale( BPy_Camera * self ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_setIpo( BPy_Camera * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Camera_clearIpo( 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 ); | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | static PyObject *Camera_setScale( BPy_Camera * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_getScriptLinks( BPy_Camera * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Camera_addScriptLink( BPy_Camera * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2005-04-21 19:44:52 +00:00
										 |  |  | static PyObject *Camera_clearScriptLinks( BPy_Camera * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2005-03-27 13:28:49 +00:00
										 |  |  | static PyObject *Camera_insertIpoKey( BPy_Camera * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-09 19:45:59 +00:00
										 |  |  | Camera *GetCameraByName( char *name ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python BPy_Camera methods table:                                          */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | static PyMethodDef BPy_Camera_methods[] = { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	/* name, method, flags, doc */ | 
					
						
							|  |  |  | 	{"getIpo", ( PyCFunction ) Camera_getIpo, METH_NOARGS, | 
					
						
							|  |  |  | 	 "() - Return Camera Data Ipo"}, | 
					
						
							|  |  |  | 	{"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, | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | 	 "() - Return *perspective* Camera lens value"}, | 
					
						
							|  |  |  | 	{"getScale", ( PyCFunction ) Camera_getScale, METH_NOARGS, | 
					
						
							|  |  |  | 	 "() - Return *ortho* Camera scale value"}, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{"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"}, | 
					
						
							|  |  |  | 	{"setIpo", ( PyCFunction ) Camera_setIpo, METH_VARARGS, | 
					
						
							|  |  |  | 	 "(Blender Ipo) - Set Camera Ipo"}, | 
					
						
							|  |  |  | 	{"clearIpo", ( PyCFunction ) Camera_clearIpo, METH_NOARGS, | 
					
						
							|  |  |  | 	 "() - Unlink Ipo from this Camera."}, | 
					
						
							| 
									
										
										
										
											2005-03-27 13:28:49 +00:00
										 |  |  | 	 {"insertIpoKey", ( PyCFunction ) Camera_insertIpoKey, METH_VARARGS, | 
					
						
							|  |  |  | 	 "( Camera IPO type ) - Inserts a key into IPO"}, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{"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, | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | 	 "(f) - Set *perpective* Camera lens value"}, | 
					
						
							|  |  |  | 	{"setScale", ( PyCFunction ) Camera_setScale, METH_VARARGS, | 
					
						
							|  |  |  | 	 "(f) - Set *ortho* Camera scale value"}, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{"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"}, | 
					
						
							|  |  |  | 	{"getScriptLinks", ( PyCFunction ) Camera_getScriptLinks, METH_VARARGS, | 
					
						
							|  |  |  | 	 "(eventname) - Get a list of this camera's scriptlinks (Text names) " | 
					
						
							|  |  |  | 	 "of the given type\n" | 
					
						
							| 
									
										
										
										
											2005-05-27 05:39:41 +00:00
										 |  |  | 	 "(eventname) - string: FrameChanged, Redraw or Render."}, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{"addScriptLink", ( PyCFunction ) Camera_addScriptLink, METH_VARARGS, | 
					
						
							|  |  |  | 	 "(text, evt) - Add a new camera scriptlink.\n" | 
					
						
							|  |  |  | 	 "(text) - string: an existing Blender Text name;\n" | 
					
						
							| 
									
										
										
										
											2005-05-27 05:39:41 +00:00
										 |  |  | 	 "(evt) string: FrameChanged, Redraw or Render."}, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{"clearScriptLinks", ( PyCFunction ) Camera_clearScriptLinks, | 
					
						
							|  |  |  | 	 METH_NOARGS, | 
					
						
							| 
									
										
										
										
											2005-04-21 19:44:52 +00:00
										 |  |  | 	 "() - Delete all scriptlinks from this camera.\n" | 
					
						
							|  |  |  | 	 "([s1<,s2,s3...>]) - Delete specified scriptlinks from this camera."}, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{NULL, NULL, 0, NULL} | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python Camera_Type callback function prototypes:                          */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static void Camera_dealloc( BPy_Camera * self ); | 
					
						
							|  |  |  | 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 ); | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | /* Python Camera_Type structure definition:	                             */ | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | PyTypeObject Camera_Type = { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyObject_HEAD_INIT( NULL ) /* required macro */  | 
					
						
							|  |  |  | 	0,	/* ob_size */ | 
					
						
							|  |  |  | 	"Blender Camera",	/* tp_name */ | 
					
						
							|  |  |  | 	sizeof( BPy_Camera ),	/* tp_basicsize */ | 
					
						
							|  |  |  | 	0,			/* tp_itemsize */ | 
					
						
							|  |  |  | 	/* methods */ | 
					
						
							|  |  |  | 	( destructor ) Camera_dealloc,	/* tp_dealloc */ | 
					
						
							|  |  |  | 	0,			/* tp_print */ | 
					
						
							|  |  |  | 	( getattrfunc ) Camera_getAttr,	/* tp_getattr */ | 
					
						
							|  |  |  | 	( setattrfunc ) Camera_setAttr,	/* tp_setattr */ | 
					
						
							|  |  |  | 	( cmpfunc ) Camera_compare,	/* tp_compare */ | 
					
						
							|  |  |  | 	( reprfunc ) Camera_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_Camera_methods,	/* tp_methods */ | 
					
						
							|  |  |  | 	0,			/* tp_members */ | 
					
						
							| 
									
										
										
										
											2005-02-09 15:53:35 +00:00
										 |  |  | 	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *M_Camera_New( PyObject * self, PyObject * args, | 
					
						
							|  |  |  | 			       PyObject * kwords ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *type_str = "persp";	/* "persp" is type 0, "ortho" is type 1 */ | 
					
						
							|  |  |  | 	char *name_str = "CamData"; | 
					
						
							|  |  |  | 	static char *kwlist[] = { "type_str", "name_str", NULL }; | 
					
						
							|  |  |  | 	PyObject *pycam;	/* for Camera Data object wrapper in Python */ | 
					
						
							|  |  |  | 	Camera *blcam;		/* for actual Camera Data we create in Blender */ | 
					
						
							|  |  |  | 	char buf[21]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Parse the arguments passed in by the Python interpreter */ | 
					
						
							|  |  |  | 	if( !PyArg_ParseTupleAndKeywords( args, kwords, "|ss", kwlist, | 
					
						
							|  |  |  | 					  &type_str, &name_str ) ) | 
					
						
							|  |  |  | 		/* We expected string(s) (or nothing) as argument, but we didn't get that. */ | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 					      "expected zero, one or two strings as arguments" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	blcam = add_camera(  );	/* first create the Camera Data in Blender */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( blcam )		/* now create the wrapper obj in Python */ | 
					
						
							|  |  |  | 		pycam = Camera_CreatePyObject( blcam ); | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 					      "couldn't create Camera Data in Blender" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* let's return user count to zero, because ... */ | 
					
						
							|  |  |  | 	blcam->id.us = 0;	/* ... add_camera() incref'ed it */ | 
					
						
							|  |  |  | 	/* XXX XXX Do this in other modules, too */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( pycam == NULL ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_MemoryError, | 
					
						
							|  |  |  | 					      "couldn't create Camera PyObject" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( strcmp( type_str, "persp" ) == 0 ) | 
					
						
							|  |  |  | 		/* default, no need to set, so */ | 
					
						
							|  |  |  | 		/*blcam->type = (short)EXPP_CAM_TYPE_PERSP */ | 
					
						
							|  |  |  | 		; | 
					
						
							|  |  |  | 	/* we comment this line */ | 
					
						
							|  |  |  | 	else if( strcmp( type_str, "ortho" ) == 0 ) | 
					
						
							|  |  |  | 		blcam->type = ( short ) EXPP_CAM_TYPE_ORTHO; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 					      "unknown camera type" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( strcmp( name_str, "CamData" ) == 0 ) | 
					
						
							|  |  |  | 		return pycam; | 
					
						
							|  |  |  | 	else {			/* user gave us a name for the camera, use it */ | 
					
						
							|  |  |  | 		PyOS_snprintf( buf, sizeof( buf ), "%s", name_str ); | 
					
						
							|  |  |  | 		rename_id( &blcam->id, buf );	/* proper way in Blender */ | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return pycam; | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *M_Camera_Get( PyObject * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	char *name = NULL; | 
					
						
							|  |  |  | 	Camera *cam_iter; | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !PyArg_ParseTuple( args, "|s", &name ) ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "expected string argument (or nothing)" ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	cam_iter = G.main->camera.first; | 
					
						
							| 
									
										
										
										
											2003-05-13 01:54:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( name ) {		/* (name) - Search camera by name */ | 
					
						
							| 
									
										
										
										
											2003-06-12 04:51:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		PyObject *wanted_cam = NULL; | 
					
						
							| 
									
										
										
										
											2003-06-12 04:51:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		while( cam_iter && !wanted_cam ) { | 
					
						
							| 
									
										
										
										
											2003-05-08 03:06:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 			if( strcmp( name, cam_iter->id.name + 2 ) == 0 ) { | 
					
						
							|  |  |  | 				wanted_cam = Camera_CreatePyObject( cam_iter ); | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2003-05-08 03:06:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 			cam_iter = cam_iter->id.next; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		if( !wanted_cam ) {	/* Requested camera doesn't exist */ | 
					
						
							|  |  |  | 			char error_msg[64]; | 
					
						
							|  |  |  | 			PyOS_snprintf( error_msg, sizeof( error_msg ), | 
					
						
							|  |  |  | 				       "Camera \"%s\" not found", name ); | 
					
						
							|  |  |  | 			return EXPP_ReturnPyObjError( PyExc_NameError, | 
					
						
							|  |  |  | 						      error_msg ); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return wanted_cam; | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-05-13 01:54:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	else {			/* () - return a list of wrappers for all cameras in the scene */ | 
					
						
							|  |  |  | 		int index = 0; | 
					
						
							|  |  |  | 		PyObject *cam_pylist, *pyobj; | 
					
						
							| 
									
										
										
										
											2003-05-13 01:54:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		cam_pylist = | 
					
						
							|  |  |  | 			PyList_New( BLI_countlist( &( G.main->camera ) ) ); | 
					
						
							| 
									
										
										
										
											2003-05-13 01:54:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		if( !cam_pylist ) | 
					
						
							|  |  |  | 			return EXPP_ReturnPyObjError( PyExc_MemoryError, | 
					
						
							|  |  |  | 						      "couldn't create PyList" ); | 
					
						
							| 
									
										
										
										
											2003-05-13 01:54:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		while( cam_iter ) { | 
					
						
							|  |  |  | 			pyobj = Camera_CreatePyObject( cam_iter ); | 
					
						
							| 
									
										
										
										
											2003-05-13 01:54:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 			if( !pyobj ) | 
					
						
							|  |  |  | 				return EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 					( PyExc_MemoryError, | 
					
						
							|  |  |  | 					  "couldn't create Camera PyObject" ); | 
					
						
							| 
									
										
										
										
											2003-05-13 01:54:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 			PyList_SET_ITEM( cam_pylist, index, pyobj ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 			cam_iter = cam_iter->id.next; | 
					
						
							|  |  |  | 			index++; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-05-13 01:54:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		return cam_pylist; | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-06-12 04:51:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | PyObject *Camera_Init( void ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyObject *submodule; | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Camera_Type.ob_type = &PyType_Type; | 
					
						
							| 
									
										
										
										
											2003-06-02 20:15:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	submodule = Py_InitModule3( "Blender.Camera", | 
					
						
							|  |  |  | 				    M_Camera_methods, M_Camera_doc ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-27 13:28:49 +00:00
										 |  |  | 	PyModule_AddIntConstant( submodule, "LENS",     IPOKEY_LENS ); | 
					
						
							|  |  |  | 	PyModule_AddIntConstant( submodule, "CLIPPING", IPOKEY_CLIPPING ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return submodule; | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-05-20 03:56:41 +00:00
										 |  |  | /* Three Python Camera_Type helper functions needed by the Object module: */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | PyObject *Camera_CreatePyObject( Camera * cam ) | 
					
						
							| 
									
										
										
										
											2003-05-20 03:56:41 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	BPy_Camera *pycam; | 
					
						
							| 
									
										
										
										
											2003-05-20 03:56:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	pycam = ( BPy_Camera * ) PyObject_NEW( BPy_Camera, &Camera_Type ); | 
					
						
							| 
									
										
										
										
											2003-05-20 03:56:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !pycam ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_MemoryError, | 
					
						
							|  |  |  | 					      "couldn't create BPy_Camera PyObject" ); | 
					
						
							| 
									
										
										
										
											2003-05-20 03:56:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	pycam->camera = cam; | 
					
						
							| 
									
										
										
										
											2003-05-20 03:56:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return ( PyObject * ) pycam; | 
					
						
							| 
									
										
										
										
											2003-05-20 03:56:41 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | int Camera_CheckPyObject( PyObject * pyobj ) | 
					
						
							| 
									
										
										
										
											2003-05-20 03:56:41 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return ( pyobj->ob_type == &Camera_Type ); | 
					
						
							| 
									
										
										
										
											2003-05-20 03:56:41 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | Camera *Camera_FromPyObject( PyObject * pyobj ) | 
					
						
							| 
									
										
										
										
											2003-05-20 03:56:41 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return ( ( BPy_Camera * ) pyobj )->camera; | 
					
						
							| 
									
										
										
										
											2003-05-20 03:56:41 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-07-27 15:56:32 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | /* Description: Returns the object with the name specified by the argument  */ | 
					
						
							|  |  |  | /*	name. Note that the calling function has to remove the first */ | 
					
						
							|  |  |  | /*	two characters of the object name. These two characters		 */ | 
					
						
							|  |  |  | /*	specify the type of the object (OB, ME, WO, ...)		 */ | 
					
						
							|  |  |  | /*	The function will return NULL when no object with the given  */ | 
					
						
							|  |  |  | /*	name is found.							    */ | 
					
						
							| 
									
										
										
										
											2003-07-27 15:56:32 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | Camera *GetCameraByName( char *name ) | 
					
						
							| 
									
										
										
										
											2003-07-27 15:56:32 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Camera *cam_iter; | 
					
						
							| 
									
										
										
										
											2003-07-27 15:56:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	cam_iter = G.main->camera.first; | 
					
						
							|  |  |  | 	while( cam_iter ) { | 
					
						
							|  |  |  | 		if( StringEqual( name, GetIdName( &( cam_iter->id ) ) ) ) { | 
					
						
							|  |  |  | 			return ( cam_iter ); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		cam_iter = cam_iter->id.next; | 
					
						
							| 
									
										
										
										
											2003-07-27 15:56:32 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	/* There is no camera with the given name */ | 
					
						
							|  |  |  | 	return ( NULL ); | 
					
						
							| 
									
										
										
										
											2003-07-27 15:56:32 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | /* Python BPy_Camera methods:                                               */ | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-26 16:51:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_getIpo( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2003-10-26 16:51:53 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	struct Ipo *ipo = self->camera->ipo; | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !ipo ) { | 
					
						
							|  |  |  | 		Py_INCREF( Py_None ); | 
					
						
							|  |  |  | 		return Py_None; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return Ipo_CreatePyObject( ipo ); | 
					
						
							| 
									
										
										
										
											2003-10-26 16:51:53 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_getName( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-26 16:51:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyObject *attr = PyString_FromString( self->camera->id.name + 2 ); | 
					
						
							| 
									
										
										
										
											2003-05-08 03:06:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( attr ) | 
					
						
							|  |  |  | 		return attr; | 
					
						
							| 
									
										
										
										
											2003-05-08 03:06:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 				      "couldn't get Camera.name attribute" ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_getType( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2003-05-08 03:06:46 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyObject *attr = PyInt_FromLong( self->camera->type ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( attr ) | 
					
						
							|  |  |  | 		return attr; | 
					
						
							| 
									
										
										
										
											2003-05-08 03:06:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 				      "couldn't get Camera.type attribute" ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_getMode( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyObject *attr = PyInt_FromLong( self->camera->flag ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( attr ) | 
					
						
							|  |  |  | 		return attr; | 
					
						
							| 
									
										
										
										
											2003-05-08 03:06:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 				      "couldn't get Camera.Mode attribute" ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_getLens( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyObject *attr = PyFloat_FromDouble( self->camera->lens ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( attr ) | 
					
						
							|  |  |  | 		return attr; | 
					
						
							| 
									
										
										
										
											2003-05-08 03:06:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 				      "couldn't get Camera.lens attribute" ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | static PyObject *Camera_getScale( BPy_Camera * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *attr = PyFloat_FromDouble( self->camera->ortho_scale ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( attr ) | 
					
						
							|  |  |  | 		return attr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 				      "couldn't get Camera.scale attribute" ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_getClipStart( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyObject *attr = PyFloat_FromDouble( self->camera->clipsta ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( attr ) | 
					
						
							|  |  |  | 		return attr; | 
					
						
							| 
									
										
										
										
											2003-05-08 03:06:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 				      "couldn't get Camera.clipStart attribute" ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_getClipEnd( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyObject *attr = PyFloat_FromDouble( self->camera->clipend ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( attr ) | 
					
						
							|  |  |  | 		return attr; | 
					
						
							| 
									
										
										
										
											2003-05-08 03:06:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 				      "couldn't get Camera.clipEnd attribute" ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_getDrawSize( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyObject *attr = PyFloat_FromDouble( self->camera->drawsize ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( attr ) | 
					
						
							|  |  |  | 		return attr; | 
					
						
							| 
									
										
										
										
											2003-05-08 03:06:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 				      "couldn't get Camera.drawSize attribute" ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_setIpo( BPy_Camera * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-10-26 16:51:53 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyObject *pyipo = 0; | 
					
						
							|  |  |  | 	Ipo *ipo = NULL; | 
					
						
							|  |  |  | 	Ipo *oldipo; | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !PyArg_ParseTuple( args, "O!", &Ipo_Type, &pyipo ) ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "expected Ipo as argument" ); | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	ipo = Ipo_FromPyObject( pyipo ); | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !ipo ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 					      "null ipo!" ); | 
					
						
							| 
									
										
										
										
											2003-10-26 16:51:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( ipo->blocktype != ID_CA ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "this ipo is not a camera data ipo" ); | 
					
						
							| 
									
										
										
										
											2003-10-26 16:51:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	oldipo = self->camera->ipo; | 
					
						
							|  |  |  | 	if( oldipo ) { | 
					
						
							|  |  |  | 		ID *id = &oldipo->id; | 
					
						
							|  |  |  | 		if( id->us > 0 ) | 
					
						
							|  |  |  | 			id->us--; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	( ( ID * ) & ipo->id )->us++; | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	self->camera->ipo = ipo; | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Py_INCREF( Py_None ); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							| 
									
										
										
										
											2003-10-26 16:51:53 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_clearIpo( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Camera *cam = self->camera; | 
					
						
							|  |  |  | 	Ipo *ipo = ( Ipo * ) cam->ipo; | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( ipo ) { | 
					
						
							|  |  |  | 		ID *id = &ipo->id; | 
					
						
							|  |  |  | 		if( id->us > 0 ) | 
					
						
							|  |  |  | 			id->us--; | 
					
						
							|  |  |  | 		cam->ipo = NULL; | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-09 15:53:35 +00:00
										 |  |  | 		return EXPP_incr_ret_True(); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-09 15:53:35 +00:00
										 |  |  | 	return EXPP_incr_ret_False(); /* no ipo found */ | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_setName( BPy_Camera * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	char *name; | 
					
						
							|  |  |  | 	char buf[21]; | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !PyArg_ParseTuple( args, "s", &name ) ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "expected string argument" ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyOS_snprintf( buf, sizeof( buf ), "%s", name ); | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	rename_id( &self->camera->id, buf ); | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Py_INCREF( Py_None ); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_setType( BPy_Camera * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	char *type; | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !PyArg_ParseTuple( args, "s", &type ) ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "expected string argument" ); | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( strcmp( type, "persp" ) == 0 ) | 
					
						
							|  |  |  | 		self->camera->type = ( short ) EXPP_CAM_TYPE_PERSP; | 
					
						
							|  |  |  | 	else if( strcmp( type, "ortho" ) == 0 ) | 
					
						
							|  |  |  | 		self->camera->type = ( short ) EXPP_CAM_TYPE_ORTHO; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 					      "unknown camera type" ); | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Py_INCREF( Py_None ); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | /* This one is 'private'. It is not really a method, just a helper function for
 | 
					
						
							| 
									
										
										
										
											2003-06-05 16:21:44 +00:00
										 |  |  |  * when script writers use Camera.type = t instead of Camera.setType(t), since | 
					
						
							|  |  |  |  * in the first case t should be an int and in the second a string. So while | 
					
						
							|  |  |  |  * the method setType expects a string ('persp' or 'ortho') or an empty | 
					
						
							|  |  |  |  * argument, this function should receive an int (0 or 1). */ | 
					
						
							| 
									
										
										
										
											2003-06-07 03:49:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_setIntType( BPy_Camera * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	short value; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "h", &value ) ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "expected int argument: 0 or 1" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( value == 0 || value == 1 ) | 
					
						
							|  |  |  | 		self->camera->type = value; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_ValueError, | 
					
						
							|  |  |  | 					      "expected int argument: 0 or 1" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Py_INCREF( Py_None ); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Camera_setMode( BPy_Camera * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *mode_str1 = NULL, *mode_str2 = NULL; | 
					
						
							|  |  |  | 	short flag = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "|ss", &mode_str1, &mode_str2 ) ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 					      "expected one or two strings as arguments" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( mode_str1 != NULL ) { | 
					
						
							|  |  |  | 		if( strcmp( mode_str1, "showLimits" ) == 0 ) | 
					
						
							|  |  |  | 			flag |= ( short ) EXPP_CAM_MODE_SHOWLIMITS; | 
					
						
							|  |  |  | 		else if( strcmp( mode_str1, "showMist" ) == 0 ) | 
					
						
							|  |  |  | 			flag |= ( short ) EXPP_CAM_MODE_SHOWMIST; | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			return EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 						      "first argument is an unknown camera flag" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if( mode_str2 != NULL ) { | 
					
						
							|  |  |  | 			if( strcmp( mode_str2, "showLimits" ) == 0 ) | 
					
						
							|  |  |  | 				flag |= ( short ) EXPP_CAM_MODE_SHOWLIMITS; | 
					
						
							|  |  |  | 			else if( strcmp( mode_str2, "showMist" ) == 0 ) | 
					
						
							|  |  |  | 				flag |= ( short ) EXPP_CAM_MODE_SHOWMIST; | 
					
						
							|  |  |  | 			else | 
					
						
							|  |  |  | 				return EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 					( PyExc_AttributeError, | 
					
						
							|  |  |  | 					  "second argument is an unknown camera flag" ); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	self->camera->flag = flag; | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Py_INCREF( Py_None ); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | /* Another helper function, for the same reason.
 | 
					
						
							|  |  |  |  * (See comment before Camera_setIntType above). */ | 
					
						
							| 
									
										
										
										
											2003-06-07 03:49:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_setIntMode( BPy_Camera * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	short value; | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !PyArg_ParseTuple( args, "h", &value ) ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "expected int argument in [0,3]" ); | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( value >= 0 && value <= 3 ) | 
					
						
							|  |  |  | 		self->camera->flag = value; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_ValueError, | 
					
						
							|  |  |  | 					      "expected int argument in [0,3]" ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Py_INCREF( Py_None ); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_setLens( BPy_Camera * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	float value; | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !PyArg_ParseTuple( args, "f", &value ) ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "expected float argument" ); | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	self->camera->lens = EXPP_ClampFloat( value, | 
					
						
							|  |  |  | 					      EXPP_CAM_LENS_MIN, | 
					
						
							|  |  |  | 					      EXPP_CAM_LENS_MAX ); | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Py_INCREF( Py_None ); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | static PyObject *Camera_setScale( BPy_Camera * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	float value; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "f", &value ) ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "expected float argument" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	self->camera->ortho_scale = EXPP_ClampFloat( value, | 
					
						
							|  |  |  | 					      EXPP_CAM_SCALE_MIN, | 
					
						
							|  |  |  | 					      EXPP_CAM_SCALE_MAX ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Py_INCREF( Py_None ); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_setClipStart( BPy_Camera * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	float value; | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !PyArg_ParseTuple( args, "f", &value ) ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "expected float argument" ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	self->camera->clipsta = EXPP_ClampFloat( value, | 
					
						
							|  |  |  | 						 EXPP_CAM_CLIPSTART_MIN, | 
					
						
							|  |  |  | 						 EXPP_CAM_CLIPSTART_MAX ); | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Py_INCREF( Py_None ); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_setClipEnd( BPy_Camera * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	float value; | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !PyArg_ParseTuple( args, "f", &value ) ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "expected float argument" ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	self->camera->clipend = EXPP_ClampFloat( value, | 
					
						
							|  |  |  | 						 EXPP_CAM_CLIPEND_MIN, | 
					
						
							|  |  |  | 						 EXPP_CAM_CLIPEND_MAX ); | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Py_INCREF( Py_None ); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_setDrawSize( BPy_Camera * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	float value; | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !PyArg_ParseTuple( args, "f", &value ) ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "expected a float number as argument" ); | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	self->camera->drawsize = EXPP_ClampFloat( value, | 
					
						
							|  |  |  | 						  EXPP_CAM_DRAWSIZE_MIN, | 
					
						
							|  |  |  | 						  EXPP_CAM_DRAWSIZE_MAX ); | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Py_INCREF( Py_None ); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | /* cam.addScriptLink */ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_addScriptLink( BPy_Camera * self, PyObject * args ) | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	Camera *cam = self->camera; | 
					
						
							|  |  |  | 	ScriptLink *slink = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	slink = &( cam )->scriptlink; | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-21 19:44:52 +00:00
										 |  |  | 	return EXPP_addScriptLink( slink, args, 0 ); | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* cam.clearScriptLinks */ | 
					
						
							| 
									
										
										
										
											2005-04-21 19:44:52 +00:00
										 |  |  | static PyObject *Camera_clearScriptLinks( BPy_Camera * self, PyObject * args ) | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	Camera *cam = self->camera; | 
					
						
							|  |  |  | 	ScriptLink *slink = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	slink = &( cam )->scriptlink; | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-21 19:44:52 +00:00
										 |  |  | 	return EXPP_clearScriptLinks( slink, args ); | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* cam.getScriptLinks */ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_getScriptLinks( BPy_Camera * self, PyObject * args ) | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	Camera *cam = self->camera; | 
					
						
							|  |  |  | 	ScriptLink *slink = NULL; | 
					
						
							|  |  |  | 	PyObject *ret = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	slink = &( cam )->scriptlink; | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	ret = EXPP_getScriptLinks( slink, args, 0 ); | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( ret ) | 
					
						
							|  |  |  | 		return ret; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static void Camera_dealloc( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyObject_DEL( self ); | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_getAttr( BPy_Camera * self, char *name ) | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyObject *attr = Py_None; | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( strcmp( name, "name" ) == 0 ) | 
					
						
							|  |  |  | 		attr = PyString_FromString( self->camera->id.name + 2 ); | 
					
						
							|  |  |  | 	else if( strcmp( name, "type" ) == 0 ) | 
					
						
							|  |  |  | 		attr = PyInt_FromLong( self->camera->type ); | 
					
						
							|  |  |  | 	else if( strcmp( name, "mode" ) == 0 ) | 
					
						
							|  |  |  | 		attr = PyInt_FromLong( self->camera->flag ); | 
					
						
							|  |  |  | 	else if( strcmp( name, "lens" ) == 0 ) | 
					
						
							|  |  |  | 		attr = PyFloat_FromDouble( self->camera->lens ); | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | 	else if( strcmp( name, "scale" ) == 0 ) | 
					
						
							|  |  |  | 		attr = PyFloat_FromDouble( self->camera->ortho_scale ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	else if( strcmp( name, "clipStart" ) == 0 ) | 
					
						
							|  |  |  | 		attr = PyFloat_FromDouble( self->camera->clipsta ); | 
					
						
							|  |  |  | 	else if( strcmp( name, "clipEnd" ) == 0 ) | 
					
						
							|  |  |  | 		attr = PyFloat_FromDouble( self->camera->clipend ); | 
					
						
							|  |  |  | 	else if( strcmp( name, "drawSize" ) == 0 ) | 
					
						
							|  |  |  | 		attr = PyFloat_FromDouble( self->camera->drawsize ); | 
					
						
							| 
									
										
										
										
											2005-01-13 03:04:12 +00:00
										 |  |  | 	else if( strcmp( name, "users" ) == 0 ) | 
					
						
							|  |  |  | 		attr = PyInt_FromLong( self->camera->id.us ); | 
					
						
							| 
									
										
										
										
											2005-06-17 05:10:14 +00:00
										 |  |  | 	else if( strcmp( name, "ipo" ) == 0 ) | 
					
						
							|  |  |  | 		/* getIpo can return None and that is a valid value, so need to return straightaway */ | 
					
						
							|  |  |  | 		return Camera_getIpo(self); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	else if( strcmp( name, "Types" ) == 0 ) { | 
					
						
							|  |  |  | 		attr = Py_BuildValue( "{s:h,s:h}", "persp", | 
					
						
							|  |  |  | 				      EXPP_CAM_TYPE_PERSP, "ortho", | 
					
						
							|  |  |  | 				      EXPP_CAM_TYPE_ORTHO ); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	else if( strcmp( name, "Modes" ) == 0 ) { | 
					
						
							|  |  |  | 		attr = Py_BuildValue( "{s:h,s:h}", "showLimits", | 
					
						
							|  |  |  | 				      EXPP_CAM_MODE_SHOWLIMITS, "showMist", | 
					
						
							|  |  |  | 				      EXPP_CAM_MODE_SHOWMIST ); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	else if( strcmp( name, "__members__" ) == 0 ) { | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | 		attr = Py_BuildValue( "[s,s,s,s,s,s,s,s,s,s,s,s]", | 
					
						
							|  |  |  | 				      "name", "type", "mode", "lens", "scale", | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 				      "clipStart", "ipo", "clipEnd", | 
					
						
							| 
									
										
										
										
											2005-01-13 03:04:12 +00:00
										 |  |  | 				      "drawSize", "Types", "Modes", "users" ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !attr ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_MemoryError, | 
					
						
							|  |  |  | 					      "couldn't create PyObject" ); | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( attr != Py_None ) | 
					
						
							|  |  |  | 		return attr;	/* member attribute found, return it */ | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	/* not an attribute, search the methods table */ | 
					
						
							|  |  |  | 	return Py_FindMethod( BPy_Camera_methods, ( PyObject * ) self, name ); | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static int Camera_setAttr( BPy_Camera * self, char *name, PyObject * value ) | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyObject *valtuple; | 
					
						
							|  |  |  | 	PyObject *error = NULL; | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | /* We're playing a trick on the Python API users here.	Even if they use
 | 
					
						
							| 
									
										
										
										
											2003-05-08 03:06:46 +00:00
										 |  |  |  * Camera.member = val instead of Camera.setMember(val), we end up using the | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  |  * function anyway, since it already has error checking, clamps to the right | 
					
						
							|  |  |  |  * interval and updates the Blender Camera structure when necessary. */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-05-08 03:06:46 +00:00
										 |  |  | /* First we put "value" in a tuple, because we want to pass it to functions
 | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  |  * that only accept PyTuples. */ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	valtuple = Py_BuildValue( "(O)", value ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !valtuple )		/* everything OK with our PyObject? */ | 
					
						
							|  |  |  | 		return EXPP_ReturnIntError( PyExc_MemoryError, | 
					
						
							|  |  |  | 					    "CameraSetAttr: couldn't create PyTuple" ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-05 16:21:44 +00:00
										 |  |  | /* Now we just compare "name" with all possible BPy_Camera member variables */ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( strcmp( name, "name" ) == 0 ) | 
					
						
							|  |  |  | 		error = Camera_setName( self, valtuple ); | 
					
						
							|  |  |  | 	else if( strcmp( name, "type" ) == 0 ) | 
					
						
							|  |  |  | 		error = Camera_setIntType( self, valtuple );	/* special case */ | 
					
						
							|  |  |  | 	else if( strcmp( name, "mode" ) == 0 ) | 
					
						
							|  |  |  | 		error = Camera_setIntMode( self, valtuple );	/* special case */ | 
					
						
							|  |  |  | 	else if( strcmp( name, "lens" ) == 0 ) | 
					
						
							|  |  |  | 		error = Camera_setLens( self, valtuple ); | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | 	else if( strcmp( name, "scale" ) == 0 ) | 
					
						
							|  |  |  | 		error = Camera_setScale( self, valtuple ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	else if( strcmp( name, "clipStart" ) == 0 ) | 
					
						
							|  |  |  | 		error = Camera_setClipStart( self, valtuple ); | 
					
						
							|  |  |  | 	else if( strcmp( name, "clipEnd" ) == 0 ) | 
					
						
							|  |  |  | 		error = Camera_setClipEnd( self, valtuple ); | 
					
						
							|  |  |  | 	else if( strcmp( name, "drawSize" ) == 0 ) | 
					
						
							|  |  |  | 		error = Camera_setDrawSize( self, valtuple ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	else {			/* Error */ | 
					
						
							|  |  |  | 		Py_DECREF( valtuple ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if( ( strcmp( name, "Types" ) == 0 ) ||	/* user tried to change a */ | 
					
						
							|  |  |  | 		    ( strcmp( name, "Modes" ) == 0 ) )	/* constant dict type ... */ | 
					
						
							|  |  |  | 			return EXPP_ReturnIntError( PyExc_AttributeError, | 
					
						
							|  |  |  | 						    "constant dictionary -- cannot be changed" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		else		/* ... or no member with the given name was found */ | 
					
						
							|  |  |  | 			return EXPP_ReturnIntError( PyExc_KeyError, | 
					
						
							|  |  |  | 						    "attribute not found" ); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-05-08 03:06:46 +00:00
										 |  |  | /* valtuple won't be returned to the caller, so we need to DECREF it */ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Py_DECREF( valtuple ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( error != Py_None ) | 
					
						
							|  |  |  | 		return -1; | 
					
						
							| 
									
										
										
										
											2003-05-08 03:06:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Py_None was incref'ed by the called Camera_set* function. We probably
 | 
					
						
							|  |  |  |  * don't need to decref Py_None (!), but since Python/C API manual tells us | 
					
						
							|  |  |  |  * to treat it like any other PyObject regarding ref counting ... */ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Py_DECREF( Py_None ); | 
					
						
							|  |  |  | 	return 0;		/* normal exit */ | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static int Camera_compare( BPy_Camera * a, BPy_Camera * b ) | 
					
						
							| 
									
										
										
										
											2003-05-21 19:58:31 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Camera *pa = a->camera, *pb = b->camera; | 
					
						
							|  |  |  | 	return ( pa == pb ) ? 0 : -1; | 
					
						
							| 
									
										
										
										
											2003-05-21 19:58:31 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-07-05 01:18:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_repr( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return PyString_FromFormat( "[Camera \"%s\"]", | 
					
						
							|  |  |  | 				    self->camera->id.name + 2 ); | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2005-03-27 13:28:49 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Camera_insertIpoKey() | 
					
						
							|  |  |  |  *  inserts Camera IPO key for LENS and CLIPPING | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Camera_insertIpoKey( BPy_Camera * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int key = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "i", &( key ) ) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 										"expected int argument" ) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (key == IPOKEY_LENS){ | 
					
						
							| 
									
										
										
										
											2005-10-10 18:05:30 +00:00
										 |  |  | 		insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_LENS);      | 
					
						
							| 
									
										
										
										
											2005-03-27 13:28:49 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else if (key == IPOKEY_CLIPPING){ | 
					
						
							| 
									
										
										
										
											2005-10-10 18:05:30 +00:00
										 |  |  | 		insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_STA); | 
					
						
							|  |  |  | 		insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_END);    | 
					
						
							| 
									
										
										
										
											2005-03-27 13:28:49 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	allspace(REMAKEIPO, 0); | 
					
						
							|  |  |  | 	EXPP_allqueue(REDRAWIPO, 0); | 
					
						
							|  |  |  | 	EXPP_allqueue(REDRAWVIEW3D, 0); | 
					
						
							|  |  |  | 	EXPP_allqueue(REDRAWACTION, 0); | 
					
						
							|  |  |  | 	EXPP_allqueue(REDRAWNLA, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return EXPP_incr_ret( Py_None ); | 
					
						
							|  |  |  | } |