Update to Cubism SDK 4-r.2. Incompatible scaling changes.
authorAdrian Iain Lam <adrianiainlam@users.noreply.github.com>
Wed, 28 Apr 2021 11:41:35 +0000 (12:41 +0100)
committerAdrian Iain Lam <adrianiainlam@users.noreply.github.com>
Wed, 28 Apr 2021 11:41:35 +0000 (12:41 +0100)
NOTE: Scale factors and translate co-ordinates worked out using
the previous release will need to be updated, because the SDK has
changed how scaling is handled.

.gitignore
README.md
example/build.sh
example/demo.patch
example/generate_patch.sh

index ff914fa..6243a90 100644 (file)
@@ -1,5 +1,5 @@
 build
 build
-example/CubismSdkForNative-4-r.1/
+example/CubismSdkForNative-4-r.*/
 example/demo_build/
 example/demo_clean/
 example/demo_dev/
 example/demo_build/
 example/demo_clean/
 example/demo_dev/
index 8d307c2..61387c3 100644 (file)
--- a/README.md
+++ b/README.md
@@ -53,14 +53,14 @@ To build the example program:
 4. Download "Cubism 4 SDK for Native R1" from the Live2D website:
    <https://www.live2d.com/en/download/cubism-sdk/download-native/>.
 
 4. Download "Cubism 4 SDK for Native R1" from the Live2D website:
    <https://www.live2d.com/en/download/cubism-sdk/download-native/>.
 
-   Extract the archive -- put the "CubismSdkForNative-4-r.1" folder under
+   Extract the archive -- put the "CubismSdkForNative-4-r.2" folder under
    the "example" folder of this repo.
 
    Note: The Cubism SDK is the property of Live2D and is not part of this
    project. You must agree to Live2D's license agreements to use it.
 
 5. Go into the
    the "example" folder of this repo.
 
    Note: The Cubism SDK is the property of Live2D and is not part of this
    project. You must agree to Live2D's license agreements to use it.
 
 5. Go into the
-   "example/CubismSdkForNative-4-r.1/Samples/OpenGL/thirdParty/scripts"
+   "example/CubismSdkForNative-4-r.2/Samples/OpenGL/thirdParty/scripts"
    directory and run
 
        ./setup_glew_glfw
    directory and run
 
        ./setup_glew_glfw
index 2902456..0aa966a 100755 (executable)
@@ -1,6 +1,6 @@
-#!/bin/sh
+#!/bin/sh -e
 
 mkdir -p demo_build
 
 mkdir -p demo_build
-cp -r CubismSdkForNative-4-r.1/Samples/OpenGL/Demo/proj.linux.cmake/* ./demo_build/
+cp -r CubismSdkForNative-4-r.2/Samples/OpenGL/Demo/proj.linux.cmake/* ./demo_build/
 patch -d demo_build -p2 < demo.patch
 ./demo_build/scripts/make_gcc
 patch -d demo_build -p2 < demo.patch
 ./demo_build/scripts/make_gcc
index 61d237d..637b3ab 100644 (file)
@@ -1,12 +1,12 @@
 diff -pruN --exclude build ./demo_clean/CMakeLists.txt ./demo_dev/CMakeLists.txt
 diff -pruN --exclude build ./demo_clean/CMakeLists.txt ./demo_dev/CMakeLists.txt
---- ./demo_clean/CMakeLists.txt        2020-10-01 22:47:25.846828066 +0100
-+++ ./demo_dev/CMakeLists.txt  2021-01-01 15:54:33.576439332 +0000
+--- ./demo_clean/CMakeLists.txt        2021-02-17 01:23:17.000000000 +0000
++++ ./demo_dev/CMakeLists.txt  2021-04-28 12:32:48.468744883 +0100
 @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.16)
  # Set app name.
  set(APP_NAME Demo)
  # Set directory paths.
 -set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../..)
 @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.16)
  # Set app name.
  set(APP_NAME Demo)
  # Set directory paths.
 -set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../..)
-+set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../CubismSdkForNative-4-r.1)
++set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../CubismSdkForNative-4-r.2)
  set(CORE_PATH ${SDK_ROOT_PATH}/Core)
  set(FRAMEWORK_PATH ${SDK_ROOT_PATH}/Framework)
  set(THIRD_PARTY_PATH ${SDK_ROOT_PATH}/Samples/OpenGL/thirdParty)
  set(CORE_PATH ${SDK_ROOT_PATH}/Core)
  set(FRAMEWORK_PATH ${SDK_ROOT_PATH}/Framework)
  set(THIRD_PARTY_PATH ${SDK_ROOT_PATH}/Samples/OpenGL/thirdParty)
@@ -54,8 +54,8 @@ diff -pruN --exclude build ./demo_clean/CMakeLists.txt ./demo_dev/CMakeLists.txt
  # Copy resource directory to build directory.
  add_custom_command(
 diff -pruN --exclude build ./demo_clean/scripts/make_gcc ./demo_dev/scripts/make_gcc
  # Copy resource directory to build directory.
  add_custom_command(
 diff -pruN --exclude build ./demo_clean/scripts/make_gcc ./demo_dev/scripts/make_gcc
---- ./demo_clean/scripts/make_gcc      2020-10-01 22:47:25.854827921 +0100
-+++ ./demo_dev/scripts/make_gcc        2021-01-01 11:34:25.583684883 +0000
+--- ./demo_clean/scripts/make_gcc      2021-02-17 01:23:17.000000000 +0000
++++ ./demo_dev/scripts/make_gcc        2021-04-28 12:18:50.948333190 +0100
 @@ -10,4 +10,4 @@ BUILD_PATH=$SCRIPT_PATH/../build/make_gc
  cmake -S "$CMAKE_PATH" \
    -B "$BUILD_PATH" \
 @@ -10,4 +10,4 @@ BUILD_PATH=$SCRIPT_PATH/../build/make_gc
  cmake -S "$CMAKE_PATH" \
    -B "$BUILD_PATH" \
@@ -63,9 +63,18 @@ diff -pruN --exclude build ./demo_clean/scripts/make_gcc ./demo_dev/scripts/make
 -cd "$BUILD_PATH" && make
 +cd "$BUILD_PATH" && make -j4
 diff -pruN --exclude build ./demo_clean/src/CMakeLists.txt ./demo_dev/src/CMakeLists.txt
 -cd "$BUILD_PATH" && make
 +cd "$BUILD_PATH" && make -j4
 diff -pruN --exclude build ./demo_clean/src/CMakeLists.txt ./demo_dev/src/CMakeLists.txt
---- ./demo_clean/src/CMakeLists.txt    2020-10-01 22:47:25.850827994 +0100
-+++ ./demo_dev/src/CMakeLists.txt      2020-10-01 22:47:24.842846271 +0100
-@@ -19,6 +19,4 @@ target_sources(${APP_NAME}
+--- ./demo_clean/src/CMakeLists.txt    2021-02-17 01:23:17.000000000 +0000
++++ ./demo_dev/src/CMakeLists.txt      2021-04-28 12:21:56.795134807 +0100
+@@ -6,8 +6,6 @@ target_sources(${APP_NAME}
+     ${CMAKE_CURRENT_SOURCE_DIR}/LAppDefine.hpp
+     ${CMAKE_CURRENT_SOURCE_DIR}/LAppDelegate.cpp
+     ${CMAKE_CURRENT_SOURCE_DIR}/LAppDelegate.hpp
+-    ${CMAKE_CURRENT_SOURCE_DIR}/LAppWavFileHandler.cpp
+-    ${CMAKE_CURRENT_SOURCE_DIR}/LAppWavFileHandler.hpp
+     ${CMAKE_CURRENT_SOURCE_DIR}/LAppLive2DManager.cpp
+     ${CMAKE_CURRENT_SOURCE_DIR}/LAppLive2DManager.hpp
+     ${CMAKE_CURRENT_SOURCE_DIR}/LAppModel.cpp
+@@ -21,6 +19,4 @@ target_sources(${APP_NAME}
      ${CMAKE_CURRENT_SOURCE_DIR}/LAppView.cpp
      ${CMAKE_CURRENT_SOURCE_DIR}/LAppView.hpp
      ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
      ${CMAKE_CURRENT_SOURCE_DIR}/LAppView.cpp
      ${CMAKE_CURRENT_SOURCE_DIR}/LAppView.hpp
      ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
@@ -73,9 +82,9 @@ diff -pruN --exclude build ./demo_clean/src/CMakeLists.txt ./demo_dev/src/CMakeL
 -    ${CMAKE_CURRENT_SOURCE_DIR}/TouchManager.hpp
  )
 diff -pruN --exclude build ./demo_clean/src/LAppDefine.cpp ./demo_dev/src/LAppDefine.cpp
 -    ${CMAKE_CURRENT_SOURCE_DIR}/TouchManager.hpp
  )
 diff -pruN --exclude build ./demo_clean/src/LAppDefine.cpp ./demo_dev/src/LAppDefine.cpp
---- ./demo_clean/src/LAppDefine.cpp    2020-10-01 22:47:25.850827994 +0100
-+++ ./demo_dev/src/LAppDefine.cpp      2020-10-18 04:59:13.238452938 +0100
-@@ -61,11 +61,11 @@ namespace LAppDefine {
+--- ./demo_clean/src/LAppDefine.cpp    2021-02-17 01:23:17.000000000 +0000
++++ ./demo_dev/src/LAppDefine.cpp      2021-04-28 12:18:50.948333190 +0100
+@@ -64,11 +64,11 @@ namespace LAppDefine {
      const csmInt32 PriorityForce = 3;
  
      // デバッグ用ログの表示オプション
      const csmInt32 PriorityForce = 3;
  
      // デバッグ用ログの表示オプション
@@ -90,8 +99,8 @@ diff -pruN --exclude build ./demo_clean/src/LAppDefine.cpp ./demo_dev/src/LAppDe
      // デフォルトのレンダーターゲットサイズ
      const csmInt32 RenderTargetWidth = 1900;
 diff -pruN --exclude build ./demo_clean/src/LAppDelegate.cpp ./demo_dev/src/LAppDelegate.cpp
      // デフォルトのレンダーターゲットサイズ
      const csmInt32 RenderTargetWidth = 1900;
 diff -pruN --exclude build ./demo_clean/src/LAppDelegate.cpp ./demo_dev/src/LAppDelegate.cpp
---- ./demo_clean/src/LAppDelegate.cpp  2020-10-01 22:47:25.850827994 +0100
-+++ ./demo_dev/src/LAppDelegate.cpp    2020-10-01 22:47:24.698848890 +0100
+--- ./demo_clean/src/LAppDelegate.cpp  2021-02-17 01:23:17.000000000 +0000
++++ ./demo_dev/src/LAppDelegate.cpp    2021-04-28 12:18:50.948333190 +0100
 @@ -45,7 +45,8 @@ void LAppDelegate::ReleaseInstance()
      s_instance = NULL;
  }
 @@ -45,7 +45,8 @@ void LAppDelegate::ReleaseInstance()
      s_instance = NULL;
  }
@@ -220,8 +229,8 @@ diff -pruN --exclude build ./demo_clean/src/LAppDelegate.cpp ./demo_dev/src/LApp
  
  Csm::csmVector<string> LAppDelegate::Split(const std::string& baseString, char delimiter)
 diff -pruN --exclude build ./demo_clean/src/LAppDelegate.hpp ./demo_dev/src/LAppDelegate.hpp
  
  Csm::csmVector<string> LAppDelegate::Split(const std::string& baseString, char delimiter)
 diff -pruN --exclude build ./demo_clean/src/LAppDelegate.hpp ./demo_dev/src/LAppDelegate.hpp
---- ./demo_clean/src/LAppDelegate.hpp  2020-10-01 22:47:25.850827994 +0100
-+++ ./demo_dev/src/LAppDelegate.hpp    2020-10-01 22:47:24.842846271 +0100
+--- ./demo_clean/src/LAppDelegate.hpp  2021-02-17 01:23:17.000000000 +0000
++++ ./demo_dev/src/LAppDelegate.hpp    2021-04-28 12:18:50.948333190 +0100
 @@ -40,7 +40,8 @@ public:
      /**
      * @brief   APPに必要なものを初期化する。
 @@ -40,7 +40,8 @@ public:
      /**
      * @brief   APPに必要なものを初期化する。
@@ -296,9 +305,9 @@ diff -pruN --exclude build ./demo_clean/src/LAppDelegate.hpp ./demo_dev/src/LApp
 -
 -};
 diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src/LAppLive2DManager.cpp
 -
 -};
 diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src/LAppLive2DManager.cpp
---- ./demo_clean/src/LAppLive2DManager.cpp     2020-10-01 22:47:25.850827994 +0100
-+++ ./demo_dev/src/LAppLive2DManager.cpp       2021-01-02 11:34:29.022662427 +0000
-@@ -52,9 +52,10 @@ void LAppLive2DManager::ReleaseInstance(
+--- ./demo_clean/src/LAppLive2DManager.cpp     2021-02-17 01:23:17.000000000 +0000
++++ ./demo_dev/src/LAppLive2DManager.cpp       2021-04-28 12:24:45.405646016 +0100
+@@ -52,11 +52,11 @@ void LAppLive2DManager::ReleaseInstance(
  
  LAppLive2DManager::LAppLive2DManager()
      : _viewMatrix(NULL)
  
  LAppLive2DManager::LAppLive2DManager()
      : _viewMatrix(NULL)
@@ -307,11 +316,13 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src
 +    , _translateX(0.0f)
 +    , _translateY(0.0f)
  {
 +    , _translateX(0.0f)
 +    , _translateY(0.0f)
  {
+     _viewMatrix = new CubismMatrix44();
+-
 -    ChangeScene(_sceneIndex);
  }
  
  LAppLive2DManager::~LAppLive2DManager()
 -    ChangeScene(_sceneIndex);
  }
  
  LAppLive2DManager::~LAppLive2DManager()
-@@ -98,26 +99,6 @@ void LAppLive2DManager::OnTap(csmFloat32
+@@ -100,26 +100,6 @@ void LAppLive2DManager::OnTap(csmFloat32
      {
          LAppPal::PrintLog("[APP]tap point: {x:%.2f y:%.2f}", x, y);
      }
      {
          LAppPal::PrintLog("[APP]tap point: {x:%.2f y:%.2f}", x, y);
      }
@@ -338,18 +349,25 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src
  }
  
  void LAppLive2DManager::OnUpdate() const
  }
  
  void LAppLive2DManager::OnUpdate() const
-@@ -125,7 +106,9 @@ void LAppLive2DManager::OnUpdate() const
-     CubismMatrix44 projection;
-     int width, height;
-     glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &width, &height);
--    projection.Scale(1.0f, static_cast<float>(width) / static_cast<float>(height));
-+    projection.Scale(_projScaleFactor,
-+                     _projScaleFactor * static_cast<float>(width) / static_cast<float>(height));
-+    projection.Translate(_translateX, _translateY);
+@@ -136,12 +116,15 @@ void LAppLive2DManager::OnUpdate() const
+         {
+             // 横に長いモデルを縦長ウィンドウに表示する際モデルの横サイズでscaleを算出する
+             model->GetModelMatrix()->SetWidth(2.0f);
+-            projection.Scale(1.0f, static_cast<float>(width) / static_cast<float>(height));
++            projection.Scale(_projScaleFactor,
++                             _projScaleFactor * static_cast<float>(width) / static_cast<float>(height));
+         }
+         else
+         {
+-            projection.Scale(static_cast<float>(height) / static_cast<float>(width), 1.0f);
++            projection.Scale(_projScaleFactor * static_cast<float>(height) / static_cast<float>(width),
++                             _projScaleFactor);
+         }
++        projection.Translate(_translateX, _translateY);
  
  
-     if (_viewMatrix != NULL)
-     {
-@@ -148,30 +131,14 @@ void LAppLive2DManager::OnUpdate() const
+         // 必要があればここで乗算
+         if (_viewMatrix != NULL)
+@@ -158,30 +141,14 @@ void LAppLive2DManager::OnUpdate() const
      }
  }
  
      }
  }
  
@@ -384,7 +402,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src
      _models[0]->LoadAssets(modelPath.c_str(), modelJsonName.c_str());
  
      /*
      _models[0]->LoadAssets(modelPath.c_str(), modelJsonName.c_str());
  
      /*
-@@ -193,7 +160,7 @@ void LAppLive2DManager::ChangeScene(Csm:
+@@ -203,7 +170,7 @@ void LAppLive2DManager::ChangeScene(Csm:
  
  #if defined(USE_RENDER_TARGET) || defined(USE_MODEL_RENDER_TARGET)
          // モデル個別にαを付けるサンプルとして、もう1体モデルを作成し、少し位置をずらす
  
  #if defined(USE_RENDER_TARGET) || defined(USE_MODEL_RENDER_TARGET)
          // モデル個別にαを付けるサンプルとして、もう1体モデルを作成し、少し位置をずらす
@@ -393,9 +411,9 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src
          _models[1]->LoadAssets(modelPath.c_str(), modelJsonName.c_str());
          _models[1]->GetModelMatrix()->TranslateX(0.2f);
  #endif
          _models[1]->LoadAssets(modelPath.c_str(), modelJsonName.c_str());
          _models[1]->GetModelMatrix()->TranslateX(0.2f);
  #endif
-@@ -215,3 +182,20 @@ csmUint32 LAppLive2DManager::GetModelNum
- {
-     return _models.GetSize();
+@@ -232,3 +199,20 @@ void LAppLive2DManager::SetViewMatrix(Cu
+         _viewMatrix->GetArray()[i] = m->GetArray()[i];
+     }
  }
 +
 +void LAppLive2DManager::SetTracker(MouseCursorTracker *tracker)
  }
 +
 +void LAppLive2DManager::SetTracker(MouseCursorTracker *tracker)
@@ -415,8 +433,8 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src
 +    _translateY = translateY;
 +}
 diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.hpp ./demo_dev/src/LAppLive2DManager.hpp
 +    _translateY = translateY;
 +}
 diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.hpp ./demo_dev/src/LAppLive2DManager.hpp
---- ./demo_clean/src/LAppLive2DManager.hpp     2020-10-01 22:47:25.846828066 +0100
-+++ ./demo_dev/src/LAppLive2DManager.hpp       2021-01-02 11:29:57.666035355 +0000
+--- ./demo_clean/src/LAppLive2DManager.hpp     2021-02-17 01:23:17.000000000 +0000
++++ ./demo_dev/src/LAppLive2DManager.hpp       2021-04-28 12:18:50.948333190 +0100
 @@ -6,12 +6,15 @@
   */
  #pragma once
 @@ -6,12 +6,15 @@
   */
  #pragma once
@@ -458,9 +476,9 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.hpp ./demo_dev/src
  
      /**
       * @brief   モデル個数を得る
  
      /**
       * @brief   モデル個数を得る
-@@ -89,6 +90,24 @@ public:
+@@ -94,6 +95,24 @@ public:
       */
       */
-     Csm::csmUint32 GetModelNum() const;
+     void SetViewMatrix(Live2D::Cubism::Framework::CubismMatrix44* m);
  
 +    /**
 +     * @brief Set the pointer to the MouseCursorTracker instance
  
 +    /**
 +     * @brief Set the pointer to the MouseCursorTracker instance
@@ -483,7 +501,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.hpp ./demo_dev/src
  private:
      /**
      * @brief  コンストラクタ
  private:
      /**
      * @brief  コンストラクタ
-@@ -102,5 +121,8 @@ private:
+@@ -107,5 +126,8 @@ private:
  
      Csm::CubismMatrix44*        _viewMatrix; ///< モデル描画に用いるView行列
      Csm::csmVector<LAppModel*>  _models; ///< モデルインスタンスのコンテナ
  
      Csm::CubismMatrix44*        _viewMatrix; ///< モデル描画に用いるView行列
      Csm::csmVector<LAppModel*>  _models; ///< モデルインスタンスのコンテナ
@@ -494,8 +512,8 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.hpp ./demo_dev/src
 +    float _translateY;
  };
 diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppModel.cpp
 +    float _translateY;
  };
 diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppModel.cpp
---- ./demo_clean/src/LAppModel.cpp     2020-10-01 22:47:25.850827994 +0100
-+++ ./demo_dev/src/LAppModel.cpp       2021-01-02 11:32:50.632989855 +0000
+--- ./demo_clean/src/LAppModel.cpp     2021-02-17 01:23:17.000000000 +0000
++++ ./demo_dev/src/LAppModel.cpp       2021-04-28 12:26:56.699586813 +0100
 @@ -21,6 +21,10 @@
  #include "LAppTextureManager.hpp"
  #include "LAppDelegate.hpp"
 @@ -21,6 +21,10 @@
  #include "LAppTextureManager.hpp"
  #include "LAppDelegate.hpp"
@@ -548,7 +566,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod
  
          _breath->SetParameters(breathParameters);
      }
  
          _breath->SetParameters(breathParameters);
      }
-@@ -335,59 +341,110 @@ void LAppModel::Update()
+@@ -335,83 +341,118 @@ void LAppModel::Update()
      const csmFloat32 deltaTimeSeconds = LAppPal::GetDeltaTime();
      _userTimeSeconds += deltaTimeSeconds;
  
      const csmFloat32 deltaTimeSeconds = LAppPal::GetDeltaTime();
      _userTimeSeconds += deltaTimeSeconds;
  
@@ -643,6 +661,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod
 -    if (_breath != NULL)
 -    {
 -        _breath->UpdateParameters(_model, deltaTimeSeconds);
 -    if (_breath != NULL)
 -    {
 -        _breath->UpdateParameters(_model, deltaTimeSeconds);
+-    }
 +        if (eyeLOpenIt != params.live2d.end())
 +        {
 +            // If value specified, override blinking
 +        if (eyeLOpenIt != params.live2d.end())
 +        {
 +            // If value specified, override blinking
@@ -653,9 +672,19 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod
 +        {
 +            // If no value specified and no auto blink, set to 1
 +            _model->SetParameterValue(idMan->GetId(_("ParamEyeLOpen")), 1);
 +        {
 +            // If no value specified and no auto blink, set to 1
 +            _model->SetParameterValue(idMan->GetId(_("ParamEyeLOpen")), 1);
-+
+-    // 物理演算の設定
+-    if (_physics != NULL)
+-    {
+-        _physics->Evaluate(_model, deltaTimeSeconds);
+-    }
 +        }
 +        }
-+
+-    // リップシンクの設定
+-    if (_lipSync)
+-    {
+-        // リアルタイムでリップシンクを行う場合、システムから音量を取得して0〜1の範囲で値を入力します。
+-        csmFloat32 value = 0.0f;
 +        if (eyeROpenIt != params.live2d.end())
 +        {
 +            _model->SetParameterValue(idMan->GetId(_("ParamEyeROpen")),
 +        if (eyeROpenIt != params.live2d.end())
 +        {
 +            _model->SetParameterValue(idMan->GetId(_("ParamEyeROpen")),
@@ -665,10 +694,15 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod
 +        {
 +            _model->SetParameterValue(idMan->GetId(_("ParamEyeROpen")), 1);
 +        }
 +        {
 +            _model->SetParameterValue(idMan->GetId(_("ParamEyeROpen")), 1);
 +        }
-+
-+
+-        // 状態更新/RMS値取得
+-        _wavFileHandler.Update(deltaTimeSeconds);
+-        value = _wavFileHandler.GetRms();
+-        for (csmUint32 i = 0; i < _lipSyncIds.GetSize(); ++i)
 +        if (params.useLipSync && _lipSync)
 +        if (params.useLipSync && _lipSync)
-+        {
+         {
+-            _model->AddParameterValue(_lipSyncIds[i], value, 0.8f);
 +            csmFloat32 value = params.lipSyncParam; // 0 to 1
 +
 +            for (csmUint32 i = 0; i < _lipSyncIds.GetSize(); ++i)
 +            csmFloat32 value = params.lipSyncParam; // 0 to 1
 +
 +            for (csmUint32 i = 0; i < _lipSyncIds.GetSize(); ++i)
@@ -699,29 +733,27 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod
 +            // Note: _model->LoadParameters and SaveParameters is needed
 +            // before - see above.
 +            _breath->UpdateParameters(_model, deltaTimeSeconds);
 +            // Note: _model->LoadParameters and SaveParameters is needed
 +            // before - see above.
 +            _breath->UpdateParameters(_model, deltaTimeSeconds);
-+        }
-     }
-     // 物理演算の設定
-@@ -396,17 +453,6 @@ void LAppModel::Update()
-         _physics->Evaluate(_model, deltaTimeSeconds);
+         }
      }
  
      }
  
--    // リップシンクの設定
--    if (_lipSync)
--    {
--        csmFloat32 value = 0; // リアルタイムでリップシンクを行う場合、システムから音量を取得して0〜1の範囲で値を入力します。
--
--        for (csmUint32 i = 0; i < _lipSyncIds.GetSize(); ++i)
--        {
--            _model->AddParameterValue(_lipSyncIds[i], value, 0.8f);
--        }
--    }
--
++    // 物理演算の設定
++    if (_physics != NULL)
++    {
++        _physics->Evaluate(_model, deltaTimeSeconds);
++    }
++
      // ポーズの設定
      if (_pose != NULL)
      {
      // ポーズの設定
      if (_pose != NULL)
      {
-@@ -626,3 +672,42 @@ Csm::Rendering::CubismOffscreenFrame_Ope
+@@ -480,7 +521,6 @@ CubismMotionQueueEntryHandle LAppModel::
+     {
+         csmString path = voice;
+         path = _modelHomeDir + path;
+-        _wavFileHandler.Start(path);
+     }
+     if (_debugMode)
+@@ -632,3 +672,42 @@ Csm::Rendering::CubismOffscreenFrame_Ope
  {
      return _renderBuffer;
  }
  {
      return _renderBuffer;
  }
@@ -765,17 +797,18 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod
 +}
 +
 diff -pruN --exclude build ./demo_clean/src/LAppModel.hpp ./demo_dev/src/LAppModel.hpp
 +}
 +
 diff -pruN --exclude build ./demo_clean/src/LAppModel.hpp ./demo_dev/src/LAppModel.hpp
---- ./demo_clean/src/LAppModel.hpp     2020-10-01 22:47:25.850827994 +0100
-+++ ./demo_dev/src/LAppModel.hpp       2021-01-02 11:33:23.417547739 +0000
-@@ -13,6 +13,7 @@
+--- ./demo_clean/src/LAppModel.hpp     2021-02-17 01:23:17.000000000 +0000
++++ ./demo_dev/src/LAppModel.hpp       2021-04-28 12:27:55.836457680 +0100
+@@ -13,7 +13,7 @@
  #include <Type/csmRectF.hpp>
  #include <Rendering/OpenGL/CubismOffscreenSurface_OpenGLES2.hpp>
  
  #include <Type/csmRectF.hpp>
  #include <Rendering/OpenGL/CubismOffscreenSurface_OpenGLES2.hpp>
  
+-#include "LAppWavFileHandler.hpp"
 +#include "mouse_cursor_tracker.h"
  
  /**
   * @brief ユーザーが実際に使用するモデルの実装クラス<br>
 +#include "mouse_cursor_tracker.h"
  
  /**
   * @brief ユーザーが実際に使用するモデルの実装クラス<br>
-@@ -24,8 +25,11 @@ class LAppModel : public Csm::CubismUser
+@@ -25,8 +25,11 @@ class LAppModel : public Csm::CubismUser
  public:
      /**
       * @brief コンストラクタ
  public:
      /**
       * @brief コンストラクタ
@@ -788,7 +821,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.hpp ./demo_dev/src/LAppMod
  
      /**
       * @brief デストラクタ
  
      /**
       * @brief デストラクタ
-@@ -113,6 +117,15 @@ public:
+@@ -114,6 +117,15 @@ public:
       */
      Csm::Rendering::CubismOffscreenFrame_OpenGLES2& GetRenderBuffer();
  
       */
      Csm::Rendering::CubismOffscreenFrame_OpenGLES2& GetRenderBuffer();
  
@@ -804,7 +837,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.hpp ./demo_dev/src/LAppMod
  protected:
      /**
       *  @brief  モデルを描画する処理。モデルを描画する空間のView-Projection行列を渡す。
  protected:
      /**
       *  @brief  モデルを描画する処理。モデルを描画する空間のView-Projection行列を渡す。
-@@ -166,6 +179,17 @@ private:
+@@ -167,6 +179,17 @@ private:
      */
      void ReleaseExpressions();
  
      */
      void ReleaseExpressions();
  
@@ -822,9 +855,12 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.hpp ./demo_dev/src/LAppMod
      Csm::ICubismModelSetting* _modelSetting; ///< モデルセッティング情報
      Csm::csmString _modelHomeDir; ///< モデルセッティングが置かれたディレクトリ
      Csm::csmFloat32 _userTimeSeconds; ///< デルタ時間の積算値[秒]
      Csm::ICubismModelSetting* _modelSetting; ///< モデルセッティング情報
      Csm::csmString _modelHomeDir; ///< モデルセッティングが置かれたディレクトリ
      Csm::csmFloat32 _userTimeSeconds; ///< デルタ時間の積算値[秒]
-@@ -183,6 +207,8 @@ private:
+@@ -183,9 +206,9 @@ private:
+     const Csm::CubismId* _idParamEyeBallX; ///< パラメータID: ParamEyeBallX
      const Csm::CubismId* _idParamEyeBallY; ///< パラメータID: ParamEyeBallXY
  
      const Csm::CubismId* _idParamEyeBallY; ///< パラメータID: ParamEyeBallXY
  
+-    LAppWavFileHandler _wavFileHandler; ///< wavファイルハンドラ
+-
      Csm::Rendering::CubismOffscreenFrame_OpenGLES2 _renderBuffer;   ///< フレームバッファ以外の描画先
 +
 +    MouseCursorTracker *_tracker;
      Csm::Rendering::CubismOffscreenFrame_OpenGLES2 _renderBuffer;   ///< フレームバッファ以外の描画先
 +
 +    MouseCursorTracker *_tracker;
@@ -832,8 +868,8 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.hpp ./demo_dev/src/LAppMod
  
  
 diff -pruN --exclude build ./demo_clean/src/LAppPal.cpp ./demo_dev/src/LAppPal.cpp
  
  
 diff -pruN --exclude build ./demo_clean/src/LAppPal.cpp ./demo_dev/src/LAppPal.cpp
---- ./demo_clean/src/LAppPal.cpp       2020-10-01 22:47:25.850827994 +0100
-+++ ./demo_dev/src/LAppPal.cpp 2020-10-18 04:57:43.289600308 +0100
+--- ./demo_clean/src/LAppPal.cpp       2021-02-17 01:23:17.000000000 +0000
++++ ./demo_dev/src/LAppPal.cpp 2021-04-28 12:18:50.952333251 +0100
 @@ -6,6 +6,7 @@
   */
  
 @@ -6,6 +6,7 @@
   */
  
@@ -863,8 +899,8 @@ diff -pruN --exclude build ./demo_clean/src/LAppPal.cpp ./demo_dev/src/LAppPal.c
      }
      file.read(buf, size);
 diff -pruN --exclude build ./demo_clean/src/LAppTextureManager.cpp ./demo_dev/src/LAppTextureManager.cpp
      }
      file.read(buf, size);
 diff -pruN --exclude build ./demo_clean/src/LAppTextureManager.cpp ./demo_dev/src/LAppTextureManager.cpp
---- ./demo_clean/src/LAppTextureManager.cpp    2020-10-01 22:47:25.850827994 +0100
-+++ ./demo_dev/src/LAppTextureManager.cpp      2020-10-01 22:47:24.654849690 +0100
+--- ./demo_clean/src/LAppTextureManager.cpp    2021-02-17 01:23:17.000000000 +0000
++++ ./demo_dev/src/LAppTextureManager.cpp      2021-04-28 12:18:50.952333251 +0100
 @@ -96,6 +96,46 @@ LAppTextureManager::TextureInfo* LAppTex
  
  }
 @@ -96,6 +96,46 @@ LAppTextureManager::TextureInfo* LAppTex
  
  }
@@ -913,8 +949,8 @@ diff -pruN --exclude build ./demo_clean/src/LAppTextureManager.cpp ./demo_dev/sr
  {
      for (Csm::csmUint32 i = 0; i < _textures.GetSize(); i++)
 diff -pruN --exclude build ./demo_clean/src/LAppTextureManager.hpp ./demo_dev/src/LAppTextureManager.hpp
  {
      for (Csm::csmUint32 i = 0; i < _textures.GetSize(); i++)
 diff -pruN --exclude build ./demo_clean/src/LAppTextureManager.hpp ./demo_dev/src/LAppTextureManager.hpp
---- ./demo_clean/src/LAppTextureManager.hpp    2020-10-01 22:47:25.846828066 +0100
-+++ ./demo_dev/src/LAppTextureManager.hpp      2020-10-01 22:47:24.786847290 +0100
+--- ./demo_clean/src/LAppTextureManager.hpp    2021-02-17 01:23:17.000000000 +0000
++++ ./demo_dev/src/LAppTextureManager.hpp      2021-04-28 12:18:50.952333251 +0100
 @@ -72,6 +72,8 @@ public:
      */
      TextureInfo* CreateTextureFromPngFile(std::string fileName);
 @@ -72,6 +72,8 @@ public:
      */
      TextureInfo* CreateTextureFromPngFile(std::string fileName);
@@ -925,8 +961,8 @@ diff -pruN --exclude build ./demo_clean/src/LAppTextureManager.hpp ./demo_dev/sr
      * @brief 画像の解放
      *
 diff -pruN --exclude build ./demo_clean/src/LAppView.cpp ./demo_dev/src/LAppView.cpp
      * @brief 画像の解放
      *
 diff -pruN --exclude build ./demo_clean/src/LAppView.cpp ./demo_dev/src/LAppView.cpp
---- ./demo_clean/src/LAppView.cpp      2020-10-01 22:47:25.850827994 +0100
-+++ ./demo_dev/src/LAppView.cpp        2020-10-01 22:47:24.602850636 +0100
+--- ./demo_clean/src/LAppView.cpp      2021-02-17 01:23:17.000000000 +0000
++++ ./demo_dev/src/LAppView.cpp        2021-04-28 12:18:50.952333251 +0100
 @@ -13,7 +13,6 @@
  #include "LAppLive2DManager.hpp"
  #include "LAppTextureManager.hpp"
 @@ -13,7 +13,6 @@
  #include "LAppLive2DManager.hpp"
  #include "LAppTextureManager.hpp"
@@ -964,7 +1000,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppView.cpp ./demo_dev/src/LAppView
  }
  
  void LAppView::Initialize()
  }
  
  void LAppView::Initialize()
-@@ -97,9 +89,6 @@ void LAppView::Initialize()
+@@ -107,9 +99,6 @@ void LAppView::Initialize()
  void LAppView::Render()
  {
      _back->Render();
  void LAppView::Render()
  {
      _back->Render();
@@ -974,7 +1010,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppView.cpp ./demo_dev/src/LAppView
  
      LAppLive2DManager* Live2DManager = LAppLive2DManager::GetInstance();
  
  
      LAppLive2DManager* Live2DManager = LAppLive2DManager::GetInstance();
  
-@@ -139,35 +128,17 @@ void LAppView::InitializeSprite()
+@@ -151,35 +140,17 @@ void LAppView::InitializeSprite()
      glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &width, &height);
  
      LAppTextureManager* textureManager = LAppDelegate::GetInstance()->GetTextureManager();
      glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &width, &height);
  
      LAppTextureManager* textureManager = LAppDelegate::GetInstance()->GetTextureManager();
@@ -1015,7 +1051,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppView.cpp ./demo_dev/src/LAppView
      // 画面全体を覆うサイズ
      x = width * 0.5f;
      y = height * 0.5f;
      // 画面全体を覆うサイズ
      x = width * 0.5f;
      y = height * 0.5f;
-@@ -175,52 +146,6 @@ void LAppView::InitializeSprite()
+@@ -187,52 +158,6 @@ void LAppView::InitializeSprite()
  
  }
  
  
  }
  
@@ -1068,7 +1104,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppView.cpp ./demo_dev/src/LAppView
  float LAppView::TransformViewX(float deviceX) const
  {
      float screenX = _deviceToScreen->TransformX(deviceX); // 論理座標変換した座標を取得。
  float LAppView::TransformViewX(float deviceX) const
  {
      float screenX = _deviceToScreen->TransformX(deviceX); // 論理座標変換した座標を取得。
-@@ -362,32 +287,4 @@ void LAppView::ResizeSprite()
+@@ -374,32 +299,4 @@ void LAppView::ResizeSprite()
              _back->ResetRect(x, y, fWidth, fHeight);
          }
      }
              _back->ResetRect(x, y, fWidth, fHeight);
          }
      }
@@ -1102,8 +1138,8 @@ diff -pruN --exclude build ./demo_clean/src/LAppView.cpp ./demo_dev/src/LAppView
 -    }
  }
 diff -pruN --exclude build ./demo_clean/src/LAppView.hpp ./demo_dev/src/LAppView.hpp
 -    }
  }
 diff -pruN --exclude build ./demo_clean/src/LAppView.hpp ./demo_dev/src/LAppView.hpp
---- ./demo_clean/src/LAppView.hpp      2020-10-01 22:47:25.846828066 +0100
-+++ ./demo_dev/src/LAppView.hpp        2020-10-01 22:47:24.802846999 +0100
+--- ./demo_clean/src/LAppView.hpp      2021-02-17 01:23:17.000000000 +0000
++++ ./demo_dev/src/LAppView.hpp        2021-04-28 12:18:50.952333251 +0100
 @@ -14,7 +14,6 @@
  #include "CubismFramework.hpp"
  #include <Rendering/OpenGL/CubismOffscreenSurface_OpenGLES2.hpp>
 @@ -14,7 +14,6 @@
  #include "CubismFramework.hpp"
  #include <Rendering/OpenGL/CubismOffscreenSurface_OpenGLES2.hpp>
@@ -1158,8 +1194,8 @@ diff -pruN --exclude build ./demo_clean/src/LAppView.hpp ./demo_dev/src/LAppView
      // レンダリング先を別ターゲットにする方式の場合に使用
      LAppSprite* _renderSprite;                                  ///< モードによっては_renderBufferのテクスチャを描画
 diff -pruN --exclude build ./demo_clean/src/main.cpp ./demo_dev/src/main.cpp
      // レンダリング先を別ターゲットにする方式の場合に使用
      LAppSprite* _renderSprite;                                  ///< モードによっては_renderBufferのテクスチャを描画
 diff -pruN --exclude build ./demo_clean/src/main.cpp ./demo_dev/src/main.cpp
---- ./demo_clean/src/main.cpp  2020-10-01 22:47:25.846828066 +0100
-+++ ./demo_dev/src/main.cpp    2021-01-02 11:41:01.033288228 +0000
+--- ./demo_clean/src/main.cpp  2021-02-17 01:23:17.000000000 +0000
++++ ./demo_dev/src/main.cpp    2021-04-28 12:28:55.845339613 +0100
 @@ -5,18 +5,188 @@
   * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
   */
 @@ -5,18 +5,188 @@
   * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
   */
@@ -1208,9 +1244,9 @@ diff -pruN --exclude build ./demo_clean/src/main.cpp ./demo_dev/src/main.cpp
 +    cmdArgs.windowHeight = 600;
 +    cmdArgs.windowTitle = "MouseTrackerForCubism example";
 +    cmdArgs.rootDir = fs::current_path();
 +    cmdArgs.windowHeight = 600;
 +    cmdArgs.windowTitle = "MouseTrackerForCubism example";
 +    cmdArgs.rootDir = fs::current_path();
-+    cmdArgs.scaleFactor = 8.0f;
++    cmdArgs.scaleFactor = 4.5f;
 +    cmdArgs.translateX = 0.0f;
 +    cmdArgs.translateX = 0.0f;
-+    cmdArgs.translateY = -2.8f;
++    cmdArgs.translateY = -3.1f;
 +    cmdArgs.modelName = "Haru";
 +    cmdArgs.oldId = false;
 +    cmdArgs.cfgPath = "";
 +    cmdArgs.modelName = "Haru";
 +    cmdArgs.oldId = false;
 +    cmdArgs.cfgPath = "";
index 738ff0a..9ebe84e 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
 
 mkdir -p demo_clean
 #!/bin/sh
 
 mkdir -p demo_clean
-cp -p -r CubismSdkForNative-4-r.1/Samples/OpenGL/Demo/proj.linux.cmake/* ./demo_clean/
+cp -p -r CubismSdkForNative-4-r.2/Samples/OpenGL/Demo/proj.linux.cmake/* ./demo_clean/
 diff -pruN --exclude build ./demo_clean ./demo_dev > ./demo.patch
 diff -pruN --exclude build ./demo_clean ./demo_dev > ./demo.patch