[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31313] branches/soc-2010-nexyon/intern/ audaspace/Python/doc: Py API Doc:
Joerg Mueller
nexyon at gmail.com
Fri Aug 13 12:33:50 CEST 2010
Revision: 31313
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31313
Author: nexyon
Date: 2010-08-13 12:33:49 +0200 (Fri, 13 Aug 2010)
Log Message:
-----------
Py API Doc:
* Added sphinx parsing for rst files
* Added bge documentation parsing
* Added a validator module that compares docs with python modules
* Added class- and staticmethods
Modified Paths:
--------------
branches/soc-2010-nexyon/intern/audaspace/Python/doc/datatypes.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/pyparser.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/rst/bge.events.rst
branches/soc-2010-nexyon/intern/audaspace/Python/doc/rst/bge.logic.rst
branches/soc-2010-nexyon/intern/audaspace/Python/doc/rst/bge.render.rst
branches/soc-2010-nexyon/intern/audaspace/Python/doc/rst/bge.types.rst
branches/soc-2010-nexyon/intern/audaspace/Python/doc/run.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/sphinxoutput.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/sphinxparser.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/templates/Layout.rst
branches/soc-2010-nexyon/intern/audaspace/Python/doc/templates/contents.rst
Added Paths:
-----------
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.events.allkeys.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.events.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.logic.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.render.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.CListValue.from_id.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.boxInsideFrustum.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.getScreenPosition.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.getScreenRay.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.getScreenVect.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.pointInsideFrustum.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.sphereInsideFrustum.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_GameObject.rayCast.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_LightObject.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_MeshProxy.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_PolygonMaterial.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_PolygonMaterial.setCustomMaterial.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_PolygonMaterial.setTexture.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_SCA_ReplaceMeshActuator.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Scene.active_camera.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Scene.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_VertexProxy.getRGBA.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_VertexProxy.setRGBA.py
branches/soc-2010-nexyon/intern/audaspace/Python/doc/templates/bge.events.Module.rst
branches/soc-2010-nexyon/intern/audaspace/Python/doc/templates/bge.logic.Module.rst
branches/soc-2010-nexyon/intern/audaspace/Python/doc/validator.py
Modified: branches/soc-2010-nexyon/intern/audaspace/Python/doc/datatypes.py
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/Python/doc/datatypes.py 2010-08-13 10:20:40 UTC (rev 31312)
+++ branches/soc-2010-nexyon/intern/audaspace/Python/doc/datatypes.py 2010-08-13 10:33:49 UTC (rev 31313)
@@ -63,6 +63,7 @@
self.arguments = []
self.return_values = []
self.location = None
+ self.decorator = ""
class Attribute(DocObj):
def __init__(self, name, parent, _type = None):
Added: branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.events.allkeys.py
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.events.allkeys.py (rev 0)
+++ branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.events.allkeys.py 2010-08-13 10:33:49 UTC (rev 31313)
@@ -0,0 +1,22 @@
+# 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.keys.keycode, key[1] = status
+ if status == bge.logic.KX_INPUT_JUST_ACTIVATED:
+ if key == bge.keys.WKEY:
+ # Activate Forward!
+ pass
+ if key == bge.keys.SKEY:
+ # Activate Backward!
+ pass
+ if key == bge.keys.AKEY:
+ # Activate Left!
+ pass
+ if key == bge.keys.DKEY:
+ # Activate Right!
+ pass
Added: branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.events.py
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.events.py (rev 0)
+++ branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.events.py 2010-08-13 10:33:49 UTC (rev 31313)
@@ -0,0 +1,8 @@
+# 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.keys.F1KEY
+
Added: branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.logic.py
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.logic.py (rev 0)
+++ branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.logic.py 2010-08-13 10:33:49 UTC (rev 31313)
@@ -0,0 +1,30 @@
+# 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
+
+# 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
+
+# To get an actuator attached to the controller:
+# +--------+ +-------------------------+
+# + Python +--+ Actuator "actuatorname" |
+# +--------+ +-------------------------+
+actuator = co.actuators["actuatorname"]
+
+# Activate an actuator
+controller.activate(actuator)
+
+# Get the current scene
+scene = bge.logic.getCurrentScene()
+
+# Get the current camera
+cam = scene.active_camera
Added: branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.render.py
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.render.py (rev 0)
+++ branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.render.py 2010-08-13 10:33:49 UTC (rev 31313)
@@ -0,0 +1,35 @@
+# Example Uses an L{SCA_MouseSensor}, and two L{KX_ObjectActuator}s to implement MouseLook::
+# To use a mouse movement sensor "Mouse" and a
+# motion actuator to mouse look:
+import bge.render
+import bge.logic
+
+# SCALE sets the speed of motion
+SCALE=[1, 0.5]
+
+co = bge.logic.getCurrentController()
+obj = co.getOwner()
+mouse = co.getSensor("Mouse")
+lmotion = co.getActuator("LMove")
+wmotion = co.getActuator("WMove")
+
+# Transform the mouse coordinates to see how far the mouse has moved.
+def mousePos():
+ x = (bge.render.getWindowWidth()/2 - mouse.getXPosition())*SCALE[0]
+ y = (bge.render.getWindowHeight()/2 - mouse.getYPosition())*SCALE[1]
+ return (x, y)
+
+pos = mousePos()
+
+# Set the amount of motion: X is applied in world coordinates...
+lmotion.setTorque(0.0, 0.0, pos[0], False)
+# ...Y is applied in local coordinates
+wmotion.setTorque(-pos[1], 0.0, 0.0, True)
+
+# Activate both actuators
+bge.logic.addActiveActuator(lmotion, True)
+bge.logic.addActiveActuator(wmotion, True)
+
+# Centre the mouse
+bge.render.setMousePosition(bge.render.getWindowWidth()/2, bge.render.getWindowHeight()/2)
+
Added: branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.CListValue.from_id.py
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.CListValue.from_id.py (rev 0)
+++ branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.CListValue.from_id.py 2010-08-13 10:33:49 UTC (rev 31313)
@@ -0,0 +1,3 @@
+myObID=id(gameObject)
+ob= scene.objects.from_id(myObID)
+
Added: branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.boxInsideFrustum.py
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.boxInsideFrustum.py (rev 0)
+++ branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.boxInsideFrustum.py 2010-08-13 10:33:49 UTC (rev 31313)
@@ -0,0 +1,22 @@
+import GameLogic
+co = GameLogic.getCurrentController()
+cam = co.owner
+
+# Box to test...
+box = []
+box.append([-1.0, -1.0, -1.0])
+box.append([-1.0, -1.0, 1.0])
+box.append([-1.0, 1.0, -1.0])
+box.append([-1.0, 1.0, 1.0])
+box.append([ 1.0, -1.0, -1.0])
+box.append([ 1.0, -1.0, 1.0])
+box.append([ 1.0, 1.0, -1.0])
+box.append([ 1.0, 1.0, 1.0])
+
+if (cam.boxInsideFrustum(box) != cam.OUTSIDE):
+ # Box is inside/intersects frustum !
+ # Do something useful !
+ pass
+else:
+ # Box is outside the frustum !
+ pass
Added: branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.getScreenPosition.py
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.getScreenPosition.py (rev 0)
+++ branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.getScreenPosition.py 2010-08-13 10:33:49 UTC (rev 31313)
@@ -0,0 +1,3 @@
+# For an object in the middle of the screen, coord = [0.5, 0.5]
+coord = camera.getScreenPosition(object)
+
Added: branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.getScreenRay.py
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.getScreenRay.py (rev 0)
+++ branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.getScreenRay.py 2010-08-13 10:33:49 UTC (rev 31313)
@@ -0,0 +1,3 @@
+# Gets an object with a property "wall" in front of the camera within a distance of 100:
+target = camera.getScreenRay(0.5, 0.5, 100, "wall")
+
Added: branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.getScreenVect.py
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.getScreenVect.py (rev 0)
+++ branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.getScreenVect.py 2010-08-13 10:33:49 UTC (rev 31313)
@@ -0,0 +1,2 @@
+# Gets the vector of the camera front direction:
+m_vect = camera.getScreenVect(0.5, 0.5)
Added: branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.pointInsideFrustum.py
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.pointInsideFrustum.py (rev 0)
+++ branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.pointInsideFrustum.py 2010-08-13 10:33:49 UTC (rev 31313)
@@ -0,0 +1,13 @@
+import GameLogic
+co = GameLogic.getCurrentController()
+cam = co.owner
+
+# Test point [0.0, 0.0, 0.0]
+if (cam.pointInsideFrustum([0.0, 0.0, 0.0])):
+ # Point is inside frustum !
+ # Do something useful !
+ pass
+else:
+ # Box is outside the frustum !
+ pass
+
Added: branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.sphereInsideFrustum.py
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.sphereInsideFrustum.py (rev 0)
+++ branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_Camera.sphereInsideFrustum.py 2010-08-13 10:33:49 UTC (rev 31313)
@@ -0,0 +1,13 @@
+import GameLogic
+co = GameLogic.getCurrentController()
+cam = co.owner
+
+# A sphere of radius 4.0 located at [x, y, z] = [1.0, 1.0, 1.0]
+if (cam.sphereInsideFrustum([1.0, 1.0, 1.0], 4) != cam.OUTSIDE):
+ # Sphere is inside frustum !
+ # Do something useful !
+ pass
+else:
+ # Sphere is outside frustum
+ pass
+
Added: branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_GameObject.rayCast.py
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_GameObject.rayCast.py (rev 0)
+++ branches/soc-2010-nexyon/intern/audaspace/Python/doc/examples/bge.types.KX_GameObject.rayCast.py 2010-08-13 10:33:49 UTC (rev 31313)
@@ -0,0 +1,5 @@
+# shoot along the axis gun-gunAim (gunAim should be collision-free)
+obj, point, normal = gun.rayCast(gunAim, None, 50)
+if obj:
+ # do something
+ pass
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list