From: Adrian Iain Lam Date: Sun, 2 Jan 2022 01:43:46 +0000 (+0000) Subject: Upgrade to Cubism 4 Release R4. No incompatible API changes. X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=5f788e6f6c607094e03b53e595c41c930a73b12d;p=facial-landmarks-for-cubism.git Upgrade to Cubism 4 Release R4. No incompatible API changes. --- diff --git a/README.md b/README.md index 345fe15..d3d9fa9 100644 --- a/README.md +++ b/README.md @@ -67,17 +67,17 @@ if you don't have C++17 support. To build the example program: -5. Download "Cubism 4 SDK for Native R3" from the Live2D website: +5. Download "Cubism 4 SDK for Native R4" from the Live2D website: . - Extract the archive -- put the "CubismSdkForNative-4-r.3" folder under + Extract the archive -- put the "CubismSdkForNative-4-r.4" 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. 6. Go into the - "example/CubismSdkForNative-4-r.3/Samples/OpenGL/thirdParty/scripts" + "example/CubismSdkForNative-4-r.4/Samples/OpenGL/thirdParty/scripts" directory and run ./setup_glew_glfw diff --git a/example/build.sh b/example/build.sh index b492043..25dcfb2 100755 --- a/example/build.sh +++ b/example/build.sh @@ -1,6 +1,6 @@ #!/bin/sh -e mkdir -p demo_build -cp -r CubismSdkForNative-4-r.3/Samples/OpenGL/Demo/proj.linux.cmake/* ./demo_build/ +cp -r CubismSdkForNative-4-r.4/Samples/OpenGL/Demo/proj.linux.cmake/* ./demo_build/ patch -d demo_build -p2 < demo.patch ./demo_build/scripts/make_gcc diff --git a/example/demo.patch b/example/demo.patch index 3a0143a..56bebfb 100644 --- a/example/demo.patch +++ b/example/demo.patch @@ -1,12 +1,12 @@ diff -pruN --exclude build ./demo_clean/CMakeLists.txt ./demo_dev/CMakeLists.txt ---- ./demo_clean/CMakeLists.txt 2021-02-17 01:23:17.000000000 +0000 -+++ ./demo_dev/CMakeLists.txt 2021-06-12 17:02:27.101948990 +0100 +--- ./demo_clean/CMakeLists.txt 2021-12-09 00:50:34.000000000 +0000 ++++ ./demo_dev/CMakeLists.txt 2022-01-02 01:25:07.078550112 +0000 @@ -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.3) ++set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../CubismSdkForNative-4-r.4) set(CORE_PATH ${SDK_ROOT_PATH}/Core) set(FRAMEWORK_PATH ${SDK_ROOT_PATH}/Framework) set(THIRD_PARTY_PATH ${SDK_ROOT_PATH}/Samples/OpenGL/thirdParty) @@ -43,35 +43,120 @@ 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 ---- ./demo_clean/scripts/make_gcc 2021-02-17 01:23:17.000000000 +0000 +--- ./demo_clean/scripts/make_gcc 2021-12-09 00:50:34.000000000 +0000 +++ ./demo_dev/scripts/make_gcc 2021-05-29 02:04:17.338257917 +0100 -@@ -10,4 +10,4 @@ BUILD_PATH=$SCRIPT_PATH/../build/make_gc +@@ -5,41 +5,9 @@ set -ue + SCRIPT_PATH=$(cd $(dirname $0) && pwd) + CMAKE_PATH=$SCRIPT_PATH/.. + BUILD_PATH=$SCRIPT_PATH/../build/make_gcc +-MINIMUM_DEMO="OFF" +-DATA="" +- +-if [ "$#" -ne 0 ]; then +- DATA="$1" +-fi +- +-while : +-do +- +- if [ -z "$DATA" ]; then +- echo "Choose which format you would like to create the demo." +- echo "Full version : 1" +- echo "Minimum version : 2" +- read -p "Your Choice : " DATA +- fi +- +- case "$DATA" in +- "1" ) +- echo "Making Full Demo" +- MINIMUM_DEMO="OFF" +- break ;; +- "2" ) +- echo "Making Minimum Demo" +- MINIMUM_DEMO="ON" +- break ;; +- * ) +- echo "You need to enter a valid number." +- DATA="" ;; +- esac +-done + + # Run CMake. cmake -S "$CMAKE_PATH" \ -B "$BUILD_PATH" \ - -D CMAKE_BUILD_TYPE=Release +- -D CMAKE_BUILD_TYPE=Release \ +- -D CSM_MINIMUM_DEMO=$MINIMUM_DEMO -cd "$BUILD_PATH" && make ++ -D CMAKE_BUILD_TYPE=Release +cd "$BUILD_PATH" && make -j4 diff -pruN --exclude build ./demo_clean/src/CMakeLists.txt ./demo_dev/src/CMakeLists.txt ---- ./demo_clean/src/CMakeLists.txt 2021-02-17 01:23:17.000000000 +0000 +--- ./demo_clean/src/CMakeLists.txt 2021-12-09 00:50:34.000000000 +0000 +++ ./demo_dev/src/CMakeLists.txt 2021-04-28 11:49:43.166296000 +0100 -@@ -6,8 +6,6 @@ target_sources(${APP_NAME} +@@ -1,49 +1,22 @@ +-if (CSM_MINIMUM_DEMO) +- target_sources(${APP_NAME} ++target_sources(${APP_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/LAppAllocator.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/LAppAllocator.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/LAppDefine.cpp ${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}/LAppDelegate.cpp ++ ${CMAKE_CURRENT_SOURCE_DIR}/LAppDelegate.hpp ++ ${CMAKE_CURRENT_SOURCE_DIR}/LAppLive2DManager.cpp ++ ${CMAKE_CURRENT_SOURCE_DIR}/LAppLive2DManager.hpp ++ ${CMAKE_CURRENT_SOURCE_DIR}/LAppModel.cpp ++ ${CMAKE_CURRENT_SOURCE_DIR}/LAppModel.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/LAppPal.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/LAppPal.hpp ++ ${CMAKE_CURRENT_SOURCE_DIR}/LAppSprite.cpp ++ ${CMAKE_CURRENT_SOURCE_DIR}/LAppSprite.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/LAppTextureManager.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/LAppTextureManager.hpp +- ${CMAKE_CURRENT_SOURCE_DIR}/mainMinimum.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/TouchManager.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/TouchManager.hpp - ) +- ${CMAKE_CURRENT_SOURCE_DIR}/CubismUserModelExtend.cpp +- ${CMAKE_CURRENT_SOURCE_DIR}/CubismUserModelExtend.hpp +- ${CMAKE_CURRENT_SOURCE_DIR}/CubismSampleViewMatrix.cpp +- ${CMAKE_CURRENT_SOURCE_DIR}/CubismSampleViewMatrix.hpp +- ${CMAKE_CURRENT_SOURCE_DIR}/MouseActionManager.cpp +- ${CMAKE_CURRENT_SOURCE_DIR}/MouseActionManager.hpp +- ) +-else () +- target_sources(${APP_NAME} +- PRIVATE +- ${CMAKE_CURRENT_SOURCE_DIR}/LAppAllocator.cpp +- ${CMAKE_CURRENT_SOURCE_DIR}/LAppAllocator.hpp +- ${CMAKE_CURRENT_SOURCE_DIR}/LAppDefine.cpp +- ${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 +- ${CMAKE_CURRENT_SOURCE_DIR}/LAppModel.hpp +- ${CMAKE_CURRENT_SOURCE_DIR}/LAppPal.cpp +- ${CMAKE_CURRENT_SOURCE_DIR}/LAppPal.hpp +- ${CMAKE_CURRENT_SOURCE_DIR}/LAppSprite.cpp +- ${CMAKE_CURRENT_SOURCE_DIR}/LAppSprite.hpp +- ${CMAKE_CURRENT_SOURCE_DIR}/LAppTextureManager.cpp +- ${CMAKE_CURRENT_SOURCE_DIR}/LAppTextureManager.hpp +- ${CMAKE_CURRENT_SOURCE_DIR}/LAppView.cpp +- ${CMAKE_CURRENT_SOURCE_DIR}/LAppView.hpp +- ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp +- ${CMAKE_CURRENT_SOURCE_DIR}/TouchManager.cpp +- ${CMAKE_CURRENT_SOURCE_DIR}/TouchManager.hpp +- ) +-endif () ++ ${CMAKE_CURRENT_SOURCE_DIR}/LAppView.cpp ++ ${CMAKE_CURRENT_SOURCE_DIR}/LAppView.hpp ++ ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ++) diff -pruN --exclude build ./demo_clean/src/LAppDelegate.cpp ./demo_dev/src/LAppDelegate.cpp ---- ./demo_clean/src/LAppDelegate.cpp 2021-02-17 01:23:17.000000000 +0000 +--- ./demo_clean/src/LAppDelegate.cpp 2021-12-09 00:50:34.000000000 +0000 +++ ./demo_dev/src/LAppDelegate.cpp 2021-04-28 11:49:43.166296000 +0100 @@ -45,7 +45,8 @@ void LAppDelegate::ReleaseInstance() s_instance = NULL; @@ -98,7 +183,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppDelegate.cpp ./demo_dev/src/LApp if (_window == NULL) { if (DebugLogEnable) -@@ -95,10 +102,6 @@ bool LAppDelegate::Initialize() +@@ -95,16 +102,11 @@ bool LAppDelegate::Initialize() glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -109,7 +194,13 @@ diff -pruN --exclude build ./demo_clean/src/LAppDelegate.cpp ./demo_dev/src/LApp // ウィンドウサイズ記憶 int width, height; glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &width, &height); -@@ -111,8 +114,6 @@ bool LAppDelegate::Initialize() + _windowWidth = width; + _windowHeight = height; +- glViewport(0, 0, _windowWidth, _windowHeight); + + //AppViewの初期化 + _view->Initialize(); +@@ -112,8 +114,6 @@ bool LAppDelegate::Initialize() // Cubism3の初期化 InitializeCubism(); @@ -118,7 +209,15 @@ diff -pruN --exclude build ./demo_clean/src/LAppDelegate.cpp ./demo_dev/src/LApp //load model LAppLive2DManager::GetInstance(); -@@ -214,49 +215,6 @@ void LAppDelegate::InitializeCubism() +@@ -155,7 +155,6 @@ void LAppDelegate::Run() + _windowWidth = width; + _windowHeight = height; + } +- glViewport(0, 0, _windowWidth, _windowHeight); + + // 時間更新 + LAppPal::UpdateTime(); +@@ -216,49 +215,6 @@ void LAppDelegate::InitializeCubism() LAppPal::UpdateTime(); } @@ -168,7 +267,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppDelegate.cpp ./demo_dev/src/LApp GLuint LAppDelegate::CreateShader() { //バーテックスシェーダのコンパイル -@@ -299,29 +257,9 @@ GLuint LAppDelegate::CreateShader() +@@ -301,29 +257,9 @@ GLuint LAppDelegate::CreateShader() return programId; } @@ -201,7 +300,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppDelegate.cpp ./demo_dev/src/LApp Csm::csmVector 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 2021-02-17 01:23:17.000000000 +0000 +--- ./demo_clean/src/LAppDelegate.hpp 2021-12-09 00:50:34.000000000 +0000 +++ ./demo_dev/src/LAppDelegate.hpp 2021-04-28 11:49:43.166296000 +0100 @@ -40,7 +40,8 @@ public: /** @@ -277,7 +376,7 @@ 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 ---- ./demo_clean/src/LAppLive2DManager.cpp 2021-02-17 01:23:17.000000000 +0000 +--- ./demo_clean/src/LAppLive2DManager.cpp 2021-12-09 00:50:34.000000000 +0000 +++ ./demo_dev/src/LAppLive2DManager.cpp 2021-04-28 11:49:43.166296000 +0100 @@ -52,11 +52,11 @@ void LAppLive2DManager::ReleaseInstance( @@ -321,7 +420,17 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src } void LAppLive2DManager::OnUpdate() const -@@ -136,12 +116,15 @@ void LAppLive2DManager::OnUpdate() const +@@ -127,21 +107,24 @@ void LAppLive2DManager::OnUpdate() const + int width, height; + glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &width, &height); + ++ CubismMatrix44 projection; + csmUint32 modelCount = _models.GetSize(); + for (csmUint32 i = 0; i < modelCount; ++i) + { +- CubismMatrix44 projection; + LAppModel* model = GetModel(i); + if (model->GetModel()->GetCanvasWidth() > 1.0f && width < height) { // 横に長いモデルを縦長ウィンドウに表示する際モデルの横サイズでscaleを算出する model->GetModelMatrix()->SetWidth(2.0f); @@ -405,7 +514,7 @@ 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 ---- ./demo_clean/src/LAppLive2DManager.hpp 2021-02-17 01:23:17.000000000 +0000 +--- ./demo_clean/src/LAppLive2DManager.hpp 2021-12-09 00:50:34.000000000 +0000 +++ ./demo_dev/src/LAppLive2DManager.hpp 2021-04-28 11:49:43.166296000 +0100 @@ -6,12 +6,15 @@ */ @@ -484,7 +593,7 @@ 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 ---- ./demo_clean/src/LAppModel.cpp 2021-02-17 01:23:17.000000000 +0000 +--- ./demo_clean/src/LAppModel.cpp 2021-12-09 00:50:34.000000000 +0000 +++ ./demo_dev/src/LAppModel.cpp 2021-04-28 11:49:43.166296000 +0100 @@ -21,6 +21,8 @@ #include "LAppTextureManager.hpp" @@ -758,7 +867,7 @@ 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 ---- ./demo_clean/src/LAppModel.hpp 2021-02-17 01:23:17.000000000 +0000 +--- ./demo_clean/src/LAppModel.hpp 2021-12-09 00:50:34.000000000 +0000 +++ ./demo_dev/src/LAppModel.hpp 2021-04-28 11:49:43.166296000 +0100 @@ -13,7 +13,7 @@ #include @@ -827,7 +936,7 @@ 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 ---- ./demo_clean/src/LAppPal.cpp 2021-02-17 01:23:17.000000000 +0000 +--- ./demo_clean/src/LAppPal.cpp 2021-12-09 00:50:34.000000000 +0000 +++ ./demo_dev/src/LAppPal.cpp 2021-04-28 11:49:43.170296000 +0100 @@ -6,6 +6,7 @@ */ @@ -850,7 +959,7 @@ 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 ---- ./demo_clean/src/LAppTextureManager.cpp 2021-02-17 01:23:17.000000000 +0000 +--- ./demo_clean/src/LAppTextureManager.cpp 2021-12-09 00:50:34.000000000 +0000 +++ ./demo_dev/src/LAppTextureManager.cpp 2021-04-28 11:49:43.178296000 +0100 @@ -96,6 +96,46 @@ LAppTextureManager::TextureInfo* LAppTex @@ -900,7 +1009,7 @@ 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 ---- ./demo_clean/src/LAppTextureManager.hpp 2021-02-17 01:23:17.000000000 +0000 +--- ./demo_clean/src/LAppTextureManager.hpp 2021-12-09 00:50:34.000000000 +0000 +++ ./demo_dev/src/LAppTextureManager.hpp 2021-04-28 11:49:43.178296000 +0100 @@ -72,6 +72,8 @@ public: */ @@ -912,7 +1021,7 @@ 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 ---- ./demo_clean/src/LAppView.cpp 2021-02-17 01:23:17.000000000 +0000 +--- ./demo_clean/src/LAppView.cpp 2021-12-09 00:50:34.000000000 +0000 +++ ./demo_dev/src/LAppView.cpp 2021-04-28 11:49:43.178296000 +0100 @@ -13,7 +13,6 @@ #include "LAppLive2DManager.hpp" @@ -1089,7 +1198,7 @@ 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 ---- ./demo_clean/src/LAppView.hpp 2021-02-17 01:23:17.000000000 +0000 +--- ./demo_clean/src/LAppView.hpp 2021-12-09 00:50:34.000000000 +0000 +++ ./demo_dev/src/LAppView.hpp 2021-04-28 11:49:43.178296000 +0100 @@ -14,7 +14,6 @@ #include "CubismFramework.hpp" @@ -1145,7 +1254,7 @@ 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 ---- ./demo_clean/src/main.cpp 2021-02-17 01:23:17.000000000 +0000 +--- ./demo_clean/src/main.cpp 2021-12-09 00:50:34.000000000 +0000 +++ ./demo_dev/src/main.cpp 2021-04-28 11:49:43.178296000 +0100 @@ -5,18 +5,162 @@ * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. diff --git a/example/generate_patch.sh b/example/generate_patch.sh index 9ebe84e..73bb563 100755 --- a/example/generate_patch.sh +++ b/example/generate_patch.sh @@ -1,5 +1,5 @@ #!/bin/sh mkdir -p demo_clean -cp -p -r CubismSdkForNative-4-r.2/Samples/OpenGL/Demo/proj.linux.cmake/* ./demo_clean/ +cp -p -r CubismSdkForNative-4-r.4/Samples/OpenGL/Demo/proj.linux.cmake/* ./demo_clean/ diff -pruN --exclude build ./demo_clean ./demo_dev > ./demo.patch