1 diff -pruN --exclude build ./demo_clean/CMakeLists.txt ./demo_dev/CMakeLists.txt
2 --- ./demo_clean/CMakeLists.txt 2021-02-17 01:23:17.000000000 +0000
3 +++ ./demo_dev/CMakeLists.txt 2021-06-12 17:14:36.877121318 +0100
5 -cmake_minimum_required(VERSION 3.16)
6 +cmake_minimum_required(VERSION 3.13)
10 # Set directory paths.
11 -set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../..)
12 +set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../CubismSdkForNative-4-r.3)
13 set(CORE_PATH ${SDK_ROOT_PATH}/Core)
14 set(FRAMEWORK_PATH ${SDK_ROOT_PATH}/Framework)
15 set(THIRD_PARTY_PATH ${SDK_ROOT_PATH}/Samples/OpenGL/thirdParty)
16 @@ -32,7 +32,7 @@ set(GLFW_INSTALL OFF CACHE BOOL "" FORCE
17 set(BUILD_UTILS OFF CACHE BOOL "" FORCE)
19 # Specify version of compiler.
20 -set(CMAKE_CXX_STANDARD 14)
21 +set(CMAKE_CXX_STANDARD 17)
22 set(CMAKE_CXX_STANDARD_REQUIRED ON)
23 set(CMAKE_CXX_EXTENSIONS OFF)
25 @@ -42,7 +42,7 @@ add_library(Live2DCubismCore STATIC IMPO
27 set_target_properties(Live2DCubismCore
29 - IMPORTED_LOCATION ${CORE_PATH}/lib/linux/x86_64/libLive2DCubismCore.a
30 + IMPORTED_LOCATION ${CORE_PATH}/lib/experimental/rpi/libLive2DCubismCore.a
31 INTERFACE_INCLUDE_DIRECTORIES ${CORE_PATH}/include
34 @@ -64,6 +64,11 @@ target_link_libraries(Framework Live2DCu
35 # Find opengl libraries.
36 find_package(OpenGL REQUIRED)
38 +# Add MouseTrackerForCubism
39 +find_package(PkgConfig)
40 +pkg_check_modules(GTKMM gtkmm-3.0)
41 +add_subdirectory(../.. MouseTrackerForCubism_build)
43 # Make executable app.
44 add_executable(${APP_NAME})
46 @@ -73,9 +78,20 @@ target_link_libraries(${APP_NAME}
50 + MouseTrackerForCubism
53 # Specify include directories.
54 -target_include_directories(${APP_NAME} PRIVATE ${STB_PATH})
55 +target_include_directories(${APP_NAME} PRIVATE ${STB_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../include ${GTKMM_INCLUDE_DIRS})
57 +# Copy GUI to build directory
63 + copy ${CMAKE_CURRENT_SOURCE_DIR}/../../src/gui.glade $<TARGET_FILE_DIR:${APP_NAME}>/gui.glade
66 # Copy resource directory to build directory.
68 diff -pruN --exclude build ./demo_clean/scripts/make_gcc ./demo_dev/scripts/make_gcc
69 --- ./demo_clean/scripts/make_gcc 2021-02-17 01:23:17.000000000 +0000
70 +++ ./demo_dev/scripts/make_gcc 2021-04-28 12:18:50.948333190 +0100
71 @@ -10,4 +10,4 @@ BUILD_PATH=$SCRIPT_PATH/../build/make_gc
72 cmake -S "$CMAKE_PATH" \
74 -D CMAKE_BUILD_TYPE=Release
75 -cd "$BUILD_PATH" && make
76 +cd "$BUILD_PATH" && make -j4
77 diff -pruN --exclude build ./demo_clean/src/CMakeLists.txt ./demo_dev/src/CMakeLists.txt
78 --- ./demo_clean/src/CMakeLists.txt 2021-02-17 01:23:17.000000000 +0000
79 +++ ./demo_dev/src/CMakeLists.txt 2021-04-28 12:21:56.795134807 +0100
80 @@ -6,8 +6,6 @@ target_sources(${APP_NAME}
81 ${CMAKE_CURRENT_SOURCE_DIR}/LAppDefine.hpp
82 ${CMAKE_CURRENT_SOURCE_DIR}/LAppDelegate.cpp
83 ${CMAKE_CURRENT_SOURCE_DIR}/LAppDelegate.hpp
84 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppWavFileHandler.cpp
85 - ${CMAKE_CURRENT_SOURCE_DIR}/LAppWavFileHandler.hpp
86 ${CMAKE_CURRENT_SOURCE_DIR}/LAppLive2DManager.cpp
87 ${CMAKE_CURRENT_SOURCE_DIR}/LAppLive2DManager.hpp
88 ${CMAKE_CURRENT_SOURCE_DIR}/LAppModel.cpp
89 @@ -21,6 +19,4 @@ target_sources(${APP_NAME}
90 ${CMAKE_CURRENT_SOURCE_DIR}/LAppView.cpp
91 ${CMAKE_CURRENT_SOURCE_DIR}/LAppView.hpp
92 ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
93 - ${CMAKE_CURRENT_SOURCE_DIR}/TouchManager.cpp
94 - ${CMAKE_CURRENT_SOURCE_DIR}/TouchManager.hpp
96 diff -pruN --exclude build ./demo_clean/src/LAppDefine.cpp ./demo_dev/src/LAppDefine.cpp
97 --- ./demo_clean/src/LAppDefine.cpp 2021-02-17 01:23:17.000000000 +0000
98 +++ ./demo_dev/src/LAppDefine.cpp 2021-04-28 12:18:50.948333190 +0100
99 @@ -64,11 +64,11 @@ namespace LAppDefine {
100 const csmInt32 PriorityForce = 3;
103 - const csmBool DebugLogEnable = true;
104 + const csmBool DebugLogEnable = false;
105 const csmBool DebugTouchLogEnable = false;
107 // Frameworkから出力するログのレベル設定
108 - const CubismFramework::Option::LogLevel CubismLoggingLevel = CubismFramework::Option::LogLevel_Verbose;
109 + const CubismFramework::Option::LogLevel CubismLoggingLevel = CubismFramework::Option::LogLevel_Warning;
111 // デフォルトのレンダーターゲットサイズ
112 const csmInt32 RenderTargetWidth = 1900;
113 diff -pruN --exclude build ./demo_clean/src/LAppDelegate.cpp ./demo_dev/src/LAppDelegate.cpp
114 --- ./demo_clean/src/LAppDelegate.cpp 2021-02-17 01:23:17.000000000 +0000
115 +++ ./demo_dev/src/LAppDelegate.cpp 2021-04-28 12:18:50.948333190 +0100
116 @@ -45,7 +45,8 @@ void LAppDelegate::ReleaseInstance()
120 -bool LAppDelegate::Initialize()
121 +bool LAppDelegate::Initialize(int initWindowWidth, int initWindowHeight,
122 + const char *windowTitle)
126 @@ -63,7 +64,13 @@ bool LAppDelegate::Initialize()
130 - _window = glfwCreateWindow(RenderTargetWidth, RenderTargetHeight, "SAMPLE", NULL, NULL);
131 + _window = glfwCreateWindow(
132 + initWindowWidth ? initWindowWidth : RenderTargetWidth,
133 + initWindowHeight ? initWindowHeight : RenderTargetHeight,
134 + windowTitle ? windowTitle : "SAMPLE",
141 @@ -95,10 +102,6 @@ bool LAppDelegate::Initialize()
143 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
146 - glfwSetMouseButtonCallback(_window, EventHandler::OnMouseCallBack);
147 - glfwSetCursorPosCallback(_window, EventHandler::OnMouseCallBack);
151 glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &width, &height);
152 @@ -111,8 +114,6 @@ bool LAppDelegate::Initialize()
156 - SetRootDirectory();
159 LAppLive2DManager::GetInstance();
161 @@ -214,49 +215,6 @@ void LAppDelegate::InitializeCubism()
162 LAppPal::UpdateTime();
165 -void LAppDelegate::OnMouseCallBack(GLFWwindow* window, int button, int action, int modify)
171 - if (GLFW_MOUSE_BUTTON_LEFT != button)
176 - if (GLFW_PRESS == action)
179 - _view->OnTouchesBegan(_mouseX, _mouseY);
181 - else if (GLFW_RELEASE == action)
186 - _view->OnTouchesEnded(_mouseX, _mouseY);
191 -void LAppDelegate::OnMouseCallBack(GLFWwindow* window, double x, double y)
193 - _mouseX = static_cast<float>(x);
194 - _mouseY = static_cast<float>(y);
205 - _view->OnTouchesMoved(_mouseX, _mouseY);
208 GLuint LAppDelegate::CreateShader()
211 @@ -299,29 +257,9 @@ GLuint LAppDelegate::CreateShader()
215 -void LAppDelegate::SetRootDirectory()
216 +void LAppDelegate::SetRootDirectory(std::string rootDir)
219 - ssize_t len = readlink("/proc/self/exe", path, 1024 - 1);
226 - std::string pathString(path);
228 - pathString = pathString.substr(0, pathString.rfind("Demo"));
229 - Csm::csmVector<string> splitStrings = this->Split(pathString, '/');
231 - this->_rootDirectory = "";
233 - for(int i = 0; i < splitStrings.GetSize(); i++)
235 - this->_rootDirectory = this->_rootDirectory + "/" +splitStrings[i];
238 - this->_rootDirectory += "/";
239 + this->_rootDirectory = rootDir + "/";
242 Csm::csmVector<string> LAppDelegate::Split(const std::string& baseString, char delimiter)
243 diff -pruN --exclude build ./demo_clean/src/LAppDelegate.hpp ./demo_dev/src/LAppDelegate.hpp
244 --- ./demo_clean/src/LAppDelegate.hpp 2021-02-17 01:23:17.000000000 +0000
245 +++ ./demo_dev/src/LAppDelegate.hpp 2021-04-28 12:18:50.948333190 +0100
246 @@ -40,7 +40,8 @@ public:
248 * @brief APPに必要なものを初期化する。
251 + bool Initialize(int initWindowWidth = 0, int initWindowHeight = 0,
252 + const char *windowTitle = "SAMPLE");
256 @@ -53,25 +54,6 @@ public:
260 - * @brief OpenGL用 glfwSetMouseButtonCallback用関数。
262 - * @param[in] window コールバックを呼んだWindow情報
263 - * @param[in] button ボタン種類
264 - * @param[in] action 実行結果
265 - * @param[in] modify
267 - void OnMouseCallBack(GLFWwindow* window, int button, int action, int modify);
270 - * @brief OpenGL用 glfwSetCursorPosCallback用関数。
272 - * @param[in] window コールバックを呼んだWindow情報
276 - void OnMouseCallBack(GLFWwindow* window, double x, double y);
281 GLuint CreateShader();
282 @@ -98,8 +80,10 @@ public:
285 * @brief ルートディレクトリを設定する。
287 + * @param[in] rootDir : The root directory to set to.
289 - void SetRootDirectory();
290 + void SetRootDirectory(std::string rootDir);
293 * @brief ルートディレクトリを取得する。
294 @@ -146,24 +130,3 @@ private:
295 int _windowWidth; ///< Initialize関数で設定したウィンドウ幅
296 int _windowHeight; ///< Initialize関数で設定したウィンドウ高さ
303 - * @brief glfwSetMouseButtonCallback用コールバック関数。
305 - static void OnMouseCallBack(GLFWwindow* window, int button, int action, int modify)
307 - LAppDelegate::GetInstance()->OnMouseCallBack(window, button, action, modify);
311 - * @brief glfwSetCursorPosCallback用コールバック関数。
313 - static void OnMouseCallBack(GLFWwindow* window, double x, double y)
315 - LAppDelegate::GetInstance()->OnMouseCallBack(window, x, y);
319 diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src/LAppLive2DManager.cpp
320 --- ./demo_clean/src/LAppLive2DManager.cpp 2021-02-17 01:23:17.000000000 +0000
321 +++ ./demo_dev/src/LAppLive2DManager.cpp 2021-04-28 12:24:45.405646016 +0100
322 @@ -52,11 +52,11 @@ void LAppLive2DManager::ReleaseInstance(
324 LAppLive2DManager::LAppLive2DManager()
327 + , _projScaleFactor(1.0f)
328 + , _translateX(0.0f)
329 + , _translateY(0.0f)
331 _viewMatrix = new CubismMatrix44();
333 - ChangeScene(_sceneIndex);
336 LAppLive2DManager::~LAppLive2DManager()
337 @@ -100,26 +100,6 @@ void LAppLive2DManager::OnTap(csmFloat32
339 LAppPal::PrintLog("[APP]tap point: {x:%.2f y:%.2f}", x, y);
342 - for (csmUint32 i = 0; i < _models.GetSize(); i++)
344 - if (_models[i]->HitTest(HitAreaNameHead, x, y))
346 - if (DebugLogEnable)
348 - LAppPal::PrintLog("[APP]hit area: [%s]", HitAreaNameHead);
350 - _models[i]->SetRandomExpression();
352 - else if (_models[i]->HitTest(HitAreaNameBody, x, y))
354 - if (DebugLogEnable)
356 - LAppPal::PrintLog("[APP]hit area: [%s]", HitAreaNameBody);
358 - _models[i]->StartRandomMotion(MotionGroupTapBody, PriorityNormal, FinishedMotion);
363 void LAppLive2DManager::OnUpdate() const
364 @@ -136,12 +116,15 @@ void LAppLive2DManager::OnUpdate() const
366 // 横に長いモデルを縦長ウィンドウに表示する際モデルの横サイズでscaleを算出する
367 model->GetModelMatrix()->SetWidth(2.0f);
368 - projection.Scale(1.0f, static_cast<float>(width) / static_cast<float>(height));
369 + projection.Scale(_projScaleFactor,
370 + _projScaleFactor * static_cast<float>(width) / static_cast<float>(height));
374 - projection.Scale(static_cast<float>(height) / static_cast<float>(width), 1.0f);
375 + projection.Scale(_projScaleFactor * static_cast<float>(height) / static_cast<float>(width),
378 + projection.Translate(_translateX, _translateY);
381 if (_viewMatrix != NULL)
382 @@ -158,30 +141,14 @@ void LAppLive2DManager::OnUpdate() const
386 -void LAppLive2DManager::NextScene()
388 - csmInt32 no = (_sceneIndex + 1) % ModelDirSize;
392 -void LAppLive2DManager::ChangeScene(Csm::csmInt32 index)
393 +void LAppLive2DManager::SetModel(std::string modelName, bool useOldParamId)
395 - _sceneIndex = index;
396 - if (DebugLogEnable)
398 - LAppPal::PrintLog("[APP]model index: %d", _sceneIndex);
401 - // ModelDir[]に保持したディレクトリ名から
402 - // model3.jsonのパスを決定する.
403 - // ディレクトリ名とmodel3.jsonの名前を一致させておくこと.
404 - std::string model = ModelDir[index];
405 - std::string modelPath = LAppDelegate::GetInstance()->GetRootDirectory() + ResourcesPath + model + "/";
406 - std::string modelJsonName = ModelDir[index];
407 + std::string modelPath = LAppDelegate::GetInstance()->GetRootDirectory() + ResourcesPath + modelName + "/";
408 + std::string modelJsonName = modelName;
409 modelJsonName += ".model3.json";
412 - _models.PushBack(new LAppModel());
413 + _models.PushBack(new LAppModel(useOldParamId));
414 _models[0]->LoadAssets(modelPath.c_str(), modelJsonName.c_str());
417 @@ -203,7 +170,7 @@ void LAppLive2DManager::ChangeScene(Csm:
419 #if defined(USE_RENDER_TARGET) || defined(USE_MODEL_RENDER_TARGET)
420 // モデル個別にαを付けるサンプルとして、もう1体モデルを作成し、少し位置をずらす
421 - _models.PushBack(new LAppModel());
422 + _models.PushBack(new LAppModel(useOldParamId));
423 _models[1]->LoadAssets(modelPath.c_str(), modelJsonName.c_str());
424 _models[1]->GetModelMatrix()->TranslateX(0.2f);
426 @@ -232,3 +199,20 @@ void LAppLive2DManager::SetViewMatrix(Cu
427 _viewMatrix->GetArray()[i] = m->GetArray()[i];
431 +void LAppLive2DManager::SetTracker(MouseCursorTracker *tracker)
433 + for (auto it = _models.Begin(); it != _models.End(); ++it)
435 + (*it)->SetTracker(tracker);
439 +void LAppLive2DManager::SetProjectionScaleTranslate(float scaleFactor,
443 + _projScaleFactor = scaleFactor;
444 + _translateX = translateX;
445 + _translateY = translateY;
447 diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.hpp ./demo_dev/src/LAppLive2DManager.hpp
448 --- ./demo_clean/src/LAppLive2DManager.hpp 2021-02-17 01:23:17.000000000 +0000
449 +++ ./demo_dev/src/LAppLive2DManager.hpp 2021-04-28 12:18:50.948333190 +0100
455 #include <CubismFramework.hpp>
456 #include <Math/CubismMatrix44.hpp>
457 #include <Type/csmVector.hpp>
461 +class MouseCursorTracker;
464 * @brief サンプルアプリケーションにおいてCubismModelを管理するクラス<br>
465 * モデル生成と破棄、タップイベントの処理、モデル切り替えを行う。
466 @@ -72,16 +75,14 @@ public:
467 void OnUpdate() const;
470 - * @brief 次のシーンに切り替える<br>
471 - * サンプルアプリケーションではモデルセットの切り替えを行う。
476 - * @brief シーンを切り替える<br>
477 - * サンプルアプリケーションではモデルセットの切り替えを行う。
479 - void ChangeScene(Csm::csmInt32 index);
480 + * @brief Set model data
482 + * @param[in] modelName : Name of model, should be the same for both
483 + * the directory and the model3.json file
484 + * @param[in] useOldParamId : If true, translate new (Cubism 3+)
485 + * parameter IDs to old (Cubism 2.1) ones
487 + void SetModel(std::string modelName, bool useOldParamId);
491 @@ -94,6 +95,24 @@ public:
493 void SetViewMatrix(Live2D::Cubism::Framework::CubismMatrix44* m);
496 + * @brief Set the pointer to the MouseCursorTracker instance
498 + * @param[in] tracker : Pointer to MouseCursorTracker instance
500 + void SetTracker(MouseCursorTracker *tracker);
503 + * @brief Set projection scale factor and translation parameters
505 + * @param[in] scaleFactor : Scale factor applied in both X and Y directions
506 + * @param[in] translateX : Translation in X direction
507 + * @param[in] translateY : Translation in Y direction
509 + void SetProjectionScaleTranslate(float scaleFactor,
516 @@ -107,5 +126,8 @@ private:
518 Csm::CubismMatrix44* _viewMatrix; ///< モデル描画に用いるView行列
519 Csm::csmVector<LAppModel*> _models; ///< モデルインスタンスのコンテナ
520 - Csm::csmInt32 _sceneIndex; ///< 表示するシーンのインデックス値
522 + float _projScaleFactor;
526 diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppModel.cpp
527 --- ./demo_clean/src/LAppModel.cpp 2021-02-17 01:23:17.000000000 +0000
528 +++ ./demo_dev/src/LAppModel.cpp 2021-04-28 12:26:56.699586813 +0100
530 #include "LAppTextureManager.hpp"
531 #include "LAppDelegate.hpp"
533 +#include "mouse_cursor_tracker.h"
537 using namespace Live2D::Cubism::Framework;
538 using namespace Live2D::Cubism::Framework::DefaultParameterId;
539 using namespace LAppDefine;
540 @@ -45,22 +49,24 @@ namespace {
544 -LAppModel::LAppModel()
545 +LAppModel::LAppModel(bool useOldParamId)
547 , _modelSetting(NULL)
548 , _userTimeSeconds(0.0f)
549 + , _tracker(nullptr)
550 + , _useOldParamId(useOldParamId)
557 - _idParamAngleX = CubismFramework::GetIdManager()->GetId(ParamAngleX);
558 - _idParamAngleY = CubismFramework::GetIdManager()->GetId(ParamAngleY);
559 - _idParamAngleZ = CubismFramework::GetIdManager()->GetId(ParamAngleZ);
560 - _idParamBodyAngleX = CubismFramework::GetIdManager()->GetId(ParamBodyAngleX);
561 - _idParamEyeBallX = CubismFramework::GetIdManager()->GetId(ParamEyeBallX);
562 - _idParamEyeBallY = CubismFramework::GetIdManager()->GetId(ParamEyeBallY);
563 + _idParamAngleX = CubismFramework::GetIdManager()->GetId(_(ParamAngleX));
564 + _idParamAngleY = CubismFramework::GetIdManager()->GetId(_(ParamAngleY));
565 + _idParamAngleZ = CubismFramework::GetIdManager()->GetId(_(ParamAngleZ));
566 + _idParamBodyAngleX = CubismFramework::GetIdManager()->GetId(_(ParamBodyAngleX));
567 + _idParamEyeBallX = CubismFramework::GetIdManager()->GetId(_(ParamEyeBallX));
568 + _idParamEyeBallY = CubismFramework::GetIdManager()->GetId(_(ParamEyeBallY));
571 LAppModel::~LAppModel()
572 @@ -190,7 +196,7 @@ void LAppModel::SetupModel(ICubismModelS
573 breathParameters.PushBack(CubismBreath::BreathParameterData(_idParamAngleY, 0.0f, 8.0f, 3.5345f, 0.5f));
574 breathParameters.PushBack(CubismBreath::BreathParameterData(_idParamAngleZ, 0.0f, 10.0f, 5.5345f, 0.5f));
575 breathParameters.PushBack(CubismBreath::BreathParameterData(_idParamBodyAngleX, 0.0f, 4.0f, 15.5345f, 0.5f));
576 - breathParameters.PushBack(CubismBreath::BreathParameterData(CubismFramework::GetIdManager()->GetId(ParamBreath), 0.5f, 0.5f, 3.2345f, 0.5f));
577 + breathParameters.PushBack(CubismBreath::BreathParameterData(CubismFramework::GetIdManager()->GetId(_(ParamBreath)), 0.5f, 0.5f, 3.2345f, 0.5f));
579 _breath->SetParameters(breathParameters);
581 @@ -335,83 +341,118 @@ void LAppModel::Update()
582 const csmFloat32 deltaTimeSeconds = LAppPal::GetDeltaTime();
583 _userTimeSeconds += deltaTimeSeconds;
585 - _dragManager->Update(deltaTimeSeconds);
586 - _dragX = _dragManager->GetX();
587 - _dragY = _dragManager->GetY();
589 - // モーションによるパラメータ更新の有無
590 - csmBool motionUpdated = false;
592 - //-----------------------------------------------------------------
593 - _model->LoadParameters(); // 前回セーブされた状態をロード
594 - if (_motionManager->IsFinished())
596 - // モーションの再生がない場合、待機モーションの中からランダムで再生する
597 - StartRandomMotion(MotionGroupIdle, PriorityIdle);
602 - motionUpdated = _motionManager->UpdateMotion(_model, deltaTimeSeconds); // モーションを更新
604 - _model->SaveParameters(); // 状態を保存
605 - //-----------------------------------------------------------------
606 + auto idMan = CubismFramework::GetIdManager();
607 + auto params = _tracker->getParams();
610 - if (!motionUpdated)
612 - if (_eyeBlink != NULL)
613 + _model->LoadParameters(); // 前回セーブされた状態をロード
615 + int paramsMotionPriority = static_cast<int>(params.motionPriority);
617 + if (paramsMotionPriority != PriorityNone)
619 - // メインモーションの更新がないとき
620 - _eyeBlink->UpdateParameters(_model, deltaTimeSeconds); // 目パチ
621 + StartMotion(params.motionGroup.c_str(), params.motionNumber,
622 + paramsMotionPriority);
624 + else if (params.randomIdleMotion && _motionManager->IsFinished())
626 + // モーションの再生がない場合、待機モーションの中からランダムで再生する
627 + StartRandomMotion(MotionGroupIdle, PriorityIdle);
631 - if (_expressionManager != NULL)
633 - _expressionManager->UpdateMotion(_model, deltaTimeSeconds); // 表情でパラメータ更新(相対変化)
635 + // FIXME pose does not return to normal after motion
636 + // if we don't have randomIdleMotion set
639 + _motionManager->UpdateMotion(_model, deltaTimeSeconds); // モーションを更新
641 + _model->SaveParameters(); // 状態を保存
645 - _model->AddParameterValue(_idParamAngleX, _dragX * 30); // -30から30の値を加える
646 - _model->AddParameterValue(_idParamAngleY, _dragY * 30);
647 - _model->AddParameterValue(_idParamAngleZ, _dragX * _dragY * -30);
648 + if (params.expression != "")
650 + SetExpression(params.expression.c_str());
652 + if (_expressionManager != NULL)
654 + _expressionManager->UpdateMotion(_model, deltaTimeSeconds); // 表情でパラメータ更新(相対変化)
658 - _model->AddParameterValue(_idParamBodyAngleX, _dragX * 10); // -10から10の値を加える
659 + bool autoBlink = params.autoBlink && _eyeBlink;
660 + auto eyeLOpenIt = params.live2d.find("ParamEyeLOpen");
661 + auto eyeROpenIt = params.live2d.find("ParamEyeROpen");
664 - _model->AddParameterValue(_idParamEyeBallX, _dragX); // -1から1の値を加える
665 - _model->AddParameterValue(_idParamEyeBallY, _dragY);
668 + // Handle blink first
669 + _eyeBlink->UpdateParameters(_model, deltaTimeSeconds);
673 - if (_breath != NULL)
675 - _breath->UpdateParameters(_model, deltaTimeSeconds);
677 + if (eyeLOpenIt != params.live2d.end())
679 + // If value specified, override blinking
680 + _model->SetParameterValue(idMan->GetId(_("ParamEyeLOpen")),
681 + eyeLOpenIt->second);
683 + else if (!autoBlink)
685 + // If no value specified and no auto blink, set to 1
686 + _model->SetParameterValue(idMan->GetId(_("ParamEyeLOpen")), 1);
689 - if (_physics != NULL)
691 - _physics->Evaluate(_model, deltaTimeSeconds);
698 - // リアルタイムでリップシンクを行う場合、システムから音量を取得して0〜1の範囲で値を入力します。
699 - csmFloat32 value = 0.0f;
700 + if (eyeROpenIt != params.live2d.end())
702 + _model->SetParameterValue(idMan->GetId(_("ParamEyeROpen")),
703 + eyeROpenIt->second);
705 + else if (!autoBlink)
707 + _model->SetParameterValue(idMan->GetId(_("ParamEyeROpen")), 1);
711 - _wavFileHandler.Update(deltaTimeSeconds);
712 - value = _wavFileHandler.GetRms();
714 - for (csmUint32 i = 0; i < _lipSyncIds.GetSize(); ++i)
715 + if (params.useLipSync && _lipSync)
717 - _model->AddParameterValue(_lipSyncIds[i], value, 0.8f);
718 + csmFloat32 value = params.lipSyncParam; // 0 to 1
720 + for (csmUint32 i = 0; i < _lipSyncIds.GetSize(); ++i)
722 + _model->AddParameterValue(_lipSyncIds[i], value, 0.8f);
727 + _model->SetParameterValue(idMan->GetId(_("ParamMouthOpenY")),
728 + params.live2d["ParamMouthOpenY"]);
731 + for (auto const &entry : params.live2d)
733 + std::string key = entry.first;
734 + double val = entry.second;
736 + if (key != "ParamEyeLOpen" && key != "ParamEyeROpen" &&
737 + key != "ParamMouthOpenY")
739 + _model->SetParameterValue(idMan->GetId(_(key)), val);
743 + if (params.autoBreath && _breath)
745 + // Note: _model->LoadParameters and SaveParameters is needed
746 + // before - see above.
747 + _breath->UpdateParameters(_model, deltaTimeSeconds);
752 + if (_physics != NULL)
754 + _physics->Evaluate(_model, deltaTimeSeconds);
760 @@ -480,7 +521,6 @@ CubismMotionQueueEntryHandle LAppModel::
762 csmString path = voice;
763 path = _modelHomeDir + path;
764 - _wavFileHandler.Start(path);
768 @@ -632,3 +672,42 @@ Csm::Rendering::CubismOffscreenFrame_Ope
770 return _renderBuffer;
773 +void LAppModel::SetTracker(MouseCursorTracker *tracker)
775 + _tracker = tracker;
778 +Csm::ICubismModelSetting* LAppModel::GetModelSetting(void) const
780 + return _modelSetting;
783 +Csm::csmString LAppModel::_(std::string s)
786 + if (_useOldParamId)
788 + if (s == "ParamTere")
790 + ans = "PARAM_CHEEK";
794 + for (size_t i = 0; i < s.size(); i++)
796 + if (std::isupper(s[i]) && i != 0)
800 + ans += std::toupper(s[i]);
808 + return csmString(ans.c_str());
811 diff -pruN --exclude build ./demo_clean/src/LAppModel.hpp ./demo_dev/src/LAppModel.hpp
812 --- ./demo_clean/src/LAppModel.hpp 2021-02-17 01:23:17.000000000 +0000
813 +++ ./demo_dev/src/LAppModel.hpp 2021-04-28 12:27:55.836457680 +0100
815 #include <Type/csmRectF.hpp>
816 #include <Rendering/OpenGL/CubismOffscreenSurface_OpenGLES2.hpp>
818 -#include "LAppWavFileHandler.hpp"
819 +#include "mouse_cursor_tracker.h"
822 * @brief ユーザーが実際に使用するモデルの実装クラス<br>
823 @@ -25,8 +25,11 @@ class LAppModel : public Csm::CubismUser
828 + * @param[in] useOldParamId : If true, translate new (Cubism 3+)
829 + * parameter IDs to old (Cubism 2.1) ones
832 + LAppModel(bool useOldParamId);
836 @@ -114,6 +117,15 @@ public:
838 Csm::Rendering::CubismOffscreenFrame_OpenGLES2& GetRenderBuffer();
841 + * @brief Set the pointer to the MouseCursorTracker instance
843 + * @param[in] tracker : Pointer to MouseCursorTracker instance
845 + void SetTracker(MouseCursorTracker *tracker);
847 + Csm::ICubismModelSetting* GetModelSetting(void) const;
851 * @brief モデルを描画する処理。モデルを描画する空間のView-Projection行列を渡す。
852 @@ -167,6 +179,17 @@ private:
854 void ReleaseExpressions();
857 + * @brief Translate new (Cubism 3+) parameter IDs to old (Cubism 2.1) ones
859 + * @param[in] s : New parameter ID
861 + * @return Old parameter ID
863 + Csm::csmString _(std::string s);
865 + bool _useOldParamId;
867 Csm::ICubismModelSetting* _modelSetting; ///< モデルセッティング情報
868 Csm::csmString _modelHomeDir; ///< モデルセッティングが置かれたディレクトリ
869 Csm::csmFloat32 _userTimeSeconds; ///< デルタ時間の積算値[秒]
870 @@ -183,9 +206,9 @@ private:
871 const Csm::CubismId* _idParamEyeBallX; ///< パラメータID: ParamEyeBallX
872 const Csm::CubismId* _idParamEyeBallY; ///< パラメータID: ParamEyeBallXY
874 - LAppWavFileHandler _wavFileHandler; ///< wavファイルハンドラ
876 Csm::Rendering::CubismOffscreenFrame_OpenGLES2 _renderBuffer; ///< フレームバッファ以外の描画先
878 + MouseCursorTracker *_tracker;
882 diff -pruN --exclude build ./demo_clean/src/LAppPal.cpp ./demo_dev/src/LAppPal.cpp
883 --- ./demo_clean/src/LAppPal.cpp 2021-02-17 01:23:17.000000000 +0000
884 +++ ./demo_dev/src/LAppPal.cpp 2021-04-28 12:18:50.952333251 +0100
888 #include "LAppPal.hpp"
889 +#include <stdexcept>
893 @@ -36,7 +37,6 @@ csmByte* LAppPal::LoadFileAsBytes(const
894 if (stat(path, &statBuf) == 0)
896 size = statBuf.st_size;
901 @@ -45,10 +45,7 @@ csmByte* LAppPal::LoadFileAsBytes(const
902 file.open(path, std::ios::in | std::ios::binary);
905 - if (DebugLogEnable)
907 - PrintLog("file open error");
909 + throw std::runtime_error("Failed to open file " + filePath);
912 file.read(buf, size);
913 diff -pruN --exclude build ./demo_clean/src/LAppTextureManager.cpp ./demo_dev/src/LAppTextureManager.cpp
914 --- ./demo_clean/src/LAppTextureManager.cpp 2021-02-17 01:23:17.000000000 +0000
915 +++ ./demo_dev/src/LAppTextureManager.cpp 2021-04-28 12:18:50.952333251 +0100
916 @@ -96,6 +96,46 @@ LAppTextureManager::TextureInfo* LAppTex
920 +LAppTextureManager::TextureInfo* LAppTextureManager::CreateTextureFromColor(
921 + uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha
924 + int width = 8, height = 8;
926 + uint8_t pixels[height][width][4];
927 + for (std::size_t h = 0; h < height; h++)
929 + for (std::size_t w = 0; w < width; w++)
931 + pixels[h][w][0] = red;
932 + pixels[h][w][1] = green;
933 + pixels[h][w][2] = blue;
934 + pixels[h][w][3] = alpha;
939 + glGenTextures(1, &textureId);
940 + glBindTexture(GL_TEXTURE_2D, textureId);
941 + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
943 + glGenerateMipmap(GL_TEXTURE_2D);
944 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
945 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
946 + glBindTexture(GL_TEXTURE_2D, 0);
949 + LAppTextureManager::TextureInfo* textureInfo = new LAppTextureManager::TextureInfo();
950 + textureInfo->fileName = "";
951 + textureInfo->width = width;
952 + textureInfo->height = height;
953 + textureInfo->id = textureId;
955 + _textures.PushBack(textureInfo);
957 + return textureInfo;
960 void LAppTextureManager::ReleaseTextures()
962 for (Csm::csmUint32 i = 0; i < _textures.GetSize(); i++)
963 diff -pruN --exclude build ./demo_clean/src/LAppTextureManager.hpp ./demo_dev/src/LAppTextureManager.hpp
964 --- ./demo_clean/src/LAppTextureManager.hpp 2021-02-17 01:23:17.000000000 +0000
965 +++ ./demo_dev/src/LAppTextureManager.hpp 2021-04-28 12:18:50.952333251 +0100
966 @@ -72,6 +72,8 @@ public:
968 TextureInfo* CreateTextureFromPngFile(std::string fileName);
970 + TextureInfo *CreateTextureFromColor(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha = 255);
975 diff -pruN --exclude build ./demo_clean/src/LAppView.cpp ./demo_dev/src/LAppView.cpp
976 --- ./demo_clean/src/LAppView.cpp 2021-02-17 01:23:17.000000000 +0000
977 +++ ./demo_dev/src/LAppView.cpp 2021-04-28 12:18:50.952333251 +0100
979 #include "LAppLive2DManager.hpp"
980 #include "LAppTextureManager.hpp"
981 #include "LAppDefine.hpp"
982 -#include "TouchManager.hpp"
983 #include "LAppSprite.hpp"
984 #include "LAppModel.hpp"
986 @@ -26,8 +25,6 @@ using namespace LAppDefine;
987 LAppView::LAppView():
993 _renderTarget(SelectTarget_None)
995 @@ -35,8 +32,6 @@ LAppView::LAppView():
996 _clearColor[1] = 1.0f;
997 _clearColor[2] = 1.0f;
998 _clearColor[3] = 0.0f;
1000 - _touchManager = new TouchManager();
1002 // デバイス座標からスクリーン座標に変換するための
1003 _deviceToScreen = new CubismMatrix44();
1004 @@ -52,10 +47,7 @@ LAppView::~LAppView()
1007 delete _deviceToScreen;
1008 - delete _touchManager;
1014 void LAppView::Initialize()
1015 @@ -107,9 +99,6 @@ void LAppView::Initialize()
1016 void LAppView::Render()
1023 LAppLive2DManager* Live2DManager = LAppLive2DManager::GetInstance();
1025 @@ -151,35 +140,17 @@ void LAppView::InitializeSprite()
1026 glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &width, &height);
1028 LAppTextureManager* textureManager = LAppDelegate::GetInstance()->GetTextureManager();
1029 - const string resourcesPath = LAppDelegate::GetInstance()->GetRootDirectory() + ResourcesPath;
1031 - string imageName = BackImageName;
1032 - LAppTextureManager::TextureInfo* backgroundTexture = textureManager->CreateTextureFromPngFile(resourcesPath + imageName);
1034 + LAppTextureManager::TextureInfo* backgroundTexture =
1035 + textureManager->CreateTextureFromColor(0, 255, 0);
1037 float x = width * 0.5f;
1038 float y = height * 0.5f;
1039 - float fWidth = static_cast<float>(backgroundTexture->width * 2.0f);
1040 - float fHeight = static_cast<float>(height) * 0.95f;
1041 + float fWidth = static_cast<float>(width);
1042 + float fHeight = static_cast<float>(height);
1043 _back = new LAppSprite(x, y, fWidth, fHeight, backgroundTexture->id, _programId);
1045 - imageName = GearImageName;
1046 - LAppTextureManager::TextureInfo* gearTexture = textureManager->CreateTextureFromPngFile(resourcesPath + imageName);
1048 - x = static_cast<float>(width - gearTexture->width * 0.5f);
1049 - y = static_cast<float>(height - gearTexture->height * 0.5f);
1050 - fWidth = static_cast<float>(gearTexture->width);
1051 - fHeight = static_cast<float>(gearTexture->height);
1052 - _gear = new LAppSprite(x, y, fWidth, fHeight, gearTexture->id, _programId);
1054 - imageName = PowerImageName;
1055 - LAppTextureManager::TextureInfo* powerTexture = textureManager->CreateTextureFromPngFile(resourcesPath + imageName);
1057 - x = static_cast<float>(width - powerTexture->width * 0.5f);
1058 - y = static_cast<float>(powerTexture->height * 0.5f);
1059 - fWidth = static_cast<float>(powerTexture->width);
1060 - fHeight = static_cast<float>(powerTexture->height);
1061 - _power = new LAppSprite(x, y, fWidth, fHeight, powerTexture->id, _programId);
1066 @@ -187,52 +158,6 @@ void LAppView::InitializeSprite()
1070 -void LAppView::OnTouchesBegan(float px, float py) const
1072 - _touchManager->TouchesBegan(px, py);
1075 -void LAppView::OnTouchesMoved(float px, float py) const
1077 - float viewX = this->TransformViewX(_touchManager->GetX());
1078 - float viewY = this->TransformViewY(_touchManager->GetY());
1080 - _touchManager->TouchesMoved(px, py);
1082 - LAppLive2DManager* Live2DManager = LAppLive2DManager::GetInstance();
1083 - Live2DManager->OnDrag(viewX, viewY);
1086 -void LAppView::OnTouchesEnded(float px, float py) const
1089 - LAppLive2DManager* live2DManager = LAppLive2DManager::GetInstance();
1090 - live2DManager->OnDrag(0.0f, 0.0f);
1094 - float x = _deviceToScreen->TransformX(_touchManager->GetX()); // 論理座標変換した座標を取得。
1095 - float y = _deviceToScreen->TransformY(_touchManager->GetY()); // 論理座標変換した座標を取得。
1096 - if (DebugTouchLogEnable)
1098 - LAppPal::PrintLog("[APP]touchesEnded x:%.2f y:%.2f", x, y);
1100 - live2DManager->OnTap(x, y);
1103 - if (_gear->IsHit(px, py))
1105 - live2DManager->NextScene();
1109 - if (_power->IsHit(px, py))
1111 - LAppDelegate::GetInstance()->AppEnd();
1116 float LAppView::TransformViewX(float deviceX) const
1118 float screenX = _deviceToScreen->TransformX(deviceX); // 論理座標変換した座標を取得。
1119 @@ -374,32 +299,4 @@ void LAppView::ResizeSprite()
1120 _back->ResetRect(x, y, fWidth, fHeight);
1126 - GLuint id = _power->GetTextureId();
1127 - LAppTextureManager::TextureInfo* texInfo = textureManager->GetTextureInfoById(id);
1130 - x = static_cast<float>(width - texInfo->width * 0.5f);
1131 - y = static_cast<float>(texInfo->height * 0.5f);
1132 - fWidth = static_cast<float>(texInfo->width);
1133 - fHeight = static_cast<float>(texInfo->height);
1134 - _power->ResetRect(x, y, fWidth, fHeight);
1140 - GLuint id = _gear->GetTextureId();
1141 - LAppTextureManager::TextureInfo* texInfo = textureManager->GetTextureInfoById(id);
1144 - x = static_cast<float>(width - texInfo->width * 0.5f);
1145 - y = static_cast<float>(height - texInfo->height * 0.5f);
1146 - fWidth = static_cast<float>(texInfo->width);
1147 - fHeight = static_cast<float>(texInfo->height);
1148 - _gear->ResetRect(x, y, fWidth, fHeight);
1152 diff -pruN --exclude build ./demo_clean/src/LAppView.hpp ./demo_dev/src/LAppView.hpp
1153 --- ./demo_clean/src/LAppView.hpp 2021-02-17 01:23:17.000000000 +0000
1154 +++ ./demo_dev/src/LAppView.hpp 2021-04-28 12:18:50.952333251 +0100
1156 #include "CubismFramework.hpp"
1157 #include <Rendering/OpenGL/CubismOffscreenSurface_OpenGLES2.hpp>
1159 -class TouchManager;
1163 @@ -66,30 +65,6 @@ public:
1164 void ResizeSprite();
1167 - * @brief タッチされたときに呼ばれる。
1169 - * @param[in] pointX スクリーンX座標
1170 - * @param[in] pointY スクリーンY座標
1172 - void OnTouchesBegan(float pointX, float pointY) const;
1175 - * @brief タッチしているときにポインタが動いたら呼ばれる。
1177 - * @param[in] pointX スクリーンX座標
1178 - * @param[in] pointY スクリーンY座標
1180 - void OnTouchesMoved(float pointX, float pointY) const;
1183 - * @brief タッチが終了したら呼ばれる。
1185 - * @param[in] pointX スクリーンX座標
1186 - * @param[in] pointY スクリーンY座標
1188 - void OnTouchesEnded(float pointX, float pointY) const;
1191 * @brief X座標をView座標に変換する。
1193 * @param[in] deviceX デバイスX座標
1194 @@ -147,13 +122,10 @@ public:
1195 void SetRenderTargetClearColor(float r, float g, float b);
1198 - TouchManager* _touchManager; ///< タッチマネージャー
1199 Csm::CubismMatrix44* _deviceToScreen; ///< デバイスからスクリーンへの行列
1200 Csm::CubismViewMatrix* _viewMatrix; ///< viewMatrix
1201 GLuint _programId; ///< シェーダID
1202 LAppSprite* _back; ///< 背景画像
1203 - LAppSprite* _gear; ///< ギア画像
1204 - LAppSprite* _power; ///< 電源画像
1206 // レンダリング先を別ターゲットにする方式の場合に使用
1207 LAppSprite* _renderSprite; ///< モードによっては_renderBufferのテクスチャを描画
1208 diff -pruN --exclude build ./demo_clean/src/main.cpp ./demo_dev/src/main.cpp
1209 --- ./demo_clean/src/main.cpp 2021-02-17 01:23:17.000000000 +0000
1210 +++ ./demo_dev/src/main.cpp 2021-04-28 12:28:55.845339613 +0100
1212 * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
1216 +#include <stdexcept>
1222 +#ifdef __cpp_lib_filesystem
1223 +#include <filesystem>
1224 +namespace fs = std::filesystem;
1226 +#include <experimental/filesystem>
1227 +namespace fs = std::experimental::filesystem;
1230 +#include "ICubismModelSetting.hpp"
1231 #include "LAppDelegate.hpp"
1232 +#include "LAppLive2DManager.hpp"
1233 +#include "LAppModel.hpp"
1234 +#include "mouse_cursor_tracker.h"
1240 + std::string windowTitle;
1241 + std::string rootDir;
1242 + float scaleFactor;
1245 + std::string modelName;
1246 + bool oldId; // If true, translate new (Cubism 3+) parameter IDs to old (Cubism 2.1) IDs
1247 + std::string cfgPath; // Path to config file for MouseCursorTracker
1250 +CmdArgs parseArgv(int argc, char *argv[])
1252 + // I think the command-line args are simple enough to not justify using a library...
1254 + // Set default values
1255 + cmdArgs.windowWidth = 600;
1256 + cmdArgs.windowHeight = 600;
1257 + cmdArgs.windowTitle = "MouseTrackerForCubism example";
1258 + cmdArgs.rootDir = fs::current_path();
1259 + cmdArgs.scaleFactor = 4.5f;
1260 + cmdArgs.translateX = 0.0f;
1261 + cmdArgs.translateY = -3.1f;
1262 + cmdArgs.modelName = "Haru";
1263 + cmdArgs.oldId = false;
1264 + cmdArgs.cfgPath = "";
1269 + std::string arg = argv[i];
1270 + std::stringstream ss;
1272 + if (arg == "--window-width" || arg == "-W") // capital W for consistency with height
1274 + ss << argv[i + 1];
1275 + if (!(ss >> cmdArgs.windowWidth))
1277 + throw std::runtime_error("Invalid argument for window width");
1280 + else if (arg == "--window-height" || arg == "-H") // avoiding "-h", typically for help
1282 + ss << argv[i + 1];
1283 + if (!(ss >> cmdArgs.windowHeight))
1285 + throw std::runtime_error("Invalid argument for window height");
1288 + else if (arg == "--window-title" || arg == "-t")
1290 + cmdArgs.windowTitle = argv[i + 1];
1292 + else if (arg == "--root-dir" || arg == "-d")
1294 + cmdArgs.rootDir = argv[i + 1];
1296 + else if (arg == "--scale-factor" || arg == "-f")
1298 + ss << argv[i + 1];
1299 + if (!(ss >> cmdArgs.scaleFactor))
1301 + throw std::runtime_error("Invalid argument for scale factor");
1304 + else if (arg == "--translate-x" || arg == "-x")
1306 + ss << argv[i + 1];
1307 + if (!(ss >> cmdArgs.translateX))
1309 + throw std::runtime_error("Invalid argument for translate X");
1312 + else if (arg == "--translate-y" || arg == "-y")
1314 + ss << argv[i + 1];
1315 + if (!(ss >> cmdArgs.translateY))
1317 + throw std::runtime_error("Invalid argument for translate Y");
1320 + else if (arg == "--model" || arg == "-m")
1322 + cmdArgs.modelName = argv[i + 1];
1324 + else if (arg == "--config" || arg == "-c")
1326 + cmdArgs.cfgPath = argv[i + 1];
1328 + else if (arg == "--old-param-id" || arg == "-o")
1330 + cmdArgs.oldId = (argv[i + 1][0] == '1');
1334 + throw std::runtime_error("Unrecognized argument: " + arg);
1343 int main(int argc, char* argv[])
1345 - // create the application instance
1346 - if (LAppDelegate::GetInstance()->Initialize() == GL_FALSE)
1347 + auto cmdArgs = parseArgv(argc, argv);
1349 + LAppDelegate *delegate = LAppDelegate::GetInstance();
1351 + if (!delegate->Initialize(cmdArgs.windowWidth,
1352 + cmdArgs.windowHeight,
1353 + cmdArgs.windowTitle.c_str()))
1356 + throw std::runtime_error("Unable to initialize LAppDelegate");
1359 - LAppDelegate::GetInstance()->Run();
1360 + delegate->SetRootDirectory(cmdArgs.rootDir);
1362 + LAppLive2DManager *manager = LAppLive2DManager::GetInstance();
1363 + manager->SetModel(cmdArgs.modelName, cmdArgs.oldId);
1365 + manager->SetProjectionScaleTranslate(cmdArgs.scaleFactor,
1366 + cmdArgs.translateX,
1367 + cmdArgs.translateY);
1369 + LAppModel *model = manager->GetModel(0);
1370 + if (!model) throw std::runtime_error("model is null");
1372 + Live2D::Cubism::Framework::ICubismModelSetting *modelSetting = model->GetModelSetting();
1373 + if (!modelSetting) throw std::runtime_error("modelSetting is null");
1375 + std::vector<std::pair<std::string, int> > motions;
1376 + int motionGroupCount = modelSetting->GetMotionGroupCount();
1377 + for (int i = 0; i < motionGroupCount; i++)
1379 + const char *motionGroup = modelSetting->GetMotionGroupName(i);
1380 + int motionCount = modelSetting->GetMotionCount(motionGroup);
1381 + motions.push_back(std::make_pair(std::string(motionGroup), motionCount));
1384 + std::vector<std::string> expressions;
1385 + int expCount = modelSetting->GetExpressionCount();
1386 + for (int i = 0; i < expCount; i++)
1388 + const char *expName = modelSetting->GetExpressionName(i);
1389 + expressions.push_back(std::string(expName));
1392 + MouseCursorTracker tracker(cmdArgs.cfgPath, motions, expressions);
1394 + std::thread trackerThread(&MouseCursorTracker::mainLoop, &tracker);
1395 + manager->SetTracker(&tracker);
1400 + trackerThread.join();