RenPy has native Live2D support now. Use it.
This is attempt to create Live2D module for RenPy. This is WIP and not production version. Project has no ETA. This source code is invitation to developers that are willing to help with development of module.
This module works only with OpenGL renderer.
As for now prebuild version of this module available only for macOS and Windows.
- Go to the 'release' section and download latest release.
- Extract files and place 'live2d' folder to the 'game' folder of your RenPy project.
- Download Cubism Native SDK and replace 'CubismSDK/Core' folder of this library with 'Core' folder from downloaded SDK.
- You are ready to go.
define h = Character("Hiyori")
init python:
from live2d.displayable import Live2DDisplayable
from renpy.loader import transfn
sprite_live2d = Live2DDisplayable()
init:
image sprite_live2d = sprite_live2d
label start:
show sprite_live2d
$ live2d_model_hiyori = sprite_live2d.scene.create_model(transfn(u'live2d_resources/Hiyori/'), u'Hiyori.model3.json')
$ live2d_model_hiyori.start_random_motion(group = u"Idle", priority = 3)
h "You've created a new Ren'Py game."
$ live2d_model_hiyori.start_motion(group = u"TapBody", no = 0, priority = 3)
h "Once you add a story, pictures, and music, you can release it to the world!"
return
This section is for those who wants to participate in extension development. If you do not want to participate in development and just want to use your Live2D models in RenPy — read 'Installing' section.
Extensions for RenPy should be built with custmoized Python 2.7.10 version that is configured for RenPy. The most convenient way is to use pyenv.
- Install pyenv.
brew install pyenv
If you want want to integrate pyenv into your shell read 'installation' section in pyenv manual. I assume that you want to use pyenv just to build module and do not want to make deep integration.
- Install python.
PYTHON_CONFIGURE_OPTS="--enable-unicode=ucs4 --enable-shared" pyenv install 2.7.10
If it fails with error read pyenv common build problems.
If you need to have multiple Python 2.7.10 installs use pyenv-alias plugin.
- Create folder to store python virtual environment. It will be mentioned as %TARGET_DIR%.
- Create virtual environment and install required packages.
cd %TARGET_DIR%
pyenv local 2.7.10
$(pyenv root)/versions/2.7.10/bin/pip install --upgrade pip
$(pyenv root)/versions/2.7.10/bin/pip install virtualenv
$(pyenv root)/versions/2.7.10/bin/virtualenv .
bin/pip install pyasn1==0.1.7 rsa==3.1.4 altgraph==0.12 macholib==1.7 cython==0.29.7
Now you have special Python build that is suitable for building Live2D module for RenPy:
- Download Cubism Native SDK and replace 'CubismSDK/Core' folder of this library with 'Core' folder from downloaded SDK.
- Open console and go to the folder where you placed content of this repository
- Launch
%TARGET_DIR%/bin/python setup.py build_ext --inplace
- Module is ready. Now you could launch RenPy game.
Should be similar to macOS but i could not confirm.
- Download and install Microsoft Visual C++ Compiler for Python 2.7
- Download and install x86 version of Python 2.7.10
- Download Cubism Native SDK and replace 'CubismSDK/Core' folder of this library with 'Core' folder from downloaded SDK.
- Launch 'Visual C++ 2008 32-bit Command Prompt' from 'Start' menu and go to 'CubismSDK/Core/dll/windows/x86' folder.
- Launch
dumpbin /EXPORTS Live2DCubismCore.dll > Live2DCubismCore.exports
- Edit 'Live2DCubismCore.exports' to create 'Live2DCubismCore.def' file. Also you could get ready 'def' file here but it may be a bit outdated so i recommend to create it by yourself.
- Launch
lib /def:Live2DCubismCore.def /out:Live2DCubismCore.lib
- Go to root module folder and launch
%PATH_TO_PYTHON%\python.exe setup.py build_ext --inplace --compiler=msvc
- Module is ready. Now you could launch RenPy game.