[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1831] contrib/py/scripts/addons/ game_engine_ragdolls_kit: Angular limits from IK now applied to rigid body joints.
Marcus Jenkins
funkywyrm at gmail.com
Fri Apr 15 00:13:36 CEST 2011
Revision: 1831
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1831
Author: funkywyrm
Date: 2011-04-14 22:13:35 +0000 (Thu, 14 Apr 2011)
Log Message:
-----------
Angular limits from IK now applied to rigid body joints. Adding ragdolls at runtime and driving armature currently broken, but rigid body structure performs correctly when game starts with rigid body structure on active layer.
Modified Paths:
--------------
contrib/py/scripts/addons/game_engine_ragdolls_kit/brik.py
contrib/py/scripts/addons/game_engine_ragdolls_kit/templates/brik_load.py
Modified: contrib/py/scripts/addons/game_engine_ragdolls_kit/brik.py
===================================================================
--- contrib/py/scripts/addons/game_engine_ragdolls_kit/brik.py 2011-04-14 17:28:41 UTC (rev 1830)
+++ contrib/py/scripts/addons/game_engine_ragdolls_kit/brik.py 2011-04-14 22:13:35 UTC (rev 1831)
@@ -452,6 +452,9 @@
pos_z = obj['joint_position_z']
itemString = str(pos_x)+"\n"+str(pos_y)+"\n"+str(pos_z)+"\n"
dataFile.write(itemString)
+ '''
+ #Should no longer need to do this.
+
#Write rigid body joint limits to the file
max_x = obj['rot_max_x']
max_y = obj['rot_max_y']
@@ -463,6 +466,7 @@
min_z = obj['rot_min_z']
itemString = str(min_x)+"\n"+str(min_y)+"\n"+str(min_z)+"\n"
dataFile.write(itemString)
+ '''
dataFile.write("'''")
@@ -954,13 +958,30 @@
RB_joint.pivot_y = -bone.length/2
RB_joint.target = RB_dict[boxObj['brik_joint_target']]
RB_joint.use_linked_collision = True
+ RB_joint.pivot_type = ("GENERIC_6_DOF")
+ RB_joint.limit_angle_max_x = bone.ik_max_x
+ RB_joint.limit_angle_max_y = bone.ik_max_y
+ RB_joint.limit_angle_max_z = bone.ik_max_z
+ RB_joint.limit_angle_min_x = bone.ik_min_x
+ RB_joint.limit_angle_min_y = bone.ik_min_y
+ RB_joint.limit_angle_min_z = bone.ik_min_z
+ RB_joint.use_limit_x = True
+ RB_joint.use_limit_y = True
+ RB_joint.use_limit_z = True
+ RB_joint.use_angular_limit_x = True
+ RB_joint.use_angular_limit_y = True
+ RB_joint.use_angular_limit_z = True
+ #For some reason the limits are not being applied correctly!
else:
boxObj['brik_joint_target'] = 'None'
-
+
+ #I think the above code should do this...
+
#It would be nice to use IK limits to define rigid body joint limits,
#but the limit arrays have not yet been wrapped in RNA apparently...
#properties_object_constraint.py in ui directory, line 554 says:
#Missing: Limit arrays (not wrapped in RNA yet)
+ #From store_joint_data in write_game_file:
def add_boxes_to_group(self, armature, RB_dict):
print("Adding boxes to group")
Modified: contrib/py/scripts/addons/game_engine_ragdolls_kit/templates/brik_load.py
===================================================================
--- contrib/py/scripts/addons/game_engine_ragdolls_kit/templates/brik_load.py 2011-04-14 17:28:41 UTC (rev 1830)
+++ contrib/py/scripts/addons/game_engine_ragdolls_kit/templates/brik_load.py 2011-04-14 22:13:35 UTC (rev 1831)
@@ -85,12 +85,15 @@
JOINT_POSITION_X = 4
JOINT_POSITION_Y = 5
JOINT_POSITION_Z = 6
+ '''
+ #should no longer need to do this.
JOINT_LIMIT_MAX_X = 7
JOINT_LIMIT_MAX_Y = 8
JOINT_LIMIT_MAX_Z = 9
JOINT_LIMIT_MIN_X = 10
JOINT_LIMIT_MIN_Y = 11
JOINT_LIMIT_MIN_Z = 12
+ '''
scene = bge.logic.getCurrentScene()
cont = bge.logic.getCurrentController()
@@ -197,12 +200,15 @@
box['joint_position'] = [float(data[Box.JOINT_POSITION_X]),\
float(data[Box.JOINT_POSITION_Y]),\
float(data[Box.JOINT_POSITION_Z])]
+ '''
+ #should no longer need to do this
box['limit_rotation_x'] = [float(data[Box.JOINT_LIMIT_MIN_X]),\
float(data[Box.JOINT_LIMIT_MAX_X])]
box['limit_rotation_y'] = [float(data[Box.JOINT_LIMIT_MIN_Y]),\
float(data[Box.JOINT_LIMIT_MAX_Y])]
box['limit_rotation_z'] = [float(data[Box.JOINT_LIMIT_MIN_Z]),\
float(data[Box.JOINT_LIMIT_MAX_Z])]
+ '''
hit_box = objects[data[Box.HIT_BOX_NAME]]
hit_box['bone_name'] = data[Box.BONE_NAME]
armature['bone_box_dict'][box['bone_name']] = box.name
More information about the Bf-extensions-cvs
mailing list