summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2016-05-09 10:25:30 -0400
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2016-05-09 10:25:30 -0400
commit184a5fd82be3a4969ac6547367d1aad458129461 (patch)
tree86b262109072ce50228935d1a31f5f4613e4f92e
parentd69c01ba80f733ab04d9d5e9588033ad5764331f (diff)
SL-315 - resetSkeleton() work, dae_tool.py can add random joint positions to models
-rwxr-xr-xindra/newview/llvoavatar.cpp37
-rwxr-xr-xindra/newview/llvoavatar.h1
-rw-r--r--scripts/content_tools/dae_tool.py28
3 files changed, 66 insertions, 0 deletions
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 979bf96151..22df9c43d7 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -1811,6 +1811,7 @@ void LLVOAvatar::resetSkeleton()
// Stop all animations
// Clear all attachment pos overrides
+ clearAttachmentPosOverrides();
// Preserve state of tweakable params
@@ -1841,6 +1842,7 @@ void LLVOAvatar::resetSkeleton()
#endif
// Restore attachment pos overrides
+ rebuildAttachmentPosOverrides();
// Restart animations
}
@@ -5328,9 +5330,44 @@ void LLVOAvatar::clearAttachmentPosOverrides()
pJoint->clearAttachmentPosOverrides();
}
}
+
+ // Attachment points
+ for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin();
+ iter != mAttachmentPoints.end();
+ ++iter)
+ {
+ LLViewerJointAttachment *attachment_pt = (*iter).second;
+ if (attachment_pt)
+ {
+ attachment_pt->clearAttachmentPosOverrides();
+ }
+ }
}
//-----------------------------------------------------------------------------
+// rebuildAttachmentPosOverrides
+//-----------------------------------------------------------------------------
+void LLVOAvatar::rebuildAttachmentPosOverrides()
+{
+ LLScopedContextString str("rebuildAttachmentPosOverrides " + getFullname());
+
+ // Attachment points
+ for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
+ iter != mAttachmentPoints.end();
+ ++iter)
+ {
+ LLViewerJointAttachment *attachment_pt = (*iter).second;
+ if (attachment_pt)
+ {
+ for (LLViewerJointAttachment::attachedobjs_vec_t::iterator at_it = attachment_pt->mAttachedObjects.begin();
+ at_it != attachment_pt->mAttachedObjects.end(); ++at_it)
+ {
+ addAttachmentPosOverridesForObject(*at_it);
+ }
+ }
+ }
+}
+//-----------------------------------------------------------------------------
// addAttachmentPosOverridesForObject
//-----------------------------------------------------------------------------
void LLVOAvatar::addAttachmentPosOverridesForObject(LLViewerObject *vo)
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index c6bc2fd58f..0a3965a597 100755
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -206,6 +206,7 @@ public:
bool jointIsRiggedTo(const std::string& joint_name);
bool jointIsRiggedTo(const std::string& joint_name, const LLViewerObject *vo);
void clearAttachmentPosOverrides();
+ void rebuildAttachmentPosOverrides();
void showAttachmentPosOverrides(bool verbose = false) const;
void getAttachmentOverrideNames(std::set<std::string>& names) const;
diff --git a/scripts/content_tools/dae_tool.py b/scripts/content_tools/dae_tool.py
index 8ac6c7582f..823f69cb85 100644
--- a/scripts/content_tools/dae_tool.py
+++ b/scripts/content_tools/dae_tool.py
@@ -27,6 +27,7 @@ $/LicenseInfo$
"""
import argparse
+import random
# Need to pip install numpy and pycollada
import numpy as np
@@ -59,12 +60,35 @@ def mesh_lock_offsets(tree, joints):
print joint_node.get("name"),matrix_node.tag,"text",matrix_node.text,len(floats),floats
+def mesh_random_offsets(tree, joints):
+ print "mesh_random_offsets",tree,joints
+ for joint_node in tree.iter():
+ if "node" not in joint_node.tag:
+ continue
+ if joint_node.get("type") != "JOINT":
+ continue
+ if not joint_node.get("name"):
+ continue
+ if joint_node.get("name") in joints or "bone" in joints:
+ for matrix_node in list(joint_node):
+ if "matrix" in matrix_node.tag:
+ floats = [float(x) for x in matrix_node.text.split()]
+ print "randomizing",floats
+ if len(floats) == 16:
+ floats[3] += random.uniform(-1.0,1.0)
+ floats[7] += random.uniform(-1.0,1.0)
+ floats[11] += random.uniform(-1.0,1.0)
+ matrix_node.text = " ".join([str(f) for f in floats])
+ print joint_node.get("name"),matrix_node.tag,"text",matrix_node.text,len(floats),floats
+
+
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="process SL animations")
parser.add_argument("--verbose", action="store_true",help="verbose flag")
parser.add_argument("infilename", help="name of a collada (dae) file to input")
parser.add_argument("outfilename", nargs="?", help="name of a collada (dae) file to output", default = None)
parser.add_argument("--lock_offsets", nargs="+", help="tweak position of listed joints to lock their offsets")
+ parser.add_argument("--random_offsets", nargs="+", help="random offset position for listed joints")
parser.add_argument("--summary", action="store_true", help="print summary info about input file")
args = parser.parse_args()
@@ -84,6 +108,10 @@ if __name__ == "__main__":
print "locking offsets for",args.lock_offsets
mesh_lock_offsets(tree, args.lock_offsets)
+ if args.random_offsets:
+ print "adding random offsets for",args.random_offsets
+ mesh_random_offsets(tree, args.random_offsets)
+
if args.outfilename:
print "writing",args.outfilename
f = open(args.outfilename,"w")