1 diff -pruN --exclude build ./demo_clean/CMakeLists.txt ./demo_dev/CMakeLists.txt
2 --- ./demo_clean/CMakeLists.txt 2024-03-28 18:19:03.168248400 +0000
3 +++ ./demo_dev/CMakeLists.txt 2024-03-28 18:23:33.549413300 +0000
4 @@ -9,7 +9,7 @@ option(
8 -set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../..)
9 +set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../CubismSdkForNative-5-r.1)
10 set(CORE_PATH ${SDK_ROOT_PATH}/Core)
11 set(FRAMEWORK_PATH ${SDK_ROOT_PATH}/Framework)
12 set(THIRD_PARTY_PATH ${SDK_ROOT_PATH}/Samples/OpenGL/thirdParty)
13 @@ -41,7 +41,7 @@ set(GLFW_INSTALL OFF CACHE BOOL "" FORCE
14 set(BUILD_UTILS OFF CACHE BOOL "" FORCE)
16 # Specify version of compiler.
17 -set(CMAKE_CXX_STANDARD 11)
18 +set(CMAKE_CXX_STANDARD 17)
19 set(CMAKE_CXX_STANDARD_REQUIRED ON)
20 set(CMAKE_CXX_EXTENSIONS OFF)
22 @@ -113,6 +113,9 @@ target_link_libraries(Framework Live2DCu
23 # Find opengl libraries.
24 find_package(OpenGL REQUIRED)
26 +# Add FacialLandmarksForCubism
27 +add_subdirectory(../.. FacialLandmarksForCubism_build)
29 # Make executable app.
30 add_executable(${APP_NAME})
32 @@ -122,12 +125,14 @@ target_link_libraries(${APP_NAME}
36 + FacialLandmarksForCubism
38 # Solve the MSVCRT confliction.
39 debug -NODEFAULTLIB:libcmtd.lib
40 optimized -NODEFAULTLIB:libcmt.lib
42 # Specify include directories.
43 -target_include_directories(${APP_NAME} PRIVATE ${STB_PATH})
44 +target_include_directories(${APP_NAME} PRIVATE ${STB_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../include)
45 # Build in multi-process.
46 target_compile_options(${APP_NAME} PRIVATE /MP)
48 diff -pruN --exclude build ./demo_clean/src/CMakeLists.txt ./demo_dev/src/CMakeLists.txt
49 --- ./demo_clean/src/CMakeLists.txt 2024-03-28 18:19:03.998153300 +0000
50 +++ ./demo_dev/src/CMakeLists.txt 2023-03-05 23:22:10.976777100 +0000
52 -if (CSM_MINIMUM_DEMO)
53 - target_sources(${APP_NAME}
54 +target_sources(${APP_NAME}
56 ${CMAKE_CURRENT_SOURCE_DIR}/LAppAllocator.cpp
57 ${CMAKE_CURRENT_SOURCE_DIR}/LAppAllocator.hpp
58 ${CMAKE_CURRENT_SOURCE_DIR}/LAppDefine.cpp
59 ${CMAKE_CURRENT_SOURCE_DIR}/LAppDefine.hpp
60 + ${CMAKE_CURRENT_SOURCE_DIR}/LAppDelegate.cpp
61 + ${CMAKE_CURRENT_SOURCE_DIR}/LAppDelegate.hpp
62 + ${CMAKE_CURRENT_SOURCE_DIR}/LAppLive2DManager.cpp
63 + ${CMAKE_CURRENT_SOURCE_DIR}/LAppLive2DManager.hpp
64 + ${CMAKE_CURRENT_SOURCE_DIR}/LAppModel.cpp
65 + ${CMAKE_CURRENT_SOURCE_DIR}/LAppModel.hpp
66 ${CMAKE_CURRENT_SOURCE_DIR}/LAppPal.cpp
67 ${CMAKE_CURRENT_SOURCE_DIR}/LAppPal.hpp
68 + ${CMAKE_CURRENT_SOURCE_DIR}/LAppSprite.cpp
69 + ${CMAKE_CURRENT_SOURCE_DIR}/LAppSprite.hpp
70 ${CMAKE_CURRENT_SOURCE_DIR}/LAppTextureManager.cpp
71 ${CMAKE_CURRENT_SOURCE_DIR}/LAppTextureManager.hpp
72 - ${CMAKE_CURRENT_SOURCE_DIR}/mainMinimum.cpp
73 - ${CMAKE_CURRENT_SOURCE_DIR}/TouchManager.cpp
74 - ${CMAKE_CURRENT_SOURCE_DIR}/TouchManager.hpp
75 - ${CMAKE_CURRENT_SOURCE_DIR}/CubismUserModelExtend.cpp
76 - ${CMAKE_CURRENT_SOURCE_DIR}/CubismUserModelExtend.hpp
77 - ${CMAKE_CURRENT_SOURCE_DIR}/CubismSampleViewMatrix.cpp
78 - ${CMAKE_CURRENT_SOURCE_DIR}/CubismSampleViewMatrix.hpp
79 - ${CMAKE_CURRENT_SOURCE_DIR}/MouseActionManager.cpp
80 - ${CMAKE_CURRENT_SOURCE_DIR}/MouseActionManager.hpp
83 - target_sources(${APP_NAME}
85 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppAllocator.cpp
86 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppAllocator.hpp
87 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppDefine.cpp
88 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppDefine.hpp
89 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppDelegate.cpp
90 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppDelegate.hpp
91 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppWavFileHandler.cpp
92 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppWavFileHandler.hpp
93 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppLive2DManager.cpp
94 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppLive2DManager.hpp
95 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppModel.cpp
96 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppModel.hpp
97 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppPal.cpp
98 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppPal.hpp
99 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppSprite.cpp
100 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppSprite.hpp
101 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppTextureManager.cpp
102 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppTextureManager.hpp
103 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppView.cpp
104 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppView.hpp
105 - ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
106 - ${CMAKE_CURRENT_SOURCE_DIR}/TouchManager.cpp
107 - ${CMAKE_CURRENT_SOURCE_DIR}/TouchManager.hpp
110 + ${CMAKE_CURRENT_SOURCE_DIR}/LAppView.cpp
111 + ${CMAKE_CURRENT_SOURCE_DIR}/LAppView.hpp
112 + ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
114 diff -pruN --exclude build ./demo_clean/src/CubismUserModelExtend.cpp ./demo_dev/src/CubismUserModelExtend.cpp
115 --- ./demo_clean/src/CubismUserModelExtend.cpp 2024-03-28 18:19:03.868189000 +0000
116 +++ ./demo_dev/src/CubismUserModelExtend.cpp 2023-03-05 23:22:10.780128700 +0000
120 * Copyright(c) Live2D Inc. All rights reserved.
122 * Use of this source code is governed by the Live2D Open Software license
124 #include "CubismUserModelExtend.hpp"
126 using namespace Live2D::Cubism::Framework;
127 -using namespace Live2D::Cubism::Framework::DefaultParameterId;
128 +using namespace DefaultParameterId;
129 using namespace LAppDefine;
132 @@ -74,34 +74,17 @@ CubismUserModelExtend::~CubismUserModelE
133 delete _textureManager;
136 -std::string CubismUserModelExtend::MakeAssetPath(const std::string& assetFileName)
137 +void CubismUserModelExtend::LoadAssets(const Csm::csmChar* fileName)
139 - return _currentModelDirectory + assetFileName;
142 -void CubismUserModelExtend::SetAssetDirectory(const std::string& path)
144 - _currentModelDirectory = path;
147 + const csmString path = csmString(_currentModelDirectory.c_str()) + fileName;
149 -void CubismUserModelExtend::LoadAsset(const std::string & fiileName, const std::function<void(Csm::csmByte*, Csm::csmSizeInt)>& afterLoadCallback)
151 - Csm::csmSizeInt bufferSize = 0;
152 - Csm::csmByte* buffer = nullptr;
154 - if (fiileName.empty())
158 + csmByte* buffer = CreateBuffer(path.GetRawString(), &size);
159 + _modelJson = new CubismModelSettingJson(buffer, size);
160 + DeleteBuffer(buffer, path.GetRawString());
163 - buffer = LAppPal::LoadFileAsBytes(MakeAssetPath(fiileName).c_str(), &bufferSize);
166 - afterLoadCallback(buffer, bufferSize);
169 - LAppPal::ReleaseBytes(buffer);
174 void CubismUserModelExtend::SetupModel()
175 @@ -109,44 +92,75 @@ void CubismUserModelExtend::SetupModel()
177 _initialized = false;
179 - // モデルの設定データをJsonファイルから読み込み
180 - LoadAsset(_modelDirName + ".model3.json", [=](Csm::csmByte* buffer, Csm::csmSizeInt bufferSize) { _modelJson = new Csm::CubismModelSettingJson(buffer, bufferSize); });
181 - // モデルの設定データからモデルデータを読み込み
182 - LoadAsset(_modelJson->GetModelFileName(), [=](Csm::csmByte* buffer, Csm::csmSizeInt bufferSize) { LoadModel(buffer, bufferSize); });
187 + if (strcmp(_modelJson->GetModelFileName(), ""))
189 + csmString path = _modelJson->GetModelFileName();
190 + path = csmString(_currentModelDirectory.c_str()) + path;
192 + buffer = CreateBuffer(path.GetRawString(), &size);
193 + LoadModel(buffer, size);
194 + DeleteBuffer(buffer, path.GetRawString());
198 - for (auto expressionIndex = 0; expressionIndex < _modelJson->GetExpressionCount(); ++expressionIndex)
199 + if (_modelJson->GetExpressionCount() > 0)
201 - LoadAsset(_modelJson->GetExpressionFileName(expressionIndex), [=](Csm::csmByte* buffer, Csm::csmSizeInt bufferSize) {
202 - auto expressionName = _modelJson->GetExpressionName(expressionIndex);
203 - ACubismMotion* motion = LoadExpression(buffer, bufferSize, expressionName);
204 + const csmInt32 count = _modelJson->GetExpressionCount();
205 + for (csmInt32 i = 0; i < count; i++)
207 + csmString name = _modelJson->GetExpressionName(i);
208 + csmString path = _modelJson->GetExpressionFileName(i);
209 + path = csmString(_currentModelDirectory.c_str()) + path;
212 + buffer = CreateBuffer(path.GetRawString(), &size);
213 + ACubismMotion* motion = LoadExpression(buffer, size, name.GetRawString());
215 + if (_expressions[name])
217 - if (_expressions[expressionName])
219 - ACubismMotion::Delete(_expressions[expressionName]);
220 - _expressions[expressionName] = nullptr;
222 - _expressions[expressionName] = motion;
223 + ACubismMotion::Delete(_expressions[name]);
224 + _expressions[name] = nullptr;
227 + _expressions[name] = motion;
229 + DeleteBuffer(buffer, path.GetRawString());
234 - LoadAsset(_modelJson->GetPoseFileName(), [=](Csm::csmByte* buffer, Csm::csmSizeInt bufferSize) {
235 - LoadPose(buffer, bufferSize);
237 + if (strcmp(_modelJson->GetPoseFileName(), ""))
239 + csmString path = _modelJson->GetPoseFileName();
240 + path = csmString(_currentModelDirectory.c_str()) + path;
242 + buffer = CreateBuffer(path.GetRawString(), &size);
243 + LoadPose(buffer, size);
244 + DeleteBuffer(buffer, path.GetRawString());
248 - LoadAsset(_modelJson->GetPhysicsFileName(), [=](Csm::csmByte* buffer, Csm::csmSizeInt bufferSize) {
249 - LoadPhysics(buffer, bufferSize);
251 + if (strcmp(_modelJson->GetPhysicsFileName(), ""))
253 + csmString path = _modelJson->GetPhysicsFileName();
254 + path = csmString(_currentModelDirectory.c_str()) + path;
256 + buffer = CreateBuffer(path.GetRawString(), &size);
257 + LoadPhysics(buffer, size);
258 + DeleteBuffer(buffer, path.GetRawString());
261 // モデルに付属するユーザーデータの読み込み
262 - LoadAsset(_modelJson->GetUserDataFile(), [=](Csm::csmByte* buffer, Csm::csmSizeInt bufferSize) {
263 - LoadUserData(buffer, bufferSize);
265 + if (strcmp(_modelJson->GetUserDataFile(), ""))
267 + csmString path = _modelJson->GetUserDataFile();
268 + path = csmString(_currentModelDirectory.c_str()) + path;
269 + buffer = CreateBuffer(path.GetRawString(), &size);
270 + LoadUserData(buffer, size);
271 + DeleteBuffer(buffer, path.GetRawString());
275 csmMap<csmString, csmFloat32> layout;
276 @@ -196,29 +210,26 @@ void CubismUserModelExtend::PreloadMotio
278 CubismMotion* tmpMotion = static_cast<CubismMotion*>(LoadMotion(buffer, size, name.GetRawString()));
282 + csmFloat32 fadeTime = _modelJson->GetMotionFadeInTimeValue(group, i);
283 + if (fadeTime >= 0.0f)
286 - csmFloat32 fadeTime = _modelJson->GetMotionFadeInTimeValue(group, i);
287 - if (fadeTime >= 0.0f)
289 - tmpMotion->SetFadeInTime(fadeTime);
291 + tmpMotion->SetFadeInTime(fadeTime);
295 - fadeTime = _modelJson->GetMotionFadeOutTimeValue(group, i);
296 - if (fadeTime >= 0.0f)
298 - tmpMotion->SetFadeOutTime(fadeTime);
301 + fadeTime = _modelJson->GetMotionFadeOutTimeValue(group, i);
302 + if (fadeTime >= 0.0f)
304 + tmpMotion->SetFadeOutTime(fadeTime);
307 - if (_motions[name])
310 - ACubismMotion::Delete(_motions[name]);
312 - _motions[name] = tmpMotion;
313 + if (_motions[name])
316 + ACubismMotion::Delete(_motions[name]);
318 + _motions[name] = tmpMotion;
320 DeleteBuffer(buffer, path.GetRawString());
322 @@ -292,24 +303,21 @@ Csm::CubismMotionQueueEntryHandle Cubism
324 motion = static_cast<CubismMotion*>(LoadMotion(buffer, size, NULL, onFinishedMotionHandler));
327 + csmFloat32 fadeTime = _modelJson->GetMotionFadeInTimeValue(group, no);
328 + if (fadeTime >= 0.0f)
330 - csmFloat32 fadeTime = _modelJson->GetMotionFadeInTimeValue(group, no);
331 - if (fadeTime >= 0.0f)
333 - motion->SetFadeInTime(fadeTime);
336 - fadeTime = _modelJson->GetMotionFadeOutTimeValue(group, no);
337 - if (fadeTime >= 0.0f)
339 - motion->SetFadeOutTime(fadeTime);
341 + motion->SetFadeInTime(fadeTime);
346 + fadeTime = _modelJson->GetMotionFadeOutTimeValue(group, no);
347 + if (fadeTime >= 0.0f)
349 + motion->SetFadeOutTime(fadeTime);
355 DeleteBuffer(buffer, path.GetRawString());
358 @@ -355,16 +363,6 @@ void CubismUserModelExtend::ModelParamUp
359 _model->SaveParameters();
360 //-----------------------------------------------------------------
362 - // メインモーションの更新がないとき
363 - if (!motionUpdated)
368 - _eyeBlink->UpdateParameters(_model, deltaTimeSeconds);
372 if (_expressionManager)
375 @@ -387,12 +385,6 @@ void CubismUserModelExtend::ModelParamUp
376 _model->AddParameterValue(_idParamEyeBallX, _dragX); // -1から1の値を加える
377 _model->AddParameterValue(_idParamEyeBallY, _dragY);
382 - _breath->UpdateParameters(_model, deltaTimeSeconds);
388 diff -pruN --exclude build ./demo_clean/src/CubismUserModelExtend.hpp ./demo_dev/src/CubismUserModelExtend.hpp
389 --- ./demo_clean/src/CubismUserModelExtend.hpp 2024-03-28 18:19:03.926168700 +0000
390 +++ ./demo_dev/src/CubismUserModelExtend.hpp 2023-03-05 23:22:10.986750400 +0000
391 @@ -27,17 +27,13 @@ class CubismUserModelExtend :
394 CubismUserModelExtend(const std::string modelDirectoryName, const std::string _currentModelDirectory); ///< コンストラクタ
395 - virtual ~CubismUserModelExtend(); ///< デストラクタ
396 + ~CubismUserModelExtend(); ///< デストラクタ
399 - * @brief model3.jsonからモデルを生成する
401 - * model3.jsonの記述に従ってモデル生成、モーション、物理演算などのコンポーネント生成を行う
403 - * @param[in] setting ICubismModelSettingのインスタンス
404 + * @brief model3.jsonが置かれたディレクトリとファイルパスからモデルを生成する
408 + void LoadAssets(const Csm::csmChar* fileName);
412 @@ -48,35 +44,24 @@ public:
417 + * @brief model3.jsonからモデルを生成する
421 - std::string MakeAssetPath(const std::string & assetFileName);
424 - * @brief ディレクトリパスの設定
425 + * model3.jsonの記述に従ってモデル生成、モーション、物理演算などのコンポーネント生成を行う
427 + * @param[in] setting ICubismModelSettingのインスタンス
429 - * モデルのディレクトリパスを設定する
431 - void SetAssetDirectory(const std::string & path);
435 - * @brief アセットのロードを行う
436 + * @brief 引数で指定したモーションの再生を開始する
438 - * 指定されたファイル名からアセットのロードを行う
439 + * @param[in] group モーショングループ名
440 + * @param[in] no グループ内の番号
441 + * @param[in] priority 優先度
442 + * @param[in] onFinishedMotionHandler モーション再生終了時に呼び出されるコールバック関数。NULLの場合、呼び出されない。
443 + * @return 開始したモーションの識別番号を返す。個別のモーションが終了したか否かを判定するIsFinished()の引数で使用する。開始できない時は「-1」
445 - void LoadAsset(const std::string & fiileName, const std::function<void(Csm::csmByte*, Csm::csmSizeInt)>& afterLoadCallback);
448 - * @brief 引数で指定したモーションの再生を開始する
450 - * @param[in] group モーショングループ名
451 - * @param[in] no グループ内の番号
452 - * @param[in] priority 優先度
453 - * @param[in] onFinishedMotionHandler モーション再生終了時に呼び出されるコールバック関数。NULLの場合、呼び出されない。
454 - * @return 開始したモーションの識別番号を返す。個別のモーションが終了したか否かを判定するIsFinished()の引数で使用する。開始できない時は「-1」
456 Csm::CubismMotionQueueEntryHandle StartMotion(const Csm::csmChar* group, Csm::csmInt32 no, Csm::csmInt32 priority, Csm::ACubismMotion::FinishedMotionCallback onFinishedMotionHandler = NULL);
459 diff -pruN --exclude build ./demo_clean/src/LAppAllocator.cpp ./demo_dev/src/LAppAllocator.cpp
460 --- ./demo_clean/src/LAppAllocator.cpp 2024-03-28 18:19:03.800631600 +0000
461 +++ ./demo_dev/src/LAppAllocator.cpp 2023-03-05 23:22:10.847976000 +0000
465 * Copyright(c) Live2D Inc. All rights reserved.
467 * Use of this source code is governed by the Live2D Open Software license
472 -void* LAppAllocator::Allocate(const csmSizeType size)
473 +void* LAppAllocator::Allocate(const csmSizeType size)
477 diff -pruN --exclude build ./demo_clean/src/LAppAllocator.hpp ./demo_dev/src/LAppAllocator.hpp
478 --- ./demo_clean/src/LAppAllocator.hpp 2024-03-28 18:19:04.446046500 +0000
479 +++ ./demo_dev/src/LAppAllocator.hpp 2023-03-05 23:22:10.953083600 +0000
483 * Copyright(c) Live2D Inc. All rights reserved.
485 * Use of this source code is governed by the Live2D Open Software license
486 diff -pruN --exclude build ./demo_clean/src/LAppDefine.cpp ./demo_dev/src/LAppDefine.cpp
487 --- ./demo_clean/src/LAppDefine.cpp 2024-03-28 18:19:04.269187200 +0000
488 +++ ./demo_dev/src/LAppDefine.cpp 2023-03-05 23:22:10.995458800 +0000
492 * Copyright(c) Live2D Inc. All rights reserved.
494 * Use of this source code is governed by the Live2D Open Software license
495 @@ -20,7 +20,7 @@ namespace LAppDefine {
496 const csmFloat32 ViewLogicalLeft = -1.0f;
497 const csmFloat32 ViewLogicalRight = 1.0f;
498 const csmFloat32 ViewLogicalBottom = -1.0f;
499 - const csmFloat32 ViewLogicalTop = -1.0f;
500 + const csmFloat32 ViewLogicalTop = 1.0f;
502 const csmFloat32 ViewLogicalMaxLeft = -2.0f;
503 const csmFloat32 ViewLogicalMaxRight = 2.0f;
504 @@ -38,6 +38,18 @@ namespace LAppDefine {
505 const csmChar* PowerImageName = "close.png";
507 // モデル定義------------------------------------------
508 + // モデルを配置したディレクトリ名の配列
509 + // ディレクトリ名とmodel3.jsonの名前を一致させておくこと
510 + const csmChar* ModelDir[] = {
518 + const csmInt32 ModelDirSize = sizeof(ModelDir) / sizeof(const csmChar*);
520 // 外部定義ファイル(json)と合わせる
521 const csmChar* MotionGroupIdle = "Idle"; // アイドリング
522 const csmChar* MotionGroupTapBody = "TapBody"; // 体をタップしたとき
523 @@ -52,9 +64,6 @@ namespace LAppDefine {
524 const csmInt32 PriorityNormal = 2;
525 const csmInt32 PriorityForce = 3;
528 - const csmBool MocConsistencyValidationEnable = true;
531 const csmBool DebugLogEnable = true;
532 const csmBool DebugTouchLogEnable = false;
533 diff -pruN --exclude build ./demo_clean/src/LAppDefine.hpp ./demo_dev/src/LAppDefine.hpp
534 --- ./demo_clean/src/LAppDefine.hpp 2024-03-28 18:19:03.690794600 +0000
535 +++ ./demo_dev/src/LAppDefine.hpp 2023-03-05 23:22:10.947784100 +0000
539 * Copyright(c) Live2D Inc. All rights reserved.
541 * Use of this source code is governed by the Live2D Open Software license
542 * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
547 #include <CubismFramework.hpp>
548 @@ -36,6 +37,9 @@ namespace LAppDefine {
549 extern const csmChar* PowerImageName; ///< 終了ボタン画像ファイル
551 // モデル定義--------------------------------------------
552 + extern const csmChar* ModelDir[]; ///< モデルを配置したディレクトリ名の配列. ディレクトリ名とmodel3.jsonの名前を一致させておく.
553 + extern const csmInt32 ModelDirSize; ///< モデルディレクトリ配列のサイズ
555 // 外部定義ファイル(json)と合わせる
556 extern const csmChar* MotionGroupIdle; ///< アイドリング時に再生するモーションのリスト
557 extern const csmChar* MotionGroupTapBody; ///< 体をタップした時に再生するモーションのリスト
558 @@ -50,8 +54,6 @@ namespace LAppDefine {
559 extern const csmInt32 PriorityNormal; ///< モーションの優先度定数: 2
560 extern const csmInt32 PriorityForce; ///< モーションの優先度定数: 3
562 - extern const csmBool MocConsistencyValidationEnable; ///< MOC3の整合性検証機能の有効・無効
565 extern const csmBool DebugLogEnable; ///< デバッグ用ログ表示の有効・無効
566 extern const csmBool DebugTouchLogEnable; ///< タッチ処理のデバッグ用ログ表示の有効・無効
567 diff -pruN --exclude build ./demo_clean/src/LAppDelegate.cpp ./demo_dev/src/LAppDelegate.cpp
568 --- ./demo_clean/src/LAppDelegate.cpp 2024-03-28 18:19:03.753278100 +0000
569 +++ ./demo_dev/src/LAppDelegate.cpp 2023-03-05 23:22:10.975780100 +0000
573 * Copyright(c) Live2D Inc. All rights reserved.
575 * Use of this source code is governed by the Live2D Open Software license
578 #include "LAppDelegate.hpp"
582 #include <GLFW/glfw3.h>
583 #include "LAppView.hpp"
584 @@ -43,11 +44,12 @@ void LAppDelegate::ReleaseInstance()
588 -bool LAppDelegate::Initialize()
589 +bool LAppDelegate::Initialize(int initWindowWidth, int initWindowHeight,
590 + const char *windowTitle)
594 - LAppPal::PrintLogLn("START");
595 + LAppPal::PrintLog("START");
599 @@ -55,18 +57,24 @@ bool LAppDelegate::Initialize()
603 - LAppPal::PrintLogLn("Can't initilize GLFW");
604 + LAppPal::PrintLog("Can't initilize GLFW");
610 - _window = glfwCreateWindow(RenderTargetWidth, RenderTargetHeight, "SAMPLE", NULL, NULL);
611 + _window = glfwCreateWindow(
612 + initWindowWidth ? initWindowWidth : RenderTargetWidth,
613 + initWindowHeight ? initWindowHeight : RenderTargetHeight,
614 + windowTitle ? windowTitle : "SAMPLE",
622 - LAppPal::PrintLogLn("Can't create GLFW window.");
623 + LAppPal::PrintLog("Can't create GLFW window.");
627 @@ -79,7 +87,7 @@ bool LAppDelegate::Initialize()
628 if (glewInit() != GLEW_OK) {
631 - LAppPal::PrintLogLn("Can't initilize glew.");
632 + LAppPal::PrintLog("Can't initilize glew.");
636 @@ -93,10 +101,6 @@ bool LAppDelegate::Initialize()
638 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
641 - glfwSetMouseButtonCallback(_window, EventHandler::OnMouseCallBack);
642 - glfwSetCursorPosCallback(_window, EventHandler::OnMouseCallBack);
646 glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &width, &height);
647 @@ -106,9 +110,15 @@ bool LAppDelegate::Initialize()
656 + LAppLive2DManager::GetInstance();
659 + _view->InitializeSprite();
664 @@ -125,7 +135,7 @@ void LAppDelegate::Release()
666 LAppLive2DManager::ReleaseInstance();
670 CubismFramework::Dispose();
673 @@ -136,18 +146,13 @@ void LAppDelegate::Run()
676 glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &width, &height);
677 - if( (_windowWidth!=width || _windowHeight!=height) && width>0 && height>0)
678 + if((_windowWidth!=width || _windowHeight!=height) && width>0 && height>0)
683 _view->ResizeSprite();
686 _windowWidth = width;
687 _windowHeight = height;
690 - glViewport(0, 0, width, height);
694 @@ -183,6 +188,7 @@ LAppDelegate::LAppDelegate():
698 + _rootDirectory = "";
699 _view = new LAppView();
700 _textureManager = new LAppTextureManager();
702 @@ -202,58 +208,10 @@ void LAppDelegate::InitializeCubism()
704 CubismFramework::Initialize();
707 - LAppLive2DManager::GetInstance();
710 CubismMatrix44 projection;
712 LAppPal::UpdateTime();
714 - _view->InitializeSprite();
717 -void LAppDelegate::OnMouseCallBack(GLFWwindow* window, int button, int action, int modify)
723 - if (GLFW_MOUSE_BUTTON_LEFT != button)
728 - if (GLFW_PRESS == action)
731 - _view->OnTouchesBegan(_mouseX, _mouseY);
733 - else if (GLFW_RELEASE == action)
738 - _view->OnTouchesEnded(_mouseX, _mouseY);
743 -void LAppDelegate::OnMouseCallBack(GLFWwindow* window, double x, double y)
745 - _mouseX = static_cast<float>(x);
746 - _mouseY = static_cast<float>(y);
757 - _view->OnTouchesMoved(_mouseX, _mouseY);
760 GLuint LAppDelegate::CreateShader()
761 @@ -271,10 +229,6 @@ GLuint LAppDelegate::CreateShader()
763 glShaderSource(vertexShaderId, 1, &vertexShader, NULL);
764 glCompileShader(vertexShaderId);
765 - if(!CheckShader(vertexShaderId))
771 GLuint fragmentShaderId = glCreateShader(GL_FRAGMENT_SHADER);
772 @@ -288,10 +242,6 @@ GLuint LAppDelegate::CreateShader()
774 glShaderSource(fragmentShaderId, 1, &fragmentShader, NULL);
775 glCompileShader(fragmentShaderId);
776 - if (!CheckShader(fragmentShaderId))
782 GLuint programId = glCreateProgram();
783 @@ -306,25 +256,24 @@ GLuint LAppDelegate::CreateShader()
787 -bool LAppDelegate::CheckShader(GLuint shaderId)
788 +void LAppDelegate::SetRootDirectory(std::string rootDir)
792 - glGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &logLength);
795 - GLchar* log = reinterpret_cast<GLchar*>(CSM_MALLOC(logLength));
796 - glGetShaderInfoLog(shaderId, logLength, &logLength, log);
797 - CubismLogError("Shader compile log: %s", log);
800 + this->_rootDirectory = rootDir + "/";
803 +Csm::csmVector<string> LAppDelegate::Split(const std::string& baseString, char delimiter)
805 + Csm::csmVector<string> elems;
806 + stringstream ss(baseString);
809 - glGetShaderiv(shaderId, GL_COMPILE_STATUS, &status);
810 - if (status == GL_FALSE)
811 + while(getline(ss, item, delimiter))
813 - glDeleteShader(shaderId);
817 + elems.PushBack(item);
824 diff -pruN --exclude build ./demo_clean/src/LAppDelegate.hpp ./demo_dev/src/LAppDelegate.hpp
825 --- ./demo_clean/src/LAppDelegate.hpp 2024-03-28 18:19:04.100879300 +0000
826 +++ ./demo_dev/src/LAppDelegate.hpp 2023-03-05 23:22:10.789104800 +0000
830 * Copyright(c) Live2D Inc. All rights reserved.
832 * Use of this source code is governed by the Live2D Open Software license
839 #include <GLFW/glfw3.h>
840 +#include "Type/csmVector.hpp"
841 #include "LAppAllocator.hpp"
844 @@ -16,7 +18,7 @@ class LAppTextureManager;
847 * @brief アプリケーションクラス。
848 -* Cubism SDK の管理を行う。
853 @@ -38,7 +40,8 @@ public:
855 * @brief APPに必要なものを初期化する。
858 + bool Initialize(int initWindowWidth = 0, int initWindowHeight = 0,
859 + const char *windowTitle = "SAMPLE");
863 @@ -51,25 +54,6 @@ public:
867 - * @brief OpenGL用 glfwSetMouseButtonCallback用関数。
869 - * @param[in] window コールバックを呼んだWindow情報
870 - * @param[in] button ボタン種類
871 - * @param[in] action 実行結果
872 - * @param[in] modify
874 - void OnMouseCallBack(GLFWwindow* window, int button, int action, int modify);
877 - * @brief OpenGL用 glfwSetCursorPosCallback用関数。
879 - * @param[in] window コールバックを呼んだWindow情報
883 - void OnMouseCallBack(GLFWwindow* window, double x, double y);
888 GLuint CreateShader();
889 @@ -94,6 +78,21 @@ public:
891 void AppEnd() { _isEnd = true; }
894 + * @brief ルートディレクトリを設定する。
896 + * @param[in] rootDir : The root directory to set to.
898 + void SetRootDirectory(std::string rootDir);
901 + * @brief ルートディレクトリを取得する。
903 + std::string GetRootDirectory(){ return _rootDirectory;}
906 + * @brief テクスチャマネージャーを取得する。
908 LAppTextureManager* GetTextureManager() { return _textureManager; }
911 @@ -108,17 +107,17 @@ private:
915 - * @brief Cubism SDK の初期化
916 + * @brief Cubism3の初期化
918 void InitializeCubism();
921 - * @brief CreateShader内部関数 エラーチェック
922 + * @brief 文字列を指定の文字で切り分ける
924 - bool CheckShader(GLuint shaderId);
925 + Csm::csmVector<std::string> Split(const std::string& baseString, char delim);
927 - LAppAllocator _cubismAllocator; ///< Cubism SDK Allocator
928 - Csm::CubismFramework::Option _cubismOption; ///< Cubism SDK Option
929 + LAppAllocator _cubismAllocator; ///< Cubism3 Allocator
930 + Csm::CubismFramework::Option _cubismOption; ///< Cubism3 Option
931 GLFWwindow* _window; ///< OpenGL ウィンドウ
932 LAppView* _view; ///< View情報
933 bool _captured; ///< クリックしているか
934 @@ -126,28 +125,8 @@ private:
935 float _mouseY; ///< マウスY座標
936 bool _isEnd; ///< APP終了しているか
937 LAppTextureManager* _textureManager; ///< テクスチャマネージャー
938 + std::string _rootDirectory; ///< ルートディレクトリ
940 int _windowWidth; ///< Initialize関数で設定したウィンドウ幅
941 int _windowHeight; ///< Initialize関数で設定したウィンドウ高さ
948 - * @brief glfwSetMouseButtonCallback用コールバック関数。
950 - static void OnMouseCallBack(GLFWwindow* window, int button, int action, int modify)
952 - LAppDelegate::GetInstance()->OnMouseCallBack(window, button, action, modify);
956 - * @brief glfwSetCursorPosCallback用コールバック関数。
958 - static void OnMouseCallBack(GLFWwindow* window, double x, double y)
960 - LAppDelegate::GetInstance()->OnMouseCallBack(window, x, y);
964 diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src/LAppLive2DManager.cpp
965 --- ./demo_clean/src/LAppLive2DManager.cpp 2024-03-28 18:19:04.069617100 +0000
966 +++ ./demo_dev/src/LAppLive2DManager.cpp 2023-03-05 23:22:10.967799000 +0000
970 * Copyright(c) Live2D Inc. All rights reserved.
972 * Use of this source code is governed by the Live2D Open Software license
976 #include "LAppLive2DManager.hpp"
982 #include <GLFW/glfw3.h>
983 #include <Rendering/CubismRenderer.hpp>
985 #include "LAppDelegate.hpp"
986 #include "LAppModel.hpp"
987 #include "LAppView.hpp"
988 +#include "LAppSprite.hpp"
991 using namespace LAppDefine;
992 @@ -27,13 +26,7 @@ namespace {
994 void FinishedMotion(ACubismMotion* self)
996 - LAppPal::PrintLogLn("Motion Finished: %x", self);
999 - int CompareCsmString(const void* a, const void* b)
1001 - return strcmp(reinterpret_cast<const Csm::csmString*>(a)->GetRawString(),
1002 - reinterpret_cast<const Csm::csmString*>(b)->GetRawString());
1003 + LAppPal::PrintLog("Motion Finished: %x", self);
1007 @@ -59,18 +52,16 @@ void LAppLive2DManager::ReleaseInstance(
1009 LAppLive2DManager::LAppLive2DManager()
1012 + , _projScaleFactor(1.0f)
1013 + , _translateX(0.0f)
1014 + , _translateY(0.0f)
1016 _viewMatrix = new CubismMatrix44();
1019 - ChangeScene(_sceneIndex);
1022 LAppLive2DManager::~LAppLive2DManager()
1025 - delete _viewMatrix;
1028 void LAppLive2DManager::ReleaseAllModel()
1029 @@ -83,50 +74,6 @@ void LAppLive2DManager::ReleaseAllModel(
1033 -void LAppLive2DManager::SetUpModel()
1035 - // ResourcesPathの中にあるフォルダ名を全てクロールし、モデルが存在するフォルダを定義する。
1036 - // フォルダはあるが同名の.model3.jsonが見つからなかった場合はリストに含めない。
1037 - csmString crawlPath(ResourcesPath);
1038 - crawlPath += "*.*";
1040 - struct _finddata_t fdata;
1041 - intptr_t fh = _findfirst(crawlPath.GetRawString(), &fdata);
1042 - if (fh == -1) return;
1044 - _modelDir.Clear();
1046 - while (_findnext(fh, &fdata) == 0)
1048 - if ((fdata.attrib & _A_SUBDIR) && strcmp(fdata.name, "..") != 0)
1050 - // フォルダと同名の.model3.jsonがあるか探索する
1051 - csmString model3jsonPath(ResourcesPath);
1052 - model3jsonPath += fdata.name;
1053 - model3jsonPath.Append(1, '/');
1054 - model3jsonPath += fdata.name;
1055 - model3jsonPath += ".model3.json";
1057 - struct _finddata_t fdata2;
1058 - if (_findfirst(model3jsonPath.GetRawString(), &fdata2) != -1)
1060 - _modelDir.PushBack(csmString(fdata.name));
1064 - qsort(_modelDir.GetPtr(), _modelDir.GetSize(), sizeof(csmString), CompareCsmString);
1067 -csmVector<csmString> LAppLive2DManager::GetModelDir() const
1072 -csmInt32 LAppLive2DManager::GetModelDirSize() const
1074 - return _modelDir.GetSize();
1077 LAppModel* LAppLive2DManager::GetModel(csmUint32 no) const
1079 if (no < _models.GetSize())
1080 @@ -151,27 +98,7 @@ void LAppLive2DManager::OnTap(csmFloat32
1084 - LAppPal::PrintLogLn("[APP]tap point: {x:%.2f y:%.2f}", x, y);
1087 - for (csmUint32 i = 0; i < _models.GetSize(); i++)
1089 - if (_models[i]->HitTest(HitAreaNameHead, x, y))
1091 - if (DebugLogEnable)
1093 - LAppPal::PrintLogLn("[APP]hit area: [%s]", HitAreaNameHead);
1095 - _models[i]->SetRandomExpression();
1097 - else if (_models[i]->HitTest(HitAreaNameBody, x, y))
1099 - if (DebugLogEnable)
1101 - LAppPal::PrintLogLn("[APP]hit area: [%s]", HitAreaNameBody);
1103 - _models[i]->StartRandomMotion(MotionGroupTapBody, PriorityNormal, FinishedMotion);
1105 + LAppPal::PrintLog("[APP]tap point: {x:%.2f y:%.2f}", x, y);
1109 @@ -180,15 +107,15 @@ void LAppLive2DManager::OnUpdate() const
1111 glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &width, &height);
1113 + CubismMatrix44 projection;
1114 csmUint32 modelCount = _models.GetSize();
1115 for (csmUint32 i = 0; i < modelCount; ++i)
1117 - CubismMatrix44 projection;
1118 LAppModel* model = GetModel(i);
1120 if (model->GetModel() == NULL)
1122 - LAppPal::PrintLogLn("Failed to model->GetModel().");
1123 + LAppPal::PrintLog("Failed to model->GetModel().");
1127 @@ -196,12 +123,15 @@ void LAppLive2DManager::OnUpdate() const
1129 // 横に長いモデルを縦長ウィンドウに表示する際モデルの横サイズでscaleを算出する
1130 model->GetModelMatrix()->SetWidth(2.0f);
1131 - projection.Scale(1.0f, static_cast<float>(width) / static_cast<float>(height));
1132 + projection.Scale(_projScaleFactor,
1133 + _projScaleFactor * static_cast<float>(width) / static_cast<float>(height));
1137 - projection.Scale(static_cast<float>(height) / static_cast<float>(width), 1.0f);
1138 + projection.Scale(_projScaleFactor * static_cast<float>(height) / static_cast<float>(width),
1139 + _projScaleFactor);
1141 + projection.Translate(_translateX, _translateY);
1144 if (_viewMatrix != NULL)
1145 @@ -209,45 +139,24 @@ void LAppLive2DManager::OnUpdate() const
1146 projection.MultiplyByMatrix(_viewMatrix);
1150 LAppDelegate::GetInstance()->GetView()->PreModelDraw(*model);
1153 model->Draw(projection);///< 参照渡しなのでprojectionは変質する
1156 LAppDelegate::GetInstance()->GetView()->PostModelDraw(*model);
1160 -void LAppLive2DManager::NextScene()
1161 +void LAppLive2DManager::SetModel(std::string modelName, bool useOldParamId)
1163 - csmInt32 no = (_sceneIndex + 1) % GetModelDirSize();
1167 -void LAppLive2DManager::ChangeScene(Csm::csmInt32 index)
1169 - _sceneIndex = index;
1170 - if (DebugLogEnable)
1172 - LAppPal::PrintLogLn("[APP]model index: %d", _sceneIndex);
1175 - // model3.jsonのパスを決定する.
1176 - // ディレクトリ名とmodel3.jsonの名前を一致していることが条件
1177 - const csmString& model = _modelDir[index];
1179 - csmString modelPath(ResourcesPath);
1180 - modelPath += model;
1181 - modelPath.Append(1, '/');
1183 - csmString modelJsonName(model);
1184 + std::string modelPath = LAppDelegate::GetInstance()->GetRootDirectory() + ResourcesPath + modelName + "/";
1185 + std::string modelJsonName = modelName;
1186 modelJsonName += ".model3.json";
1189 - _models.PushBack(new LAppModel());
1190 - _models[0]->LoadAssets(modelPath.GetRawString(), modelJsonName.GetRawString());
1191 + _models.PushBack(new LAppModel(useOldParamId));
1192 + _models[0]->LoadAssets(modelPath.c_str(), modelJsonName.c_str());
1195 * モデル半透明表示を行うサンプルを提示する。
1196 @@ -268,16 +177,21 @@ void LAppLive2DManager::ChangeScene(Csm:
1198 #if defined(USE_RENDER_TARGET) || defined(USE_MODEL_RENDER_TARGET)
1199 // モデル個別にαを付けるサンプルとして、もう1体モデルを作成し、少し位置をずらす
1200 - _models.PushBack(new LAppModel());
1201 - _models[1]->LoadAssets(modelPath.GetRawString(), modelJsonName.GetRawString());
1202 + _models.PushBack(new LAppModel(useOldParamId));
1203 + _models[1]->LoadAssets(modelPath.c_str(), modelJsonName.c_str());
1204 _models[1]->GetModelMatrix()->TranslateX(0.2f);
1207 + float clearColor[3] = { 1.0f, 1.0f, 1.0f };
1209 LAppDelegate::GetInstance()->GetView()->SwitchRenderingTarget(useRenderTarget);
1211 - // 別レンダリング先を選択した際の背景クリア色
1212 - float clearColor[3] = { 1.0f, 1.0f, 1.0f };
1213 - LAppDelegate::GetInstance()->GetView()->SetRenderTargetClearColor(clearColor[0], clearColor[1], clearColor[2]);
1214 + if(useRenderTarget)
1216 + LAppDelegate::GetInstance()->GetView()->SwitchRenderingTarget(useRenderTarget);
1218 + LAppDelegate::GetInstance()->GetView()->SetRenderTargetClearColor(clearColor[0], clearColor[1], clearColor[2]);
1223 @@ -292,3 +206,20 @@ void LAppLive2DManager::SetViewMatrix(Cu
1224 _viewMatrix->GetArray()[i] = m->GetArray()[i];
1228 +void LAppLive2DManager::SetFacialLandmarkDetector(FacialLandmarkDetector *detector)
1230 + for (auto it = _models.Begin(); it != _models.End(); ++it)
1232 + (*it)->SetFacialLandmarkDetector(detector);
1236 +void LAppLive2DManager::SetProjectionScaleTranslate(float scaleFactor,
1240 + _projScaleFactor = scaleFactor;
1241 + _translateX = translateX;
1242 + _translateY = translateY;
1244 diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.hpp ./demo_dev/src/LAppLive2DManager.hpp
1245 --- ./demo_clean/src/LAppLive2DManager.hpp 2024-03-28 18:19:04.607350600 +0000
1246 +++ ./demo_dev/src/LAppLive2DManager.hpp 2023-03-05 23:22:10.829032000 +0000
1250 * Copyright(c) Live2D Inc. All rights reserved.
1252 * Use of this source code is governed by the Live2D Open Software license
1253 * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
1259 #include <CubismFramework.hpp>
1260 #include <Math/CubismMatrix44.hpp>
1261 #include <Type/csmVector.hpp>
1265 +class FacialLandmarkDetector;
1268 * @brief サンプルアプリケーションにおいてCubismModelを管理するクラス<br>
1269 * モデル生成と破棄、タップイベントの処理、モデル切り替えを行う。
1270 @@ -37,24 +39,6 @@ public:
1271 static void ReleaseInstance();
1274 - * @brief Resources フォルダにあるモデルフォルダ名をセットする
1277 - void SetUpModel();
1280 - * @brief Resources フォルダにあるモデルフォルダ名を取得する
1283 - Csm::csmVector<Csm::csmString> GetModelDir() const;
1286 - * @brief Resources フォルダにあるモデルフォルダのサイズを取得する
1289 - Csm::csmInt32 GetModelDirSize() const;
1292 * @brief 現在のシーンで保持しているモデルを返す
1294 * @param[in] no モデルリストのインデックス値
1295 @@ -91,16 +75,14 @@ public:
1296 void OnUpdate() const;
1299 - * @brief 次のシーンに切り替える<br>
1300 - * サンプルアプリケーションではモデルセットの切り替えを行う。
1305 - * @brief シーンを切り替える<br>
1306 - * サンプルアプリケーションではモデルセットの切り替えを行う。
1308 - void ChangeScene(Csm::csmInt32 index);
1309 + * @brief Set model data
1311 + * @param[in] modelName : Name of model, should be the same for both
1312 + * the directory and the model3.json file
1313 + * @param[in] useOldParamId : If true, translate new (Cubism 3+)
1314 + * parameter IDs to old (Cubism 2.1) ones
1316 + void SetModel(std::string modelName, bool useOldParamId);
1320 @@ -113,6 +95,24 @@ public:
1322 void SetViewMatrix(Live2D::Cubism::Framework::CubismMatrix44* m);
1325 + * @brief Set the pointer to the FacialLandmarkDetector instance
1327 + * @param[in] detector : Pointer to FacialLandmarkDetector instance
1329 + void SetFacialLandmarkDetector(FacialLandmarkDetector *detector);
1332 + * @brief Set projection scale factor and translation parameters
1334 + * @param[in] scaleFactor : Scale factor applied in both X and Y directions
1335 + * @param[in] translateX : Translation in X direction
1336 + * @param[in] translateY : Translation in Y direction
1338 + void SetProjectionScaleTranslate(float scaleFactor,
1340 + float translateY);
1345 @@ -124,9 +124,10 @@ private:
1347 virtual ~LAppLive2DManager();
1349 - Csm::CubismMatrix44* _viewMatrix; ///< モデル描画に用いるView行列
1350 - Csm::csmVector<LAppModel*> _models; ///< モデルインスタンスのコンテナ
1351 - Csm::csmInt32 _sceneIndex; ///< 表示するシーンのインデックス値
1352 + Csm::CubismMatrix44* _viewMatrix; ///< モデル描画に用いるView行列
1353 + Csm::csmVector<LAppModel*> _models; ///< モデルインスタンスのコンテナ
1355 - Csm::csmVector<Csm::csmString> _modelDir; ///< モデルディレクトリ名のコンテナ
1356 + float _projScaleFactor;
1357 + float _translateX;
1358 + float _translateY;
1360 diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppModel.cpp
1361 --- ./demo_clean/src/LAppModel.cpp 2024-03-28 18:19:04.524642700 +0000
1362 +++ ./demo_dev/src/LAppModel.cpp 2024-03-28 18:26:32.604595000 +0000
1366 * Copyright(c) Live2D Inc. All rights reserved.
1368 * Use of this source code is governed by the Live2D Open Software license
1370 #include "LAppTextureManager.hpp"
1371 #include "LAppDelegate.hpp"
1373 +#include "facial_landmark_detector.h"
1375 using namespace Live2D::Cubism::Framework;
1376 using namespace Live2D::Cubism::Framework::DefaultParameterId;
1377 using namespace LAppDefine;
1378 @@ -30,7 +32,7 @@ namespace {
1382 - LAppPal::PrintLogLn("[APP]create buffer: %s ", path);
1383 + LAppPal::PrintLog("[APP]create buffer: %s ", path);
1385 return LAppPal::LoadFileAsBytes(path, size);
1387 @@ -39,33 +41,30 @@ namespace {
1391 - LAppPal::PrintLogLn("[APP]delete buffer: %s", path);
1392 + LAppPal::PrintLog("[APP]delete buffer: %s", path);
1394 LAppPal::ReleaseBytes(buffer);
1398 -LAppModel::LAppModel()
1399 +LAppModel::LAppModel(bool useOldParamId)
1401 , _modelSetting(NULL)
1402 , _userTimeSeconds(0.0f)
1403 + , _detector(nullptr)
1404 + , _useOldParamId(useOldParamId)
1406 - if (MocConsistencyValidationEnable)
1408 - _mocConsistency = true;
1416 - _idParamAngleX = CubismFramework::GetIdManager()->GetId(ParamAngleX);
1417 - _idParamAngleY = CubismFramework::GetIdManager()->GetId(ParamAngleY);
1418 - _idParamAngleZ = CubismFramework::GetIdManager()->GetId(ParamAngleZ);
1419 - _idParamBodyAngleX = CubismFramework::GetIdManager()->GetId(ParamBodyAngleX);
1420 - _idParamEyeBallX = CubismFramework::GetIdManager()->GetId(ParamEyeBallX);
1421 - _idParamEyeBallY = CubismFramework::GetIdManager()->GetId(ParamEyeBallY);
1422 + _idParamAngleX = CubismFramework::GetIdManager()->GetId(_(ParamAngleX));
1423 + _idParamAngleY = CubismFramework::GetIdManager()->GetId(_(ParamAngleY));
1424 + _idParamAngleZ = CubismFramework::GetIdManager()->GetId(_(ParamAngleZ));
1425 + _idParamBodyAngleX = CubismFramework::GetIdManager()->GetId(_(ParamBodyAngleX));
1426 + _idParamEyeBallX = CubismFramework::GetIdManager()->GetId(_(ParamEyeBallX));
1427 + _idParamEyeBallY = CubismFramework::GetIdManager()->GetId(_(ParamEyeBallY));
1430 LAppModel::~LAppModel()
1431 @@ -89,7 +88,7 @@ void LAppModel::LoadAssets(const csmChar
1435 - LAppPal::PrintLogLn("[APP]load model setting: %s", fileName);
1436 + LAppPal::PrintLog("[APP]load model setting: %s", fileName);
1440 @@ -101,17 +100,12 @@ void LAppModel::LoadAssets(const csmChar
1442 SetupModel(setting);
1444 - if (_model == NULL)
1446 - LAppPal::PrintLogLn("Failed to LoadAssets().");
1456 void LAppModel::SetupModel(ICubismModelSetting* setting)
1459 @@ -130,41 +124,14 @@ void LAppModel::SetupModel(ICubismModelS
1463 - LAppPal::PrintLogLn("[APP]create model: %s", setting->GetModelFileName());
1464 + LAppPal::PrintLog("[APP]create model: %s", setting->GetModelFileName());
1467 buffer = CreateBuffer(path.GetRawString(), &size);
1468 - LoadModel(buffer, size, _mocConsistency);
1469 + LoadModel(buffer, size);
1470 DeleteBuffer(buffer, path.GetRawString());
1474 - if (_modelSetting->GetExpressionCount() > 0)
1476 - const csmInt32 count = _modelSetting->GetExpressionCount();
1477 - for (csmInt32 i = 0; i < count; i++)
1479 - csmString name = _modelSetting->GetExpressionName(i);
1480 - csmString path = _modelSetting->GetExpressionFileName(i);
1481 - path = _modelHomeDir + path;
1483 - buffer = CreateBuffer(path.GetRawString(), &size);
1484 - ACubismMotion* motion = LoadExpression(buffer, size, name.GetRawString());
1488 - if (_expressions[name] != NULL)
1490 - ACubismMotion::Delete(_expressions[name]);
1491 - _expressions[name] = NULL;
1493 - _expressions[name] = motion;
1496 - DeleteBuffer(buffer, path.GetRawString());
1501 if (strcmp(_modelSetting->GetPhysicsFileName(), "") != 0)
1503 @@ -203,7 +170,7 @@ void LAppModel::SetupModel(ICubismModelS
1504 breathParameters.PushBack(CubismBreath::BreathParameterData(_idParamAngleY, 0.0f, 8.0f, 3.5345f, 0.5f));
1505 breathParameters.PushBack(CubismBreath::BreathParameterData(_idParamAngleZ, 0.0f, 10.0f, 5.5345f, 0.5f));
1506 breathParameters.PushBack(CubismBreath::BreathParameterData(_idParamBodyAngleX, 0.0f, 4.0f, 15.5345f, 0.5f));
1507 - breathParameters.PushBack(CubismBreath::BreathParameterData(CubismFramework::GetIdManager()->GetId(ParamBreath), 0.5f, 0.5f, 3.2345f, 0.5f));
1508 + breathParameters.PushBack(CubismBreath::BreathParameterData(CubismFramework::GetIdManager()->GetId(_(ParamBreath)), 0.5f, 0.5f, 3.2345f, 0.5f));
1510 _breath->SetParameters(breathParameters);
1512 @@ -227,21 +194,6 @@ void LAppModel::SetupModel(ICubismModelS
1518 - csmInt32 lipSyncIdCount = _modelSetting->GetLipSyncParameterCount();
1519 - for (csmInt32 i = 0; i < lipSyncIdCount; ++i)
1521 - _lipSyncIds.PushBack(_modelSetting->GetLipSyncParameterId(i));
1525 - if (_modelSetting == NULL || _modelMatrix == NULL)
1527 - LAppPal::PrintLogLn("Failed to SetupModel().");
1532 csmMap<csmString, csmFloat32> layout;
1533 _modelSetting->GetLayoutMap(layout);
1534 @@ -274,7 +226,7 @@ void LAppModel::PreloadMotionGroup(const
1538 - LAppPal::PrintLogLn("[APP]load motion: %s => [%s_%d] ", path.GetRawString(), group, i);
1539 + LAppPal::PrintLog("[APP]load motion: %s => [%s_%d] ", path.GetRawString(), group, i);
1543 @@ -282,27 +234,24 @@ void LAppModel::PreloadMotionGroup(const
1544 buffer = CreateBuffer(path.GetRawString(), &size);
1545 CubismMotion* tmpMotion = static_cast<CubismMotion*>(LoadMotion(buffer, size, name.GetRawString()));
1548 + csmFloat32 fadeTime = _modelSetting->GetMotionFadeInTimeValue(group, i);
1549 + if (fadeTime >= 0.0f)
1551 - csmFloat32 fadeTime = _modelSetting->GetMotionFadeInTimeValue(group, i);
1552 - if (fadeTime >= 0.0f)
1554 - tmpMotion->SetFadeInTime(fadeTime);
1556 + tmpMotion->SetFadeInTime(fadeTime);
1559 - fadeTime = _modelSetting->GetMotionFadeOutTimeValue(group, i);
1560 - if (fadeTime >= 0.0f)
1562 - tmpMotion->SetFadeOutTime(fadeTime);
1564 - tmpMotion->SetEffectIds(_eyeBlinkIds, _lipSyncIds);
1565 + fadeTime = _modelSetting->GetMotionFadeOutTimeValue(group, i);
1566 + if (fadeTime >= 0.0f)
1568 + tmpMotion->SetFadeOutTime(fadeTime);
1570 + tmpMotion->SetEffectIds(_eyeBlinkIds, _lipSyncIds);
1572 - if (_motions[name] != NULL)
1574 - ACubismMotion::Delete(_motions[name]);
1576 - _motions[name] = tmpMotion;
1577 + if (_motions[name] != NULL)
1579 + ACubismMotion::Delete(_motions[name]);
1581 + _motions[name] = tmpMotion;
1583 DeleteBuffer(buffer, path.GetRawString());
1585 @@ -357,62 +306,57 @@ void LAppModel::Update()
1586 const csmFloat32 deltaTimeSeconds = LAppPal::GetDeltaTime();
1587 _userTimeSeconds += deltaTimeSeconds;
1589 - _dragManager->Update(deltaTimeSeconds);
1590 - _dragX = _dragManager->GetX();
1591 - _dragY = _dragManager->GetY();
1593 - // モーションによるパラメータ更新の有無
1594 - csmBool motionUpdated = false;
1596 - //-----------------------------------------------------------------
1597 - _model->LoadParameters(); // 前回セーブされた状態をロード
1598 - if (_motionManager->IsFinished())
1600 - // モーションの再生がない場合、待機モーションの中からランダムで再生する
1601 - StartRandomMotion(MotionGroupIdle, PriorityIdle);
1606 - motionUpdated = _motionManager->UpdateMotion(_model, deltaTimeSeconds); // モーションを更新
1608 - _model->SaveParameters(); // 状態を保存
1609 - //-----------------------------------------------------------------
1612 - _opacity = _model->GetModelOpacity();
1613 + auto idMan = CubismFramework::GetIdManager();
1614 + auto params = _detector->getParams();
1617 - if (!motionUpdated)
1619 - if (_eyeBlink != NULL)
1620 + // NOTE: Apparently, this LoadParameters/SaveParameters pair
1621 + // is needed for auto breath to work.
1622 + _model->LoadParameters(); // 前回セーブされた状態をロード
1623 + if (_motionManager->IsFinished() && params.randomMotion)
1625 - // メインモーションの更新がないとき
1626 - _eyeBlink->UpdateParameters(_model, deltaTimeSeconds); // 目パチ
1627 + // モーションの再生がない場合、待機モーションの中からランダムで再生する
1628 + StartRandomMotion(MotionGroupIdle, PriorityIdle);
1632 - if (_expressionManager != NULL)
1634 - _expressionManager->UpdateMotion(_model, deltaTimeSeconds); // 表情でパラメータ更新(相対変化)
1639 - _model->AddParameterValue(_idParamAngleX, _dragX * 30); // -30から30の値を加える
1640 - _model->AddParameterValue(_idParamAngleY, _dragY * 30);
1641 - _model->AddParameterValue(_idParamAngleZ, _dragX * _dragY * -30);
1644 - _model->AddParameterValue(_idParamBodyAngleX, _dragX * 10); // -10から10の値を加える
1647 + _motionManager->UpdateMotion(_model, deltaTimeSeconds); // モーションを更新
1649 + _model->SaveParameters(); // 状態を保存
1652 - _model->AddParameterValue(_idParamEyeBallX, _dragX); // -1から1の値を加える
1653 - _model->AddParameterValue(_idParamEyeBallY, _dragY);
1656 - if (_breath != NULL)
1658 - _breath->UpdateParameters(_model, deltaTimeSeconds);
1659 + if (params.autoBlink && _eyeBlink)
1661 + _eyeBlink->UpdateParameters(_model, deltaTimeSeconds);
1665 + _model->SetParameterValue(idMan->GetId(_("ParamEyeLOpen")),
1666 + params.leftEyeOpenness);
1667 + _model->SetParameterValue(idMan->GetId(_("ParamEyeROpen")),
1668 + params.rightEyeOpenness);
1670 + _model->SetParameterValue(idMan->GetId(_("ParamMouthForm")),
1671 + params.mouthForm);
1672 + _model->SetParameterValue(idMan->GetId(_("ParamMouthOpenY")),
1673 + params.mouthOpenness);
1674 + _model->SetParameterValue(idMan->GetId(_("ParamEyeLSmile")),
1675 + params.leftEyeSmile);
1676 + _model->SetParameterValue(idMan->GetId(_("ParamEyeRSmile")),
1677 + params.rightEyeSmile);
1678 + _model->SetParameterValue(idMan->GetId(_("ParamAngleX")),
1679 + params.faceXAngle);
1680 + _model->SetParameterValue(idMan->GetId(_("ParamAngleY")),
1681 + params.faceYAngle);
1682 + _model->SetParameterValue(idMan->GetId(_("ParamAngleZ")),
1683 + params.faceZAngle);
1684 + if (params.autoBreath && _breath)
1686 + // Note: _model->LoadParameters and SaveParameters is needed
1687 + // before - see above.
1688 + _breath->UpdateParameters(_model, deltaTimeSeconds);
1693 @@ -421,22 +365,6 @@ void LAppModel::Update()
1694 _physics->Evaluate(_model, deltaTimeSeconds);
1700 - // リアルタイムでリップシンクを行う場合、システムから音量を取得して0〜1の範囲で値を入力します。
1701 - csmFloat32 value = 0.0f;
1704 - _wavFileHandler.Update(deltaTimeSeconds);
1705 - value = _wavFileHandler.GetRms();
1707 - for (csmUint32 i = 0; i < _lipSyncIds.GetSize(); ++i)
1709 - _model->AddParameterValue(_lipSyncIds[i], value, 0.8f);
1716 @@ -457,7 +385,7 @@ CubismMotionQueueEntryHandle LAppModel::
1720 - LAppPal::PrintLogLn("[APP]can't start motion.");
1721 + LAppPal::PrintLog("[APP]can't start motion.");
1723 return InvalidMotionQueueEntryHandleValue;
1725 @@ -478,23 +406,19 @@ CubismMotionQueueEntryHandle LAppModel::
1727 buffer = CreateBuffer(path.GetRawString(), &size);
1728 motion = static_cast<CubismMotion*>(LoadMotion(buffer, size, NULL, onFinishedMotionHandler));
1731 + csmFloat32 fadeTime = _modelSetting->GetMotionFadeInTimeValue(group, no);
1732 + if (fadeTime >= 0.0f)
1734 - csmFloat32 fadeTime = _modelSetting->GetMotionFadeInTimeValue(group, no);
1735 - if (fadeTime >= 0.0f)
1737 - motion->SetFadeInTime(fadeTime);
1739 + motion->SetFadeInTime(fadeTime);
1742 - fadeTime = _modelSetting->GetMotionFadeOutTimeValue(group, no);
1743 - if (fadeTime >= 0.0f)
1745 - motion->SetFadeOutTime(fadeTime);
1747 - motion->SetEffectIds(_eyeBlinkIds, _lipSyncIds);
1748 - autoDelete = true; // 終了時にメモリから削除
1749 + fadeTime = _modelSetting->GetMotionFadeOutTimeValue(group, no);
1750 + if (fadeTime >= 0.0f)
1752 + motion->SetFadeOutTime(fadeTime);
1754 + motion->SetEffectIds(_eyeBlinkIds, _lipSyncIds);
1755 + autoDelete = true; // 終了時にメモリから削除
1757 DeleteBuffer(buffer, path.GetRawString());
1759 @@ -509,12 +433,11 @@ CubismMotionQueueEntryHandle LAppModel::
1761 csmString path = voice;
1762 path = _modelHomeDir + path;
1763 - _wavFileHandler.Start(path);
1768 - LAppPal::PrintLogLn("[APP]start motion: [%s_%d]", group, no);
1769 + LAppPal::PrintLog("[APP]start motion: [%s_%d]", group, no);
1771 return _motionManager->StartMotionPriority(motion, autoDelete, priority);
1773 @@ -579,7 +502,7 @@ void LAppModel::SetExpression(const csmC
1774 ACubismMotion* motion = _expressions[expressionID];
1777 - LAppPal::PrintLogLn("[APP]expression: [%s]", expressionID);
1778 + LAppPal::PrintLog("[APP]expression: [%s]", expressionID);
1782 @@ -588,7 +511,7 @@ void LAppModel::SetExpression(const csmC
1786 - if (_debugMode) LAppPal::PrintLogLn("[APP]expression[%s] is null ", expressionID);
1787 + if (_debugMode) LAppPal::PrintLog("[APP]expression[%s] is null ", expressionID);
1791 @@ -662,29 +585,36 @@ Csm::Rendering::CubismOffscreenSurface_O
1792 return _renderBuffer;
1795 -csmBool LAppModel::HasMocConsistencyFromFile(const csmChar* mocFileName)
1796 +void LAppModel::SetFacialLandmarkDetector(FacialLandmarkDetector *detector)
1798 - CSM_ASSERT(strcmp(mocFileName, ""));
1803 - csmString path = mocFileName;
1804 - path = _modelHomeDir + path;
1806 - buffer = CreateBuffer(path.GetRawString(), &size);
1807 + _detector = detector;
1810 - csmBool consistency = CubismMoc::HasMocConsistencyFromUnrevivedMoc(buffer, size);
1812 +Csm::csmString LAppModel::_(std::string s)
1815 + if (_useOldParamId)
1817 - CubismLogInfo("Inconsistent MOC3.");
1818 + if (s == "ParamTere")
1820 + ans = "PARAM_CHEEK";
1824 + for (size_t i = 0; i < s.size(); i++)
1826 + if (std::isupper(s[i]) && i != 0)
1830 + ans += std::toupper(s[i]);
1836 - CubismLogInfo("Consistent MOC3.");
1840 - DeleteBuffer(buffer);
1842 - return consistency;
1843 + return csmString(ans.c_str());
1846 diff -pruN --exclude build ./demo_clean/src/LAppModel.hpp ./demo_dev/src/LAppModel.hpp
1847 --- ./demo_clean/src/LAppModel.hpp 2024-03-28 18:19:04.414826700 +0000
1848 +++ ./demo_dev/src/LAppModel.hpp 2024-03-28 18:25:30.566916900 +0000
1852 * Copyright(c) Live2D Inc. All rights reserved.
1854 * Use of this source code is governed by the Live2D Open Software license
1856 #include <Type/csmRectF.hpp>
1857 #include <Rendering/OpenGL/CubismOffscreenSurface_OpenGLES2.hpp>
1859 -#include "LAppWavFileHandler.hpp"
1860 +#include "facial_landmark_detector.h"
1863 * @brief ユーザーが実際に使用するモデルの実装クラス<br>
1864 @@ -25,8 +25,11 @@ class LAppModel : public Csm::CubismUser
1869 + * @param[in] useOldParamId : If true, translate new (Cubism 3+)
1870 + * parameter IDs to old (Cubism 2.1) ones
1873 + LAppModel(bool useOldParamId);
1877 @@ -115,12 +118,11 @@ public:
1878 Csm::Rendering::CubismOffscreenSurface_OpenGLES2& GetRenderBuffer();
1881 - * @brief .moc3ファイルの整合性をチェックする
1882 + * @brief Set the pointer to the FacialLandmarkDetector instance
1884 - * @param[in] mocName MOC3ファイル名
1885 - * @return MOC3に整合性があれば'true'、そうでなければ'false'。
1886 + * @param[in] detector : Pointer to FacialLandmarkDetector instance
1888 - Csm::csmBool HasMocConsistencyFromFile(const Csm::csmChar* mocFileName);
1889 + void SetFacialLandmarkDetector(FacialLandmarkDetector *detector);
1893 @@ -175,6 +177,17 @@ private:
1895 void ReleaseExpressions();
1898 + * @brief Translate new (Cubism 3+) parameter IDs to old (Cubism 2.1) ones
1900 + * @param[in] s : New parameter ID
1902 + * @return Old parameter ID
1904 + Csm::csmString _(std::string s);
1906 + bool _useOldParamId;
1908 Csm::ICubismModelSetting* _modelSetting; ///< モデルセッティング情報
1909 Csm::csmString _modelHomeDir; ///< モデルセッティングが置かれたディレクトリ
1910 Csm::csmFloat32 _userTimeSeconds; ///< デルタ時間の積算値[秒]
1911 @@ -191,7 +204,10 @@ private:
1912 const Csm::CubismId* _idParamEyeBallX; ///< パラメータID: ParamEyeBallX
1913 const Csm::CubismId* _idParamEyeBallY; ///< パラメータID: ParamEyeBallXY
1915 - LAppWavFileHandler _wavFileHandler; ///< wavファイルハンドラ
1916 + Csm::Rendering::CubismOffscreenSurface_OpenGLES2 _renderBuffer; ///< フレームバッファ以外の描画先
1918 - Csm::Rendering::CubismOffscreenSurface_OpenGLES2 _renderBuffer; ///< フレームバッファ以外の描画先
1919 + FacialLandmarkDetector *_detector;
1924 diff -pruN --exclude build ./demo_clean/src/LAppPal.cpp ./demo_dev/src/LAppPal.cpp
1925 --- ./demo_clean/src/LAppPal.cpp 2024-03-28 18:19:04.037915500 +0000
1926 +++ ./demo_dev/src/LAppPal.cpp 2023-03-05 23:22:10.834981800 +0000
1930 * Copyright(c) Live2D Inc. All rights reserved.
1932 * Use of this source code is governed by the Live2D Open Software license
1936 #include "LAppPal.hpp"
1938 +#include <stdexcept>
1940 +#include <stdlib.h>
1942 #include <sys/stat.h>
1944 @@ -35,37 +37,18 @@ csmByte* LAppPal::LoadFileAsBytes(const
1945 if (stat(path, &statBuf) == 0)
1947 size = statBuf.st_size;
1951 - if (DebugLogEnable)
1953 - PrintLogLn("Stat succeeded but file size is zero. path:%s", path);
1960 - if (DebugLogEnable)
1962 - PrintLogLn("Stat failed. errno:%d path:%s", errno, path);
1969 + char* buf = new char[size];
1971 file.open(path, std::ios::in | std::ios::binary);
1972 if (!file.is_open())
1974 - if (DebugLogEnable)
1976 - PrintLogLn("File open failed. path:%s", path);
1978 + throw std::runtime_error("Failed to open file " + filePath);
1982 - char* buf = new char[size];
1983 file.read(buf, size);
1986 @@ -95,28 +78,8 @@ void LAppPal::PrintLog(const csmChar* fo
1989 va_start(args, format);
1990 - vsnprintf_s(buf, sizeof(buf), format, args); // 標準出力でレンダリング
1991 -#ifdef CSM_DEBUG_MEMORY_LEAKING
1992 -// メモリリークチェック時は大量の標準出力がはしり重いのでprintfを利用する
2000 -void LAppPal::PrintLogLn(const Csm::csmChar* format, ...)
2004 - va_start(args, format);
2005 - vsnprintf_s(buf, sizeof(buf), format, args); // 標準出力でレンダリング
2006 -#ifdef CSM_DEBUG_MEMORY_LEAKING
2007 - // メモリリークチェック時は大量の標準出力がはしり重いのでprintfを利用する
2008 - std::printf("%s\n", buf);
2010 - std::cout << buf << std::endl;
2012 + vsnprintf(buf, sizeof(buf), format, args); // 標準出力でレンダリング
2013 + std::cerr << buf << std::endl;
2017 @@ -124,8 +87,3 @@ void LAppPal::PrintMessage(const csmChar
2019 PrintLog("%s", message);
2022 -void LAppPal::PrintMessageLn(const csmChar* message)
2024 - PrintLogLn("%s", message);
2026 diff -pruN --exclude build ./demo_clean/src/LAppPal.hpp ./demo_dev/src/LAppPal.hpp
2027 --- ./demo_clean/src/LAppPal.hpp 2024-03-28 18:19:03.957378000 +0000
2028 +++ ./demo_dev/src/LAppPal.hpp 2023-03-05 23:22:10.939820800 +0000
2032 * Copyright(c) Live2D Inc. All rights reserved.
2034 * Use of this source code is governed by the Live2D Open Software license
2038 #include <CubismFramework.hpp>
2043 @@ -62,17 +63,6 @@ public:
2044 static void PrintLog(const Csm::csmChar* format, ...);
2047 - * @brief ログを出力し最後に改行する
2051 - * @param[in] format 書式付文字列
2052 - * @param[in] ... (可変長引数)文字列
2055 - static void PrintLogLn(const Csm::csmChar* format, ...);
2061 @@ -82,16 +72,6 @@ public:
2063 static void PrintMessage(const Csm::csmChar* message);
2066 - * @brief メッセージを出力し最後に改行する
2068 - * メッセージを出力し最後に改行する
2070 - * @param[in] message 文字列
2073 - static void PrintMessageLn(const Csm::csmChar* message);
2076 static double s_currentFrame;
2077 static double s_lastFrame;
2078 diff -pruN --exclude build ./demo_clean/src/LAppSprite.cpp ./demo_dev/src/LAppSprite.cpp
2079 --- ./demo_clean/src/LAppSprite.cpp 2024-03-28 18:19:04.304960000 +0000
2080 +++ ./demo_dev/src/LAppSprite.cpp 2023-03-05 23:22:10.900085700 +0000
2084 * Copyright(c) Live2D Inc. All rights reserved.
2086 * Use of this source code is governed by the Live2D Open Software license
2090 #include "LAppSprite.hpp"
2091 +#include "LAppDelegate.hpp"
2093 LAppSprite::LAppSprite(float x, float y, float width, float height, GLuint textureId, GLuint programId)
2095 @@ -34,10 +35,13 @@ LAppSprite::~LAppSprite()
2097 void LAppSprite::Render() const
2100 + int maxWidth, maxHeight;
2101 + glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &maxWidth, &maxHeight);
2103 - if (_maxWidth == 0 || _maxHeight == 0)
2104 + if(maxWidth==0 || maxHeight==0)
2106 - return; // この際は描画できず
2110 const GLfloat uvVertex[] =
2111 @@ -58,10 +62,10 @@ void LAppSprite::Render() const
2113 float positionVertex[] =
2115 - (_rect.right - _maxWidth * 0.5f) / (_maxWidth * 0.5f), (_rect.up - _maxHeight * 0.5f) / (_maxHeight * 0.5f),
2116 - (_rect.left - _maxWidth * 0.5f) / (_maxWidth * 0.5f), (_rect.up - _maxHeight * 0.5f) / (_maxHeight * 0.5f),
2117 - (_rect.left - _maxWidth * 0.5f) / (_maxWidth * 0.5f), (_rect.down - _maxHeight * 0.5f) / (_maxHeight * 0.5f),
2118 - (_rect.right - _maxWidth * 0.5f) / (_maxWidth * 0.5f), (_rect.down - _maxHeight * 0.5f) / (_maxHeight * 0.5f)
2119 + (_rect.right - maxWidth * 0.5f) / (maxWidth * 0.5f), (_rect.up - maxHeight * 0.5f) / (maxHeight * 0.5f),
2120 + (_rect.left - maxWidth * 0.5f) / (maxWidth * 0.5f), (_rect.up - maxHeight * 0.5f) / (maxHeight * 0.5f),
2121 + (_rect.left - maxWidth * 0.5f) / (maxWidth * 0.5f), (_rect.down - maxHeight * 0.5f) / (maxHeight * 0.5f),
2122 + (_rect.right - maxWidth * 0.5f) / (maxWidth * 0.5f), (_rect.down - maxHeight * 0.5f) / (maxHeight * 0.5f)
2126 @@ -70,7 +74,6 @@ void LAppSprite::Render() const
2128 glUniform4f(_colorLocation, _spriteColor[0], _spriteColor[1], _spriteColor[2], _spriteColor[3]);
2132 glBindTexture(GL_TEXTURE_2D, _textureId);
2133 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
2134 @@ -78,9 +81,13 @@ void LAppSprite::Render() const
2136 void LAppSprite::RenderImmidiate(GLuint textureId, const GLfloat uvVertex[8]) const
2138 - if (_maxWidth == 0 || _maxHeight == 0)
2140 + int maxWidth, maxHeight;
2141 + glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &maxWidth, &maxHeight);
2143 + if(maxWidth==0 || maxHeight==0)
2145 - return; // この際は描画できず
2149 // attribute属性を有効にする
2150 @@ -93,10 +100,10 @@ void LAppSprite::RenderImmidiate(GLuint
2152 float positionVertex[] =
2154 - (_rect.right - _maxWidth * 0.5f) / (_maxWidth * 0.5f), (_rect.up - _maxHeight * 0.5f) / (_maxHeight * 0.5f),
2155 - (_rect.left - _maxWidth * 0.5f) / (_maxWidth * 0.5f), (_rect.up - _maxHeight * 0.5f) / (_maxHeight * 0.5f),
2156 - (_rect.left - _maxWidth * 0.5f) / (_maxWidth * 0.5f), (_rect.down - _maxHeight * 0.5f) / (_maxHeight * 0.5f),
2157 - (_rect.right - _maxWidth * 0.5f) / (_maxWidth * 0.5f), (_rect.down - _maxHeight * 0.5f) / (_maxHeight * 0.5f)
2158 + (_rect.right - maxWidth * 0.5f) / (maxWidth * 0.5f), (_rect.up - maxHeight * 0.5f) / (maxHeight * 0.5f),
2159 + (_rect.left - maxWidth * 0.5f) / (maxWidth * 0.5f), (_rect.up - maxHeight * 0.5f) / (maxHeight * 0.5f),
2160 + (_rect.left - maxWidth * 0.5f) / (maxWidth * 0.5f), (_rect.down - maxHeight * 0.5f) / (maxHeight * 0.5f),
2161 + (_rect.right - maxWidth * 0.5f) / (maxWidth * 0.5f), (_rect.down - maxHeight * 0.5f) / (maxHeight * 0.5f)
2165 @@ -112,13 +119,16 @@ void LAppSprite::RenderImmidiate(GLuint
2167 bool LAppSprite::IsHit(float pointX, float pointY) const
2169 - if (_maxWidth == 0 || _maxHeight == 0)
2171 + int maxWidth, maxHeight;
2172 + glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &maxWidth, &maxHeight);
2174 + if(maxWidth==0 || maxHeight==0)
2176 - return false; // この際は描画できず
2181 - float y = _maxHeight - pointY;
2182 + float y = maxHeight - pointY;
2184 return (pointX >= _rect.left && pointX <= _rect.right && y <= _rect.up && y >= _rect.down);
2186 @@ -138,9 +148,3 @@ void LAppSprite::ResetRect(float x, floa
2187 _rect.up = (y + height * 0.5f);
2188 _rect.down = (y - height * 0.5f);
2191 -void LAppSprite::SetWindowSize(int width, int height)
2193 - _maxWidth = width;
2194 - _maxHeight = height;
2196 diff -pruN --exclude build ./demo_clean/src/LAppSprite.hpp ./demo_dev/src/LAppSprite.hpp
2197 --- ./demo_clean/src/LAppSprite.hpp 2024-03-28 18:19:03.831886500 +0000
2198 +++ ./demo_dev/src/LAppSprite.hpp 2023-03-05 23:22:10.876156000 +0000
2202 * Copyright(c) Live2D Inc. All rights reserved.
2204 * Use of this source code is governed by the Live2D Open Software license
2205 @@ -61,7 +61,7 @@ public:
2206 void Render() const;
2209 - * @brief テクスチャIDを指定して描画する
2210 + * @brief テクスチャを指定しての描画
2213 void RenderImmidiate(GLuint textureId, const GLfloat uvVertex[8]) const;
2214 @@ -94,24 +94,14 @@ public:
2216 void ResetRect(float x, float y, float width, float height);
2219 - * @brief ウインドウサイズ設定
2221 - * @param[in] width 横幅
2222 - * @param[in] height 高さ
2224 - void SetWindowSize(int width, int height);
2227 - GLuint _textureId; ///< テクスチャID
2228 - Rect _rect; ///< 矩形
2229 + GLuint _textureId; ///< テクスチャID
2230 + Rect _rect; ///< 矩形
2231 int _positionLocation; ///< 位置アトリビュート
2232 int _uvLocation; ///< UVアトリビュート
2233 int _textureLocation; ///< テクスチャアトリビュート
2234 int _colorLocation; ///< カラーアトリビュート
2236 float _spriteColor[4]; ///< 表示カラー
2237 - int _maxWidth; ///< ウインドウ幅
2238 - int _maxHeight; ///< ウインドウ高さ
2241 diff -pruN --exclude build ./demo_clean/src/LAppTextureManager.cpp ./demo_dev/src/LAppTextureManager.cpp
2242 --- ./demo_clean/src/LAppTextureManager.cpp 2024-03-28 18:19:04.226438800 +0000
2243 +++ ./demo_dev/src/LAppTextureManager.cpp 2023-03-05 23:22:10.765166600 +0000
2247 * Copyright(c) Live2D Inc. All rights reserved.
2249 * Use of this source code is governed by the Live2D Open Software license
2251 #define STBI_NO_STDIO
2252 #define STBI_ONLY_PNG
2253 #define STB_IMAGE_IMPLEMENTATION
2254 +#if defined(__clang__)
2255 +#pragma clang diagnostic push
2256 +#pragma clang diagnostic ignored "-Wunused-function"
2258 #include "stb_image.h"
2259 +#if defined(__clang__)
2260 +#pragma clang diagnostic pop
2262 #include "LAppPal.hpp"
2264 LAppTextureManager::LAppTextureManager()
2265 @@ -89,6 +96,46 @@ LAppTextureManager::TextureInfo* LAppTex
2269 +LAppTextureManager::TextureInfo* LAppTextureManager::CreateTextureFromColor(
2270 + uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha
2273 + constexpr int width = 8, height = 8;
2275 + uint8_t pixels[height][width][4];
2276 + for (std::size_t h = 0; h < height; h++)
2278 + for (std::size_t w = 0; w < width; w++)
2280 + pixels[h][w][0] = red;
2281 + pixels[h][w][1] = green;
2282 + pixels[h][w][2] = blue;
2283 + pixels[h][w][3] = alpha;
2288 + glGenTextures(1, &textureId);
2289 + glBindTexture(GL_TEXTURE_2D, textureId);
2290 + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
2292 + glGenerateMipmap(GL_TEXTURE_2D);
2293 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
2294 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
2295 + glBindTexture(GL_TEXTURE_2D, 0);
2298 + LAppTextureManager::TextureInfo* textureInfo = new LAppTextureManager::TextureInfo();
2299 + textureInfo->fileName = "";
2300 + textureInfo->width = width;
2301 + textureInfo->height = height;
2302 + textureInfo->id = textureId;
2304 + _textures.PushBack(textureInfo);
2306 + return textureInfo;
2309 void LAppTextureManager::ReleaseTextures()
2311 for (Csm::csmUint32 i = 0; i < _textures.GetSize(); i++)
2312 diff -pruN --exclude build ./demo_clean/src/LAppTextureManager.hpp ./demo_dev/src/LAppTextureManager.hpp
2313 --- ./demo_clean/src/LAppTextureManager.hpp 2024-03-28 18:19:04.351863200 +0000
2314 +++ ./demo_dev/src/LAppTextureManager.hpp 2023-03-05 23:22:10.822016600 +0000
2318 * Copyright(c) Live2D Inc. All rights reserved.
2320 * Use of this source code is governed by the Live2D Open Software license
2321 @@ -72,6 +72,8 @@ public:
2323 TextureInfo* CreateTextureFromPngFile(std::string fileName);
2325 + TextureInfo *CreateTextureFromColor(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha = 255);
2330 @@ -98,9 +100,9 @@ public:
2332 * @brief テクスチャIDからテクスチャ情報を得る
2334 - * @param textureId[in] 取得したいテクスチャID
2335 - * @return テクスチャが存在していればTextureInfoが返る
2337 + * @param[in] textureId 取得したいテクスチャID
2338 + * @return テクスチャが存在していればTextureInfoが返る
2340 TextureInfo* GetTextureInfoById(GLuint textureId) const;
2343 diff -pruN --exclude build ./demo_clean/src/LAppView.cpp ./demo_dev/src/LAppView.cpp
2344 --- ./demo_clean/src/LAppView.cpp 2024-03-28 18:19:03.722026200 +0000
2345 +++ ./demo_dev/src/LAppView.cpp 2024-03-28 18:26:14.230329000 +0000
2349 * Copyright(c) Live2D Inc. All rights reserved.
2351 * Use of this source code is governed by the Live2D Open Software license
2353 #include "LAppLive2DManager.hpp"
2354 #include "LAppTextureManager.hpp"
2355 #include "LAppDefine.hpp"
2356 -#include "TouchManager.hpp"
2357 #include "LAppSprite.hpp"
2358 #include "LAppModel.hpp"
2360 +#include <Rendering/OpenGL/CubismOffscreenSurface_OpenGLES2.hpp>
2361 +#include <Rendering/OpenGL/CubismRenderer_OpenGLES2.hpp>
2363 using namespace std;
2364 using namespace LAppDefine;
2366 LAppView::LAppView():
2371 _renderSprite(NULL),
2372 _renderTarget(SelectTarget_None)
2374 @@ -33,9 +33,6 @@ LAppView::LAppView():
2375 _clearColor[2] = 1.0f;
2376 _clearColor[3] = 0.0f;
2379 - _touchManager = new TouchManager();
2381 // デバイス座標からスクリーン座標に変換するための
2382 _deviceToScreen = new CubismMatrix44();
2384 @@ -47,12 +44,10 @@ LAppView::~LAppView()
2386 _renderBuffer.DestroyOffscreenSurface();
2387 delete _renderSprite;
2390 delete _deviceToScreen;
2391 - delete _touchManager;
2397 void LAppView::Initialize()
2398 @@ -75,7 +70,7 @@ void LAppView::Initialize()
2399 _viewMatrix->SetScreenRect(left, right, bottom, top); // デバイスに対応する画面の範囲。 Xの左端, Xの右端, Yの下端, Yの上端
2400 _viewMatrix->Scale(ViewScale, ViewScale);
2402 - _deviceToScreen->LoadIdentity(); // サイズが変わった際などリセット必須
2403 + _deviceToScreen->LoadIdentity();
2406 float screenW = fabsf(right - left);
2407 @@ -103,16 +98,7 @@ void LAppView::Initialize()
2409 void LAppView::Render()
2412 - int maxWidth, maxHeight;
2413 - glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &maxWidth, &maxHeight);
2414 - _back->SetWindowSize(maxWidth, maxHeight);
2415 - _gear->SetWindowSize(maxWidth, maxHeight);
2416 - _power->SetWindowSize(maxWidth, maxHeight);
2422 LAppLive2DManager* Live2DManager = LAppLive2DManager::GetInstance();
2424 @@ -132,16 +118,15 @@ void LAppView::Render()
2428 - for (csmUint32 i = 0; i < Live2DManager->GetModelNum(); i++)
2429 + for(csmUint32 i=0; i<Live2DManager->GetModelNum(); i++)
2431 - LAppModel* model = Live2DManager->GetModel(i);
2432 - float alpha = i < 1 ? 1.0f : model->GetOpacity(); // 片方のみ不透明度を取得できるようにする
2433 + float alpha = GetSpriteAlpha(i); // サンプルとしてαに適当な差をつける
2434 _renderSprite->SetColor(1.0f, 1.0f, 1.0f, alpha);
2436 + LAppModel *model = Live2DManager->GetModel(i);
2439 - _renderSprite->SetWindowSize(maxWidth, maxHeight);
2440 - _renderSprite->RenderImmidiate( model->GetRenderBuffer().GetColorBuffer(), uvVertex);
2441 + _renderSprite->RenderImmidiate(model->GetRenderBuffer().GetColorBuffer(), uvVertex);
2445 @@ -155,85 +140,22 @@ void LAppView::InitializeSprite()
2446 glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &width, &height);
2448 LAppTextureManager* textureManager = LAppDelegate::GetInstance()->GetTextureManager();
2449 - const string resourcesPath = ResourcesPath;
2451 - string imageName = BackImageName;
2452 - LAppTextureManager::TextureInfo* backgroundTexture = textureManager->CreateTextureFromPngFile(resourcesPath + imageName);
2454 + LAppTextureManager::TextureInfo* backgroundTexture =
2455 + textureManager->CreateTextureFromColor(0, 255, 0);
2457 float x = width * 0.5f;
2458 float y = height * 0.5f;
2459 - float fWidth = static_cast<float>(backgroundTexture->width * 2.0f);
2460 - float fHeight = static_cast<float>(height * 0.95f);
2461 + float fWidth = static_cast<float>(width);
2462 + float fHeight = static_cast<float>(height);
2463 _back = new LAppSprite(x, y, fWidth, fHeight, backgroundTexture->id, _programId);
2465 - imageName = GearImageName;
2466 - LAppTextureManager::TextureInfo* gearTexture = textureManager->CreateTextureFromPngFile(resourcesPath + imageName);
2468 - x = static_cast<float>(width - gearTexture->width * 0.5f);
2469 - y = static_cast<float>(height - gearTexture->height * 0.5f);
2470 - fWidth = static_cast<float>(gearTexture->width);
2471 - fHeight = static_cast<float>(gearTexture->height);
2472 - _gear = new LAppSprite(x, y, fWidth, fHeight, gearTexture->id, _programId);
2474 - imageName = PowerImageName;
2475 - LAppTextureManager::TextureInfo* powerTexture = textureManager->CreateTextureFromPngFile(resourcesPath + imageName);
2477 - x = static_cast<float>(width - powerTexture->width * 0.5f);
2478 - y = static_cast<float>(powerTexture->height * 0.5f);
2479 - fWidth = static_cast<float>(powerTexture->width);
2480 - fHeight = static_cast<float>(powerTexture->height);
2481 - _power = new LAppSprite(x, y, fWidth, fHeight, powerTexture->id, _programId);
2486 _renderSprite = new LAppSprite(x, y, static_cast<float>(width), static_cast<float>(height), 0, _programId);
2489 -void LAppView::OnTouchesBegan(float px, float py) const
2491 - _touchManager->TouchesBegan(px, py);
2494 -void LAppView::OnTouchesMoved(float px, float py) const
2496 - float viewX = this->TransformViewX(_touchManager->GetX());
2497 - float viewY = this->TransformViewY(_touchManager->GetY());
2499 - _touchManager->TouchesMoved(px, py);
2501 - LAppLive2DManager* Live2DManager = LAppLive2DManager::GetInstance();
2502 - Live2DManager->OnDrag(viewX, viewY);
2505 -void LAppView::OnTouchesEnded(float px, float py) const
2508 - LAppLive2DManager* live2DManager = LAppLive2DManager::GetInstance();
2509 - live2DManager->OnDrag(0.0f, 0.0f);
2513 - float x = _deviceToScreen->TransformX(_touchManager->GetX()); // 論理座標変換した座標を取得。
2514 - float y = _deviceToScreen->TransformY(_touchManager->GetY()); // 論理座標変換した座標を取得。
2515 - if (DebugTouchLogEnable)
2517 - LAppPal::PrintLogLn("[APP]touchesEnded x:%.2f y:%.2f", x, y);
2519 - live2DManager->OnTap(x, y);
2522 - if (_gear->IsHit(px, py))
2524 - live2DManager->NextScene();
2528 - if (_power->IsHit(px, py))
2530 - LAppDelegate::GetInstance()->AppEnd();
2535 float LAppView::TransformViewX(float deviceX) const
2536 @@ -258,7 +180,7 @@ float LAppView::TransformScreenY(float d
2537 return _deviceToScreen->TransformY(deviceY);
2540 -void LAppView::PreModelDraw(LAppModel& refModel)
2541 +void LAppView::PreModelDraw(LAppModel &refModel)
2543 // 別のレンダリングターゲットへ向けて描画する場合の使用するフレームバッファ
2544 Csm::Rendering::CubismOffscreenSurface_OpenGLES2* useTarget = NULL;
2545 @@ -271,12 +193,13 @@ void LAppView::PreModelDraw(LAppModel& r
2547 if (!useTarget->IsValid())
2548 {// 描画ターゲット内部未作成の場合はここで作成
2549 - int width, height;
2550 - glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &width, &height);
2551 - if (width != 0 && height != 0)
2552 + int bufWidth, bufHeight;
2553 + glfwGetFramebufferSize(LAppDelegate::GetInstance()->GetWindow(), &bufWidth, &bufHeight);
2555 + if(bufWidth!=0 && bufHeight!=0)
2558 - useTarget->CreateOffscreenSurface(static_cast<csmUint32>(width), static_cast<csmUint32>(height));
2559 + useTarget->CreateOffscreenSurface(static_cast<csmUint32>(bufWidth), static_cast<csmUint32>(bufHeight));
2563 @@ -286,7 +209,7 @@ void LAppView::PreModelDraw(LAppModel& r
2567 -void LAppView::PostModelDraw(LAppModel& refModel)
2568 +void LAppView::PostModelDraw(LAppModel &refModel)
2570 // 別のレンダリングターゲットへ向けて描画する場合の使用するフレームバッファ
2571 Csm::Rendering::CubismOffscreenSurface_OpenGLES2* useTarget = NULL;
2572 @@ -312,12 +235,6 @@ void LAppView::PostModelDraw(LAppModel&
2575 _renderSprite->SetColor(1.0f, 1.0f, 1.0f, GetSpriteAlpha(0));
2578 - int maxWidth, maxHeight;
2579 - glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &maxWidth, &maxHeight);
2580 - _renderSprite->SetWindowSize(maxWidth, maxHeight);
2582 _renderSprite->RenderImmidiate(useTarget->GetColorBuffer(), uvVertex);
2585 @@ -382,32 +299,4 @@ void LAppView::ResizeSprite()
2586 _back->ResetRect(x, y, fWidth, fHeight);
2592 - GLuint id = _power->GetTextureId();
2593 - LAppTextureManager::TextureInfo* texInfo = textureManager->GetTextureInfoById(id);
2596 - x = static_cast<float>(width - texInfo->width * 0.5f);
2597 - y = static_cast<float>(texInfo->height * 0.5f);
2598 - fWidth = static_cast<float>(texInfo->width);
2599 - fHeight = static_cast<float>(texInfo->height);
2600 - _power->ResetRect(x, y, fWidth, fHeight);
2606 - GLuint id = _gear->GetTextureId();
2607 - LAppTextureManager::TextureInfo* texInfo = textureManager->GetTextureInfoById(id);
2610 - x = static_cast<float>(width - texInfo->width * 0.5f);
2611 - y = static_cast<float>(height - texInfo->height * 0.5f);
2612 - fWidth = static_cast<float>(texInfo->width);
2613 - fHeight = static_cast<float>(texInfo->height);
2614 - _gear->ResetRect(x, y, fWidth, fHeight);
2618 diff -pruN --exclude build ./demo_clean/src/LAppView.hpp ./demo_dev/src/LAppView.hpp
2619 --- ./demo_clean/src/LAppView.hpp 2024-03-28 18:19:03.659043800 +0000
2620 +++ ./demo_dev/src/LAppView.hpp 2024-03-28 18:25:01.124283600 +0000
2624 * Copyright(c) Live2D Inc. All rights reserved.
2626 * Use of this source code is governed by the Live2D Open Software license
2628 #include "CubismFramework.hpp"
2629 #include <Rendering/OpenGL/CubismOffscreenSurface_OpenGLES2.hpp>
2631 -class TouchManager;
2635 @@ -61,35 +60,11 @@ public:
2636 void InitializeSprite();
2639 - * @brief スプライト系のサイズ再設定
2641 + * @brief スプライト系のサイズ再設定
2643 void ResizeSprite();
2646 - * @brief タッチされたときに呼ばれる。
2648 - * @param[in] pointX スクリーンX座標
2649 - * @param[in] pointY スクリーンY座標
2651 - void OnTouchesBegan(float pointX, float pointY) const;
2654 - * @brief タッチしているときにポインタが動いたら呼ばれる。
2656 - * @param[in] pointX スクリーンX座標
2657 - * @param[in] pointY スクリーンY座標
2659 - void OnTouchesMoved(float pointX, float pointY) const;
2662 - * @brief タッチが終了したら呼ばれる。
2664 - * @param[in] pointX スクリーンX座標
2665 - * @param[in] pointY スクリーンY座標
2667 - void OnTouchesEnded(float pointX, float pointY) const;
2670 * @brief X座標をView座標に変換する。
2672 * @param[in] deviceX デバイスX座標
2673 @@ -120,12 +95,12 @@ public:
2675 * @brief モデル1体を描画する直前にコールされる
2677 - void PreModelDraw(LAppModel& refModel);
2678 + void PreModelDraw(LAppModel &refModel);
2681 * @brief モデル1体を描画した直後にコールされる
2683 - void PostModelDraw(LAppModel& refModel);
2684 + void PostModelDraw(LAppModel &refModel);
2687 * @brief 別レンダリングターゲットにモデルを描画するサンプルで
2688 @@ -147,16 +122,13 @@ public:
2689 void SetRenderTargetClearColor(float r, float g, float b);
2692 - TouchManager* _touchManager; ///< タッチマネージャー
2693 Csm::CubismMatrix44* _deviceToScreen; ///< デバイスからスクリーンへの行列
2694 Csm::CubismViewMatrix* _viewMatrix; ///< viewMatrix
2695 GLuint _programId; ///< シェーダID
2696 LAppSprite* _back; ///< 背景画像
2697 - LAppSprite* _gear; ///< ギア画像
2698 - LAppSprite* _power; ///< 電源画像
2700 // レンダリング先を別ターゲットにする方式の場合に使用
2701 - LAppSprite* _renderSprite; ///< モードによっては_renderBufferのテクスチャを描画
2702 + LAppSprite* _renderSprite; ///< モードによっては_renderBufferのテクスチャを描画
2703 Csm::Rendering::CubismOffscreenSurface_OpenGLES2 _renderBuffer; ///< モードによってはCubismモデル結果をこっちにレンダリング
2704 SelectTarget _renderTarget; ///< レンダリング先の選択肢
2705 float _clearColor[4]; ///< レンダリングターゲットのクリアカラー
2706 diff -pruN --exclude build ./demo_clean/src/LAppWavFileHandler.cpp ./demo_dev/src/LAppWavFileHandler.cpp
2707 --- ./demo_clean/src/LAppWavFileHandler.cpp 2024-03-28 18:19:04.555847400 +0000
2708 +++ ./demo_dev/src/LAppWavFileHandler.cpp 2023-03-05 23:22:10.921862800 +0000
2710 #include "LAppPal.hpp"
2712 LAppWavFileHandler::LAppWavFileHandler()
2716 , _userTimeSeconds(0.0f)
2719 @@ -21,11 +20,6 @@ LAppWavFileHandler::LAppWavFileHandler()
2721 LAppWavFileHandler::~LAppWavFileHandler()
2723 - if (_rawData != NULL)
2725 - CSM_FREE(_rawData);
2728 if (_pcmData != NULL)
2731 @@ -91,115 +85,11 @@ Csm::csmFloat32 LAppWavFileHandler::GetR
2735 -const LAppWavFileHandler::WavFileInfo& LAppWavFileHandler::GetWavFileInfo() const
2737 - return _wavFileInfo;
2740 -const Csm::csmByte* LAppWavFileHandler::GetRawData() const
2745 -Csm::csmUint64 LAppWavFileHandler::GetRawDataSize() const
2747 - return _rawDataSize;
2750 -Csm::csmVector<Csm::csmFloat32> LAppWavFileHandler::GetPcmData() const
2752 - Csm::csmVector<Csm::csmFloat32> buffer;
2754 - for (Csm::csmUint32 sampleCount = 0; sampleCount < _wavFileInfo._samplesPerChannel; sampleCount++)
2756 - for (Csm::csmUint32 channelCount = 0; channelCount < _wavFileInfo._numberOfChannels; channelCount++)
2758 - buffer.PushBack(_pcmData[channelCount][sampleCount]);
2765 -void LAppWavFileHandler::GetPcmDataChannel(Csm::csmFloat32* dst, Csm::csmUint32 useChannel) const
2767 - for (Csm::csmUint32 sampleCount = 0; sampleCount < _wavFileInfo._samplesPerChannel; sampleCount++)
2769 - dst[sampleCount] = _pcmData[useChannel][sampleCount];
2773 -Csm::csmFloat32 LAppWavFileHandler::NormalizePcmSample(Csm::csmUint32 bitsPerSample, Csm::csmByte* data, Csm::csmUint32 dataSize)
2775 - Csm::csmInt32 pcm32;
2777 - // 32ビット幅に拡張してから-1~1の範囲に丸める
2778 - switch (bitsPerSample)
2781 - if (1 <= dataSize)
2783 - const Csm::csmUint8 ret = data[0];
2784 - pcm32 = static_cast<Csm::csmInt32>(ret) - 128;
2793 - if (2 <= dataSize)
2795 - const Csm::csmUint16 ret = (data[1] << 8) | data[0];
2796 - pcm32 = ret << 16;
2804 - if (3 <= dataSize)
2806 - const Csm::csmUint32 ret = (data[2] << 16) | (data[1] << 8) | data[0];
2815 - if (4 <= dataSize)
2817 - const Csm::csmUint32 ret = (data[3] << 24) | (data[2] << 16) | (data[1] << 8) | data[0];
2831 - return static_cast<Csm::csmFloat32>(pcm32) / INT32_MAX;
2834 Csm::csmBool LAppWavFileHandler::LoadWavFile(const Csm::csmString& filePath)
2838 // 既にwavファイルロード済みならば領域開放
2839 - if (_rawData != NULL)
2841 - CSM_FREE(_rawData);
2844 if (_pcmData != NULL)
2847 @@ -251,10 +141,10 @@ Csm::csmBool LAppWavFileHandler::LoadWav
2848 _wavFileInfo._numberOfChannels = _byteReader.Get16LittleEndian();
2850 _wavFileInfo._samplingRate = _byteReader.Get32LittleEndian();
2852 - _wavFileInfo._avgBytesPerSec = _byteReader.Get32LittleEndian();
2854 - _wavFileInfo._blockAlign = _byteReader.Get16LittleEndian();
2855 + // データ速度[byte/sec](読み飛ばし)
2856 + _byteReader.Get32LittleEndian();
2858 + _byteReader.Get16LittleEndian();
2860 _wavFileInfo._bitsPerSample = _byteReader.Get16LittleEndian();
2861 // fmtチャンクの拡張部分の読み飛ばし
2862 @@ -280,25 +170,16 @@ Csm::csmBool LAppWavFileHandler::LoadWav
2863 _wavFileInfo._samplesPerChannel = (dataChunkSize * 8) / (_wavFileInfo._bitsPerSample * _wavFileInfo._numberOfChannels);
2866 - _rawDataSize = static_cast<Csm::csmUint64>(_wavFileInfo._blockAlign) * static_cast<Csm::csmUint64>(_wavFileInfo._samplesPerChannel);
2867 - _rawData = static_cast<Csm::csmByte*>(CSM_MALLOC(sizeof(Csm::csmByte) * _rawDataSize));
2868 _pcmData = static_cast<Csm::csmFloat32**>(CSM_MALLOC(sizeof(Csm::csmFloat32*) * _wavFileInfo._numberOfChannels));
2869 for (Csm::csmUint32 channelCount = 0; channelCount < _wavFileInfo._numberOfChannels; channelCount++)
2871 _pcmData[channelCount] = static_cast<Csm::csmFloat32*>(CSM_MALLOC(sizeof(Csm::csmFloat32) * _wavFileInfo._samplesPerChannel));
2874 - Csm::csmUint64 rawPos = 0;
2875 for (Csm::csmUint32 sampleCount = 0; sampleCount < _wavFileInfo._samplesPerChannel; sampleCount++)
2877 for (Csm::csmUint32 channelCount = 0; channelCount < _wavFileInfo._numberOfChannels; channelCount++)
2880 - for (Csm::csmUint32 byteCount = 0; byteCount < _wavFileInfo._bitsPerSample / 8; byteCount++)
2882 - _rawData[rawPos++] = _byteReader._fileByte[_byteReader._readOffset + byteCount];
2885 _pcmData[channelCount][sampleCount] = GetPcmSample();
2888 diff -pruN --exclude build ./demo_clean/src/LAppWavFileHandler.hpp ./demo_dev/src/LAppWavFileHandler.hpp
2889 --- ./demo_clean/src/LAppWavFileHandler.hpp 2024-03-28 18:19:04.132172700 +0000
2890 +++ ./demo_dev/src/LAppWavFileHandler.hpp 2023-03-05 23:22:10.871136700 +0000
2894 #include <CubismFramework.hpp>
2895 -#include <Type/csmVector.hpp>
2896 +#include <Utils/CubismString.hpp>
2899 * @brief wavファイルハンドラ
2900 @@ -18,28 +18,6 @@ class LAppWavFileHandler
2904 - * @brief 読み込んだwavfileの情報
2906 - struct WavFileInfo
2911 - WavFileInfo() : _fileName(""), _numberOfChannels(0),
2912 - _bitsPerSample(0), _samplingRate(0), _samplesPerChannel(0),
2913 - _avgBytesPerSec(0), _blockAlign(0)
2916 - Csm::csmString _fileName; ///< ファイル名
2917 - Csm::csmUint32 _numberOfChannels; ///< チャンネル数
2918 - Csm::csmUint32 _bitsPerSample; ///< サンプルあたりビット数
2919 - Csm::csmUint32 _samplingRate; ///< サンプリングレート
2920 - Csm::csmUint32 _samplesPerChannel; ///< 1チャンネルあたり総サンプル数
2921 - Csm::csmUint32 _avgBytesPerSec; ///< 平均データ速度
2922 - Csm::csmUint32 _blockAlign; ///< ブロックサイズ
2928 LAppWavFileHandler();
2929 @@ -72,53 +50,6 @@ public:
2931 Csm::csmFloat32 GetRms() const;
2934 - * @brief ファイル情報を取得
2938 - const WavFileInfo& GetWavFileInfo() const;
2941 - * @brief 正規化前のデータを取得
2943 - * @retval 正規化前のデータ
2945 - const Csm::csmByte* GetRawData() const;
2948 - * @brief 正規化前のデータの大きさを取得
2950 - * @retval 正規化前のデータの大きさ
2952 - Csm::csmUint64 GetRawDataSize() const;
2955 - * @brief 正規化データを取得する
2959 - Csm::csmVector<Csm::csmFloat32> GetPcmData() const;
2962 - * @brief 引数で指定したチャンネルの正規化データを取得する
2964 - * @param[in] dst 格納先
2965 - * @param[in] useChannel 使用するチャンネル
2967 - void GetPcmDataChannel(Csm::csmFloat32* dst, Csm::csmUint32 useChannel) const;
2970 - * @brief -1~1の範囲の1サンプル取得
2972 - * @param[in] bitsPerSample ビット深度
2973 - * @param[in] data 正規化したいデータ
2974 - * @param[in] dataSize 正規化したいデータの大きさ
2976 - * @retval csmFloat32 正規化されたサンプル
2978 - static Csm::csmFloat32 NormalizePcmSample(Csm::csmUint32 bitsPerSample, Csm::csmByte* data, Csm::csmUint32 dataSize);
2982 * @brief wavファイルのロード
2983 @@ -141,6 +72,25 @@ private:
2984 Csm::csmFloat32 GetPcmSample();
2987 + * @brief 読み込んだwavfileの情報
2989 + struct WavFileInfo
2994 + WavFileInfo() : _fileName(""), _numberOfChannels(0),
2995 + _bitsPerSample(0), _samplingRate(0), _samplesPerChannel(0)
2998 + Csm::csmString _fileName; ///< ファイル名
2999 + Csm::csmUint32 _numberOfChannels; ///< チャンネル数
3000 + Csm::csmUint32 _bitsPerSample; ///< サンプルあたりビット数
3001 + Csm::csmUint32 _samplingRate; ///< サンプリングレート
3002 + Csm::csmUint32 _samplesPerChannel; ///< 1チャンネルあたり総サンプル数
3009 @@ -225,8 +175,6 @@ private:
3010 Csm::csmUint32 _readOffset; ///< ファイル参照位置
3013 - Csm::csmByte* _rawData; ///< 正規化される前のバイト列
3014 - Csm::csmUint64 _rawDataSize; ///< 正規化される前のバイト列の大きさ
3015 Csm::csmFloat32** _pcmData; ///< -1から1の範囲で表現された音声データ配列
3016 Csm::csmUint32 _sampleOffset; ///< サンプル参照位置
3017 Csm::csmFloat32 _lastRms; ///< 最後に計測したRMS値
3018 diff -pruN --exclude build ./demo_clean/src/MouseActionManager.cpp ./demo_dev/src/MouseActionManager.cpp
3019 --- ./demo_clean/src/MouseActionManager.cpp 2024-03-28 18:19:04.195179800 +0000
3020 +++ ./demo_dev/src/MouseActionManager.cpp 2023-03-05 23:22:10.841970900 +0000
3023 - * Copyright(c) Live2D Inc. All rights reserved.
3025 - * Use of this source code is governed by the Live2D Open Software license
3026 - * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
3029 +* Copyright(c) Live2D Inc. All rights reserved.
3031 +* Use of this source code is governed by the Live2D Open Software license
3032 +* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
3035 #include "MouseActionManager.hpp"
3037 @@ -13,7 +13,7 @@ namespace {
3039 MouseActionManager* MouseActionManager::GetInstance()
3041 - if (instance == NULL)
3044 instance = new MouseActionManager();
3046 @@ -23,7 +23,7 @@ MouseActionManager* MouseActionManager::
3048 void MouseActionManager::ReleaseInstance()
3050 - if (instance != NULL)
3055 @@ -99,18 +99,21 @@ void MouseActionManager::OnMouseCallBack
3059 - if (GLFW_PRESS == action)
3064 OnTouchesBegan(_mouseX, _mouseY);
3066 - else if (GLFW_RELEASE == action)
3069 + case GLFW_RELEASE:
3073 OnTouchesEnded(_mouseX, _mouseY);
3081 diff -pruN --exclude build ./demo_clean/src/MouseActionManager.hpp ./demo_dev/src/MouseActionManager.hpp
3082 --- ./demo_clean/src/MouseActionManager.hpp 2024-03-28 18:19:04.336247400 +0000
3083 +++ ./demo_dev/src/MouseActionManager.hpp 2023-03-05 23:22:10.961094400 +0000
3087 * Copyright(c) Live2D Inc. All rights reserved.
3089 * Use of this source code is governed by the Live2D Open Software license
3090 diff -pruN --exclude build ./demo_clean/src/TouchManager.cpp ./demo_dev/src/TouchManager.cpp
3091 --- ./demo_clean/src/TouchManager.cpp 2024-03-28 18:19:04.493378700 +0000
3092 +++ ./demo_dev/src/TouchManager.cpp 2023-03-05 23:22:10.861957900 +0000
3096 * Copyright(c) Live2D Inc. All rights reserved.
3098 * Use of this source code is governed by the Live2D Open Software license
3099 diff -pruN --exclude build ./demo_clean/src/TouchManager.hpp ./demo_dev/src/TouchManager.hpp
3100 --- ./demo_clean/src/TouchManager.hpp 2024-03-28 18:19:03.612203500 +0000
3101 +++ ./demo_dev/src/TouchManager.hpp 2023-03-05 23:22:10.884102300 +0000
3105 * Copyright(c) Live2D Inc. All rights reserved.
3107 * Use of this source code is governed by the Live2D Open Software license
3108 diff -pruN --exclude build ./demo_clean/src/main.cpp ./demo_dev/src/main.cpp
3109 --- ./demo_clean/src/main.cpp 2024-03-28 18:19:03.894879200 +0000
3110 +++ ./demo_dev/src/main.cpp 2023-03-05 23:22:10.772150300 +0000
3114 * Copyright(c) Live2D Inc. All rights reserved.
3116 * Use of this source code is governed by the Live2D Open Software license
3117 * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
3121 +#include <stdexcept>
3124 +#ifdef __cpp_lib_filesystem
3125 +#include <filesystem>
3126 +namespace fs = std::filesystem;
3128 +#include <experimental/filesystem>
3129 +namespace fs = std::experimental::filesystem;
3133 #include "LAppDelegate.hpp"
3134 +#include "LAppLive2DManager.hpp"
3135 +#include "facial_landmark_detector.h"
3140 - // create the application instance
3141 - if (LAppDelegate::GetInstance()->Initialize() == GL_FALSE)
3144 + std::string windowTitle;
3145 + std::string rootDir;
3146 + float scaleFactor;
3149 + std::string modelName;
3150 + bool oldId; // If true, translate new (Cubism 3+) parameter IDs to old (Cubism 2.1) IDs
3151 + std::string cfgPath; // Path to config file for FacialLandmarkDetector
3154 +CmdArgs parseArgv(int argc, char *argv[])
3156 + // I think the command-line args are simple enough to not justify using a library...
3158 + // Set default values
3159 + cmdArgs.windowWidth = 600;
3160 + cmdArgs.windowHeight = 600;
3161 + cmdArgs.windowTitle = "FacialLandmarksForCubism example";
3162 + cmdArgs.rootDir = fs::current_path().string();
3163 + cmdArgs.scaleFactor = 4.5f;
3164 + cmdArgs.translateX = 0.0f;
3165 + cmdArgs.translateY = -3.1f;
3166 + cmdArgs.modelName = "Haru";
3167 + cmdArgs.oldId = false;
3168 + cmdArgs.cfgPath = "";
3174 + std::string arg = argv[i];
3175 + std::stringstream ss;
3177 + if (arg == "--window-width" || arg == "-W") // capital W for consistency with height
3179 + ss << argv[i + 1];
3180 + if (!(ss >> cmdArgs.windowWidth))
3182 + throw std::runtime_error("Invalid argument for window width");
3185 + else if (arg == "--window-height" || arg == "-H") // avoiding "-h", typically for help
3187 + ss << argv[i + 1];
3188 + if (!(ss >> cmdArgs.windowHeight))
3190 + throw std::runtime_error("Invalid argument for window height");
3193 + else if (arg == "--window-title" || arg == "-t")
3195 + cmdArgs.windowTitle = argv[i + 1];
3197 + else if (arg == "--root-dir" || arg == "-d")
3199 + cmdArgs.rootDir = argv[i + 1];
3201 + else if (arg == "--scale-factor" || arg == "-f")
3203 + ss << argv[i + 1];
3204 + if (!(ss >> cmdArgs.scaleFactor))
3206 + throw std::runtime_error("Invalid argument for scale factor");
3209 + else if (arg == "--translate-x" || arg == "-x")
3211 + ss << argv[i + 1];
3212 + if (!(ss >> cmdArgs.translateX))
3214 + throw std::runtime_error("Invalid argument for translate X");
3217 + else if (arg == "--translate-y" || arg == "-y")
3219 + ss << argv[i + 1];
3220 + if (!(ss >> cmdArgs.translateY))
3222 + throw std::runtime_error("Invalid argument for translate Y");
3225 + else if (arg == "--model" || arg == "-m")
3227 + cmdArgs.modelName = argv[i + 1];
3229 + else if (arg == "--config" || arg == "-c")
3231 + cmdArgs.cfgPath = argv[i + 1];
3233 + else if (arg == "--old-param-id" || arg == "-o")
3235 + cmdArgs.oldId = (argv[i + 1][0] == '1');
3239 + throw std::runtime_error("Unrecognized argument: " + arg);
3245 - LAppDelegate::GetInstance()->Run();
3249 +int main(int argc, char* argv[])
3251 + auto cmdArgs = parseArgv(argc, argv);
3253 + LAppDelegate *delegate = LAppDelegate::GetInstance();
3255 + if (!delegate->Initialize(cmdArgs.windowWidth,
3256 + cmdArgs.windowHeight,
3257 + cmdArgs.windowTitle.c_str()))
3259 + throw std::runtime_error("Unable to initialize LAppDelegate");
3262 + delegate->SetRootDirectory(cmdArgs.rootDir);
3264 + FacialLandmarkDetector detector(cmdArgs.cfgPath);
3266 + std::thread detectorThread(&FacialLandmarkDetector::mainLoop,
3269 + LAppLive2DManager *manager = LAppLive2DManager::GetInstance();
3270 + manager->SetModel(cmdArgs.modelName, cmdArgs.oldId);
3272 + manager->SetProjectionScaleTranslate(cmdArgs.scaleFactor,
3273 + cmdArgs.translateX,
3274 + cmdArgs.translateY);
3275 + manager->SetFacialLandmarkDetector(&detector);
3280 + detectorThread.join();
3285 diff -pruN --exclude build ./demo_clean/src/mainMinimum.cpp ./demo_dev/src/mainMinimum.cpp
3286 --- ./demo_clean/src/mainMinimum.cpp 2024-03-28 18:19:04.383534500 +0000
3287 +++ ./demo_dev/src/mainMinimum.cpp 2023-03-05 23:22:10.854990900 +0000
3291 * Copyright(c) Live2D Inc. All rights reserved.
3293 * Use of this source code is governed by the Live2D Open Software license
3296 #include <functional>
3298 -#include <stb_image.h>
3300 +#include <unistd.h>
3301 #include <GL/glew.h>
3302 #include <GLFW/glfw3.h>
3305 #include "LAppAllocator.hpp"
3306 #include "LAppTextureManager.hpp"
3307 #include "LAppPal.hpp"
3308 -#include "TouchManager.hpp"
3309 #include "CubismUserModelExtend.hpp"
3310 -#include "CubismSampleViewMatrix.hpp"
3311 #include "MouseActionManager.hpp"
3313 #include <CubismFramework.hpp>
3314 -#include <CubismDefaultParameterId.hpp>
3315 #include <CubismModelSettingJson.hpp>
3316 #include <Model/CubismUserModel.hpp>
3317 #include <Physics/CubismPhysics.hpp>
3318 #include <Rendering/OpenGL/CubismRenderer_OpenGLES2.hpp>
3319 #include <Utils/CubismString.hpp>
3320 -#include <Math/CubismViewMatrix.hpp>
3323 *@brief モデルデータのディレクトリ名
3325 static const Csm::csmChar* _modelDirectoryName = "Hiyori";
3327 static Csm::CubismUserModel* _userModel; ///< ユーザーが実際に使用するモデル
3328 -static Csm::CubismModelSettingJson* _modelJson; ///< モデルの設定情報
3329 -static Csm::CubismModel* _model; ///< Mocデータから作成されるモデルデータ
3331 Csm::csmFloat32 _userTimeSeconds; ///< デルタ時間の積算値[秒]
3332 Csm::csmVector<Csm::CubismIdHandle> _eyeBlinkIds; ///< モデルに設定されたまばたき機能用パラメータID
3333 @@ -66,8 +61,8 @@ static LAppAllocator _cubismAllocator; /
3335 static LAppTextureManager* _textureManager; ///< テクスチャの管理
3337 +static std::string _rootDirectory; ///< ルートディレクトリ
3338 static std::string _currentModelDirectory; ///< 現在のモデルのディレクトリ名
3339 -const Csm::csmChar* _currentModelDirectoryChar; ///< 現在のモデルのディレクトリ名のconst csmCharポインタ型
3341 static GLFWwindow* _window; ///< ウィンドウオブジェクト
3343 @@ -90,18 +85,71 @@ static void InitializeCubism()
3349 +* 指定された区切り文字で文字列を分割する
3351 +Csm::csmVector<std::string> Split(const std::string& baseString, char delimiter)
3353 + Csm::csmVector < std::string > elems;
3354 + std::stringstream ss(baseString);
3357 + while (getline(ss, item, delimiter))
3359 + if (!item.empty())
3361 + elems.PushBack(item);
3369 +* @brief ルートディレクトリの設定
3371 +* Linuxのルートディレクトリを確認し、パスを取得する
3373 +void SetRootDirectory()
3375 + const int maximumPathBufferSize = 1024;
3376 + char path[maximumPathBufferSize];
3377 + ssize_t len = readlink("/proc/self/exe", path, maximumPathBufferSize - 1);
3384 + std::string pathString(path);
3386 + pathString = pathString.substr(0, pathString.rfind("Demo"));
3387 + Csm::csmVector<std::string> splitStrings = Split(pathString, '/');
3389 + _rootDirectory = "";
3391 + for (int i = 0; i < splitStrings.GetSize(); i++)
3393 + _rootDirectory += "/" + splitStrings[i];
3396 + _rootDirectory += "/";
3404 static bool InitializeSystem()
3406 - LAppPal::PrintLogLn("START");
3407 + LAppPal::PrintLog("START");
3410 if (glfwInit() == GL_FALSE)
3412 - LAppPal::PrintLogLn("Can't initilize GLFW");
3413 + LAppPal::PrintLog("Can't initilize GLFW");
3417 @@ -110,7 +158,7 @@ static bool InitializeSystem()
3418 _window = glfwCreateWindow(LAppDefine::RenderTargetWidth, LAppDefine::RenderTargetHeight, "SIMPLE_SAMPLE", NULL, NULL);
3419 if (_window == NULL)
3421 - LAppPal::PrintLogLn("Can't create GLFW window.");
3422 + LAppPal::PrintLog("Can't create GLFW window.");
3426 @@ -121,7 +169,7 @@ static bool InitializeSystem()
3427 glfwSwapInterval(1);
3429 if (glewInit() != GLEW_OK) {
3430 - LAppPal::PrintLogLn("Can't initilize glew.");
3431 + LAppPal::PrintLog("Can't initilize glew.");
3435 @@ -149,6 +197,8 @@ static bool InitializeSystem()
3437 MouseActionManager::GetInstance()->Initialize(windowWidth, windowHeight);
3439 + SetRootDirectory();
3444 @@ -182,16 +232,6 @@ void Release()
3448 -* @brief ディレクトリパスの設定
3450 -* モデルのディレクトリパスを設定する
3452 -void SetAssetDirectory(const std::string& path)
3454 - _currentModelDirectory = path;
3461 @@ -201,13 +241,15 @@ void SetAssetDirectory(const std::string
3462 void LoadModel(const std::string modelDirectoryName)
3465 - SetAssetDirectory(LAppDefine::ResourcesPath + modelDirectoryName + "/");
3466 + _currentModelDirectory = _rootDirectory + LAppDefine::ResourcesPath + modelDirectoryName + "/";
3469 _userModel = new CubismUserModelExtend(modelDirectoryName, _currentModelDirectory);
3471 // モデルデータの読み込み及び生成とセットアップを行う
3472 - static_cast<CubismUserModelExtend*>(_userModel)->SetupModel();
3473 + std::string json = ".model3.json";
3474 + std::string fileName = _modelDirectoryName + json;
3475 + static_cast<CubismUserModelExtend*>(_userModel)->LoadAssets(fileName.c_str());
3477 // ユーザーモデルをMouseActionManagerへ渡す
3478 MouseActionManager::GetInstance()->SetUserModel(_userModel);