[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1297] contrib/py/scripts/addons: Adding the Blender Ragdoll Implementation Kit (BRIK) by Marcus Jenkins ( funkywyrm)
Mitchell Stokes
mogurijin at gmail.com
Tue Dec 21 23:38:31 CET 2010
Revision: 1297
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1297
Author: moguri
Date: 2010-12-21 23:38:30 +0100 (Tue, 21 Dec 2010)
Log Message:
-----------
Adding the Blender Ragdoll Implementation Kit (BRIK) by Marcus Jenkins (funkywyrm)
Tracker link: https://projects.blender.org/tracker/?func=detail&atid=467&aid=24946&group_id=153
Added Paths:
-----------
contrib/py/scripts/addons/game_engine_ragdolls_kit/
contrib/py/scripts/addons/game_engine_ragdolls_kit/__init__.py
contrib/py/scripts/addons/game_engine_ragdolls_kit/brik.py
contrib/py/scripts/addons/game_engine_ragdolls_kit/templates/
contrib/py/scripts/addons/game_engine_ragdolls_kit/templates/brik_init_ragdoll.py
contrib/py/scripts/addons/game_engine_ragdolls_kit/templates/brik_load.py
contrib/py/scripts/addons/game_engine_ragdolls_kit/templates/brik_spawn.py
Added: contrib/py/scripts/addons/game_engine_ragdolls_kit/__init__.py
===================================================================
--- contrib/py/scripts/addons/game_engine_ragdolls_kit/__init__.py (rev 0)
+++ contrib/py/scripts/addons/game_engine_ragdolls_kit/__init__.py 2010-12-21 22:38:30 UTC (rev 1297)
@@ -0,0 +1,55 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# Script copyright (C) Marcus Jenkins (Blenderartists user name FunkyWyrm)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# ***** END GPL LICENCE BLOCK *****
+# --------------------------------------------------------------------------
+
+bl_addon_info = {
+ "name": "BRIK - Blender Ragdoll Implementation Kit",
+ "author": "FunkyWyrm",
+ "version": (0,2),
+ "blender": (2, 5, 5),
+ "api": 31965,
+ "location": "Tool Shelf",
+ "description": "Kit for creating ragdoll structures from armatures and implementing them in the game engine.",
+ "warning": "Preliminary release for testing purposes. Use with caution on important files.",
+ "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/Game_Engine/BRIK_ragdolls",
+ "tracker_url": "https://projects.blender.org/tracker/index.php?func=detail&aid=24946&group_id=153&atid=468",
+ "category": "Game Engine"}
+
+import bpy
+
+try:
+ init_data
+
+ reload(brik)
+except:
+ from game_engine_ragdolls_kit import brik
+
+init_data = True
+
+################################################################################
+##### REGISTER #####
+def register():
+ pass
+
+def unregister():
+ pass
+
+if __name__ == "__main__":
+ register()
\ No newline at end of file
Added: contrib/py/scripts/addons/game_engine_ragdolls_kit/brik.py
===================================================================
--- contrib/py/scripts/addons/game_engine_ragdolls_kit/brik.py (rev 0)
+++ contrib/py/scripts/addons/game_engine_ragdolls_kit/brik.py 2010-12-21 22:38:30 UTC (rev 1297)
@@ -0,0 +1,1084 @@
+#BRIK_0_2.py
+
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# Script copyright (C) Marcus Jenkins (Blenderartists user name FunkyWyrm)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# ***** END GPL LICENCE BLOCK *****
+# --------------------------------------------------------------------------
+
+"""
+BRIK is the Blender Ragdoll Implementation Kit.
+
+It aims to provide a tool kit that enables the easy implementation of ragdolls in Blender.
+
+Acnowledgements:
+
+This section comes first because I am grateful to Thomas Eldredge (teldredge on
+www.blenderartists.com). Without his great script to take apart, I would never have got
+around to this even though it's been in my todo list for a while. The link to his thread is
+http://blenderartists.org/forum/showthread.php?t=152150
+
+Website:
+ Blenderartists script development thread is:
+ http://blenderartists.org/forum/showthread.php?t=199191
+
+Bugs:
+
+ Editing a text file after hitting the create or destroy button and then
+ changing an option such as writing the hierarchy file will undo the edits
+ to the text. This is a known bug due to the lack of a text editor global
+ undo push. See the bug tracker:
+ https://projects.blender.org/tracker/index.php?func=detail&aid=21043&group_id=9&atid=498
+
+ Creating rigid body structures based on multiple armatures in the scene that have similarly
+ named bones can cause some rigid body objects to be removed. This can probably be fixed by
+ testing for membership of a group. However, similarly named bones should be renamed to a
+ unique name since bone name and driver object name being similar is essential for correct
+ operation of both the BRIK script and the BRIK_Use_doll game engine script.
+
+ Running Create multiple times on the same armature will recreate the rigid body joints
+ rather than editing existing ones.
+
+Notes:
+
+ The mass of each object could be calculated using their volume. The
+ armature could be assigned a mass and the bones' mass could be calculated
+ from this using their volume.
+
+ Non-deforming bones do not have rigid body objects created for them.
+ Perhaps this would be better given as a toggle option.
+"""
+
+import bpy
+from bpy.props import *
+import mathutils
+from mathutils import Vector
+
+class VIEW3D_PT_BRIK_panel(bpy.types.Panel):
+
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'TOOLS'
+ bl_context = 'objectmode'
+ bl_label = 'BRIK'
+
+ #Draws the panel header in the tools pane
+ def draw_header(self, context):
+ layout = self.layout
+ layout.label(text='', icon='CONSTRAINT_BONE')
+
+ #Draws the BRIK panel in the tools pane
+ def draw(self, context):
+
+ ob = bpy.context.object
+
+ layout = self.layout
+
+ col = layout.column()
+ if ob:
+ col.prop(ob, 'name', text = 'Selected', icon = 'OUTLINER_OB_'+str(ob.type))
+
+ layout.separator()
+
+ box = layout.box()
+ box.label(text = 'Create or remove?')
+
+ if ob.type == 'ARMATURE':
+ col = box.column(align=True)
+ col.operator('object.BRIK_create_structure', text = 'Create structure')
+
+ row = col.row()
+ remove_structure_active = 'BRIK_structure_created' in ob.keys() and ob['BRIK_structure_created']
+ row.active = remove_structure_active
+ row.operator('object.BRIK_destroy_structure', text = 'Remove structure')
+
+ col = box.column(align = True)
+ col.operator('object.BRIK_create_hit_boxes', text = 'Create hit boxes')
+
+ row = col.row()
+ remove_hit_boxes_active = 'BRIK_hit_boxes_created' in ob.keys() and ob['BRIK_hit_boxes_created']
+ row.active = remove_hit_boxes_active
+ row.operator('object.BRIK_remove_hit_boxes', text = 'Remove hit boxes')
+ else:
+ box.label(text='Select armature')
+
+ game_options_active = 'BRIK_structure_created' in ob.keys() and ob['BRIK_structure_created'] \
+ and 'BRIK_hit_boxes_created' in ob.keys() and ob['BRIK_hit_boxes_created']
+ col = box.column(align = True)
+ col.active = game_options_active
+ col.label(text='Game options:')
+ col.operator('object.BRIK_write_game_file', text = 'Write game file')
+ create_logic_active = 'BRIK_file_written' in ob.keys() and ob['BRIK_file_written']
+ row = col.row()
+ row.active = create_logic_active
+ row.operator('object.BRIK_create_game_logic', text = 'Create game logic')
+
+ else:
+ col.label(text='Select an object')
+
+class BRIK_create_game_logic(bpy.types.Operator):
+ bl_label = 'BRIK create game logic operator'
+ bl_idname = 'object.BRIK_create_game_logic'
+ bl_description = 'Create the game logic for the created objects.'
+ bl_options = {'REGISTER', 'UNDO'}
+
+ template_path = bpy.utils.script_paths()[0]+'\\addons\\game_engine_ragdolls_kit\\templates\\'
+
+ game_script_list = ['brik_load.py', \
+ 'brik_init_ragdoll.py', \
+ 'brik_spawn.py']
+
+
+ def set_up_armature_logic(self, armature):
+
+ if not 'BRIK_use_ragdoll' in armature.game.properties:
+
+ bpy.ops.object.game_property_new()
+ prop = armature.game.properties[-1]
+ prop.name = 'BRIK_use_ragdoll'
+ prop.type = 'BOOL'
+ prop.value = False
+
+ bpy.ops.object.game_property_new()
+ prop = armature.game.properties[-1]
+ prop.name = 'BRIK_init_ragdoll'
+ prop.type = 'BOOL'
+ prop.value = True
+
+ #Logic to spawn the rigid body boxes
+ bpy.ops.logic.sensor_add(type='PROPERTY', name='BRIK_use_changed_sens', object=armature.name)
+ sens = armature.game.sensors[-1]
+ sens.property = 'BRIK_use_ragdoll'
+ sens.evaluation_type = 'PROPCHANGED'
+
+ bpy.ops.logic.controller_add(type='PYTHON', name='BRIK_init_ragdoll_cont', object=armature.name)
+ cont = armature.game.controllers[-1]
+ cont.mode = 'MODULE'
+ cont.module = 'brik_init_ragdoll.main'
+
+ bpy.ops.logic.actuator_add(type='EDIT_OBJECT', name='BRIK_spawn_boxes_act', object=armature.name)
+ act = armature.game.actuators[-1]
+ act.mode = 'ADDOBJECT'
+
+ cont.link(sens, act)
+
+ #Logic to change the value of BRIK_use_ragdoll property
+ bpy.ops.logic.sensor_add(type='KEYBOARD', name='BRIK_set_use_ragdoll_sens', object=armature.name)
+ sens = armature.game.sensors[-1]
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list