Skip to content

Commit d14d187

Browse files
Merge pull request #3 from Live2D/develop
Cubism 4 SDK for Java R1 beta2
2 parents beeb136 + 12ff1b0 commit d14d187

29 files changed

+481
-370
lines changed

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,34 @@ 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+
## [4-r.1-beta.2] - 2023-01-26
8+
9+
### Added
10+
11+
* Add a description of type package to `README.md`.
12+
13+
### Changed
14+
15+
* Change Android SDK API level from 31 (Android 12) to 33 (Android 13).
16+
* Change the name and package of the `CubismRectangle` class to `type/csmRect` to match SDK for Native.
17+
* Move constants related to debugging from `CubismFramework` class to the newly created `CubismFrameworkConfig` class.
18+
* Change implementation to hide `CubismJsonString` from shallow layers. The following functions are affcted by this change.
19+
* `getLayoutMap` function in `ICubismModelSetting` class
20+
* `getLayoutMap` function in `CubismModelSettingJson` class
21+
* `setupFromLayout` function in `CubismModelMatrix` class
22+
* Change the name and arguments of `createRenderer` function in `CubismUserModel`.
23+
* The `RendererType` enumurator is abolished. Please generate a renderer you want to use by yourself and put it in the function as an argument.
24+
25+
### Fixed
26+
27+
* Fix JSON data parsing process to improve performance.
28+
* Fix a problem where `setClippingMaskBufferSize` in `CubismRendererAndroid` would be thrown a `NullPointerException` if there are no clipping masks in the model.
29+
30+
### Removed
31+
32+
* Remove dependencies not to be used.
33+
* Remove the unused method `getMotionMap` in `ICubismModelSetting` and `CubismModelSettingJson` class.
34+
735
## [4-r.1-beta.1] - 2022-12-08
836

937
### Added
@@ -32,4 +60,5 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
3260

3361
* New released!
3462

63+
[4-r.1-beta.2]: https://github.com/Live2D/CubismJavaFramework/compare/4-r.1-beta.1...4-r.1-beta.2
3564
[4-r.1-beta.1]: https://github.com/Live2D/CubismJavaFramework/compare/4-r.1-alpha.1...4-r.1-beta.1

README.ja.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ Cubism SDK frameworkに関連する例外クラス群を提供します。
5252

5353
各種プラットフォームでモデルを描画するためのグラフィックス命令を実装したレンダラを提供します。
5454

55+
### type
56+
57+
本フレームワーク内で使用する基本的な型をクラスとして定義したものを提供します。
58+
5559
### utils
5660

5761
JSON パーサーやログ出力などのユーティリティ機能を提供します。

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ Provides functions for applying transformation manipulations due to physics to t
5252

5353
Provides a renderer that implements graphics instructions for drawing the model on various platforms.
5454

55+
### type
56+
57+
Provides classes that are defined from the basic types used within this framework.
58+
5559
### utils
5660

5761
Provides utility functions such as JSON parser and log output.

framework/build.gradle

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

55
android {
6-
compileSdkVersion 31
6+
compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
77

88
defaultConfig {
9-
minSdkVersion 16
10-
targetSdk 31
9+
minSdkVersion PROP_MIN_SDK_VERSION
10+
targetSdkVersion PROP_TARGET_SDK_VERSION
1111
versionCode 1
1212
versionName "1.0"
1313

@@ -32,7 +32,4 @@ dependencies {
3232

3333
testImplementation 'junit:junit:4.13.2'
3434
testImplementation 'commons-io:commons-io:2.11.0'
35-
36-
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
37-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
3835
}

framework/src/main/java/com/live2d/sdk/cubism/framework/CubismFramework.java

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
import com.live2d.sdk.cubism.core.CubismCoreVersion;
1111
import com.live2d.sdk.cubism.core.ICubismLogger;
1212
import com.live2d.sdk.cubism.core.Live2DCubismCore;
13+
import com.live2d.sdk.cubism.framework.CubismFrameworkConfig.LogLevel;
1314
import com.live2d.sdk.cubism.framework.id.CubismIdManager;
1415
import com.live2d.sdk.cubism.framework.rendering.android.CubismRendererAndroid;
15-
import com.live2d.sdk.cubism.framework.utils.CubismDebug;
1616

1717
import java.util.Locale;
1818

@@ -29,46 +29,6 @@ public class CubismFramework {
2929
* Inner class that define optional elements to be set in CubismFramework.
3030
*/
3131
public static class Option {
32-
/**
33-
* Log output level
34-
*/
35-
public enum LogLevel {
36-
/**
37-
* Detailed log
38-
*/
39-
VERBOSE(0),
40-
/**
41-
* Debug log
42-
*/
43-
DEBUG(1),
44-
/**
45-
* Info log
46-
*/
47-
INFO(2),
48-
/**
49-
* Warning log
50-
*/
51-
WARNING(3),
52-
/**
53-
* Error log
54-
*/
55-
ERROR(4),
56-
/**
57-
* Log output disabled.
58-
*/
59-
OFF(5);
60-
61-
private final int id;
62-
63-
LogLevel(final int id) {
64-
this.id = id;
65-
}
66-
67-
public int getId() {
68-
return id;
69-
}
70-
}
71-
7232
/**
7333
* Set the log output function.
7434
*
@@ -101,20 +61,6 @@ public void setLogFunction(ICubismLogger logger) {
10161
*/
10262
public static final int VERTEX_STEP = 2;
10363

104-
/**
105-
* The default logging level used in CubismFramework.
106-
* <p>
107-
* Activate this constant when forcibly changing the log output level.
108-
* Select LogLevel.VERBOSE to LogLevel.OFF in this CubismFramework class's internal class "Option".
109-
* </p>
110-
*/
111-
public static final Option.LogLevel CSM_LOG_LEVEL = Option.LogLevel.VERBOSE;
112-
113-
/**
114-
* Enable/Disable debugging in this Framework.
115-
*/
116-
public static final boolean CSM_DEBUG = true;
117-
11864

11965
/**
12066
* Enable Cubism Framework API.
@@ -142,7 +88,7 @@ public static boolean startUp(final Option option) {
14288
// Display the version information of Live2D Cubism Core.
14389
final CubismCoreVersion version = Live2DCubismCore.getVersion();
14490

145-
CubismDebug.cubismLogInfo(String.format(Locale.US, "Live2D Cubism Core version: %02d.%02d.%04d (%d)", version.getMajor(), version.getMinor(), version.getPatch(), version.getVersionNumber()));
91+
cubismLogInfo(String.format(Locale.US, "Live2D Cubism Core version: %02d.%02d.%04d (%d)", version.getMajor(), version.getMinor(), version.getPatch(), version.getVersionNumber()));
14692

14793
cubismLogInfo("CubismFramework.startUp() is complete.");
14894

@@ -246,11 +192,11 @@ public static void coreLogFunction(final String message) {
246192
*
247193
* @return the current value of log output level setting
248194
*/
249-
public static Option.LogLevel getLoggingLevel() {
195+
public static LogLevel getLoggingLevel() {
250196
if (s_option != null) {
251197
return s_option.loggingLevel;
252198
}
253-
return Option.LogLevel.OFF;
199+
return LogLevel.OFF;
254200
}
255201

256202
/**
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.live2d.sdk.cubism.framework;
2+
3+
/**
4+
* CubismFrameworkで使用される定数の定義クラス。<br>
5+
* デバッグやログに関わる設定をデフォルトから変更したい場合は、このクラスの定数の値を書き換えること。
6+
*/
7+
public class CubismFrameworkConfig {
8+
/**
9+
* ログ出力レベルを定義する列挙体。
10+
*/
11+
public enum LogLevel {
12+
/**
13+
* 詳細ログ出力設定
14+
*/
15+
VERBOSE(0),
16+
/**
17+
* デバッグログ出力設定
18+
*/
19+
DEBUG(1),
20+
/**
21+
* Infoログ出力設定
22+
*/
23+
INFO(2),
24+
/**
25+
* 警告ログ出力設定
26+
*/
27+
WARNING(3),
28+
/**
29+
* エラーログ出力設定
30+
*/
31+
ERROR(4),
32+
/**
33+
* ログ出力オフ設定
34+
*/
35+
OFF(5);
36+
37+
private final int id;
38+
39+
LogLevel(final int id) {
40+
this.id = id;
41+
}
42+
43+
public int getId() {
44+
return id;
45+
}
46+
}
47+
48+
/**
49+
* Cubism SDKにおけるデバッグ機能の有効状態。trueなら有効。
50+
*/
51+
public static final boolean CSM_DEBUG = true;
52+
53+
/**
54+
* ログ出力設定。<br>
55+
* 強制的にログ出力レベルを変える時に定義を有効にする。
56+
*
57+
* @note LogLevel.VERBOSE ~ LogLevel.OFF のいずれかを指定する。
58+
*/
59+
public static final LogLevel CSM_LOG_LEVEL = LogLevel.VERBOSE;
60+
61+
/**
62+
* privateコンストラクタ。
63+
*
64+
* @note 定数クラスのためインスタンス化させない
65+
*/
66+
private CubismFrameworkConfig() {}
67+
}

framework/src/main/java/com/live2d/sdk/cubism/framework/CubismModelSettingJson.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ public int getHitAreasCount() {
9292
return 0;
9393
}
9494
return jsonFrequencyValue.get(FrequentNode.HIT_AREAS.id).size();
95-
9695
}
9796

9897
@Override
@@ -165,15 +164,6 @@ public String getMotionGroupName(int index) {
165164
return jsonFrequencyValue.get(FrequentNode.MOTIONS.id).getKeys().get(index).getString();
166165
}
167166

168-
@Override
169-
public Map<CubismJsonString, ACubismJsonValue> getMotionMap() {
170-
ACubismJsonValue jsonValue = jsonFrequencyValue.get(FrequentNode.MOTIONS.id);
171-
if (jsonValue == null) {
172-
return Collections.emptyMap();
173-
}
174-
return jsonValue.getMap();
175-
}
176-
177167
@Override
178168
public int getMotionCount(final String groupName) {
179169
if (!existsMotionGroupName(groupName)) {
@@ -228,7 +218,7 @@ public String getUserDataFile() {
228218
}
229219

230220
@Override
231-
public boolean getLayoutMap(Map<CubismJsonString, Float> outLayoutMap) {
221+
public boolean getLayoutMap(Map<String, Float> outLayoutMap) {
232222
Map<CubismJsonString, ACubismJsonValue> map = json.getRoot().get(JsonKey.LAYOUT.key).getMap();
233223

234224
if (map == null) {
@@ -237,7 +227,7 @@ public boolean getLayoutMap(Map<CubismJsonString, Float> outLayoutMap) {
237227

238228
boolean result = false;
239229
for (Map.Entry<CubismJsonString, ACubismJsonValue> entry : map.entrySet()) {
240-
outLayoutMap.put(entry.getKey(), entry.getValue().toFloat());
230+
outLayoutMap.put(entry.getKey().getString(), entry.getValue().toFloat());
241231
result = true;
242232
}
243233

framework/src/main/java/com/live2d/sdk/cubism/framework/ICubismModelSetting.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ public interface ICubismModelSetting {
140140
*/
141141
int getMotionCount(final String groupName);
142142

143-
Map<CubismJsonString, ACubismJsonValue> getMotionMap();
144-
145143
/**
146144
* Get the name of the motion file from group name and index value.
147145
*
@@ -190,7 +188,7 @@ public interface ICubismModelSetting {
190188
*
191189
* @return if layout information exists, return true
192190
*/
193-
boolean getLayoutMap(Map<CubismJsonString, Float> outLayoutMap);
191+
boolean getLayoutMap(Map<String, Float> outLayoutMap);
194192

195193
/**
196194
* Get the number of parameters associated to eye blink.

framework/src/main/java/com/live2d/sdk/cubism/framework/math/CubismModelMatrix.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
package com.live2d.sdk.cubism.framework.math;
99

10-
import com.live2d.sdk.cubism.framework.utils.jsonparser.CubismJsonString;
11-
1210
import java.util.Map;
1311

1412
/**
@@ -166,7 +164,7 @@ public void setY(float y) {
166164
*
167165
* @param layout layout information
168166
*/
169-
public void setupFromLayout(Map<CubismJsonString, Float> layout) {
167+
public void setupFromLayout(Map<String, Float> layout) {
170168
final String keyWidth = "width";
171169
final String keyHeight = "height";
172170
final String keyX = "x";
@@ -178,17 +176,17 @@ public void setupFromLayout(Map<CubismJsonString, Float> layout) {
178176
final String keyLeft = "left";
179177
final String keyRight = "right";
180178

181-
for (Map.Entry<CubismJsonString, Float> entry : layout.entrySet()) {
182-
String key = entry.getKey().getString();
179+
for (Map.Entry<String, Float> entry : layout.entrySet()) {
180+
String key = entry.getKey();
183181
if (key.equals(keyWidth)) {
184182
setWidth(entry.getValue());
185183
} else if (key.equals(keyHeight)) {
186184
setHeight(entry.getValue());
187185
}
188186
}
189187

190-
for (Map.Entry<CubismJsonString, Float> entry : layout.entrySet()) {
191-
String key = entry.getKey().getString();
188+
for (Map.Entry<String, Float> entry : layout.entrySet()) {
189+
String key = entry.getKey();
192190
float value = entry.getValue();
193191

194192
if (key.equals(keyX)) {

0 commit comments

Comments
 (0)