public void UpdateIKTargetPosition() { if (iktarget != null) { if (sprObject != null) { PHIKEndEffectorIf phIKee = sprObject as PHIKEndEffectorIf; if (phIKee.GetOriCtlMode() == PHIKEndEffectorDesc.OriCtlMode.MODE_LOOKAT) { phIKee.SetTargetLookat(iktarget.transform.position.ToVec3d()); } else { phIKee.SetTargetPosition(iktarget.transform.position.ToVec3d()); // 現在の姿勢からの回転角がより少ない方のQuaternionに変換 Quaterniond qT = iktarget.transform.rotation.ToQuaterniond(); Quaterniond qDiff = qT * phIKee.GetSolid().GetPose().Ori().Inv(); qDiff = Quaterniond.Rot(qDiff.RotationHalf()); qT = qDiff * phIKee.GetSolid().GetPose().Ori(); phIKee.SetTargetOrientation(qT); } } } if (ikLocalTarget != null) { if (sprObject != null) { Vec3d targetLocalPos = gameObject.transform.ToPosed().Inv() * ikLocalTarget.transform.position.ToVec3d(); phIKEndEffector.SetTargetLocalPosition(targetLocalPos); } } }
// -- Sprオブジェクトの構築を行う public override ObjectIf Build() { PHIKEndEffectorIf phIKee = phScene.CreateIKEndEffector((PHIKEndEffectorDesc)desc); phIKee.SetName("ike:" + gameObject.name); PHSolidBehaviour solidBehaviour = gameObject.GetComponent <PHSolidBehaviour>(); if (solidBehaviour != null && solidBehaviour.sprObject != null) { phIKee.AddChildObject(solidBehaviour.sprObject); } phSceneBehaviour.RegisterPHIKEndEffectorBehaviour(this); return(phIKee); }