Skip to content

Commit 5170b23

Browse files
committed
修复加载外部motion时motionCount赋值错误
1 parent 5065f73 commit 5170b23

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Main/src/fine-grained/Model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,11 +651,11 @@ void Model::LoadExtraMotion(const char *group, int no, const char *motionJsonPat
651651
{
652652
if (s == group)
653653
{
654-
_motionGroupNames[i] = group;
655654
_motionCounts[i] = _motionCounts[i] + 1;
656655
found = true;
657656
break;
658657
}
658+
i++;
659659
}
660660
if (!found)
661661
{

package/main_pygame_fine_grained.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@
2222
os.path.join(resources.RESOURCES_DIRECTORY, "v3/Haru/Haru.model3.json")
2323
)
2424

25+
# load extra motion file which is not defined in model3.json
26+
model.LoadExtraMotion(
27+
"extra",
28+
0,
29+
os.path.join(
30+
resources.RESOURCES_DIRECTORY, "v3/public_motions/drag_down.motion3.json"
31+
),
32+
)
33+
34+
model.LoadExtraMotion(
35+
"extra",
36+
1,
37+
os.path.join(
38+
resources.RESOURCES_DIRECTORY, "v3/public_motions/touch_head.motion3.json"
39+
),
40+
)
41+
2542
# Get Basic Model Info
2643
modelDir = model.GetModelHomeDir()
2744
print(modelDir)
@@ -123,6 +140,12 @@
123140
elif event.key == pygame.K_LEFTBRACKET:
124141
degrees += 5
125142
model.Rotate(degrees)
143+
elif event.key == pygame.K_e:
144+
model.StartRandomMotion(
145+
"extra",
146+
onStart=lambda group, no: print(f"{group} {no} started"),
147+
onFinish=lambda group, no: print(f"{group} {no} finished"),
148+
)
126149

127150
if not running:
128151
break

0 commit comments

Comments
 (0)