public BioSegment Create(BioIK character)
 {
     Character = character;
     Transform = transform;
     hideFlags = HideFlags.HideInInspector;
     return(this);
 }
示例#2
0
 private void Start()
 {
     ik = GetComponent <BioIK.BioIK>();
     if (joints == null || targets == null || joints.Length == 0 || targets.Length == 0)
     {
         FindJoints();
     }
 }
示例#3
0
        public Model(BioIK character)
        {
            Character = character;

            //Set Root
            Root = Character.FindSegment(Character.transform);

            //Create Root
            AddNode(Root);

            //Build Model
            BioObjective[] objectives = CollectObjectives(Root, new List <BioObjective>());
            for (int i = 0; i < objectives.Length; i++)
            {
                List <BioSegment> chain = Character.GetChain(Root, objectives[i].Segment);
                for (int j = 1; j < chain.Count; j++)
                {
                    AddNode(chain[j]);
                }
            }

            //Assign DoF
            DoF = MotionPtrs.Length;

            //Initialise arrays for single transform modifications
            for (int i = 0; i < Nodes.Length; i++)
            {
                Nodes[i].ObjectiveImpacts = new bool[ObjectivePtrs.Length];
            }
            PX              = new double[ObjectivePtrs.Length];
            PY              = new double[ObjectivePtrs.Length];
            PZ              = new double[ObjectivePtrs.Length];
            RX              = new double[ObjectivePtrs.Length];
            RY              = new double[ObjectivePtrs.Length];
            RZ              = new double[ObjectivePtrs.Length];
            RW              = new double[ObjectivePtrs.Length];
            Configuration   = new double[MotionPtrs.Length];
            Gradient        = new double[MotionPtrs.Length];
            Losses          = new double[ObjectivePtrs.Length];
            SimulatedLosses = new double[ObjectivePtrs.Length];

            //Assigns references to all objective nodes that are affected by a parenting node
            for (int i = 0; i < ObjectivePtrs.Length; i++)
            {
                Node node = ObjectivePtrs[i].Node;
                while (node != null)
                {
                    node.ObjectiveImpacts[i] = true;
                    node = node.Parent;
                }
            }

            Refresh();

            //DebugSetup();
        }
示例#4
0
 void Awake()
 {
     EditorApplication.playmodeStateChanged += PlaymodeStateChanged;
     Target          = (BioIK)target;
     TargetTransform = Target.transform;
     Target.Refresh(false);
     DoF = 0;
     //MakeVisible(TargetTransform);
     //MakeInvisible(TargetTransform);
 }
示例#5
0
 public static BioSegment AddBioSegment(BioIK character, Transform t)
 {
                 #if UNITY_EDITOR
     if (Application.isPlaying)
     {
         return((t.gameObject.AddComponent(typeof(BioSegment)) as BioSegment).Create(character));
     }
     else
     {
         return((Undo.AddComponent(t.gameObject, typeof(BioSegment)) as BioSegment).Create(character));
     }
                 #else
     return((t.gameObject.AddComponent(typeof(BioSegment)) as BioSegment).Create(character));
                 #endif
 }
示例#6
0
 public void LoadModel(int index)
 {
     index -= 1;
     if (Models.Length > index)
     {
         if (ModelGO != null)
         {
             ModelGO.SetActive(false);
         }
         ModelCharacter = Models[index];
         ModelGO        = ModelCharacter.transform.root.gameObject;
         ModelGO.SetActive(true);
         UpdateMotionType();
     }
 }
示例#7
0
 public BioIKGroup(BioSegment _segment, BioIK.BioIK _body)
 {
     hand_segment = _segment;
     hand_body    = _body;
     enabled      = false;
 }
示例#8
0
 // Start is called before the first frame update
 void Start()
 {
     animator = GetComponent <Animator>();
     bioik    = GetComponentInChildren <BioIK.BioIK>();
 }