Skip to content

Commit 0aaf271

Browse files
committed
完善部分说明和文档
1 parent a000bd1 commit 0aaf271

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

README.en.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ Source code: [main_facial_bind_mediapipe.py](./package/main_facial_bind.py)
9898

9999
![面捕-期末周破防](./docs/video_test.gif)
100100

101+
### Live2DViewer based on live2d-py C Module and Qt
102+
103+
![Live2DViewer](./docs/live2dviewer.png)
104+
101105
### Multi-live2d model rendering
102106

103107
Source code: [main_pygame_three_model.py](./package/main_pygame_three_model.py)
@@ -118,7 +122,7 @@ Source code: [main_pygame.py](./package/main_pygame.py)
118122

119123
### Model Opacity
120124

121-
源码见 [main_pyqt5_canvas_opacity.py](./package/main_pyqt5_canvas_opacity.py)
125+
Source Code: [main_pyqt5_canvas_opacity.py](./package/main_pyqt5_canvas_opacity.py)
122126

123127
![opacity](./docs/opacity.gif)
124128

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ pip install live2d-py
103103

104104
![面捕-期末周破防](./docs/video_test.gif)
105105

106+
### 基于 live2d-py C 模块及 Qt 开发的 Live2DViewer
107+
108+
![Live2DViewer](./docs/live2dviewer.png)
109+
110+
106111
### 多模型加载
107112

108113
源码见 [main_pygame_three_model.py](./package/main_pygame_three_model.py)

docs/live2dviewer.png

120 KB
Loading

package/main_pygame_fine_grained.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
live2d.glInit()
7676
# CreateRenderer should be called after OpenGL context is created and glInit is called
7777
# maskBufferCount = 2
78+
# more info about maskBufferCount: https://docs.live2d.com/zh-CHS/cubism-sdk-manual/ow-sdk-mask-premake/
79+
# typically maskBufferCount = 2 is enough for most cases
7880
model.CreateRenderer(2)
7981

8082
lastUpdateTime = time.time()
@@ -158,33 +160,47 @@
158160
ct = time.time()
159161
# delta seconds
160162
deltaSecs = ct - lastUpdateTime
161-
deltaSecs = max(0.001, deltaSecs)
163+
deltaSecs = max(0.0001, deltaSecs)
162164
lastUpdateTime = ct
163165

164-
# the following lines are equal to LAppModel.Update()
166+
# the following section is equal to LAppModel.Update()
167+
168+
# === Section Start Update() ===
165169
# load cached parameters from last frame
166170
motionUpdated = False
167-
model.LoadParameters()
171+
model.LoadParameters() # initialize params using cached values
172+
168173
if not model.IsMotionFinished():
169174
motionUpdated = model.UpdateMotion(deltaSecs)
170175

171176
# if SetParameterValue is called here, the parameter will be saved to the cache
172-
model.SaveParameters()
177+
# model.SetParameterValue(StandardParams.ParamAngleX, params.AngleX, 1)
178+
179+
model.SaveParameters() # save params to cache for next frame
173180

174181
if not motionUpdated:
175-
model.UpdateBlink(deltaSecs) # auto blink
182+
# auto blink
183+
# update eye blink params if they are defined in the model3.json
184+
model.UpdateBlink(deltaSecs)
176185

177186
model.UpdateExpression(deltaSecs)
178187

179188
model.UpdateDrag(deltaSecs)
180189

181-
model.UpdateBreath(deltaSecs) # auto breath
190+
# auto breath
191+
# update breath params such as ParamBodyAngleX, ParamAngleX...
192+
model.UpdateBreath(deltaSecs)
182193

183-
# create physics effects according to the parameters set
194+
# create physics effects according to current and previous param values
195+
# some params can be overridden by physics effects
184196
model.UpdatePhysics(deltaSecs)
185197

186198
model.UpdatePose(deltaSecs)
199+
# === Section End Update() ===
187200

201+
# Draw():
202+
# 1. update meshes according to the parameters
203+
# 2. draw meshes using opengl
188204
model.Draw()
189205

190206
pygame.display.flip()

0 commit comments

Comments
 (0)