Exemple #1
0
        public void Draw()
        {
            if (oculusTouch.GetButton(drawButton))
            {
                Vector3 nowPosition = oculusTouch.GetPositionR();

                if (Length() == 0)
                {
                    this.points.Add(nowPosition);
                }
                else if (Vector3.Distance(this.points.Last(), nowPosition) >= this.segment)
                {
                    this.points.Add(nowPosition);
                    this.MeshUpdate();
                }
            }
        }
        public static int FindClosestPoint(OculusTouch oculusTouch, List <Vector3> points)
        {
            // KnotStateChoose2 からも呼び出せるように static メソッドにした
            Vector3 controllerPosition = oculusTouch.GetPositionR();
            int     closestIndex       = 0;
            float   closestDistance    = Vector3.Distance(points[closestIndex], controllerPosition);

            for (int i = 1; i < points.Count; i++)
            {
                float distance = Vector3.Distance(points[i], controllerPosition);
                if (distance < closestDistance)
                {
                    closestIndex    = i;
                    closestDistance = distance;
                }
            }
            return(closestIndex);
        }