Module API_intro
[hide private]
[frames] | no frames]

Source Code for Module API_intro

  1  # This is not a real module, it's simply an introductory text. 
  2   
  3  """ 
  4  The Blender Game Engine Python API Reference 
  5  ============================================ 
  6   
  7          See U{release notes<http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.49/Game_Engine>} for updates, changes and new functionality in the Game Engine Python API. 
  8   
  9          Blender Game Engine Modules: 
 10          ---------------------------- 
 11           
 12                  Modules that include methods for accessing GameEngine data and functions. 
 13                   
 14                          - L{GameLogic} utility functons for game logic. 
 15                          - L{GameKeys} keyboard input and event conversion. 
 16                          - L{Rasterizer} display and rendering. 
 17                          - L{GameTypes} contains all the python types spesific to the GameEngine. 
 18           
 19          Undocumented modules: 
 20          --------------------- 
 21                  - VideoTexture 
 22                  - PhysicsConstraints 
 23           
 24          Additional Modules: 
 25          ------------------- 
 26           
 27                  These modules have no GameEngine specific functionality but are useful in many cases. 
 28                   
 29                          - L{Mathutils} 
 30                          - L{Geometry} 
 31                          - L{BGL} 
 32   
 33   
 34  Introduction: 
 35  ============= 
 36   
 37          This reference documents the Blender Python API, a growing collection of 
 38          Python modules (libraries) that give access to part of the program's internal 
 39          data and functions. 
 40           
 41          Through scripting Blender can be extended in real-time via 
 42          U{Python <www.python.org>}, an impressive high level, multi-paradigm, open 
 43          source language.  Newcomers are recommended to start with the tutorial that 
 44          comes with it. 
 45   
 46          This opens many interesting possibilities not available with logic bricks. 
 47   
 48          Game Engine API Stability: 
 49          -------------------------- 
 50   
 51          When writing python scripts there are a number of situations you should avoid to prevent crashes or unstable behavior. 
 52          While the API tries to prevent problems there are some situations where error checking would be too time consuming. 
 53           
 54          Known cases: 
 55                  - Memory Limits. 
 56   
 57                                  There is nothing stopping you from filling a list or making a string so big that that causes blender to run out of memory, in this case python should rasie a MemoryError, but its likely blender will crash before this point. 
 58                                   
 59                  - Accessing any data that has been freed. 
 60   
 61                                  For instance accessing a KX_GameObject after its End Object actuator runs. 
 62                                  This will cause a SystemError, however for L{KX_MeshProxy}, L{KX_VertexProxy} and L{KX_VertexProxy} it will crash the blender game engine. 
 63                                   
 64                                  See: L{GameTypes.PyObjectPlus.invalid} which many types inherit. 
 65   
 66                  - Mixing L{KX_GameObject} between scenes. 
 67   
 68                                  For instance tracking/parenting an L{KX_GameObject} object to an object from other scene. 
 69   
 70          External Modules: 
 71          ----------------- 
 72           
 73          Since 2.49 support for importing modules has been added. 
 74   
 75          This allows you to import any blender textblock with a .py extension. 
 76           
 77          External python scripts may be imported as modules when the script is in the same directory as the blend file. 
 78           
 79          The current blend files path is included in the sys.path for loading modules. 
 80          All linked libraries will also be included so you can be sure when linking in assets from another blend file the scripts will load too. 
 81           
 82          A note to newbie script writers: 
 83          -------------------------------- 
 84   
 85          Interpreted languages are known to be much slower than compiled code, but for 
 86          many applications the difference is negligible or acceptable.  Also, with 
 87          profiling (or even simple direct timing with L{Blender.sys.time<Sys.time>}) to 
 88          identify slow areas and well thought optimizations, the speed can be 
 89          I{considerably} improved in many cases.  Try some of the best BPython scripts 
 90          to get an idea of what can be done, you may be surprised. 
 91   
 92  @author: The Blender Python Team 
 93  @requires: Blender 2.49 or newer. 
 94  @version: 2.49 
 95  @see: U{www.blender.org<http://www.blender.org>}: documentation and forum 
 96  @see: U{blenderartists.org<http://blenderartists.org>}: user forum 
 97  @see: U{projects.blender.org<http://projects.blender.org>} 
 98  @see: U{www.python.org<http://www.python.org>} 
 99  @see: U{www.python.org/doc<http://www.python.org/doc>} 
100  @see: U{Blending into Python<en.wikibooks.org/wiki/Blender_3D:_Blending_Into_Python>}: User contributed documentation, featuring a blender/python cookbook with many examples. 
101   
102  @note: the official version of this reference guide is only updated for each 
103          new Blender release.  But you can build the current SVN 
104          version yourself: install epydoc, grab all files in the 
105          source/gameengine/PyDoc/ folder of Blender's SVN and use the 
106          epy_docgen.sh script also found there to generate the html docs. 
107          Naturally you will also need a recent Blender binary to try the new 
108          features.  If you prefer not to compile it yourself, there is a testing 
109          builds forum at U{blender.org<http://www.blender.org>}. 
110  """ 
111