Skip to content

Commit

Permalink
Merge pull request #13 from Live2D/develop
Browse files Browse the repository at this point in the history
Update to Cubism 5 SDK for Java R2
  • Loading branch information
itoh-at-live2d-com authored Nov 7, 2024
2 parents b0a5ab2 + 0abad96 commit 917d01c
Show file tree
Hide file tree
Showing 18 changed files with 273 additions and 56 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ 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.2] - 2024-11-07

### Added

* Add a function to notify when motion playback starts.
* Add right orientation to the fixed orientations in the Android app.
* Add a feature to change render target to the minimum sample.

### Fixed

* Fix a hang-up caused by an improper function call in the application termination process.
* Fix a bug that caused white edge-like objects to be drawn when enabling the `USE_RENDER_TARGET` or `USE_MODEL_RENDER_TARGET` flag in `LAppDefine`.
* Fix a bug where the method of obtaining color location differs between full sample and minimum sample.

### Removed

* Remove armeabi-v7a from architecture support.
* Remove the `startMotion()` method that receives a callback in the minimum sample.
* If you want to use the callback feature, please check the Full sample.


## [5-r.1] - 2024-03-26

### Added
Expand Down Expand Up @@ -140,6 +162,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* New released!


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


## 2024-11-07

### Added

* [Native] Add experimental support `arm64` library for linux.

### Removed

* [Unity,Native,Java] Remove Android ARM v7 library.


## 2024-04-04

### Added

* [Unity] Add library(.so) for HarmonyOS build.


## 2024-03-26

### Remove
Expand Down
1 change: 0 additions & 1 deletion Core/README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ Javaで開発する場合は、このファイルを使用してください。
| プラットフォーム | アーキテクチャ | jar | aar | パス | 注記 |
| --- |----------|---|-----|---|-----|
| Android | ARM64 | || android/Live2DCubismCore.aar | |
| Android | ARMv7 | || android/Live2DCubismCore.aar | このライブラリは現在非推奨で、近日中に削除される予定です。 |
| Android | x86 | || android/Live2DCubismCore.aar | |
| Android | x86_64 | || android/Live2DCubismCore.aar | |
1 change: 0 additions & 1 deletion Core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ Use this file when developing with Java.
| Platform | Architecture | jar | aar | Path | Note |
| --- | --- | --- | --- |------------------------------| --- |
| Android | ARM64 | || android/Live2DCubismCore.aar | |
| Android | ARMv7 | || android/Live2DCubismCore.aar | This library is currently deprecated and will be removed in the near future. |
| Android | x86 | || android/Live2DCubismCore.aar | |
| Android | x86_64 | || android/Live2DCubismCore.aar | |
13 changes: 7 additions & 6 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ Core : [CHANGELOG.md](Core/CHANGELOG.md)

| 開発ツール | バージョン |
|----------------|------------------|
| Android Studio | Iguana 2023.2.1 |
| Android Studio | Ladybug 2024.2.1 Patch 2 |
| Gradle | 8.2 |
| Gradle JDK | 17.0.12 |
| Android SDK | 34.0.0 |

## 動作確認環境
Expand All @@ -82,11 +83,11 @@ Core : [CHANGELOG.md](Core/CHANGELOG.md)
本サンプルアプリケーションは**Java SE 7**以上のJavaバージョンで動作します。

### Android
| バージョン | デバイス | Tegra |
|-------|----------|-------|
| 14 | Pixel 7a | |
| 7.1.1 | Nexus 9 | |
| 4.1 | Pixel 5 | |

| バージョン | デバイス | エミュレーター |
|-------|----------|:-------:|
| 14 | Pixel 7a | |
| 5.0 | Pixel 7a | |

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

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ Core : [CHANGELOG.md](Core/CHANGELOG.md)

| Development Tools | Version |
|-------------------|--|
| Android Studio | Iguana 2023.2.1 |
| Android Studio | Ladybug 2024.2.1 Patch 2 |
| Gradle | 8.2 |
| Gradle JDK | 17.0.12 |
| Android SDK | 34.0.0 |

## Operation environment
Expand All @@ -83,11 +84,10 @@ This sample application runs with **Java SE 7** or higher Java versions.

### Android

| Version | Device | Tegra |
|---------|----------| --- |
| 14 | Pixel 7a ||
| 7.1.1 | Nexus 9 | ✔︎ |
| 4.1 | Pixel 5 ||
| Version | Device | Emulator |
|---------|----------|:--------:|
| 14 | Pixel 7a | |
| 5.0 | Pixel 7a ||

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

Expand Down
2 changes: 1 addition & 1 deletion Sample/src/full/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<activity
android:name=".full.MainActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="landscape"
android:screenOrientation="sensorLandscape"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ public void run() {
// アプリケーションを非アクティブにする
if (!isActive) {
activity.finishAndRemoveTask();
System.exit(0);
}
}

Expand Down
17 changes: 15 additions & 2 deletions Sample/src/full/java/com/live2d/demo/full/LAppLive2DManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.live2d.sdk.cubism.framework.math.CubismMatrix44;
import com.live2d.sdk.cubism.framework.motion.ACubismMotion;
import com.live2d.sdk.cubism.framework.motion.IBeganMotionCallback;
import com.live2d.sdk.cubism.framework.motion.IFinishedMotionCallback;

import java.io.IOException;
Expand Down Expand Up @@ -154,7 +155,7 @@ else if (model.hitTest(HitAreaName.BODY.getId(), x, y)) {
LAppPal.printLog("hit area: " + HitAreaName.HEAD.getId());
}

model.startRandomMotion(MotionGroup.TAP_BODY.getId(), Priority.NORMAL.getPriority(), finishedMotion);
model.startRandomMotion(MotionGroup.TAP_BODY.getId(), Priority.NORMAL.getPriority(), finishedMotion, beganMotion);
}
}
}
Expand Down Expand Up @@ -218,7 +219,7 @@ public void changeScene(int index) {
LAppDelegate.getInstance().getView().switchRenderingTarget(useRenderingTarget);

// 別レンダリング先を選択した際の背景クリア色
float[] clearColor = {1.0f, 1.0f, 1.0f};
float[] clearColor = {0.0f, 0.0f, 0.0f};
LAppDelegate.getInstance().getView().setRenderingTargetClearColor(clearColor[0], clearColor[1], clearColor[2]);
}

Expand Down Expand Up @@ -256,6 +257,18 @@ public int getModelNum() {
return models.size();
}

/**
* モーション再生時に実行されるコールバック関数
*/
private static class BeganMotion implements IBeganMotionCallback {
@Override
public void execute(ACubismMotion motion) {
LAppPal.printLog("Motion Began: " + motion);
}
}

private static final BeganMotion beganMotion = new BeganMotion();

/**
* モーション終了時に実行されるコールバック関数
*/
Expand Down
15 changes: 9 additions & 6 deletions Sample/src/full/java/com/live2d/demo/full/LAppModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.live2d.sdk.cubism.framework.motion.ACubismMotion;
import com.live2d.sdk.cubism.framework.motion.CubismExpressionMotion;
import com.live2d.sdk.cubism.framework.motion.CubismMotion;
import com.live2d.sdk.cubism.framework.motion.IBeganMotionCallback;
import com.live2d.sdk.cubism.framework.motion.IFinishedMotionCallback;
import com.live2d.sdk.cubism.framework.rendering.CubismRenderer;
import com.live2d.sdk.cubism.framework.rendering.android.CubismOffscreenSurfaceAndroid;
Expand Down Expand Up @@ -186,7 +187,7 @@ public void update() {
* @return 開始したモーションの識別番号を返す。個別のモーションが終了したか否かを判別するisFinished()の引数で使用する。開始できない時は「-1」
*/
public int startMotion(final String group, int number, int priority) {
return startMotion(group, number, priority, null);
return startMotion(group, number, priority, null, null);
}

/**
Expand All @@ -201,7 +202,8 @@ public int startMotion(final String group, int number, int priority) {
public int startMotion(final String group,
int number,
int priority,
IFinishedMotionCallback onFinishedMotionHandler
IFinishedMotionCallback onFinishedMotionHandler,
IBeganMotionCallback onBeganMotionHandler
) {
if (priority == LAppDefine.Priority.FORCE.getPriority()) {
motionManager.setReservationPriority(priority);
Expand All @@ -225,7 +227,7 @@ public int startMotion(final String group,
byte[] buffer;
buffer = createBuffer(path);

motion = loadMotion(buffer, onFinishedMotionHandler);
motion = loadMotion(buffer, onFinishedMotionHandler, onBeganMotionHandler);
if (motion != null) {
final float fadeInTime = modelSetting.getMotionFadeInTimeValue(group, number);

Expand All @@ -242,6 +244,7 @@ public int startMotion(final String group,
}
}
} else {
motion.setBeganMotionHandler(onBeganMotionHandler);
motion.setFinishedMotionHandler(onFinishedMotionHandler);
}

Expand Down Expand Up @@ -270,7 +273,7 @@ public int startMotion(final String group,
* @return 開始したモーションの識別番号。個別のモーションが終了したか否かを判定するisFinished()の引数で使用する。開始できない時は「-1」
*/
public int startRandomMotion(final String group, int priority) {
return startRandomMotion(group, priority, null);
return startRandomMotion(group, priority, null, null);
}

/**
Expand All @@ -281,15 +284,15 @@ public int startRandomMotion(final String group, int priority) {
* @param onFinishedMotionHandler モーション再生終了時に呼び出されるコールバック関数。nullの場合は呼び出されない。
* @return 開始したモーションの識別番号を返す。個別のモーションが終了したか否かを判定するisFinished()の引数で使用する。開始できない時は-1
*/
public int startRandomMotion(final String group, int priority, IFinishedMotionCallback onFinishedMotionHandler) {
public int startRandomMotion(final String group, int priority, IFinishedMotionCallback onFinishedMotionHandler, IBeganMotionCallback onBeganMotionHandler) {
if (modelSetting.getMotionCount(group) == 0) {
return -1;
}

Random random = new Random();
int number = random.nextInt(Integer.MAX_VALUE) % modelSetting.getMotionCount(group);

return startMotion(group, number, priority, onFinishedMotionHandler);
return startMotion(group, number, priority, onFinishedMotionHandler, onBeganMotionHandler);
}

public void draw(CubismMatrix44 matrix) {
Expand Down
2 changes: 1 addition & 1 deletion Sample/src/minimum/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<activity
android:name=".minimum.MainActivityMinimum"
android:configChanges="orientation|screenSize"
android:screenOrientation="landscape"
android:screenOrientation="sensorLandscape"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ public void run() {
// アプリケーションを非アクティブにする
if (!isActive) {
activity.finishAndRemoveTask();
System.exit(0);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ public void onUpdate() {
viewMatrix.multiplyByMatrix(projection);
}

// 描画前コール
LAppMinimumDelegate.getInstance().getView().preModelDraw(model);

model.update();
model.draw(projection); // 参照渡しなのでprojectionは変質する

// 描画後コール
LAppMinimumDelegate.getInstance().getView().postModelDraw(model);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.live2d.sdk.cubism.framework.motion.ACubismMotion;
import com.live2d.sdk.cubism.framework.motion.CubismExpressionMotion;
import com.live2d.sdk.cubism.framework.motion.CubismMotion;
import com.live2d.sdk.cubism.framework.motion.IBeganMotionCallback;
import com.live2d.sdk.cubism.framework.motion.IFinishedMotionCallback;
import com.live2d.sdk.cubism.framework.rendering.CubismRenderer;
import com.live2d.sdk.cubism.framework.rendering.android.CubismOffscreenSurfaceAndroid;
Expand Down Expand Up @@ -146,30 +147,13 @@ public void update() {

/**
* 引数で指定したモーションの再生を開始する。
* コールバック関数が渡されなかった場合にそれをnullとして同メソッドを呼び出す。
*
* @param group モーショングループ名
* @param number グループ内の番号
* @param priority 優先度
* @return 開始したモーションの識別番号を返す。個別のモーションが終了したか否かを判別するisFinished()の引数で使用する。開始できない時は「-1」
*/
public int startMotion(final String group, int number, int priority) {
return startMotion(group, number, priority, null);
}

/**
* 引数で指定したモーションの再生を開始する。
*
* @param group モーショングループ名
* @param number グループ内の番号
* @param priority 優先度
* @param onFinishedMotionHandler モーション再生終了時に呼び出されるコールバック関数。nullの場合は呼び出されない。
* @return 開始したモーションの識別番号を返す。個別のモーションが終了したか否かを判定するisFinished()の引数で使用する。開始できない時は「-1」
*/
public int startMotion(final String group,
int number,
int priority,
IFinishedMotionCallback onFinishedMotionHandler) {
if (priority == LAppDefine.Priority.FORCE.getPriority()) {
motionManager.setReservationPriority(priority);
} else if (!motionManager.reserveMotion(priority)) {
Expand All @@ -193,7 +177,7 @@ public int startMotion(final String group,
byte[] buffer;
buffer = LAppMinimumPal.loadFileAsBytes(path);

CubismMotion tmpMotion = loadMotion(buffer, onFinishedMotionHandler);
CubismMotion tmpMotion = loadMotion(buffer);
if (tmpMotion != null) {
motion = (CubismMotion) tmpMotion;

Expand All @@ -208,8 +192,6 @@ public int startMotion(final String group,
}
}
}
} else {
motion.setFinishedMotionHandler(onFinishedMotionHandler);
}

if (LAppDefine.DEBUG_LOG_ENABLE) {
Expand Down Expand Up @@ -443,7 +425,6 @@ private void setupTextures() {
}
}


private ICubismModelSetting modelSetting;
/**
* モデルのホームディレクトリ
Expand Down Expand Up @@ -492,5 +473,5 @@ private void setupTextures() {
/**
* フレームバッファ以外の描画先
*/
private CubismOffscreenSurfaceAndroid renderingBuffer;
private CubismOffscreenSurfaceAndroid renderingBuffer = new CubismOffscreenSurfaceAndroid();
}
Loading

0 comments on commit 917d01c

Please sign in to comment.