[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32445] trunk/blender: == python api doc = =
Luca Bonavita
mindrones at gmail.com
Wed Oct 13 12:42:33 CEST 2010
Revision: 32445
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32445
Author: mindrones
Date: 2010-10-13 12:42:33 +0200 (Wed, 13 Oct 2010)
Log Message:
-----------
== python api doc ==
First commit to make some structure in doc/ directory.
- moved source/blender/python/doc -> doc/python_api
- moved source/gameengine/PyDoc/*.rst -> doc/python_api/rst
- modified accordingly sphinx_doc_gen.py and sphinx_doc_gen.sh
(later on I'll try alternative/ scripts by neXyon as promised :)
- source/gameengine/PyDoc/ is still there because contains epydoc stuff for the bge, will ask more and look into it later
Modified Paths:
--------------
trunk/blender/doc/python_api/sphinx_doc_gen.py
trunk/blender/doc/python_api/sphinx_doc_gen.sh
Added Paths:
-----------
trunk/blender/doc/python_api/
trunk/blender/doc/python_api/rst/
trunk/blender/doc/python_api/rst/bge.events.rst
trunk/blender/doc/python_api/rst/bge.logic.rst
trunk/blender/doc/python_api/rst/bge.render.rst
trunk/blender/doc/python_api/rst/bge.types.rst
Removed Paths:
-------------
trunk/blender/source/blender/python/doc/
trunk/blender/source/gameengine/PyDoc/bge.events.rst
trunk/blender/source/gameengine/PyDoc/bge.logic.rst
trunk/blender/source/gameengine/PyDoc/bge.render.rst
trunk/blender/source/gameengine/PyDoc/bge.types.rst
Copied: trunk/blender/doc/python_api (from rev 32444, trunk/blender/source/blender/python/doc)
Copied: trunk/blender/doc/python_api/rst/bge.events.rst (from rev 32444, trunk/blender/source/gameengine/PyDoc/bge.events.rst)
===================================================================
--- trunk/blender/doc/python_api/rst/bge.events.rst (rev 0)
+++ trunk/blender/doc/python_api/rst/bge.events.rst 2010-10-13 10:42:33 UTC (rev 32445)
@@ -0,0 +1,250 @@
+
+Game Engine bge.events module
+=============================
+
+*****
+Intro
+*****
+
+This module holds key constants for the SCA_KeyboardSensor.
+
+.. module:: bge.events
+
+.. code-block:: python
+
+ # Set a connected keyboard sensor to accept F1
+ import bge
+
+ co = bge.logic.getCurrentController()
+ # 'Keyboard' is a keyboard sensor
+ sensor = co.sensors["Keyboard"]
+ sensor.key = bge.events.F1KEY
+
+.. code-block:: python
+
+ # Do the all keys thing
+ import bge
+
+ co = bge.logic.getCurrentController()
+ # 'Keyboard' is a keyboard sensor
+ sensor = co.sensors["Keyboard"]
+
+ for key,status in sensor.events:
+ # key[0] == bge.events.keycode, key[1] = status
+ if status == bge.logic.KX_INPUT_JUST_ACTIVATED:
+ if key == bge.events.WKEY:
+ # Activate Forward!
+ if key == bge.events.SKEY:
+ # Activate Backward!
+ if key == bge.events.AKEY:
+ # Activate Left!
+ if key == bge.events.DKEY:
+ # Activate Right!
+
+.. code-block:: python
+
+ # The all keys thing without a keyboard sensor (but you will
+ # need an always sensor with pulse mode on)
+ import bge
+
+ # Just shortening names here
+ keyboard = bge.logic.keyboard
+ JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
+
+ if keyboard.events[bge.events.WKEY] == JUST_ACTIVATED:
+ print("Activate Forward!")
+ if keyboard.events[bge.events.SKEY] == JUST_ACTIVATED:
+ print("Activate Backward!")
+ if keyboard.events[bge.events.AKEY] == JUST_ACTIVATED:
+ print("Activate Left!")
+ if keyboard.events[bge.events.DKEY] == JUST_ACTIVATED:
+ print("Activate Right!")
+
+
+*********
+Functions
+*********
+
+.. function:: EventToString(event)
+
+ Return the string name of a key event. Will raise a ValueError error if its invalid.
+
+ :arg event: key event from bge.keys or the keyboard sensor.
+ :type event: int
+ :rtype: string
+
+.. function:: EventToCharacter(event, shift)
+
+ Return the string name of a key event. Returns an empty string if the event cant be represented as a character.
+
+ :type event: int
+ :arg event: key event from :mod:`bge.keys` or the keyboard sensor.
+ :type shift: bool
+ :arg shift: set to true if shift is held.
+ :rtype: string
+
+****************
+Keys (Constants)
+****************
+
+.. _mouse-keys:
+
+==========
+Mouse Keys
+==========
+
+.. data:: LEFTMOUSE
+.. data:: MIDDLEMOUSE
+.. data:: RIGHTMOUSE
+.. data:: WHEELUPMOUSE
+.. data:: WHEELDOWNMOUSE
+.. data:: MOUSEX
+.. data:: MOUSEY
+
+.. _keyboard-keys:
+
+=============
+Keyboard Keys
+=============
+
+-------------
+Alphabet keys
+-------------
+
+.. data:: AKEY
+.. data:: BKEY
+.. data:: CKEY
+.. data:: DKEY
+.. data:: EKEY
+.. data:: FKEY
+.. data:: GKEY
+.. data:: HKEY
+.. data:: IKEY
+.. data:: JKEY
+.. data:: KKEY
+.. data:: LKEY
+.. data:: MKEY
+.. data:: NKEY
+.. data:: OKEY
+.. data:: PKEY
+.. data:: QKEY
+.. data:: RKEY
+.. data:: SKEY
+.. data:: TKEY
+.. data:: UKEY
+.. data:: VKEY
+.. data:: WKEY
+.. data:: XKEY
+.. data:: YKEY
+.. data:: ZKEY
+
+-----------
+Number keys
+-----------
+
+.. data:: ZEROKEY
+.. data:: ONEKEY
+.. data:: TWOKEY
+.. data:: THREEKEY
+.. data:: FOURKEY
+.. data:: FIVEKEY
+.. data:: SIXKEY
+.. data:: SEVENKEY
+.. data:: EIGHTKEY
+.. data:: NINEKEY
+
+--------------
+Modifiers Keys
+--------------
+
+.. data:: CAPSLOCKKEY
+.. data:: LEFTCTRLKEY
+.. data:: LEFTALTKEY
+.. data:: RIGHTALTKEY
+.. data:: RIGHTCTRLKEY
+.. data:: RIGHTSHIFTKEY
+.. data:: LEFTSHIFTKEY
+
+----------
+Arrow Keys
+----------
+
+.. data:: LEFTARROWKEY
+.. data:: DOWNARROWKEY
+.. data:: RIGHTARROWKEY
+.. data:: UPARROWKEY
+
+--------------
+Numberpad Keys
+--------------
+
+.. data:: PAD0
+.. data:: PAD1
+.. data:: PAD2
+.. data:: PAD3
+.. data:: PAD4
+.. data:: PAD5
+.. data:: PAD6
+.. data:: PAD7
+.. data:: PAD8
+.. data:: PAD9
+.. data:: PADPERIOD
+.. data:: PADSLASHKEY
+.. data:: PADASTERKEY
+.. data:: PADMINUS
+.. data:: PADENTER
+.. data:: PADPLUSKEY
+
+-------------
+Function Keys
+-------------
+
+.. data:: F1KEY
+.. data:: F2KEY
+.. data:: F3KEY
+.. data:: F4KEY
+.. data:: F5KEY
+.. data:: F6KEY
+.. data:: F7KEY
+.. data:: F8KEY
+.. data:: F9KEY
+.. data:: F10KEY
+.. data:: F11KEY
+.. data:: F12KEY
+.. data:: F13KEY
+.. data:: F14KEY
+.. data:: F15KEY
+.. data:: F16KEY
+.. data:: F17KEY
+.. data:: F18KEY
+.. data:: F19KEY
+
+----------
+Other Keys
+----------
+
+.. data:: ACCENTGRAVEKEY
+.. data:: BACKSLASHKEY
+.. data:: BACKSPACEKEY
+.. data:: COMMAKEY
+.. data:: DELKEY
+.. data:: ENDKEY
+.. data:: EQUALKEY
+.. data:: ESCKEY
+.. data:: HOMEKEY
+.. data:: INSERTKEY
+.. data:: LEFTBRACKETKEY
+.. data:: LINEFEEDKEY
+.. data:: MINUSKEY
+.. data:: PAGEDOWNKEY
+.. data:: PAGEUPKEY
+.. data:: PAUSEKEY
+.. data:: PERIODKEY
+.. data:: QUOTEKEY
+.. data:: RIGHTBRACKETKEY
+.. data:: RETKEY (Deprecated: use bge.events.ENTERKEY)
+.. data:: ENTERKEY
+.. data:: SEMICOLONKEY
+.. data:: SLASHKEY
+.. data:: SPACEKEY
+.. data:: TABKEY
Copied: trunk/blender/doc/python_api/rst/bge.logic.rst (from rev 32444, trunk/blender/source/gameengine/PyDoc/bge.logic.rst)
===================================================================
--- trunk/blender/doc/python_api/rst/bge.logic.rst (rev 0)
+++ trunk/blender/doc/python_api/rst/bge.logic.rst 2010-10-13 10:42:33 UTC (rev 32445)
@@ -0,0 +1,932 @@
+
+Game Engine bge.logic Module
+============================
+*****
+Intro
+*****
+
+Module to access logic functions, imported automatically into the python controllers namespace.
+
+.. module:: bge.logic
+
+.. code-block:: python
+
+ # To get the controller thats running this python script:
+ cont = bge.logic.getCurrentController() # bge.logic is automatically imported
+
+ # To get the game object this controller is on:
+ obj = cont.owner
+
+:class:`~bge.types.KX_GameObject` and :class:`~bge.types.KX_Camera` or :class:`bge.types.~KX_LightObject` methods are available depending on the type of object
+
+.. code-block:: python
+
+ # To get a sensor linked to this controller.
+ # "sensorname" is the name of the sensor as defined in the Blender interface.
+ # +---------------------+ +--------+
+ # | Sensor "sensorname" +--+ Python +
+ # +---------------------+ +--------+
+ sens = cont.sensors["sensorname"]
+
+ # To get a sequence of all sensors:
+ sensors = co.sensors
+
+See the sensor's reference for available methods:
+
+.. hlist::
+ :columns: 3
+
+ * :class:`~bge.types.KX_MouseFocusSensor`
+ * :class:`~bge.types.KX_NearSensor`
+ * :class:`~bge.types.KX_NetworkMessageSensor`
+ * :class:`~bge.types.KX_RadarSensor`
+ * :class:`~bge.types.KX_RaySensor`
+ * :class:`~bge.types.KX_TouchSensor`
+ * :class:`~bge.types.SCA_DelaySensor`
+ * :class:`~bge.types.SCA_JoystickSensor`
+ * :class:`~bge.types.SCA_KeyboardSensor`
+ * :class:`~bge.types.SCA_MouseSensor`
+ * :class:`~bge.types.SCA_PropertySensor`
+ * :class:`~bge.types.SCA_RandomSensor`
+
+You can also access actuators linked to the controller
+
+.. code-block:: python
+
+ # To get an actuator attached to the controller:
+ # +--------+ +-------------------------+
+ # + Python +--+ Actuator "actuatorname" |
+ # +--------+ +-------------------------+
+ actuator = co.actuators["actuatorname"]
+
+ # Activate an actuator
+ controller.activate(actuator)
+
+See the actuator's reference for available methods
+
+.. hlist::
+ :columns: 3
+
+ * :class:`~bge.types.BL_ActionActuator`
+ * :class:`~bge.types.BL_ShapeActionActuator`
+ * :class:`~bge.types.KX_CameraActuator`
+ * :class:`~bge.types.KX_ConstraintActuator`
+ * :class:`~bge.types.KX_GameActuator`
+ * :class:`~bge.types.KX_IpoActuator`
+ * :class:`~bge.types.KX_NetworkMessageActuator`
+ * :class:`~bge.types.KX_ObjectActuator`
+ * :class:`~bge.types.KX_ParentActuator`
+ * :class:`~bge.types.KX_SCA_AddObjectActuator`
+ * :class:`~bge.types.KX_SCA_DynamicActuator`
+ * :class:`~bge.types.KX_SCA_EndObjectActuator`
+ * :class:`~bge.types.KX_SCA_ReplaceMeshActuator`
+ * :class:`~bge.types.KX_SceneActuator`
+ * :class:`~bge.types.KX_SoundActuator`
+ * :class:`~bge.types.KX_StateActuator`
+ * :class:`~bge.types.KX_TrackToActuator`
+ * :class:`~bge.types.KX_VisibilityActuator`
+ * :class:`~bge.types.SCA_2DFilterActuator`
+ * :class:`~bge.types.SCA_PropertyActuator`
+ * :class:`~bge.types.SCA_RandomActuator`
+
+Most logic brick's methods are accessors for the properties available in the logic buttons.
+Consult the logic bricks documentation for more information on how each logic brick works.
+
+There are also methods to access the current :class:`bge.types.KX_Scene`
+
+.. code-block:: python
+
+ # Get the current scene
+ scene = bge.logic.getCurrentScene()
+
+ # Get the current camera
+ cam = scene.active_camera
+
+Matricies as used by the game engine are **row major**
+``matrix[row][col] = float``
+
+:class:`bge.types.KX_Camera` has some examples using matricies.
+
+*********
+Variables
+*********
+
+.. data:: globalDict
+
+ A dictionary that is saved between loading blend files so you can use it to store inventory and other variables you want to store between scenes and blend files.
+ It can also be written to a file and loaded later on with the game load/save actuators.
+
+ .. note:: only python built in types such as int/string/bool/float/tuples/lists can be saved, GameObjects, Actuators etc will not work as expected.
+
+.. data:: keyboard
+
+ The current keyboard wrapped in an :class:`~bge.types.SCA_PythonKeyboard` object.
+
+.. data:: mouse
+
+ The current mouse wrapped in an :class:`~bge.types.SCA_PythonMouse` object.
+
+*****************
+General functions
+*****************
+
+.. function:: getCurrentController()
+
+ Gets the Python controller associated with this Python script.
+
+ :rtype: :class:`bge.types.SCA_PythonController`
+
+.. function:: getCurrentScene()
+
+ Gets the current Scene.
+
+ :rtype: :class:`bge.types.KX_Scene`
+
+.. function:: getSceneList()
+
+ Gets a list of the current scenes loaded in the game engine.
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list