Exemplo n.º 1
0
        protected virtual void Start()
        {
            if (headTransform == null)
            {
                Debug.Log("Error: please assign the headTransform in the inspector.");
            }
            else
            {
                headMatrix = Matrix4x4.Rotate(headTransform.localRotation);
            }

            if (eyeLTransform == null)
            {
                Debug.Log("Error: please assign the eyeLTransform in the inspector.");
            }
            else
            {
                eyeLMatrix = Matrix4x4.Rotate(eyeLTransform.localRotation);
            }

            if (eyeRTransform == null)
            {
                Debug.Log("Error: please assign the eyeRTransform in the inspector.");
            }
            else
            {
                eyeRMatrix = Matrix4x4.Rotate(eyeRTransform.localRotation);
            }


            if (blendshapesGeometry == null)
            {
                Debug.Log("Error: please assign the skinnedMeshRenderer with blendshapes in the inspector.");
            }
            else
            {
                blendshapesCount = blendshapesGeometry.sharedMesh.blendShapeCount;

                string blendShapeNames = "Blendshape (" + blendshapesCount + ") index and name:\n";

                for (int i = 0; i < blendshapesCount; i++)
                {
                    blendShapeNames += (i + ":" + blendshapesGeometry.sharedMesh.GetBlendShapeName(i).ToString() + "\n");
                }

                Debug.Log(blendShapeNames);

                // Creating an OSC receiver.
                _OSCReceiver = gameObject.AddComponent <OSCReceiver>();

                // Set local OSC port.
                _OSCReceiver.LocalPort = _OSCReceiverPort;

                // Bind OSC Addresses.
                if (usePositionData)
                {
                    _OSCReceiver.Bind(_Position, PositionReceived);
                }

                if (useOrientationData)
                {
                    _OSCReceiver.Bind(_EulerAngles, EulerAnglesReceived);
                }

                _OSCReceiver.Bind(_LeftEyeEulerAngles, LeftEyeEulerAnglesReceived);
                _OSCReceiver.Bind(_RightEyeEulerAngles, RightEyeEulerAnglesReceived);

                _OSCReceiver.Bind(_Blendshapes, BlendshapeReceived);
            }
        }
Exemplo n.º 2
0
        protected virtual void Start()
        {
            if (headTransform == null)
            {
                Debug.Log("Error: please assign the headTransform in the inspector.");
            }
            else
            {
                headMatrix = Matrix4x4.Rotate(headTransform.localRotation);
            }

            if (eyeLTransform == null)
            {
                Debug.Log("Error: please assign the eyeLTransform in the inspector.");
            }
            else
            {
                eyeLMatrix = Matrix4x4.Rotate(eyeLTransform.localRotation);
            }

            if (eyeRTransform == null)
            {
                Debug.Log("Error: please assign the eyeRTransform in the inspector.");
            }
            else
            {
                eyeRMatrix = Matrix4x4.Rotate(eyeRTransform.localRotation);
            }

            if (blendshapesGeometry == null || faceCapRemapperObject == null)
            {
                Debug.Log("Error: please assign the skinnedMeshRenderer with blendshapes in the inspector.");
            }
            else
            {
                Debug.Log("Amount of configured remappings: " + faceCapRemapperObject.data.Count);

                // Get blendshape count;
                blendshapesCount = blendshapesGeometry.sharedMesh.blendShapeCount;

                // Load remappingData;
                remappingData = new FaceCapData[faceCapRemapperObject.data.Count];

                for (int i = 0; i < faceCapRemapperObject.data.Count; i++)
                {
                    remappingData[i] = faceCapRemapperObject.data[i];
                }

                // Creating an OSC receiver.
                _OSCReceiver = gameObject.AddComponent <OSCReceiver>();

                // Set local OSC port.
                _OSCReceiver.LocalPort = _OSCReceiverPort;

                // Bind OSC Addresses.
                if (usePositionData)
                {
                    _OSCReceiver.Bind(_Position, PositionReceived);
                }

                if (useOrientationData)
                {
                    _OSCReceiver.Bind(_EulerAngles, EulerAnglesReceived);
                }

                _OSCReceiver.Bind(_LeftEyeEulerAngles, LeftEyeEulerAnglesReceived);
                _OSCReceiver.Bind(_RightEyeEulerAngles, RightEyeEulerAnglesReceived);

                _OSCReceiver.Bind(_Blendshapes, BlendshapeReceived);
            }
        }