예제 #1
0
 //This function is called when the script is loaded or a value is changed in the inspector (Called in the editor only).
 public override void OnValidate()
 {
     MUtil.logEvent(this, "OnValidate");
     needsUpdate = true;
     if (!Application.isPlaying)
     {
         needsReset = true;
     }
 }
예제 #2
0
 public void reset()
 {
     MUtil.logEvent(this, "reset");
     //if (body == null) return;
     needsReset = false;
     engine.reset(transform.position, transform.rotation);
     targetPos = transform.position;
     targetRot = transform.rotation;
 }
예제 #3
0
        //TODO call when needed only
        public override void updateData()
        {
            MUtil.logEvent(this, "updateData");
            normalRel             = normalRel.normalized;
            rotationJoint.axisRel = normalRel;
            elbowJoint.radius1    = r1;
            elbowJoint.radius2    = r2;
            bones[0].r            = r1;
            bones[1].r            = r2;
            maxLen = (r1 + r2) * 0.99f;//*0.99 because elbow junction "sticks" when it is close to the limit

            base.updateData();
        }
예제 #4
0
 public override void OnEnable()
 {
     base.OnEnable();
     MUtil.logEvent(this, "OnEnable");
     needsUpdate = true;
     if (body != null)
     {
         bodyRigid = body.GetComponent <Rigidbody>();
     }
     else
     {
         bodyRigid = GetComponent <Rigidbody>();
     }
 }
예제 #5
0
        public override void updateData()
        {
            MUtil.logEvent(this, "updateData");

//            rotJoint.axisRel = axis;
            rotJoint.axisRel          = rotJoint.axisRel.normalized;
            rotJoint.secondaryAxisRel = rotJoint.secondaryAxisRel.normalized;
            elbowJoint.radius1        = r1;
            elbowJoint.radius2        = r2;
            bones[0].r = r1;
            bones[1].r = r2;
            bones[2].r = footPlatformHeight;
            minLen     = Math.Abs(r1 - r2) * 1.1f;
            maxLen     = r1 + r2;


            base.updateData();
        }
예제 #6
0
 public virtual void reset(Vector3 pos, Quaternion rot)
 {
     MUtil.logEvent(this, ("reset " + pos));
     this.comfortRadius = ((this.maxLen * 0.5f) * this.comfortRadiusRatio);
     this.bodyPos       = pos;
     this.bodyRot       = rot;
     this.bestTargetConservativeUnprojAbs = (Step2.toAbs(this.comfortPosRel, this.bodyPos, rot) + this.additionalDisplacement);
     this.bestTargetConservativeAbs       = this.bestTargetConservativeUnprojAbs;
     this.bestTargetProgressiveAbs        = this.bestTargetConservativeUnprojAbs;
     this.posAbs          = this.bestTargetConservativeUnprojAbs;
     this.oldPosAbs       = this.bestTargetConservativeUnprojAbs;
     this.speedAbs        = new Vector3();
     this.acceleration    = new Vector3();
     this.undockPauseCur  = 0;
     this.airTime         = 0;
     this.undockProgress  = 100500;
     this.undockCurTime   = 100500;
     this.footOrientation = rot;
 }
예제 #7
0
        //This function is called when the script is loaded or a value is changed in the inspector (Called in the editor only).
        public override void OnValidate()
        {
            MUtil.logEvent(this, "OnValidate");
            base.OnValidate();
            int targetBonesCount = bones.Count;

            if (bonesGeometry.Count != targetBonesCount)
            {
                Debug.LogWarning("Don't change array size!");
                if (bonesGeometry.Count > targetBonesCount)
                {
                    bonesGeometry.RemoveRange(targetBonesCount, bonesGeometry.Count - targetBonesCount);
                }
                while (bonesGeometry.Count < targetBonesCount)
                {
                    bonesGeometry.Add(null);
                }
            }
            needsUpdate = true;
        }
예제 #8
0
        public override void updateData()
        {
            MUtil.logEvent(this, "updateData");
            rotJoint.axisRel          = rotJoint.axisRel.normalized;
            rotJoint.secondaryAxisRel = rotJoint.secondaryAxisRel.normalized;

            //((SkelLeg2) legSkel).updateRadiuses(step.footPlatformHeight, rA + rC * style, rB + rC * (1 - style), rA, rB, rC);


            if (style)
            {
                r1 = rA + styleRatio * rB;
                r2 = maxLen - r1;
                visibleElbowJoint.radius1 = rB;
                visibleElbowJoint.radius2 = rC;
            }
            else
            {
                r2 = rC + styleRatio * rB;
                r1 = maxLen - r2;
                visibleElbowJoint.radius1 = rA;
                visibleElbowJoint.radius2 = rB;
            }

            maxLen = rA + rB + rC;
//            minLen = 0;
            minLen = Math.Abs(r1 - r2) * 1.1f;
//            minLen = Math.Max(rA, Math.Max(rB, Math.Max(rC, Math.Abs(r1 - r2))));


            invisibleElbowJoint.radius1 = r1;
            invisibleElbowJoint.radius2 = r2;

            bones[0].r = rA;
            bones[1].r = rB;
            bones[2].r = rC;
            bones[3].r = footPlatformHeight;

            base.updateData();
        }
 public void OnTransformChildrenChanged()
 {
     MUtil.logEvent(this, "OnTransformChildrenChanged");
     needsUpdate = true;
 }
예제 #10
0
 public override void reset()
 {
     MUtil.logEvent(this, "reset");
     base.reset();
     tick(1);
 }
예제 #11
0
        public void updateData()
        {
            MUtil.logEvent(this, "updateData");
            needsUpdate = false;
            //TODO update height
            //TODO only update, not create

            engine.steps.Clear();
            engine.legSkel.Clear();

            MoveenStep2[] step2s = transform.gameObject.GetComponentsInChildren <MoveenStep2>();
            for (int index = 0; index < step2s.Length; index++)
            {
                var step2 = step2s[index];
                if (!step2.isActiveAndEnabled)
                {
                    continue;
                }
                step2.step.thisTransform = step2.transform;

//            for (int i = 0; i < transform.childCount; i++) {
//                Transform child = transform.GetChild(i);
//                MoveenStep2 step2 = child.GetComponent<MoveenStep2>();
                if (!Application.isPlaying)
                {
//we can't do this at runtime, because basises are changed by the flexible hip
                    step2.step.basisPosRel = step2.transform.localPosition;
                    step2.step.basisRotRel = step2.transform.localRotation;
                }

                MoveenSkelBase skelDesc = step2.transform.GetComponent <MoveenSkelBase>();
                if (!skelDesc.isActiveAndEnabled)
                {
                    skelDesc = null;
                }
                engine.legSkel.Add(skelDesc);
                if (skelDesc == null)
                {
                    continue;
                }

                step2.step.maxLen          = skelDesc.maxLen;
                step2.step.surfaceDetector = engine.surfaceDetector;
                if (!step2.step.detachedComfortPosRel && !Application.isPlaying)
                {
                    Vector3 tipAbs = skelDesc.transform.TransformPoint(skelDesc.targetPosRel);
                    step2.step.comfortPosRel = transform.rotation.conjug().rotate(tipAbs - transform.position);//can't use Inverse, because in the enine - only rotation and translation is used
                }
                engine.steps.Add(step2.step);

                //skelDesc.checkNeeds();
            }
            if (engine.steps.Count < 4)
            {
                AssetsGo2SSkeletonsV.fillNeuroSimple(engine.steps, engine.rewardSelf, engine.rewardOthers);
            }
            else
            {
                AssetsGo2SSkeletonsV.fillNeuroNPares2(engine.steps, engine.rewardPare);
            }
        }
예제 #12
0
 //update inner structures in response to GameObject params change
 public virtual void updateData()
 {
     MUtil.logEvent(this, "updateData");
     needsUpdate = false;
     //if (!Application.isPlaying) reset();
 }
예제 #13
0
 public MoveenSkelBase()
 {
     MUtil.logEvent(this, "constructor", true);
     executionOrder = 1;
 }