示例#1
0
        // Update is called once per frame
        void Update()
        {
            if (deviceController != null && deviceController.GetDevice() != null)
            {
                CVirtDevice virtDevice = deviceController.GetDevice();

                float sumForce = 0;

                foreach (CVirtHapticEmitter emitter in emitters)
                {
                    float distance = Vector3.Distance(this.transform.position, emitter.transform.position);
                    if (distance < maxRange && distance < emitter.distance)
                    {
                        float force = emitter.EvaluateForce(this.transform.position);
                        if (sumForce < force)
                        {
                            sumForce = force;
                        }
                        //sumForce = SumUpDecibal(force, force);
                    }
                }

                if (virtDevice.HasHaptic())
                {
                    virtDevice.HapticSetVolume(Mathf.FloorToInt(100f * sumForce));
                }
            }
        }
示例#2
0
 void OnDestroy()
 {
     if (deviceController != null && deviceController.GetDevice() != null)
     {
         CVirtDevice virtDevice = deviceController.GetDevice();
         if (virtDevice.HasHaptic())
         {
             virtDevice.HapticStop();
         }
     }
 }
示例#3
0
        public void OnCVirtDeviceControllerCallback(CVirtDevice virtDevice, CVirtDeviceController.CVirtDeviceControllerCallbackType callbackType)
        {
            switch (callbackType)
            {
            case CVirtDeviceController.CVirtDeviceControllerCallbackType.Connect:
                virtDevice.HapticSetGain(4);
                virtDevice.HapticSetFrequency(60);
                virtDevice.HapticSetVolume(0);
                //
                virtDevice.HapticPlay();
                break;

            case CVirtDeviceController.CVirtDeviceControllerCallbackType.Disconnect:
                virtDevice.HapticStop();
                break;
            }
        }