Skip to content

Commit 9608d4a

Browse files
Merge pull request #13 from Live2D/develop
Update to Cubism 5 SDK for Java R4
2 parents 52389ca + 2f6946f commit 9608d4a

File tree

10 files changed

+749
-106
lines changed

10 files changed

+749
-106
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,30 @@ 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+
## [5-r.4] - 2025-05-15
9+
10+
### Added
11+
12+
* Add an API to `CubismMotionJson` for verifying the consistency of `motion3.json`.
13+
* Add a flag to the arguments of the following methods to enable the function that verifies the consistency of `motion3.json`:
14+
* `CubismUserModel.loadMotion()`
15+
* `CubismMotion.create()`
16+
* `CubismMotion.parse()`
17+
* Add parameter repeat processing that connects the right and left ends of the parameter to create a loop, allowing the motion to repeat.
18+
* Add the variable `isOverriddenParameterRepeat` to the `CubismModel` class for managing parameter repeat flags at the model level.
19+
* Add the variable `userParameterRepeatDataList` to the `CubismModel` class for managing parameter repeat flags for each parameter.
20+
* Add a `getPartParentPartIndices()` function.
21+
22+
### Changed
23+
24+
* Change the access level of the private members in the `CubismModelSettingJson` class to protected.
25+
* Change the default JDK version for compilation to 17 using Gradle's Java toolchain.
26+
27+
### Fixed
28+
29+
* Fix an issue in the `CubismPose` class where the opacity calculation for non-displayed parts differed from the implementation in the other Cubism SDK.
30+
31+
832
## [5-r.3] - 2025-02-18
933

1034
### Added
@@ -52,6 +76,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
5276

5377
### Changed
5478

79+
* Change an expression "overwrite" to "override" for multiply color, screen color, and culling to adapt the actual behavior.
5580
* Change the access level of `CubismMotionJson` class to public.
5681
* Change the threshold for enabling anisotropic filtering.
5782

@@ -239,6 +264,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
239264
* New released!
240265

241266

267+
[5-r.4]: https://github.com/Live2D/CubismJavaFramework/compare/5-r.3...5-r.4
242268
[5-r.3]: https://github.com/Live2D/CubismJavaFramework/compare/5-r.2...5-r.3
243269
[5-r.2]: https://github.com/Live2D/CubismJavaFramework/compare/5-r.1...5-r.2
244270
[5-r.1]: https://github.com/Live2D/CubismJavaFramework/compare/5-r.1-beta.3...5-r.1

framework/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ android {
2828
}
2929
}
3030

31+
java {
32+
toolchain {
33+
languageVersion = JavaLanguageVersion.of(17)
34+
}
35+
}
36+
3137
dependencies {
3238
compileOnly(fileTree(dir: '../../Core/android', include: ['Live2DCubismCore.aar']))
3339

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public CubismId getLipSyncParameterId(int index) {
324324
/**
325325
* Enum class for frequent nodes.
326326
*/
327-
private enum FrequentNode {
327+
protected enum FrequentNode {
328328
GROUPS(0),
329329
MOC(1),
330330
MOTIONS(2),
@@ -335,14 +335,14 @@ private enum FrequentNode {
335335
POSE(7),
336336
HIT_AREAS(8);
337337

338-
private final int id;
338+
protected final int id;
339339

340340
FrequentNode(final int id) {
341341
this.id = id;
342342
}
343343
}
344344

345-
private enum JsonKey {
345+
protected enum JsonKey {
346346
VERSION("Version"),
347347
FILE_REFERENCES("FileReferences"),
348348
GROUPS("Groups"),
@@ -392,7 +392,7 @@ private enum JsonKey {
392392
INIT_PARTS_VISIBLE("init_parts_visible"),
393393
VAL("val");
394394

395-
private final String key;
395+
protected final String key;
396396

397397
JsonKey(String key) {
398398
this.key = key;
@@ -401,71 +401,71 @@ private enum JsonKey {
401401

402402

403403
// キーが存在するかどうかのチェック
404-
private boolean existsModelFile() {
404+
protected boolean existsModelFile() {
405405
ACubismJsonValue node = jsonFrequencyValue.get(FrequentNode.MOC.id);
406406
return !node.isNull() && !node.isError();
407407
}
408408

409-
private boolean existsTextureFiles() {
409+
protected boolean existsTextureFiles() {
410410
ACubismJsonValue node = jsonFrequencyValue.get(FrequentNode.TEXTURES.id);
411411
return !node.isNull() && !node.isError();
412412
}
413413

414-
private boolean existsHitAreas() {
414+
protected boolean existsHitAreas() {
415415
ACubismJsonValue node = jsonFrequencyValue.get(FrequentNode.HIT_AREAS.id);
416416
return !node.isNull() && !node.isError();
417417
}
418418

419-
private boolean existsPhysicsFile() {
419+
protected boolean existsPhysicsFile() {
420420
ACubismJsonValue node = jsonFrequencyValue.get(FrequentNode.PHYSICS.id);
421421
return !node.isNull() && !node.isError();
422422
}
423423

424-
private boolean existsPoseFile() {
424+
protected boolean existsPoseFile() {
425425
ACubismJsonValue node = jsonFrequencyValue.get(FrequentNode.POSE.id);
426426
return !node.isNull() && !node.isError();
427427
}
428428

429-
private boolean existsDisplayInfoFile() {
429+
protected boolean existsDisplayInfoFile() {
430430
ACubismJsonValue node = jsonFrequencyValue.get(FrequentNode.DISPLAY_INFO.id);
431431
return !node.isNull() && !node.isError();
432432
}
433433

434-
private boolean existsExpressionFile() {
434+
protected boolean existsExpressionFile() {
435435
ACubismJsonValue node = jsonFrequencyValue.get(FrequentNode.EXPRESSIONS.id);
436436
return !node.isNull() && !node.isError();
437437
}
438438

439-
private boolean existsMotionGroups() {
439+
protected boolean existsMotionGroups() {
440440
ACubismJsonValue node = jsonFrequencyValue.get(FrequentNode.MOTIONS.id);
441441
return !node.isNull() && !node.isError();
442442
}
443443

444-
private boolean existsMotionGroupName(String groupName) {
444+
protected boolean existsMotionGroupName(String groupName) {
445445
ACubismJsonValue node = jsonFrequencyValue.get(FrequentNode.MOTIONS.id).get(groupName);
446446
return !node.isNull() && !node.isError();
447447
}
448448

449-
private boolean existsMotionSoundFile(String groupName, int index) {
449+
protected boolean existsMotionSoundFile(String groupName, int index) {
450450
ACubismJsonValue node = jsonFrequencyValue.get(FrequentNode.MOTIONS.id).get(groupName).get(index).get(JsonKey.SOUND_PATH.key);
451451
return !node.isNull() && !node.isError();
452452
}
453453

454-
private boolean existsMotionFadeIn(String groupName, int index) {
454+
protected boolean existsMotionFadeIn(String groupName, int index) {
455455
ACubismJsonValue node = jsonFrequencyValue.get(FrequentNode.MOTIONS.id).get(groupName).get(index).get(JsonKey.FADE_IN_TIME.key);
456456
return !node.isNull() && !node.isError();
457457
}
458458

459-
private boolean existsMotionFadeOut(String groupName, int index) {
459+
protected boolean existsMotionFadeOut(String groupName, int index) {
460460
ACubismJsonValue node = jsonFrequencyValue.get(FrequentNode.MOTIONS.id).get(groupName).get(index).get(JsonKey.FADE_OUT_TIME.key);
461461
return !node.isNull() && !node.isError();
462462
}
463463

464-
private boolean existsUserDataFile() {
464+
protected boolean existsUserDataFile() {
465465
return !json.getRoot().get(JsonKey.FILE_REFERENCES.key).get(JsonKey.USER_DATA.key).isNull();
466466
}
467467

468-
private boolean existsEyeBlinkParameters() {
468+
protected boolean existsEyeBlinkParameters() {
469469
if (jsonFrequencyValue.get(FrequentNode.GROUPS.id).isNull() || jsonFrequencyValue.get(FrequentNode.GROUPS.id).isError()) {
470470
return false;
471471
}
@@ -479,7 +479,7 @@ private boolean existsEyeBlinkParameters() {
479479
return false;
480480
}
481481

482-
private boolean existsLipSyncParameters() {
482+
protected boolean existsLipSyncParameters() {
483483
if (jsonFrequencyValue.get(FrequentNode.GROUPS.id).isNull() || jsonFrequencyValue.get(FrequentNode.GROUPS.id).isError()) {
484484
return false;
485485
}
@@ -495,9 +495,9 @@ private boolean existsLipSyncParameters() {
495495
/**
496496
* model3.json data
497497
*/
498-
private final CubismJson json;
498+
protected final CubismJson json;
499499
/**
500500
* Frequent nodes in the _json data
501501
*/
502-
private List<ACubismJsonValue> jsonFrequencyValue;
502+
protected List<ACubismJsonValue> jsonFrequencyValue;
503503
}

framework/src/main/java/com/live2d/sdk/cubism/framework/effect/CubismPose.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ private float calcNonDisplayedPartsOpacity(float currentOpacity, final float new
339339
float a1; // opacity to be calculated
340340
if (newOpacity < PHI) {
341341
// Linear equation passing through (0,1),(PHI,PHI)
342-
a1 = newOpacity * (PHI - 1.0f) / (PHI + 1.0f);
342+
a1 = newOpacity * (PHI - 1) / PHI + 1.0f;
343343
} else {
344344
a1 = (1 - newOpacity) * PHI / (1.0f - PHI);
345345
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ public class CubismMath {
1616
public static final float PI = 3.1415926535897932384626433832795f;
1717
public static final float EPSILON = 0.00001f;
1818

19+
public static float clampF(float val, float min, float max) {
20+
if (val < min) {
21+
return min;
22+
} else if (max < val) {
23+
return max;
24+
}
25+
26+
return val;
27+
}
28+
1929
/**
2030
* Returns the value of the first argument in the range of minimum and maximum values.
2131
*

0 commit comments

Comments
 (0)