[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3536] contrib/py/scripts/addons/ game_engine_ragdolls_kit: updated, patch by Wraaah
Brendon Murphy
meta.androcto1 at gmail.com
Mon Jun 25 06:57:49 CEST 2012
Revision: 3536
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3536
Author: meta-androcto
Date: 2012-06-25 04:57:28 +0000 (Mon, 25 Jun 2012)
Log Message:
-----------
updated, patch by Wraaah
fix for contrib file path also
Modified Paths:
--------------
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/brik_funcs.py
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
Modified: contrib/py/scripts/addons/game_engine_ragdolls_kit/__init__.py
===================================================================
--- contrib/py/scripts/addons/game_engine_ragdolls_kit/__init__.py 2012-06-24 20:39:40 UTC (rev 3535)
+++ contrib/py/scripts/addons/game_engine_ragdolls_kit/__init__.py 2012-06-25 04:57:28 UTC (rev 3536)
@@ -1,6 +1,7 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Script copyright (C) Marcus Jenkins (Blenderartists user name FunkyWyrm)
+# Modified by Kees Brouwer (Blenderartists user name Wraaah)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -24,10 +25,11 @@
"author": "FunkyWyrm",
"version": (0,2),
"blender": (2, 5, 5),
+ "api": 31965,
"location": "View 3D > Tool Shelf > BRIK Panel",
"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.6/Py/"\
+ "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",
@@ -43,14 +45,47 @@
import bpy
################################################################################
+
##### REGISTER #####
def register():
+ #Register brik add-on
bpy.utils.register_module(__name__)
+
+ #Set-up gui menu properties using the bpy.types.Scene type
+ scnType = bpy.types.Scene
+
+ FloatProperty = bpy.props.FloatProperty
+ scnType.brik_ragdoll_mass = FloatProperty( name = "Ragdoll mass",
+ default = 80.0, min = 0.05, max= 99999,
+ description = "The total mass of the ragdoll rigid body structure created with BRIK",
+ update = brik.calc_ragdoll_mass)
+
+ # triplet setup.... ( return value, name, description )
+ EnumProperty = bpy.props.EnumProperty
+ menu_options = [ ( "All", "All", "Use all armature bones" ) ]
+ #enumProp = EnumProperty( name = "Bone selection", items = menu_options,
+ enumProp = EnumProperty( name = "Bone selection", items = brik_bone_list,
+ description = "Use the bones from the selected bone group" )
+
+ scnType.brik_bone_groups = enumProp
pass
def unregister():
bpy.utils.unregister_module(__name__)
pass
+def brik_bone_list(self, context):
+ ob = bpy.context.object
+ group_list = [ ( "All", "All", "Use all armature bones" ) ]
+ if ob.type == 'ARMATURE':
+ #Select bone groups
+ ob_pose = ob.pose
+ bone_groups = ob_pose.bone_groups
+ for item in bone_groups:
+ group_list = group_list + [(item.name, item.name, "Use bones in selected bone group")]
+
+ return group_list
+
if __name__ == "__main__":
register()
+
Modified: contrib/py/scripts/addons/game_engine_ragdolls_kit/brik.py
===================================================================
--- contrib/py/scripts/addons/game_engine_ragdolls_kit/brik.py 2012-06-24 20:39:40 UTC (rev 3535)
+++ contrib/py/scripts/addons/game_engine_ragdolls_kit/brik.py 2012-06-25 04:57:28 UTC (rev 3536)
@@ -3,6 +3,7 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Script copyright (C) Marcus Jenkins (Blenderartists user name FunkyWyrm)
+# Modified by Kees Brouwer (Blenderartists user name Wraaah)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -76,19 +77,20 @@
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
-
+ scn = bpy.context.scene
layout = self.layout
col = layout.column()
+
if ob:
col.prop(ob, 'name', text = 'Selected', icon = 'OUTLINER_OB_'+str(ob.type))
@@ -96,23 +98,39 @@
box = layout.box()
box.label(text = 'Create or remove?')
+
if ob.type == 'ARMATURE':
+ brik_structure = 'brik_structure_created' in ob.keys() and ob['brik_structure_created']
+ hitboxes = 'brik_hit_boxes_created' in ob.keys() and ob['brik_hit_boxes_created']
+
+ col.label(text = 'BRIK structure settings')
+ row = col.row()
+ col.prop( scn, "brik_ragdoll_mass" )
+ col.prop( scn, "brik_bone_groups" )
+
col = box.column(align=True)
- col.operator('object.brik_create_structure', text = 'Create structure')
+ row = col.row()
+ row.active = not(brik_structure)
+ row.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.active = brik_structure
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()
+ row.active = not(hitboxes)
+# col = box.column(align = True)
+ row.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.active = hitboxes
row.operator('object.brik_remove_hit_boxes', text = 'Remove hit boxes')
+
+ row = col.row()
+ row.active = hitboxes and brik_structure
+ row.operator('object.brik_link_structure', text = 'Link objects')
+
else:
box.label(text='Select armature')
@@ -129,6 +147,39 @@
else:
col.label(text='Select an object')
+
+ def test_func(operator):
+ print(operator)
+
+class brik_link_structure(bpy.types.Operator):
+ bl_label = 'brik link structure operator'
+ bl_idname = 'object.brik_link_structure'
+ bl_description = 'Links the object data of the hitboxes and corresponding rigid bodies'
+ bl_options = {'REGISTER', 'UNDO'}
+
+ def draw(self, context):
+ #No menu options available
+ pass
+ #Create links
+ def execute(self, context):
+ armature = bpy.context.active_object
+ driver_dict = armature['brik_bone_driver_dict']
+ hitbox_dict = armature['brik_bone_hit_box_dict']
+ objects = bpy.data.objects
+ for bone_name in hitbox_dict:
+ hitbox = objects[hitbox_dict[bone_name]]
+# print(driver_dict, bone_name, objects)
+ driver_box = objects[driver_dict[bone_name]]
+ #select hitbox
+ select_name(name = hitbox_dict[bone_name], extend = False)
+ #select driver_box
+ select_name(name = driver_dict[bone_name], extend = True)
+ #create link
+ bpy.ops.object.make_links_data(type='OBDATA')
+ #return original selection
+ select_name(name = armature.name, extend = False)
+
+ return{'FINISHED'}
class brik_create_structure(bpy.types.Operator):
bl_label = 'brik create structure operator'
@@ -160,6 +211,11 @@
description='Add all created objects to a group',\
default=True)
+ invisible = BoolProperty(name='Invisible',\
+ description='Make boxes invisible for rendering',\
+ default=True)
+
+
box_type = EnumProperty(name="Box type",
description="Shape that rigid body objects are created from.",
items=[ \
@@ -175,69 +231,83 @@
#Create the rigid body boxes
def create_boxes(self, armature):
- bones_dict = armature.pose.bones #Dictionary of posebones
- bones = bones_dict.values()
- armature = bpy.context.object
+ bones = bone_group_list(armature)
RB_dict = {} #Dictionary of rigid body objects
armature['brik_bone_driver_dict'] = {}
armature['brik_armature_locator_name'] = ''
- #All deforming bones have boxes created for them
+ #All deforming bones within selected group(s) have boxes created for them
for bone in bones:
- if bone.bone.use_deform:
- #print(self.box_type)
- box = None
- volume = 0.0
- #Create boxes that do not exist
- if self.box_type == 'BONE':
- box, volume = create_box(self.prefix, self.driver_length, self.driver_width, armature, bone)
- elif self.box_type == 'BBONE':
- box, volume = create_box_bbone(self.prefix, armature, bone)
- elif self.box_type == 'ENVELOPE':
- box, volume = create_box_envelope(self.prefix, armature, bone)
- #box = create_box(self.prefix, self.driver_length, self.driver_width, armature, bone)
- RB_dict[box.name] = box
- armature['brik_bone_driver_dict'][bone.name] = box.name
+
+ box = None
+ #Create boxes that do not exist
+ if self.box_type == 'BONE':
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list