From ee3fcae5e0d637b9714c25e67b580b6c0da65d29 Mon Sep 17 00:00:00 2001 From: Adrian Iain Lam Date: Fri, 30 May 2025 01:30:53 +0100 Subject: [PATCH] Upgrade to Cubism 5 Release R4. --- README.md | 6 +- example/build.sh | 2 +- example/demo.patch | 1629 +++------------------------------------------ example/generate_patch.sh | 2 +- 4 files changed, 101 insertions(+), 1538 deletions(-) diff --git a/README.md b/README.md index 0812a3e..b919b3d 100644 --- a/README.md +++ b/README.md @@ -50,17 +50,17 @@ if you don't have C++17 support. To build the example program: -4. Download "Cubism 5 SDK for Native R3" from the Live2D website: +4. Download "Cubism 5 SDK for Native R4" from the Live2D website: . - Extract the archive -- put the "CubismSdkForNative-5-r.3" folder under + Extract the archive -- put the "CubismSdkForNative-5-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. 5. Go into the - "example/CubismSdkForNative-5-r.3/Samples/OpenGL/thirdParty/scripts" + "example/CubismSdkForNative-5-r.4/Samples/OpenGL/thirdParty/scripts" directory and run ./setup_glew_glfw diff --git a/example/build.sh b/example/build.sh index e895b81..109ced8 100755 --- a/example/build.sh +++ b/example/build.sh @@ -1,6 +1,6 @@ #!/bin/sh -e mkdir -p demo_build -cp -r CubismSdkForNative-5-r.3/Samples/OpenGL/Demo/proj.linux.cmake/* ./demo_build/ +cp -r CubismSdkForNative-5-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 d0f53a0..3286429 100644 --- a/example/demo.patch +++ b/example/demo.patch @@ -1,24 +1,16 @@ diff -pruN --exclude build ./demo_clean/CMakeLists.txt ./demo_dev/CMakeLists.txt ---- ./demo_clean/CMakeLists.txt 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/CMakeLists.txt 2025-03-23 03:23:43.815969266 +0000 +--- ./demo_clean/CMakeLists.txt 2025-05-30 00:59:58.252401066 +0100 ++++ ./demo_dev/CMakeLists.txt 2025-05-30 01:05:35.538986524 +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}/../../../..) -+set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../CubismSdkForNative-5-r.3) ++set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../CubismSdkForNative-5-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) -@@ -11,7 +11,6 @@ set(STB_PATH ${THIRD_PARTY_PATH}/stb) - set(GLEW_PATH ${THIRD_PARTY_PATH}/glew) - set(GLFW_PATH ${THIRD_PARTY_PATH}/glfw) - set(RES_PATH ${SDK_ROOT_PATH}/Samples/Resources) --set(SAMPLE_SHADER_PATH ${SDK_ROOT_PATH}/Samples/OpenGL/Shaders/Standard) - - # Set project. - project(${APP_NAME}) -@@ -33,7 +32,7 @@ set(GLFW_INSTALL OFF CACHE BOOL "" FORCE +@@ -35,7 +35,7 @@ set(GLFW_INSTALL OFF CACHE BOOL "" FORCE set(BUILD_UTILS OFF CACHE BOOL "" FORCE) # Specify version of compiler. @@ -27,7 +19,7 @@ diff -pruN --exclude build ./demo_clean/CMakeLists.txt ./demo_dev/CMakeLists.txt set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -@@ -65,26 +64,42 @@ target_link_libraries(Framework Live2DCu +@@ -67,6 +67,11 @@ target_link_libraries(Framework Live2DCu # Find opengl libraries. find_package(OpenGL REQUIRED) @@ -38,11 +30,8 @@ diff -pruN --exclude build ./demo_clean/CMakeLists.txt ./demo_dev/CMakeLists.txt + # Make executable app. add_executable(${APP_NAME}) - # Add source files. - add_subdirectory(src) -- - # Link libraries to app. - target_link_libraries(${APP_NAME} + # Add common source files. +@@ -79,9 +84,20 @@ target_link_libraries(${APP_NAME} Framework glfw ${OPENGL_LIBRARIES} @@ -64,18 +53,8 @@ diff -pruN --exclude build ./demo_clean/CMakeLists.txt ./demo_dev/CMakeLists.txt # Copy resource directory to build directory. add_custom_command( - TARGET ${APP_NAME} - POST_BUILD -- COMMAND ${CMAKE_COMMAND} -E copy_directory ${RES_PATH} $/Resources -- COMMAND ${CMAKE_COMMAND} -E copy_directory ${SAMPLE_SHADER_PATH} $/SampleShaders -+ COMMAND -+ ${CMAKE_COMMAND} -E -+ copy_directory ${RES_PATH} $/Resources - ) - - # You can change target that renderer draws by enabling following definition. diff -pruN --exclude build ./demo_clean/scripts/make_gcc ./demo_dev/scripts/make_gcc ---- ./demo_clean/scripts/make_gcc 2025-03-23 03:22:05.213672569 +0000 +--- ./demo_clean/scripts/make_gcc 2025-05-30 00:59:58.252401066 +0100 +++ ./demo_dev/scripts/make_gcc 2023-05-28 09:11:29.467788463 +0100 @@ -5,42 +5,9 @@ set -ue SCRIPT_PATH=$(cd $(dirname $0) && pwd) @@ -122,227 +101,10 @@ diff -pruN --exclude build ./demo_clean/scripts/make_gcc ./demo_dev/scripts/make -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 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/CMakeLists.txt 2024-03-28 18:43:36.369973576 +0000 -@@ -1,51 +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}/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}/LAppSpriteShader.cpp -- ${CMAKE_CURRENT_SOURCE_DIR}/LAppSpriteShader.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/CubismUserModelExtend.cpp ./demo_dev/src/CubismUserModelExtend.cpp ---- ./demo_clean/src/CubismUserModelExtend.cpp 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/CubismUserModelExtend.cpp 2024-03-28 18:43:36.373973644 +0000 -@@ -119,15 +119,12 @@ void CubismUserModelExtend::SetupModel() - buffer = CreateBuffer(path.GetRawString(), &size); - ACubismMotion* motion = LoadExpression(buffer, size, name.GetRawString()); - -- if (motion) -+ if (_expressions[name]) - { -- if (_expressions[name]) -- { -- ACubismMotion::Delete(_expressions[name]); -- _expressions[name] = nullptr; -- } -- _expressions[name] = motion; -+ ACubismMotion::Delete(_expressions[name]); -+ _expressions[name] = nullptr; - } -+ _expressions[name] = motion; - - DeleteBuffer(buffer, path.GetRawString()); - } -@@ -211,17 +208,28 @@ void CubismUserModelExtend::PreloadMotio - csmSizeInt size; - buffer = CreateBuffer(path.GetRawString(), &size); - // モーションデータの読み込み -- CubismMotion* tmpMotion = static_cast(LoadMotion(buffer, size, name.GetRawString(), NULL, NULL, _modelJson, group, i)); -+ CubismMotion* tmpMotion = static_cast(LoadMotion(buffer, size, name.GetRawString())); - -- if (tmpMotion) -+ // フェードインの時間を取得 -+ csmFloat32 fadeTime = _modelJson->GetMotionFadeInTimeValue(group, i); -+ if (fadeTime >= 0.0f) - { -- if (_motions[name]) -- { -- // インスタンスを破棄 -- ACubismMotion::Delete(_motions[name]); -- } -- _motions[name] = tmpMotion; -+ tmpMotion->SetFadeInTime(fadeTime); -+ } -+ -+ // フェードアウトの時間を取得 -+ fadeTime = _modelJson->GetMotionFadeOutTimeValue(group, i); -+ if (fadeTime >= 0.0f) -+ { -+ tmpMotion->SetFadeOutTime(fadeTime); -+ } -+ -+ if (_motions[name]) -+ { -+ // インスタンスを破棄 -+ ACubismMotion::Delete(_motions[name]); - } -+ _motions[name] = tmpMotion; - - DeleteBuffer(buffer, path.GetRawString()); - } -@@ -254,9 +262,10 @@ void CubismUserModelExtend::ReleaseModel - * @param[in] group モーショングループ名 - * @param[in] no グループ内の番号 - * @param[in] priority 優先度 -+* @param[in] onFinishedMotionHandler モーション再生終了時に呼び出されるコールバック関数。NULLの場合、呼び出されない。 - * @return 開始したモーションの識別番号を返す。個別のモーションが終了したか否かを判定するIsFinished()の引数で使用する。開始できない時は「-1」 - */ --Csm::CubismMotionQueueEntryHandle CubismUserModelExtend::StartMotion(const Csm::csmChar* group, Csm::csmInt32 no, Csm::csmInt32 priority) -+Csm::CubismMotionQueueEntryHandle CubismUserModelExtend::StartMotion(const Csm::csmChar* group, Csm::csmInt32 no, Csm::csmInt32 priority, Csm::ACubismMotion::FinishedMotionCallback onFinishedMotionHandler) - { - // モーション数が取得出来なかった、もしくは0の時 - if (!(_modelJson->GetMotionCount(group))) -@@ -292,16 +301,30 @@ Csm::CubismMotionQueueEntryHandle Cubism - csmSizeInt size; - buffer = CreateBuffer(path.GetRawString(), &size); - // 一番先頭のモーションを読み込む -- motion = static_cast(LoadMotion(buffer, size, NULL, NULL, NULL, _modelJson, group, no)); -+ motion = static_cast(LoadMotion(buffer, size, NULL, onFinishedMotionHandler)); -+ -+ csmFloat32 fadeTime = _modelJson->GetMotionFadeInTimeValue(group, no); -+ if (fadeTime >= 0.0f) -+ { -+ motion->SetFadeInTime(fadeTime); -+ } - -- if (motion) -+ fadeTime = _modelJson->GetMotionFadeOutTimeValue(group, no); -+ if (fadeTime >= 0.0f) - { -- // 終了時にメモリから削除 -- autoDelete = true; -+ motion->SetFadeOutTime(fadeTime); - } - -+ // 終了時にメモリから削除 -+ autoDelete = true; -+ - DeleteBuffer(buffer, path.GetRawString()); - } -+ else -+ { -+ // モーションの再生終了コールバックを登録 -+ motion->SetFinishedMotionHandler(onFinishedMotionHandler); -+ } - - // 優先度を設定してモーションを始める - return _motionManager->StartMotionPriority(motion, autoDelete, priority); -diff -pruN --exclude build ./demo_clean/src/CubismUserModelExtend.hpp ./demo_dev/src/CubismUserModelExtend.hpp ---- ./demo_clean/src/CubismUserModelExtend.hpp 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/CubismUserModelExtend.hpp 2024-03-28 18:43:36.377973713 +0000 -@@ -59,9 +59,10 @@ private: - * @param[in] group モーショングループ名 - * @param[in] no グループ内の番号 - * @param[in] priority 優先度 -+ * @param[in] onFinishedMotionHandler モーション再生終了時に呼び出されるコールバック関数。NULLの場合、呼び出されない。 - * @return 開始したモーションの識別番号を返す。個別のモーションが終了したか否かを判定するIsFinished()の引数で使用する。開始できない時は「-1」 - */ -- Csm::CubismMotionQueueEntryHandle StartMotion(const Csm::csmChar* group, Csm::csmInt32 no, Csm::csmInt32 priority); -+ Csm::CubismMotionQueueEntryHandle StartMotion(const Csm::csmChar* group, Csm::csmInt32 no, Csm::csmInt32 priority, Csm::ACubismMotion::FinishedMotionCallback onFinishedMotionHandler = NULL); - - /** - * @brief 解放 diff -pruN --exclude build ./demo_clean/src/LAppDefine.cpp ./demo_dev/src/LAppDefine.cpp ---- ./demo_clean/src/LAppDefine.cpp 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/LAppDefine.cpp 2024-03-28 18:43:36.377973713 +0000 -@@ -37,14 +37,19 @@ namespace LAppDefine { - // 終了ボタン - const csmChar* PowerImageName = "close.png"; - -- // シェーダー相対パス -- const csmChar* ShaderPath = "SampleShaders/"; -- // 頂点シェーダー -- const csmChar* VertShaderName = "VertSprite.vert"; -- // フラグメントシェーダー -- const csmChar* FragShaderName = "FragSprite.frag"; -- - // モデル定義------------------------------------------ -+ // モデルを配置したディレクトリ名の配列 -+ // ディレクトリ名とmodel3.jsonの名前を一致させておくこと -+ const csmChar* ModelDir[] = { -+ "Haru", -+ "Hiyori", -+ "Mark", -+ "Natori", -+ "Rice", -+ "Mao" -+ }; -+ const csmInt32 ModelDirSize = sizeof(ModelDir) / sizeof(const csmChar*); -+ - // 外部定義ファイル(json)と合わせる - const csmChar* MotionGroupIdle = "Idle"; // アイドリング - const csmChar* MotionGroupTapBody = "TapBody"; // 体をタップしたとき -@@ -60,11 +65,11 @@ namespace LAppDefine { +--- ./demo_clean/src/LAppDefine.cpp 2025-05-30 00:59:58.252401066 +0100 ++++ ./demo_dev/src/LAppDefine.cpp 2025-05-30 01:07:49.665920483 +0100 +@@ -60,11 +60,11 @@ namespace LAppDefine { const csmInt32 PriorityForce = 3; // デバッグ用ログの表示オプション @@ -356,36 +118,10 @@ diff -pruN --exclude build ./demo_clean/src/LAppDefine.cpp ./demo_dev/src/LAppDe // デフォルトのレンダーターゲットサイズ const csmInt32 RenderTargetWidth = 1900; -diff -pruN --exclude build ./demo_clean/src/LAppDefine.hpp ./demo_dev/src/LAppDefine.hpp ---- ./demo_clean/src/LAppDefine.hpp 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/LAppDefine.hpp 2024-03-28 18:43:36.377973713 +0000 -@@ -36,11 +36,10 @@ namespace LAppDefine { - extern const csmChar* GearImageName; ///< 歯車画像ファイル - extern const csmChar* PowerImageName; ///< 終了ボタン画像ファイル - -- extern const csmChar* ShaderPath; ///< シェーダーパス -- extern const csmChar* VertShaderName; ///< 頂点シェーダー -- extern const csmChar* FragShaderName; ///< フラグメントシェーダー -- - // モデル定義-------------------------------------------- -+ extern const csmChar* ModelDir[]; ///< モデルを配置したディレクトリ名の配列. ディレクトリ名とmodel3.jsonの名前を一致させておく. -+ extern const csmInt32 ModelDirSize; ///< モデルディレクトリ配列のサイズ -+ - // 外部定義ファイル(json)と合わせる - extern const csmChar* MotionGroupIdle; ///< アイドリング時に再生するモーションのリスト - extern const csmChar* MotionGroupTapBody; ///< 体をタップした時に再生するモーションのリスト diff -pruN --exclude build ./demo_clean/src/LAppDelegate.cpp ./demo_dev/src/LAppDelegate.cpp ---- ./demo_clean/src/LAppDelegate.cpp 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/LAppDelegate.cpp 2024-03-28 18:43:36.381973781 +0000 -@@ -9,7 +9,6 @@ - #include - #include - #include --#include - #include - #include - #include "LAppView.hpp" -@@ -46,11 +45,12 @@ void LAppDelegate::ReleaseInstance() +--- ./demo_clean/src/LAppDelegate.cpp 2025-05-30 00:59:58.252401066 +0100 ++++ ./demo_dev/src/LAppDelegate.cpp 2025-05-30 01:09:31.843395630 +0100 +@@ -46,7 +46,8 @@ void LAppDelegate::ReleaseInstance() s_instance = NULL; } @@ -395,19 +131,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppDelegate.cpp ./demo_dev/src/LApp { if (DebugLogEnable) { -- LAppPal::PrintLogLn("START"); -+ LAppPal::PrintLog("START"); - } - - // GLFWの初期化 -@@ -58,18 +58,24 @@ bool LAppDelegate::Initialize() - { - if (DebugLogEnable) - { -- LAppPal::PrintLogLn("Can't initilize GLFW"); -+ LAppPal::PrintLog("Can't initilize GLFW"); - } - return GL_FALSE; +@@ -64,7 +65,13 @@ bool LAppDelegate::Initialize() } // Windowの生成_ @@ -422,24 +146,9 @@ diff -pruN --exclude build ./demo_clean/src/LAppDelegate.cpp ./demo_dev/src/LApp if (_window == NULL) { if (DebugLogEnable) - { -- LAppPal::PrintLogLn("Can't create GLFW window."); -+ LAppPal::PrintLog("Can't create GLFW window."); - } - glfwTerminate(); - return GL_FALSE; -@@ -82,7 +88,7 @@ bool LAppDelegate::Initialize() - if (glewInit() != GLEW_OK) { - if (DebugLogEnable) - { -- LAppPal::PrintLogLn("Can't initilize glew."); -+ LAppPal::PrintLog("Can't initilize glew."); - } - glfwTerminate(); - return GL_FALSE; -@@ -96,27 +102,22 @@ bool LAppDelegate::Initialize() +@@ -96,10 +103,6 @@ bool LAppDelegate::Initialize() glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - //コールバック関数の登録 - glfwSetMouseButtonCallback(_window, EventHandler::OnMouseCallBack); @@ -448,162 +157,9 @@ diff -pruN --exclude build ./demo_clean/src/LAppDelegate.cpp ./demo_dev/src/LApp // ウィンドウサイズ記憶 int width, height; glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &width, &height); - _windowWidth = width; - _windowHeight = height; -- glViewport(0, 0, _windowWidth, _windowHeight); -+ -+ //AppViewの初期化 -+ _view->Initialize(); - - // Cubism3の初期化 - InitializeCubism(); - -- SetExecuteAbsolutePath(); -- - //load model - LAppLive2DManager::GetInstance(); - -- //AppViewの初期化 -- _view->Initialize(); -+ //load sprite - _view->InitializeSprite(); - - return GL_TRUE; -@@ -154,7 +155,6 @@ void LAppDelegate::Run() - _windowWidth = width; - _windowHeight = height; - } -- glViewport(0, 0, _windowWidth, _windowHeight); - - // 時間更新 - LAppPal::UpdateTime(); -@@ -189,7 +189,7 @@ LAppDelegate::LAppDelegate(): - _windowWidth(0), - _windowHeight(0) - { -- _executeAbsolutePath = ""; -+ _rootDirectory = ""; - _view = new LAppView(); - _textureManager = new LAppTextureManager(); - } -@@ -215,59 +215,66 @@ void LAppDelegate::InitializeCubism() - LAppPal::UpdateTime(); - } - --void LAppDelegate::OnMouseCallBack(GLFWwindow* window, int button, int action, int modify) -+GLuint LAppDelegate::CreateShader() - { -- if (_view == NULL) -- { -- return; -- } -- if (GLFW_MOUSE_BUTTON_LEFT != button) -- { -- return; -- } -+ //バーテックスシェーダのコンパイル -+ GLuint vertexShaderId = glCreateShader(GL_VERTEX_SHADER); -+ const char* vertexShader = -+ "#version 120\n" -+ "attribute vec3 position;" -+ "attribute vec2 uv;" -+ "varying vec2 vuv;" -+ "void main(void){" -+ " gl_Position = vec4(position, 1.0);" -+ " vuv = uv;" -+ "}"; -+ glShaderSource(vertexShaderId, 1, &vertexShader, NULL); -+ glCompileShader(vertexShaderId); -+ -+ //フラグメントシェーダのコンパイル -+ GLuint fragmentShaderId = glCreateShader(GL_FRAGMENT_SHADER); -+ const char* fragmentShader = -+ "#version 120\n" -+ "varying vec2 vuv;" -+ "uniform sampler2D texture;" -+ "uniform vec4 baseColor;" -+ "void main(void){" -+ " gl_FragColor = texture2D(texture, vuv) * baseColor;" -+ "}"; -+ glShaderSource(fragmentShaderId, 1, &fragmentShader, NULL); -+ glCompileShader(fragmentShaderId); -+ -+ //プログラムオブジェクトの作成 -+ GLuint programId = glCreateProgram(); -+ glAttachShader(programId, vertexShaderId); -+ glAttachShader(programId, fragmentShaderId); -+ -+ // リンク -+ glLinkProgram(programId); -+ -+ glUseProgram(programId); -+ -+ return programId; -+} -+ -+void LAppDelegate::SetRootDirectory(std::string rootDir) -+{ -+ this->_rootDirectory = rootDir + "/"; -+} -+ -+Csm::csmVector LAppDelegate::Split(const std::string& baseString, char delimiter) -+{ -+ Csm::csmVector elems; -+ stringstream ss(baseString); -+ string item; - -- if (GLFW_PRESS == action) -+ while(getline(ss, item, delimiter)) - { -- _captured = true; -- _view->OnTouchesBegan(_mouseX, _mouseY); -- } -- else if (GLFW_RELEASE == action) -- { -- if (_captured) -+ if(!item.empty()) - { -- _captured = false; -- _view->OnTouchesEnded(_mouseX, _mouseY); -+ elems.PushBack(item); - } - } --} -- --void LAppDelegate::OnMouseCallBack(GLFWwindow* window, double x, double y) --{ -- _mouseX = static_cast(x); -- _mouseY = static_cast(y); -- -- if (!_captured) -- { -- return; -- } -- if (_view == NULL) -- { -- return; -- } -- -- _view->OnTouchesMoved(_mouseX, _mouseY); --} -- --void LAppDelegate::SetExecuteAbsolutePath() --{ -- char path[1024]; -- ssize_t len = readlink("/proc/self/exe", path, 1024 - 1); -- -- if (len != -1) -- { -- path[len] = '\0'; -- } - -- this->_executeAbsolutePath = dirname(path); -- this->_executeAbsolutePath += "/"; -+ return elems; - } diff -pruN --exclude build ./demo_clean/src/LAppDelegate.hpp ./demo_dev/src/LAppDelegate.hpp ---- ./demo_clean/src/LAppDelegate.hpp 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/LAppDelegate.hpp 2024-03-28 18:43:36.381973781 +0000 +--- ./demo_clean/src/LAppDelegate.hpp 2025-05-30 00:59:58.252401066 +0100 ++++ ./demo_dev/src/LAppDelegate.hpp 2025-05-30 01:10:00.192935412 +0100 @@ -40,7 +40,8 @@ public: /** * @brief APPに必要なものを初期化する。 @@ -614,99 +170,9 @@ diff -pruN --exclude build ./demo_clean/src/LAppDelegate.hpp ./demo_dev/src/LApp /** * @brief 解放する。 -@@ -53,23 +54,9 @@ public: - void Run(); - - /** -- * @brief OpenGL用 glfwSetMouseButtonCallback用関数。 -- * -- * @param[in] window コールバックを呼んだWindow情報 -- * @param[in] button ボタン種類 -- * @param[in] action 実行結果 -- * @param[in] modify -- */ -- void OnMouseCallBack(GLFWwindow* window, int button, int action, int modify); -- -- /** -- * @brief OpenGL用 glfwSetCursorPosCallback用関数。 -- * -- * @param[in] window コールバックを呼んだWindow情報 -- * @param[in] x x座標 -- * @param[in] y x座標 -+ * @brief シェーダーを登録する。 - */ -- void OnMouseCallBack(GLFWwindow* window, double x, double y); -+ GLuint CreateShader(); - - /** - * @brief Window情報を取得する。 -@@ -92,14 +79,16 @@ public: - void AppEnd() { _isEnd = true; } - - /** -- * @brief アプリケーションの実行パスを設定する。 -+ * @brief ルートディレクトリを設定する。 -+ * -+ * @param[in] rootDir : The root directory to set to. - */ -- void SetExecuteAbsolutePath(); -+ void SetRootDirectory(std::string rootDir); - - /** -- * @brief アプリケーションの実行パスを取得する。 -+ * @brief ルートディレクトリを取得する。 - */ -- std::string GetExecuteAbsolutePath(){ return _executeAbsolutePath;} -+ std::string GetRootDirectory(){ return _rootDirectory;} - - /** - * @brief テクスチャマネージャーを取得する。 -@@ -122,6 +111,11 @@ private: - */ - void InitializeCubism(); - -+ /** -+ * @brief 文字列を指定の文字で切り分ける -+ */ -+ Csm::csmVector Split(const std::string& baseString, char delim); -+ - LAppAllocator _cubismAllocator; ///< Cubism3 Allocator - Csm::CubismFramework::Option _cubismOption; ///< Cubism3 Option - GLFWwindow* _window; ///< OpenGL ウィンドウ -@@ -131,29 +125,8 @@ private: - float _mouseY; ///< マウスY座標 - bool _isEnd; ///< APP終了しているか - LAppTextureManager* _textureManager; ///< テクスチャマネージャー -- std::string _executeAbsolutePath; ///< アプリケーションの実行パス -+ std::string _rootDirectory; ///< ルートディレクトリ - - int _windowWidth; ///< Initialize関数で設定したウィンドウ幅 - int _windowHeight; ///< Initialize関数で設定したウィンドウ高さ - }; -- --class EventHandler --{ --public: -- /** -- * @brief glfwSetMouseButtonCallback用コールバック関数。 -- */ -- static void OnMouseCallBack(GLFWwindow* window, int button, int action, int modify) -- { -- LAppDelegate::GetInstance()->OnMouseCallBack(window, button, action, modify); -- } -- -- /** -- * @brief glfwSetCursorPosCallback用コールバック関数。 -- */ -- static void OnMouseCallBack(GLFWwindow* window, double x, double y) -- { -- LAppDelegate::GetInstance()->OnMouseCallBack(window, x, y); -- } -- --}; diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src/LAppLive2DManager.cpp ---- ./demo_clean/src/LAppLive2DManager.cpp 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/LAppLive2DManager.cpp 2024-03-28 18:43:36.381973781 +0000 +--- ./demo_clean/src/LAppLive2DManager.cpp 2025-05-30 00:59:58.252401066 +0100 ++++ ./demo_dev/src/LAppLive2DManager.cpp 2025-05-30 01:12:18.865322293 +0100 @@ -6,13 +6,7 @@ */ @@ -722,34 +188,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src #include #include #include -@@ -25,24 +19,14 @@ - - using namespace Csm; - using namespace LAppDefine; -+using namespace std; - - namespace { - LAppLive2DManager* s_instance = NULL; - -- void BeganMotion(ACubismMotion* self) -- { -- LAppPal::PrintLogLn("Motion began: %x", self); -- } -- - void FinishedMotion(ACubismMotion* self) - { -- LAppPal::PrintLogLn("Motion Finished: %x", self); -- } -- -- int CompareCsmString(const void* a, const void* b) -- { -- return strcmp(reinterpret_cast(a)->GetRawString(), -- reinterpret_cast(b)->GetRawString()); -+ LAppPal::PrintLog("Motion Finished: %x", self); - } - } - -@@ -68,18 +52,16 @@ void LAppLive2DManager::ReleaseInstance( +@@ -68,12 +62,11 @@ void LAppLive2DManager::ReleaseInstance( LAppLive2DManager::LAppLive2DManager() : _viewMatrix(NULL) @@ -765,13 +204,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src } LAppLive2DManager::~LAppLive2DManager() - { - ReleaseAllModel(); -- delete _viewMatrix; - } - - void LAppLive2DManager::ReleaseAllModel() -@@ -92,60 +74,6 @@ void LAppLive2DManager::ReleaseAllModel( +@@ -92,60 +85,6 @@ void LAppLive2DManager::ReleaseAllModel( _models.Clear(); } @@ -832,12 +265,10 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src LAppModel* LAppLive2DManager::GetModel(csmUint32 no) const { if (no < _models.GetSize()) -@@ -170,27 +98,7 @@ void LAppLive2DManager::OnTap(csmFloat32 - { - if (DebugLogEnable) +@@ -172,26 +111,6 @@ void LAppLive2DManager::OnTap(csmFloat32 { -- LAppPal::PrintLogLn("[APP]tap point: {x:%.2f y:%.2f}", x, y); -- } + LAppPal::PrintLogLn("[APP]tap point: {x:%.2f y:%.2f}", x, y); + } - - for (csmUint32 i = 0; i < _models.GetSize(); i++) - { @@ -857,29 +288,11 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src - } - _models[i]->StartRandomMotion(MotionGroupTapBody, PriorityNormal, FinishedMotion, BeganMotion); - } -+ LAppPal::PrintLog("[APP]tap point: {x:%.2f y:%.2f}", x, y); - } +- } } -@@ -199,15 +107,15 @@ 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() == NULL) - { -- LAppPal::PrintLogLn("Failed to model->GetModel()."); -+ LAppPal::PrintLog("Failed to model->GetModel()."); - continue; - } - -@@ -215,12 +123,15 @@ void LAppLive2DManager::OnUpdate() const + void LAppLive2DManager::OnUpdate() const +@@ -215,12 +134,15 @@ void LAppLive2DManager::OnUpdate() const { // 横に長いモデルを縦長ウィンドウに表示する際モデルの横サイズでscaleを算出する model->GetModelMatrix()->SetWidth(2.0f); @@ -897,19 +310,19 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src // 必要があればここで乗算 if (_viewMatrix != NULL) -@@ -237,37 +148,15 @@ void LAppLive2DManager::OnUpdate() const +@@ -237,37 +159,15 @@ void LAppLive2DManager::OnUpdate() const } } -void LAppLive2DManager::NextScene() --{ ++void LAppLive2DManager::SetModel(std::string modelName, bool useOldParamId) + { - csmInt32 no = (_sceneIndex + 1) % GetModelDirSize(); - ChangeScene(no); -} - -void LAppLive2DManager::ChangeScene(Csm::csmInt32 index) -+void LAppLive2DManager::SetModel(std::string modelName, bool useOldParamId) - { +-{ - _sceneIndex = index; - if (DebugLogEnable) - { @@ -928,7 +341,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src - modelPath.Append(1, '/'); - - csmString modelJsonName(model); -+ std::string modelPath = LAppDelegate::GetInstance()->GetRootDirectory() + ResourcesPath + modelName + "/"; ++ std::string modelPath = LAppDelegate::GetInstance()->GetExecuteAbsolutePath() + ResourcesPath + modelName + "/"; + std::string modelJsonName = modelName; modelJsonName += ".model3.json"; @@ -940,7 +353,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src /* * モデル半透明表示を行うサンプルを提示する。 -@@ -288,12 +177,12 @@ void LAppLive2DManager::ChangeScene(Csm: +@@ -288,8 +188,8 @@ void LAppLive2DManager::ChangeScene(Csm: #if defined(USE_RENDER_TARGET) || defined(USE_MODEL_RENDER_TARGET) // モデル個別にαを付けるサンプルとして、もう1体モデルを作成し、少し位置をずらす @@ -951,12 +364,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src _models[1]->GetModelMatrix()->TranslateX(0.2f); #endif -- float clearColor[3] = { 0.0f, 0.0f, 0.0f }; -+ float clearColor[3] = { 1.0f, 1.0f, 1.0f }; - - LAppDelegate::GetInstance()->GetView()->SwitchRenderingTarget(useRenderTarget); - -@@ -317,3 +206,20 @@ void LAppLive2DManager::SetViewMatrix(Cu +@@ -317,3 +217,20 @@ void LAppLive2DManager::SetViewMatrix(Cu _viewMatrix->GetArray()[i] = m->GetArray()[i]; } } @@ -978,8 +386,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 ---- ./demo_clean/src/LAppLive2DManager.hpp 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/LAppLive2DManager.hpp 2024-03-28 18:43:36.381973781 +0000 +--- ./demo_clean/src/LAppLive2DManager.hpp 2025-05-30 00:59:58.256401196 +0100 ++++ ./demo_dev/src/LAppLive2DManager.hpp 2025-05-30 01:12:54.056756547 +0100 @@ -6,12 +6,15 @@ */ #pragma once @@ -1071,15 +479,11 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.hpp ./demo_dev/src private: /** * @brief コンストラクタ -@@ -123,9 +124,10 @@ private: - */ - virtual ~LAppLive2DManager(); +@@ -125,7 +126,8 @@ private: -- Csm::CubismMatrix44* _viewMatrix; ///< モデル描画に用いるView行列 -- Csm::csmVector _models; ///< モデルインスタンスのコンテナ + Csm::CubismMatrix44* _viewMatrix; ///< モデル描画に用いるView行列 + Csm::csmVector _models; ///< モデルインスタンスのコンテナ - Csm::csmInt32 _sceneIndex; ///< 表示するシーンのインデックス値 -+ Csm::CubismMatrix44* _viewMatrix; ///< モデル描画に用いるView行列 -+ Csm::csmVector _models; ///< モデルインスタンスのコンテナ - Csm::csmVector _modelDir; ///< モデルディレクトリ名のコンテナ + float _projScaleFactor; @@ -1087,9 +491,9 @@ 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 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/LAppModel.cpp 2024-03-28 18:44:22.822767401 +0000 -@@ -21,6 +21,10 @@ +--- ./demo_clean/src/LAppModel.cpp 2025-05-30 00:59:58.256401196 +0100 ++++ ./demo_dev/src/LAppModel.cpp 2025-05-30 01:17:12.780545257 +0100 +@@ -21,26 +21,32 @@ #include "LAppTextureManager.hpp" #include "LAppDelegate.hpp" @@ -1100,29 +504,10 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod using namespace Live2D::Cubism::Framework; using namespace Live2D::Cubism::Framework::DefaultParameterId; using namespace LAppDefine; -@@ -30,7 +34,7 @@ namespace { - { - if (DebugLogEnable) - { -- LAppPal::PrintLogLn("[APP]create buffer: %s ", path); -+ LAppPal::PrintLog("[APP]create buffer: %s ", path); - } - return LAppPal::LoadFileAsBytes(path, size); - } -@@ -39,28 +43,30 @@ namespace { - { - if (DebugLogEnable) - { -- LAppPal::PrintLogLn("[APP]delete buffer: %s", path); -+ LAppPal::PrintLog("[APP]delete buffer: %s", path); - } - LAppPal::ReleaseBytes(buffer); - } - } -LAppModel::LAppModel() +LAppModel::LAppModel(bool useOldParamId) - : CubismUserModel() + : LAppModel_Common() , _modelSetting(NULL) , _userTimeSeconds(0.0f) + , _tracker(nullptr) @@ -1148,58 +533,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod } LAppModel::~LAppModel() -@@ -84,7 +90,7 @@ void LAppModel::LoadAssets(const csmChar - - if (_debugMode) - { -- LAppPal::PrintLogLn("[APP]load model setting: %s", fileName); -+ LAppPal::PrintLog("[APP]load model setting: %s", fileName); - } - - csmSizeInt size; -@@ -96,12 +102,6 @@ void LAppModel::LoadAssets(const csmChar - - SetupModel(setting); - -- if (_model == NULL) -- { -- LAppPal::PrintLogLn("Failed to LoadAssets()."); -- return; -- } -- - CreateRenderer(); - - SetupTextures(); -@@ -126,7 +126,7 @@ void LAppModel::SetupModel(ICubismModelS - - if (_debugMode) - { -- LAppPal::PrintLogLn("[APP]create model: %s", setting->GetModelFileName()); -+ LAppPal::PrintLog("[APP]create model: %s", setting->GetModelFileName()); - } - - buffer = CreateBuffer(path.GetRawString(), &size); -@@ -147,15 +147,12 @@ void LAppModel::SetupModel(ICubismModelS - buffer = CreateBuffer(path.GetRawString(), &size); - ACubismMotion* motion = LoadExpression(buffer, size, name.GetRawString()); - -- if (motion) -+ if (_expressions[name] != NULL) - { -- if (_expressions[name] != NULL) -- { -- ACubismMotion::Delete(_expressions[name]); -- _expressions[name] = NULL; -- } -- _expressions[name] = motion; -+ ACubismMotion::Delete(_expressions[name]); -+ _expressions[name] = NULL; - } -+ _expressions[name] = motion; - - DeleteBuffer(buffer, path.GetRawString()); - } -@@ -199,7 +196,7 @@ void LAppModel::SetupModel(ICubismModelS +@@ -179,7 +185,7 @@ void LAppModel::SetupModel(ICubismModelS breathParameters.PushBack(CubismBreath::BreathParameterData(_idParamAngleY, 0.0f, 8.0f, 3.5345f, 0.5f)); breathParameters.PushBack(CubismBreath::BreathParameterData(_idParamAngleZ, 0.0f, 10.0f, 5.5345f, 0.5f)); breathParameters.PushBack(CubismBreath::BreathParameterData(_idParamBodyAngleX, 0.0f, 4.0f, 15.5345f, 0.5f)); @@ -1208,62 +542,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod _breath->SetParameters(breathParameters); } -@@ -232,12 +229,6 @@ void LAppModel::SetupModel(ICubismModelS - } - } - -- if (_modelSetting == NULL || _modelMatrix == NULL) -- { -- LAppPal::PrintLogLn("Failed to SetupModel()."); -- return; -- } -- - //Layout - csmMap layout; - _modelSetting->GetLayoutMap(layout); -@@ -270,24 +261,32 @@ void LAppModel::PreloadMotionGroup(const - - if (_debugMode) - { -- LAppPal::PrintLogLn("[APP]load motion: %s => [%s_%d] ", path.GetRawString(), group, i); -+ LAppPal::PrintLog("[APP]load motion: %s => [%s_%d] ", path.GetRawString(), group, i); - } - - csmByte* buffer; - csmSizeInt size; - buffer = CreateBuffer(path.GetRawString(), &size); -- CubismMotion* tmpMotion = static_cast(LoadMotion(buffer, size, name.GetRawString(), NULL, NULL, _modelSetting, group, i)); -+ CubismMotion* tmpMotion = static_cast(LoadMotion(buffer, size, name.GetRawString())); - -- if (tmpMotion) -+ csmFloat32 fadeTime = _modelSetting->GetMotionFadeInTimeValue(group, i); -+ if (fadeTime >= 0.0f) - { -- tmpMotion->SetEffectIds(_eyeBlinkIds, _lipSyncIds); -+ tmpMotion->SetFadeInTime(fadeTime); -+ } - -- if (_motions[name] != NULL) -- { -- ACubismMotion::Delete(_motions[name]); -- } -- _motions[name] = tmpMotion; -+ fadeTime = _modelSetting->GetMotionFadeOutTimeValue(group, i); -+ if (fadeTime >= 0.0f) -+ { -+ tmpMotion->SetFadeOutTime(fadeTime); -+ } -+ tmpMotion->SetEffectIds(_eyeBlinkIds, _lipSyncIds); -+ -+ if (_motions[name] != NULL) -+ { -+ ACubismMotion::Delete(_motions[name]); - } -+ _motions[name] = tmpMotion; - - DeleteBuffer(buffer, path.GetRawString()); - } -@@ -342,84 +341,115 @@ void LAppModel::Update() +@@ -322,86 +328,117 @@ void LAppModel::Update() const csmFloat32 deltaTimeSeconds = LAppPal::GetDeltaTime(); _userTimeSeconds += deltaTimeSeconds; @@ -1408,11 +687,10 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod + } + } + else - { -- _model->AddParameterValue(_lipSyncIds[i], value, 0.8f); ++ { + _model->SetParameterValue(idMan->GetId(_("ParamMouthOpenY")), + params.live2d["ParamMouthOpenY"]); - } ++ } + + for (auto const &entry : params.live2d) + { @@ -1427,70 +705,24 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod + } + + if (params.autoBreath && _breath) -+ { + { +- _model->AddParameterValue(_lipSyncIds[i], value, 0.8f); + // Note: _model->LoadParameters and SaveParameters is needed + // before - see above. + _breath->UpdateParameters(_model, deltaTimeSeconds); -+ } -+ } -+ + } + } + + // 物理演算の設定 + if (_physics != NULL) + { + _physics->Evaluate(_model, deltaTimeSeconds); - } - - // ポーズの設定 -@@ -432,7 +462,7 @@ void LAppModel::Update() - - } - --CubismMotionQueueEntryHandle LAppModel::StartMotion(const csmChar* group, csmInt32 no, csmInt32 priority, ACubismMotion::FinishedMotionCallback onFinishedMotionHandler, ACubismMotion::BeganMotionCallback onBeganMotionHandler) -+CubismMotionQueueEntryHandle LAppModel::StartMotion(const csmChar* group, csmInt32 no, csmInt32 priority, ACubismMotion::FinishedMotionCallback onFinishedMotionHandler) - { - if (priority == PriorityForce) - { -@@ -442,7 +472,7 @@ CubismMotionQueueEntryHandle LAppModel:: - { - if (_debugMode) - { -- LAppPal::PrintLogLn("[APP]can't start motion."); -+ LAppPal::PrintLog("[APP]can't start motion."); - } - return InvalidMotionQueueEntryHandleValue; - } -@@ -462,19 +492,25 @@ CubismMotionQueueEntryHandle LAppModel:: - csmByte* buffer; - csmSizeInt size; - buffer = CreateBuffer(path.GetRawString(), &size); -- motion = static_cast(LoadMotion(buffer, size, NULL, onFinishedMotionHandler, onBeganMotionHandler, _modelSetting, group, no)); -+ motion = static_cast(LoadMotion(buffer, size, NULL, onFinishedMotionHandler)); -+ csmFloat32 fadeTime = _modelSetting->GetMotionFadeInTimeValue(group, no); -+ if (fadeTime >= 0.0f) -+ { -+ motion->SetFadeInTime(fadeTime); -+ } - -- if (motion) -+ fadeTime = _modelSetting->GetMotionFadeOutTimeValue(group, no); -+ if (fadeTime >= 0.0f) - { -- motion->SetEffectIds(_eyeBlinkIds, _lipSyncIds); -- autoDelete = true; // 終了時にメモリから削除 -+ motion->SetFadeOutTime(fadeTime); - } -+ motion->SetEffectIds(_eyeBlinkIds, _lipSyncIds); -+ autoDelete = true; // 終了時にメモリから削除 - - DeleteBuffer(buffer, path.GetRawString()); - } - else ++ } ++ + // ポーズの設定 + if (_pose != NULL) { -- motion->SetBeganMotionHandler(onBeganMotionHandler); - motion->SetFinishedMotionHandler(onFinishedMotionHandler); - } - -@@ -484,17 +520,16 @@ CubismMotionQueueEntryHandle LAppModel:: +@@ -464,7 +501,6 @@ CubismMotionQueueEntryHandle LAppModel:: { csmString path = voice; path = _modelHomeDir + path; @@ -1498,48 +730,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod } if (_debugMode) - { -- LAppPal::PrintLogLn("[APP]start motion: [%s_%d]", group, no); -+ LAppPal::PrintLog("[APP]start motion: [%s_%d]", group, no); - } - return _motionManager->StartMotionPriority(motion, autoDelete, priority); - } - --CubismMotionQueueEntryHandle LAppModel::StartRandomMotion(const csmChar* group, csmInt32 priority, ACubismMotion::FinishedMotionCallback onFinishedMotionHandler, ACubismMotion::BeganMotionCallback onBeganMotionHandler) -+CubismMotionQueueEntryHandle LAppModel::StartRandomMotion(const csmChar* group, csmInt32 priority, ACubismMotion::FinishedMotionCallback onFinishedMotionHandler) - { - if (_modelSetting->GetMotionCount(group) == 0) - { -@@ -503,7 +538,7 @@ CubismMotionQueueEntryHandle LAppModel:: - - csmInt32 no = rand() % _modelSetting->GetMotionCount(group); - -- return StartMotion(group, no, priority, onFinishedMotionHandler, onBeganMotionHandler); -+ return StartMotion(group, no, priority, onFinishedMotionHandler); - } - - void LAppModel::DoDraw() -@@ -554,16 +589,16 @@ void LAppModel::SetExpression(const csmC - ACubismMotion* motion = _expressions[expressionID]; - if (_debugMode) - { -- LAppPal::PrintLogLn("[APP]expression: [%s]", expressionID); -+ LAppPal::PrintLog("[APP]expression: [%s]", expressionID); - } - - if (motion != NULL) - { -- _expressionManager->StartMotion(motion, false); -+ _expressionManager->StartMotionPriority(motion, false, PriorityForce); - } - else - { -- if (_debugMode) LAppPal::PrintLogLn("[APP]expression[%s] is null ", expressionID); -+ if (_debugMode) LAppPal::PrintLog("[APP]expression[%s] is null ", expressionID); - } - } - -@@ -636,3 +671,42 @@ Csm::Rendering::CubismOffscreenSurface_O +@@ -616,3 +652,42 @@ Csm::Rendering::CubismOffscreenSurface_O { return _renderBuffer; } @@ -1583,18 +774,19 @@ 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 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/LAppModel.hpp 2024-03-28 18:43:36.385973850 +0000 -@@ -13,7 +13,7 @@ +--- ./demo_clean/src/LAppModel.hpp 2025-05-30 00:59:58.252401066 +0100 ++++ ./demo_dev/src/LAppModel.hpp 2025-05-30 01:15:06.963872011 +0100 +@@ -12,8 +12,8 @@ #include #include --#include "LAppWavFileHandler.hpp" +-#include "LAppWavFileHandler_Common.hpp" + #include "LAppModel_Common.hpp" +#include "mouse_cursor_tracker.h" /** * @brief ユーザーが実際に使用するモデルの実装クラス
-@@ -25,8 +25,11 @@ class LAppModel : public Csm::CubismUser +@@ -25,8 +25,11 @@ class LAppModel : public LAppModel_Commo public: /** * @brief コンストラクタ @@ -1607,31 +799,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.hpp ./demo_dev/src/LAppMod /** * @brief デストラクタ -@@ -66,10 +69,9 @@ public: - * @param[in] no グループ内の番号 - * @param[in] priority 優先度 - * @param[in] onFinishedMotionHandler モーション再生終了時に呼び出されるコールバック関数。NULLの場合、呼び出されない。 -- * @param[in] onBeganMotionHandler モーション再生開始時に呼び出されるコールバック関数。NULLの場合、呼び出されない。 - * @return 開始したモーションの識別番号を返す。個別のモーションが終了したか否かを判定するIsFinished()の引数で使用する。開始できない時は「-1」 - */ -- Csm::CubismMotionQueueEntryHandle StartMotion(const Csm::csmChar* group, Csm::csmInt32 no, Csm::csmInt32 priority, Csm::ACubismMotion::FinishedMotionCallback onFinishedMotionHandler = NULL, Csm::ACubismMotion::BeganMotionCallback onBeganMotionHandler = NULL); -+ Csm::CubismMotionQueueEntryHandle StartMotion(const Csm::csmChar* group, Csm::csmInt32 no, Csm::csmInt32 priority, Csm::ACubismMotion::FinishedMotionCallback onFinishedMotionHandler = NULL); - - /** - * @brief ランダムに選ばれたモーションの再生を開始する。 -@@ -77,10 +79,9 @@ public: - * @param[in] group モーショングループ名 - * @param[in] priority 優先度 - * @param[in] onFinishedMotionHandler モーション再生終了時に呼び出されるコールバック関数。NULLの場合、呼び出されない。 -- * @param[in] onBeganMotionHandler モーション再生開始時に呼び出されるコールバック関数。NULLの場合、呼び出されない。 - * @return 開始したモーションの識別番号を返す。個別のモーションが終了したか否かを判定するIsFinished()の引数で使用する。開始できない時は「-1」 - */ -- Csm::CubismMotionQueueEntryHandle StartRandomMotion(const Csm::csmChar* group, Csm::csmInt32 priority, Csm::ACubismMotion::FinishedMotionCallback onFinishedMotionHandler = NULL, Csm::ACubismMotion::BeganMotionCallback onBeganMotionHandler = NULL); -+ Csm::CubismMotionQueueEntryHandle StartRandomMotion(const Csm::csmChar* group, Csm::csmInt32 priority, Csm::ACubismMotion::FinishedMotionCallback onFinishedMotionHandler = NULL); - - /** - * @brief 引数で指定した表情モーションをセットする -@@ -116,6 +117,15 @@ public: +@@ -116,6 +119,15 @@ public: */ Csm::Rendering::CubismOffscreenSurface_OpenGLES2& GetRenderBuffer(); @@ -1647,7 +815,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.hpp ./demo_dev/src/LAppMod protected: /** * @brief モデルを描画する処理。モデルを描画する空間のView-Projection行列を渡す。 -@@ -169,6 +179,17 @@ private: +@@ -169,6 +181,17 @@ private: */ void ReleaseExpressions(); @@ -1665,313 +833,20 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.hpp ./demo_dev/src/LAppMod Csm::ICubismModelSetting* _modelSetting; ///< モデルセッティング情報 Csm::csmString _modelHomeDir; ///< モデルセッティングが置かれたディレクトリ Csm::csmFloat32 _userTimeSeconds; ///< デルタ時間の積算値[秒] -@@ -185,7 +206,10 @@ private: +@@ -185,7 +208,7 @@ private: const Csm::CubismId* _idParamEyeBallX; ///< パラメータID: ParamEyeBallX const Csm::CubismId* _idParamEyeBallY; ///< パラメータID: ParamEyeBallXY -- LAppWavFileHandler _wavFileHandler; ///< wavファイルハンドラ +- LAppWavFileHandler_Common _wavFileHandler; ///< wavファイルハンドラ - Csm::Rendering::CubismOffscreenSurface_OpenGLES2 _renderBuffer; ///< フレームバッファ以外の描画先 + + MouseCursorTracker *_tracker; }; -+ -+ -+ -diff -pruN --exclude build ./demo_clean/src/LAppPal.cpp ./demo_dev/src/LAppPal.cpp ---- ./demo_clean/src/LAppPal.cpp 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/LAppPal.cpp 2024-03-28 18:43:36.385973850 +0000 -@@ -6,6 +6,7 @@ - */ - - #include "LAppPal.hpp" -+#include - #include - #include - #include -@@ -36,37 +37,17 @@ csmByte* LAppPal::LoadFileAsBytes(const - if (stat(path, &statBuf) == 0) - { - size = statBuf.st_size; -- -- if (size == 0) -- { -- if (DebugLogEnable) -- { -- PrintLogLn("Stat succeeded but file size is zero. path:%s", path); -- } -- return NULL; -- } -- } -- else -- { -- if (DebugLogEnable) -- { -- PrintLogLn("Stat failed. errno:%d path:%s", errno, path); -- } -- return NULL; - } - - std::fstream file; -+ char* buf = new char[size]; -+ - file.open(path, std::ios::in | std::ios::binary); - if (!file.is_open()) - { -- if (DebugLogEnable) -- { -- PrintLogLn("File open failed. path:%s", path); -- } -+ throw std::runtime_error("Failed to open file " + filePath); - return NULL; - } -- -- char* buf = new char[size]; - file.read(buf, size); - file.close(); - -@@ -97,17 +78,7 @@ void LAppPal::PrintLog(const csmChar* fo - csmChar buf[256]; - va_start(args, format); - vsnprintf(buf, sizeof(buf), format, args); // 標準出力でレンダリング -- std::cout << buf; -- va_end(args); --} -- --void LAppPal::PrintLogLn(const csmChar* format, ...) --{ -- va_list args; -- csmChar buf[256]; -- va_start(args, format); -- vsnprintf(buf, sizeof(buf), format, args); // 標準出力でレンダリング -- std::cout << buf << std::endl; -+ std::cerr << buf << std::endl; - va_end(args); - } - -@@ -115,8 +86,3 @@ void LAppPal::PrintMessage(const csmChar - { - PrintLog("%s", message); - } -- --void LAppPal::PrintMessageLn(const csmChar* message) --{ -- PrintLogLn("%s", message); --} -diff -pruN --exclude build ./demo_clean/src/LAppPal.hpp ./demo_dev/src/LAppPal.hpp ---- ./demo_clean/src/LAppPal.hpp 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/LAppPal.hpp 2024-03-28 18:43:36.385973850 +0000 -@@ -63,17 +63,6 @@ public: - static void PrintLog(const Csm::csmChar* format, ...); - - /** -- * @brief ログを出力し最後に改行する -- * -- * ログを出力し最後に改行する -- * -- * @param[in] format 書式付文字列 -- * @param[in] ... (可変長引数)文字列 -- * -- */ -- static void PrintLogLn(const Csm::csmChar* format, ...); -- -- /** - * @brief メッセージを出力する - * - * メッセージを出力する -@@ -83,16 +72,6 @@ public: - */ - static void PrintMessage(const Csm::csmChar* message); - -- /** -- * @brief メッセージを出力し最後に改行する -- * -- * メッセージを出力し最後に改行する -- * -- * @param[in] message 文字列 -- * -- */ -- static void PrintMessageLn(const Csm::csmChar* message); -- - private: - static double s_currentFrame; - static double s_lastFrame; -diff -pruN --exclude build ./demo_clean/src/LAppSpriteShader.cpp ./demo_dev/src/LAppSpriteShader.cpp ---- ./demo_clean/src/LAppSpriteShader.cpp 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/LAppSpriteShader.cpp 1970-01-01 01:00:00.000000000 +0100 -@@ -1,107 +0,0 @@ --/** -- * Copyright(c) Live2D Inc. All rights reserved. -- * -- * Use of this source code is governed by the Live2D Open Software license -- * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. -- */ -- --#include "LAppSpriteShader.hpp" -- --#include "LAppDefine.hpp" --#include "LAppLive2DManager.hpp" --#include "LAppPal.hpp" -- --LAppSpriteShader::LAppSpriteShader() --{ -- _programId = CreateShader(); --} -- --LAppSpriteShader::~LAppSpriteShader() --{ -- glDeleteShader(_programId); --} -- --GLuint LAppSpriteShader::GetShaderId() const --{ -- return _programId; --} -- --GLuint LAppSpriteShader::CreateShader() --{ -- // シェーダーのパスの作成 -- Csm::csmString vertShaderFile(LAppDefine::ShaderPath); -- vertShaderFile += LAppDefine::VertShaderName; -- Csm::csmString fragShaderFile(LAppDefine::ShaderPath); -- fragShaderFile += LAppDefine::FragShaderName; -- -- // シェーダーのコンパイル -- GLuint vertexShaderId = CompileShader(vertShaderFile, GL_VERTEX_SHADER); -- GLuint fragmentShaderId = CompileShader(fragShaderFile, GL_FRAGMENT_SHADER); -- -- if (!vertexShaderId || !fragmentShaderId) -- { -- return 0; -- } -- -- //プログラムオブジェクトの作成 -- GLuint programId = glCreateProgram(); -- glAttachShader(programId, vertexShaderId); -- glAttachShader(programId, fragmentShaderId); -- -- // リンク -- glLinkProgram(programId); -- -- glUseProgram(programId); -- -- // 不要になったシェーダーオブジェクトの削除 -- glDeleteShader(vertexShaderId); -- glDeleteShader(fragmentShaderId); -- -- return programId; --} -- --bool LAppSpriteShader::CheckShader(GLuint shaderId) --{ -- GLint status; -- GLint logLength; -- glGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &logLength); -- if (logLength > 0) -- { -- GLchar* log = reinterpret_cast(CSM_MALLOC(logLength)); -- glGetShaderInfoLog(shaderId, logLength, &logLength, log); -- CubismLogError("Shader compile log: %s", log); -- CSM_FREE(log); -- } -- -- glGetShaderiv(shaderId, GL_COMPILE_STATUS, &status); -- if (status == GL_FALSE) -- { -- glDeleteShader(shaderId); -- return false; -- } -- -- return true; --} -- --GLuint LAppSpriteShader::CompileShader(Csm::csmString filename, GLenum shaderType) --{ -- // ファイル読み込み -- Csm::csmSizeInt bufferSize = 0; -- const char* shaderString = reinterpret_cast(LAppPal::LoadFileAsBytes(filename.GetRawString(), &bufferSize)); -- const GLint glSize = (GLint)bufferSize; -- -- // コンパイル -- GLuint shaderId = glCreateShader(shaderType); -- glShaderSource(shaderId, 1, &shaderString, &glSize); -- glCompileShader(shaderId); -- -- // 読み込んだシェーダー文字列の開放 -- LAppPal::ReleaseBytes(reinterpret_cast(const_cast(shaderString))); -- -- if (!CheckShader(shaderId)) -- { -- return 0; -- } -- -- return shaderId; --} -diff -pruN --exclude build ./demo_clean/src/LAppSpriteShader.hpp ./demo_dev/src/LAppSpriteShader.hpp ---- ./demo_clean/src/LAppSpriteShader.hpp 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/LAppSpriteShader.hpp 1970-01-01 01:00:00.000000000 +0100 -@@ -1,57 +0,0 @@ --/** -- * Copyright(c) Live2D Inc. All rights reserved. -- * -- * Use of this source code is governed by the Live2D Open Software license -- * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. -- */ -- --#pragma once -- --#include --#include --#include --#include "CubismFramework.hpp" -- --/** --* @brief スプライト用のシェーダー設定を保持するクラス --*/ --class LAppSpriteShader --{ --public: -- /** -- * @brief コンストラクタ -- */ -- LAppSpriteShader(); -- -- /** -- * @brief デストラクタ -- */ -- ~LAppSpriteShader(); -- -- /** -- * @brief シェーダーIDを取得する -- */ -- GLuint GetShaderId() const; -- --private: -- /** -- * @brief シェーダーを作成する。 -- */ -- GLuint CreateShader(); -- -- /** -- * @brief CreateShader内部関数 エラーチェック -- */ -- bool CheckShader(GLuint shaderId); -- -- /** -- * @brief シェーダーをコンパイルする -- * コンパイルに失敗した場合には 0 が戻る。 -- * -- * @param[in] filename シェーダーファイル名 -- * @param[in] shaderType 作成するシェーダーの種類 -- */ -- GLuint CompileShader(Csm::csmString filename, GLenum shaderType); -- -- GLuint _programId; ///< シェーダID --}; diff -pruN --exclude build ./demo_clean/src/LAppTextureManager.cpp ./demo_dev/src/LAppTextureManager.cpp ---- ./demo_clean/src/LAppTextureManager.cpp 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/LAppTextureManager.cpp 2024-03-28 18:43:36.385973850 +0000 -@@ -96,11 +96,50 @@ LAppTextureManager::TextureInfo* LAppTex +--- ./demo_clean/src/LAppTextureManager.cpp 2025-05-30 00:59:58.252401066 +0100 ++++ ./demo_dev/src/LAppTextureManager.cpp 2025-05-30 01:18:50.733874528 +0100 +@@ -96,6 +96,46 @@ LAppTextureManager::TextureInfo* LAppTex } @@ -2010,39 +885,18 @@ diff -pruN --exclude build ./demo_clean/src/LAppTextureManager.cpp ./demo_dev/sr + textureInfo->height = height; + textureInfo->id = textureId; + -+ _textures.PushBack(textureInfo); ++ _texturesInfo.PushBack(textureInfo); + + return textureInfo; +} + void LAppTextureManager::ReleaseTextures() { - for (Csm::csmUint32 i = 0; i < _textures.GetSize(); i++) - { -- glDeleteTextures(1, &(_textures[i]->id)); - delete _textures[i]; - } - -@@ -115,7 +154,6 @@ void LAppTextureManager::ReleaseTexture( - { - continue; - } -- glDeleteTextures(1, &(_textures[i]->id)); - delete _textures[i]; - _textures.Remove(i); - break; -@@ -128,7 +166,6 @@ void LAppTextureManager::ReleaseTexture( - { - if (_textures[i]->fileName == fileName) - { -- glDeleteTextures(1, &(_textures[i]->id)); - delete _textures[i]; - _textures.Remove(i); - break; + for (Csm::csmUint32 i = 0; i < _texturesInfo.GetSize(); i++) diff -pruN --exclude build ./demo_clean/src/LAppTextureManager.hpp ./demo_dev/src/LAppTextureManager.hpp ---- ./demo_clean/src/LAppTextureManager.hpp 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/LAppTextureManager.hpp 2024-03-28 18:43:36.385973850 +0000 -@@ -72,6 +72,8 @@ public: +--- ./demo_clean/src/LAppTextureManager.hpp 2025-05-30 00:59:58.252401066 +0100 ++++ ./demo_dev/src/LAppTextureManager.hpp 2025-05-30 01:19:14.566288429 +0100 +@@ -41,6 +41,8 @@ public: */ TextureInfo* CreateTextureFromPngFile(std::string fileName); @@ -2052,63 +906,9 @@ 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 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/LAppView.cpp 2024-03-28 18:44:40.051061624 +0000 -@@ -13,9 +13,7 @@ - #include "LAppLive2DManager.hpp" - #include "LAppTextureManager.hpp" - #include "LAppDefine.hpp" --#include "TouchManager.hpp" - #include "LAppSprite.hpp" --#include "LAppSpriteShader.hpp" - #include "LAppModel.hpp" - - #include -@@ -25,9 +23,8 @@ using namespace std; - using namespace LAppDefine; - - LAppView::LAppView(): -+ _programId(0), - _back(NULL), -- _gear(NULL), -- _power(NULL), - _renderSprite(NULL), - _renderTarget(SelectTarget_None) - { -@@ -35,8 +32,6 @@ LAppView::LAppView(): - _clearColor[1] = 1.0f; - _clearColor[2] = 1.0f; - _clearColor[3] = 0.0f; -- // タッチ関係のイベント管理 -- _touchManager = new TouchManager(); - - // デバイス座標からスクリーン座標に変換するための - _deviceToScreen = new CubismMatrix44(); -@@ -48,15 +43,11 @@ LAppView::LAppView(): - LAppView::~LAppView() - { - _renderBuffer.DestroyOffscreenSurface(); -- delete _spriteShader; - delete _renderSprite; - - delete _viewMatrix; - delete _deviceToScreen; -- delete _touchManager; - delete _back; -- delete _gear; -- delete _power; - } - - void LAppView::Initialize() -@@ -103,17 +94,11 @@ void LAppView::Initialize() - ViewLogicalMaxBottom, - ViewLogicalMaxTop - ); -- -- // シェーダー作成 -- _spriteShader = new LAppSpriteShader(); - } - +--- ./demo_clean/src/LAppView.cpp 2025-05-30 00:59:58.252401066 +0100 ++++ ./demo_dev/src/LAppView.cpp 2025-05-30 01:24:23.734104120 +0100 +@@ -81,9 +81,6 @@ void LAppView::Initialize(int width, int void LAppView::Render() { _back->Render(); @@ -2118,14 +918,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppView.cpp ./demo_dev/src/LAppView LAppLive2DManager* Live2DManager = LAppLive2DManager::GetInstance(); -@@ -149,92 +134,28 @@ void LAppView::Render() - - void LAppView::InitializeSprite() - { -- GLuint programId = _spriteShader->GetShaderId(); -+ _programId = LAppDelegate::GetInstance()->CreateShader(); - - int width, height; +@@ -125,35 +122,17 @@ void LAppView::InitializeSprite() glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &width, &height); LAppTextureManager* textureManager = LAppDelegate::GetInstance()->GetTextureManager(); @@ -2141,8 +934,10 @@ diff -pruN --exclude build ./demo_clean/src/LAppView.cpp ./demo_dev/src/LAppView float y = height * 0.5f; - float fWidth = static_cast(backgroundTexture->width * 2.0f); - float fHeight = static_cast(height) * 0.95f; -- _back = new LAppSprite(x, y, fWidth, fHeight, backgroundTexture->id, programId); -- ++ float fWidth = static_cast(width); ++ float fHeight = static_cast(height); + _back = new LAppSprite(x, y, fWidth, fHeight, backgroundTexture->id, programId); + - imageName = GearImageName; - LAppTextureManager::TextureInfo* gearTexture = textureManager->CreateTextureFromPngFile(resourcesPath + imageName); - @@ -2160,50 +955,15 @@ diff -pruN --exclude build ./demo_clean/src/LAppView.cpp ./demo_dev/src/LAppView - fWidth = static_cast(powerTexture->width); - fHeight = static_cast(powerTexture->height); - _power = new LAppSprite(x, y, fWidth, fHeight, powerTexture->id, programId); -+ float fWidth = static_cast(width); -+ float fHeight = static_cast(height); -+ _back = new LAppSprite(x, y, fWidth, fHeight, backgroundTexture->id, _programId); - +- // 画面全体を覆うサイズ x = width * 0.5f; y = height * 0.5f; -- _renderSprite = new LAppSprite(x, y, static_cast(width), static_cast(height), 0, programId); -- --} -- --void LAppView::OnTouchesBegan(float px, float py) const --{ -- _touchManager->TouchesBegan(px, py); --} -- --void LAppView::OnTouchesMoved(float px, float py) const --{ -- float viewX = this->TransformViewX(_touchManager->GetX()); -- float viewY = this->TransformViewY(_touchManager->GetY()); -- -- _touchManager->TouchesMoved(px, py); -- -- LAppLive2DManager* Live2DManager = LAppLive2DManager::GetInstance(); -- Live2DManager->OnDrag(viewX, viewY); --} -- --void LAppView::OnTouchesEnded(float px, float py) const --{ -- // タッチ終了 -- LAppLive2DManager* live2DManager = LAppLive2DManager::GetInstance(); -- live2DManager->OnDrag(0.0f, 0.0f); -- { +@@ -192,18 +171,6 @@ void LAppView::OnTouchesEnded(float px, + LAppPal::PrintLogLn("[APP]touchesEnded x:%.2f y:%.2f", x, y); + } + live2DManager->OnTap(x, y); - -- // シングルタップ -- float x = _deviceToScreen->TransformX(_touchManager->GetX()); // 論理座標変換した座標を取得。 -- float y = _deviceToScreen->TransformY(_touchManager->GetY()); // 論理座標変換した座標を取得。 -- if (DebugTouchLogEnable) -- { -- LAppPal::PrintLogLn("[APP]touchesEnded x:%.2f y:%.2f", x, y); -- } -- live2DManager->OnTap(x, y); -+ _renderSprite = new LAppSprite(x, y, static_cast(width), static_cast(height), 0, _programId); - - // 歯車にタップしたか - if (_gear->IsHit(px, py)) - { @@ -2215,11 +975,10 @@ diff -pruN --exclude build ./demo_clean/src/LAppView.cpp ./demo_dev/src/LAppView - { - LAppDelegate::GetInstance()->AppEnd(); - } -- } + } } - float LAppView::TransformViewX(float deviceX) const -@@ -378,32 +299,4 @@ void LAppView::ResizeSprite() +@@ -329,32 +296,4 @@ void LAppView::ResizeSprite() _back->ResetRect(x, y, fWidth, fHeight); } } @@ -2252,74 +1011,10 @@ 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 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/LAppView.hpp 2024-03-28 18:43:36.385973850 +0000 -@@ -14,9 +14,7 @@ - #include "CubismFramework.hpp" - #include - --class TouchManager; - class LAppSprite; --class LAppSpriteShader; - class LAppModel; - - /** -@@ -67,30 +65,6 @@ public: - void ResizeSprite(); - - /** -- * @brief タッチされたときに呼ばれる。 -- * -- * @param[in] pointX スクリーンX座標 -- * @param[in] pointY スクリーンY座標 -- */ -- void OnTouchesBegan(float pointX, float pointY) const; -- -- /** -- * @brief タッチしているときにポインタが動いたら呼ばれる。 -- * -- * @param[in] pointX スクリーンX座標 -- * @param[in] pointY スクリーンY座標 -- */ -- void OnTouchesMoved(float pointX, float pointY) const; -- -- /** -- * @brief タッチが終了したら呼ばれる。 -- * -- * @param[in] pointX スクリーンX座標 -- * @param[in] pointY スクリーンY座標 -- */ -- void OnTouchesEnded(float pointX, float pointY) const; -- -- /** - * @brief X座標をView座標に変換する。 - * - * @param[in] deviceX デバイスX座標 -@@ -148,18 +122,14 @@ public: - void SetRenderTargetClearColor(float r, float g, float b); - - private: -- TouchManager* _touchManager; ///< タッチマネージャー - Csm::CubismMatrix44* _deviceToScreen; ///< デバイスからスクリーンへの行列 - Csm::CubismViewMatrix* _viewMatrix; ///< viewMatrix -+ GLuint _programId; ///< シェーダID - LAppSprite* _back; ///< 背景画像 -- LAppSprite* _gear; ///< ギア画像 -- LAppSprite* _power; ///< 電源画像 - - // レンダリング先を別ターゲットにする方式の場合に使用 - LAppSprite* _renderSprite; ///< モードによっては_renderBufferのテクスチャを描画 - Csm::Rendering::CubismOffscreenSurface_OpenGLES2 _renderBuffer; ///< モードによってはCubismモデル結果をこっちにレンダリング - SelectTarget _renderTarget; ///< レンダリング先の選択肢 - float _clearColor[4]; ///< レンダリングターゲットのクリアカラー -- -- LAppSpriteShader* _spriteShader; ///< シェーダー作成委譲クラス - }; diff -pruN --exclude build ./demo_clean/src/main.cpp ./demo_dev/src/main.cpp ---- ./demo_clean/src/main.cpp 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/main.cpp 2024-03-28 18:43:36.389973918 +0000 -@@ -5,18 +5,188 @@ +--- ./demo_clean/src/main.cpp 2025-05-30 00:59:58.252401066 +0100 ++++ ./demo_dev/src/main.cpp 2025-05-30 01:19:44.722858078 +0100 +@@ -5,18 +5,186 @@ * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. */ @@ -2468,8 +1163,6 @@ diff -pruN --exclude build ./demo_clean/src/main.cpp ./demo_dev/src/main.cpp } - LAppDelegate::GetInstance()->Run(); -+ delegate->SetRootDirectory(cmdArgs.rootDir); -+ + LAppLive2DManager *manager = LAppLive2DManager::GetInstance(); + manager->SetModel(cmdArgs.modelName, cmdArgs.oldId); + @@ -2513,133 +1206,3 @@ diff -pruN --exclude build ./demo_clean/src/main.cpp ./demo_dev/src/main.cpp return 0; } - -diff -pruN --exclude build ./demo_clean/src/mainMinimum.cpp ./demo_dev/src/mainMinimum.cpp ---- ./demo_clean/src/mainMinimum.cpp 2025-03-23 03:22:05.213672569 +0000 -+++ ./demo_dev/src/mainMinimum.cpp 2024-03-28 18:43:36.389973918 +0000 -@@ -9,7 +9,6 @@ - - #include - #include --#include - #include - #include - -@@ -62,7 +61,7 @@ static LAppAllocator _cubismAllocator; / - - static LAppTextureManager* _textureManager; ///< テクスチャの管理 - --static std::string _executeAbsolutePath; ///< アプリケーションの実行パス -+static std::string _rootDirectory; ///< ルートディレクトリ - static std::string _currentModelDirectory; ///< 現在のモデルのディレクトリ名 - - static GLFWwindow* _window; ///< ウィンドウオブジェクト -@@ -86,11 +85,33 @@ static void InitializeCubism() - } - - /** --* @brief アプリケーションの実行パスの設定 -+* @brief 文字列の分割 - * --* Linuxのアプリケーションの実行パスを確認し、パスを取得する -+* 指定された区切り文字で文字列を分割する - */ --void SetExecuteAbsolutePath() -+Csm::csmVector Split(const std::string& baseString, char delimiter) -+{ -+ Csm::csmVector < std::string > elems; -+ std::stringstream ss(baseString); -+ std::string item; -+ -+ while (getline(ss, item, delimiter)) -+ { -+ if (!item.empty()) -+ { -+ elems.PushBack(item); -+ } -+ } -+ -+ return elems; -+} -+ -+/** -+* @brief ルートディレクトリの設定 -+* -+* Linuxのルートディレクトリを確認し、パスを取得する -+*/ -+void SetRootDirectory() - { - const int maximumPathBufferSize = 1024; - char path[maximumPathBufferSize]; -@@ -101,8 +122,19 @@ void SetExecuteAbsolutePath() - path[len] = '\0'; - } - -- _executeAbsolutePath = dirname(path); -- _executeAbsolutePath += "/"; -+ std::string pathString(path); -+ -+ pathString = pathString.substr(0, pathString.rfind("Demo")); -+ Csm::csmVector splitStrings = Split(pathString, '/'); -+ -+ _rootDirectory = ""; -+ -+ for (int i = 0; i < splitStrings.GetSize(); i++) -+ { -+ _rootDirectory += "/" + splitStrings[i]; -+ } -+ -+ _rootDirectory += "/"; - } - - /** -@@ -112,12 +144,12 @@ void SetExecuteAbsolutePath() - */ - static bool InitializeSystem() - { -- LAppPal::PrintLogLn("START"); -+ LAppPal::PrintLog("START"); - - // GLFWの初期化 - if (glfwInit() == GL_FALSE) - { -- LAppPal::PrintLogLn("Can't initilize GLFW"); -+ LAppPal::PrintLog("Can't initilize GLFW"); - - return GL_FALSE; - } -@@ -126,7 +158,7 @@ static bool InitializeSystem() - _window = glfwCreateWindow(LAppDefine::RenderTargetWidth, LAppDefine::RenderTargetHeight, "SIMPLE_SAMPLE", NULL, NULL); - if (_window == NULL) - { -- LAppPal::PrintLogLn("Can't create GLFW window."); -+ LAppPal::PrintLog("Can't create GLFW window."); - - glfwTerminate(); - return GL_FALSE; -@@ -137,7 +169,7 @@ static bool InitializeSystem() - glfwSwapInterval(1); - - if (glewInit() != GLEW_OK) { -- LAppPal::PrintLogLn("Can't initilize glew."); -+ LAppPal::PrintLog("Can't initilize glew."); - - glfwTerminate(); - return GL_FALSE; -@@ -165,7 +197,7 @@ static bool InitializeSystem() - // ドラッグ入力管理クラスの初期化 - MouseActionManager::GetInstance()->Initialize(windowWidth, windowHeight); - -- SetExecuteAbsolutePath(); -+ SetRootDirectory(); - - return GL_TRUE; - } -@@ -209,7 +241,7 @@ void Release() - void LoadModel(const std::string modelDirectoryName) - { - // モデルのディレクトリを指定 -- _currentModelDirectory = _executeAbsolutePath + LAppDefine::ResourcesPath + modelDirectoryName + "/"; -+ _currentModelDirectory = _rootDirectory + LAppDefine::ResourcesPath + modelDirectoryName + "/"; - - // モデルデータの新規生成 - _userModel = new CubismUserModelExtend(modelDirectoryName, _currentModelDirectory); diff --git a/example/generate_patch.sh b/example/generate_patch.sh index 3269196..fe9e9e0 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-5-r.3/Samples/OpenGL/Demo/proj.linux.cmake/* ./demo_clean/ +cp -p -r CubismSdkForNative-5-r.4/Samples/OpenGL/Demo/proj.linux.cmake/* ./demo_clean/ diff -pruN --exclude build ./demo_clean ./demo_dev > ./demo.patch -- 2.7.4