Skip to content

Commit 1704591

Browse files
Update to Cubism 5 SDK for Java R1 beta1
1 parent 0c50687 commit 1704591

34 files changed

+9149
-98
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

7+
## [5-r.1-beta.1] - 2023-08-17
8+
9+
### Added
10+
11+
* Add Wankoromochi as a model bundled with SDK.
12+
13+
### Changed
14+
15+
* Change the minimum support version of Android OS to 5.0 (API 21).
16+
* Unify Offscreen drawing-related terminology with `OffscreenSurface`.
17+
* Adjust to automatically search and use models in the assets folder.
18+
19+
720
## [4-r.1] - 2023-05-25
821

922
### Added
@@ -75,6 +88,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
7588

7689
* New released!
7790

91+
[5-r.1-beta.1]: https://github.com/Live2D/CubismJavaSamples/compare/4-r.1...5-r.1-beta.1
7892
[4-r.1]: https://github.com/Live2D/CubismJavaSamples/compare/4-r.1-beta.4...4-r.1
7993
[4-r.1-beta.4]: https://github.com/Live2D/CubismJavaSamples/compare/4-r.1-beta.3...4-r.1-beta.4
8094
[4-r.1-beta.3]: https://github.com/Live2D/CubismJavaSamples/compare/4-r.1-beta.2...4-r.1-beta.3

Core/CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

7+
8+
## 2023-08-17
9+
10+
### Added
11+
12+
* Enhance Blend Shape features.
13+
* Please see [here](https://docs.live2d.com/en/cubism-editor-manual/blend-shape/).
14+
15+
### Changed
16+
17+
* Upgrade Core version to 05.00.0000.
18+
19+
20+
## 2023-05-09
21+
22+
### Changed
23+
24+
* Change the GCC version of the library for Linux from 6.5.0 to 8.3.0.
25+
26+
727
## 2023-03-16
828

929
### Fixed

Framework

Submodule Framework updated 26 files

LICENSE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Sample/src/main/assets/Mao
5353
Sample/src/main/assets/Mark
5454
Sample/src/main/assets/Natori
5555
Sample/src/main/assets/Rice
56+
Sample/src/main/assets/Wanko
5657
```
5758

5859
If you use these models, you must agree to the terms of a contract set [here](https://docs.live2d.com/cubism-editor-manual/sample-model/) for each model.

README.ja.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,21 @@
44

55
# Cubism Java Samples
66

7-
Live2D Cubism 4 Editor で出力したモデルを表示するアプリケーションのサンプル実装です。
7+
Live2D Cubism Editor で出力したモデルを表示するアプリケーションのサンプル実装です。
88
Cubism Java Framework および Live2D Cubism Core Javaと組み合わせて使用します。
99

1010
## ライセンス
1111

1212
本 SDK を使用する前に[ライセンス](LICENSE.md)をご確認ください。
1313

14+
15+
## Cubism 5新機能や過去バージョンとの互換性について
16+
17+
本 SDK はCubism 5に対応した製品です。
18+
Cubism 5 Editorに搭載された新機能のSDK対応については [こちら](https://docs.live2d.com/cubism-sdk-manual/cubism-5-new-functions/)をご確認ください。
19+
過去バージョンのCubism SDKとの互換性については [こちら](https://docs.live2d.com/cubism-sdk-manual/compatibility-with-cubism-5/)をご確認ください。
20+
21+
1422
## ディレクトリ構成
1523

1624
```
@@ -59,10 +67,9 @@ Android Studioでプロジェクトを開きビルドすることを推奨しま
5967

6068
| 開発ツール | バージョン |
6169
|----------------|------------------|
62-
| Android Studio | Flamingo 2022.2.1 Patch 1 |
63-
| IntelliJ IDEA | 2023.1.1 |
70+
| Android Studio | Giraffe 2022.3.1 |
6471
| CMake | 3.1.0 |
65-
| Gradle | 6.9 |
72+
| Gradle | 8.1.1 |
6673

6774
### Android
6875

@@ -76,7 +83,7 @@ Android Studioでプロジェクトを開きビルドすることを推奨しま
7683

7784
### Java
7885

79-
本サンプルアプリケーションは**Java SE 6**以上のJavaバージョンで動作します。
86+
本サンプルアプリケーションは**Java SE 7**以上のJavaバージョンで動作します。
8087

8188
### Android
8289
| バージョン | デバイス | Tegra |
@@ -85,7 +92,7 @@ Android Studioでプロジェクトを開きビルドすることを推奨しま
8592
| 7.1.1 | Nexus 9 ||
8693
| 4.1 | Pixel 5 | |
8794

88-
本サンプルアプリケーションは**Android API 16**以上のAndroidバージョンで動作します。
95+
本サンプルアプリケーションは**Android API 21**以上のAndroidバージョンで動作します。
8996

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

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@
44

55
# Cubism Java Samples
66

7-
This is a sample implementation of an application that displays models output by the Live2D Cubism 4 Editor.
7+
This is a sample implementation of an application that displays models output by the Live2D Cubism Editor.
88

99
It is used in conjunction with Cubism Java Framework and Live2D Cubism Core Java.
1010

1111
## License
1212

1313
Please check the [license](LICENSE.md) before using this SDK.
1414

15+
16+
## Compatibility with Cubism 5 new features and previous Cubism SDK versions
17+
18+
This SDK is compatible with Cubism 5.
19+
For SDK compatibility with new features in Cubism 5 Editor, please refer to [here](https://docs.live2d.com/en/cubism-sdk-manual/cubism-5-new-functions/).
20+
For compatibility with previous versions of Cubism SDK, please refer to [here](https://docs.live2d.com/en/cubism-sdk-manual/compatibility-with-cubism-5/).
21+
22+
1523
## Directory structure
1624

1725
```
@@ -59,10 +67,9 @@ Please refer to [CHANGELOG.md](CHANGELOG.md) for the changelog of this repositor
5967

6068
| Development Tools | Version |
6169
|-------------------|--|
62-
| Android Studio | Flamingo 2022.2.1 Patch 1 |
63-
| IntelliJ IDEA | 2023.1.1 |
70+
| Android Studio | Giraffe 2022.3.1 |
6471
| CMake | 3.1.0 |
65-
| Gradle | 6.9 |
72+
| Gradle | 8.1.1 |
6673

6774
### Android
6875

@@ -76,7 +83,7 @@ Please refer to [CHANGELOG.md](CHANGELOG.md) for the changelog of this repositor
7683

7784
### Java
7885

79-
This sample application runs with **Java SE 6** or higher Java versions.
86+
This sample application runs with **Java SE 7** or higher Java versions.
8087

8188
### Android
8289

@@ -86,7 +93,7 @@ This sample application runs with **Java SE 6** or higher Java versions.
8693
| 7.1.1 | Nexus 9 | ✔︎ |
8794
| 4.1 | Pixel 5 ||
8895

89-
This sample application runs with **Android API 16** or higher Android versions.
96+
This sample application runs with **Android API 21** or higher Android versions.
9097

9198
## Contributing
9299

Sample/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
}
44

55
android {
6+
namespace = "com.live2d.demo"
67
compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
78

89
defaultConfig {
@@ -52,8 +53,8 @@ android {
5253
}
5354

5455
compileOptions {
55-
sourceCompatibility JavaVersion.VERSION_1_6
56-
targetCompatibility JavaVersion.VERSION_1_6
56+
sourceCompatibility JavaVersion.VERSION_1_7
57+
targetCompatibility JavaVersion.VERSION_1_7
5758
}
5859

5960
lintOptions {

Sample/src/full/java/com/live2d/demo/full/LAppDelegate.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import android.opengl.GLES20;
1212
import android.os.Build;
1313
import com.live2d.demo.LAppDefine;
14-
import com.live2d.demo.LAppDefine.ModelDir;
1514
import com.live2d.sdk.cubism.framework.CubismFramework;
1615

1716
import static android.opengl.GLES20.*;
@@ -93,7 +92,7 @@ public void onSurfaceChanged(int width, int height) {
9392

9493
// load models
9594
if (LAppLive2DManager.getInstance().getCurrentModel() != currentModel) {
96-
LAppLive2DManager.getInstance().changeScene(currentModel.getOrder());
95+
LAppLive2DManager.getInstance().changeScene(currentModel);
9796
}
9897

9998
isActive = true;
@@ -220,7 +219,7 @@ public int getWindowHeight() {
220219
private static LAppDelegate s_instance;
221220

222221
private LAppDelegate() {
223-
currentModel = ModelDir.values()[0];
222+
currentModel = 0;
224223

225224
// Set up Cubism SDK framework.
226225
cubismOption.logFunction = new LAppPal.PrintLogFunction();
@@ -243,7 +242,7 @@ private LAppDelegate() {
243242
/**
244243
* モデルシーンインデックス
245244
*/
246-
private ModelDir currentModel;
245+
private int currentModel;
247246

248247
/**
249248
* クリックしているか

Sample/src/full/java/com/live2d/demo/full/LAppLive2DManager.java

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
import com.live2d.sdk.cubism.framework.motion.ACubismMotion;
1212
import com.live2d.sdk.cubism.framework.motion.IFinishedMotionCallback;
1313

14+
import java.io.IOException;
1415
import java.util.ArrayList;
16+
import java.util.Collections;
1517
import java.util.List;
1618

19+
import android.content.res.AssetManager;
20+
1721
import static com.live2d.demo.LAppDefine.*;
1822

1923
/**
@@ -42,6 +46,34 @@ public void releaseAllModel() {
4246
models.clear();
4347
}
4448

49+
/**
50+
* assets フォルダにあるモデルフォルダ名をセットする
51+
*/
52+
public void setUpModel() {
53+
// assetsフォルダの中にあるフォルダ名を全てクロールし、モデルが存在するフォルダを定義する。
54+
// フォルダはあるが同名の.model3.jsonが見つからなかった場合はリストに含めない。
55+
modelDir.clear();
56+
57+
final AssetManager assets = LAppDelegate.getInstance().getActivity().getResources().getAssets();
58+
try {
59+
String[] root = assets.list("");
60+
for (String subdir: root) {
61+
String[] files = assets.list(subdir);
62+
String target = subdir + ".model3.json";
63+
// フォルダと同名の.model3.jsonがあるか探索する
64+
for (String file : files) {
65+
if (file.equals(target)) {
66+
modelDir.add(subdir);
67+
break;
68+
}
69+
}
70+
}
71+
Collections.sort(modelDir);
72+
} catch (IOException ex) {
73+
throw new IllegalStateException(ex);
74+
}
75+
}
76+
4577
// モデル更新処理及び描画処理を行う
4678
public void onUpdate() {
4779
int width = LAppDelegate.getInstance().getWindowWidth();
@@ -132,7 +164,7 @@ else if (model.hitTest(HitAreaName.BODY.getId(), x, y)) {
132164
* サンプルアプリケーションではモデルセットの切り替えを行う
133165
*/
134166
public void nextScene() {
135-
final int number = (currentModel.getOrder() + 1) % ModelDir.values().length;
167+
final int number = (currentModel + 1) % modelDir.size();
136168

137169
changeScene(number);
138170
}
@@ -143,14 +175,15 @@ public void nextScene() {
143175
* @param index 切り替えるシーンインデックス
144176
*/
145177
public void changeScene(int index) {
146-
currentModel = ModelDir.values()[index];
178+
currentModel = index;
147179
if (DEBUG_LOG_ENABLE) {
148-
LAppPal.printLog("model index: " + currentModel.getOrder());
180+
LAppPal.printLog("model index: " + currentModel);
149181
}
150182

151-
String modelDirName = currentModel.getDirName();
183+
String modelDirName = modelDir.get(index);
184+
152185
String modelPath = ResourcePath.ROOT.getPath() + modelDirName + "/";
153-
String modelJsonName = currentModel.getDirName() + ".model3.json";
186+
String modelJsonName = modelDirName + ".model3.json";
154187

155188
releaseAllModel();
156189

@@ -207,7 +240,7 @@ public LAppModel getModel(int number) {
207240
*
208241
* @return シーンインデックス
209242
*/
210-
public ModelDir getCurrentModel() {
243+
public int getCurrentModel() {
211244
return currentModel;
212245
}
213246

@@ -241,16 +274,21 @@ public void execute(ACubismMotion motion) {
241274
private static LAppLive2DManager s_instance;
242275

243276
private LAppLive2DManager() {
244-
currentModel = ModelDir.values()[0];
245-
changeScene(currentModel.getOrder());
277+
setUpModel();
278+
changeScene(0);
246279
}
247280

248-
private final List<LAppModel> models = new ArrayList<LAppModel>();
281+
private final List<LAppModel> models = new ArrayList<>();
249282

250283
/**
251284
* 表示するシーンのインデックス値
252285
*/
253-
private ModelDir currentModel;
286+
private int currentModel;
287+
288+
/**
289+
* モデルディレクトリ名
290+
*/
291+
private final List<String> modelDir = new ArrayList<>();
254292

255293
// onUpdateメソッドで使用されるキャッシュ変数
256294
private final CubismMatrix44 viewMatrix = CubismMatrix44.create();

Sample/src/full/java/com/live2d/demo/full/LAppView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public void render() {
184184
* @param refModel モデルデータ
185185
*/
186186
public void preModelDraw(LAppModel refModel) {
187-
// 別のレンダリングターゲットへ向けて描画する場合の使用するフレームバッファ
187+
// 別のレンダリングターゲットへ向けて描画する場合の使用するオフスクリーンサーフェス
188188
CubismOffscreenSurfaceAndroid useTarget;
189189

190190
// 別のレンダリングターゲットへ向けて描画する場合
@@ -201,7 +201,7 @@ public void preModelDraw(LAppModel refModel) {
201201
int height = LAppDelegate.getInstance().getWindowHeight();
202202

203203
// モデル描画キャンバス
204-
useTarget.createOffscreenFrame((int) width, (int) height, null);
204+
useTarget.createOffscreenSurface((int) width, (int) height, null);
205205
}
206206
// レンダリング開始
207207
useTarget.beginDraw(null);
Loading

0 commit comments

Comments
 (0)