| 
									
										
										
										
											2003-07-12 18:02:54 +00:00
										 |  |  | # Blender.Scene module and the Scene PyType object | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | """
 | 
					
						
							|  |  |  | The Blender.Scene submodule. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-21 19:44:52 +00:00
										 |  |  | B{New}: | 
					
						
							| 
									
										
										
										
											2005-10-11 15:11:39 +00:00
										 |  |  |   - L{Scene.clearScriptLinks<Scene.Scene.clearScriptLinks>} accepts a parameter now. | 
					
						
							|  |  |  |   - acess methods L{Scene.getLayers<Scene.Scene.getLayers>}, L{Scene.setLayers<Scene.Scene.setLayers>} via lists to complement the layers and | 
					
						
							|  |  |  |     Layers Scene attributes which use bitmasks.  | 
					
						
							|  |  |  |   - L{Scene.getActiveObject<Scene.Scene.getActiveObject>} method. | 
					
						
							| 
									
										
										
										
											2004-06-24 09:43:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-07-12 18:02:54 +00:00
										 |  |  | Scene | 
					
						
							|  |  |  | ===== | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This module provides access to B{Scenes} in Blender. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Example:: | 
					
						
							| 
									
										
										
										
											2003-07-22 00:27:03 +00:00
										 |  |  |   import Blender | 
					
						
							|  |  |  |   from Blender import Scene, Object, Camera | 
					
						
							|  |  |  |   # | 
					
						
							|  |  |  |   camdata = Camera.New('ortho')           # create new camera data | 
					
						
							|  |  |  |   camdata.setName('newCam') | 
					
						
							|  |  |  |   camdata.setLens(16.0) | 
					
						
							|  |  |  |   scene = Scene.New('NewScene')           # create a new scene | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  |   camobj = Object.New('Camera')           # create a new camera object | 
					
						
							|  |  |  |   camobj.link(camdata)                    # (*) link data to object first | 
					
						
							|  |  |  |   scene.link(camobj)                      # and then link object to scene | 
					
						
							| 
									
										
										
										
											2003-07-22 00:27:03 +00:00
										 |  |  |   scene.makeCurrent()                     # make this the current scene | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | @warn: as done in the example (*), it's recommended to first link object data to | 
					
						
							|  |  |  |     objects and only after that link objects to scene.  This is because if | 
					
						
							|  |  |  |     there is no object data linked to an object ob, scene.link(ob) will | 
					
						
							| 
									
										
										
										
											2005-10-11 15:11:39 +00:00
										 |  |  |     automatically create the missing data.  This is OK on its own, but I{if | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  |     after that} this object is linked to obdata, the automatically created one | 
					
						
							|  |  |  |     will be discarded -- as expected -- but will stay in Blender's memory | 
					
						
							|  |  |  |     space until the program is exited, since Blender doesn't really get rid of | 
					
						
							| 
									
										
										
										
											2005-10-11 15:11:39 +00:00
										 |  |  |     most kinds of data.  So first linking ObData to object, then object to | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  |     scene is a tiny tiny bit faster than the other way around and also saves | 
					
						
							|  |  |  |     some realtime memory (if many objects are created from scripts, the | 
					
						
							|  |  |  |     savings become important). | 
					
						
							| 
									
										
										
										
											2003-07-12 18:02:54 +00:00
										 |  |  | """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def New (name = 'Scene'): | 
					
						
							|  |  |  |   """
 | 
					
						
							|  |  |  |   Create a new Scene in Blender. | 
					
						
							|  |  |  |   @type name: string | 
					
						
							|  |  |  |   @param name: The Scene name. | 
					
						
							|  |  |  |   @rtype: Blender Scene | 
					
						
							|  |  |  |   @return: The created Scene. | 
					
						
							|  |  |  |   """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def Get (name = None): | 
					
						
							|  |  |  |   """
 | 
					
						
							|  |  |  |   Get the Scene(s) from Blender. | 
					
						
							|  |  |  |   @type name: string | 
					
						
							|  |  |  |   @param name: The name of a Scene. | 
					
						
							|  |  |  |   @rtype: Blender Scene or a list of Blender Scenes | 
					
						
							|  |  |  |   @return: It depends on the I{name} parameter: | 
					
						
							|  |  |  |       - (name): The Scene with the given I{name}; | 
					
						
							|  |  |  |       - ():     A list with all Scenes currently in Blender. | 
					
						
							|  |  |  |   """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def GetCurrent(): | 
					
						
							|  |  |  |   """
 | 
					
						
							|  |  |  |   Get the currently active Scene in Blender. | 
					
						
							|  |  |  |   @rtype: Blender Scene | 
					
						
							|  |  |  |   @return: The currently active Scene. | 
					
						
							|  |  |  |   """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def Unlink(scene): | 
					
						
							|  |  |  |   """
 | 
					
						
							|  |  |  |   Unlink (delete) a Scene from Blender. | 
					
						
							|  |  |  |   @type scene: Blender Scene | 
					
						
							|  |  |  |   @param scene: The Scene to be unlinked. | 
					
						
							|  |  |  |   """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Scene: | 
					
						
							|  |  |  |   """
 | 
					
						
							|  |  |  |   The Scene object | 
					
						
							|  |  |  |   ================ | 
					
						
							|  |  |  |     This object gives access to Scene data in Blender. | 
					
						
							| 
									
										
										
										
											2005-04-21 19:44:52 +00:00
										 |  |  |   @type name: string | 
					
						
							| 
									
										
										
										
											2005-06-15 06:22:26 +00:00
										 |  |  |   @ivar name: The Scene name. | 
					
						
							| 
									
										
										
										
											2005-04-21 19:44:52 +00:00
										 |  |  |   @type Layers: integer (bitmask) | 
					
						
							| 
									
										
										
										
											2005-06-15 06:22:26 +00:00
										 |  |  |   @ivar Layers: The Scene layers (check also the easier to use | 
					
						
							| 
									
										
										
										
											2005-10-11 15:11:39 +00:00
										 |  |  |         L{layers}).  This value is a bitmask with at least | 
					
						
							| 
									
										
										
										
											2005-04-21 19:44:52 +00:00
										 |  |  |         one position set for the 20 possible layers starting from the low order | 
					
						
							|  |  |  |         bit.  The easiest way to deal with these values in in hexadecimal  | 
					
						
							|  |  |  |         notation. | 
					
						
							|  |  |  |         Example:: | 
					
						
							|  |  |  |           scene.Layers = 0x04 # sets layer 3 ( bit pattern 0100 ) | 
					
						
							|  |  |  |           scene.Layers |= 0x01 | 
					
						
							|  |  |  |           print scene.Layers # will print: 5 ( meaning bit pattern 0101) | 
					
						
							|  |  |  |         After setting the Layers value, the interface (at least the 3d View and | 
					
						
							|  |  |  |         the Buttons window) needs to be redrawn to show the changes. | 
					
						
							|  |  |  |   @type layers: list of integers | 
					
						
							| 
									
										
										
										
											2005-10-11 15:11:39 +00:00
										 |  |  |   @ivar layers: The Scene layers (check also L{Layers}). | 
					
						
							| 
									
										
										
										
											2005-04-21 19:44:52 +00:00
										 |  |  |         This attribute accepts and returns a list of integer values in the | 
					
						
							|  |  |  |         range [1, 20]. | 
					
						
							|  |  |  |         Example:: | 
					
						
							|  |  |  |           scene.layers = [3] # set layer 3 | 
					
						
							|  |  |  |           scene.layers = scene.layers.append(1) | 
					
						
							|  |  |  |           print scene.layers # will print: [1, 3] | 
					
						
							| 
									
										
										
										
											2003-07-12 18:02:54 +00:00
										 |  |  |   """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def getName(): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Get the name of this Scene. | 
					
						
							|  |  |  |     @rtype: string | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def setName(name): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Set the name of this Scene. | 
					
						
							|  |  |  |     @type name: string | 
					
						
							|  |  |  |     @param name: The new name. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-21 19:44:52 +00:00
										 |  |  |   def getLayers(): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Get the layers set for this Scene. | 
					
						
							|  |  |  |     @rtype: list of integers | 
					
						
							|  |  |  |     @return: a list where each number means the layer with that number is | 
					
						
							|  |  |  |        set. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def setLayers(layers): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Set the visible layers for this scene. | 
					
						
							|  |  |  |     @type layers: list of integers | 
					
						
							|  |  |  |     @param layers: a list of integers in the range [1, 20], where each available | 
					
						
							|  |  |  |        index makes the layer with that number visible. | 
					
						
							|  |  |  |     @note: if this Scene is the current one, the 3D View layers are also | 
					
						
							|  |  |  |        updated, but the screen needs to be redrawn (at least 3D Views and | 
					
						
							|  |  |  |        Buttons windows) for the changes to be seen. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-07-12 18:02:54 +00:00
										 |  |  |   def copy(duplicate_objects = 1): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Make a copy of this Scene. | 
					
						
							|  |  |  |     @type duplicate_objects: int | 
					
						
							|  |  |  |     @param duplicate_objects: Defines how the Scene children are duplicated: | 
					
						
							|  |  |  |         - 0: Link Objects; | 
					
						
							|  |  |  |         - 1: Link Object Data; | 
					
						
							|  |  |  |         - 2: Full copy. | 
					
						
							|  |  |  |     @rtype: Scene | 
					
						
							|  |  |  |     @return: The copied Blender Scene. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def makeCurrent(): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Make this Scene the currently active one in Blender. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-08-06 19:25:06 +00:00
										 |  |  |   def update(full = 0): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Update this Scene in Blender. | 
					
						
							|  |  |  |     @type full: int | 
					
						
							|  |  |  |     @param full: A bool to control the level of updating: | 
					
						
							|  |  |  |         - 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
										 |  |  |         - 1: sort and also regroup, do ipos, keys, script links, etc. | 
					
						
							| 
									
										
										
										
											2003-08-06 19:25:06 +00:00
										 |  |  |     @warn: When in doubt, try with I{full = 0} first, since it is faster. | 
					
						
							|  |  |  |         The "full" update is a recent addition to this method. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												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
										 |  |  |   def getRenderingContext(): | 
					
						
							| 
									
										
										
										
											2004-06-24 09:43:13 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
											
												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
										 |  |  |     Get the rendering context for this scene, see L{Render}. | 
					
						
							|  |  |  |     @rtype: RenderData | 
					
						
							|  |  |  |     @return: the render data object for this scene. | 
					
						
							| 
									
										
										
										
											2004-06-24 09:43:13 +00:00
										 |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												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
										 |  |  |   def getRadiosityContext(): | 
					
						
							| 
									
										
										
										
											2004-06-24 09:43:13 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
											
												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
										 |  |  |     Get the radiosity context for this scene, see L{Radio}. | 
					
						
							|  |  |  |     @rtype: Blender Radiosity | 
					
						
							|  |  |  |     @return: the radiosity object for this scene. | 
					
						
							|  |  |  |     @note: only the current scene can return a radiosity context. | 
					
						
							| 
									
										
										
										
											2004-06-24 09:43:13 +00:00
										 |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def getChildren(): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Get all objects linked to this Scene. | 
					
						
							|  |  |  |     @rtype: list of Blender Objects | 
					
						
							|  |  |  |     @return: A list with all Blender Objects linked to this Scene. | 
					
						
							| 
									
										
										
										
											2005-04-21 19:44:52 +00:00
										 |  |  |     @note: L{Object.Get} will return all objects currently in Blender, which | 
					
						
							|  |  |  |        means all objects from all available scenes.  In most cases (exporter | 
					
						
							|  |  |  |        scripts, for example), it's probably better to use this | 
					
						
							|  |  |  |        scene.GetChildren instead, since it will only access objects from this | 
					
						
							|  |  |  |        particular scene. | 
					
						
							| 
									
										
										
										
											2004-06-24 09:43:13 +00:00
										 |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-05-20 05:14:03 +00:00
										 |  |  |   def getActiveObject(): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Get this scene's active object. | 
					
						
							|  |  |  |     @note: the active object, if selected, can also be retrieved with | 
					
						
							|  |  |  |       L{Object.GetSelected} -- it is the first item in the returned | 
					
						
							|  |  |  |       list.  But even when no object is selected in Blender, there can be | 
					
						
							|  |  |  |       an active one (if the user enters editmode, for example, this is the | 
					
						
							|  |  |  |       object that should become available for edition).  So what makes this | 
					
						
							|  |  |  |       scene method different from C{Object.GetSelected()[0]} is that it can | 
					
						
							|  |  |  |       return the active object even when no objects are selected. | 
					
						
							|  |  |  |     @rtype: Blender Object or None | 
					
						
							|  |  |  |     @return: the active object or None if not available. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-24 09:43:13 +00:00
										 |  |  |   def getCurrentCamera(): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Get the currently active Camera for this Scene. | 
					
						
							| 
									
										
										
										
											2005-10-11 15:11:39 +00:00
										 |  |  |     @note: The active camera can be any object type, not just a camera object. | 
					
						
							|  |  |  |     @rtype: Blender Object | 
					
						
							|  |  |  |     @return: The currently active Camera object. | 
					
						
							| 
									
										
										
										
											2004-06-24 09:43:13 +00:00
										 |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def setCurrentCamera(camera): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Set the currently active Camera in this Scene. | 
					
						
							|  |  |  |     @type camera: Blender Camera | 
					
						
							|  |  |  |     @param camera: The new active Camera. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-07-12 18:02:54 +00:00
										 |  |  |   def link(object): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Link an Object to this Scene. | 
					
						
							|  |  |  |     @type object: Blender Object | 
					
						
							|  |  |  |     @param object: A Blender Object. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def unlink(object): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Unlink an Object from this Scene. | 
					
						
							|  |  |  |     @type object: Blender Object | 
					
						
							|  |  |  |     @param object: A Blender Object. | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2004-06-24 09:43:13 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def getScriptLinks (event): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Get a list with this Scene's script links of type 'event'. | 
					
						
							|  |  |  |     @type event: string | 
					
						
							| 
									
										
										
										
											2005-05-22 07:22:34 +00:00
										 |  |  |     @param event: "FrameChanged", "OnLoad", "OnSave", "Redraw" or "Render". | 
					
						
							| 
									
										
										
										
											2004-06-24 09:43:13 +00:00
										 |  |  |     @rtype: list | 
					
						
							|  |  |  |     @return: a list with Blender L{Text} names (the script links of the given | 
					
						
							|  |  |  |         'event' type) or None if there are no script links at all. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-21 19:44:52 +00:00
										 |  |  |   def clearScriptLinks (links = None): | 
					
						
							| 
									
										
										
										
											2004-06-24 09:43:13 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2005-04-21 19:44:52 +00:00
										 |  |  |     Delete script links from this Scene.  If no list is specified, all | 
					
						
							|  |  |  |     script links are deleted. | 
					
						
							|  |  |  |     @type links: list of strings | 
					
						
							|  |  |  |     @param links: None (default) or a list of Blender L{Text} names. | 
					
						
							| 
									
										
										
										
											2004-06-24 09:43:13 +00:00
										 |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def addScriptLink (text, event): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Add a new script link to this Scene. | 
					
						
							| 
									
										
										
										
											2005-10-11 15:11:39 +00:00
										 |  |  |      | 
					
						
							|  |  |  |     Using OpenGL functions within a scene ScriptLink will draw graphics over the 3D view. | 
					
						
							|  |  |  |     There is an issue with the zoom of the floating panels also scaling graphics drawn by your scriptlink. | 
					
						
							|  |  |  |     This makes matching OpenGL graphics to mouse location impossible. | 
					
						
							|  |  |  |     Make sure that you use floating point for operations that you would usually use int functions for: glRasterPos2f rather then glRasterPos2i. | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     The following example shows how you can use the OpenGL model view matrix to obtain the scale value. | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     Example:: | 
					
						
							|  |  |  |       from Blender import BGL | 
					
						
							|  |  |  |       view_matrix = BGL.Buffer(BGL.GL_FLOAT, 16) | 
					
						
							|  |  |  |       BGL.glGetFloatv(BGL.GL_MODELVIEW_MATRIX, view_matrix) | 
					
						
							|  |  |  |       gl_scale = 1/viewMatrix[0] | 
					
						
							|  |  |  |        | 
					
						
							|  |  |  |       # Now that we have the scale we can draw to the correct scale. | 
					
						
							|  |  |  |       BGL.glRect2f(10*gl_scale, 10*gl_scale, 110*gl_scale, 110*gl_scale) | 
					
						
							|  |  |  |        | 
					
						
							|  |  |  |        | 
					
						
							| 
									
										
										
										
											2004-06-24 09:43:13 +00:00
										 |  |  |     @type text: string | 
					
						
							|  |  |  |     @param text: the name of an existing Blender L{Text}. | 
					
						
							|  |  |  |     @type event: string | 
					
						
							| 
									
										
										
										
											2005-05-22 07:22:34 +00:00
										 |  |  |     @param event: "FrameChanged", "OnLoad", "OnSave", "Redraw" or "Render". | 
					
						
							| 
									
										
										
										
											2004-06-24 09:43:13 +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
										 |  |  | 
 | 
					
						
							|  |  |  |   def play (mode = 0, win = '<VIEW3D>'): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Play a realtime animation.  This is the "Play Back Animation" function in | 
					
						
							|  |  |  |     Blender, different from playing a sequence of rendered images (for that | 
					
						
							|  |  |  |     check L{Render.RenderData.play}). | 
					
						
							|  |  |  |     @type mode: int | 
					
						
							|  |  |  |     @param mode: controls playing: | 
					
						
							|  |  |  |         - 0: keep playing in the biggest 'win' window; | 
					
						
							|  |  |  |         - 1: keep playing in all 'win', VIEW3D and SEQ windows; | 
					
						
							|  |  |  |         - 2: play once in the biggest VIEW3D; | 
					
						
							|  |  |  |         - 3: play once in all 'win', VIEW3D and SEQ windows. | 
					
						
							|  |  |  |     @type win: int | 
					
						
							|  |  |  |     @param win: window type, see L{Window.Types}.  Only some of them are | 
					
						
							|  |  |  |         meaningful here: VIEW3D, SEQ, IPO, ACTION, NLA, SOUND.  But the others | 
					
						
							|  |  |  |         are also accepted, since this function can be used simply as an | 
					
						
							|  |  |  |         interruptible timer.  If 'win' is not visible or invalid, VIEW3D is | 
					
						
							|  |  |  |         tried, then any bigger visible window. | 
					
						
							|  |  |  |     @rtype: bool | 
					
						
							|  |  |  |     @return: 0 on normal exit or 1 when play back is canceled by user input. | 
					
						
							|  |  |  |     """
 |