summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/content_tools/anim_tool.py13
-rw-r--r--scripts/content_tools/skel_tool.py59
2 files changed, 62 insertions, 10 deletions
diff --git a/scripts/content_tools/anim_tool.py b/scripts/content_tools/anim_tool.py
index 0cb1e1022e..9b795f45fd 100644
--- a/scripts/content_tools/anim_tool.py
+++ b/scripts/content_tools/anim_tool.py
@@ -29,6 +29,7 @@ $/LicenseInfo$
"""
import sys
+import os
import struct
import StringIO
import math
@@ -511,6 +512,11 @@ def resolve_joints(names, skel_tree, lad_tree):
if __name__ == "__main__":
+ # default search location for config files is defined relative to
+ # the script location; assuming they live in the same viewer repo
+ pathname = os.path.dirname(sys.argv[0])
+ path_to_skel = os.path.join(os.path.abspath(pathname),"..","..","indra","newview","character")
+
parser = argparse.ArgumentParser(description="process SL animations")
parser.add_argument("--verbose", help="verbose flag", action="store_true")
parser.add_argument("--dump", help="dump to specified file")
@@ -518,11 +524,12 @@ if __name__ == "__main__":
parser.add_argument("--rand_pos", help="request random positions", action="store_true")
parser.add_argument("--reset_pos", help="request original positions", action="store_true")
parser.add_argument("--pos", help="specify sequence of positions", type=float_triple, nargs="+")
+ parser.add_argument("--num_pos", help="number of positions to create", type=int, default=2)
parser.add_argument("--delete_joints", help="specify joints to be deleted", nargs="+")
parser.add_argument("--joints", help="specify joints to be added or modified", nargs="+")
parser.add_argument("--summary", help="print summary of the output animation", action="store_true")
- parser.add_argument("--skel", help="name of the avatar_skeleton file", default="avatar_skeleton.xml")
- parser.add_argument("--lad", help="name of the avatar_lad file", default="avatar_lad.xml")
+ parser.add_argument("--skel", help="name of the avatar_skeleton file", default= os.path.join(path_to_skel,"avatar_skeleton.xml"))
+ parser.add_argument("--lad", help="name of the avatar_lad file", default= os.path.join(path_to_skel,"avatar_lad.xml"))
parser.add_argument("--set_version", nargs=2, type=int, help="set version and sub-version to specified values")
parser.add_argument("--no_hud", help="omit hud joints from list of attachments", action="store_true")
parser.add_argument("infilename", help="name of a .anim file to input")
@@ -566,7 +573,7 @@ if __name__ == "__main__":
anim.add_pos(joints, args.pos)
if joints and args.rand_pos:
for joint in joints:
- pos_array = list(tuple(random.uniform(-1,1) for i in xrange(3)) for j in xrange(2))
+ pos_array = list(tuple(random.uniform(-1,1) for i in xrange(3)) for j in xrange(args.num_pos))
pos_array.append(pos_array[0])
anim.add_pos([joint], pos_array)
if joints and args.reset_pos:
diff --git a/scripts/content_tools/skel_tool.py b/scripts/content_tools/skel_tool.py
index f7301c55e1..7fefa59293 100644
--- a/scripts/content_tools/skel_tool.py
+++ b/scripts/content_tools/skel_tool.py
@@ -52,11 +52,17 @@ def fix_name(element):
def enforce_precision_rules(element):
pass
-def float_tuple(str):
+def float_tuple(str, n=3):
try:
- return [float(e) for e in str.split(" ")]
+ result = tuple(float(e) for e in str.split())
+ if len(result)==n:
+ return result
+ else:
+ print "tuple length wrong:", str,"gave",result,"wanted len",n,"got len",len(result)
+ raise Exception()
except:
- return (0,0,0)
+ print "convert failed for:",str
+ raise
def check_symmetry(name, field, vec1, vec2):
if vec1[0] != vec2[0]:
@@ -232,6 +238,41 @@ def validate_skel_tree(tree, ogtree, reftree, fix=False):
print "BAD FILE:", unfixable,"errs could not be fixed"
+def slider_info(ladtree,skeltree):
+ for param in ladtree.iter("param"):
+ for skel_param in param.iter("param_skeleton"):
+ bones = [b for b in skel_param.iter("bone")]
+ if bones:
+ print "param",param.get("name"),"id",param.get("id")
+ value_min = float(param.get("value_min"))
+ value_max = float(param.get("value_max"))
+ neutral = 100.0 * (0.0-value_min)/(value_max-value_min)
+ print " neutral",neutral
+ for b in bones:
+ scale = float_tuple(b.get("scale","0 0 0"))
+ offset = float_tuple(b.get("offset","0 0 0"))
+ print " bone", b.get("name"), "scale", scale, "offset", offset
+ print " scale",scale
+ print " offset",offset
+ scale_min = [value_min * s for s in scale]
+ scale_max = [value_max * s for s in scale]
+ offset_min = [value_min * t for t in offset]
+ offset_max = [value_max * t for t in offset]
+ if (scale_min != scale_max):
+ print " Scale MinX", scale_min[0]
+ print " Scale MinY", scale_min[1]
+ print " Scale MinZ", scale_min[2]
+ print " Scale MaxX", scale_max[0]
+ print " Scale MaxY", scale_max[1]
+ print " Scale MaxZ", scale_max[2]
+ if (offset_min != offset_max):
+ print " Offset MinX", offset_min[0]
+ print " Offset MinY", offset_min[1]
+ print " Offset MinZ", offset_min[2]
+ print " Offset MaxX", offset_max[0]
+ print " Offset MaxY", offset_max[1]
+ print " Offset MaxZ", offset_max[2]
+
# Check contents of avatar_lad file relative to a specified skeleton
def validate_lad_tree(ladtree,skeltree,orig_ladtree):
print "validate_lad_tree"
@@ -366,17 +407,18 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser(description="process SL avatar_skeleton/avatar_lad files")
parser.add_argument("--verbose", action="store_true",help="verbose flag")
- parser.add_argument("--ogfile", help="specify file containing base bones")
+ parser.add_argument("--ogfile", help="specify file containing base bones", default="avatar_skeleton_orig.xml")
parser.add_argument("--ref_file", help="specify another file containing replacements for missing fields")
- parser.add_argument("--lad_file", help="specify avatar_lad file to check")
- parser.add_argument("--orig_lad_file", help="specify avatar_lad file to compare to")
+ parser.add_argument("--lad_file", help="specify avatar_lad file to check", default="avatar_lad.xml")
+ parser.add_argument("--orig_lad_file", help="specify avatar_lad file to compare to", default="avatar_lad_orig.xml")
parser.add_argument("--aliases", help="specify file containing bone aliases")
parser.add_argument("--validate", action="store_true", help="check specified input file for validity")
parser.add_argument("--fix", action="store_true", help="try to correct errors")
parser.add_argument("--remove", nargs="+", help="remove specified joints")
parser.add_argument("--list", action="store_true", help="list joint names")
parser.add_argument("--compare", help="alternate skeleton file to compare")
- parser.add_argument("infilename", help="name of a skel .xml file to input")
+ parser.add_argument("--slider_info", help="information about the lad file sliders and affected bones", action="store_true")
+ parser.add_argument("infilename", help="name of a skel .xml file to input", default="avatar_skeleton.xml")
parser.add_argument("outfilename", nargs="?", help="name of a skel .xml file to output")
args = parser.parse_args()
@@ -426,6 +468,9 @@ if __name__ == "__main__":
compare_tree = etree.parse(args.compare)
compare_skel_trees(compare_tree,tree)
+ if ladtree and tree and args.slider_info:
+ slider_info(ladtree,tree)
+
if args.outfilename:
f = open(args.outfilename,"w")
print >>f, etree.tostring(tree, pretty_print=True) #need update to get: , short_empty_elements=True)