public void Update() { if (!isInitialized() || isUpdating()) { return; } view.Update(Input.acceleration); if (live2DModel == null) { if (LAppDefine.DEBUG_LOG) { Debug.Log("Can not update there is no model data"); } return; } if (!Application.isPlaying) { live2DModel.update(); return; } live2DModel.update(); }
/* * 更新 */ public void Update() { if (!isInitialized() || isUpdating()) { return; } view.Update(Input.acceleration); if (live2DModel == null) { if (LAppDefine.DEBUG_LOG) { Debug.Log("Can not update there is no model data"); } return; } if (!Application.isPlaying) { live2DModel.update(); return; } long timeMSec = UtSystem.getUserTimeMSec() - startTimeMSec; double timeSec = timeMSec / 1000.0; double t = timeSec * 2 * Math.PI;// 2πt // 待机动作确定 if (mainMotionManager.isFinished()) { // 没有动作播放时,从待机动作中随机播放 StartRandomMotion(LAppDefine.MOTION_GROUP_IDLE, LAppDefine.PRIORITY_IDLE); } //----------------------------------------------------------------- live2DModel.loadParam(); // 加载以前保存的状态 bool update = mainMotionManager.updateParam(live2DModel); // 更新动作 if (!update) { // 当主要动作未更新时 eyeBlink.updateParam(live2DModel);// 眼睛抓住 } live2DModel.saveParam();// 保存状态 //----------------------------------------------------------------- if (expressionManager != null) { expressionManager.updateParam(live2DModel); // 带表达式的参数更新(相对更改) } // ドラッグによる変化 // ドラッグによる顔の向きの調整 live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_X, dragX * 30, 1);// -30から30の値を加える live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_Y, dragY * 30, 1); live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_Z, (dragX * dragY) * -30, 1); // ドラッグによる体の向きの調整 live2DModel.addToParamFloat(L2DStandardID.PARAM_BODY_ANGLE_X, dragX, 10);// -10から10の値を加える // ドラッグによる目の向きの調整 live2DModel.addToParamFloat(L2DStandardID.PARAM_EYE_BALL_X, dragX, 1);// -1から1の値を加える live2DModel.addToParamFloat(L2DStandardID.PARAM_EYE_BALL_Y, dragY, 1); // 呼吸など live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_X, (float)(15 * Math.Sin(t / 6.5345)), 0.5f); live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_Y, (float)(8 * Math.Sin(t / 3.5345)), 0.5f); live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_Z, (float)(10 * Math.Sin(t / 5.5345)), 0.5f); live2DModel.addToParamFloat(L2DStandardID.PARAM_BODY_ANGLE_X, (float)(4 * Math.Sin(t / 15.5345)), 0.5f); live2DModel.setParamFloat(L2DStandardID.PARAM_BREATH, (float)(0.5f + 0.5f * Math.Sin(t / 3.2345)), 1); // 加速度による変化 live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_X, 90 * accelX, 0.5f); live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_Z, 10 * accelX, 0.5f); if (physics != null) { physics.updateParam(live2DModel); // 物理演算でパラメータ更新 } // リップシンクの設定 if (lipSync) { live2DModel.setParamFloat(L2DStandardID.PARAM_MOUTH_OPEN_Y, lipSyncValue, 0.8f); } // ポーズの設定 if (pose != null) { pose.updateParam(live2DModel); } live2DModel.update(); }
/* * 更新 */ public void Update() { if (!isInitialized() || isUpdating()) { return; } view.Update(Input.acceleration); if (live2DModel == null) { if (LAppDefine.DEBUG_LOG) { Debug.Log("Can not update there is no model data"); } return; } if (!Application.isPlaying) { live2DModel.update(); return; } long timeMSec = UtSystem.getUserTimeMSec() - startTimeMSec; double timeSec = timeMSec / 1000.0; double t = timeSec * 2 * Math.PI;// 2πt // 待機モーション判定 대기 모션 판정 if (mainMotionManager.isFinished()) { // モーションの再生がない場合、待機モーションの中からランダムで再生する // 모션 재생이 없으면 대기 모션 중에서 무작위로 재생 StartRandomMotion(LAppDefine.MOTION_GROUP_IDLE, LAppDefine.PRIORITY_IDLE); } //----------------------------------------------------------------- live2DModel.loadParam(); // 前回セーブされた状態をロード bool update = mainMotionManager.updateParam(live2DModel); // モーションを更新 if (!update) { // メインモーションの更新がないとき eyeBlink.updateParam(live2DModel);// 目パチ } live2DModel.saveParam();// 状態を保存 //----------------------------------------------------------------- if (expressionManager != null) { expressionManager.updateParam(live2DModel); // 表情でパラメータ更新(相対変化) } // ドラッグによる変化 // ドラッグによる顔の向きの調整 live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_X, dragX * 30, 1);// -30から30の値を加える live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_Y, dragY * 30, 1); live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_Z, (dragX * dragY) * -30, 1); // ドラッグによる体の向きの調整 live2DModel.addToParamFloat(L2DStandardID.PARAM_BODY_ANGLE_X, dragX, 10);// -10から10の値を加える // ドラッグによる目の向きの調整 live2DModel.addToParamFloat(L2DStandardID.PARAM_EYE_BALL_X, dragX, 1);// -1から1の値を加える live2DModel.addToParamFloat(L2DStandardID.PARAM_EYE_BALL_Y, dragY, 1); // 呼吸など live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_X, (float)(15 * Math.Sin(t / 6.5345)), 0.5f); live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_Y, (float)(8 * Math.Sin(t / 3.5345)), 0.5f); live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_Z, (float)(10 * Math.Sin(t / 5.5345)), 0.5f); live2DModel.addToParamFloat(L2DStandardID.PARAM_BODY_ANGLE_X, (float)(4 * Math.Sin(t / 15.5345)), 0.5f); live2DModel.setParamFloat(L2DStandardID.PARAM_BREATH, (float)(0.5f + 0.5f * Math.Sin(t / 3.2345)), 1); // 加速度による変化 live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_X, 90 * accelX, 0.5f); live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_Z, 10 * accelX, 0.5f); if (physics != null) { physics.updateParam(live2DModel); // 物理演算でパラメータ更新 } // リップシンクの設定 if (lipSync) { live2DModel.setParamFloat(L2DStandardID.PARAM_MOUTH_OPEN_Y, lipSyncValue, 0.8f); } // ポーズの設定 if (pose != null) { pose.updateParam(live2DModel); } live2DModel.update(); }
public void Update() { if (!isInitialized() || isUpdating()) { return; } view.Update(Input.acceleration); if (live2DModel == null) { if (LAppDefine.DEBUG_LOG) { Debug.Log("Can not update there is no model data"); } return; } if (!Application.isPlaying) { live2DModel.update(); return; } long timeMSec = UtSystem.getUserTimeMSec() - startTimeMSec; double timeSec = timeMSec / 1000.0; double t = timeSec * 2 * Math.PI; if (mainMotionManager.isFinished()) { StartRandomMotion(LAppDefine.MOTION_GROUP_IDLE, LAppDefine.PRIORITY_IDLE); } //----------------------------------------------------------------- live2DModel.loadParam(); bool update = mainMotionManager.updateParam(live2DModel); if (!update) { eyeBlink.updateParam(live2DModel); } live2DModel.saveParam(); //----------------------------------------------------------------- if (expressionManager != null) { expressionManager.updateParam(live2DModel); } live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_X, dragX * 30, 1); live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_Y, dragY * 30, 1); live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_Z, (dragX * dragY) * -30, 1); live2DModel.addToParamFloat(L2DStandardID.PARAM_BODY_ANGLE_X, dragX, 10); live2DModel.addToParamFloat(L2DStandardID.PARAM_EYE_BALL_X, dragX, 1); live2DModel.addToParamFloat(L2DStandardID.PARAM_EYE_BALL_Y, dragY, 1); live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_X, (float)(15 * Math.Sin(t / 6.5345)), 0.5f); live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_Y, (float)(8 * Math.Sin(t / 3.5345)), 0.5f); live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_Z, (float)(10 * Math.Sin(t / 5.5345)), 0.5f); live2DModel.addToParamFloat(L2DStandardID.PARAM_BODY_ANGLE_X, (float)(4 * Math.Sin(t / 15.5345)), 0.5f); live2DModel.setParamFloat(L2DStandardID.PARAM_BREATH, (float)(0.5f + 0.5f * Math.Sin(t / 3.2345)), 1); live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_X, 90 * accelX, 0.5f); live2DModel.addToParamFloat(L2DStandardID.PARAM_ANGLE_Z, 10 * accelX, 0.5f); if (physics != null) { physics.updateParam(live2DModel); } if (lipSync) { live2DModel.setParamFloat(L2DStandardID.PARAM_MOUTH_OPEN_Y, lipSyncValue, 0.8f); } if (pose != null) { pose.updateParam(live2DModel); } live2DModel.update(); }