544 lines
35 KiB
HTML
544 lines
35 KiB
HTML
|
<!DOCTYPE html>
|
||
|
|
||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
|
<head>
|
||
|
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<title>Live2D Cubism — Ren'Py Documentation</title>
|
||
|
<link rel="stylesheet" href="_static/renpydoc.css" type="text/css" />
|
||
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||
|
<link rel="stylesheet" type="text/css" href="_static/bootstrap-3.3.6/css/bootstrap.min.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="_static/bootstrap-3.3.6/css/bootstrap-theme.min.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="_static/bootstrap-sphinx.css" />
|
||
|
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
||
|
<script type="text/javascript" src="_static/jquery.js"></script>
|
||
|
<script type="text/javascript" src="_static/underscore.js"></script>
|
||
|
<script type="text/javascript" src="_static/doctools.js"></script>
|
||
|
<script type="text/javascript" src="_static/language_data.js"></script>
|
||
|
<script type="text/javascript" src="_static/js/jquery-1.11.0.min.js"></script>
|
||
|
<script type="text/javascript" src="_static/js/jquery-fix.js"></script>
|
||
|
<script type="text/javascript" src="_static/bootstrap-3.3.6/js/bootstrap.min.js"></script>
|
||
|
<script type="text/javascript" src="_static/bootstrap-sphinx.js"></script>
|
||
|
<link rel="index" title="Index" href="genindex.html" />
|
||
|
<link rel="search" title="Search" href="search.html" />
|
||
|
<link rel="next" title="Styles" href="style.html" />
|
||
|
<link rel="prev" title="3D Stage" href="3dstage.html" />
|
||
|
<meta charset='utf-8'>
|
||
|
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
|
||
|
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
|
||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||
|
|
||
|
</head><body>
|
||
|
|
||
|
<div id="navbar" class="navbar navbar-default navbar-fixed-top">
|
||
|
<div class="container">
|
||
|
<div class="navbar-header">
|
||
|
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
|
||
|
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
|
||
|
<span class="icon-bar"></span>
|
||
|
<span class="icon-bar"></span>
|
||
|
<span class="icon-bar"></span>
|
||
|
</button>
|
||
|
<a class="navbar-brand" href="index.html">
|
||
|
Ren'Py Documentation</a>
|
||
|
<span class="navbar-text navbar-version pull-left"><b>7.5.3</b></span>
|
||
|
</div>
|
||
|
|
||
|
<div class="collapse navbar-collapse nav-collapse">
|
||
|
<ul class="nav navbar-nav">
|
||
|
|
||
|
<li><a href="https://www.renpy.org">Home Page</a></li>
|
||
|
<li><a href="https://www.renpy.org/doc/html/">Online Documentation</a></li>
|
||
|
|
||
|
|
||
|
<li class="dropdown globaltoc-container">
|
||
|
<a role="button"
|
||
|
id="dLabelGlobalToc"
|
||
|
data-toggle="dropdown"
|
||
|
data-target="#"
|
||
|
href="index.html">Site <b class="caret"></b></a>
|
||
|
<ul class="dropdown-menu globaltoc"
|
||
|
role="menu"
|
||
|
aria-labelledby="dLabelGlobalToc"><ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="quickstart.html">Quickstart</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="gui.html">GUI Customization Guide</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="language_basics.html">Language Basics</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="label.html">Labels & Control Flow</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="dialogue.html">Dialogue and Narration</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="displaying_images.html">Displaying Images</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="menus.html">In-Game Menus</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="python.html">Python Statements</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="conditional.html">Conditional Statements</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="audio.html">Audio</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="movie.html">Movie</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="voice.html">Voice</a></li>
|
||
|
</ul>
|
||
|
<ul class="current">
|
||
|
<li class="toctree-l1"><a class="reference internal" href="text.html">Text</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="translation.html">Translation</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="displayables.html">Displayables</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="transforms.html">Transforms</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="transitions.html">Transitions</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="atl.html">Animation and Transformation Language</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="matrixcolor.html">Matrixcolor</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="layeredimage.html">Layered Images</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="3dstage.html">3D Stage</a></li>
|
||
|
<li class="toctree-l1 current"><a class="current reference internal" href="#">Live2D Cubism</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="style.html">Styles</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="style_properties.html">Style Properties</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="screens.html">Screens and Screen Language</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="screen_actions.html">Screen Actions, Values, and Functions</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="screen_special.html">Special Screen Names</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="screen_optimization.html">Screen Language Optimization</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="config.html">Configuration Variables</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="preferences.html">Preference Variables</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="store_variables.html">Store Variables</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="mouse.html">Custom Mouse Cursors</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="launcher.html">Launcher</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="developer_tools.html">Developer Tools</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="director.html">Interactive Director</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="nvl_mode.html">NVL-Mode Tutorial</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="input.html">Text Input</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="side_image.html">Side Images</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="rooms.html">Image Gallery, Music Room, and Replay Actions</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="drag_drop.html">Drag and Drop</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="sprites.html">Sprites</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="keymap.html">Customizing the Keymap</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="achievement.html">Achievements</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="history.html">Dialogue History</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="multiple.html">Multiple Character Dialogue</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="splashscreen_presplash.html">Splashscreen and Presplash</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="statement_equivalents.html">Statement Equivalents</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="save_load_rollback.html">Saving, Loading, and Rollback</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="persistent.html">Persistent Data</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="trans_trans_python.html">Transforms and Transitions in Python</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="gui_advanced.html">Advanced GUI</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="screen_python.html">Screens and Python</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="modes.html">Modes</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="cdd.html">Creator-Defined Displayables</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="cds.html">Creator-Defined Statements</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="custom_text_tags.html">Custom Text Tags</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="character_callbacks.html">Character Callbacks</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="file_python.html">File Access</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="color_class.html">Color Class</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="matrix.html">Matrix</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="model.html">Model-Based Rendering</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="other.html">Other Functions and Variables</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="build.html">Building Distributions</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="updater.html">Web Updater</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="android.html">Android</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="chromeos.html">Chrome OS/Chromebook</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="ios.html">iOS</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="iap.html">In-App Purchasing</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="gesture.html">Gestures</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="raspi.html">Raspberry Pi</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="security.html">Security</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="problems.html">Dealing with Problems</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="environment_variables.html">Environment Variables</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="self_voicing.html">Self-Voicing</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="editor.html">Text Editor Integration</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="skins.html">Skins</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="translating_renpy.html">Translating Ren'Py</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog (Ren'Py 7.x-)</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="changelog6.html">Changelog (Ren'Py 6.11 - 6.99)</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="incompatible.html">Incompatible Changes</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="distributor.html">Distributor Notes</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="license.html">License</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="credits.html">Credits</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="sponsors.html">Ren'Py Development Sponsors</a></li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="thequestion.html">Script of The Question</a></li>
|
||
|
<li class="toctree-l1"><a class="reference internal" href="thequestion_nvl.html">NVL-mode script for The Question</a></li>
|
||
|
</ul>
|
||
|
</ul>
|
||
|
</li>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</ul>
|
||
|
|
||
|
|
||
|
|
||
|
<form class="navbar-form navbar-right" action="search.html" method="get">
|
||
|
<div class="form-group">
|
||
|
<input type="text" name="q" class="form-control" placeholder="Search" />
|
||
|
</div>
|
||
|
<input type="hidden" name="check_keywords" value="yes" />
|
||
|
<input type="hidden" name="area" value="default" />
|
||
|
</form>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div class="container">
|
||
|
<div class="row">
|
||
|
<div class="col-md-3">
|
||
|
<div id="sidebar" class="bs-sidenav" role="complementary"><ul>
|
||
|
<li><a class="reference internal" href="#">Live2D Cubism</a><ul>
|
||
|
<li><a class="reference internal" href="#installing-live2d">Installing Live2D</a></li>
|
||
|
<li><a class="reference internal" href="#opt-in-to-gl2">Opt in to GL2</a></li>
|
||
|
<li><a class="reference internal" href="#defining-animations">Defining Animations</a></li>
|
||
|
<li><a class="reference internal" href="#using-animations">Using Animations</a></li>
|
||
|
<li><a class="reference internal" href="#scaling">Scaling</a></li>
|
||
|
<li><a class="reference internal" href="#motion-fading">Motion Fading</a></li>
|
||
|
<li><a class="reference internal" href="#aliasing">Aliasing</a></li>
|
||
|
<li><a class="reference internal" href="#loop-and-image-prediction">Loop and Image Prediction</a></li>
|
||
|
<li><a class="reference internal" href="#functions">Functions</a></li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="col-md-9 content">
|
||
|
|
||
|
<div class="section" id="live2d-cubism">
|
||
|
<span id="live2d"></span><h1>Live2D Cubism<a class="headerlink" href="#live2d-cubism" title="Permalink to this headline"> link</a></h1>
|
||
|
<p><a class="reference external" href="https://www.live2d.com/en/">Live2D Cubism</a> is a system that allows you
|
||
|
to animate 2D images, such as the character sprites in a visual novel. These
|
||
|
images are drawn in a series of layers - for example, a layer for pupils and
|
||
|
irises, a layer for the whites of the eyes, a layer for the eyebrows, and so
|
||
|
on.</p>
|
||
|
<p>The Live2D software lets you associate meshes with each of these layers,
|
||
|
and then specify how the meshes are deformed (the shape of each mesh is
|
||
|
changed) as the parameters are adjusted. The Live2D software lets you
|
||
|
create motion files that determine how these parameters are adjusted over
|
||
|
time, and expression files that determine expressions.</p>
|
||
|
<p>Ren'Py's Live2D integration involves taking the files that Live2D produces,
|
||
|
and using them to define animations that can be displayed in Ren'Py. Ren'Py
|
||
|
processes the motions and expressions to determine the values of
|
||
|
the parameters. This is passed to the Cubism SDK for Native, which gives
|
||
|
Ren'Py back a list of meshes to show. Ren'Py then renders these meshes, and the result is a Live2D character on the screen.</p>
|
||
|
<p>Ren'Py supports Live2D animations in the Cubism 3 and Cubism 4 formats.
|
||
|
It supports the playback of expressions and motions.</p>
|
||
|
<div class="admonition warning">
|
||
|
<p class="first admonition-title">Warning</p>
|
||
|
<p>Live2D is not supported on the x86_64 Android platform, as a DLL is not
|
||
|
provided for this platform. This means that it may have problems running
|
||
|
on the Android emulator or ChromeOS.</p>
|
||
|
<p>Live2D is not supported on the web platform.</p>
|
||
|
<p class="last">Installing Live2D on iOS requires copying the static libraries into your
|
||
|
iOS project by hand.</p>
|
||
|
</div>
|
||
|
<div class="section" id="installing-live2d">
|
||
|
<h2>Installing Live2D<a class="headerlink" href="#installing-live2d" title="Permalink to this headline"> link</a></h2>
|
||
|
<p>Before you can use Live2D, you'll need to download and install the Cubism
|
||
|
SDK for Native, found on the
|
||
|
<a class="reference external" href="https://www.live2d.com/en/download/cubism-sdk/download-native/">Live2D website</a>.
|
||
|
Please note that you may need to purchase a license to use Live2D if your
|
||
|
business makes more than a certain amount of money a year.</p>
|
||
|
<p>Once you've downloaded Live2D, you can install it from the Ren'Py launcher. To
|
||
|
install, go to "preferences", then click "Install libraries". Place the
|
||
|
CubismSdkForNative-4-r.1.zip file in the Ren'Py SDK directory, which can
|
||
|
be accessed using the button in the bottom right of the install libraries
|
||
|
screen. Then click "Install Live2D Cubism SDK for Native". After a short
|
||
|
amount of time, Live2D will be installed.</p>
|
||
|
</div>
|
||
|
<div class="section" id="opt-in-to-gl2">
|
||
|
<h2>Opt in to GL2<a class="headerlink" href="#opt-in-to-gl2" title="Permalink to this headline"> link</a></h2>
|
||
|
<p>To use Live2D, you'll need to opt in to the Model-based renderer, by adding
|
||
|
the line:</p>
|
||
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">define</span> <span class="n">config</span><span class="o">.</span><span class="n">gl2</span> <span class="o">=</span> <span class="kc">True</span>
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
<p>to your game. This has to be done once per game.</p>
|
||
|
</div>
|
||
|
<div class="section" id="defining-animations">
|
||
|
<h2>Defining Animations<a class="headerlink" href="#defining-animations" title="Permalink to this headline"> link</a></h2>
|
||
|
<p>Live2D animations are defined using the Live2D displayable and the image statement:</p>
|
||
|
<dl class="function">
|
||
|
<dt id="Live2D">
|
||
|
<code class="descname">Live2D</code><span class="sig-paren">(</span><em>filename</em>, <em>zoom=None</em>, <em>top=0.0</em>, <em>base=1.0</em>, <em>height=1.0</em>, <em>alias={}</em>, <em>loop=False</em>, <em>fade=None</em>, <em>seamless=None</em>, <em>attribute_function=None</em>, <em>attribute_filter=None</em>, <em>update_function=None</em>, <em>**properties</em><span class="sig-paren">)</span><a class="headerlink" href="#Live2D" title="Permalink to this definition"> link</a></dt>
|
||
|
<dd><p>This displayable displays a Live2D animation.</p>
|
||
|
<dl class="docutils">
|
||
|
<dt><cite>filename</cite></dt>
|
||
|
<dd><p class="first">This may either be a model3.json file defining a Live2D animation, or a
|
||
|
directory containing that animation. In the latter case, the last
|
||
|
component of the directory is taken, and has .model3.json appended
|
||
|
to find the file.</p>
|
||
|
<p class="last">For example, "Resources/Hiyori" and "Resources/Hiyori/Hiyori.model3.json"
|
||
|
are equivalent.</p>
|
||
|
</dd>
|
||
|
<dt><cite>zoom</cite></dt>
|
||
|
<dd>If not None, a zoom factor that is applied. This takes precedence
|
||
|
over <cite>top</cite> and <cite>base</cite>.</dd>
|
||
|
<dt><cite>top</cite></dt>
|
||
|
<dd>The top of the image, for sizing purposes. This is a fraction of the
|
||
|
image, with 0.0 being the top and 1.0 the bottom.</dd>
|
||
|
<dt><cite>base</cite></dt>
|
||
|
<dd>The bottom of the image, for sizing purposes. This is a fraction of
|
||
|
the image, with 0.0 being the top and 1.0 being the bottom. This
|
||
|
also becomes the default value of yanchor.</dd>
|
||
|
<dt><cite>height</cite></dt>
|
||
|
<dd>The height that the image is scaled to. This is a fraction of the
|
||
|
virtual height of the screen.</dd>
|
||
|
<dt><cite>loop</cite></dt>
|
||
|
<dd>True if the final motion should be looped, False otherwise.</dd>
|
||
|
<dt><cite>alias</cite></dt>
|
||
|
<dd>A dictionary mapping aliases to the motions or expressions they
|
||
|
alias.</dd>
|
||
|
<dt><cite>fade</cite></dt>
|
||
|
<dd>True if motion fading should be enabled, False if motion fading
|
||
|
should not be enabled, and None to use the value of <a class="reference internal" href="#var-_live2d_fade"><code class="xref std std-var docutils literal notranslate"><span class="pre">_live2d_fade</span></code></a>.</dd>
|
||
|
<dt><cite>nonexclusive</cite></dt>
|
||
|
<dd>If not None, this should be a list of names of nonexclusive expressions.
|
||
|
Expressions default to being exlcusive, with only one beign shown at
|
||
|
a time. If listed here, any number of nonexclusive expressions can be
|
||
|
shown, in addition to one exclusive expression.</dd>
|
||
|
<dt><cite>seamless</cite></dt>
|
||
|
<dd>This determines if seamless looping should be used. Seamless looping
|
||
|
avoids fading between loops of a single motion. This may be True to
|
||
|
enable seamless looping all the time, False to dispable it all the
|
||
|
time, or a set of motions to be looped.</dd>
|
||
|
<dt><cite>default_fade</cite></dt>
|
||
|
<dd>The default amount of time that is spending fading into our out of
|
||
|
a motion or expression. This defaults to 1.0, per Live2D, which
|
||
|
might mean that fades happen unexpectedly. Set this to 0.0 to ensure
|
||
|
that fading is only done when it is explicitly requested.</dd>
|
||
|
<dt><cite>attribute_function</cite></dt>
|
||
|
<dd>If not None, this is a function that takes a tuple of attributes,
|
||
|
and returns a second tuple of attributes. This can be used to replace
|
||
|
attributes for the purpose of display only - the attributes it returns
|
||
|
are not used when showing an image. It should ensure
|
||
|
that at most one attribute corresponding to an expression is given.</dd>
|
||
|
<dt><cite>attribute_filter</cite></dt>
|
||
|
<dd>If not None, this is a function that takes a tuple of attributes,
|
||
|
and returns a second tuple of attributes. This is usually used to
|
||
|
filter out nonexclusice attributes that conflict with each other. The attributes
|
||
|
are ordered such that more recently requested attributes come first,
|
||
|
meaning that in the case of a conflict, the first attribute should
|
||
|
win.</dd>
|
||
|
<dt><cite>update_function</cite></dt>
|
||
|
<dd><p class="first">If not None, this is a function that is called when the animation
|
||
|
is rendered after updating parameters by the current motion and expressions.
|
||
|
The function is called with two arguments:</p>
|
||
|
<ul class="simple">
|
||
|
<li>The Live2D object.</li>
|
||
|
<li>The shown timebase, in seconds.</li>
|
||
|
</ul>
|
||
|
<p class="last">This function is used to dynamically change parameters using the <cite>blend_parameter</cite>
|
||
|
method of the passed Live2D object.
|
||
|
The function should return a delay, in seconds, after which it will
|
||
|
be called again, or None to be called again at the start of the next
|
||
|
interaction. Note that as long the motion is running, this function
|
||
|
will also be called every frame.</p>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
<p>The difference between <cite>attribute_function</cite> and <cite>attribute_filter</cite> is
|
||
|
that the former is generally used to compute replacement - the presence
|
||
|
of two attributes means one should be replaced by a third. The latter
|
||
|
is used to resolve conflicts between attributes, like having a group of
|
||
|
attributes where only one is valid.</p>
|
||
|
<p>Only <cite>filename</cite> should be given positionally, and all other arguments should
|
||
|
be given as keyword arguments.</p>
|
||
|
<p>The values of <cite>alias</cite>, <cite>fade</cite>, <cite>nonexclusive</cite>, <cite>seamless</cite>, <cite>default_fade</cite>, <cite>attribute_function</cite>,
|
||
|
<cite>attribute_filter</cite> and <cite>update_function</cite> are shared between all Live2D objects that share <cite>filename</cite>,
|
||
|
such that these only need to be supplied once as part of the first Live2D object to
|
||
|
use <cite>filename</cite>.</p>
|
||
|
<dl class="method">
|
||
|
<dt id="blend_parameter">
|
||
|
<code class="descname">blend_parameter</code><span class="sig-paren">(</span><em>name</em>, <em>blend</em>, <em>value</em>, <em>weight=1.0</em><span class="sig-paren">)</span><a class="headerlink" href="#blend_parameter" title="Permalink to this definition"> link</a></dt>
|
||
|
<dd><p>This method blends the current value of the parameter with passed.
|
||
|
This have no effect outside of <cite>update_function</cite>.</p>
|
||
|
<dl class="docutils">
|
||
|
<dt><cite>name</cite></dt>
|
||
|
<dd>Name of parameter to change defined for this model.</dd>
|
||
|
<dt><cite>blend</cite></dt>
|
||
|
<dd>One of "Add", "Multiply" or "Overwrite". The blend kind that will be used.</dd>
|
||
|
<dt><cite>value</cite></dt>
|
||
|
<dd>The value to be used.</dd>
|
||
|
<dt><cite>weight</cite></dt>
|
||
|
<dd>Float from 0.0 to 1.0, the weight by which the new value will change the current value.</dd>
|
||
|
</dl>
|
||
|
</dd></dl>
|
||
|
|
||
|
</dd></dl>
|
||
|
|
||
|
<p>There is a config variable that can help in debugging what motions and
|
||
|
expressions were loaded from .model3.json files:</p>
|
||
|
<dl class="var">
|
||
|
<dt id="var-config.log_live2d_loading">
|
||
|
define <code class="descname">config.log_live2d_loading</code> = False<a class="headerlink" href="#var-config.log_live2d_loading" title="Permalink to this definition"> link</a></dt>
|
||
|
<dd><p>If True, loaded path and used motions and expressions will be written to
|
||
|
log.txt on start.</p>
|
||
|
</dd></dl>
|
||
|
|
||
|
<p>Live2D displayables should be assigned to an image statement:</p>
|
||
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">image</span> <span class="n">hiyori</span> <span class="o">=</span> <span class="n">Live2D</span><span class="p">(</span><span class="s2">"Resources/Hiyori"</span><span class="p">,</span> <span class="n">base</span><span class="o">=.</span><span class="mi">6</span><span class="p">)</span>
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
<p>It's also possible to define attributes, and this is very useful when
|
||
|
defining different zooms and scaling factors.</p>
|
||
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">image</span> <span class="n">hiyori</span> <span class="n">close</span> <span class="o">=</span> <span class="n">Live2D</span><span class="p">(</span><span class="s2">"Resources/Hiyori"</span><span class="p">,</span> <span class="n">base</span><span class="o">=.</span><span class="mi">6</span><span class="p">)</span>
|
||
|
<span class="k">image</span> <span class="n">hiyori</span> <span class="n">far</span> <span class="o">=</span> <span class="n">Live2D</span><span class="p">(</span><span class="s2">"Resources/Hiyori"</span><span class="p">,</span> <span class="n">base</span><span class="o">=.</span><span class="mi">9</span><span class="p">)</span>
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
<p>Keep in mind that the user's hardware may be unable to init Live2D, and in that
|
||
|
case a single call to Live2D() will keep the entire project from loading. The same
|
||
|
happens in the case of a game distributed in a web version. If your game should be able
|
||
|
to work even without Live2D, you could use a wrapper or workaround, for example:</p>
|
||
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">init</span> <span class="k">python</span><span class="p">:</span>
|
||
|
<span class="k">def</span> <span class="nf">MyLive2D</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="n">fallback</span><span class="o">=</span><span class="n">Placeholder</span><span class="p">(</span><span class="k">text</span><span class="o">=</span><span class="s2">"no live2d"</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||
|
<span class="k">if</span> <span class="n">renpy</span><span class="o">.</span><span class="n">has_live2d</span><span class="p">():</span>
|
||
|
<span class="k">return</span> <span class="n">Live2D</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||
|
<span class="k">else</span><span class="p">:</span>
|
||
|
<span class="k">return</span> <span class="n">fallback</span>
|
||
|
|
||
|
<span class="k">image</span> <span class="n">kobayashi</span> <span class="o">=</span> <span class="n">MyLive2D</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>
|
||
|
<span class="k">image</span> <span class="n">eileen</span> <span class="n">moving</span> <span class="o">=</span> <span class="n">MyLive2D</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">fallback</span><span class="o">=</span><span class="s2">"eileen happy"</span><span class="p">)</span>
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="section" id="using-animations">
|
||
|
<h2>Using Animations<a class="headerlink" href="#using-animations" title="Permalink to this headline"> link</a></h2>
|
||
|
<p>The usual way to display a Live2D image is to display it using the
|
||
|
show statement. In addition to any attributes added as part of the
|
||
|
image statement, the names of expressions and motions can be used.</p>
|
||
|
<p>Some examples are:</p>
|
||
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">show</span> <span class="n">natori</span> <span class="n">exp_00</span> <span class="n">mtn_01</span>
|
||
|
<span class="k">show</span> <span class="n">hiyori</span> <span class="n">m10</span>
|
||
|
<span class="k">show</span> <span class="n">hiyori</span> <span class="n">m10</span> <span class="n">m01</span>
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
<p>These use the default names found in the Cubism SDK sample names. The names
|
||
|
of the motions and expressions are taken from the Live2D files, then forced to lower
|
||
|
case, and if they begin with the name of the model3.json file (without directories
|
||
|
or extensions), followed by an underscore, then that prefix is removed. (For example,
|
||
|
"Hiyori_Motion01" becomes just motion01.)</p>
|
||
|
<p>At most one exclusive expression can be used, and any number of nonexclusive expressions and
|
||
|
motions can be given. When more than one motion is given, the motions are played in order,
|
||
|
and the final motion is looped if loop is True.
|
||
|
This makes it possible for a motion to be played, followed by an idle animation.
|
||
|
Each motion can only appear once, unless multiple aliases for that motion are created.</p>
|
||
|
<p>There are two special attributes <code class="docutils literal notranslate"><span class="pre">null</span></code> and <code class="docutils literal notranslate"><span class="pre">still</span></code>. The null attribute
|
||
|
means that no exclusive expression file should be applied, giving the character's
|
||
|
default expression. The <code class="docutils literal notranslate"><span class="pre">still</span></code> motion stops all motion.</p>
|
||
|
<p>Nonexclusive expressions persist until removed with attribute negation:</p>
|
||
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">show</span> <span class="n">hiyori</span> <span class="o">-</span><span class="n">wave</span>
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="section" id="scaling">
|
||
|
<h2>Scaling<a class="headerlink" href="#scaling" title="Permalink to this headline"> link</a></h2>
|
||
|
<p>Many Live2D models are defined at high resolutions, at least in the internal
|
||
|
coordinate system that the models use. To compensate for this, Ren'Py includes
|
||
|
two ways to scale down the Live2D model.</p>
|
||
|
<p>The first is the <cite>zoom</cite> argument. This can directly set the zoom factor of the
|
||
|
model. If zoom is used, then the other scaling parameters are ignored.</p>
|
||
|
<p>Otherwise, the <cite>top</cite>, <cite>base</cite>, and <cite>height</cite> arguments are used. The first two
|
||
|
specify two lines, relative to the top and bottom of the image. (As elsewhere
|
||
|
in Ren'Py, 0.0 is the top and 1.0 is the bottom.) When these arguments are used,
|
||
|
two things happen:</p>
|
||
|
<ul class="simple">
|
||
|
<li>The image is scaled so that the area between <cite>top</cite> and <cite>base</cite> takes up <cite>height</cite>,
|
||
|
where <cite>height</cite> is a fraction of the screen.</li>
|
||
|
<li>The anchor is adjusted so that <cite>base</cite> will be placed at the bottom of the
|
||
|
screen.</li>
|
||
|
</ul>
|
||
|
<p>When figuring out how to scale a Live2D animation, what I do first is adjust the <cite>base</cite> parameter until the right part of the animation is lined
|
||
|
up with the bottom of the screen. Then:</p>
|
||
|
<ul class="simple">
|
||
|
<li>If the image is too big, reduce <cite>height</cite> until it's the right size.</li>
|
||
|
<li>If the image is too small, increase <cite>top</cite> to reduce the amount of blank
|
||
|
space above the animation.</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<div class="section" id="motion-fading">
|
||
|
<h2>Motion Fading<a class="headerlink" href="#motion-fading" title="Permalink to this headline"> link</a></h2>
|
||
|
<p>Ren'Py's support for Live2D includes motion fading. Normally, when Ren'Py
|
||
|
changes from one animation to another, the transition is abrupt - one
|
||
|
animation is stopped, and the other starts. If a transition occurs,
|
||
|
both animations are played at the same time.</p>
|
||
|
<p>Live2D supports a different model, in which the old animation can be
|
||
|
smoothly faded into the new one, but interpolating the parameters. Think
|
||
|
of this like a character moving their arms into position, rather than
|
||
|
dissolving from one position to another.</p>
|
||
|
<p>Motion fading is controlled with the <cite>fade</cite> argument. If it's true,
|
||
|
motion fading is used, and if it's false, then abrupt changes occur. If None,
|
||
|
motion fading is controlled by the <code class="docutils literal notranslate"><span class="pre">_live2d_fade</span></code> variable:</p>
|
||
|
<dl class="var">
|
||
|
<dt id="var-_live2d_fade">
|
||
|
<code class="descname">_live2d_fade</code> = True<a class="headerlink" href="#var-_live2d_fade" title="Permalink to this definition"> link</a></dt>
|
||
|
<dd><p>If true, Live2D animations use motion fading. If False, animations
|
||
|
are transitioned abruptly.</p>
|
||
|
</dd></dl>
|
||
|
|
||
|
</div>
|
||
|
<div class="section" id="aliasing">
|
||
|
<h2>Aliasing<a class="headerlink" href="#aliasing" title="Permalink to this headline"> link</a></h2>
|
||
|
<p>The <cite>alias</cite> parameter lets you specify your own names for the motions
|
||
|
that would otherwise be automatically defined. For example, one could do:</p>
|
||
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">image</span> <span class="n">hiyori</span> <span class="o">=</span> <span class="n">Live2D</span><span class="p">(</span><span class="s2">"Resources/Hiyori"</span><span class="p">,</span> <span class="n">base</span><span class="o">=.</span><span class="mi">6</span><span class="p">,</span> <span class="n">aliases</span><span class="o">=</span><span class="p">{</span><span class="s2">"idle"</span> <span class="p">:</span> <span class="s2">"m01"</span><span class="p">})</span>
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
<p>To be able to use:</p>
|
||
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">show</span> <span class="n">hiyori</span> <span class="na">idle</span>
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
<p>Instead of:</p>
|
||
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">show</span> <span class="n">hiyori</span> <span class="n">m01</span>
|
||
|
</pre></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="section" id="loop-and-image-prediction">
|
||
|
<h2>Loop and Image Prediction<a class="headerlink" href="#loop-and-image-prediction" title="Permalink to this headline"> link</a></h2>
|
||
|
<p>Ren'Py's Live2D support can loop the final animation if the <cite>loop</cite> parameter
|
||
|
is set to True. If the animation is being looped, it is important to add
|
||
|
greater than .2 second pauses that Ren'Py can exploit to perform expensive
|
||
|
image prediction. (This may not be necessary if image prediction and loading
|
||
|
can happen at other times.)</p>
|
||
|
</div>
|
||
|
<div class="section" id="functions">
|
||
|
<h2>Functions<a class="headerlink" href="#functions" title="Permalink to this headline"> link</a></h2>
|
||
|
<dl class="function">
|
||
|
<dt id="renpy.has_live2d">
|
||
|
<code class="descclassname">renpy.</code><code class="descname">has_live2d</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#renpy.has_live2d" title="Permalink to this definition"> link</a></dt>
|
||
|
<dd><p>Returns True if Live2d is supported on the current platform, and
|
||
|
False otherwise.</p>
|
||
|
</dd></dl>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
<footer class="footer">
|
||
|
<div class="container">
|
||
|
<p class="pull-right">
|
||
|
<a href="#">Back to top</a>
|
||
|
|
||
|
</p>
|
||
|
<p>
|
||
|
© Copyright 2012-2022, Tom Rothamel.<br/>
|
||
|
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.6.<br/>
|
||
|
</p>
|
||
|
</div>
|
||
|
</footer>
|
||
|
</body>
|
||
|
</html>
|