示例#1
0
            /// <summary>
            /// 角度制限
            /// </summary>
            /// <param name="data"></param>
            /// <param name="cindex"></param>
            /// <param name="nextpos"></param>
            /// <param name="outpos"></param>
            /// <param name="ang"></param>
            /// <returns></returns>
            private bool AnglePenetration(ref PenetrationData data, int cindex, float3 nextpos, out float3 outpos, float ang)
            {
                var cpos = nextPosList[cindex];
                var crot = nextRotList[cindex];

                // スケール
                var tindex = transformIndexList[cindex];
                var cscl   = boneSclList[tindex];
                //float scl = cscl.x; // X軸を採用(基本的には均等スケールのみを想定)

                // 押し出し平面を求める
                var c = math.mul(crot, data.localPos * cscl) + cpos;
                var n = math.mul(crot, data.localDir);

                var v = nextpos - c;

                float3 v2;

                if (MathUtility.ClampAngle(v, n, ang, out v2))
                {
                    outpos = c + v2;
                    return(true);
                }

                outpos = nextpos;
                return(false);
            }
示例#2
0
            //=====================================================================================
            /// <summary>
            /// 内球制限
            /// </summary>
            /// <param name="data"></param>
            /// <param name="distance"></param>
            /// <param name="cindex"></param>
            /// <param name="cr"></param>
            /// <param name="nextpos"></param>
            /// <param name="outpos"></param>
            /// <returns></returns>
            private bool InverseSpherePenetration(ref PenetrationData data, float distance, int cindex, float cr, float3 nextpos, out float3 outpos)
            {
                var cpos = nextPosList[cindex];
                var crot = nextRotList[cindex];

                // スケール
                var tindex = transformIndexList[cindex];
                var cscl   = boneSclList[tindex];

                // 中心軸
                var d = math.mul(crot, data.localPos * cscl) + cpos;

                // 方向
                var n = math.mul(crot, data.localDir);

                // 球の位置
                var c = d + n * (data.distance - distance + cr);

                // 球内部制限
                var v   = nextpos - c;
                var len = math.length(v);

                if (len > cr)
                {
                    v     *= (cr / len);
                    outpos = c + v;
                    return(true);
                }
                else
                {
                    outpos = nextpos;
                    return(false);
                }
            }
示例#3
0
    // Use this for initialization
    void Start()
    {
        InitPracticeObj();
        practiceObj[num].SetActive(true);

        dc = device.GetComponent <DeviceController>();
        pd = evalSet.GetComponent <PenetrationData>();
    }
示例#4
0
            private void InversePlanePosition(ref PenetrationData data, float teamScale, float distance, int cindex, out float3 center, out float3 dir)
            {
                var cpos = nextPosList[cindex];
                var crot = nextRotList[cindex];

                // スケール
                var tindex = transformIndexList[cindex];
                var cscl   = boneSclList[tindex];

                // 中心軸
                var d = math.mul(crot, data.localPos * cscl) + cpos;

                // 方向
                var n = math.mul(crot, data.localDir);

                // プレーン位置
                var c = d + n * (data.distance * teamScale - distance);

                center = c;
                dir    = n;
            }
示例#5
0
            //=====================================================================================
            /// <summary>
            /// 内球制限
            /// </summary>
            /// <param name="data"></param>
            /// <param name="distance"></param>
            /// <param name="cindex"></param>
            /// <param name="cr"></param>
            /// <param name="nextpos"></param>
            /// <param name="outpos"></param>
            /// <returns></returns>

            /*private bool InverseSpherePenetration(ref PenetrationData data, float teamScale, float distance, int cindex, float cr, float3 nextpos, out float3 outpos)
             * {
             *  var cpos = nextPosList[cindex];
             *  var crot = nextRotList[cindex];
             *
             *  // スケール
             *  var tindex = transformIndexList[cindex];
             *  var cscl = boneSclList[tindex];
             *
             *  // 中心軸
             *  var d = math.mul(crot, data.localPos * cscl) + cpos;
             *
             *  // 方向
             *  var n = math.mul(crot, data.localDir);
             *
             *  // 球の位置
             *  var c = d + n * (data.distance * teamScale - distance + cr);
             *
             *  // 球内部制限
             *  var v = nextpos - c;
             *  var len = math.length(v);
             *  if (len > cr)
             *  {
             *      v *= (cr / len);
             *      outpos = c + v;
             *      return true;
             *  }
             *  else
             *  {
             *      outpos = nextpos;
             *      return false;
             *  }
             * }*/

            /// <summary>
            /// 内球制限の中心位置を求める
            /// </summary>
            /// <param name="data"></param>
            /// <param name="teamScale"></param>
            /// <param name="distance">チームスケール済み</param>
            /// <param name="cindex"></param>
            /// <param name="cr">チームスケール済み</param>
            /// <returns></returns>
            private float3 InverseSpherePosition(ref PenetrationData data, float teamScale, float3 scaleDirection, float distance, int cindex, float cr)
            {
                var cpos = nextPosList[cindex];
                var crot = nextRotList[cindex];

                // スケール
                var tindex = transformIndexList[cindex];
                var cscl   = boneSclList[tindex];

                // 中心軸
                var d = math.mul(crot, data.localPos * cscl) + cpos;

                // 方向
                //var n = math.mul(crot, data.localDir);
                var n = math.mul(crot, data.localDir * scaleDirection); // マイナススケール対応

                // 球の位置
                var c = d + n * (data.distance * teamScale - distance + cr);

                return(c);
            }
    // Use this for initialization
    void Start()
    {
        GameObject eSet = GameObject.Find(evaluationSet);

        string name = this.gameObject.transform.parent.name.Replace("_Set", ""); // yama 181203 接触対象のオブジェクト名を選択(~_Setの~に当たる名前にする必要あり)

        foreach (Transform child in this.gameObject.transform.parent.transform)  // yama 181203 自分と同じ階層にあるターゲットオブジェクトの取得
        {
            if (child.gameObject.name == name)
            {
                targetObj = child.gameObject;
                //Debug.Log("Target_Set");
            }
        }

        if (targetObj == null)
        {
            Debug.Log("ERROR:接触対象のオブジェクトが選択されていません.");
        }

        pd = eSet.GetComponent <PenetrationData>();
    }
示例#7
0
            /// <summary>
            /// 平面制限
            /// </summary>
            /// <param name="data"></param>
            /// <param name="cindex"></param>
            /// <param name="nextpos"></param>
            /// <param name="outpos"></param>
            /// <returns></returns>
            private bool PlanePenetration(ref PenetrationData data, float teamScale, float distance, int cindex, float3 nextpos, out float3 outpos)
            {
                var cpos = nextPosList[cindex];
                var crot = nextRotList[cindex];

                // スケール
                var tindex = transformIndexList[cindex];
                var cscl   = boneSclList[tindex];

                // 中心軸
                var d = math.mul(crot, data.localPos * cscl) + cpos;

                // 方向
                var n = math.mul(crot, data.localDir);

                // 押し出し平面を求める
                var c = d + n * (data.distance * teamScale - distance);

                // c = 平面位置
                // n = 平面方向
                // 平面衝突判定と押し出し
                return(MathUtility.IntersectPointPlane(c, n, nextpos, out outpos));
            }
    // Use this for initialization
    void Start()
    {
        pd = this.GetComponent <PenetrationData>();

        #region オブジェクトをランダムに並べ替え配列に格納

        // yama 181124 配列をランダムソート
        if (evaluationNum == 1)         // yama 181205 実験1では点で触るだけなのでソートした配列をそのまま使用
        {
            pointObj = pointObj.OrderBy(i => Guid.NewGuid()).ToArray();
            //pointObj[numP].SetActive(true);

            for (int i = 1; i < pointObj.Length; i++)
            {
                pointObj[i].SetActive(false);
            }
        }
        else if (evaluationNum == 2)    // yama 181205 実験1では角度を変更する必要があるため角度とオブジェクトを構造体に格納
        {
            order = new OrderObj[strokeObj.Length * yAngle.Length];

            for (int i = 0; i < strokeObj.Length; i++)
            {
                for (int j = 0; j < yAngle.Length; j++)
                {
                    order[i * yAngle.Length + j].obj   = strokeObj[i];
                    order[i * yAngle.Length + j].angle = yAngle[j];
                }
            }

            order = order.OrderBy(i => Guid.NewGuid()).ToArray();
            order[numS].obj.SetActive(true);
            order[numS].obj.transform.eulerAngles = new Vector3(0, order[numS].angle, 0);

            Debug.Log("Name: " + order[numS].obj.name + ", yAngle = " + order[numS].angle + ", numS = " + numS);

            foreach (Transform child in order[numS].obj.transform)      // yama 181205 ゴールオブジェクトを検索・格納
            {
                if (goalName == child.gameObject.name)
                {
                    goalObj = child.gameObject;
                    break;
                }
            }
        }

        #endregion

        nextPoint  = true;      // yama 181228 最初のオブジェクト表示を許可
        nextStroke = false;

        if (evaluationNum == 1)
        {
            repeat = 4;
        }
        else if (evaluationNum == 2)
        {
            repeat = 1;
        }

        Debug.Log("OE_OK");
    }