示例#1
0
    private void UpdateArcs()
    {
        FingerArc.UpdateArcLights();

        int maxActiveArcs = surfaceArcs.Length - numFingersEngaged;

        for (int i = 0; i < surfaceArcs.Length; i++)
        {
            surfaceArcs[i].gameObject.SetActive(i < maxActiveArcs);
        }

        if (Random.value < randomSurfaceArcChange)
        {
            SurfaceArc arc = surfaceArcs[Random.Range(0, surfaceArcs.Length)];
            if (Random.value > 0.5f)
            {
                arc.gameObject.SetActive(true);
                MeshSample point1 = sampler.Samples[Random.Range(0, sampler.Samples.Length)];
                MeshSample point2 = sampler.Samples[Random.Range(0, sampler.Samples.Length)];
                arc.SetArc(point1, point2, transform.position, SurfaceRadius);
            }
            else
            {
                arc.gameObject.SetActive(false);
            }
        }
    }
示例#2
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++;
                }
            }
        }
    }