Skip to content

Commit

Permalink
Merge pull request #38 from Live2D/develop
Browse files Browse the repository at this point in the history
Update to Cubism 4 SDK for Native R7
  • Loading branch information
itoh-at-live2d-com authored May 25, 2023
2 parents ffc60e1 + 044c9b0 commit bd14cff
Show file tree
Hide file tree
Showing 52 changed files with 340 additions and 57 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).


## [4-r.7] - 2023-05-25

### Added

* Add some functions for checking consistency of MOC3 files.
* Add the function of checking consistency in `LAppModel::SetupModel()`.
* Add the function of checking consistency before loading a model. (`LAppModel::HasMocConsistencyFromFile()`)
* This feature is enabled by default.Please see the following manual for more information.
* https://docs.live2d.com/cubism-sdk-manual/moc3-consistency/

### Changed

* Change so that when `USE_MODEL_RENDER_TARGET` is defined, one model will apply the opacity obtained from the motion.

### Fixed

* Fix a problem in which `haru` motion and voice were incorrect combination.
* Fix opacity of drawn models when using `USE_RENDER_TARGET` macro.


## [4-r.6.2] - 2023-03-16

### Changed
Expand Down Expand Up @@ -285,6 +305,7 @@ See [Core Changelog] for details.
* What was `Package.json` is currently being changed to`cubism-info.yml`.


[4-r.7]: https://github.com/Live2D/CubismNativeSamples/compare/4-r.6.2...4-r.7
[4-r.6.2]: https://github.com/Live2D/CubismNativeSamples/compare/4-r.6.1...4-r.6.2
[4-r.6.1]: https://github.com/Live2D/CubismNativeSamples/compare/4-r.6...4-r.6.1
[4-r.6]: https://github.com/Live2D/CubismNativeSamples/compare/4-r.5.1...4-r.6
Expand Down
24 changes: 12 additions & 12 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ Demo

| 開発ツール | バージョン |
| --- | --- |
| Android Studio | Electric Eel 2022.1.1 Patch 1 |
| CMake | 3.25.2 |
| Android Studio | Flamingo 2022.2.1 Patch 1 |
| CMake | 3.26.3 |
| Visual Studio 2013 | Update 5 |
| Visual Studio 2015 | Update 3 |
| Visual Studio 2017 | 15.9.51 |
| Visual Studio 2019 | 16.11.23 |
| Visual Studio 2022 | 17.4.4 |
| XCode | 14.2 |
| Visual Studio 2017 | 15.9.54 |
| Visual Studio 2019 | 16.11.26 |
| Visual Studio 2022 | 17.5.5 |
| XCode | 14.3 |

### Android

Expand All @@ -125,7 +125,7 @@ Demo
| Red Hat | CentOS Stream 8 *1 | `centos:latest` | 8.5.0 |
| Red Hat | CentOS Stream 9 | - | 11.3.1 |
| Debian | Ubuntu 18.04 | `ubuntu:18.04` | 7.5.0 |
| Debian | Ubuntu 22.04.1 | `ubuntu:22.04.1` | 11.3.0 |
| Debian | Ubuntu 22.04.2 | `ubuntu:22.04.2` | 11.3.0 |

*1 CentOS 8はサポートしておりません

Expand All @@ -143,10 +143,10 @@ Demo

| プラットフォーム | バージョン |
| --- | --- |
| iOS / iPadOS | 16.3 |
| macOS | 13.2 |
| Windows 10 | 21H2 |
| Windows 11 | 21H2 |
| iOS / iPadOS | 16.4.1 |
| macOS | 13.3 |
| Windows 10 | 22H2 |
| Windows 11 | 22H2 |

### Android

Expand All @@ -162,7 +162,7 @@ Demo
| Red Hat | Amazon Linux | 2 |
| Red Hat | CentOS Stream | 8 |
| Red Hat | CentOS Stream | 9 |
| Debian | Ubuntu | 22.04.1 |
| Debian | Ubuntu | 22.04.2 |

## プロジェクトへの貢献

Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ Please refer to [CHANGELOG.md](CHANGELOG.md) for the changelog of this repositor

| Development Tool | Version |
| --- | --- |
| Android Studio | Electric Eel 2022.1.1 Patch 1 |
| CMake | 3.25.2 |
| Android Studio | Flamingo 2022.2.1 Patch 1 |
| CMake | 3.26.3 |
| Visual Studio 2013 | Update 5 |
| Visual Studio 2015 | Update 3 |
| Visual Studio 2017 | 15.9.51 |
| Visual Studio 2019 | 16.11.23 |
| Visual Studio 2022 | 17.4.4 |
| XCode | 14.2 |
| Visual Studio 2017 | 15.9.54 |
| Visual Studio 2019 | 16.11.26 |
| Visual Studio 2022 | 17.5.5 |
| XCode | 14.3 |

### Android

Expand Down Expand Up @@ -142,10 +142,10 @@ Please refer to [CHANGELOG.md](CHANGELOG.md) for the changelog of this repositor

| Platform | Version |
| --- | --- |
| iOS / iPadOS | 16.3 |
| macOS | 13.2 |
| Windows 10 | 21H2 |
| Windows 11 | 21H2 |
| iOS / iPadOS | 16.4.1 |
| macOS | 13.3 |
| Windows 10 | 22H2 |
| Windows 11 | 22H2 |

### Android

Expand Down
2 changes: 1 addition & 1 deletion Samples/Cocos2d-x/Demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ if(APPLE)
set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "")
set_xcode_property(${APP_NAME} CODE_SIGN_IDENTITY "iPhone Developer")
set_xcode_property(${APP_NAME} PRODUCT_BUNDLE_IDENTIFIER "com.live2d.demo-4-r6-cocos2dx")
set_xcode_property(${APP_NAME} PRODUCT_BUNDLE_IDENTIFIER "com.live2d.demo-4-r7-cocos2dx")
set_xcode_property(${APP_NAME} TARGETED_DEVICE_FAMILY "1,2")
set_xcode_property(${APP_NAME} ONLY_ACTIVE_ARCH "NO")
set_xcode_property(${APP_NAME} ARCHS "arm64")
Expand Down
3 changes: 3 additions & 0 deletions Samples/Cocos2d-x/Demo/Classes/LAppDefine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ namespace LAppDefine {
const csmInt32 PriorityNormal = 2;
const csmInt32 PriorityForce = 3;

// MOC3の整合性検証オプション
const csmBool MocConsistencyValidationEnable = true;

// デバッグ用ログの表示オプション
const csmBool DebugLogEnable = true;
const csmBool DebugTouchLogEnable = false;
Expand Down
2 changes: 2 additions & 0 deletions Samples/Cocos2d-x/Demo/Classes/LAppDefine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ namespace LAppDefine {
extern const csmInt32 PriorityNormal; ///< モーションの優先度定数: 2
extern const csmInt32 PriorityForce; ///< モーションの優先度定数: 3

extern const csmBool MocConsistencyValidationEnable; ///< MOC3の整合性検証機能の有効・無効

// デバッグ用ログの表示
extern const csmBool DebugLogEnable; ///< デバッグ用ログ表示の有効・無効
extern const csmBool DebugTouchLogEnable; ///< タッチ処理のデバッグ用ログ表示の有効・無効
Expand Down
16 changes: 14 additions & 2 deletions Samples/Cocos2d-x/Demo/Classes/LAppLive2DManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ void LAppLive2DManager::OnUpdate(Csm::Rendering::CubismCommandBuffer_Cocos2dx* c
model->Update();
model->Draw(commandBuffer, projection);///< 参照渡しなのでprojectionは変質する

// 各モデルが持つ描画ターゲットをテクスチャとする場合
if (_renderTarget == SelectTarget_ModelFrameBuffer)
{
// レンダリング先とスプライトを作成
model->MakeRenderingTarget();
// αを付ける
float alpha = i < 1 ? 1.0f : model->GetOpacity(); // 片方のみ不透明度を取得できるようにする
model->SetSpriteColor(1.0f, 1.0f, 1.0f, alpha);
}

if (_renderTarget == SelectTarget_ViewFrameBuffer && _renderBuffer && _sprite)
{// レンダリングターゲット使いまわしの場合
// レンダリング終了
Expand Down Expand Up @@ -311,8 +321,10 @@ void LAppLive2DManager::ChangeScene(Csm::csmInt32 index)
{
// レンダリング先とスプライトを作成
_models[i]->MakeRenderingTarget();
// 適当なαを付ける
_models[i]->SetSpriteColor(1.0f, 1.0f, 1.0f, 0.25f + 0.5f*(float)i);
// αを付ける
LAppModel* model = _models[i];
float alpha = i < 1 ? 1.0f : model->GetOpacity(); // 片方のみ不透明度を取得できるようにする
_models[i]->SetSpriteColor(1.0f, 1.0f, 1.0f, alpha);
}
}
}
Expand Down
37 changes: 36 additions & 1 deletion Samples/Cocos2d-x/Demo/Classes/LAppModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ LAppModel::LAppModel()
, _userTimeSeconds(0.0f)
, _renderSprite(NULL)
{
if (MocConsistencyValidationEnable)
{
_mocConsistency = true;
}

if (DebugLogEnable)
{
_debugMode = true;
Expand Down Expand Up @@ -161,7 +166,7 @@ void LAppModel::SetupModel(ICubismModelSetting* setting)
if (_debugMode)LAppPal::PrintLog("[APP]create model: %s", setting->GetModelFileName());

buffer = CreateBuffer(path.GetRawString(), &size);
LoadModel(buffer, size);
LoadModel(buffer, size, _mocConsistency);
DeleteBuffer(buffer, path.GetRawString());

}
Expand Down Expand Up @@ -416,6 +421,9 @@ void LAppModel::Update()
_model->SaveParameters(); // 状態を保存
//-----------------------------------------------------------------

// 不透明度
_opacity = _model->GetModelOpacity();

// まばたき
if (!motionUpdated)
{
Expand Down Expand Up @@ -819,3 +827,30 @@ void LAppModel::SetSpriteColor(float r, float g, float b, float a)
_renderSprite->getSprite()->setOpacity(static_cast<unsigned char>(255.0f * a));
}
}

csmBool LAppModel::HasMocConsistencyFromFile(const csmChar* mocFileName)
{
CSM_ASSERT(strcmp(mocFileName, ""));

csmByte* buffer;
csmSizeInt size;

csmString path = mocFileName;
path = _modelHomeDir + path;

buffer = CreateBuffer(path.GetRawString(), &size);

csmBool consistency = CubismMoc::HasMocConsistencyFromUnrevivedMoc(buffer, size);
if (!consistency)
{
CubismLogInfo("Inconsistent MOC3.");
}
else
{
CubismLogInfo("Consistent MOC3.");
}

DeleteBuffer(buffer);

return consistency;
}
7 changes: 7 additions & 0 deletions Samples/Cocos2d-x/Demo/Classes/LAppModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ class LAppModel : public Csm::CubismUserModel
*/
void SetSpriteColor(float r, float g, float b, float a);

/**
* @brief .moc3ファイルの整合性をチェックする
*
* @param[in] mocName MOC3ファイル名
* @return MOC3に整合性があれば'true'、そうでなければ'false'。
*/
Csm::csmBool HasMocConsistencyFromFile(const Csm::csmChar* mocFileName);

protected:
/**
Expand Down
3 changes: 3 additions & 0 deletions Samples/D3D11/Demo/proj.d3d11.cmake/src/LAppDefine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ namespace LAppDefine {
const csmInt32 PriorityNormal = 2;
const csmInt32 PriorityForce = 3;

// MOC3の整合性検証オプション
const csmBool MocConsistencyValidationEnable = true;

// デバッグ用ログの表示オプション
const csmBool DebugLogEnable = true;
const csmBool DebugTouchLogEnable = false;
Expand Down
2 changes: 2 additions & 0 deletions Samples/D3D11/Demo/proj.d3d11.cmake/src/LAppDefine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ namespace LAppDefine {
extern const csmInt32 PriorityNormal; ///< モーションの優先度定数: 2
extern const csmInt32 PriorityForce; ///< モーションの優先度定数: 3

extern const csmBool MocConsistencyValidationEnable; ///< MOC3の整合性検証機能の有効・無効

// デバッグ用ログの表示
extern const csmBool DebugLogEnable; ///< デバッグ用ログ表示の有効・無効
extern const csmBool DebugTouchLogEnable; ///< タッチ処理のデバッグ用ログ表示の有効・無効
Expand Down
37 changes: 36 additions & 1 deletion Samples/D3D11/Demo/proj.d3d11.cmake/src/LAppModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ LAppModel::LAppModel()
, _userTimeSeconds(0.0f)
, _deleteModel(false)
{
if (MocConsistencyValidationEnable)
{
_mocConsistency = true;
}

if (DebugLogEnable)
{
_debugMode = true;
Expand Down Expand Up @@ -139,7 +144,7 @@ void LAppModel::SetupModel(ICubismModelSetting* setting)
}

buffer = CreateBuffer(path.GetRawString(), &size);
LoadModel(buffer, size);
LoadModel(buffer, size, _mocConsistency);
DeleteBuffer(buffer, path.GetRawString());
}

Expand Down Expand Up @@ -367,6 +372,9 @@ void LAppModel::Update()
_model->SaveParameters(); // 状態を保存
//-----------------------------------------------------------------

// 不透明度
_opacity = _model->GetModelOpacity();

// まばたき
if (!motionUpdated)
{
Expand Down Expand Up @@ -661,3 +669,30 @@ Csm::Rendering::CubismOffscreenFrame_D3D11& LAppModel::GetRenderBuffer()
{
return _renderBuffer;
}

csmBool LAppModel::HasMocConsistencyFromFile(const csmChar* mocFileName)
{
CSM_ASSERT(strcmp(mocFileName, ""));

csmByte* buffer;
csmSizeInt size;

csmString path = mocFileName;
path = _modelHomeDir + path;

buffer = CreateBuffer(path.GetRawString(), &size);

csmBool consistency = CubismMoc::HasMocConsistencyFromUnrevivedMoc(buffer, size);
if (!consistency)
{
CubismLogInfo("Inconsistent MOC3.");
}
else
{
CubismLogInfo("Consistent MOC3.");
}

DeleteBuffer(buffer);

return consistency;
}
7 changes: 7 additions & 0 deletions Samples/D3D11/Demo/proj.d3d11.cmake/src/LAppModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ class LAppModel : public Csm::CubismUserModel
*/
Csm::Rendering::CubismOffscreenFrame_D3D11& GetRenderBuffer();

/**
* @brief .moc3ファイルの整合性をチェックする
*
* @param[in] mocName MOC3ファイル名
* @return MOC3に整合性があれば'true'、そうでなければ'false'。
*/
Csm::csmBool HasMocConsistencyFromFile(const Csm::csmChar* mocFileName);

protected:
/**
Expand Down
4 changes: 2 additions & 2 deletions Samples/D3D11/Demo/proj.d3d11.cmake/src/LAppView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ void LAppView::Render()
{
for(csmUint32 i=0; i<live2DManager->GetModelNum(); i++)
{
float alpha = GetSpriteAlpha(i); // サンプルとしてαに適当な差をつける
LAppModel* model = live2DManager->GetModel(i);
float alpha = i < 1 ? 1.0f : model->GetOpacity(); // サンプルとしてαに適当な差をつける
_renderSprite->SetColor(1.0f, 1.0f, 1.0f, alpha);

LAppModel *model = live2DManager->GetModel(i);
if (model)
{
_renderSprite->RenderImmidiate(width, height, model->GetRenderBuffer().GetTextureView());
Expand Down
2 changes: 1 addition & 1 deletion Samples/D3D11/README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ DirectX 11 で実装したアプリケーションのサンプル実装です。
| [DirectXTK] | 2013 | April 23, 2018 |
| [DirectXTK] | 2015 | December 17, 2019 |
| [DirectXTK] | 2017 | March 24, 2022 |
| [DirectXTK] | 2019 / 2022 | February 6, 2023 |
| [DirectXTK] | 2019 / 2022 | April 28, 2023 |

その他の開発環境・動作確認環境はトップディレクトリにある [README.md](/README.ja.md) を参照してください。

Expand Down
2 changes: 1 addition & 1 deletion Samples/D3D11/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This is a sample implementation of an application implemented with DirectX 11.
| [DirectXTK] | 2013 | April 23, 2018 |
| [DirectXTK] | 2015 | December 17, 2019 |
| [DirectXTK] | 2017 | March 24, 2022 |
| [DirectXTK] | 2019 / 2022 | February 6, 2023 |
| [DirectXTK] | 2019 / 2022 | April 28, 2023 |

For other development environments and operation environments, see [README.md](/README.md) in the top directory.

Expand Down
2 changes: 1 addition & 1 deletion Samples/D3D11/thirdParty/scripts/setup_msvc2019.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setlocal

set XTK_VERSION=feb2023
set XTK_VERSION=apr2023

set SCRIPT_PATH=%~dp0

Expand Down
Loading

0 comments on commit bd14cff

Please sign in to comment.