merge with trunk r39216

This commit is contained in:
Xiao Xiangquan
2011-08-10 14:32:03 +00:00
210 changed files with 6222 additions and 3313 deletions

View File

@@ -219,7 +219,7 @@ div.sphinxsidebarwrapper.fixed {
}
{%- if theme_stickysidebar|tobool %}
/* this is nice, but it it leads to hidden headings when jumping
/* this is nice, but it leads to hidden headings when jumping
to an anchor */
/*
div.related {

12
doc/python_api/examples/bge.constraints.py Executable file → Normal file
View File

@@ -8,11 +8,11 @@ from bge import constraints
# get object list
objects = logic.getCurrentScene().objects
# get object named Object1 and Object 2
object_1 = objects["Object1"]
object_2 = objects["Object2"]
# want to use Edge constraint type
constraint_type = 2
@@ -31,7 +31,7 @@ edge_angle_y = 1.0
edge_angle_z = 0.0
# create an edge constraint
constraints.createConstraint( physics_id_1, physics_id_2,
constraint_type,
edge_position_x, edge_position_y, edge_position_z,
edge_angle_x, edge_angle_y, edge_angle_z )
constraints.createConstraint(physics_id_1, physics_id_2,
constraint_type,
edge_position_x, edge_position_y, edge_position_z,
edge_angle_x, edge_angle_y, edge_angle_z)

16
doc/python_api/examples/bge.texture.1.py Executable file → Normal file
View File

@@ -6,29 +6,31 @@ createTexture() and removeTexture() are to be called from a module Python
Controller.
"""
from bge import logic
from bge import texture
from bge import texture
def createTexture(cont):
"""Create a new Dynamic Texture"""
object = cont.owner
# get the reference pointer (ID) of the internal texture
ID = texture.materialID(obj, 'IMoriginal.png')
# create a texture object
# create a texture object
object_texture = texture.Texture(object, ID)
# create a new source with an external image
url = logic.expandPath("//newtexture.jpg")
new_source = texture.ImageFFmpeg(url)
# the texture has to be stored in a permanent Python object
logic.texture = object_texture
# update/replace the texture
logic.texture.source = new_source
logic.texture.refresh(False)
def removeTexture(cont):
"""Delete the Dynamic Texture, reversing back the final to its original state."""
try:

10
doc/python_api/examples/bge.texture.py Executable file → Normal file
View File

@@ -9,14 +9,14 @@ from bge import logic
cont = logic.getCurrentController()
obj = cont.owner
# the creation of the texture must be done once: save the
# the creation of the texture must be done once: save the
# texture object in an attribute of bge.logic module makes it persistent
if not hasattr(logic, 'video'):
# identify a static texture by name
matID = texture.materialID(obj, 'IMvideo.png')
# create a dynamic texture that will replace the static texture
logic.video = texture.Texture(obj, matID)
@@ -24,7 +24,7 @@ if not hasattr(logic, 'video'):
movie = logic.expandPath('//trailer_400p.ogg')
logic.video.source = texture.VideoFFmpeg(movie)
logic.video.source.scale = True
# quick off the movie, but it wont play in the background
logic.video.source.play()

15
doc/python_api/examples/blf.py Executable file → Normal file
View File

@@ -1,6 +1,7 @@
"""
Hello World Text Example
++++++++++++++++++++++++
Blender Game Engine example of using the blf module. For this module to work we
need to use the OpenGL wrapper :class:`~bgl` as well.
"""
@@ -11,31 +12,33 @@ from bge import logic
import bgl
import blf
def init():
"""init function - runs once"""
# create a new font object, use external ttf file
font_path = logic.expandPath('//Zeyada.ttf')
# store the font indice - to use later
# store the font indice - to use later
logic.font_id = blf.load(font_path)
# set the font drawing routine to run every frame
# set the font drawing routine to run every frame
scene = logic.getCurrentScene()
scene.post_draw=[write]
scene.post_draw = [write]
def write():
"""write on screen"""
width = render.getWindowWidth()
height = render.getWindowHeight()
# OpenGL setup
bgl.glMatrixMode(bgl.GL_PROJECTION)
bgl.glLoadIdentity()
bgl.gluOrtho2D(0, width, 0, height)
bgl.glMatrixMode(bgl.GL_MODELVIEW)
bgl.glLoadIdentity()
# BLF drawing routine
font_id = logic.font_id
blf.position(font_id, (width*0.2), (height*0.3), 0)
blf.position(font_id, (width * 0.2), (height * 0.3), 0)
blf.size(font_id, 50, 72)
blf.draw(font_id, "Hello World")

240
doc/python_api/rst/bge.constraints.rst Executable file → Normal file
View File

@@ -1,28 +1,51 @@
Game Engine bge.constraints Module
==================================
Physics Constraints (bge.constraints)
=====================================
.. note::
This documentation is still very weak, and needs some help!
.. module:: bge.constraints
.. function:: createConstraint([obj1, [obj2, [restLength, [restitution, [damping]]]]])
.. literalinclude:: ../examples/bge.constraints.py
.. function:: createConstraint(physicsid, physicsid2, constrainttype, [pivotX, pivotY, pivotZ, [axisX, axisY, axisZ, [flag]]]])
Creates a constraint.
:arg obj1: first object on Constraint
:type obj1: :class:'bge.types.KX_GameObject' #I think, there is no error when I use one
:arg physicsid: the physics id of the first object in constraint
:type physicsid: int
:arg obj2: second object on Constraint
:type obj2: :class:'bge.types.KX_GameObject' #too
:arg physicsid2: the physics id of the second object in constraint
:type physicsid2: int
:arg restLength: #to be filled
:type restLength: float
:arg constrainttype: the type of the constraint. The constraint types are:
:arg restitution: #to be filled
:type restitution: float
- :class:`POINTTOPOINT_CONSTRAINT`
- :class:`LINEHINGE_CONSTRAINT`
- :class:`ANGULAR_CONSTRAINT`
- :class:`CONETWIST_CONSTRAINT`
- :class:`VEHICLE_CONSTRAINT`
:arg damping: #to be filled
:type damping: float
:type constrainttype: int
:arg pivotX: pivot X position
:type pivotX: float
:arg pivotY: pivot Y position
:type pivotY: float
:arg pivotZ: pivot Z position
:type pivotZ: float
:arg axisX: X axis
:type axisX: float
:arg axisY: Y axis
:type axisY: float
:arg axisZ: Z axis
:type axisZ: float
:arg flag: .. to do
:type flag: int
.. attribute:: error
@@ -49,7 +72,7 @@ Game Engine bge.constraints Module
:type constraintId: int
:return: a vehicle constraint object.
:rtype: :class:'KX_VehicleWrapper'
:rtype: :class:`bge.types.KX_VehicleWrapper`
.. function:: removeConstraint(constraintId)
@@ -60,10 +83,10 @@ Game Engine bge.constraints Module
.. function:: setCcdMode(ccdMode)
..note::
.. note::
Very experimental, not recommended
Sets the CCD mode in the Physics Environment.
Sets the CCD (Continous Colision Detection) mode in the Physics Environment.
:arg ccdMode: The new CCD mode.
:type ccdMode: int
@@ -73,21 +96,21 @@ Game Engine bge.constraints Module
.. note::
Reasonable default is 0.02 (if units are meters)
Sets the contact breaking treshold in the Physics Environment.
Sets tresholds to do with contact point management.
:arg breakingTreshold: The new contact breaking treshold.
:type breakingTreshold: float
.. function:: setDeactivationAngularTreshold(angularTreshold)
Sets the deactivation angular treshold.
Sets the angular velocity treshold.
:arg angularTreshold: New deactivation angular treshold.
:type angularTreshold: float
.. function:: setDeactivationLinearTreshold(linearTreshold)
Sets the deactivation linear treshold.
Sets the linear velocity treshold.
:arg linearTreshold: New deactivation linear treshold.
:type linearTreshold: float
@@ -104,21 +127,20 @@ Game Engine bge.constraints Module
Sets the debug mode.
Debug modes:
- No debug: 0
- Draw wireframe: 1
- Draw Aabb: 2 #What's Aabb?
- Draw freatures text: 4
- Draw contact points: 8
- No deactivation: 16
- No help text: 32
- Draw text: 64
- Profile timings: 128
- Enable sat comparision: 256
- Disable Bullet LCP: 512
- Enable CCD: 1024
- Draw Constraints: #(1 << 11) = ?
- Draw Constraint Limits: #(1 << 12) = ?
- Fast Wireframe: #(1 << 13) = ?
- :class:`DBG_NODEBUG`
- :class:`DBG_DRAWWIREFRAME`
- :class:`DBG_DRAWAABB`
- :class:`DBG_DRAWFREATURESTEXT`
- :class:`DBG_DRAWCONTACTPOINTS`
- :class:`DBG_NOHELPTEXT`
- :class:`DBG_DRAWTEXT`
- :class:`DBG_PROFILETIMINGS`
- :class:`DBG_ENABLESATCOMPARISION`
- :class:`DBG_DISABLEBULLETLCP`
- :class:`DBG_ENABLECCD`
- :class:`DBG_DRAWCONSTRAINTS`
- :class:`DBG_DRAWCONSTRAINTLIMITS`
- :class:`DBG_FASTWIREFRAME`
:arg mode: The new debug mode.
:type mode: int
@@ -138,7 +160,10 @@ Game Engine bge.constraints Module
.. function:: setLinearAirDamping(damping)
Not implemented.
.. note::
Not implemented.
Sets the linear air damping for rigidbodies.
.. function:: setNumIterations(numiter)
@@ -156,10 +181,10 @@ Game Engine bge.constraints Module
.. function:: setSolverDamping(damping)
..note::
.. note::
Very experimental, not recommended
Sets the solver damping.
Sets the damper constant of a penalty based solver.
:arg damping: New damping for the solver.
:type damping: float
@@ -169,7 +194,7 @@ Game Engine bge.constraints Module
.. note::
Very experimental, not recommended
Sets the solver tau.
Sets the spring constant of a penalty based solver.
:arg tau: New tau for the solver.
:type tau: float
@@ -189,7 +214,7 @@ Game Engine bge.constraints Module
.. note::
Very experimental, not recommended
Sets the sor constant.
Sets the successive overrelaxation constant.
:arg sor: New sor value.
:type sor: float
@@ -197,3 +222,136 @@ Game Engine bge.constraints Module
.. function:: setUseEpa(epa)
Not implemented.
.. data:: DBG_NODEBUG
.. note::
Debug mode to be used with function :class:`setDebugMode`
No debug.
.. data:: DBG_DRAWWIREFRAME
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw wireframe in debug.
.. data:: DBG_DRAWAABB
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw Axis Aligned Bounding Box in debug.
.. data:: DBG_DRAWFREATURESTEXT
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw freatures text in debug.
.. data:: DBG_DRAWCONTACTPOINTS
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw contact points in debug.
.. data:: DBG_NOHELPTEXT
.. note::
Debug mode to be used with function :class:`setDebugMode`
Debug without help text.
.. data:: DBG_DRAWTEXT
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw text in debug.
.. data:: DBG_PROFILETIMINGS
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw profile timings in debug.
.. data:: DBG_ENABLESATCOMPARISION
.. note::
Debug mode to be used with function :class:`setDebugMode`
Enable sat comparision in debug.
.. data:: DBG_DISABLEBULLETLCP
.. note::
Debug mode to be used with function :class:`setDebugMode`
Disable Bullet LCP.
.. data:: DBG_ENABLECCD
.. note::
Debug mode to be used with function :class:`setDebugMode`
Enable Continous Colision Detection in debug.
.. data:: DBG_DRAWCONSTRAINTS
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw constraints in debug.
.. data:: DBG_DRAWCONSTRAINTLIMITS
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw constraint limits in debug.
.. data:: DBG_FASTWIREFRAME
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw a fast wireframe in debug.
.. data:: POINTTOPOINT_CONSTRAINT
.. note::
Constraint type to be used with function :class:`createConstraint`
.. to do
.. data:: LINEHINGE_CONSTRAINT
.. note::
Constraint type to be used with function :class:`createConstraint`
.. to do
.. data:: ANGULAR_CONSTRAINT
.. note::
Constraint type to be used with function :class:`createConstraint`
.. to do
.. data:: CONETWIST_CONSTRAINT
.. note::
Constraint type to be used with function :class:`createConstraint`
.. to do
.. data:: VEHICLE_CONSTRAINT
.. note::
Constraint type to be used with function :class:`createConstraint`
.. to do

View File

@@ -1,6 +1,6 @@
Game Engine bge.events Module
=============================
Game Keys (bge.events)
======================
*****
Intro

View File

@@ -1,6 +1,7 @@
Game Engine bge.logic Module
============================
Game Logic (bge.logic)
======================
*****
Intro
*****
@@ -216,6 +217,12 @@ General functions
Loads a scene into the game engine.
.. note::
This function is not effective immediately, the scene is queued
and added on the next logic cycle where it will be available
from `getSceneList`
:arg name: The name of the scene
:type name: string
:arg overlay: Overlay or underlay (optional)

View File

@@ -1,6 +1,6 @@
Game Engine bge.render Module
=============================
Rasterizer (bge.render)
=======================
*****
Intro
@@ -16,8 +16,8 @@ Intro
import bge.render
import bge.logic
# SCALE sets the speed of motion
SCALE=[1, 0.5]
# scale sets the speed of motion
scale = 1.0, 0.5
co = bge.logic.getCurrentController()
obj = co.getOwner()
@@ -27,8 +27,8 @@ Intro
# 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]
x = (bge.render.getWindowWidth() / 2 - mouse.getXPosition()) * scale[0]
y = (bge.render.getWindowHeight() / 2 - mouse.getYPosition()) * scale[1]
return (x, y)
pos = mousePos()
@@ -43,7 +43,7 @@ Intro
bge.logic.addActiveActuator(wmotion, True)
# Centre the mouse
bge.render.setMousePosition(bge.render.getWindowWidth()/2, bge.render.getWindowHeight()/2)
bge.render.setMousePosition(bge.render.getWindowWidth() / 2, bge.render.getWindowHeight() / 2)
*********
Constants

12
doc/python_api/rst/bge.texture.rst Executable file → Normal file
View File

@@ -1,10 +1,6 @@
Game Engine bge.texture Module
==============================
.. note::
This documentation is still very weak, and needs some help! Right now they are mostly a collection
of the docstrings found in the bge.texture source code + some random places filled with text.
Video Texture (bge.texture)
===========================
*****
Intro
@@ -40,6 +36,10 @@ When the texture object is deleted, the new texture is deleted and the old textu
.. module:: bge.texture
.. literalinclude:: ../examples/bge.texture.py
.. literalinclude:: ../examples/bge.texture.1.py
.. class:: VideoFFmpeg(file [, capture=-1, rate=25.0, width=0, height=0])
FFmpeg video source

View File

@@ -1,6 +1,6 @@
Game Engine bge.types Module
=============================
Game Types (bge.types)
======================
.. module:: bge.types

16
doc/python_api/rst/bgl.rst Executable file → Normal file
View File

@@ -1,6 +1,6 @@
bgl module (OpenGL wrapper)
===========================
OpenGL Wrapper (bgl)
====================
.. module:: bgl
@@ -15,7 +15,7 @@ collections of tutorials.
The "red book": "I{OpenGL Programming Guide: The Official Guide to Learning
OpenGL}" and the online NeHe tutorials are two of the best resources.
..note::
.. note::
You can use the :class:`Image` type to load and set textures.
See :class:`Image.gl_load` and :class:`Image.gl_load`,
for example.
@@ -71,8 +71,8 @@ OpenGL}" and the online NeHe tutorials are two of the best resources.
.. seealso:: `OpenGL Docs <http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/begin.html>`_
:type mode: Enumerated constant
:arg mode: Specifies the primitive that will be create from vertices between glBegin and
glEnd.
:arg mode: Specifies the primitive that will be create from vertices between
glBegin and glEnd.
.. function:: glBindTexture(target, texture):
@@ -1386,7 +1386,7 @@ OpenGL}" and the online NeHe tutorials are two of the best resources.
bgl.glGetFloatv(bgl.GL_MODELVIEW_MATRIX, view_matrix)
f = 1.0 / view_matrix[0]
# Instead of the usual glRasterPos2i(xval, yval)
# Instead of the usual glRasterPos2i(xval, yval)
bgl.glRasterPos2f(xval * f, yval * f)
@@ -1848,10 +1848,13 @@ class Buffer:
.. code-block:: python
import bgl
myByteBuffer = bgl.Buffer(bgl.GL_BYTE, [32, 32])
bgl.glGetPolygonStipple(myByteBuffer)
print(myByteBuffer.dimensions)
print(myByteBuffer.to_list())
sliceBuffer = myByteBuffer[0:16]
print(sliceBuffer)
@@ -1886,4 +1889,3 @@ class Buffer:
the Buffer. If a template is not passed in all fields will be initialized to 0.
:rtype: Buffer object
:return: The newly created buffer as a PyObject.

View File

@@ -416,6 +416,7 @@ def pymodule2sphinx(BASEPATH, module_name, module, title):
del key, descr
classes = []
submodules = []
for attribute in module_dir:
if not attribute.startswith("_"):
@@ -437,6 +438,8 @@ def pymodule2sphinx(BASEPATH, module_name, module, title):
py_c_func2sphinx("", fw, module_name, None, attribute, value, is_class=False)
elif value_type == type:
classes.append((attribute, value))
elif issubclass(value_type, types.ModuleType):
submodules.append((attribute, value))
elif value_type in (bool, int, float, str, tuple):
# constant, not much fun we can do here except to list it.
# TODO, figure out some way to document these!
@@ -444,12 +447,26 @@ def pymodule2sphinx(BASEPATH, module_name, module, title):
write_indented_lines(" ", fw, "constant value %s" % repr(value), False)
fw("\n")
else:
print("\tnot documenting %s.%s" % (module_name, attribute))
print("\tnot documenting %s.%s of %r type" % (module_name, attribute, value_type.__name__))
continue
attribute_set.add(attribute)
# TODO, more types...
# TODO, bpy_extras does this already, mathutils not.
"""
if submodules:
fw("\n"
"**********\n"
"Submodules\n"
"**********\n"
"\n"
)
for attribute, submod in submodules:
fw("* :mod:`%s.%s`\n" % (module_name, attribute))
fw("\n")
"""
# write collected classes now
for (type_name, value) in classes:
# May need to be its own function