[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28296] trunk/blender/source/gameengine/ PyDoc: BGE EPY Docs: PhysicsConstraints and fixes in other modules

Dalai Felinto dfelinto at gmail.com
Tue Apr 20 10:23:25 CEST 2010


Revision: 28296
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28296
Author:   dfelinto
Date:     2010-04-20 10:23:22 +0200 (Tue, 20 Apr 2010)

Log Message:
-----------
BGE EPY Docs: PhysicsConstraints and fixes in other modules
PhysicsConstraints module documented by Jean-Fran?\195?\167ois (Ninja Goliath) based on GameKit 2nd ed.
Thanks for the initiative and the great help!

General advice for anyone helping with EpyDocs:
* use :: instead of : to keep the indentation correct,
* use B{} for clarity when needed (e.g. createConstraints)

Adding F13 to F19 to complement Matt's recent commit
* There are other (not so important) functions in PhysicsConstraints module that are not exposed in the documentation right now.

The generated page is temporarily here, if someone want to review it:
http://blenderecia.orgfree.com/blender/tmp/PhysicsConstraints-module.html

Modified Paths:
--------------
    trunk/blender/source/gameengine/PyDoc/GameKeys.py
    trunk/blender/source/gameengine/PyDoc/GameLogic.py
    trunk/blender/source/gameengine/PyDoc/GameTypes.py
    trunk/blender/source/gameengine/PyDoc/PhysicsConstraints.py
    trunk/blender/source/gameengine/PyDoc/VideoTexture.py

Modified: trunk/blender/source/gameengine/PyDoc/GameKeys.py
===================================================================
--- trunk/blender/source/gameengine/PyDoc/GameKeys.py	2010-04-20 02:39:07 UTC (rev 28295)
+++ trunk/blender/source/gameengine/PyDoc/GameKeys.py	2010-04-20 08:23:22 UTC (rev 28296)
@@ -13,7 +13,7 @@
 	
 	co = GameLogic.getCurrentController()
 	# 'Keyboard' is a keyboard sensor
-	sensor = co.getSensor('Keyboard')
+	sensor = co.sensors["Keyboard"]
 	sensor.key = GameKeys.F1KEY
 
 Example::
@@ -23,18 +23,18 @@
 	
 	co = GameLogic.getCurrentController()
 	# 'Keyboard' is a keyboard sensor
-	sensor = co.getSensor('Keyboard')
-	keylist = sensor.events
-	for key in keylist:
+	sensor = co.sensors["Keyboard"]
+
+	for key,status in sensor.events:
 		# key[0] == GameKeys.keycode, key[1] = status
-		if key[1] == GameLogic.KX_INPUT_JUST_ACTIVATED:
-			if key[0] == GameKeys.WKEY:
+		if status == GameLogic.KX_INPUT_JUST_ACTIVATED:
+			if key == GameKeys.WKEY:
 				# Activate Forward!
-			if key[0] == GameKeys.SKEY:
+			if key == GameKeys.SKEY:
 				# Activate Backward!
-			if key[0] == GameKeys.AKEY:
+			if key == GameKeys.AKEY:
 				# Activate Left!
-			if key[0] == GameKeys.DKEY:
+			if key == GameKeys.DKEY:
 				# Activate Right!
 
 @group Alphabet keys: AKEY, BKEY, CKEY, DKEY, EKEY, FKEY, GKEY, HKEY, IKEY, JKEY, KKEY, LKEY, MKEY, NKEY, OKEY, PKEY, QKEY, RKEY, SKEY, TKEY, UKEY, VKEY, WKEY, XKEY, YKEY, ZKEY
@@ -110,7 +110,7 @@
 @var PADENTER:
 @var PADPLUSKEY:
 
- at group Function Keys: F1KEY, F2KEY, F3KEY, F4KEY, F5KEY, F6KEY, F7KEY, F8KEY, F9KEY, F10KEY, F11KEY, F12KEY
+ at group Function Keys: F1KEY, F2KEY, F3KEY, F4KEY, F5KEY, F6KEY, F7KEY, F8KEY, F9KEY, F10KEY, F11KEY, F12KEY, F13KEY, F14KEY, F15KEY, F16KEY, F17KEY, F18KEY, F19KEY
 @var F1KEY:
 @var F2KEY:
 @var F3KEY:
@@ -123,6 +123,13 @@
 @var F10KEY:
 @var F11KEY:
 @var F12KEY:
+ at var F13KEY:
+ at var F14KEY:
+ at var F15KEY:
+ at var F16KEY:
+ at var F17KEY:
+ at var F18KEY:
+ at var F19KEY:
 
 @group Other Keys: ACCENTGRAVEKEY, BACKSLASHKEY, BACKSPACEKEY, COMMAKEY, DELKEY, ENDKEY, EQUALKEY, ESCKEY, HOMEKEY, INSERTKEY, LEFTBRACKETKEY, LINEFEEDKEY, MINUSKEY, PAGEDOWNKEY, PAGEUPKEY, PAUSEKEY, PERIODKEY, QUOTEKEY, RIGHTBRACKETKEY, RETKEY, SEMICOLONKEY, SLASHKEY, SPACEKEY, TABKEY
 @var ACCENTGRAVEKEY:

Modified: trunk/blender/source/gameengine/PyDoc/GameLogic.py
===================================================================
--- trunk/blender/source/gameengine/PyDoc/GameLogic.py	2010-04-20 02:39:07 UTC (rev 28295)
+++ trunk/blender/source/gameengine/PyDoc/GameLogic.py	2010-04-20 08:23:22 UTC (rev 28296)
@@ -361,8 +361,8 @@
 	
 	@param name: The name of the scene
 	@type name: string
-	@param body: Overlay or underlay (optional)
-	@type body: int
+	@param overlay: Overlay or underlay (optional)
+	@type overlay: int
 	"""
 def sendMessage(subject, body="", to="", message_from=""):
 	"""
@@ -402,7 +402,7 @@
 	Gets the maximum number of logic frame per render frame.
 	
 	@return: The maximum number of logic frame per render frame
-	@rtype: interger
+	@rtype: integer
 	"""
 def setMaxLogicFrame(maxlogic):
 	"""
@@ -417,7 +417,7 @@
 	Gets the maximum number of physics frame per render frame.
 	
 	@return: The maximum number of physics frame per render frame
-	@rtype: interger
+	@rtype: integer
 	"""
 def setMaxPhysicsFrame(maxphysics):
 	"""

Modified: trunk/blender/source/gameengine/PyDoc/GameTypes.py
===================================================================
--- trunk/blender/source/gameengine/PyDoc/GameTypes.py	2010-04-20 02:39:07 UTC (rev 28295)
+++ trunk/blender/source/gameengine/PyDoc/GameTypes.py	2010-04-20 08:23:22 UTC (rev 28296)
@@ -108,7 +108,7 @@
 		"""
 #}
 
-class SCA_PythonKeyboard(PyObjectPlus)
+class SCA_PythonKeyboard(PyObjectPlus):
 	"""
 	The current keyboard.	
 	@ivar events: a list of pressed keys that have either been pressed, or just released, or are active this frame. (read-only).
@@ -124,7 +124,7 @@
 	"""
 	pass
 	
-class SCA_PythonMouse(PyObjectPlus)
+class SCA_PythonMouse(PyObjectPlus):
 	"""
 	The current mouse.
 	

Modified: trunk/blender/source/gameengine/PyDoc/PhysicsConstraints.py
===================================================================
--- trunk/blender/source/gameengine/PyDoc/PhysicsConstraints.py	2010-04-20 02:39:07 UTC (rev 28295)
+++ trunk/blender/source/gameengine/PyDoc/PhysicsConstraints.py	2010-04-20 08:23:22 UTC (rev 28296)
@@ -1,126 +1,294 @@
 # $Id$
 """
 Documentation for the PhysicsConstraints module.
+================================================
 
-Example:
+Example::
+	
+	
+	#  Adding a point constraint  #
+	###############################
+	
+	
+	# import BGE internal module
 	import PhysicsConstraints
-	import GameLogic
+	
+	# get object list
+	obj_list = GameLogic.getCurrentScene().objects
+	
+	# get object named Obj_1
+	root = obj_list["root"]
+	obj = obj_list["obj"]
 
+	# get object physics ID
+	phido = obj.getPhysicsId()
+	
+	# get root physics ID
+	phidr = root.getPhysicsId()
+
+	# want to use point constraint type
+	constraint_type = 1
+	
+	# Use bottom right front corner of object for point constraint position
+	point_pos_x = 1.0
+	point_pos_y = -1.0
+	point_pos_z = -1.0
+	
+	# create a point constraint
+	const =	PhysicsConstraints.createConstraint( phido, phidr, constraint_type, point_pos_x, point_pos_y, point_pos_z)
+
+	# stores the new constraint ID to be used later
+	obj["constraint_ID"] = const.getConstraintId()	
+	
+	
+Example::
+	
+	
+	#  Removing a point constraint  #
+	#################################
+	
+	
+	# import BGE internal module
+	import PhysicsConstraints
+	
+	# get object list
+	obj_list = GameLogic.getCurrentScene().objects
+	
+	# get object 1
+	obj = obj_list["obj"]
+	
+	# get constraint ID that was saved as an obj property
+	# when the constraint was created
+	constraint_ID = obj["constraint_ID"]
+	
+	# remove constraint
+	PhysicsConstraints.removeConstraint(constraint_ID)
+
 """
-# TODO
-# error
 
-def createConstraint():
-	"""
-	Does something
+def createConstraint(obj_PhysicsID, root_PhysicsID, constraintType, pointPos_x, pointPos_y, pointPos_z, edgePos_x, edgePos_y, edgePos_z, edgeAngle_x, edgeAngle_y, edgeAngle_z):
+	"""	
+	Create a point constraint between two objects, an edge constraint between two objects, or a vehicle constraint on an object.
 	
-	@rtype: 
-	"""
-def getAppliedImpulse():
-	"""
-	Does something
+	You only have to input the needed parammeters depending on the type of constraint you are trying to create.
 	
-	@rtype: 
-	"""
-def getVehicleConstraint():
-	"""
-	Does something
+
+	B{Point Constraint} ::
 	
-	@rtype: 
-	"""
-def removeConstraint():
-	"""
-	Does something
+		While creating a point constraint, the "pointPos" values define where you want the pivot point to be located.
+		If you are creating a point constraint be sure to assing the integer "1" as the constraintType value.
 	
-	@rtype: 
-	"""
-def setCcdMode():
-	"""
-	Does something
+		Parameters to use:
+		obj_PhysicsID, root_PhysicsID, constraintType, pointPos_x, pointPos_y, pointPos_z
 	
-	@rtype: 
-	"""
-def setContactBreakingTreshold():
-	"""
-	Does something
+	B{Edge Constraint} ::
+		
+		While creating an edge constraint, the "edgePos" values define where you want the center of the edge constraint to be.
+		Also, the "edgeAngle" values define in which direction you want the edge constraint to point (As a 3 dimensions vector).
+		If you want to create an edge constraint be sure to assing the integer "2" as the constraintType value.
+
+		Parameters to use:
+		obj_PhysicsID, root_PhysicsID, constraintType, edgePos_x, edgePos_y, edgePos_z, edgeAngle_x, edgeAngle_y, edgeAngle_z}		
 	
-	@rtype: 
-	"""
-def setDeactivationAngularTreshold():
-	"""
-	Does something
+	B{Vehicle Constraint} ::
+		
+		While creating a point constraint, the "pointPos" values define where you want the pivot point to be located.
+		If you want to create an edge constraint be sure to assing the integer "0" as the constraintType value.
+
+		Parameters to use :
+		obj_PhysicsID, root_PhysicsID, constraintType
 	
-	@rtype: 
+	@type obj_PhysicsID: integer
+	@param obj_PhysicsID: The physic ID of the first object to constraint.
+
+	@type root_PhysicsID: integer
+	@param root_PhysicsID: The physic ID of the second object to constraint.
+
+	@type constraintType: integer
+	@param constraintType: The type of constraint.
+
+	@type pointPos_x: float
+	@param pointPos_x: The X position of the point constraint.
+
+	@type pointPos_y: float
+	@param pointPos_y: The Y position of the point constraint.
+
+	@type pointPos_z: float
+	@param pointPos_z: The Z position of the point constraint.
+
+	@type edgePos_x: float
+	@param edgePos_x: The X value of the center of the edge constraint.
+
+	@type edgePos_y: float
+	@param edgePos_y: The Y value of the center of the edge constraint.
+
+	@type edgePos_z: float
+	@param edgePos_z: The Z value of the center of the edge constraint.
+
+	@type edgeAngle_x: float
+	@param edgeAngle_x: The X value of the edge's orientation vector.
+
+	@type edgeAngle_y: float
+	@param edgeAngle_y: The Y value of the edge's orientation vector.
+
+	@type edgeAngle_z: float
+	@param edgeAngle_z: The Z value of the edge's orientation vector.
+
+	@rtype: integer
+	@return: The created constraint ID
 	"""
-def setDeactivationLinearTreshold():
-	"""
-	Does something
 	
-	@rtype: 
+
+def getAppliedImpulse(constraint_ID):
 	"""
-def setDeactivationTime():
-	"""
-	Does something
+	Returns the applied impulse.
 	
-	@rtype: 
+	@param constraint_ID: The constraint ID that was saved on the creation of the constraint.
+	@type constraint_ID: integer
+	@rtype: float
+	@return: Measure the stress on a constraint.
 	"""
-def setDebugMode():
+
+
+def getVehicleConstraint(constraint_ID):
 	"""
-	Does something
+	Returns the vehicle constraint ID.
 	
-	@rtype: 
+	@param constraint_ID: The constraint ID that was saved on the creation of the constraint.
+	@type constraint_ID: integer
+	@rtype: integer
 	"""
-def setGravity():
+def removeConstraint(constraint_ID):
 	"""
-	Does something
 	
-	@rtype: 
+	Removes the constraint between 2 game objects (point and edge constraints).
+	
+	It does not remove vehicle constraints.
+	
+	@param constraint_ID: The constraint ID that was saved on the creation of the constraint.
+	@type constraint_ID: integer
 	"""
-def setLinearAirDamping():
+def setDeactivationLinearTreshold(linearTreshold):
 	"""
-	Does something
 	
-	@rtype: 
+	Sets the linear velocity that an object must be below before the deactivation timer can start.
+	

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list