예제 #1
0
    IEnumerator Pinning(float interval, int count)
    {
        while (true)
        {
            yield return(new WaitForSeconds(interval));

            Vector3 posLocal, normalLocal;
            foreach (var uv in _mcmc.Sequence(10, count))
            {
                if (uvWorld.World(uv, out posLocal, out normalLocal))
                {
                    posLocal += (Vector3)(perturbation * Random.insideUnitCircle);
                    var pin = Instantiate(pinfab);
                    pin.SetParent(transform, false);
                    pin.position = uvWorld.transform.TransformPoint(posLocal);
                    pin.forward  = uvWorld.transform.TransformDirection(normalLocal);

                    _pins.Add(pin);
                }
            }

            if (_pins.Count >= limitPinCount)
            {
                foreach (var p in _pins)
                {
                    Destroy(p.gameObject);
                }
                _pins.Clear();
                yield return(new WaitForSeconds(2f));
            }
        }
    }
예제 #2
0
파일: MCMCTest.cs 프로젝트: nobnak/MCMC
    IEnumerator Generate()
    {
        while (true)
        {
            if (sleep <= 0f)
            {
                yield return(null);
            }
            else
            {
                yield return(new WaitForSeconds(sleep));
            }

            foreach (var uv in _mcmc.Sequence(nInitials, nSamples))
            {
                var worldPos = Camera.main.ViewportToWorldPoint((Vector3)uv);
                worldPos.z = 0f;

                var go = (GameObject)Instantiate(pointfab);
                go.transform.parent   = transform;
                go.transform.position = worldPos;
                go.SetActive(true);
            }
        }
    }
예제 #3
0
    IEnumerator Pinning(float interval, int count)
    {
        while (true)
        {
            yield return(new WaitForSeconds(interval));

            if (!enabled || !_mousePressed)
            {
                continue;
            }

            _mcmc.Reset();
            foreach (var uv in _mcmc.Sequence(100, count))
            {
                Vector3 posLocal;
                Vector3 normalLocal;
                if (uvWorld.World(uv, out posLocal, out normalLocal))
                {
                    posLocal += (Vector3)(perturbation * Random.insideUnitCircle);
                    var pos = uvWorld.transform.TransformPoint(posLocal) + shuriken.startSize * Vector3.up;
                    shuriken.Emit(pos, Vector3.zero, shuriken.startSize, shuriken.startLifetime, shuriken.startColor);
                }
            }
        }
    }