2003-06-07 03:49:45 +00:00
|
|
|
/*
|
2004-09-18 18:47:03 +00:00
|
|
|
* $Id$
|
2003-06-07 03:49:45 +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-24 17:08:59 +00:00
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
2003-06-07 03:49:45 +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-05-20 05:14:03 +00:00
|
|
|
* Contributor(s): Willian P. Germano, Jacques Guignot, Joseph Gilbert,
|
2005-08-21 15:00:17 +00:00
|
|
|
* Campbell Barton, Ken Hughes
|
2003-06-07 03:49:45 +00:00
|
|
|
*
|
|
|
|
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
|
|
|
|
*/
|
2005-07-18 03:50:37 +00:00
|
|
|
struct View3D;
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2005-07-18 03:50:37 +00:00
|
|
|
#include "Scene.h" /*This must come first */
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2005-07-18 03:50:37 +00:00
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_main.h"
|
|
|
|
|
#include "MEM_guardedalloc.h" /* for MEM_callocN */
|
|
|
|
|
#include "DNA_screen_types.h" /* SPACE_VIEW3D, SPACE_SEQ */
|
|
|
|
|
#include "BKE_depsgraph.h"
|
|
|
|
|
#include "BKE_library.h"
|
|
|
|
|
#include "BKE_scene.h"
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
#include "BSE_drawview.h" /* for play_anim */
|
|
|
|
|
#include "BSE_headerbuttons.h" /* for copy_scene */
|
|
|
|
|
#include "BIF_drawscene.h" /* for set_scene */
|
|
|
|
|
#include "BIF_space.h" /* for copy_view3d_lock() */
|
|
|
|
|
#include "BIF_screen.h" /* curarea */
|
|
|
|
|
#include "mydevice.h" /* for #define REDRAW */
|
|
|
|
|
#include "DNA_view3d_types.h"
|
2003-06-09 04:01:48 +00:00
|
|
|
#include "Object.h"
|
2005-08-21 15:00:17 +00:00
|
|
|
#include "Camera.h"
|
2004-04-25 05:18:43 +00:00
|
|
|
#include "gen_utils.h"
|
|
|
|
|
#include "sceneRender.h"
|
BPython:
- new submodule Scene.Radio, for radiosity: still incomplete, but in shape for demos, updated SConscript to include it;
- new functions in Window module;
- doc updates: adding a todo file and a new start page for our docs: API_intro.py + other updates;
- small fix in Ipo.c provided by Damien McGuinnes (thanks!): Nathan has a patch with IPO additions and fixes for this and more, but until it is committed, there's this fix for Ipo.getCurve('LocX'), LocY, Z and QuatW,X,Y,Z too, according to Damien.
Other files:
- radpreprocess.c: added check for "during_script()" so eventual msgs don't popup during scripts;
- drawmesh.c: made a pointer (display list) be checked before accessed, fixes crash in scripts that forget to update display lists for subsurf meshes when a 3d view is in textured view mode.
Script: updated bevel_center by Loic Berthe.
2004-07-25 16:55:45 +00:00
|
|
|
#include "sceneRadio.h"
|
2005-08-05 17:47:48 +00:00
|
|
|
#include "sceneTimeLine.h"
|
2003-06-07 03:49:45 +00:00
|
|
|
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
static Base *EXPP_Scene_getObjectBase( Scene * scene, Object * object );
|
|
|
|
|
PyObject *M_Object_Get( PyObject * self, PyObject * args ); /* from Object.c */
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
//----------------------------------- Python BPy_Scene defaults------------
|
2005-03-31 18:49:52 +00:00
|
|
|
#define EXPP_SCENE_FRAME_MAX 30000
|
2003-07-12 18:02:54 +00:00
|
|
|
#define EXPP_SCENE_RENDER_WINRESOLUTION_MIN 4
|
|
|
|
|
#define EXPP_SCENE_RENDER_WINRESOLUTION_MAX 10000
|
2004-09-25 20:30:40 +00:00
|
|
|
//-----------------------Python API function prototypes for the Scene module--
|
|
|
|
|
static PyObject *M_Scene_New( PyObject * self, PyObject * args,
|
|
|
|
|
PyObject * keywords );
|
|
|
|
|
static PyObject *M_Scene_Get( PyObject * self, PyObject * args );
|
|
|
|
|
static PyObject *M_Scene_GetCurrent( PyObject * self );
|
|
|
|
|
static PyObject *M_Scene_Unlink( PyObject * self, PyObject * arg );
|
|
|
|
|
//-----------------------Scene module doc strings-----------------------------
|
|
|
|
|
static char M_Scene_doc[] = "The Blender.Scene submodule";
|
2003-07-12 18:02:54 +00:00
|
|
|
static char M_Scene_New_doc[] =
|
2004-09-25 20:30:40 +00:00
|
|
|
"(name = 'Scene') - Create a new Scene called 'name' in Blender.";
|
2003-07-12 18:02:54 +00:00
|
|
|
static char M_Scene_Get_doc[] =
|
2004-09-25 20:30:40 +00:00
|
|
|
"(name = None) - Return the scene called 'name'. If 'name' is None, return a list with all Scenes.";
|
2003-07-12 18:02:54 +00:00
|
|
|
static char M_Scene_GetCurrent_doc[] =
|
2004-09-25 20:30:40 +00:00
|
|
|
"() - Return the currently active Scene in Blender.";
|
2003-07-12 18:02:54 +00:00
|
|
|
static char M_Scene_Unlink_doc[] =
|
2004-09-25 20:30:40 +00:00
|
|
|
"(scene) - Unlink (delete) scene 'Scene' from Blender. (scene) is of type Blender scene.";
|
|
|
|
|
//----------------------Scene module method def----------------------------
|
2003-06-07 03:49:45 +00:00
|
|
|
struct PyMethodDef M_Scene_methods[] = {
|
2004-09-25 20:30:40 +00:00
|
|
|
{"New", ( PyCFunction ) M_Scene_New, METH_VARARGS | METH_KEYWORDS,
|
|
|
|
|
M_Scene_New_doc},
|
|
|
|
|
{"Get", M_Scene_Get, METH_VARARGS, M_Scene_Get_doc},
|
|
|
|
|
{"get", M_Scene_Get, METH_VARARGS, M_Scene_Get_doc},
|
|
|
|
|
{"GetCurrent", ( PyCFunction ) M_Scene_GetCurrent,
|
|
|
|
|
METH_NOARGS, M_Scene_GetCurrent_doc},
|
|
|
|
|
{"getCurrent", ( PyCFunction ) M_Scene_GetCurrent,
|
|
|
|
|
METH_NOARGS, M_Scene_GetCurrent_doc},
|
|
|
|
|
{"Unlink", M_Scene_Unlink, METH_VARARGS, M_Scene_Unlink_doc},
|
|
|
|
|
{"unlink", M_Scene_Unlink, METH_VARARGS, M_Scene_Unlink_doc},
|
2003-10-24 17:08:59 +00:00
|
|
|
{NULL, NULL, 0, NULL}
|
2003-06-07 03:49:45 +00:00
|
|
|
};
|
2004-09-25 20:30:40 +00:00
|
|
|
//-----------------------BPy_Scene method declarations--------------------
|
|
|
|
|
static PyObject *Scene_getName( BPy_Scene * self );
|
|
|
|
|
static PyObject *Scene_setName( BPy_Scene * self, PyObject * arg );
|
2005-04-21 19:44:52 +00:00
|
|
|
static PyObject *Scene_getLayers( BPy_Scene * self );
|
|
|
|
|
static PyObject *Scene_setLayers( BPy_Scene * self, PyObject * arg );
|
|
|
|
|
static PyObject *Scene_setLayersMask( BPy_Scene * self, PyObject * arg );
|
2004-09-25 20:30:40 +00:00
|
|
|
static PyObject *Scene_copy( BPy_Scene * self, PyObject * arg );
|
|
|
|
|
static PyObject *Scene_makeCurrent( BPy_Scene * self );
|
|
|
|
|
static PyObject *Scene_update( BPy_Scene * self, PyObject * args );
|
|
|
|
|
static PyObject *Scene_link( BPy_Scene * self, PyObject * args );
|
|
|
|
|
static PyObject *Scene_unlink( BPy_Scene * self, PyObject * args );
|
|
|
|
|
static PyObject *Scene_getChildren( BPy_Scene * self );
|
2005-05-20 05:14:03 +00:00
|
|
|
static PyObject *Scene_getActiveObject(BPy_Scene *self);
|
2004-09-25 20:30:40 +00:00
|
|
|
static PyObject *Scene_getCurrentCamera( BPy_Scene * self );
|
|
|
|
|
static PyObject *Scene_setCurrentCamera( BPy_Scene * self, PyObject * args );
|
|
|
|
|
static PyObject *Scene_getRenderingContext( BPy_Scene * self );
|
|
|
|
|
static PyObject *Scene_getRadiosityContext( BPy_Scene * self );
|
|
|
|
|
static PyObject *Scene_getScriptLinks( BPy_Scene * self, PyObject * args );
|
|
|
|
|
static PyObject *Scene_addScriptLink( BPy_Scene * self, PyObject * args );
|
2005-04-21 19:44:52 +00:00
|
|
|
static PyObject *Scene_clearScriptLinks( BPy_Scene * self, PyObject * args );
|
2004-09-25 20:30:40 +00:00
|
|
|
static PyObject *Scene_play( BPy_Scene * self, PyObject * args );
|
2005-08-05 17:47:48 +00:00
|
|
|
static PyObject *Scene_getTimeLine( BPy_Scene * self );
|
|
|
|
|
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-04-25 05:18:43 +00:00
|
|
|
//internal
|
2004-09-25 20:30:40 +00:00
|
|
|
static void Scene_dealloc( BPy_Scene * self );
|
|
|
|
|
static int Scene_setAttr( BPy_Scene * self, char *name, PyObject * v );
|
|
|
|
|
static int Scene_compare( BPy_Scene * a, BPy_Scene * b );
|
|
|
|
|
static PyObject *Scene_getAttr( BPy_Scene * self, char *name );
|
|
|
|
|
static PyObject *Scene_repr( BPy_Scene * self );
|
|
|
|
|
//-----------------------BPy_Scene method def------------------------------
|
2003-06-07 03:49:45 +00:00
|
|
|
static PyMethodDef BPy_Scene_methods[] = {
|
2004-09-25 20:30:40 +00:00
|
|
|
/* name, method, flags, doc */
|
|
|
|
|
{"getName", ( PyCFunction ) Scene_getName, METH_NOARGS,
|
|
|
|
|
"() - Return Scene name"},
|
|
|
|
|
{"setName", ( PyCFunction ) Scene_setName, METH_VARARGS,
|
|
|
|
|
"(str) - Change Scene name"},
|
2005-04-21 19:44:52 +00:00
|
|
|
{"getLayers", ( PyCFunction ) Scene_getLayers, METH_NOARGS,
|
2005-05-20 05:14:03 +00:00
|
|
|
"() - Return a list of layers int indices which are set in this scene "},
|
2005-04-21 19:44:52 +00:00
|
|
|
{"setLayers", ( PyCFunction ) Scene_setLayers, METH_VARARGS,
|
2005-05-20 05:14:03 +00:00
|
|
|
"(layers) - Change layers which are set in this scene\n"
|
2005-04-21 19:44:52 +00:00
|
|
|
"(layers) - list of integers in the range [1, 20]."},
|
2004-09-25 20:30:40 +00:00
|
|
|
{"copy", ( PyCFunction ) Scene_copy, METH_VARARGS,
|
|
|
|
|
"(duplicate_objects = 1) - Return a copy of this scene\n"
|
|
|
|
|
"The optional argument duplicate_objects defines how the scene\n"
|
|
|
|
|
"children are duplicated:\n\t0: Link Objects\n\t1: Link Object Data"
|
|
|
|
|
"\n\t2: Full copy\n"},
|
|
|
|
|
{"makeCurrent", ( PyCFunction ) Scene_makeCurrent, METH_NOARGS,
|
|
|
|
|
"() - Make self the current scene"},
|
|
|
|
|
{"update", ( PyCFunction ) Scene_update, METH_VARARGS,
|
|
|
|
|
"(full = 0) - Update scene self.\n"
|
|
|
|
|
"full = 0: sort the base list of objects."
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
"full = 1: full update -- also regroups, does ipos, keys"},
|
2004-09-25 20:30:40 +00:00
|
|
|
{"link", ( PyCFunction ) Scene_link, METH_VARARGS,
|
|
|
|
|
"(obj) - Link Object obj to this scene"},
|
|
|
|
|
{"unlink", ( PyCFunction ) Scene_unlink, METH_VARARGS,
|
|
|
|
|
"(obj) - Unlink Object obj from this scene"},
|
|
|
|
|
{"getChildren", ( PyCFunction ) Scene_getChildren, METH_NOARGS,
|
2005-05-20 05:14:03 +00:00
|
|
|
"() - Return list of all objects linked to this scene"},
|
|
|
|
|
{"getActiveObject", (PyCFunction)Scene_getActiveObject, METH_NOARGS,
|
|
|
|
|
"() - Return this scene's active object"},
|
2004-09-25 20:30:40 +00:00
|
|
|
{"getCurrentCamera", ( PyCFunction ) Scene_getCurrentCamera,
|
|
|
|
|
METH_NOARGS,
|
|
|
|
|
"() - Return current active Camera"},
|
|
|
|
|
{"getScriptLinks", ( PyCFunction ) Scene_getScriptLinks, METH_VARARGS,
|
|
|
|
|
"(eventname) - Get a list of this scene's scriptlinks (Text names) "
|
|
|
|
|
"of the given type\n"
|
2005-05-27 05:39:41 +00:00
|
|
|
"(eventname) - string: FrameChanged, OnLoad, OnSave, Redraw or Render."},
|
2004-09-25 20:30:40 +00:00
|
|
|
{"addScriptLink", ( PyCFunction ) Scene_addScriptLink, METH_VARARGS,
|
|
|
|
|
"(text, evt) - Add a new scene scriptlink.\n"
|
|
|
|
|
"(text) - string: an existing Blender Text name;\n"
|
2005-05-27 05:39:41 +00:00
|
|
|
"(evt) string: FrameChanged, OnLoad, OnSave, Redraw or Render."},
|
2004-09-25 20:30:40 +00:00
|
|
|
{"clearScriptLinks", ( PyCFunction ) Scene_clearScriptLinks,
|
2005-04-21 19:44:52 +00:00
|
|
|
METH_VARARGS,
|
|
|
|
|
"() - Delete all scriptlinks from this scene.\n"
|
|
|
|
|
"([s1<,s2,s3...>]) - Delete specified scriptlinks from this scene."},
|
2004-09-25 20:30:40 +00:00
|
|
|
{"setCurrentCamera", ( PyCFunction ) Scene_setCurrentCamera,
|
|
|
|
|
METH_VARARGS,
|
|
|
|
|
"() - Set the currently active Camera"},
|
|
|
|
|
{"getRenderingContext", ( PyCFunction ) Scene_getRenderingContext,
|
|
|
|
|
METH_NOARGS,
|
|
|
|
|
"() - Get the rendering context for the scene and return it as a BPy_RenderData"},
|
|
|
|
|
{"getRadiosityContext", ( PyCFunction ) Scene_getRadiosityContext,
|
|
|
|
|
METH_NOARGS,
|
|
|
|
|
"() - Get the radiosity context for this scene."},
|
|
|
|
|
{"play", ( PyCFunction ) Scene_play, METH_VARARGS,
|
|
|
|
|
"(mode = 0, win = VIEW3D) - Play realtime animation in Blender"
|
|
|
|
|
" (not rendered).\n"
|
|
|
|
|
"(mode) - int:\n"
|
|
|
|
|
"\t0 - keep playing in biggest given 'win';\n"
|
|
|
|
|
"\t1 - keep playing in all 'win', VIEW3D and SEQ windows;\n"
|
|
|
|
|
"\t2 - play once in biggest given 'win';\n"
|
|
|
|
|
"\t3 - play once in all 'win', VIEW3D and SEQ windows.\n"
|
|
|
|
|
"(win) - int: see Blender.Window.Types. Only these are meaningful here:"
|
|
|
|
|
"VIEW3D, SEQ, IPO, ACTION, NLA, SOUND. But others are also accepted, "
|
|
|
|
|
"since they can be used just as an interruptible timer. If 'win' is not"
|
|
|
|
|
"available or invalid, VIEW3D is tried, then any bigger window."
|
|
|
|
|
"Returns 0 for normal exit or 1 when canceled by user input."},
|
2005-08-05 17:47:48 +00:00
|
|
|
{"getTimeLine", ( PyCFunction ) Scene_getTimeLine, METH_NOARGS,
|
|
|
|
|
"() - Get time line of this Scene"},
|
2004-06-06 22:42:51 +00:00
|
|
|
{NULL, NULL, 0, NULL}
|
2003-06-07 03:49:45 +00:00
|
|
|
};
|
2004-09-25 20:30:40 +00:00
|
|
|
//-----------------------BPy_Scene method def------------------------------
|
|
|
|
|
PyTypeObject Scene_Type = {
|
|
|
|
|
PyObject_HEAD_INIT( NULL )
|
|
|
|
|
0, /* ob_size */
|
|
|
|
|
"Scene", /* tp_name */
|
|
|
|
|
sizeof( BPy_Scene ), /* tp_basicsize */
|
|
|
|
|
0, /* tp_itemsize */
|
2003-10-24 17:08:59 +00:00
|
|
|
/* methods */
|
2004-09-25 20:30:40 +00:00
|
|
|
( destructor ) Scene_dealloc, /* tp_dealloc */
|
|
|
|
|
0, /* tp_print */
|
|
|
|
|
( getattrfunc ) Scene_getAttr, /* tp_getattr */
|
|
|
|
|
( setattrfunc ) Scene_setAttr, /* tp_setattr */
|
|
|
|
|
( cmpfunc ) Scene_compare, /* tp_compare */
|
|
|
|
|
( reprfunc ) Scene_repr, /* tp_repr */
|
|
|
|
|
0, /* tp_as_number */
|
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
|
0, /* tp_as_hash */
|
|
|
|
|
0, 0, 0, 0, 0, 0,
|
|
|
|
|
0, /* tp_doc */
|
|
|
|
|
0, 0, 0, 0, 0, 0,
|
|
|
|
|
BPy_Scene_methods, /* tp_methods */
|
|
|
|
|
0, /* tp_members */
|
2005-04-21 19:44:52 +00:00
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
2003-06-07 03:49:45 +00:00
|
|
|
};
|
2004-09-25 20:30:40 +00:00
|
|
|
//-----------------------Scene module Init())-----------------------------
|
|
|
|
|
PyObject *Scene_Init( void )
|
2004-04-25 05:18:43 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
PyObject *submodule;
|
|
|
|
|
PyObject *dict;
|
2004-04-25 05:18:43 +00:00
|
|
|
|
|
|
|
|
Scene_Type.ob_type = &PyType_Type;
|
2004-09-25 20:30:40 +00:00
|
|
|
submodule =
|
|
|
|
|
Py_InitModule3( "Blender.Scene", M_Scene_methods,
|
|
|
|
|
M_Scene_doc );
|
2004-04-25 05:18:43 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
dict = PyModule_GetDict( submodule );
|
|
|
|
|
PyDict_SetItemString( dict, "Render", Render_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Radio", Radio_Init( ) );
|
2004-04-25 05:18:43 +00:00
|
|
|
|
|
|
|
|
return submodule;
|
|
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------Scene module internal callbacks------------------
|
|
|
|
|
//-----------------------dealloc------------------------------------------
|
|
|
|
|
static void Scene_dealloc( BPy_Scene * self )
|
2004-04-25 05:18:43 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
PyObject_DEL( self );
|
2004-04-25 05:18:43 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------getAttr----------------------------------------
|
|
|
|
|
static PyObject *Scene_getAttr( BPy_Scene * self, char *name )
|
2004-04-25 05:18:43 +00:00
|
|
|
{
|
|
|
|
|
PyObject *attr = Py_None;
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( strcmp( name, "name" ) == 0 )
|
|
|
|
|
attr = PyString_FromString( self->scene->id.name + 2 );
|
2005-04-21 19:44:52 +00:00
|
|
|
/* accept both Layer (for compatibility with ob.Layer) and Layers */
|
|
|
|
|
else if( strncmp( name, "Layer", 5 ) == 0 )
|
|
|
|
|
attr = PyInt_FromLong( self->scene->lay );
|
|
|
|
|
/* Layers returns a bitmask, layers returns a list of integers */
|
|
|
|
|
else if( strcmp( name, "layers") == 0) {
|
|
|
|
|
return Scene_getLayers(self);
|
|
|
|
|
}
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
else if( strcmp( name, "__members__" ) == 0 )
|
2005-04-21 19:44:52 +00:00
|
|
|
attr = Py_BuildValue( "[ss]", "name", "Layers", "layers" );
|
2004-04-25 05:18:43 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !attr )
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
|
|
|
|
|
"couldn't create PyObject" ) );
|
2004-04-25 05:18:43 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( attr != Py_None )
|
|
|
|
|
return attr; /* member attribute found, return it */
|
2004-04-25 05:18:43 +00:00
|
|
|
|
|
|
|
|
/* not an attribute, search the methods table */
|
2004-09-25 20:30:40 +00:00
|
|
|
return Py_FindMethod( BPy_Scene_methods, ( PyObject * ) self, name );
|
2004-04-25 05:18:43 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------setAttr----------------------------------------
|
|
|
|
|
static int Scene_setAttr( BPy_Scene * self, char *name, PyObject * value )
|
2004-04-25 05:18:43 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
PyObject *valtuple;
|
2004-04-25 05:18:43 +00:00
|
|
|
PyObject *error = NULL;
|
|
|
|
|
|
|
|
|
|
/* We're playing a trick on the Python API users here. Even if they use
|
|
|
|
|
* Scene.member = val instead of Scene.setMember(val), we end up using the
|
|
|
|
|
* function anyway, since it already has error checking, clamps to the right
|
|
|
|
|
* interval and updates the Blender Scene structure when necessary. */
|
|
|
|
|
|
|
|
|
|
/* First we put "value" in a tuple, because we want to pass it to functions
|
|
|
|
|
* that only accept PyTuples. Using "N" doesn't increment value's ref count */
|
2004-09-25 20:30:40 +00:00
|
|
|
valtuple = Py_BuildValue( "(O)", value );
|
2004-04-25 05:18:43 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !valtuple ) /* everything OK with our PyObject? */
|
|
|
|
|
return EXPP_ReturnIntError( PyExc_MemoryError,
|
|
|
|
|
"SceneSetAttr: couldn't create PyTuple" );
|
2004-04-25 05:18:43 +00:00
|
|
|
|
|
|
|
|
/* Now we just compare "name" with all possible BPy_Scene member variables */
|
2004-09-25 20:30:40 +00:00
|
|
|
if( strcmp( name, "name" ) == 0 )
|
|
|
|
|
error = Scene_setName( self, valtuple );
|
2005-04-21 19:44:52 +00:00
|
|
|
else if (strncmp(name, "Layer", 5) == 0)
|
|
|
|
|
error = Scene_setLayersMask(self, valtuple);
|
|
|
|
|
else if (strcmp(name, "layers") == 0)
|
|
|
|
|
error = Scene_setLayers(self, valtuple);
|
2004-04-25 05:18:43 +00:00
|
|
|
|
2005-04-21 19:44:52 +00:00
|
|
|
else { /* Error: no member with the given name was found */
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_DECREF( valtuple );
|
|
|
|
|
return ( EXPP_ReturnIntError( PyExc_AttributeError, name ) );
|
2004-04-25 05:18:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* valtuple won't be returned to the caller, so we need to DECREF it */
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_DECREF( valtuple );
|
2004-04-25 05:18:43 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( error != Py_None )
|
|
|
|
|
return -1;
|
2004-04-25 05:18:43 +00:00
|
|
|
|
|
|
|
|
/* Py_None was incref'ed by the called Scene_set* function. We probably
|
|
|
|
|
* don't need to decref Py_None (!), but since Python/C API manual tells us
|
|
|
|
|
* to treat it like any other PyObject regarding ref counting ... */
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_DECREF( Py_None );
|
|
|
|
|
return 0; /* normal exit */
|
2004-04-25 05:18:43 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------compare----------------------------------------
|
|
|
|
|
static int Scene_compare( BPy_Scene * a, BPy_Scene * b )
|
2004-04-25 05:18:43 +00:00
|
|
|
{
|
|
|
|
|
Scene *pa = a->scene, *pb = b->scene;
|
2004-09-25 20:30:40 +00:00
|
|
|
return ( pa == pb ) ? 0 : -1;
|
2004-04-25 05:18:43 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//----------------------repr--------------------------------------------
|
|
|
|
|
static PyObject *Scene_repr( BPy_Scene * self )
|
2004-04-25 05:18:43 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
return PyString_FromFormat( "[Scene \"%s\"]",
|
|
|
|
|
self->scene->id.name + 2 );
|
2004-04-25 05:18:43 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------CreatePyObject---------------------------------
|
|
|
|
|
PyObject *Scene_CreatePyObject( Scene * scene )
|
2004-04-25 05:18:43 +00:00
|
|
|
{
|
|
|
|
|
BPy_Scene *pyscene;
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
pyscene = ( BPy_Scene * ) PyObject_NEW( BPy_Scene, &Scene_Type );
|
2004-04-25 05:18:43 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !pyscene )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_MemoryError,
|
|
|
|
|
"couldn't create BPy_Scene object" );
|
2004-04-25 05:18:43 +00:00
|
|
|
|
|
|
|
|
pyscene->scene = scene;
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
return ( PyObject * ) pyscene;
|
2004-04-25 05:18:43 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------CheckPyObject----------------------------------
|
|
|
|
|
int Scene_CheckPyObject( PyObject * pyobj )
|
2004-04-25 05:18:43 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
return ( pyobj->ob_type == &Scene_Type );
|
2004-04-25 05:18:43 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------FromPyObject-----------------------------------
|
|
|
|
|
Scene *Scene_FromPyObject( PyObject * pyobj )
|
2004-04-25 05:18:43 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
return ( ( BPy_Scene * ) pyobj )->scene;
|
2004-04-25 05:18:43 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------GetSceneByName()-------------------------------
|
2004-04-25 05:18:43 +00:00
|
|
|
/* Description: Returns the object with the name specified by the argument name.
|
|
|
|
|
Note that the calling function has to remove the first two characters of the object name.
|
|
|
|
|
These two characters specify the type of the object (OB, ME, WO, ...)The function
|
|
|
|
|
will return NULL when no object with the given name is found. */
|
2004-09-25 20:30:40 +00:00
|
|
|
Scene *GetSceneByName( char *name )
|
2004-04-25 05:18:43 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
Scene *scene_iter;
|
2004-04-25 05:18:43 +00:00
|
|
|
|
|
|
|
|
scene_iter = G.main->scene.first;
|
2004-09-25 20:30:40 +00:00
|
|
|
while( scene_iter ) {
|
|
|
|
|
if( StringEqual( name, GetIdName( &( scene_iter->id ) ) ) ) {
|
|
|
|
|
return ( scene_iter );
|
2004-04-25 05:18:43 +00:00
|
|
|
}
|
|
|
|
|
scene_iter = scene_iter->id.next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* There is no object with the given name */
|
2004-09-25 20:30:40 +00:00
|
|
|
return ( NULL );
|
2004-04-25 05:18:43 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------EXPP_Scene_getObjectBase()---------------------
|
|
|
|
|
Base *EXPP_Scene_getObjectBase( Scene * scene, Object * object )
|
2004-04-25 05:18:43 +00:00
|
|
|
{
|
|
|
|
|
Base *base = scene->base.first;
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
while( base ) {
|
2004-04-25 05:18:43 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( object == base->object )
|
|
|
|
|
return base; /* found it? */
|
2004-04-25 05:18:43 +00:00
|
|
|
|
|
|
|
|
base = base->next;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
return NULL; /* object isn't linked to this scene */
|
2004-04-25 05:18:43 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------Scene module function defintions---------------
|
|
|
|
|
//-----------------------Scene.New()------------------------------------
|
|
|
|
|
static PyObject *M_Scene_New( PyObject * self, PyObject * args,
|
|
|
|
|
PyObject * kword )
|
2003-06-07 03:49:45 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
char *name = "Scene";
|
|
|
|
|
char *kw[] = { "name", NULL };
|
|
|
|
|
PyObject *pyscene; /* for the Scene object wrapper in Python */
|
|
|
|
|
Scene *blscene; /* for the actual Scene we create in Blender */
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !PyArg_ParseTupleAndKeywords( args, kword, "|s", kw, &name ) )
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
|
|
|
|
|
"expected a string or an empty argument list" ) );
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
blscene = add_scene( name ); /* first create the Scene in Blender */
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( blscene ) {
|
|
|
|
|
/* normally, for most objects, we set the user count to zero here.
|
|
|
|
|
* Scene is different than most objs since it is the container
|
|
|
|
|
* for all the others. Since add_scene() has already set
|
|
|
|
|
* the user count to one, we leave it alone.
|
|
|
|
|
*/
|
2003-11-12 07:46:07 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
/* now create the wrapper obj in Python */
|
|
|
|
|
pyscene = Scene_CreatePyObject( blscene );
|
|
|
|
|
} else
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"couldn't create Scene obj in Blender" ) );
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( pyscene == NULL )
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
|
|
|
|
|
"couldn't create Scene PyObject" ) );
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2003-10-24 17:08:59 +00:00
|
|
|
return pyscene;
|
2003-06-07 03:49:45 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------Scene.Get()------------------------------------
|
|
|
|
|
static PyObject *M_Scene_Get( PyObject * self, PyObject * args )
|
2003-06-07 03:49:45 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
char *name = NULL;
|
2003-10-24 17:08:59 +00:00
|
|
|
Scene *scene_iter;
|
2003-06-07 03:49:45 +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-06-07 03:49:45 +00:00
|
|
|
|
2003-10-24 17:08:59 +00:00
|
|
|
scene_iter = G.main->scene.first;
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( name ) { /* (name) - Search scene by name */
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2003-10-24 17:08:59 +00:00
|
|
|
PyObject *wanted_scene = NULL;
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
while( ( scene_iter ) && ( wanted_scene == NULL ) ) {
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( strcmp( name, scene_iter->id.name + 2 ) == 0 )
|
|
|
|
|
wanted_scene =
|
|
|
|
|
Scene_CreatePyObject( scene_iter );
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2003-10-24 17:08:59 +00:00
|
|
|
scene_iter = scene_iter->id.next;
|
|
|
|
|
}
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( wanted_scene == NULL ) { /* Requested scene doesn't exist */
|
2003-10-24 17:08:59 +00:00
|
|
|
char error_msg[64];
|
2004-09-25 20:30:40 +00:00
|
|
|
PyOS_snprintf( error_msg, sizeof( error_msg ),
|
|
|
|
|
"Scene \"%s\" not found", name );
|
|
|
|
|
return ( EXPP_ReturnPyObjError
|
|
|
|
|
( PyExc_NameError, error_msg ) );
|
2003-10-24 17:08:59 +00:00
|
|
|
}
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2003-10-24 17:08:59 +00:00
|
|
|
return wanted_scene;
|
|
|
|
|
}
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
else { /* () - return a list with wrappers for all scenes in Blender */
|
2003-10-24 17:08:59 +00:00
|
|
|
int index = 0;
|
|
|
|
|
PyObject *sce_pylist, *pyobj;
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
sce_pylist = PyList_New( BLI_countlist( &( G.main->scene ) ) );
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( sce_pylist == NULL )
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
|
|
|
|
|
"couldn't create PyList" ) );
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
while( scene_iter ) {
|
|
|
|
|
pyobj = Scene_CreatePyObject( scene_iter );
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !pyobj )
|
|
|
|
|
return ( EXPP_ReturnPyObjError
|
|
|
|
|
( PyExc_MemoryError,
|
|
|
|
|
"couldn't create PyString" ) );
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
PyList_SET_ITEM( sce_pylist, index, pyobj );
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2003-10-24 17:08:59 +00:00
|
|
|
scene_iter = scene_iter->id.next;
|
|
|
|
|
index++;
|
|
|
|
|
}
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2003-10-24 17:08:59 +00:00
|
|
|
return sce_pylist;
|
|
|
|
|
}
|
2003-06-07 03:49:45 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------Scene.GetCurrent()------------------------------
|
|
|
|
|
static PyObject *M_Scene_GetCurrent( PyObject * self )
|
2003-06-07 03:49:45 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
return Scene_CreatePyObject( ( Scene * ) G.scene );
|
2003-06-07 03:49:45 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------Scene.Unlink()----------------------------------
|
|
|
|
|
static PyObject *M_Scene_Unlink( PyObject * self, PyObject * args )
|
|
|
|
|
{
|
2003-10-24 17:08:59 +00:00
|
|
|
PyObject *pyobj;
|
2004-09-25 20:30:40 +00:00
|
|
|
Scene *scene;
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !PyArg_ParseTuple( args, "O!", &Scene_Type, &pyobj ) )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
|
|
|
|
"expected Scene PyType object" );
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
scene = ( ( BPy_Scene * ) pyobj )->scene;
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( scene == G.scene )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_SystemError,
|
|
|
|
|
"current Scene cannot be removed!" );
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
free_libblock( &G.main->scene, scene );
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_INCREF( Py_None );
|
2003-10-24 17:08:59 +00:00
|
|
|
return Py_None;
|
2003-06-07 03:49:45 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------BPy_Scene function defintions-------------------
|
|
|
|
|
//-----------------------Scene.getName()---------------------------------
|
|
|
|
|
static PyObject *Scene_getName( BPy_Scene * self )
|
2003-06-07 03:49:45 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
PyObject *attr = PyString_FromString( self->scene->id.name + 2 );
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( attr )
|
|
|
|
|
return attr;
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"couldn't get Scene.name attribute" ) );
|
2003-06-07 03:49:45 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------Scene.setName()---------------------------------
|
|
|
|
|
static PyObject *Scene_setName( BPy_Scene * self, PyObject * args )
|
2003-06-07 03:49:45 +00:00
|
|
|
{
|
2003-10-24 17:08:59 +00:00
|
|
|
char *name;
|
|
|
|
|
char buf[21];
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !PyArg_ParseTuple( args, "s", &name ) )
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
|
|
|
|
|
"expected string argument" ) );
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
PyOS_snprintf( buf, sizeof( buf ), "%s", name );
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
rename_id( &self->scene->id, buf );
|
2003-06-07 03:49:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_INCREF( Py_None );
|
2003-10-24 17:08:59 +00:00
|
|
|
return Py_None;
|
2003-06-07 03:49:45 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
2005-04-21 19:44:52 +00:00
|
|
|
//-----------------------Scene.getLayers()---------------------------------
|
|
|
|
|
static PyObject *Scene_getLayers( BPy_Scene * self )
|
|
|
|
|
{
|
|
|
|
|
PyObject *laylist = PyList_New( 0 ), *item;
|
|
|
|
|
int layers, bit = 0, val = 0;
|
|
|
|
|
|
|
|
|
|
if( !laylist )
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
|
|
|
|
|
"couldn't create pylist!" ) );
|
|
|
|
|
|
|
|
|
|
layers = self->scene->lay;
|
|
|
|
|
|
|
|
|
|
while( bit < 20 ) {
|
|
|
|
|
val = 1 << bit;
|
|
|
|
|
if( layers & val ) {
|
|
|
|
|
item = Py_BuildValue( "i", bit + 1 );
|
|
|
|
|
PyList_Append( laylist, item );
|
|
|
|
|
Py_DECREF( item );
|
|
|
|
|
}
|
|
|
|
|
bit++;
|
|
|
|
|
}
|
|
|
|
|
return laylist;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-----------------------Scene.setLayers()---------------------------------
|
|
|
|
|
static PyObject *Scene_setLayers( BPy_Scene * self, PyObject * args )
|
|
|
|
|
{
|
|
|
|
|
PyObject *list = NULL, *item = NULL;
|
|
|
|
|
int layers = 0, val, i, len_list;
|
|
|
|
|
|
|
|
|
|
if( !PyArg_ParseTuple( args, "O!", &PyList_Type, &list ) )
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
|
|
|
|
|
"expected a list of integers in the range [1, 20]" ) );
|
|
|
|
|
|
|
|
|
|
len_list = PyList_Size(list);
|
|
|
|
|
|
|
|
|
|
if (len_list == 0)
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
|
|
|
|
|
"list can't be empty, at least one layer must be set" ) );
|
|
|
|
|
|
|
|
|
|
for( i = 0; i < len_list; i++ ) {
|
|
|
|
|
item = PyList_GetItem( list, i );
|
|
|
|
|
if( !PyInt_Check( item ) )
|
|
|
|
|
return EXPP_ReturnPyObjError
|
|
|
|
|
( PyExc_AttributeError,
|
|
|
|
|
"list must contain only integer numbers" );
|
|
|
|
|
|
|
|
|
|
val = ( int ) PyInt_AsLong( item );
|
|
|
|
|
if( val < 1 || val > 20 )
|
|
|
|
|
return EXPP_ReturnPyObjError
|
|
|
|
|
( PyExc_AttributeError,
|
|
|
|
|
"layer values must be in the range [1, 20]" );
|
|
|
|
|
|
|
|
|
|
layers |= 1 << ( val - 1 );
|
|
|
|
|
}
|
|
|
|
|
self->scene->lay = layers;
|
|
|
|
|
|
|
|
|
|
if (G.vd && (self->scene == G.scene)) {
|
|
|
|
|
int bit = 0;
|
|
|
|
|
G.vd->lay = layers;
|
|
|
|
|
|
|
|
|
|
while( bit < 20 ) {
|
|
|
|
|
val = 1 << bit;
|
|
|
|
|
if( layers & val ) {
|
|
|
|
|
G.vd->layact = val;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
bit++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EXPP_incr_ret(Py_None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* only used by setAttr */
|
|
|
|
|
static PyObject *Scene_setLayersMask(BPy_Scene *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
int laymask = 0;
|
|
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args , "i", &laymask)) {
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
|
|
|
|
"expected an integer (bitmask) as argument" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (laymask <= 0 || laymask > 1048575) /* binary: 1111 1111 1111 1111 1111 */
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
|
|
|
|
"bitmask must have from 1 up to 20 bits set");
|
|
|
|
|
|
|
|
|
|
self->scene->lay = laymask;
|
|
|
|
|
/* if this is the current scene then apply the scene layers value
|
|
|
|
|
* to the view layers value: */
|
|
|
|
|
if (G.vd && (self->scene == G.scene)) {
|
|
|
|
|
int val, bit = 0;
|
|
|
|
|
G.vd->lay = laymask;
|
|
|
|
|
|
|
|
|
|
while( bit < 20 ) {
|
|
|
|
|
val = 1 << bit;
|
|
|
|
|
if( laymask & val ) {
|
|
|
|
|
G.vd->layact = val;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
bit++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EXPP_incr_ret(Py_None);
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
//-----------------------Scene.copy()------------------------------------
|
|
|
|
|
static PyObject *Scene_copy( BPy_Scene * self, PyObject * args )
|
2003-06-09 04:01:48 +00:00
|
|
|
{
|
2003-10-24 17:08:59 +00:00
|
|
|
short dup_objs = 1;
|
|
|
|
|
Scene *scene = self->scene;
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !scene )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"Blender Scene was deleted!" );
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !PyArg_ParseTuple( args, "|h", &dup_objs ) )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
|
|
|
|
"expected int in [0,2] or nothing as argument" );
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
return Scene_CreatePyObject( copy_scene( scene, dup_objs ) );
|
2003-06-09 04:01:48 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------Scene.makeCurrent()-----------------------------
|
|
|
|
|
static PyObject *Scene_makeCurrent( BPy_Scene * self )
|
2003-06-09 04:01:48 +00:00
|
|
|
{
|
2003-10-24 17:08:59 +00:00
|
|
|
Scene *scene = self->scene;
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( scene )
|
|
|
|
|
set_scene( scene );
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_INCREF( Py_None );
|
2003-10-24 17:08:59 +00:00
|
|
|
return Py_None;
|
2003-06-09 04:01:48 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------Scene.update()----------------------------------
|
|
|
|
|
static PyObject *Scene_update( BPy_Scene * self, PyObject * args )
|
2003-06-09 04:01:48 +00:00
|
|
|
{
|
2003-10-24 17:08:59 +00:00
|
|
|
Scene *scene = self->scene;
|
2003-08-06 19:25:06 +00:00
|
|
|
int full = 0;
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !scene )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"Blender Scene was deleted!" );
|
2003-08-06 19:25:06 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !PyArg_ParseTuple( args, "|i", &full ) )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
|
|
|
|
"expected nothing or int (0 or 1) argument" );
|
2003-08-06 19:25:06 +00:00
|
|
|
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
/* Under certain circunstances, DAG_scene_sort *here* can crash Blender.
|
2003-09-18 00:54:43 +00:00
|
|
|
* A "RuntimeError: max recursion limit" happens when a scriptlink
|
|
|
|
|
* on frame change has scene.update(1).
|
|
|
|
|
* Investigate better how to avoid this. */
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !full )
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
DAG_scene_sort( scene );
|
2003-08-06 19:25:06 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
else if( full == 1 )
|
|
|
|
|
set_scene_bg( scene );
|
2003-08-06 19:25:06 +00:00
|
|
|
|
|
|
|
|
else
|
2004-09-25 20:30:40 +00:00
|
|
|
return EXPP_ReturnPyObjError( PyExc_ValueError,
|
|
|
|
|
"in method scene.update(full), full should be:\n"
|
|
|
|
|
"0: to only sort scene elements (old behavior); or\n"
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
"1: for a full update (regroups, does ipos, keys, etc.)" );
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_INCREF( Py_None );
|
2003-10-24 17:08:59 +00:00
|
|
|
return Py_None;
|
2003-06-09 04:01:48 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------Scene.link()------------------------------------
|
|
|
|
|
static PyObject *Scene_link( BPy_Scene * self, PyObject * args )
|
2003-06-09 04:01:48 +00:00
|
|
|
{
|
2003-10-24 17:08:59 +00:00
|
|
|
Scene *scene = self->scene;
|
|
|
|
|
BPy_Object *bpy_obj;
|
2005-12-29 19:27:52 +00:00
|
|
|
Object *object = NULL;
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !scene )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"Blender Scene was deleted!" );
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !PyArg_ParseTuple( args, "O!", &Object_Type, &bpy_obj ) )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
|
|
|
|
"expected Object argument" );
|
2005-12-29 12:06:42 +00:00
|
|
|
|
|
|
|
|
|
2005-12-29 19:27:52 +00:00
|
|
|
//return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
// "Could not create data on demand for this object type!" );
|
2005-12-29 12:06:42 +00:00
|
|
|
|
2005-12-29 19:27:52 +00:00
|
|
|
object = bpy_obj->object;
|
2005-12-29 12:06:42 +00:00
|
|
|
|
|
|
|
|
/* Object.c's EXPP_add_obdata does not support these objects */
|
|
|
|
|
if (!object->data && (object->type == OB_SURF || object->type == OB_FONT || object->type == OB_WAVE )) {
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"Object has no data and new data cant be automaticaly created for Surf, Text or Wave type objects!" );
|
|
|
|
|
} else {
|
|
|
|
|
/* Ok, all is fine, let's try to link it */
|
2003-10-24 17:08:59 +00:00
|
|
|
Base *base;
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2003-10-24 17:08:59 +00:00
|
|
|
/* We need to link the object to a 'Base', then link this base
|
2004-09-25 20:30:40 +00:00
|
|
|
* to the scene. See DNA_scene_types.h ... */
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2003-10-24 17:08:59 +00:00
|
|
|
/* First, check if the object isn't already in the scene */
|
2004-09-25 20:30:40 +00:00
|
|
|
base = EXPP_Scene_getObjectBase( scene, object );
|
2003-10-24 17:08:59 +00:00
|
|
|
/* if base is not NULL ... */
|
2004-09-25 20:30:40 +00:00
|
|
|
if( base ) /* ... the object is already in one of the Scene Bases */
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"object already in scene!" );
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2003-10-24 17:08:59 +00:00
|
|
|
/* not linked, go get mem for a new base object */
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2005-05-22 07:22:34 +00:00
|
|
|
base = MEM_callocN( sizeof( Base ), "pynewbase" );
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
if( !base )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_MemoryError,
|
|
|
|
|
"couldn't allocate new Base for object" );
|
2003-10-24 17:08:59 +00:00
|
|
|
|
|
|
|
|
/* check if this object has obdata, case not, try to create it */
|
2005-12-29 12:06:42 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !object->data && ( object->type != OB_EMPTY ) )
|
2005-12-29 12:06:42 +00:00
|
|
|
EXPP_add_obdata( object ); /* returns -1 on error, defined in Object.c */
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
base->object = object; /* link object to the new base */
|
2003-10-24 17:08:59 +00:00
|
|
|
base->lay = object->lay;
|
|
|
|
|
base->flag = object->flag;
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
object->id.us += 1; /* incref the object user count in Blender */
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
BLI_addhead( &scene->base, base ); /* finally, link new base to scene */
|
2003-10-24 17:08:59 +00:00
|
|
|
}
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_INCREF( Py_None );
|
2003-10-24 17:08:59 +00:00
|
|
|
return Py_None;
|
2003-06-09 04:01:48 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------Scene.unlink()----------------------------------
|
|
|
|
|
static PyObject *Scene_unlink( BPy_Scene * self, PyObject * args )
|
|
|
|
|
{
|
2003-10-24 17:08:59 +00:00
|
|
|
BPy_Object *bpy_obj = NULL;
|
|
|
|
|
Object *object;
|
|
|
|
|
Scene *scene = self->scene;
|
|
|
|
|
Base *base;
|
|
|
|
|
short retval = 0;
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !scene )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"Blender scene was deleted!" );
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !PyArg_ParseTuple( args, "O!", &Object_Type, &bpy_obj ) )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
|
|
|
|
"expected Object as argument" );
|
2003-10-24 17:08:59 +00:00
|
|
|
|
|
|
|
|
object = bpy_obj->object;
|
|
|
|
|
|
|
|
|
|
/* is the object really in the scene? */
|
2004-09-25 20:30:40 +00:00
|
|
|
base = EXPP_Scene_getObjectBase( scene, object );
|
|
|
|
|
|
|
|
|
|
if( base ) { /* if it is, remove it: */
|
|
|
|
|
BLI_remlink( &scene->base, base );
|
2003-10-24 17:08:59 +00:00
|
|
|
object->id.us -= 1;
|
2004-09-25 20:30:40 +00:00
|
|
|
MEM_freeN( base );
|
|
|
|
|
scene->basact = 0; /* in case the object was selected */
|
2003-10-24 17:08:59 +00:00
|
|
|
retval = 1;
|
|
|
|
|
}
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
return Py_BuildValue( "i", PyInt_FromLong( retval ) );
|
2003-06-09 04:01:48 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------Scene.getChildren()-----------------------------
|
|
|
|
|
static PyObject *Scene_getChildren( BPy_Scene * self )
|
|
|
|
|
{
|
2003-06-09 04:01:48 +00:00
|
|
|
Scene *scene = self->scene;
|
2004-09-25 20:30:40 +00:00
|
|
|
PyObject *pylist = PyList_New( 0 );
|
2003-06-09 04:01:48 +00:00
|
|
|
PyObject *bpy_obj;
|
|
|
|
|
Object *object;
|
|
|
|
|
Base *base;
|
2005-08-21 15:00:17 +00:00
|
|
|
PyObject *name;
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !scene )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"Blender Scene was deleted!" );
|
2003-06-09 04:01:48 +00:00
|
|
|
|
|
|
|
|
base = scene->base.first;
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
while( base ) {
|
2003-06-09 04:01:48 +00:00
|
|
|
object = base->object;
|
|
|
|
|
|
2005-08-21 15:00:17 +00:00
|
|
|
name = Py_BuildValue( "(s)", object->id.name + 2 );
|
|
|
|
|
if( !name )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"Py_BuildValue() failed" );
|
|
|
|
|
|
|
|
|
|
bpy_obj = M_Object_Get( Py_None, name );
|
|
|
|
|
Py_DECREF ( name );
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !bpy_obj )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"couldn't create new object wrapper" );
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
PyList_Append( pylist, bpy_obj );
|
|
|
|
|
Py_XDECREF( bpy_obj ); /* PyList_Append incref'ed it */
|
2003-06-09 04:01:48 +00:00
|
|
|
|
|
|
|
|
base = base->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pylist;
|
|
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
2005-05-20 05:14:03 +00:00
|
|
|
//-----------------------Scene.getActiveObject()------------------------
|
|
|
|
|
static PyObject *Scene_getActiveObject(BPy_Scene *self)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene = self->scene;
|
|
|
|
|
PyObject *pyob;
|
|
|
|
|
Object *ob;
|
|
|
|
|
|
|
|
|
|
if (!scene)
|
|
|
|
|
return EXPP_ReturnPyObjError(PyExc_RuntimeError,
|
|
|
|
|
"Blender Scene was deleted!");
|
|
|
|
|
|
|
|
|
|
ob = ((scene->basact) ? (scene->basact->object) : 0);
|
|
|
|
|
|
|
|
|
|
if (ob) {
|
|
|
|
|
PyObject *arg = Py_BuildValue("(s)", ob->id.name+2);
|
|
|
|
|
|
|
|
|
|
pyob = M_Object_Get(Py_None, arg);
|
|
|
|
|
|
|
|
|
|
Py_DECREF(arg);
|
|
|
|
|
|
|
|
|
|
if (!pyob)
|
|
|
|
|
return EXPP_ReturnPyObjError(PyExc_MemoryError,
|
|
|
|
|
"couldn't create new object wrapper!");
|
|
|
|
|
|
|
|
|
|
return pyob;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EXPP_incr_ret(Py_None); /* no active object */
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
//-----------------------Scene.getCurrentCamera()------------------------
|
|
|
|
|
static PyObject *Scene_getCurrentCamera( BPy_Scene * self )
|
|
|
|
|
{
|
2003-06-09 04:01:48 +00:00
|
|
|
Object *cam_obj;
|
|
|
|
|
Scene *scene = self->scene;
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !scene )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"Blender Scene was deleted!" );
|
2003-06-09 04:01:48 +00:00
|
|
|
|
|
|
|
|
cam_obj = scene->camera;
|
|
|
|
|
|
2005-08-21 15:00:17 +00:00
|
|
|
if( cam_obj ) { /* if found, return a wrapper for it */
|
|
|
|
|
PyObject *camera = NULL;
|
|
|
|
|
PyObject *name = Py_BuildValue( "(s)", cam_obj->id.name + 2 );
|
|
|
|
|
|
|
|
|
|
if( !name )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"Py_BuildValue() failed" );
|
|
|
|
|
|
|
|
|
|
camera = M_Object_Get( Py_None, name );
|
|
|
|
|
Py_DECREF ( name );
|
|
|
|
|
return camera;
|
|
|
|
|
}
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_INCREF( Py_None ); /* none found */
|
2003-06-09 04:01:48 +00:00
|
|
|
return Py_None;
|
|
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------------Scene.setCurrentCamera()------------------------
|
|
|
|
|
static PyObject *Scene_setCurrentCamera( BPy_Scene * self, PyObject * args )
|
2003-06-09 04:01:48 +00:00
|
|
|
{
|
|
|
|
|
Object *object;
|
2003-06-28 07:38:21 +00:00
|
|
|
BPy_Object *cam_obj;
|
2004-06-15 04:16:30 +00:00
|
|
|
Scene *scene = self->scene;
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !scene )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"Blender Scene was deleted!" );
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !PyArg_ParseTuple( args, "O!", &Object_Type, &cam_obj ) )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
|
|
|
|
"expected Camera Object as argument" );
|
2003-06-09 04:01:48 +00:00
|
|
|
|
|
|
|
|
object = cam_obj->object;
|
2005-08-21 15:00:17 +00:00
|
|
|
if( object->type != OB_CAMERA )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_ValueError,
|
|
|
|
|
"expected Camera Object as argument" );
|
2003-06-09 04:01:48 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
scene->camera = object; /* set the current Camera */
|
2003-06-09 04:01:48 +00:00
|
|
|
|
|
|
|
|
/* if this is the current scene, update its window now */
|
2004-09-25 20:30:40 +00:00
|
|
|
if( scene == G.scene )
|
|
|
|
|
copy_view3d_lock( REDRAW );
|
2003-06-09 04:01:48 +00:00
|
|
|
|
|
|
|
|
/* XXX copy_view3d_lock(REDRAW) prints "bad call to addqueue: 0 (18, 1)".
|
|
|
|
|
* The same happens in bpython. */
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_INCREF( Py_None );
|
2003-06-09 04:01:48 +00:00
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
//-----------------------Scene.getRenderingContext()---------------------
|
|
|
|
|
static PyObject *Scene_getRenderingContext( BPy_Scene * self )
|
|
|
|
|
{
|
|
|
|
|
if( !self->scene )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"Blender Scene was deleted!" );
|
|
|
|
|
|
|
|
|
|
return RenderData_CreatePyObject( self->scene );
|
2003-06-09 04:01:48 +00:00
|
|
|
}
|
2004-06-15 04:16:30 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
static PyObject *Scene_getRadiosityContext( BPy_Scene * self )
|
BPython:
- new submodule Scene.Radio, for radiosity: still incomplete, but in shape for demos, updated SConscript to include it;
- new functions in Window module;
- doc updates: adding a todo file and a new start page for our docs: API_intro.py + other updates;
- small fix in Ipo.c provided by Damien McGuinnes (thanks!): Nathan has a patch with IPO additions and fixes for this and more, but until it is committed, there's this fix for Ipo.getCurve('LocX'), LocY, Z and QuatW,X,Y,Z too, according to Damien.
Other files:
- radpreprocess.c: added check for "during_script()" so eventual msgs don't popup during scripts;
- drawmesh.c: made a pointer (display list) be checked before accessed, fixes crash in scripts that forget to update display lists for subsurf meshes when a 3d view is in textured view mode.
Script: updated bevel_center by Loic Berthe.
2004-07-25 16:55:45 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !self->scene )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"Blender Scene was deleted!" );
|
BPython:
- new submodule Scene.Radio, for radiosity: still incomplete, but in shape for demos, updated SConscript to include it;
- new functions in Window module;
- doc updates: adding a todo file and a new start page for our docs: API_intro.py + other updates;
- small fix in Ipo.c provided by Damien McGuinnes (thanks!): Nathan has a patch with IPO additions and fixes for this and more, but until it is committed, there's this fix for Ipo.getCurve('LocX'), LocY, Z and QuatW,X,Y,Z too, according to Damien.
Other files:
- radpreprocess.c: added check for "during_script()" so eventual msgs don't popup during scripts;
- drawmesh.c: made a pointer (display list) be checked before accessed, fixes crash in scripts that forget to update display lists for subsurf meshes when a 3d view is in textured view mode.
Script: updated bevel_center by Loic Berthe.
2004-07-25 16:55:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
return Radio_CreatePyObject( self->scene );
|
BPython:
- new submodule Scene.Radio, for radiosity: still incomplete, but in shape for demos, updated SConscript to include it;
- new functions in Window module;
- doc updates: adding a todo file and a new start page for our docs: API_intro.py + other updates;
- small fix in Ipo.c provided by Damien McGuinnes (thanks!): Nathan has a patch with IPO additions and fixes for this and more, but until it is committed, there's this fix for Ipo.getCurve('LocX'), LocY, Z and QuatW,X,Y,Z too, according to Damien.
Other files:
- radpreprocess.c: added check for "during_script()" so eventual msgs don't popup during scripts;
- drawmesh.c: made a pointer (display list) be checked before accessed, fixes crash in scripts that forget to update display lists for subsurf meshes when a 3d view is in textured view mode.
Script: updated bevel_center by Loic Berthe.
2004-07-25 16:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
2004-06-24 09:43:13 +00:00
|
|
|
/* scene.addScriptLink */
|
2004-09-25 20:30:40 +00:00
|
|
|
static PyObject *Scene_addScriptLink( BPy_Scene * self, PyObject * args )
|
2004-06-15 04:16:30 +00:00
|
|
|
{
|
|
|
|
|
Scene *scene = self->scene;
|
2004-06-24 09:43:13 +00:00
|
|
|
ScriptLink *slink = NULL;
|
2004-06-15 04:16:30 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !scene )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"Blender Scene was deleted!" );
|
2004-06-15 04:16:30 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
slink = &( scene )->scriptlink;
|
2004-06-15 04:16:30 +00:00
|
|
|
|
2005-04-21 19:44:52 +00:00
|
|
|
return EXPP_addScriptLink( slink, args, 1 );
|
2004-06-24 09:43:13 +00:00
|
|
|
}
|
2004-06-15 04:16:30 +00:00
|
|
|
|
2004-06-24 09:43:13 +00:00
|
|
|
/* scene.clearScriptLinks */
|
2005-04-21 19:44:52 +00:00
|
|
|
static PyObject *Scene_clearScriptLinks( BPy_Scene * self, PyObject * args )
|
2004-06-24 09:43:13 +00:00
|
|
|
{
|
|
|
|
|
Scene *scene = self->scene;
|
|
|
|
|
ScriptLink *slink = NULL;
|
2004-06-15 04:16:30 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !scene )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"Blender Scene was deleted!" );
|
2004-06-15 04:16:30 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
slink = &( scene )->scriptlink;
|
2004-06-24 09:43:13 +00:00
|
|
|
|
2005-04-21 19:44:52 +00:00
|
|
|
return EXPP_clearScriptLinks( slink, args );
|
2004-06-24 09:43:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* scene.getScriptLinks */
|
2004-09-25 20:30:40 +00:00
|
|
|
static PyObject *Scene_getScriptLinks( BPy_Scene * self, PyObject * args )
|
2004-06-24 09:43:13 +00:00
|
|
|
{
|
|
|
|
|
Scene *scene = self->scene;
|
|
|
|
|
ScriptLink *slink = NULL;
|
|
|
|
|
PyObject *ret = NULL;
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !scene )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"Blender Scene was deleted!" );
|
2004-06-24 09:43:13 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
slink = &( scene )->scriptlink;
|
2004-06-24 09:43:13 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
ret = EXPP_getScriptLinks( slink, args, 1 );
|
2004-06-24 09:43:13 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( ret )
|
|
|
|
|
return ret;
|
|
|
|
|
else
|
|
|
|
|
return NULL;
|
2004-06-15 04:16:30 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
static PyObject *Scene_play( BPy_Scene * 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
|
|
|
{
|
|
|
|
|
Scene *scene = self->scene;
|
|
|
|
|
int mode = 0, win = SPACE_VIEW3D;
|
|
|
|
|
PyObject *ret = NULL;
|
|
|
|
|
ScrArea *sa = NULL, *oldsa = curarea;
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !scene )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"Blender Scene was deleted!" );
|
|
|
|
|
|
|
|
|
|
if( !PyArg_ParseTuple( args, "|ii", &mode, &win ) )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
|
|
|
|
"expected nothing, or or two ints as arguments." );
|
|
|
|
|
|
|
|
|
|
if( mode < 0 || mode > 3 )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
|
|
|
|
"mode should be in range [0, 3]." );
|
|
|
|
|
|
|
|
|
|
switch ( win ) {
|
|
|
|
|
case SPACE_VIEW3D:
|
|
|
|
|
case SPACE_SEQ:
|
|
|
|
|
case SPACE_IPO:
|
|
|
|
|
case SPACE_ACTION:
|
|
|
|
|
case SPACE_NLA:
|
|
|
|
|
case SPACE_SOUND:
|
|
|
|
|
case SPACE_BUTS: /* from here they don't 'play', but ... */
|
|
|
|
|
case SPACE_TEXT: /* ... might be used as a timer. */
|
|
|
|
|
case SPACE_SCRIPT:
|
|
|
|
|
case SPACE_OOPS:
|
|
|
|
|
case SPACE_IMAGE:
|
|
|
|
|
case SPACE_IMASEL:
|
|
|
|
|
case SPACE_INFO:
|
|
|
|
|
case SPACE_FILE:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
win = SPACE_VIEW3D;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* we have to move to a proper win */
|
2004-09-25 20:30:40 +00:00
|
|
|
sa = find_biggest_area_of_type( win );
|
|
|
|
|
if( !sa && win != SPACE_VIEW3D )
|
|
|
|
|
sa = find_biggest_area_of_type( SPACE_VIEW3D );
|
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( !sa )
|
|
|
|
|
sa = find_biggest_area( );
|
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( sa )
|
|
|
|
|
areawinset( sa->win );
|
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
|
|
|
|
|
|
|
|
/* play_anim returns 0 for normal exit or 1 if user canceled it */
|
2004-09-25 20:30:40 +00:00
|
|
|
ret = Py_BuildValue( "i", play_anim( mode ) );
|
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( sa )
|
|
|
|
|
areawinset( oldsa->win );
|
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
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2005-08-05 17:47:48 +00:00
|
|
|
|
|
|
|
|
static PyObject *Scene_getTimeLine( BPy_Scene *self )
|
|
|
|
|
{
|
|
|
|
|
BPy_TimeLine *tm= NULL;
|
|
|
|
|
|
|
|
|
|
tm= (BPy_TimeLine *) PyObject_NEW (BPy_TimeLine, &TimeLine_Type);
|
|
|
|
|
if (!tm)
|
|
|
|
|
return EXPP_ReturnPyObjError (PyExc_MemoryError,
|
|
|
|
|
"couldn't create BPy_TimeLine object");
|
|
|
|
|
tm->marker_list= &(self->scene->markers);
|
|
|
|
|
tm->sfra= (int) self->scene->r.sfra;
|
|
|
|
|
tm->efra= (int) self->scene->r.efra;
|
|
|
|
|
|
|
|
|
|
return (PyObject *)tm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|