[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20189] trunk/blender: * More updates to game engine type docs from Roelf de Kock

Campbell Barton ideasman42 at gmail.com
Thu May 14 00:52:32 CEST 2009


Revision: 20189
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20189
Author:   campbellbarton
Date:     2009-05-14 00:52:31 +0200 (Thu, 14 May 2009)

Log Message:
-----------
* More updates to game engine type docs from Roelf de Kock

* FBX Bugfix, was exporting all animation curves as 'Constant' type (no docs for this so could only guess), Thanks to Sander Brandenburg for spotting this problem.
Also improved keyframe removal to work on animation curves an angle

Modified Paths:
--------------
    trunk/blender/release/scripts/export_fbx.py
    trunk/blender/source/gameengine/PyDoc/GameTypes.py

Modified: trunk/blender/release/scripts/export_fbx.py
===================================================================
--- trunk/blender/release/scripts/export_fbx.py	2009-05-13 17:02:39 UTC (rev 20188)
+++ trunk/blender/release/scripts/export_fbx.py	2009-05-13 22:52:31 UTC (rev 20189)
@@ -2611,10 +2611,9 @@
 										if frame!=act_start:
 											file.write(',')
 										
-										# Curve types are 
+										# Curve types are 'C,n' for constant, 'L' for linear
 										# C,n is for bezier? - linear is best for now so we can do simple keyframe removal
-										file.write('\n\t\t\t\t\t\t\t%i,%.15f,C,n'  % (fbx_time(frame-1), context_bone_anim_vecs[frame-act_start][i] ))
-										#file.write('\n\t\t\t\t\t\t\t%i,%.15f,L'  % (fbx_time(frame-1), context_bone_anim_vecs[frame-act_start][i] ))
+										file.write('\n\t\t\t\t\t\t\t%i,%.15f,L'  % (fbx_time(frame-1), context_bone_anim_vecs[frame-act_start][i] ))
 										frame+=1
 								else:
 									# remove unneeded keys, j is the frame, needed when some frames are removed.
@@ -2622,11 +2621,32 @@
 									
 									# last frame to fisrt frame, missing 1 frame on either side.
 									# removeing in a backwards loop is faster
-									for j in xrange( (act_end-act_start)-1, 0, -1 ):
-										# Is this key reduenant?
-										if	abs(context_bone_anim_keys[j][0] - context_bone_anim_keys[j-1][0]) < ANIM_OPTIMIZE_PRECISSION_FLOAT and\
-											abs(context_bone_anim_keys[j][0] - context_bone_anim_keys[j+1][0]) < ANIM_OPTIMIZE_PRECISSION_FLOAT:
+									#for j in xrange( (act_end-act_start)-1, 0, -1 ):
+									# j = (act_end-act_start)-1
+									j = len(context_bone_anim_keys)-2
+									while j > 0 and len(context_bone_anim_keys) > 2:
+										# print j, len(context_bone_anim_keys)
+										# Is this key the same as the ones next to it?
+										
+										# co-linear horizontal...
+										if		abs(context_bone_anim_keys[j][0] - context_bone_anim_keys[j-1][0]) < ANIM_OPTIMIZE_PRECISSION_FLOAT and\
+												abs(context_bone_anim_keys[j][0] - context_bone_anim_keys[j+1][0]) < ANIM_OPTIMIZE_PRECISSION_FLOAT:
+												
 											del context_bone_anim_keys[j]
+											
+										else:
+											frame_range = float(context_bone_anim_keys[j+1][1] - context_bone_anim_keys[j-1][1])
+											frame_range_fac1 = (context_bone_anim_keys[j+1][1] - context_bone_anim_keys[j][1]) / frame_range
+											frame_range_fac2 = 1.0 - frame_range_fac1
+											
+											if abs(((context_bone_anim_keys[j-1][0]*frame_range_fac1 + context_bone_anim_keys[j+1][0]*frame_range_fac2)) - context_bone_anim_keys[j][0]) < ANIM_OPTIMIZE_PRECISSION_FLOAT:
+												del context_bone_anim_keys[j]
+											else:
+												j-=1
+											
+										# keep the index below the list length
+										if j > len(context_bone_anim_keys)-2:
+											j = len(context_bone_anim_keys)-2
 									
 									if len(context_bone_anim_keys) == 2 and context_bone_anim_keys[0][0] == context_bone_anim_keys[1][0]:
 										# This axis has no moton, its okay to skip KeyCount and Keys in this case
@@ -2639,8 +2659,7 @@
 											if frame != context_bone_anim_keys[0][1]: # not the first
 												file.write(',')
 											# frame is alredy one less then blenders frame
-											file.write('\n\t\t\t\t\t\t\t%i,%.15f,C,n'  % (fbx_time(frame), val ))
-											#file.write('\n\t\t\t\t\t\t\t%i,%.15f,L'  % (fbx_time(frame), val ))
+											file.write('\n\t\t\t\t\t\t\t%i,%.15f,L'  % (fbx_time(frame), val ))
 								
 								if		i==0:	file.write('\n\t\t\t\t\t\tColor: 1,0,0')
 								elif	i==1:	file.write('\n\t\t\t\t\t\tColor: 0,1,0')
@@ -2919,7 +2938,7 @@
 		Draw.BeginAlign()
 		GLOBALS['ANIM_OPTIMIZE'] =				Draw.Toggle('Optimize Keyframes',	EVENT_REDRAW, x+20,  y+0, 160, 20, GLOBALS['ANIM_OPTIMIZE'].val,	'Remove double keyframes', do_redraw)
 		if GLOBALS['ANIM_OPTIMIZE'].val:
-			GLOBALS['ANIM_OPTIMIZE_PRECISSION'] =	Draw.Number('Precission: ',			EVENT_NONE, x+180,  y+0, 160, 20, GLOBALS['ANIM_OPTIMIZE_PRECISSION'].val,	3, 16, 'Tolerence for comparing double keyframes (higher for greater accuracy)')
+			GLOBALS['ANIM_OPTIMIZE_PRECISSION'] =	Draw.Number('Precission: ',			EVENT_NONE, x+180,  y+0, 160, 20, GLOBALS['ANIM_OPTIMIZE_PRECISSION'].val,	1, 16, 'Tolerence for comparing double keyframes (higher for greater accuracy)')
 		Draw.EndAlign()
 		
 		Draw.BeginAlign()
@@ -2997,7 +3016,7 @@
 	# animation opts
 	GLOBALS['ANIM_ENABLE'] =				Draw.Create(1)
 	GLOBALS['ANIM_OPTIMIZE'] =				Draw.Create(1)
-	GLOBALS['ANIM_OPTIMIZE_PRECISSION'] =	Draw.Create(6) # decimal places
+	GLOBALS['ANIM_OPTIMIZE_PRECISSION'] =	Draw.Create(4) # decimal places
 	GLOBALS['ANIM_ACTION_ALL'] =			[Draw.Create(0), Draw.Create(1)] # not just the current action
 	
 	# batch export options

Modified: trunk/blender/source/gameengine/PyDoc/GameTypes.py
===================================================================
--- trunk/blender/source/gameengine/PyDoc/GameTypes.py	2009-05-13 17:02:39 UTC (rev 20188)
+++ trunk/blender/source/gameengine/PyDoc/GameTypes.py	2009-05-13 22:52:31 UTC (rev 20189)
@@ -512,8 +512,7 @@
 
 	def delSource():
 		"""
-		TODO - Description
-
+		Clear the shader. Use this method before the source is changed with L{setSource}.
 		"""
 	def getFragmentProg():
 		"""
@@ -997,39 +996,56 @@
 	"""
 	KX_BlenderMaterial
 	
-	All placeholders have a __ prefix
 	"""
 	
-	def __getShader(val):
+	def getShader():
 		"""
-		TODO - Description
+		Returns the material's shader.
 		
-		@param val: the starting frame of the animation
-		@type val: float
-		
-		@rtype: integer
-		@return: TODO Description
+		@rtype: L{BL_Shader}
+		@return: the material's shader
 		"""
 
-	def __setBlending(val):
+	def setBlending(src, dest):
 		"""
-		TODO - Description
+		Set the pixel color arithmetic functions.
 		
-		@param val: the starting frame of the animation
-		@type val: float
+		@param src: Specifies how the red, green, blue,
+                    and alpha source blending factors are computed.
+		@type src: 	GL_ZERO,
+					GL_ONE,
+					GL_SRC_COLOR,
+					GL_ONE_MINUS_SRC_COLOR,
+					GL_DST_COLOR,
+					GL_ONE_MINUS_DST_COLOR,
+					GL_SRC_ALPHA,
+					GL_ONE_MINUS_SRC_ALPHA,
+					GL_DST_ALPHA,
+					GL_ONE_MINUS_DST_ALPHA,
+					GL_SRC_ALPHA_SATURATE
+
 		
-		@rtype: integer
-		@return: TODO Description
+		@param dest: Specifies how the red, green, blue,
+                    and alpha destination blending factors are computed.
+		@type dest: GL_ZERO,
+					GL_ONE,
+					GL_SRC_COLOR,
+					GL_ONE_MINUS_SRC_COLOR,
+					GL_DST_COLOR,
+					GL_ONE_MINUS_DST_COLOR,
+					GL_SRC_ALPHA,
+					GL_ONE_MINUS_SRC_ALPHA,
+					GL_DST_ALPHA,
+					GL_ONE_MINUS_DST_ALPHA,
+					GL_SRC_ALPHA_SATURATE
+
 		"""
-	def __getMaterialIndex(val):
+	def getMaterialIndex():
 		"""
-		TODO - Description
+		Returns the material's index.
 		
-		@param val: the starting frame of the animation
-		@type val: float
-		
 		@rtype: integer
-		@return: TODO Description
+		@return: the material's index
 		"""
 
 class KX_CDActuator(SCA_IActuator):
@@ -1419,30 +1435,15 @@
 	"""
 	KX_ConstraintWrapper
 	
-	All placeholders have a __ prefix
 	"""
-	def __getConstraintId(val):
+	def getConstraintId(val):
 		"""
-		TODO - Description
+		Returns the contraint's ID
 		
-		@param val: the starting frame of the animation
-		@type val: float
-		
 		@rtype: integer
-		@return: TODO Description
+		@return: the constraint's ID
 		"""
 
-	def __testMethod(val):
-		"""
-		TODO - Description
-		
-		@param val: the starting frame of the animation
-		@type val: float
-		
-		@rtype: integer
-		@return: TODO Description
-		"""
-
 class KX_GameActuator(SCA_IActuator):
 	"""
 	The game actuator loads a new .blend file, restarts the current .blend file or quits the game.





More information about the Bf-blender-cvs mailing list