Skip to content

Commit b0a5ab2

Browse files
Merge pull request #12 from Live2D/develop
Update to Cubism 5 SDK for Java R1
2 parents 351601d + 0270d37 commit b0a5ab2

20 files changed

Lines changed: 389 additions & 192 deletions

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,31 @@ 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] - 2024-03-26
8+
9+
### Added
10+
11+
* Add a OpenGL shader setup class.
12+
13+
### Changed
14+
15+
* Change so that `LAppSprite` does not depend on `LAppDelegate`.
16+
* Change to read shader source codes from files.
17+
18+
### Fixed
19+
20+
* Fix a problem where two application icons are generated when installing the Minimum sample application on a device.
21+
22+
### Removed
23+
24+
* Remove description of CMake from development environment in README files.
25+
* CMake is not actually used.
26+
* Remove the unnecessary `if` branch due to raising the minimum API version.
27+
* Remove the description of NDK version.
28+
* Because of not using NDK.
29+
* Remove the unnecessary variables in the `LAppSprite` class.
30+
31+
732
## [5-r.1-beta.3] - 2024-01-18
833

934
### Changed
@@ -114,6 +139,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
114139

115140
* New released!
116141

142+
143+
[5-r.1]: https://github.com/Live2D/CubismJavaSamples/compare/5-r.1-beta.3...5-r.1
117144
[5-r.1-beta.3]: https://github.com/Live2D/CubismJavaSamples/compare/5-r.1-beta.2...5-r.1-beta.3
118145
[5-r.1-beta.2]: https://github.com/Live2D/CubismJavaSamples/compare/5-r.1-beta.1...5-r.1-beta.2
119146
[5-r.1-beta.1]: https://github.com/Live2D/CubismJavaSamples/compare/4-r.1...5-r.1-beta.1

Core/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

77

8+
## 2024-03-26
9+
10+
### Remove
11+
12+
* [Unity] Remove built with Emscripten 1.38.48.
13+
* Unity 2021.2 or later uses only Core under `Assets/Live2D/Cubism/Plugins/Experimental/Emscripten/latest`.
14+
15+
16+
## 2023-09-28
17+
18+
### Remove
19+
20+
* Remove bitcode from IOS build.
21+
22+
823
## 2023-08-17
924

1025
### Added

Core/README.ja.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ Javaで開発する場合は、このファイルを使用してください。
1818
| プラットフォーム | アーキテクチャ | jar | aar | パス | 注記 |
1919
| --- |----------|---|-----|---|-----|
2020
| Android | ARM64 | || android/Live2DCubismCore.aar | |
21-
| Android | ARMv7 | || android/Live2DCubismCore.aar | |
21+
| Android | ARMv7 | || android/Live2DCubismCore.aar | このライブラリは現在非推奨で、近日中に削除される予定です。 |
2222
| Android | x86 | || android/Live2DCubismCore.aar | |
2323
| Android | x86_64 | || android/Live2DCubismCore.aar | |

Core/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ Use this file when developing with Java.
1818
| Platform | Architecture | jar | aar | Path | Note |
1919
| --- | --- | --- | --- |------------------------------| --- |
2020
| Android | ARM64 | || android/Live2DCubismCore.aar | |
21-
| Android | ARMv7 | || android/Live2DCubismCore.aar | |
21+
| Android | ARMv7 | || android/Live2DCubismCore.aar | This library is currently deprecated and will be removed in the near future. |
2222
| Android | x86 | || android/Live2DCubismCore.aar | |
2323
| Android | x86_64 | || android/Live2DCubismCore.aar | |

README.ja.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ Cubism 5 Editorに搭載された新機能のSDK対応については [こちら
2525
.
2626
├─ Core # Live2D Cubism Core Javaが含まれるディレクトリ
2727
├─ Framework # レンダリングやアニメーション機能などのソースコードが含まれるディレクトリ
28-
└─ Samples
28+
└─ Sample/src
2929
├─ full # フルバージョンのサンプルアプリ
3030
├─ main # full, minimumに共通するコード
31-
└─ assets # モデルのファイルや画像などのリソースが含まれるディレクトリ
31+
└─ assets # モデルのファイルや画像などのリソースが含まれるディレクトリ
3232
└─ minimum # 機能を減らしシンプルにしたサンプルアプリ
3333
```
3434

@@ -61,23 +61,19 @@ Android Studioでプロジェクトを開きビルドすることを推奨しま
6161

6262
## 変更履歴
6363

64-
当リポジトリの変更履歴については [CHANGELOG.md](CHANGELOG.md) を参照ください。
64+
Samples : [CHANGELOG.md](CHANGELOG.md)
65+
66+
Framework : [CHANGELOG.md](Framework/CHANGELOG.md)
67+
68+
Core : [CHANGELOG.md](Core/CHANGELOG.md)
6569

6670
## 開発環境
6771

6872
| 開発ツール | バージョン |
6973
|----------------|------------------|
70-
| Android Studio | Hedgehog 2023.1.1 |
71-
| CMake | 3.1.0 |
74+
| Android Studio | Iguana 2023.2.1 |
7275
| Gradle | 8.2 |
73-
74-
### Android
75-
76-
| Android SDK tools | バージョン |
77-
| --- |--------------|
78-
| Android NDK | 21.4.7075529 |
7976
| Android SDK | 34.0.0 |
80-
| CMake | 3.1.0 |
8177

8278
## 動作確認環境
8379

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

10197
### フォークとプルリクエスト
10298

103-
修正、改善、さらには新機能をもたらすかどうかにかかわらず、プルリクエストに感謝します。ただし、ラッパーは可能な限り軽量で浅くなるように設計されているため、バグ修正とメモリ/パフォーマンスの改善のみを行う必要があることに注意してください。メインリポジトリを可能な限りクリーンに保つために、必要に応じて個人用フォークと機能ブランチを作成してください。
99+
修正、改善、さらには新機能をもたらすかどうかにかかわらず、プルリクエストに感謝します。メインリポジトリを可能な限りクリーンに保つために、必要に応じて個人用フォークと機能ブランチを作成してください。
104100

105101
### バグ
106102

README.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ For compatibility with previous versions of Cubism SDK, please refer to [here](h
2626
.
2727
├─ Core # Directory containing Live2D Cubism Core Java
2828
├─ Framework # Directory containing source code for rendering and animation functions
29-
└─ Samples
30-
├─ full # Full version of sample application
31-
├─ main # Common code for full and minimum
32-
└─ assets # Directory containing resources such as model files and images
33-
─ minimum # Sample application with reduced and simplified functions
29+
└─ Sample/src
30+
├─ full # Full version of sample application
31+
├─ main # Common code for full and minimum
32+
└─ assets # Directory containing resources such as model files and images
33+
─ minimum # Sample application with reduced and simplified functions
3434
```
3535

3636
## Cubism Java Framework
@@ -61,23 +61,19 @@ It is recommended to open and build the project in Android Studio. Other IDEs do
6161

6262
## Changelog
6363

64-
Please refer to [CHANGELOG.md](CHANGELOG.md) for the changelog of this repository.
64+
Samples : [CHANGELOG.md](CHANGELOG.md)
65+
66+
Framework : [CHANGELOG.md](Framework/CHANGELOG.md)
67+
68+
Core : [CHANGELOG.md](Core/CHANGELOG.md)
6569

6670
## Development environment
6771

6872
| Development Tools | Version |
6973
|-------------------|--|
70-
| Android Studio | Hedgehog 2023.1.1 |
71-
| CMake | 3.1.0 |
74+
| Android Studio | Iguana 2023.2.1 |
7275
| Gradle | 8.2 |
73-
74-
### Android
75-
76-
| Android SDK tools | Version |
77-
| --- |--------------|
78-
| Android NDK | 21.4.7075529 |
7976
| Android SDK | 34.0.0 |
80-
| CMake | 3.1.0 |
8177

8278
## Operation environment
8379

@@ -101,7 +97,7 @@ There are many ways to contribute to the project: logging bugs, submitting pull
10197

10298
### Forking And Pull Requests
10399

104-
We very much appreciate your pull requests, whether they bring fixes, improvements, or even new features. Note, however, that the wrapper is designed to be as lightweight and shallow as possible and should therefore only be subject to bug fixes and memory/performance improvements. To keep the main repository as clean as possible, create a personal fork and feature branches there as needed.
100+
We very much appreciate your pull requests, whether they bring fixes, improvements, or even new features. To keep the main repository as clean as possible, create a personal fork and feature branches there as needed.
105101

106102
### Bugs
107103

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

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ public void onPause() {
5353
}
5454

5555
public void onStop() {
56-
view = null;
56+
if (view != null) {
57+
view.close();
58+
}
5759
textureManager = null;
5860

5961
LAppLive2DManager.releaseInstance();
@@ -75,9 +77,6 @@ public void onSurfaceCreated() {
7577

7678
// Initialize Cubism SDK framework
7779
CubismFramework.initialize();
78-
79-
// シェーダーの初期化
80-
view.initializeShader();
8180
}
8281

8382
public void onSurfaceChanged(int width, int height) {
@@ -113,9 +112,7 @@ public void run() {
113112

114113
// アプリケーションを非アクティブにする
115114
if (!isActive) {
116-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
117-
activity.finishAndRemoveTask();
118-
}
115+
activity.finishAndRemoveTask();
119116
System.exit(0);
120117
}
121118
}
@@ -150,51 +147,6 @@ public void onTouchMoved(float x, float y) {
150147
}
151148
}
152149

153-
// シェーダーを登録する
154-
public int createShader() {
155-
int vertexShaderId = glCreateShader(GLES20.GL_VERTEX_SHADER);
156-
final String vertexShader =
157-
"#version 100\n"
158-
+ "attribute vec3 position;"
159-
+ "attribute vec2 uv;"
160-
+ "varying vec2 vuv;"
161-
+ "void main(void){"
162-
+ "gl_Position = vec4(position, 1.0);"
163-
+ "vuv = uv;"
164-
+ "}";
165-
166-
GLES20.glShaderSource(vertexShaderId, vertexShader);
167-
GLES20.glCompileShader(vertexShaderId);
168-
169-
// フラグメントシェーダのコンパイル
170-
int fragmentShaderId = glCreateShader(GLES20.GL_FRAGMENT_SHADER);
171-
final String fragmentShader =
172-
"#version 100\n"
173-
+ "precision mediump float;"
174-
+ "uniform sampler2D texture;"
175-
+ "varying vec2 vuv;"
176-
+ "uniform vec4 baseColor;"
177-
+ "void main(void){"
178-
+ "gl_FragColor = texture2D(texture, vuv) * baseColor;"
179-
+ "}";
180-
181-
GLES20.glShaderSource(fragmentShaderId, fragmentShader);
182-
GLES20.glCompileShader(fragmentShaderId);
183-
184-
// プログラムオブジェクトの作成
185-
int programId = GLES20.glCreateProgram();
186-
187-
// Programのシェーダーを設定
188-
GLES20.glAttachShader(programId, vertexShaderId);
189-
GLES20.glAttachShader(programId, fragmentShaderId);
190-
191-
GLES20.glLinkProgram(programId);
192-
193-
GLES20.glUseProgram(programId);
194-
195-
return programId;
196-
}
197-
198150
// getter, setter群
199151
public Activity getActivity() {
200152
return activity;

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

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ public LAppSprite(
4141
spriteColor[1] = 1.0f;
4242
spriteColor[2] = 1.0f;
4343
spriteColor[3] = 1.0f;
44-
45-
// this projection matrix is applied to object coordinates
46-
// in the onDrawFrame() method
47-
int windowWidth = LAppDelegate.getInstance().getWindowWidth();
48-
int windowHeight = LAppDelegate.getInstance().getWindowHeight();
4944
}
5045

5146
public void render() {
@@ -65,10 +60,6 @@ public void render() {
6560

6661
GLES20.glUniform1i(textureLocation, 0);
6762

68-
// 画面サイズを取得する
69-
int maxWidth = LAppDelegate.getInstance().getWindowWidth();
70-
int maxHeight = LAppDelegate.getInstance().getWindowHeight();
71-
7263
// 頂点データ
7364
positionVertex[0] = (rect.right - maxWidth * 0.5f) / (maxWidth * 0.5f);
7465
positionVertex[1] = (rect.up - maxHeight * 0.5f) / (maxHeight * 0.5f);
@@ -121,10 +112,6 @@ public void renderImmediate(int textureId, final float[] uvVertex) {
121112
// uniform属性の登録
122113
GLES20.glUniform1i(textureLocation, 0);
123114

124-
// 画面サイズを取得する
125-
int maxWidth = LAppDelegate.getInstance().getWindowWidth();
126-
int maxHeight = LAppDelegate.getInstance().getWindowHeight();
127-
128115
// 頂点データ
129116
float[] positionVertex = {
130117
(rect.right - maxWidth * 0.5f) / (maxWidth * 0.5f), (rect.up - maxHeight * 0.5f) / (maxHeight * 0.5f),
@@ -176,9 +163,6 @@ public void resize(float x, float y, float width, float height) {
176163
* @return 当たっていればtrue
177164
*/
178165
public boolean isHit(float pointX, float pointY) {
179-
// 画面高さを取得する
180-
int maxHeight = LAppDelegate.getInstance().getWindowHeight();
181-
182166
// y座標は変換する必要あり
183167
float y = maxHeight - pointY;
184168

@@ -192,6 +176,17 @@ public void setColor(float r, float g, float b, float a) {
192176
spriteColor[3] = a;
193177
}
194178

179+
/**
180+
* ウィンドウサイズを設定する。
181+
*
182+
* @param width 横幅
183+
* @param height 高さ
184+
*/
185+
public void setWindowSize(int width, int height) {
186+
maxWidth = width;
187+
maxHeight = height;
188+
}
189+
195190
/**
196191
* Rectクラス
197192
*/
@@ -224,10 +219,6 @@ private static class Rect {
224219
private final int colorLocation; // カラーアトリビュート
225220
private final float[] spriteColor = new float[4]; // 表示カラー
226221

227-
// vpMatrix is an abbreviation for "Model View Projection Matrix"
228-
private final float[] mVPMatrix = new float[16];
229-
private final float[] projectionMatrix = new float[16];
230-
private final float[] viewMatrix = new float[16];
231-
232-
private int vPMatrixHandle;
222+
private int maxWidth; // ウィンドウ幅
223+
private int maxHeight; // ウィンドウ高さ
233224
}

0 commit comments

Comments
 (0)