| 
									
										
										
										
											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"
 | 
					
						
							| 
									
										
										
										
											2007-04-28 18:20:43 +00:00
										 |  |  | #include "BLI_arithb.h" /* for M_PI */
 | 
					
						
							| 
									
										
										
										
											2005-07-18 03:50:37 +00:00
										 |  |  | #include "BSE_editipo.h"
 | 
					
						
							|  |  |  | #include "BIF_space.h"
 | 
					
						
							|  |  |  | #include "mydevice.h"
 | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | #include "gen_utils.h"
 | 
					
						
							| 
									
										
										
										
											2007-03-11 04:05:45 +00:00
										 |  |  | #include "gen_library.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
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | enum cam_consts { | 
					
						
							|  |  |  | 	EXPP_CAM_ATTR_LENS = 0, | 
					
						
							| 
									
										
										
										
											2007-04-28 17:21:00 +00:00
										 |  |  | 	EXPP_CAM_ATTR_ANGLE, | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	EXPP_CAM_ATTR_DOFDIST, | 
					
						
							|  |  |  | 	EXPP_CAM_ATTR_CLIPEND, | 
					
						
							|  |  |  | 	EXPP_CAM_ATTR_CLIPSTART, | 
					
						
							|  |  |  | 	EXPP_CAM_ATTR_SCALE, | 
					
						
							|  |  |  | 	EXPP_CAM_ATTR_DRAWSIZE, | 
					
						
							|  |  |  | 	EXPP_CAM_ATTR_SHIFTX, | 
					
						
							|  |  |  | 	EXPP_CAM_ATTR_SHIFTY, | 
					
						
							|  |  |  | 	EXPP_CAM_ATTR_ALPHA, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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\ | 
					
						
							| 
									
										
										
										
											2007-01-22 00:04:13 +00:00
										 |  |  |   scn = Scene.GetCurrent()     # get current Scene\n\ | 
					
						
							|  |  |  |   ob = scn.objects.new(c)      # Make an object from this data in the scene\n\ | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  |   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:                                   */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | static PyObject *Camera_oldgetType( BPy_Camera * self ); | 
					
						
							|  |  |  | static PyObject *Camera_oldgetMode( BPy_Camera * self ); | 
					
						
							|  |  |  | static PyObject *Camera_oldgetLens( BPy_Camera * self ); | 
					
						
							|  |  |  | static PyObject *Camera_oldgetClipStart( BPy_Camera * self ); | 
					
						
							|  |  |  | static PyObject *Camera_oldgetClipEnd( BPy_Camera * self ); | 
					
						
							|  |  |  | static PyObject *Camera_oldgetDrawSize( BPy_Camera * self ); | 
					
						
							|  |  |  | static PyObject *Camera_oldgetScale( BPy_Camera * self ); | 
					
						
							| 
									
										
										
										
											2007-03-08 14:37:34 +00:00
										 |  |  | static PyObject *Camera_getIpo( BPy_Camera * self ); | 
					
						
							|  |  |  | static int Camera_setIpo( BPy_Camera * self, PyObject * value ); | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | static PyObject *Camera_oldsetIpo( BPy_Camera * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Camera_oldsetType( BPy_Camera * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Camera_oldsetMode( BPy_Camera * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Camera_oldsetLens( BPy_Camera * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Camera_oldsetClipStart( BPy_Camera * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Camera_oldsetClipEnd( BPy_Camera * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Camera_oldsetDrawSize( BPy_Camera * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Camera_oldsetScale( BPy_Camera * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | static PyObject *Camera_oldgetScriptLinks( BPy_Camera * self, PyObject * value ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Camera_addScriptLink( BPy_Camera * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | static PyObject *Camera_oldclearIpo( BPy_Camera * self ); | 
					
						
							| 
									
										
										
										
											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 ); | 
					
						
							| 
									
										
										
										
											2006-08-16 14:06:24 +00:00
										 |  |  | static PyObject *Camera_copy( BPy_Camera * self ); | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-09 19:45:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 */ | 
					
						
							| 
									
										
										
										
											2007-03-08 14:37:34 +00:00
										 |  |  | 	{"getIpo", ( PyCFunction ) Camera_getIpo, METH_NOARGS, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "() - Return Camera Data Ipo"}, | 
					
						
							| 
									
										
										
										
											2007-02-25 07:36:50 +00:00
										 |  |  | 	{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "() - Return Camera Data name"}, | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	{"getType", ( PyCFunction ) Camera_oldgetType, METH_NOARGS, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "() - Return Camera type - 'persp':0, 'ortho':1"}, | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	{"getMode", ( PyCFunction ) Camera_oldgetMode, METH_NOARGS, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "() - Return Camera mode flags (or'ed value) -\n" | 
					
						
							|  |  |  | 	 "     'showLimits':1, 'showMist':2"}, | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	{"getLens", ( PyCFunction ) Camera_oldgetLens, METH_NOARGS, | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | 	 "() - Return *perspective* Camera lens value"}, | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	{"getScale", ( PyCFunction ) Camera_oldgetScale, METH_NOARGS, | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | 	 "() - Return *ortho* Camera scale value"}, | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	{"getClipStart", ( PyCFunction ) Camera_oldgetClipStart, METH_NOARGS, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "() - Return Camera clip start value"}, | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	{"getClipEnd", ( PyCFunction ) Camera_oldgetClipEnd, METH_NOARGS, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "() - Return Camera clip end value"}, | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	{"getDrawSize", ( PyCFunction ) Camera_oldgetDrawSize, METH_NOARGS, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "() - Return Camera draw size value"}, | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	{"setIpo", ( PyCFunction ) Camera_oldsetIpo, METH_VARARGS, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "(Blender Ipo) - Set Camera Ipo"}, | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	{"clearIpo", ( PyCFunction ) Camera_oldclearIpo, METH_NOARGS, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "() - 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"}, | 
					
						
							| 
									
										
										
										
											2007-02-25 07:36:50 +00:00
										 |  |  | 	{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "(s) - Set Camera Data name"}, | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	{"setType", ( PyCFunction ) Camera_oldsetType, METH_O, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "(s) - Set Camera type, which can be 'persp' or 'ortho'"}, | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	{"setMode", ( PyCFunction ) Camera_oldsetMode, METH_VARARGS, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "(<s<,s>>) - Set Camera mode flag(s): 'showLimits' and 'showMist'"}, | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	{"setLens", ( PyCFunction ) Camera_oldsetLens, METH_O, | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | 	 "(f) - Set *perpective* Camera lens value"}, | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	{"setScale", ( PyCFunction ) Camera_oldsetScale, METH_O, | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | 	 "(f) - Set *ortho* Camera scale value"}, | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	{"setClipStart", ( PyCFunction ) Camera_oldsetClipStart, METH_O, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "(f) - Set Camera clip start value"}, | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	{"setClipEnd", ( PyCFunction ) Camera_oldsetClipEnd, METH_O, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "(f) - Set Camera clip end value"}, | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	{"setDrawSize", ( PyCFunction ) Camera_oldsetDrawSize, METH_O, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "(f) - Set Camera draw size value"}, | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	{"getScriptLinks", ( PyCFunction ) Camera_oldgetScriptLinks, METH_O, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "(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."}, | 
					
						
							| 
									
										
										
										
											2006-08-16 14:06:24 +00:00
										 |  |  | 	{"__copy__", ( PyCFunction ) Camera_copy, METH_NOARGS, | 
					
						
							|  |  |  | 	 "() - Return a copy of the camera."}, | 
					
						
							| 
									
										
										
										
											2007-03-14 03:01:24 +00:00
										 |  |  | 	{"copy", ( PyCFunction ) Camera_copy, METH_NOARGS, | 
					
						
							|  |  |  | 	 "() - Return a copy of the 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 int Camera_compare( BPy_Camera * a, BPy_Camera * b ); | 
					
						
							|  |  |  | static PyObject *Camera_repr( BPy_Camera * self ); | 
					
						
							| 
									
										
										
										
											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 */ | 
					
						
							| 
									
										
										
										
											2007-03-11 16:25:17 +00:00
										 |  |  | 	char *name_str = "Camera"; | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	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 */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* 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" ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-11 16:25:17 +00:00
										 |  |  | 	blcam = add_camera( name_str );	/* first create the Camera Data in Blender */ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	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" ); | 
					
						
							| 
									
										
										
										
											2007-03-11 16:25:17 +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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-27 21:33:48 +00:00
										 |  |  | 			if( !pyobj ) { | 
					
						
							|  |  |  | 				Py_DECREF(cam_pylist); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 				return EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 					( PyExc_MemoryError, | 
					
						
							|  |  |  | 					  "couldn't create Camera PyObject" ); | 
					
						
							| 
									
										
										
										
											2007-05-27 21:33:48 +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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	if( PyType_Ready( &Camera_Type ) < 0 ) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							|  |  |  | 	return ( PyObject * ) pycam; | 
					
						
							| 
									
										
										
										
											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-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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | static PyObject *Camera_oldgetType( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2003-05-08 03:06:46 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-06-29 08:59:26 +00:00
										 |  |  | 	return PyInt_FromLong( self->camera->type ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | static PyObject *Camera_oldgetMode( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-06-29 08:59:26 +00:00
										 |  |  | 	return PyInt_FromLong( self->camera->flag ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | static PyObject *Camera_oldgetLens( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-06-29 08:59:26 +00:00
										 |  |  | 	return PyFloat_FromDouble( self->camera->lens ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | static PyObject *Camera_oldgetScale( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-06-29 08:59:26 +00:00
										 |  |  | 	return PyFloat_FromDouble( self->camera->ortho_scale ); | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | static PyObject *Camera_oldgetClipStart( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-06-29 08:59:26 +00:00
										 |  |  | 	return PyFloat_FromDouble( self->camera->clipsta ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | static PyObject *Camera_oldgetClipEnd( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-06-29 08:59:26 +00:00
										 |  |  | 	return PyFloat_FromDouble( self->camera->clipend ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | static PyObject *Camera_oldgetDrawSize( BPy_Camera * self ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-06-29 08:59:26 +00:00
										 |  |  | 	return PyFloat_FromDouble( self->camera->drawsize ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | static PyObject *Camera_oldsetIpo( BPy_Camera * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-10-26 16:51:53 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-03-08 14:37:34 +00:00
										 |  |  | 	return EXPP_setterWrapper( (void *)self, args, (setter)Camera_setIpo ); | 
					
						
							| 
									
										
										
										
											2003-10-26 16:51:53 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | static PyObject *Camera_oldclearIpo( 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
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | static PyObject *Camera_oldsetType( BPy_Camera * self, PyObject * value ) | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	char *type = PyString_AsString(value); | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	if(!value) | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-24 03:25:53 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | static PyObject *Camera_oldsetMode( BPy_Camera * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-24 03:25:53 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | static PyObject *Camera_oldsetLens( BPy_Camera * self, PyObject * value ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	float param = PyFloat_AsDouble(value); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	if( !PyFloat_Check(value) ) | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "expected float argument" ); | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	self->camera->lens = EXPP_ClampFloat( param, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 					      EXPP_CAM_LENS_MIN, | 
					
						
							|  |  |  | 					      EXPP_CAM_LENS_MAX ); | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-24 03:25:53 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | static PyObject *Camera_oldsetScale( BPy_Camera * self, PyObject * value ) | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	float param = PyFloat_AsDouble(value); | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	if( !PyFloat_Check(value) ) | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "expected float argument" ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	self->camera->ortho_scale = EXPP_ClampFloat( param, | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | 					      EXPP_CAM_SCALE_MIN, | 
					
						
							|  |  |  | 					      EXPP_CAM_SCALE_MAX ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-24 03:25:53 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | static PyObject *Camera_oldsetClipStart( BPy_Camera * self, PyObject * value ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	float param = PyFloat_AsDouble(value); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	if( !PyFloat_Check(value) ) | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "expected float argument" ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	self->camera->clipsta = EXPP_ClampFloat( param, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 						 EXPP_CAM_CLIPSTART_MIN, | 
					
						
							|  |  |  | 						 EXPP_CAM_CLIPSTART_MAX ); | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-24 03:25:53 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | static PyObject *Camera_oldsetClipEnd( BPy_Camera * self, PyObject * value ) | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	float param = PyFloat_AsDouble(value); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	if( !PyFloat_Check(value) ) | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "expected float argument" ); | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	self->camera->clipend = EXPP_ClampFloat( param, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 						 EXPP_CAM_CLIPEND_MIN, | 
					
						
							|  |  |  | 						 EXPP_CAM_CLIPEND_MAX ); | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-24 03:25:53 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | static PyObject *Camera_oldsetDrawSize( BPy_Camera * self, PyObject * value ) | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	float param = PyFloat_AsDouble(value); | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	if( !PyFloat_Check(value) ) | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 					      "expected float argument" ); | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	self->camera->drawsize = EXPP_ClampFloat( param, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 						  EXPP_CAM_DRAWSIZE_MIN, | 
					
						
							|  |  |  | 						  EXPP_CAM_DRAWSIZE_MAX ); | 
					
						
							| 
									
										
										
										
											2003-10-28 00:29:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-24 03:25:53 +00:00
										 |  |  | 	Py_RETURN_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 */ | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | static PyObject *Camera_oldgetScriptLinks( BPy_Camera * self, PyObject * value ) | 
					
						
							| 
									
										
											  
											
												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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	ret = EXPP_getScriptLinks( slink, value, 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-16 14:06:24 +00:00
										 |  |  | /* cam.__copy__ */ | 
					
						
							|  |  |  | static PyObject *Camera_copy( BPy_Camera * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *pycam;	/* for Camera Data object wrapper in Python */ | 
					
						
							|  |  |  | 	Camera *blcam;		/* for actual Camera Data we create in Blender */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	blcam = copy_camera( self->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;	/* ... copy_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" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return pycam; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | static PyObject *Camera_getType( BPy_Camera * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (self->camera->type == EXPP_CAM_TYPE_PERSP) | 
					
						
							|  |  |  | 		return PyString_FromString("persp"); | 
					
						
							|  |  |  | 	else /* must be EXPP_CAM_TYPE_ORTHO */ | 
					
						
							|  |  |  | 		return PyString_FromString("ortho"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int Camera_setType( BPy_Camera * self, PyObject * value ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *type = NULL; | 
					
						
							|  |  |  | 	type = PyString_AsString(value); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (!type) | 
					
						
							|  |  |  | 		return EXPP_ReturnIntError( PyExc_ValueError, | 
					
						
							|  |  |  | 					      "expected a string" ); | 
					
						
							|  |  |  | 	if (strcmp("persp", type)==0) { | 
					
						
							|  |  |  | 		self->camera->type = EXPP_CAM_TYPE_PERSP; | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 	} else if (strcmp("ortho", type)==0) { | 
					
						
							|  |  |  | 		self->camera->type = EXPP_CAM_TYPE_ORTHO; | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	return EXPP_ReturnIntError( PyExc_ValueError, | 
					
						
							|  |  |  | 		"expected a string \"ortho\" or \"persp\"" ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Camera_getMode( BPy_Camera * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return PyInt_FromLong(self->camera->flag); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int Camera_setMode( BPy_Camera * self, PyObject * value ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	unsigned int flag = 0; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2007-07-01 05:41:23 +00:00
										 |  |  | 	if( !PyInt_Check( value ) ) | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 		return EXPP_ReturnIntError( PyExc_TypeError, | 
					
						
							|  |  |  | 			"expected an integer (bitmask) as argument" ); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	flag = ( unsigned int )PyInt_AS_LONG( value ); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	self->camera->flag = flag; | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Camera_getIpo( BPy_Camera * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct Ipo *ipo = self->camera->ipo; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( ipo ) | 
					
						
							|  |  |  | 		return Ipo_CreatePyObject( ipo ); | 
					
						
							|  |  |  | 	Py_RETURN_NONE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int Camera_setIpo( BPy_Camera * self, PyObject * value ) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2007-03-08 14:37:34 +00:00
										 |  |  | 	return GenericLib_assignData(value, (void **) &self->camera->ipo, 0, 1, ID_IP, ID_CA); | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * get floating point attributes | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *getFloatAttr( BPy_Camera *self, void *type ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	float param; | 
					
						
							|  |  |  | 	struct Camera *cam= self->camera; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	switch( (int)type ) { | 
					
						
							|  |  |  | 	case EXPP_CAM_ATTR_LENS:  | 
					
						
							|  |  |  | 		param = cam->lens; | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2007-04-28 17:21:00 +00:00
										 |  |  | 	case EXPP_CAM_ATTR_ANGLE:  | 
					
						
							|  |  |  | 		param = 360.0f * atan(16.0f/cam->lens) / M_PI; | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	case EXPP_CAM_ATTR_DOFDIST:  | 
					
						
							|  |  |  | 		param = cam->YF_dofdist; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_CAM_ATTR_CLIPSTART:  | 
					
						
							|  |  |  | 		param = cam->clipsta; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_CAM_ATTR_CLIPEND:  | 
					
						
							|  |  |  | 		param = cam->clipend; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_CAM_ATTR_DRAWSIZE:  | 
					
						
							|  |  |  | 		param = cam->drawsize; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_CAM_ATTR_SCALE:  | 
					
						
							|  |  |  | 		param = cam->ortho_scale; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_CAM_ATTR_ALPHA:  | 
					
						
							|  |  |  | 		param = cam->passepartalpha; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_CAM_ATTR_SHIFTX:  | 
					
						
							|  |  |  | 		param = cam->shiftx; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_CAM_ATTR_SHIFTY: | 
					
						
							|  |  |  | 		param = cam->shifty; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_RuntimeError,  | 
					
						
							|  |  |  | 				"undefined type in getFloatAttr" ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-03-31 07:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	return PyFloat_FromDouble( param ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * set floating point attributes which require clamping | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int setFloatAttrClamp( BPy_Camera *self, PyObject *value, void *type ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	float *param; | 
					
						
							|  |  |  | 	struct Camera *cam = self->camera; | 
					
						
							|  |  |  | 	float min, max; | 
					
						
							| 
									
										
										
										
											2007-04-28 17:21:00 +00:00
										 |  |  | 	int ret; | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	switch( (int)type ) { | 
					
						
							|  |  |  | 	case EXPP_CAM_ATTR_LENS: | 
					
						
							|  |  |  | 		min = 1.0; | 
					
						
							|  |  |  | 		max = 250.0; | 
					
						
							|  |  |  | 		param = &cam->lens; | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2007-04-28 17:21:00 +00:00
										 |  |  | 	case EXPP_CAM_ATTR_ANGLE: | 
					
						
							|  |  |  | 		min = 7.323871; | 
					
						
							|  |  |  | 		max = 172.847331; | 
					
						
							|  |  |  | 		param = &cam->lens; | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	case EXPP_CAM_ATTR_DOFDIST: | 
					
						
							|  |  |  | 		min = 0.0; | 
					
						
							|  |  |  | 		max = 5000.0; | 
					
						
							|  |  |  | 		param = &cam->YF_dofdist; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_CAM_ATTR_CLIPSTART: | 
					
						
							|  |  |  | 		min = 0.0; | 
					
						
							|  |  |  | 		max = 100.0; | 
					
						
							|  |  |  | 		param = &cam->clipsta; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_CAM_ATTR_CLIPEND: | 
					
						
							|  |  |  | 		min = 1.0; | 
					
						
							|  |  |  | 		max = 5000.0; | 
					
						
							|  |  |  | 		param = &cam->clipend; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_CAM_ATTR_DRAWSIZE: | 
					
						
							| 
									
										
										
										
											2007-03-01 21:30:48 +00:00
										 |  |  | 		min = 0.1f; | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 		max = 10.0; | 
					
						
							|  |  |  | 		param = &cam->drawsize; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_CAM_ATTR_SCALE: | 
					
						
							| 
									
										
										
										
											2007-03-01 21:30:48 +00:00
										 |  |  | 		min = 0.01f; | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 		max = 1000.0; | 
					
						
							|  |  |  | 		param = &cam->ortho_scale; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_CAM_ATTR_ALPHA: | 
					
						
							|  |  |  | 		min = 0.0; | 
					
						
							|  |  |  | 		max = 1.0; | 
					
						
							|  |  |  | 		param = &cam->passepartalpha; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_CAM_ATTR_SHIFTX: | 
					
						
							|  |  |  | 		min = -2.0; | 
					
						
							|  |  |  | 		max =  2.0; | 
					
						
							|  |  |  | 		param = &cam->shiftx; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_CAM_ATTR_SHIFTY: | 
					
						
							|  |  |  | 		min = -2.0; | 
					
						
							|  |  |  | 		max =  2.0; | 
					
						
							|  |  |  | 		param = &cam->shifty; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		return EXPP_ReturnIntError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 				"undefined type in setFloatAttrClamp" ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-04-28 17:21:00 +00:00
										 |  |  | 	ret = EXPP_setFloatClamped( value, param, min, max ); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (ret==0) { | 
					
						
							|  |  |  | 		if ((int)type == EXPP_CAM_ATTR_ANGLE) { | 
					
						
							|  |  |  | 			cam->lens = 16.0f / tan(M_PI*cam->lens/360.0f); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return ret; | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * get floating point attributes | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2003-05-08 03:06:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | static PyObject *getFlagAttr( BPy_Camera *self, void *type ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (self->camera->flag & (int)type) | 
					
						
							|  |  |  | 		Py_RETURN_TRUE; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		Py_RETURN_FALSE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * set floating point attributes which require clamping | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int setFlagAttr( BPy_Camera *self, PyObject *value, void *type ) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2007-07-12 11:51:21 +00:00
										 |  |  | 	int param = PyObject_IsTrue( value ); | 
					
						
							|  |  |  | 	if( param == -1 ) | 
					
						
							|  |  |  | 		return EXPP_ReturnIntError( PyExc_TypeError, | 
					
						
							|  |  |  | 				"expected True/False or 0/1" ); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (param) | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 		self->camera->flag |= (int)type; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		self->camera->flag &= ~(int)type; | 
					
						
							|  |  |  | 	return 0; | 
					
						
							| 
									
										
										
										
											2003-03-25 19:16:13 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-04-08 19:54:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python attributes get/set structure:                                      */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | static PyGetSetDef BPy_Camera_getseters[] = { | 
					
						
							| 
									
										
										
										
											2007-02-25 07:36:50 +00:00
										 |  |  | 	GENERIC_LIB_GETSETATTR, | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	{"type", | 
					
						
							|  |  |  | 	 (getter)Camera_getType, (setter)Camera_setType, | 
					
						
							|  |  |  | 	 "camera type \"persp\" or \"ortho\"", | 
					
						
							|  |  |  | 	 NULL}, | 
					
						
							|  |  |  | 	{"mode", | 
					
						
							|  |  |  | 	 (getter)Camera_getMode, (setter)Camera_setMode, | 
					
						
							|  |  |  | 	 "Cameras mode", | 
					
						
							|  |  |  | 	 NULL}, | 
					
						
							|  |  |  | 	{"ipo", | 
					
						
							|  |  |  | 	 (getter)Camera_getIpo, (setter)Camera_setIpo, | 
					
						
							|  |  |  | 	 "Cameras ipo", | 
					
						
							|  |  |  | 	 NULL}, | 
					
						
							| 
									
										
										
										
											2007-04-27 00:33:07 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	/* float settings */ | 
					
						
							|  |  |  | 	{"lens", | 
					
						
							|  |  |  | 	 (getter)getFloatAttr, (setter)setFloatAttrClamp, | 
					
						
							|  |  |  | 	 "lens angle for perspective cameras", | 
					
						
							| 
									
										
										
										
											2007-01-22 00:04:13 +00:00
										 |  |  | 	 (void *)EXPP_CAM_ATTR_LENS}, | 
					
						
							| 
									
										
										
										
											2007-04-28 17:21:00 +00:00
										 |  |  | 	{"angle", | 
					
						
							|  |  |  | 	 (getter)getFloatAttr, (setter)setFloatAttrClamp, | 
					
						
							|  |  |  | 	 "lens angle for perspective cameras", | 
					
						
							|  |  |  | 	 (void *)EXPP_CAM_ATTR_ANGLE}, | 
					
						
							|  |  |  | 	  | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	{"scale", | 
					
						
							|  |  |  | 	 (getter)getFloatAttr, (setter)setFloatAttrClamp, | 
					
						
							|  |  |  | 	 "scale for ortho cameras", | 
					
						
							| 
									
										
										
										
											2007-01-22 00:04:13 +00:00
										 |  |  | 	 (void *)EXPP_CAM_ATTR_SCALE}, | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	{"clipStart", | 
					
						
							|  |  |  | 	 (getter)getFloatAttr, (setter)setFloatAttrClamp, | 
					
						
							|  |  |  | 	 "the cameras clip start", | 
					
						
							|  |  |  | 	 (void *)EXPP_CAM_ATTR_CLIPSTART}, | 
					
						
							|  |  |  | 	{"clipEnd", | 
					
						
							|  |  |  | 	 (getter)getFloatAttr, (setter)setFloatAttrClamp, | 
					
						
							|  |  |  | 	 "the cameras clip end", | 
					
						
							|  |  |  | 	 (void *)EXPP_CAM_ATTR_CLIPEND}, | 
					
						
							| 
									
										
										
										
											2007-04-27 00:33:07 +00:00
										 |  |  | 	{"shiftX", | 
					
						
							|  |  |  | 	 (getter)getFloatAttr, (setter)setFloatAttrClamp, | 
					
						
							|  |  |  | 	 "the cameras X perspective shift", | 
					
						
							|  |  |  | 	 (void *)EXPP_CAM_ATTR_SHIFTX}, | 
					
						
							|  |  |  | 	{"shiftY", | 
					
						
							|  |  |  | 	 (getter)getFloatAttr, (setter)setFloatAttrClamp, | 
					
						
							|  |  |  | 	 "the cameras Y perspective shift", | 
					
						
							|  |  |  | 	 (void *)EXPP_CAM_ATTR_SHIFTY}, | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	{"dofDist", | 
					
						
							|  |  |  | 	 (getter)getFloatAttr, (setter)setFloatAttrClamp, | 
					
						
							|  |  |  | 	 "cameras dof distance", | 
					
						
							|  |  |  | 	 (void *)EXPP_CAM_ATTR_DOFDIST}, | 
					
						
							|  |  |  | 	{"drawSize", | 
					
						
							|  |  |  | 	 (getter)getFloatAttr, (setter)setFloatAttrClamp, | 
					
						
							|  |  |  | 	 "the cameras display size", | 
					
						
							|  |  |  | 	 (void *)EXPP_CAM_ATTR_DRAWSIZE}, | 
					
						
							|  |  |  | 	{"alpha", | 
					
						
							|  |  |  | 	 (getter)getFloatAttr, (setter)setFloatAttrClamp, | 
					
						
							|  |  |  | 	 "passepart alpha value for display", | 
					
						
							|  |  |  | 	 (void *)EXPP_CAM_ATTR_ALPHA}, | 
					
						
							|  |  |  | 	  | 
					
						
							|  |  |  | 	/* flags - use flags as defined in DNA_camera_types.h */ | 
					
						
							|  |  |  | 	{"drawLimits", | 
					
						
							|  |  |  | 	 (getter)getFlagAttr, (setter)setFlagAttr, | 
					
						
							|  |  |  | 	 "toggle the draw limits display flag", | 
					
						
							|  |  |  | 	 (void *)CAM_SHOWLIMITS}, | 
					
						
							|  |  |  | 	{"drawMist", | 
					
						
							|  |  |  | 	 (getter)getFlagAttr, (setter)setFlagAttr, | 
					
						
							|  |  |  | 	 "toggle the draw mist display flag", | 
					
						
							|  |  |  | 	 (void *)CAM_SHOWMIST}, | 
					
						
							|  |  |  | 	{"drawName", | 
					
						
							|  |  |  | 	 (getter)getFlagAttr, (setter)setFlagAttr, | 
					
						
							|  |  |  | 	 "toggle the draw name display flag", | 
					
						
							|  |  |  | 	 (void *)CAM_SHOWNAME}, | 
					
						
							|  |  |  | 	{"drawTileSafe", | 
					
						
							|  |  |  | 	 (getter)getFlagAttr, (setter)setFlagAttr, | 
					
						
							|  |  |  | 	 "toggle the tile safe display flag", | 
					
						
							|  |  |  | 	 (void *)CAM_SHOWTITLESAFE}, | 
					
						
							|  |  |  | 	{"drawPassepartout", | 
					
						
							|  |  |  | 	 (getter)getFlagAttr, (setter)setFlagAttr, | 
					
						
							|  |  |  | 	 "toggle the passPartOut display flag", | 
					
						
							|  |  |  | 	 (void *)CAM_SHOWPASSEPARTOUT}, | 
					
						
							| 
									
										
										
										
											2007-03-23 13:12:11 +00:00
										 |  |  | 	{"angleToggle", | 
					
						
							|  |  |  | 	 (getter)getFlagAttr, (setter)setFlagAttr, | 
					
						
							|  |  |  | 	 "toggle the camera input unit flag", | 
					
						
							|  |  |  | 	 (void *)CAM_ANGLETOGGLE}, | 
					
						
							|  |  |  | 	{NULL,NULL,NULL,NULL}  /* Sentinel */ | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python Camera_Type structure definition:                               */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | PyTypeObject Camera_Type = { | 
					
						
							|  |  |  | 	PyObject_HEAD_INIT( NULL )  /* required py macro */ | 
					
						
							|  |  |  | 	0,                          /* ob_size */ | 
					
						
							|  |  |  | 	/*  For printing, in format "<module>.<name>" */ | 
					
						
							|  |  |  | 	"Blender Camera",           /* char *tp_name; */ | 
					
						
							|  |  |  | 	sizeof( BPy_Camera ),       /* int tp_basicsize; */ | 
					
						
							|  |  |  | 	0,                          /* tp_itemsize;  For allocation */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Methods to implement standard operations */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 01:47:53 +00:00
										 |  |  | 	NULL,						/* destructor tp_dealloc; */ | 
					
						
							| 
									
										
										
										
											2006-12-26 07:00:32 +00:00
										 |  |  | 	NULL,                       /* printfunc tp_print; */ | 
					
						
							|  |  |  | 	NULL,                       /* getattrfunc tp_getattr; */ | 
					
						
							|  |  |  | 	NULL,                       /* setattrfunc tp_setattr; */ | 
					
						
							|  |  |  | 	( cmpfunc ) Camera_compare, /* cmpfunc tp_compare; */ | 
					
						
							|  |  |  | 	( reprfunc ) Camera_repr,   /* reprfunc tp_repr; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Method suites for standard classes */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	NULL,                       /* PyNumberMethods *tp_as_number; */ | 
					
						
							|  |  |  | 	NULL,                       /* PySequenceMethods *tp_as_sequence; */ | 
					
						
							|  |  |  | 	NULL,                       /* PyMappingMethods *tp_as_mapping; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* More standard operations (here for binary compatibility) */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	NULL,                       /* hashfunc tp_hash; */ | 
					
						
							|  |  |  | 	NULL,                       /* ternaryfunc tp_call; */ | 
					
						
							|  |  |  | 	NULL,                       /* reprfunc tp_str; */ | 
					
						
							|  |  |  | 	NULL,                       /* getattrofunc tp_getattro; */ | 
					
						
							|  |  |  | 	NULL,                       /* setattrofunc tp_setattro; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Functions to access object as input/output buffer */ | 
					
						
							|  |  |  | 	NULL,                       /* PyBufferProcs *tp_as_buffer; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /*** Flags to define presence of optional/expanded features ***/ | 
					
						
							|  |  |  | 	Py_TPFLAGS_DEFAULT,         /* long tp_flags; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	NULL,                       /*  char *tp_doc;  Documentation string */ | 
					
						
							|  |  |  |   /*** Assigned meaning in release 2.0 ***/ | 
					
						
							|  |  |  | 	/* call function for all accessible objects */ | 
					
						
							|  |  |  | 	NULL,                       /* traverseproc tp_traverse; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* delete references to contained objects */ | 
					
						
							|  |  |  | 	NULL,                       /* inquiry tp_clear; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /***  Assigned meaning in release 2.1 ***/ | 
					
						
							|  |  |  |   /*** rich comparisons ***/ | 
					
						
							|  |  |  | 	NULL,                       /* richcmpfunc tp_richcompare; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /***  weak reference enabler ***/ | 
					
						
							|  |  |  | 	0,                          /* long tp_weaklistoffset; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /*** Added in release 2.2 ***/ | 
					
						
							|  |  |  | 	/*   Iterators */ | 
					
						
							|  |  |  | 	NULL, /* getiterfunc tp_iter; */ | 
					
						
							|  |  |  | 	NULL, /* iternextfunc tp_iternext; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /*** Attribute descriptor and subclassing stuff ***/ | 
					
						
							|  |  |  | 	BPy_Camera_methods,       /* struct PyMethodDef *tp_methods; */ | 
					
						
							|  |  |  | 	NULL,                       /* struct PyMemberDef *tp_members; */ | 
					
						
							|  |  |  | 	BPy_Camera_getseters,                       /* struct PyGetSetDef *tp_getset; */ | 
					
						
							|  |  |  | 	NULL,                       /* struct _typeobject *tp_base; */ | 
					
						
							|  |  |  | 	NULL,                       /* PyObject *tp_dict; */ | 
					
						
							|  |  |  | 	NULL,                       /* descrgetfunc tp_descr_get; */ | 
					
						
							|  |  |  | 	NULL,                       /* descrsetfunc tp_descr_set; */ | 
					
						
							|  |  |  | 	0,                          /* long tp_dictoffset; */ | 
					
						
							|  |  |  | 	NULL,                       /* initproc tp_init; */ | 
					
						
							|  |  |  | 	NULL,                       /* allocfunc tp_alloc; */ | 
					
						
							|  |  |  | 	NULL,                       /* newfunc tp_new; */ | 
					
						
							|  |  |  | 	/*  Low-level free-memory routine */ | 
					
						
							|  |  |  | 	NULL,                       /* freefunc tp_free;  */ | 
					
						
							|  |  |  | 	/* For PyObject_IS_GC */ | 
					
						
							|  |  |  | 	NULL,                       /* inquiry tp_is_gc;  */ | 
					
						
							|  |  |  | 	NULL,                       /* PyObject *tp_bases; */ | 
					
						
							|  |  |  | 	/* method resolution order */ | 
					
						
							|  |  |  | 	NULL,                       /* PyObject *tp_mro;  */ | 
					
						
							|  |  |  | 	NULL,                       /* PyObject *tp_cache; */ | 
					
						
							|  |  |  | 	NULL,                       /* PyObject *tp_subclasses; */ | 
					
						
							|  |  |  | 	NULL,                       /* PyObject *tp_weaklist; */ | 
					
						
							|  |  |  | 	NULL | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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){ | 
					
						
							| 
									
										
										
										
											2007-09-18 06:41:29 +00:00
										 |  |  | 		insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_LENS, 0);      | 
					
						
							| 
									
										
										
										
											2005-03-27 13:28:49 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else if (key == IPOKEY_CLIPPING){ | 
					
						
							| 
									
										
										
										
											2007-09-18 06:41:29 +00:00
										 |  |  | 		insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_STA, 0); | 
					
						
							|  |  |  | 		insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_END, 0);    | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-24 03:25:53 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-03-27 13:28:49 +00:00
										 |  |  | } |