Skip to content

Commit 46f6680

Browse files
authored
Merge pull request #25 from Arkueid/v2-rewrite-in-python
rewrite v2 in python
2 parents 2ccb56f + 94e9e00 commit 46f6680

File tree

389 files changed

+79066
-255
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

389 files changed

+79066
-255
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ test
2828

2929
**.db
3030

31-
Resources/v2
32-
3331
!package/audio1.wav
3432

3533
!package/audio2.wav

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ message("${CMAKE_BUILD_TYPE}")
1414

1515
set(LIB_NAME LAppModelWrapper)
1616
set(PROJECT_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
17-
set(RES_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Resources)
1817

1918
# prevent python root dir being shadowed by registry
2019
set(Python3_FIND_REGISTRY "NEVER")
@@ -25,7 +24,7 @@ if(DEFINED PYTHON_INSTALLATION_PATH)
2524
else()
2625
# 寻找Python
2726
message("Not found PYTHON_INSTALLATION_PATH in environment variables. \nUse default path.")
28-
set(CMAKE_PREFIX_PATH D:/Python/x86/3.12.0)
27+
set(CMAKE_PREFIX_PATH D:/Python/x64/3.12)
2928
endif()
3029

3130
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")

LAppModelWrapper.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -775,19 +775,6 @@ static PyObject* live2d_glew_init()
775775
Py_RETURN_NONE;
776776
}
777777

778-
static PyObject* live2d_set_gl_properties()
779-
{
780-
// テクスチャサンプリング設定
781-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
782-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
783-
784-
// 透過設定
785-
glEnable(GL_BLEND);
786-
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
787-
788-
Py_RETURN_NONE;
789-
}
790-
791778
static PyObject* live2d_clear_buffer(PyObject* self, PyObject* args)
792779
{
793780
// 默认为黑色
@@ -833,7 +820,6 @@ static PyMethodDef live2d_methods[] = {
833820
{"init", (PyCFunction)live2d_init, METH_VARARGS, ""},
834821
{"dispose", (PyCFunction)live2d_dispose, METH_VARARGS, ""},
835822
{"glewInit", (PyCFunction)live2d_glew_init, METH_VARARGS, ""},
836-
{"setGLProperties", (PyCFunction)live2d_set_gl_properties, METH_VARARGS, ""},
837823
{"clearBuffer", (PyCFunction)live2d_clear_buffer, METH_VARARGS, ""},
838824
{"setLogEnable", (PyCFunction)live2d_set_log_enable, METH_VARARGS, ""},
839825
{"logEnable", (PyCFunction)live2d_log_enable, METH_VARARGS, ""},

Main/live2d/MatrixManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Csm::CubismMatrix44 &MatrixManager::GetProjection(LAppModel *model)
4646
{
4747
_projection.LoadIdentity();
4848

49-
if (model->GetModel()->GetCanvasWidth() > 1.0f && _ww < _ww)
49+
if (model->GetModel()->GetCanvasWidth() > 1.0f && _ww < _wh)
5050
{
5151
// 横に長いモデルを縦長ウィンドウに表示する際モデルの横サイズでscaleを算出する
5252
model->GetModelMatrix()->SetWidth(2.0f);

README.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,62 @@
1111

1212
使用 Python 直接加载和操作 Live2D 模型,不通过 Web Engine 等间接手段进行渲染。
1313

14-
基于 Python C++ API 对 Live2D Native SDK (C++) 进行了封装。理论上,只要配置好 OpenGL 上下文,可在 Python 中将 live2d 绘制在任何基于 OpenGL 的窗口。
14+
基于 Python C++ API 对 Live2D Native SDK (C++) 进行了封装。理论上,只要配置好 OpenGL 上下文,可在 Python 中将 live2d
15+
绘制在任何基于 OpenGL 的窗口。
1516

1617
代码使用示例:[package](./package/)
1718

1819
详细使用文档:https://arkueid.github.io/live2d-py-docs/
1920

20-
加载 Cubism 2.1 及以下版本的 Live2D 模型使用 [v2](https://github.com/Arkueid/live2d-py/tree/v2) 分支
21-
2221
## 兼容UI库
22+
2323
理论上兼容所有能使用 OpenGL 进行绘制的UI库: Pygame / PyQt5 / PySide2 / PySide6 / GLFW / FreeGlut / Qfluentwidgets ...
2424

2525
## 支持功能
26-
* 加载模型
26+
27+
* 加载模型:**Cubism 2.1****Cubism 3.0** 及以上版本
2728
* 视线跟踪
2829
* 点击交互
2930
* 动作播放回调
3031
* 口型同步
3132
* 模型各部分参数控制
3233
* 各部件透明度控制
34+
* 精确到部件的点击检测
3335

3436
## 平台支持
3537

36-
| `live2d-py` | 支持的live2d模型 | 支持的Python版本 | 支持平台 |
37-
|-------------|------------------------|----------------------------------------------------------------|---------------|
38-
| `live2d.v2` | Cubism 2.1 以及更早的版本 | 仅 32 位,支持`Python 3.0` 及以上版本,但除 `Python 3.10.11` 外需要自行编译 | Windows |
39-
| `live2d.v3` | Cubism 3.0 及以上版本 | 支持 `32` / `64` 位,支持`Python 3.0` 及以上版本,但除 `Python 3.12` 外需要自行编译 | Windows、Linux |
38+
| `live2d-py` | 支持的live2d模型 | 实现 | 支持的Python版本 | 支持平台 |
39+
|-------------|--------------------|-------------------|---------------------------------------|--------------------------|
40+
| `live2d.v2` | Cubism 2.1 以及更早的版本 | 纯 Python 实现 | 支持 `32` / `64` 位,支持`Python 3.0` 及以上版本 | Winodws、Linux、MacOS(理论上) | |
41+
| `live2d.v3` | Cubism 3.0 及以上版本 | Python C++ API 封装 | 支持 `32` / `64` 位,支持`Python 3.0` 及以上版本 | Windows、Linux |
4042

4143
注:
44+
45+
* `live2d.v2` 由 Cubism Web SDK 转写为纯 Python,尚未使用 numpy 等优化的库,性能有待提升。
4246
* Cubism 2.X 导出的模型:文件名格式常为 `XXX.moc``XXX.model.json``XXX.mtn`
43-
* Cubism 3.0 及以上导出的模型:文件名格式常为 `XXX.moc3``XXX.model3.json`, `XXX.motion3.json`
44-
* 对于 Cubism 2.0 模型,网络上能找到的现存 live2d opengl 静态库只有 32 位,因此只能使用 32 位 Python 解释器加载。
47+
* Cubism 3.0 及以上导出的模型:文件名格式常为 `XXX.moc3``XXX.model3.json`, `XXX.motion3.json`
4548

4649
## 安装方式
4750

4851
1. 通过 [PyPI](https://pypi.org/project/live2d-py/) 安装
52+
4953
```shell
5054
pip install live2d-py
5155
```
5256

5357
2.[Release](https://github.com/Arkueid/live2d-py/releases/latest) 中下载对应版本的 `whl` 文件并安装(推荐)
58+
5459
```shell
5560
pip install live2d_py-0.X.X-cpXXX-cpXXX-win32.whl
5661
```
5762

58-
3. 从源码构建,参考 [安装#源码构建](https://arkueid.github.io/live2d-py-docs/%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E/%E5%AE%89%E8%A3%85.html#%E6%BA%90%E7%A0%81%E6%9E%84%E5%BB%BA)
63+
3.
5964

65+
从源码构建,参考 [安装#源码构建](https://arkueid.github.io/live2d-py-docs/%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E/%E5%AE%89%E8%A3%85.html#%E6%BA%90%E7%A0%81%E6%9E%84%E5%BB%BA)
6066

6167
## 简易面部动捕示例
62-
源码见 [main_facial_bind_mediapipe.py](./package/main_facial_bind_mediapipe.py)
68+
69+
源码见 [main_facial_bind_mediapipe.py](./package/main_facial_bind_mediapipe.py)
6370

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

@@ -71,8 +78,12 @@ pip install live2d_py-0.X.X-cpXXX-cpXXX-win32.whl
7178

7279
## 贡献
7380

74-
特别感谢 [@96bearli][@Ovizro], [@AnyaCoder] 为本项目提供的帮助和支持。
81+
特别感谢 [@96bearli][@Ovizro], [@AnyaCoder], [@jahtim] 为本项目提供的帮助和支持。
7582

7683
[@96bearli]: https://github.com/96bearli
84+
7785
[@Ovizro]: https://github.com/Ovizro
78-
[@AnyaCoder]: https://github.com/AnyaCoder
86+
87+
[@AnyaCoder]: https://github.com/AnyaCoder
88+
89+
[@jahtim]: https://github.com/jahtim
Loading
Loading
Loading

Resources/v2/Epsilon/Epsilon.moc

170 KB
Binary file not shown.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"version":"Sample 1.0.0",
3+
"model":"Epsilon.moc",
4+
"textures":[
5+
"Epsilon.1024/texture_00.png",
6+
"Epsilon.1024/texture_01.png",
7+
"Epsilon.1024/texture_02.png"
8+
],
9+
"motions":{
10+
"idle":[
11+
{
12+
"file":"motions/Epsilon_idle_01.mtn"
13+
}
14+
],
15+
"null":[
16+
{
17+
"file":"motions/Epsilon_m_01.mtn"
18+
},
19+
{
20+
"file":"motions/Epsilon_m_02.mtn"
21+
},
22+
{
23+
"file":"motions/Epsilon_m_03.mtn"
24+
},
25+
{
26+
"file":"motions/Epsilon_m_04.mtn"
27+
},
28+
{
29+
"file":"motions/Epsilon_m_05.mtn"
30+
},
31+
{
32+
"file":"motions/Epsilon_m_06.mtn"
33+
},
34+
{
35+
"file":"motions/Epsilon_m_07.mtn"
36+
},
37+
{
38+
"file":"motions/Epsilon_m_08.mtn"
39+
},
40+
{
41+
"file":"motions/Epsilon_m_sp_01.mtn"
42+
},
43+
{
44+
"file":"motions/Epsilon_m_sp_02.mtn"
45+
},
46+
{
47+
"file":"motions/Epsilon_m_sp_03.mtn"
48+
},
49+
{
50+
"file":"motions/Epsilon_m_sp_04.mtn"
51+
},
52+
{
53+
"file":"motions/Epsilon_m_sp_05.mtn"
54+
},
55+
{
56+
"file":"motions/Epsilon_shake_01.mtn"
57+
}
58+
]
59+
},
60+
"expressions":[
61+
{"name":"f01.exp.json","file":"expressions/f01.exp.json"},
62+
{"name":"f02.exp.json","file":"expressions/f02.exp.json"},
63+
{"name":"f03.exp.json","file":"expressions/f03.exp.json"},
64+
{"name":"f04.exp.json","file":"expressions/f04.exp.json"},
65+
{"name":"f05.exp.json","file":"expressions/f05.exp.json"},
66+
{"name":"f06.exp.json","file":"expressions/f06.exp.json"},
67+
{"name":"f07.exp.json","file":"expressions/f07.exp.json"},
68+
{"name":"f08.exp.json","file":"expressions/f08.exp.json"}
69+
],
70+
"physics":"Epsilon.physics.json"
71+
}

0 commit comments

Comments
 (0)