コード例 #1
0
    public static Vector3 GetIndexThumbPos(SelectionDataManager sDM)
    {
        if (!sDM.ActiveHand)
        {
            return(NullVector3);
        }

        Vector3 indexPos = sDM.ActiveIndex.transform.position;
        Vector3 thumbPos = sDM.ActiveThumb.transform.position;

        float factor = 0.5f;

        float x = (indexPos.x + thumbPos.x) * factor;
        float y = (indexPos.y + thumbPos.y) * factor;
        float z = (indexPos.z + thumbPos.z) * factor;

        return(new Vector3(x, y, z));
    }
コード例 #2
0
ファイル: FocusCylinder.cs プロジェクト: jama1017/FlowAR
 // Start is called before the first frame update
 void Start()
 {
     _selectionDM = GameObject.FindGameObjectWithTag("selectionDM").GetComponent <SelectionDataManager>();
 }
コード例 #3
0
    public static GameObject RankFocusedObjects(List <GameObject> focusedObjects, Vector3 cylinderPosition, SelectionDataManager sDM, Canvas canvas)
    {
        if (focusedObjects.Count == 0)
        {
            return(null);
        }

        GameObject num_one   = null;
        float      max_score = -9999999f;

        for (int i = 0; i < focusedObjects.Count; i++)
        {
            Vector3 objPos = focusedObjects[i].transform.position;

            float objCylinderDis = Vector3.Distance(WorldToUISpace(canvas, objPos), WorldToUISpace(canvas, cylinderPosition));
            float objHandDis     = 0.0f;

            Vector3 handPos = GetIndexThumbPos(sDM);
            if (handPos != NullVector3)
            {
                objHandDis = Vector3.Distance(objPos, handPos);
            }

            float objCylPortion  = (1.0f / objCylinderDis) * 20000f;
            float objHandPortion = 1.0f / Mathf.Pow(objHandDis, 3.0f);

            float score = objCylPortion + objHandPortion;
            //Debug.Log("DATAA cy obj score: " + objCylPortion + " , " + objHandPortion + " , " + score);

            if (score > max_score)
            {
                max_score = score;
                num_one   = focusedObjects[i];
            }
        }

        //Debug.Log("DATAA -----------");

        return(num_one);
    }