예제 #1
0
    private void UpdateFingers()
    {
        numFingersEngaged = 0;
        for (int i = 0; i < fingers.Length; i++)
        {
            Transform finger = fingers[i];
            FingerArc arc    = fingerArcs[i];

            if (!finger.gameObject.activeSelf)
            {
                arc.gameObject.SetActive(false);
                continue;
            }

            if (arc.gameObject.activeSelf)
            {
                // See if we're too far away
                MeshSample sample = sampler.Samples[arc.Point1SampleIndex];
                if (Vector3.Distance(sample.Point, finger.position) > fingerDisengageDistance)
                {   // If we are, disable the arc and move on
                    arc.gameObject.SetActive(false);
                    continue;
                }
                else
                {     // If we aren't, see if it's time to zap to a different position
                    if (Random.value < randomFingerArcChange)
                    { // Get the closest point on the sphere
                        MeshSample point1 = sampler.ClosestSample(finger.position);
                        // Then get a random sample somewhere nearby
                        point1 = sampler.RandomSample(point1.Point, fingerRandomPosRadius);
                        arc.SetArc(point1, fingerArcSources[i]);
                    }
                    numFingersEngaged++;
                }
            }
            else
            {   // See if we're close enough to any samples to start
                // Get the closest point on the sphere
                MeshSample point1 = sampler.ClosestSample(finger.position);
                if (Vector3.Distance(point1.Point, finger.position) < fingerEngageDistance)
                {   // Then get a random sample somewhere nearby
                    point1 = sampler.RandomSample(point1.Point, fingerRandomPosRadius);
                    arc.gameObject.SetActive(true);
                    arc.SetArc(point1, fingerArcSources[i]);
                    numFingersEngaged++;
                }
            }
        }
    }
예제 #2
0
    private void UpdateGoopSlime()
    {
        for (int i = 0; i < fingers.Length; i++)
        {
            if (!fingers[i].gameObject.activeSelf)
            {
                goopSlimes[i].gameObject.SetActive(false);
                continue;
            }

            if (Vector3.Distance(fingers[i].position, transform.position) < SurfaceRadius + goopDistance)
            {
                MeshSample closestSample = sampler.ClosestSample(fingers[i].localPosition);
                goopSlimes[i].SetGoop(closestSample, fingers[i]);
            }
        }
    }
예제 #3
0
    private Vector2 ProjectFingerPosition(Vector3 position)
    {
        MeshSample sample = sampler.ClosestSample(surfaceTransform.InverseTransformPoint(position));

        return(sample.UV);
    }