public void BIND(object[] args)
{
//Vector3 targetRotation;
//Helper.PrintRDFTriples (rdfTriples);
bool r = false;
foreach (object arg in args) {
if (arg == null) {
r = true;
break;
}
}
if (r) {
return;
}
GameObject container = null;
Vector3 boundsCenter = Vector3.zero,boundsSize = Vector3.zero;
if (args [args.Length - 1] is bool) {
if ((bool)args [args.Length - 1] == true) {
if (args [args.Length - 2] is String) {
container = new GameObject ((args [args.Length - 2] as String).Replace("\"",""));
}
else {
container = new GameObject ("bind");
}
if (args.Length-1 == 0) {
container.transform.position = Vector3.zero;
}
// get bounds of composite to be created
List<GameObject> objs = new List<GameObject> ();
foreach (object arg in args) {
if (arg is GameObject) {
objs.Add (arg as GameObject);
}
}
Bounds bounds = Helper.GetObjectWorldSize (objs);
boundsCenter = container.transform.position = bounds.center;
boundsSize = bounds.size;
// nuke any relations between objects to be bound
RelationTracker relationTracker = (RelationTracker)GameObject.Find("BehaviorController").GetComponent("RelationTracker");
List<object> toRemove = new List<object>();
foreach (DictionaryEntry pair in relationTracker.relations) {
if (objs.Contains ((pair.Key as List<GameObject>) [0]) && objs.Contains ((pair.Key as List<GameObject>) [1])) {
toRemove.Add (pair.Key);
}
}
foreach (object key in toRemove) {
relationTracker.RemoveRelation (key as List<GameObject>);
}
// bind objects
foreach (object arg in args) {
if (arg is GameObject) {
(arg as GameObject).GetComponent<Voxeme>().enabled = false;
(arg as GameObject).GetComponent<Rigging>().ActivatePhysics(false);
Collider[] colliders = (arg as GameObject).GetComponentsInChildren<Collider> ();
foreach (Collider collider in colliders) {
collider.isTrigger = false;
}
(arg as GameObject).transform.parent = container.transform;
if (!(args [args.Length - 2] is String)) {
container.name = container.name + " " + (arg as GameObject).name;
}
}
}
}
}
if (container != null) {
container.AddComponent<Voxeme> ();
container.AddComponent<Rigging> ();
BoxCollider collider = container.AddComponent<BoxCollider> ();
//collider.center = boundsCenter;
collider.size = boundsSize;
collider.isTrigger = true;
}
}