/** * @brief Creates a new state and adds it to this clip. * @param[in] timestamp The timestamp for this new state. * @return The newly created state. */ public RigState NewState(double timestamp) { RigState state = new RigState(m_rig); state.SetTimestamp(timestamp); m_states.Add(state); return(state); }
void Update() { bool new_data = false; m_mutex.WaitOne(); // check if there are new blendshape names, and if so update if (NewBlendShapeNamesArrived()) { m_rig = Rig.GetRigFromBlendShapeNames(GetBlendShapeNames()); } // get most recent tracking data while (m_data_parser.CountAvailableTracks() > 0) { m_current_track = m_data_parser.Dequeue(); new_data = true; } // check that we have a rig (set up from blendshape names) with the same number of blendshapes as what we receive if (m_rig != null && m_current_track != null) { int n_track_coefficients = m_current_track.n_coefficients(); int n_rig_coefficients = m_rig.NumShapes(); if (n_track_coefficients != n_rig_coefficients) { Debug.LogWarning("number of coefficients of rig and tracking state have changed: " + n_track_coefficients + " vs " + n_rig_coefficients); // clear the current rig as it is not usable with the data coming from faceshift m_rig = null; m_current_track = null; // get again the blendshapes from fs studio AskForBlendshapeNames(); } } m_mutex.ReleaseMutex(); if (m_rig != null && m_current_track != null && m_Retargeting != null) { if (new_data && m_current_track.TrackSuccess) { // create a rig state RigState state = new RigState(m_rig); state.SetTimestamp(m_current_track.TimeStamp); state.SetBoneTranslation(0, m_current_track.HeadTranslation()); state.SetBoneRotation(0, m_current_track.HeadRotation()); state.SetBoneRotation(1, m_current_track.LeftEyeRotation()); state.SetBoneRotation(2, m_current_track.RightEyeRotation()); for (int i = 0; i < m_rig.NumShapes(); i++) { state.SetBlendshapeCoefficient(i, m_current_track.Coefficient[i]); } base.UpdateAnimation(m_rig, state); } } }
void Update () { bool new_data = false; m_mutex.WaitOne(); // check if there are new blendshape names, and if so update if (NewBlendShapeNamesArrived()) { m_rig = Rig.GetRigFromBlendShapeNames(GetBlendShapeNames()); } // get most recent tracking data while (m_data_parser.CountAvailableTracks() > 0) { m_current_track = m_data_parser.Dequeue(); new_data = true; } // check that we have a rig (set up from blendshape names) with the same number of blendshapes as what we receive if (m_rig != null && m_current_track != null) { int n_track_coefficients = m_current_track.n_coefficients(); int n_rig_coefficients = m_rig.NumShapes(); if (n_track_coefficients != n_rig_coefficients) { Debug.LogWarning("number of coefficients of rig and tracking state have changed: " + n_track_coefficients + " vs " + n_rig_coefficients); // clear the current rig as it is not usable with the data coming from faceshift m_rig = null; m_current_track = null; // get again the blendshapes from fs studio AskForBlendshapeNames(); } } m_mutex.ReleaseMutex(); if (m_rig != null && m_current_track != null && m_Retargeting != null) { if (new_data && m_current_track.TrackSuccess) { // create a rig state RigState state = new RigState(m_rig); state.SetTimestamp(m_current_track.TimeStamp); state.SetBoneTranslation(0, m_current_track.HeadTranslation()); state.SetBoneRotation(0, m_current_track.HeadRotation()); state.SetBoneRotation(1, m_current_track.LeftEyeRotation()); state.SetBoneRotation(2, m_current_track.RightEyeRotation()); for (int i = 0; i < m_rig.NumShapes(); i++) { state.SetBlendshapeCoefficient(i, m_current_track.Coefficient[i]); } base.UpdateAnimation(m_rig, state); } } }
/** * @brief Creates a new state and adds it to this clip. * @param[in] timestamp The timestamp for this new state. * @return The newly created state. */ public RigState NewState(double timestamp) { RigState state = new RigState(m_rig); state.SetTimestamp(timestamp); m_states.Add(state); return state; }