Skip to content

Commit

Permalink
Merge pull request #9 from Live2D/develop
Browse files Browse the repository at this point in the history
Update to Cubism 5 SDK for Java R1 beta1
  • Loading branch information
itoh-at-live2d-com authored Aug 17, 2023
2 parents 156ba1f + 1704591 commit f2bae74
Show file tree
Hide file tree
Showing 34 changed files with 9,149 additions and 98 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ 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/).

## [5-r.1-beta.1] - 2023-08-17

### Added

* Add Wankoromochi as a model bundled with SDK.

### Changed

* Change the minimum support version of Android OS to 5.0 (API 21).
* Unify Offscreen drawing-related terminology with `OffscreenSurface`.
* Adjust to automatically search and use models in the assets folder.


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

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

* New released!

[5-r.1-beta.1]: https://github.com/Live2D/CubismJavaSamples/compare/4-r.1...5-r.1-beta.1
[4-r.1]: https://github.com/Live2D/CubismJavaSamples/compare/4-r.1-beta.4...4-r.1
[4-r.1-beta.4]: https://github.com/Live2D/CubismJavaSamples/compare/4-r.1-beta.3...4-r.1-beta.4
[4-r.1-beta.3]: https://github.com/Live2D/CubismJavaSamples/compare/4-r.1-beta.2...4-r.1-beta.3
Expand Down
20 changes: 20 additions & 0 deletions Core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,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/).


## 2023-08-17

### Added

* Enhance Blend Shape features.
* Please see [here](https://docs.live2d.com/en/cubism-editor-manual/blend-shape/).

### Changed

* Upgrade Core version to 05.00.0000.


## 2023-05-09

### Changed

* Change the GCC version of the library for Linux from 6.5.0 to 8.3.0.


## 2023-03-16

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Framework
Submodule Framework updated 26 files
+28 −0 CHANGELOG.md
+10 −2 README.ja.md
+10 −2 README.md
+1 −1 build.gradle
+3 −3 framework/build.gradle
+1 −1 framework/src/main/java/com/live2d/sdk/cubism/framework/effect/CubismPose.java
+23 −23 framework/src/main/java/com/live2d/sdk/cubism/framework/id/CubismId.java
+10 −0 framework/src/main/java/com/live2d/sdk/cubism/framework/model/CubismModel.java
+2 −2 framework/src/main/java/com/live2d/sdk/cubism/framework/model/CubismModelUserData.java
+2 −1 framework/src/main/java/com/live2d/sdk/cubism/framework/model/CubismUserModel.java
+30 −19 framework/src/main/java/com/live2d/sdk/cubism/framework/motion/ACubismMotion.java
+156 −1 framework/src/main/java/com/live2d/sdk/cubism/framework/motion/CubismExpressionMotion.java
+225 −0 framework/src/main/java/com/live2d/sdk/cubism/framework/motion/CubismExpressionMotionManager.java
+9 −0 framework/src/main/java/com/live2d/sdk/cubism/framework/motion/CubismMotionQueueEntry.java
+9 −0 framework/src/main/java/com/live2d/sdk/cubism/framework/motion/CubismMotionQueueManager.java
+55 −23 framework/src/main/java/com/live2d/sdk/cubism/framework/rendering/ACubismClippingContext.java
+578 −0 framework/src/main/java/com/live2d/sdk/cubism/framework/rendering/ACubismClippingManager.java
+40 −28 framework/src/main/java/com/live2d/sdk/cubism/framework/rendering/CubismRenderer.java
+103 −0 framework/src/main/java/com/live2d/sdk/cubism/framework/rendering/ICubismClippingManager.java
+43 −0 framework/src/main/java/com/live2d/sdk/cubism/framework/rendering/android/CubismClippingContextAndroid.java
+74 −634 framework/src/main/java/com/live2d/sdk/cubism/framework/rendering/android/CubismClippingManagerAndroid.java
+23 −23 framework/src/main/java/com/live2d/sdk/cubism/framework/rendering/android/CubismOffscreenSurfaceAndroid.java
+81 −180 framework/src/main/java/com/live2d/sdk/cubism/framework/rendering/android/CubismRendererAndroid.java
+259 −240 framework/src/main/java/com/live2d/sdk/cubism/framework/rendering/android/CubismShaderAndroid.java
+1 −1 gradle.properties
+3 −3 gradle/wrapper/gradle-wrapper.properties
1 change: 1 addition & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Sample/src/main/assets/Mao
Sample/src/main/assets/Mark
Sample/src/main/assets/Natori
Sample/src/main/assets/Rice
Sample/src/main/assets/Wanko
```

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.
Expand Down
19 changes: 13 additions & 6 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@

# Cubism Java Samples

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

## ライセンス

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


## Cubism 5新機能や過去バージョンとの互換性について

本 SDK はCubism 5に対応した製品です。
Cubism 5 Editorに搭載された新機能のSDK対応については [こちら](https://docs.live2d.com/cubism-sdk-manual/cubism-5-new-functions/)をご確認ください。
過去バージョンのCubism SDKとの互換性については [こちら](https://docs.live2d.com/cubism-sdk-manual/compatibility-with-cubism-5/)をご確認ください。


## ディレクトリ構成

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

| 開発ツール | バージョン |
|----------------|------------------|
| Android Studio | Flamingo 2022.2.1 Patch 1 |
| IntelliJ IDEA | 2023.1.1 |
| Android Studio | Giraffe 2022.3.1 |
| CMake | 3.1.0 |
| Gradle | 6.9 |
| Gradle | 8.1.1 |

### Android

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

### Java

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

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

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

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

Expand Down
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@

# Cubism Java Samples

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

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

## License

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


## Compatibility with Cubism 5 new features and previous Cubism SDK versions

This SDK is compatible with Cubism 5.
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/).
For compatibility with previous versions of Cubism SDK, please refer to [here](https://docs.live2d.com/en/cubism-sdk-manual/compatibility-with-cubism-5/).


## Directory structure

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

| Development Tools | Version |
|-------------------|--|
| Android Studio | Flamingo 2022.2.1 Patch 1 |
| IntelliJ IDEA | 2023.1.1 |
| Android Studio | Giraffe 2022.3.1 |
| CMake | 3.1.0 |
| Gradle | 6.9 |
| Gradle | 8.1.1 |

### Android

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

### Java

This sample application runs with **Java SE 6** or higher Java versions.
This sample application runs with **Java SE 7** or higher Java versions.

### Android

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

This sample application runs with **Android API 16** or higher Android versions.
This sample application runs with **Android API 21** or higher Android versions.

## Contributing

Expand Down
5 changes: 3 additions & 2 deletions Sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
}

android {
namespace = "com.live2d.demo"
compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()

defaultConfig {
Expand Down Expand Up @@ -52,8 +53,8 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

lintOptions {
Expand Down
7 changes: 3 additions & 4 deletions Sample/src/full/java/com/live2d/demo/full/LAppDelegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.opengl.GLES20;
import android.os.Build;
import com.live2d.demo.LAppDefine;
import com.live2d.demo.LAppDefine.ModelDir;
import com.live2d.sdk.cubism.framework.CubismFramework;

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

// load models
if (LAppLive2DManager.getInstance().getCurrentModel() != currentModel) {
LAppLive2DManager.getInstance().changeScene(currentModel.getOrder());
LAppLive2DManager.getInstance().changeScene(currentModel);
}

isActive = true;
Expand Down Expand Up @@ -220,7 +219,7 @@ public int getWindowHeight() {
private static LAppDelegate s_instance;

private LAppDelegate() {
currentModel = ModelDir.values()[0];
currentModel = 0;

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

/**
* クリックしているか
Expand Down
58 changes: 48 additions & 10 deletions Sample/src/full/java/com/live2d/demo/full/LAppLive2DManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
import com.live2d.sdk.cubism.framework.motion.ACubismMotion;
import com.live2d.sdk.cubism.framework.motion.IFinishedMotionCallback;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import android.content.res.AssetManager;

import static com.live2d.demo.LAppDefine.*;

/**
Expand Down Expand Up @@ -42,6 +46,34 @@ public void releaseAllModel() {
models.clear();
}

/**
* assets フォルダにあるモデルフォルダ名をセットする
*/
public void setUpModel() {
// assetsフォルダの中にあるフォルダ名を全てクロールし、モデルが存在するフォルダを定義する。
// フォルダはあるが同名の.model3.jsonが見つからなかった場合はリストに含めない。
modelDir.clear();

final AssetManager assets = LAppDelegate.getInstance().getActivity().getResources().getAssets();
try {
String[] root = assets.list("");
for (String subdir: root) {
String[] files = assets.list(subdir);
String target = subdir + ".model3.json";
// フォルダと同名の.model3.jsonがあるか探索する
for (String file : files) {
if (file.equals(target)) {
modelDir.add(subdir);
break;
}
}
}
Collections.sort(modelDir);
} catch (IOException ex) {
throw new IllegalStateException(ex);
}
}

// モデル更新処理及び描画処理を行う
public void onUpdate() {
int width = LAppDelegate.getInstance().getWindowWidth();
Expand Down Expand Up @@ -132,7 +164,7 @@ else if (model.hitTest(HitAreaName.BODY.getId(), x, y)) {
* サンプルアプリケーションではモデルセットの切り替えを行う
*/
public void nextScene() {
final int number = (currentModel.getOrder() + 1) % ModelDir.values().length;
final int number = (currentModel + 1) % modelDir.size();

changeScene(number);
}
Expand All @@ -143,14 +175,15 @@ public void nextScene() {
* @param index 切り替えるシーンインデックス
*/
public void changeScene(int index) {
currentModel = ModelDir.values()[index];
currentModel = index;
if (DEBUG_LOG_ENABLE) {
LAppPal.printLog("model index: " + currentModel.getOrder());
LAppPal.printLog("model index: " + currentModel);
}

String modelDirName = currentModel.getDirName();
String modelDirName = modelDir.get(index);

String modelPath = ResourcePath.ROOT.getPath() + modelDirName + "/";
String modelJsonName = currentModel.getDirName() + ".model3.json";
String modelJsonName = modelDirName + ".model3.json";

releaseAllModel();

Expand Down Expand Up @@ -207,7 +240,7 @@ public LAppModel getModel(int number) {
*
* @return シーンインデックス
*/
public ModelDir getCurrentModel() {
public int getCurrentModel() {
return currentModel;
}

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

private LAppLive2DManager() {
currentModel = ModelDir.values()[0];
changeScene(currentModel.getOrder());
setUpModel();
changeScene(0);
}

private final List<LAppModel> models = new ArrayList<LAppModel>();
private final List<LAppModel> models = new ArrayList<>();

/**
* 表示するシーンのインデックス値
*/
private ModelDir currentModel;
private int currentModel;

/**
* モデルディレクトリ名
*/
private final List<String> modelDir = new ArrayList<>();

// onUpdateメソッドで使用されるキャッシュ変数
private final CubismMatrix44 viewMatrix = CubismMatrix44.create();
Expand Down
4 changes: 2 additions & 2 deletions Sample/src/full/java/com/live2d/demo/full/LAppView.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public void render() {
* @param refModel モデルデータ
*/
public void preModelDraw(LAppModel refModel) {
// 別のレンダリングターゲットへ向けて描画する場合の使用するフレームバッファ
// 別のレンダリングターゲットへ向けて描画する場合の使用するオフスクリーンサーフェス
CubismOffscreenSurfaceAndroid useTarget;

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

// モデル描画キャンバス
useTarget.createOffscreenFrame((int) width, (int) height, null);
useTarget.createOffscreenSurface((int) width, (int) height, null);
}
// レンダリング開始
useTarget.beginDraw(null);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f2bae74

Please sign in to comment.