コード例 #1
0
    private void onFrame(object sender, FrameEventArgs args)
    {
        Frame currentFrame = args.frame;

        if (currentFrame.Hands.Count != 0)
        {
            if (currentFrame.Hands.Count > 1)
            {
                Hand hand1 = currentFrame.Hands[0];
                Hand hand2 = currentFrame.Hands[1];
            }
            else
            {
                Hand hand = currentFrame.Hands[0];

                grabStrength = hand.GrabStrength;
                visualEffect.SetFloat("Turbulence", hand.GrabStrength);

                Vector3 newPos = new Vector3(-Leap.Unity.UnityVectorExtension.ToVector3(hand.PalmPosition).x / 1000, -Leap.Unity.UnityVectorExtension.ToVector3(hand.PalmPosition).z / 1000, Leap.Unity.UnityVectorExtension.ToVector3(hand.PalmPosition).y / 1000);
                if (hand.IsLeft)
                {
                    leftPos.SetActive(true); rightPos.SetActive(false);
                    leftPos.transform.localPosition = newPos;
                }
                else
                {
                    leftPos.SetActive(false); rightPos.SetActive(true);
                    rightPos.transform.localPosition = newPos;
                }
            }
        }
    }
コード例 #2
0
    void Update()
    {
        if (_vfxGraph != null)
        {
            var noiseTime = Time.time * 0.5f;
            _currentEmitterPosition = (new Vector3(
                                           Mathf.PerlinNoise(1, noiseTime),
                                           Mathf.PerlinNoise(2, noiseTime),
                                           Mathf.PerlinNoise(3, noiseTime)
                                           ) - Vector3.one * 0.5f) * EmitterPositionNoiseRadius + EmitterPositionCenter;

            var emitterDirection = _currentEmitterPosition - _previousEmitterPosition;

            _vfxGraph.SetVector3("EmitterPosition", _currentEmitterPosition);
            _vfxGraph.SetVector3("EmitterDirection", emitterDirection);

            var emitRate = EmitRateAmplitude * Mathf.PerlinNoise(0, Time.time * 0.5f);
            _vfxGraph.SetFloat("EmitRate", emitRate);


            _previousEmitterPosition = _currentEmitterPosition;
        }
    }