Skip to content

Commit

Permalink
Merge pull request #12 from Live2D/develop
Browse files Browse the repository at this point in the history
Update to Cubism 5 SDK for Java R1
  • Loading branch information
itoh-at-live2d-com authored Mar 26, 2024
2 parents 351601d + 0270d37 commit b0a5ab2
Show file tree
Hide file tree
Showing 20 changed files with 389 additions and 192 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ 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] - 2024-03-26

### Added

* Add a OpenGL shader setup class.

### Changed

* Change so that `LAppSprite` does not depend on `LAppDelegate`.
* Change to read shader source codes from files.

### Fixed

* Fix a problem where two application icons are generated when installing the Minimum sample application on a device.

### Removed

* Remove description of CMake from development environment in README files.
* CMake is not actually used.
* Remove the unnecessary `if` branch due to raising the minimum API version.
* Remove the description of NDK version.
* Because of not using NDK.
* Remove the unnecessary variables in the `LAppSprite` class.


## [5-r.1-beta.3] - 2024-01-18

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

* New released!


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

### Remove

* [Unity] Remove built with Emscripten 1.38.48.
* Unity 2021.2 or later uses only Core under `Assets/Live2D/Cubism/Plugins/Experimental/Emscripten/latest`.


## 2023-09-28

### Remove

* Remove bitcode from IOS build.


## 2023-08-17

### Added
Expand Down
2 changes: 1 addition & 1 deletion Core/README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ Javaで開発する場合は、このファイルを使用してください。
| プラットフォーム | アーキテクチャ | jar | aar | パス | 注記 |
| --- |----------|---|-----|---|-----|
| Android | ARM64 | || android/Live2DCubismCore.aar | |
| Android | ARMv7 | || android/Live2DCubismCore.aar | |
| Android | ARMv7 | || android/Live2DCubismCore.aar | このライブラリは現在非推奨で、近日中に削除される予定です。 |
| Android | x86 | || android/Live2DCubismCore.aar | |
| Android | x86_64 | || android/Live2DCubismCore.aar | |
2 changes: 1 addition & 1 deletion Core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ Use this file when developing with Java.
| Platform | Architecture | jar | aar | Path | Note |
| --- | --- | --- | --- |------------------------------| --- |
| Android | ARM64 | || android/Live2DCubismCore.aar | |
| Android | ARMv7 | || 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 | |
22 changes: 9 additions & 13 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Cubism 5 Editorに搭載された新機能のSDK対応については [こちら
.
├─ Core # Live2D Cubism Core Javaが含まれるディレクトリ
├─ Framework # レンダリングやアニメーション機能などのソースコードが含まれるディレクトリ
└─ Samples
└─ Sample/src
├─ full # フルバージョンのサンプルアプリ
├─ main # full, minimumに共通するコード
└─ assets # モデルのファイルや画像などのリソースが含まれるディレクトリ
└─ assets # モデルのファイルや画像などのリソースが含まれるディレクトリ
└─ minimum # 機能を減らしシンプルにしたサンプルアプリ
```

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

## 変更履歴

当リポジトリの変更履歴については [CHANGELOG.md](CHANGELOG.md) を参照ください。
Samples : [CHANGELOG.md](CHANGELOG.md)

Framework : [CHANGELOG.md](Framework/CHANGELOG.md)

Core : [CHANGELOG.md](Core/CHANGELOG.md)

## 開発環境

| 開発ツール | バージョン |
|----------------|------------------|
| Android Studio | Hedgehog 2023.1.1 |
| CMake | 3.1.0 |
| Android Studio | Iguana 2023.2.1 |
| Gradle | 8.2 |

### Android

| Android SDK tools | バージョン |
| --- |--------------|
| Android NDK | 21.4.7075529 |
| Android SDK | 34.0.0 |
| CMake | 3.1.0 |

## 動作確認環境

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

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

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

### バグ

Expand Down
28 changes: 12 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ For compatibility with previous versions of Cubism SDK, please refer to [here](h
.
├─ Core # Directory containing Live2D Cubism Core Java
├─ Framework # Directory containing source code for rendering and animation functions
└─ Samples
├─ full # Full version of sample application
├─ main # Common code for full and minimum
└─ assets # Directory containing resources such as model files and images
─ minimum # Sample application with reduced and simplified functions
└─ Sample/src
├─ full # Full version of sample application
├─ main # Common code for full and minimum
└─ assets # Directory containing resources such as model files and images
─ minimum # Sample application with reduced and simplified functions
```

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

## Changelog

Please refer to [CHANGELOG.md](CHANGELOG.md) for the changelog of this repository.
Samples : [CHANGELOG.md](CHANGELOG.md)

Framework : [CHANGELOG.md](Framework/CHANGELOG.md)

Core : [CHANGELOG.md](Core/CHANGELOG.md)

## Development environment

| Development Tools | Version |
|-------------------|--|
| Android Studio | Hedgehog 2023.1.1 |
| CMake | 3.1.0 |
| Android Studio | Iguana 2023.2.1 |
| Gradle | 8.2 |

### Android

| Android SDK tools | Version |
| --- |--------------|
| Android NDK | 21.4.7075529 |
| Android SDK | 34.0.0 |
| CMake | 3.1.0 |

## Operation environment

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

### Forking And Pull Requests

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.
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.

### Bugs

Expand Down
56 changes: 4 additions & 52 deletions Sample/src/full/java/com/live2d/demo/full/LAppDelegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ public void onPause() {
}

public void onStop() {
view = null;
if (view != null) {
view.close();
}
textureManager = null;

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

// Initialize Cubism SDK framework
CubismFramework.initialize();

// シェーダーの初期化
view.initializeShader();
}

public void onSurfaceChanged(int width, int height) {
Expand Down Expand Up @@ -113,9 +112,7 @@ public void run() {

// アプリケーションを非アクティブにする
if (!isActive) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.finishAndRemoveTask();
}
activity.finishAndRemoveTask();
System.exit(0);
}
}
Expand Down Expand Up @@ -150,51 +147,6 @@ public void onTouchMoved(float x, float y) {
}
}

// シェーダーを登録する
public int createShader() {
int vertexShaderId = glCreateShader(GLES20.GL_VERTEX_SHADER);
final String vertexShader =
"#version 100\n"
+ "attribute vec3 position;"
+ "attribute vec2 uv;"
+ "varying vec2 vuv;"
+ "void main(void){"
+ "gl_Position = vec4(position, 1.0);"
+ "vuv = uv;"
+ "}";

GLES20.glShaderSource(vertexShaderId, vertexShader);
GLES20.glCompileShader(vertexShaderId);

// フラグメントシェーダのコンパイル
int fragmentShaderId = glCreateShader(GLES20.GL_FRAGMENT_SHADER);
final String fragmentShader =
"#version 100\n"
+ "precision mediump float;"
+ "uniform sampler2D texture;"
+ "varying vec2 vuv;"
+ "uniform vec4 baseColor;"
+ "void main(void){"
+ "gl_FragColor = texture2D(texture, vuv) * baseColor;"
+ "}";

GLES20.glShaderSource(fragmentShaderId, fragmentShader);
GLES20.glCompileShader(fragmentShaderId);

// プログラムオブジェクトの作成
int programId = GLES20.glCreateProgram();

// Programのシェーダーを設定
GLES20.glAttachShader(programId, vertexShaderId);
GLES20.glAttachShader(programId, fragmentShaderId);

GLES20.glLinkProgram(programId);

GLES20.glUseProgram(programId);

return programId;
}

// getter, setter群
public Activity getActivity() {
return activity;
Expand Down
35 changes: 13 additions & 22 deletions Sample/src/full/java/com/live2d/demo/full/LAppSprite.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ public LAppSprite(
spriteColor[1] = 1.0f;
spriteColor[2] = 1.0f;
spriteColor[3] = 1.0f;

// this projection matrix is applied to object coordinates
// in the onDrawFrame() method
int windowWidth = LAppDelegate.getInstance().getWindowWidth();
int windowHeight = LAppDelegate.getInstance().getWindowHeight();
}

public void render() {
Expand All @@ -65,10 +60,6 @@ public void render() {

GLES20.glUniform1i(textureLocation, 0);

// 画面サイズを取得する
int maxWidth = LAppDelegate.getInstance().getWindowWidth();
int maxHeight = LAppDelegate.getInstance().getWindowHeight();

// 頂点データ
positionVertex[0] = (rect.right - maxWidth * 0.5f) / (maxWidth * 0.5f);
positionVertex[1] = (rect.up - maxHeight * 0.5f) / (maxHeight * 0.5f);
Expand Down Expand Up @@ -121,10 +112,6 @@ public void renderImmediate(int textureId, final float[] uvVertex) {
// uniform属性の登録
GLES20.glUniform1i(textureLocation, 0);

// 画面サイズを取得する
int maxWidth = LAppDelegate.getInstance().getWindowWidth();
int maxHeight = LAppDelegate.getInstance().getWindowHeight();

// 頂点データ
float[] positionVertex = {
(rect.right - maxWidth * 0.5f) / (maxWidth * 0.5f), (rect.up - maxHeight * 0.5f) / (maxHeight * 0.5f),
Expand Down Expand Up @@ -176,9 +163,6 @@ public void resize(float x, float y, float width, float height) {
* @return 当たっていればtrue
*/
public boolean isHit(float pointX, float pointY) {
// 画面高さを取得する
int maxHeight = LAppDelegate.getInstance().getWindowHeight();

// y座標は変換する必要あり
float y = maxHeight - pointY;

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

/**
* ウィンドウサイズを設定する。
*
* @param width 横幅
* @param height 高さ
*/
public void setWindowSize(int width, int height) {
maxWidth = width;
maxHeight = height;
}

/**
* Rectクラス
*/
Expand Down Expand Up @@ -224,10 +219,6 @@ private static class Rect {
private final int colorLocation; // カラーアトリビュート
private final float[] spriteColor = new float[4]; // 表示カラー

// vpMatrix is an abbreviation for "Model View Projection Matrix"
private final float[] mVPMatrix = new float[16];
private final float[] projectionMatrix = new float[16];
private final float[] viewMatrix = new float[16];

private int vPMatrixHandle;
private int maxWidth; // ウィンドウ幅
private int maxHeight; // ウィンドウ高さ
}
Loading

0 comments on commit b0a5ab2

Please sign in to comment.