== python api doc ==
First commit to make some structure in doc/ directory. - moved source/blender/python/doc -> doc/python_api - moved source/gameengine/PyDoc/*.rst -> doc/python_api/rst - modified accordingly sphinx_doc_gen.py and sphinx_doc_gen.sh (later on I'll try alternative/ scripts by neXyon as promised :) - source/gameengine/PyDoc/ is still there because contains epydoc stuff for the bge, will ask more and look into it later
This commit is contained in:
201
doc/python_api/blender-org/layout.html
Normal file
201
doc/python_api/blender-org/layout.html
Normal file
@@ -0,0 +1,201 @@
|
||||
{%- block doctype -%}
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
{%- endblock %}
|
||||
{%- set script_files = script_files + [pathto("_static/jquery.sidebar.js", 1)] %}
|
||||
{%- set reldelim1 = reldelim1 is not defined and ' »' or reldelim1 %}
|
||||
{%- set reldelim2 = reldelim2 is not defined and ' •' or reldelim2 %}
|
||||
|
||||
{%- macro relbar() %}
|
||||
<div class="subnav boxheader">
|
||||
<ul class="noprint"><li><a href="http://www.blender.org/development/coding-guides/">Coding Guides</a></li><li>•</li><li><a href="http://www.blender.org/development/report-a-bug/">Report a Bug</a></li><li>•</li><li><a href="http://www.blender.org/development/submit-a-patch/">Submit a Patch</a></li><li>•</li><li><a href="http://www.blender.org/development/release-logs/">Release Logs</a></li><li>•</li><li><a href="http://www.blender.org/development/current-projects/">Current Projects</a></li><li>•</li><li><a href="http://www.blender.org/development/architecture/">Architecture</a></li><li>•</li><li><a href="http://www.blender.org/development/building-blender/">Building Blender</a></li><li>•</li><li class="subnav-active"><a href="http://www.blender.org/documentation/250PythonDoc/contents.html">PyAPI</a></li><li>•</li><li><a href="http://wiki.blender.org/index.php/Main_Page">Wiki</a></li></ul>
|
||||
</div>
|
||||
<div class="related subnav">
|
||||
<h3>{{ _('Navigation') }}</h3>
|
||||
<ul>
|
||||
{%- for rellink in rellinks %}
|
||||
<li class="right">
|
||||
<a href="{{ pathto(rellink[0]) }}" title="{{ rellink[1]|striptags }}"
|
||||
{{ accesskey(rellink[2]) }}>{{ rellink[3] }}</a>
|
||||
{%- if not loop.first %}{{ reldelim2 }}{% endif %}</li>
|
||||
{%- endfor %}
|
||||
{%- block rootrellink %}
|
||||
<li><a href="{{ pathto(master_doc) }}">{{ shorttitle|e }}</a>{{ reldelim1 }}</li>
|
||||
{%- endblock %}
|
||||
{%- for parent in parents %}
|
||||
<li><a href="{{ parent.link|e }}" {% if loop.last %}{{ accesskey("U") }}{% endif %}>{{ parent.title }}</a>{{ reldelim1 }}</li>
|
||||
{%- endfor %}
|
||||
{%- block relbaritems %} {% endblock %}
|
||||
</ul>
|
||||
</div>
|
||||
{%- endmacro %}
|
||||
|
||||
{%- macro sidebar() %}
|
||||
{%- if not embedded %}{% if not theme_nosidebar|tobool %}
|
||||
<div class="sphinxsidebar">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
{%- block sidebarlogo %}
|
||||
{%- if logo %}
|
||||
<p class="logo"><a href="{{ pathto(master_doc) }}">
|
||||
<img class="logo" src="{{ pathto('_static/' + logo, 1) }}" alt="Logo"/>
|
||||
</a></p>
|
||||
{%- endif %}
|
||||
{%- endblock %}
|
||||
{%- block sidebartoc %}
|
||||
{%- if display_toc %}
|
||||
<h3><a href="{{ pathto(master_doc) }}">{{ _('Table Of Contents') }}</a></h3>
|
||||
{{ toc }}
|
||||
{%- endif %}
|
||||
{%- endblock %}
|
||||
{%- block sidebarrel %}
|
||||
{%- if prev %}
|
||||
<h4>{{ _('Previous topic') }}</h4>
|
||||
<p class="topless"><a href="{{ prev.link|e }}"
|
||||
title="{{ _('previous chapter') }}">{{ prev.title }}</a></p>
|
||||
{%- endif %}
|
||||
{%- if next %}
|
||||
<h4>{{ _('Next topic') }}</h4>
|
||||
<p class="topless"><a href="{{ next.link|e }}"
|
||||
title="{{ _('next chapter') }}">{{ next.title }}</a></p>
|
||||
{%- endif %}
|
||||
{%- endblock %}
|
||||
{%- block sidebarsourcelink %}
|
||||
{%- if show_source and has_source and sourcename %}
|
||||
<h3>{{ _('This Page') }}</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="{{ pathto('_sources/' + sourcename, true)|e }}"
|
||||
rel="nofollow">{{ _('Show Source') }}</a></li>
|
||||
</ul>
|
||||
{%- endif %}
|
||||
{%- endblock %}
|
||||
{%- if customsidebar %}
|
||||
{% include customsidebar %}
|
||||
{%- endif %}
|
||||
{%- block sidebarsearch %}
|
||||
{%- if pagename != "search" %}
|
||||
<div id="searchbox" style="display: none">
|
||||
<h3>{{ _('Quick search') }}</h3>
|
||||
<form class="search" action="{{ pathto('search') }}" method="get">
|
||||
<input type="text" name="q" size="18" />
|
||||
<input type="submit" value="{{ _('Go') }}" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
<p class="searchtip">
|
||||
{{ _('Enter search terms or a module, class or function name.') }}
|
||||
</p>
|
||||
</div>
|
||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
||||
{%- endif %}
|
||||
{%- endblock %}
|
||||
</div>
|
||||
</div>
|
||||
{%- endif %}{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
{{ metatags }}
|
||||
{%- if not embedded and docstitle %}
|
||||
{%- set titlesuffix = " — "|safe + docstitle|e %}
|
||||
{%- else %}
|
||||
{%- set titlesuffix = "" %}
|
||||
{%- endif %}
|
||||
<title>{{ title|striptags }}{{ titlesuffix }}</title>
|
||||
<link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
|
||||
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
|
||||
{%- if not embedded %}
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT: '{{ pathto("", 1) }}',
|
||||
VERSION: '{{ release|e }}',
|
||||
COLLAPSE_MODINDEX: false,
|
||||
FILE_SUFFIX: '{{ file_suffix }}',
|
||||
HAS_SOURCE: {{ has_source|lower }}
|
||||
};
|
||||
</script>
|
||||
{%- for scriptfile in script_files %}
|
||||
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
|
||||
{%- endfor %}
|
||||
{%- if use_opensearch %}
|
||||
<link rel="search" type="application/opensearchdescription+xml"
|
||||
title="{% trans docstitle=docstitle|e %}Search within {{ docstitle }}{% endtrans %}"
|
||||
href="{{ pathto('_static/opensearch.xml', 1) }}"/>
|
||||
{%- endif %}
|
||||
{%- if favicon %}
|
||||
<link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}"/>
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
{%- block linktags %}
|
||||
{%- if hasdoc('about') %}
|
||||
<link rel="author" title="{{ _('About these documents') }}" href="{{ pathto('about') }}" />
|
||||
{%- endif %}
|
||||
{%- if hasdoc('genindex') %}
|
||||
<link rel="index" title="{{ _('Index') }}" href="{{ pathto('genindex') }}" />
|
||||
{%- endif %}
|
||||
{%- if hasdoc('search') %}
|
||||
<link rel="search" title="{{ _('Search') }}" href="{{ pathto('search') }}" />
|
||||
{%- endif %}
|
||||
{%- if hasdoc('copyright') %}
|
||||
<link rel="copyright" title="{{ _('Copyright') }}" href="{{ pathto('copyright') }}" />
|
||||
{%- endif %}
|
||||
<link rel="top" title="{{ docstitle|e }}" href="{{ pathto('index') }}" />
|
||||
{%- if parents %}
|
||||
<link rel="up" title="{{ parents[-1].title|striptags }}" href="{{ parents[-1].link|e }}" />
|
||||
{%- endif %}
|
||||
{%- if next %}
|
||||
<link rel="next" title="{{ next.title|striptags }}" href="{{ next.link|e }}" />
|
||||
{%- endif %}
|
||||
{%- if prev %}
|
||||
<link rel="prev" title="{{ prev.title|striptags }}" href="{{ prev.link|e }}" />
|
||||
{%- endif %}
|
||||
{%- endblock %}
|
||||
{%- block extrahead %} {% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
{%- block header %}
|
||||
<div class="noprint" id="navcontainer"><a href="http://www.blender.org/"><img width="140" height="50" title="blender.org home page" alt="blender.org home page" src="http://www.blender.org/fileadmin/site/_gfx/nav-home.png"></a><a href="http://www.blender.org/features-gallery/"><img width="140" height="50" title="Features & Gallery" alt="Features & Gallery" src="http://www.blender.org/fileadmin/site/_gfx/nav-features.png"></a><a href="http://www.blender.org/download/get-blender/"><img width="140" height="50" title="Download" alt="Download" src="http://www.blender.org/fileadmin/site/_gfx/nav-download.png"></a><a href="http://www.blender.org/education-help/"><img width="140" height="50" title="Tutorials & Help" alt="Tutorials & Help" src="http://www.blender.org/fileadmin/site/_gfx/nav-help.png"></a><a href="http://www.blender.org/community/user-community/"><img width="140" height="50" title="Community" alt="Community" src="http://www.blender.org/fileadmin/site/_gfx/nav-community.png"></a><a href="http://www.blender.org/development/"><img width="140" height="50" title="Development" alt="Development" src="http://www.blender.org/fileadmin/site/_gfx/nav-development-on.png"></a><a href="http://www.blender.org/e-shop/"><img width="140" height="50" title="e-Shop" alt="e-Shop" src="http://www.blender.org/fileadmin/site/_gfx/nav-eshop.png"></a></div>
|
||||
{% endblock %}
|
||||
|
||||
<div class="document">
|
||||
<div id="pageheader"></div>
|
||||
{%- block relbar1 %}{{ relbar() }}{% endblock %}
|
||||
|
||||
{%- block sidebar1 %} {# possible location for sidebar #} {% endblock %}
|
||||
|
||||
{%- block document %}
|
||||
<div class="documentwrapper">
|
||||
{%- if not embedded %}{% if not theme_nosidebar|tobool %}
|
||||
<div class="bodywrapper">
|
||||
{%- endif %}{% endif %}
|
||||
<div class="body">
|
||||
{% block body %} {% endblock %}
|
||||
</div>
|
||||
{%- if not embedded %}{% if not theme_nosidebar|tobool %}
|
||||
</div>
|
||||
{%- endif %}{% endif %}
|
||||
</div>
|
||||
{%- endblock %}
|
||||
|
||||
{%- block sidebar2 %}{{ sidebar() }}{% endblock %}
|
||||
<div class="clearer"></div>
|
||||
|
||||
{%- block footer %}
|
||||
<div class="footer">
|
||||
{%- if hasdoc('copyright') %}
|
||||
{% trans path=pathto('copyright'), copyright=copyright|e %}© <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
|
||||
{%- else %}
|
||||
{% trans copyright=copyright|e %}© Copyright {{ copyright }}.{% endtrans %}
|
||||
{%- endif %}
|
||||
{%- if last_updated %}
|
||||
{% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}
|
||||
{%- endif %}
|
||||
{%- if show_sphinx %}
|
||||
{% trans sphinx_version=sphinx_version|e %}Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> {{ sphinx_version }}.{% endtrans %}
|
||||
{%- endif %}
|
||||
</div><b class="round"><b id="r1"></b><b id="r2"></b><b id="r3"></b><b id="r4"></b></b>
|
||||
{%- endblock %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
4
doc/python_api/blender-org/page.html
Normal file
4
doc/python_api/blender-org/page.html
Normal file
@@ -0,0 +1,4 @@
|
||||
{% extends "layout.html" %}
|
||||
{% block body %}
|
||||
{{ body }}
|
||||
{% endblock %}
|
BIN
doc/python_api/blender-org/static/bg.png
Normal file
BIN
doc/python_api/blender-org/static/bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 54 KiB |
654
doc/python_api/blender-org/static/default.css_t
Normal file
654
doc/python_api/blender-org/static/default.css_t
Normal file
@@ -0,0 +1,654 @@
|
||||
/**
|
||||
* Sphinx stylesheet -- default theme
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
*/
|
||||
|
||||
@import url("basic.css");
|
||||
|
||||
/* -- page layout ----------------------------------------------------------- */
|
||||
|
||||
#navcontainer {
|
||||
height: 50px;
|
||||
margin: 0 auto;
|
||||
position: relative;
|
||||
width: 980px;
|
||||
}
|
||||
|
||||
#navcontainer img {
|
||||
width: 140px;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
#pageheader {
|
||||
background-image:url("bg.png");
|
||||
height:80px;
|
||||
position:relative;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: {{ theme_bodyfont }};
|
||||
font-size: 12px;
|
||||
line-height: 145%;
|
||||
background-color: {{ theme_footerbgcolor }};
|
||||
color: {{ theme_textcolor }};
|
||||
min-width: 980px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.document {
|
||||
margin:20px auto 0;
|
||||
position:relative;
|
||||
text-align:left;
|
||||
width:980px;
|
||||
/* background-color: {{ theme_sidebarbgcolor }};*/
|
||||
}
|
||||
|
||||
div.documentwrapper {
|
||||
float: left;
|
||||
width: 100%;
|
||||
background-color: {{ theme_bgcolor }};
|
||||
border-color: {{ theme_bordercolor }};
|
||||
border-style:solid;
|
||||
border-width:0 1px;
|
||||
margin:0 auto;
|
||||
min-height:30em;
|
||||
padding:35px;
|
||||
/* position:relative;*/
|
||||
text-align:left;
|
||||
width:908px;
|
||||
|
||||
}
|
||||
|
||||
div.bodywrapper {
|
||||
margin: 0 0 0 230px;
|
||||
}
|
||||
|
||||
div.body {
|
||||
background-color: {{ theme_bgcolor }};
|
||||
color: {{ theme_textcolor }};
|
||||
padding: 0;
|
||||
width: 640px;
|
||||
}
|
||||
|
||||
{%- if theme_rightsidebar|tobool %}
|
||||
div.bodywrapper {
|
||||
margin: 0 230px 0 0;
|
||||
}
|
||||
{%- endif %}
|
||||
|
||||
div.footer {
|
||||
background: #292929;
|
||||
border-left: 1px solid #363636;
|
||||
border-right: 1px solid #363636;
|
||||
color: #ffffff;
|
||||
/* width: 100%;*/
|
||||
margin: 0 auto;
|
||||
padding: 20px 20px 15px 35px;
|
||||
text-align: center;
|
||||
font-size: 75%;
|
||||
}
|
||||
|
||||
div.footer+.round b {
|
||||
display: block;
|
||||
background: #292929;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
div.footer+.round #r1 {
|
||||
border-left: 1px solid #363636;
|
||||
border-right: 1px solid #363636;
|
||||
height: 2px;
|
||||
margin: 0 1px;
|
||||
}
|
||||
|
||||
div.footer+.round #r2 {
|
||||
border-left: 1px solid #363636;
|
||||
border-right: 1px solid #363636;
|
||||
height: 1px;
|
||||
margin: 0 2px;
|
||||
}
|
||||
|
||||
div.footer+.round #r3 {
|
||||
border-left: 1px solid #363636;
|
||||
border-right: 1px solid #363636;
|
||||
height: 1px;
|
||||
margin: 0 3px;
|
||||
}
|
||||
|
||||
div.footer+.round #r4 {
|
||||
border-bottom: 1px solid #363636;
|
||||
height: 0px;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
div.footer a {
|
||||
color: {{ theme_footertextcolor }};
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.boxheader {
|
||||
background-color:#3E4D5E;
|
||||
}
|
||||
|
||||
.subnav {
|
||||
height:auto !important;
|
||||
min-height:15px;
|
||||
padding:9px 0px 9px 37px;
|
||||
position:relative;
|
||||
}
|
||||
|
||||
div.related {
|
||||
width:auto;
|
||||
font-size:100%;
|
||||
font-weight:400;
|
||||
background-color: {{ theme_relbarbgcolor }};
|
||||
line-height: 145%;
|
||||
color: {{ theme_relbartextcolor }};
|
||||
}
|
||||
|
||||
div.related li {
|
||||
font-size:0.9em;
|
||||
}
|
||||
|
||||
div.related li.right {
|
||||
margin: 0;
|
||||
word-spacing: 3px;
|
||||
}
|
||||
|
||||
div.subnav li {
|
||||
display:inline;
|
||||
list-style-type:none;
|
||||
margin:0;
|
||||
padding:0 7px 0 0;
|
||||
}
|
||||
|
||||
div.subnav ul {
|
||||
display:inline;
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
.subnav a {
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.subnav li.subnav-active a {
|
||||
color:#F39410;
|
||||
}
|
||||
|
||||
div.related a {
|
||||
color: {{ theme_relbarlinkcolor }};
|
||||
}
|
||||
|
||||
div.related a:active {
|
||||
color: {{ theme_relbaractlinkcolor }};
|
||||
}
|
||||
|
||||
div.sphinxsidebar {
|
||||
width: 280px;
|
||||
font-size: 100%;
|
||||
{%- if theme_stickysidebar|tobool %}
|
||||
/* top: 30px;*/
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
overflow: auto;
|
||||
height: 100%;
|
||||
{%- endif %}
|
||||
{%- if theme_rightsidebar|tobool %}
|
||||
float: right;
|
||||
{%- if theme_stickysidebar|tobool %}
|
||||
right: 0;
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
}
|
||||
|
||||
div.sphinxsidebarwrapper {
|
||||
width: inherit;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
margin-top: 35px;
|
||||
font-size: 8pt;
|
||||
}
|
||||
|
||||
div.sphinxsidebarwrapper.fixed {
|
||||
position:fixed;
|
||||
top:10px;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
{%- if theme_stickysidebar|tobool %}
|
||||
/* this is nice, but it it leads to hidden headings when jumping
|
||||
to an anchor */
|
||||
/*
|
||||
div.related {
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
div.documentwrapper {
|
||||
margin-top: 30px;
|
||||
}
|
||||
*/
|
||||
{%- endif %}
|
||||
|
||||
div.sphinxsidebar h3 {
|
||||
font-family: {{ theme_headfont }};
|
||||
color: {{ theme_sidebartextcolor }};
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
background: #3E4D5E url("rnd.png") no-repeat top left;
|
||||
height: 16px;
|
||||
margin: 0;
|
||||
padding: 10px 5px 10px 18px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar h3 a {
|
||||
color: {{ theme_sidebartextcolor }};
|
||||
}
|
||||
|
||||
div.sphinxsidebar h4 {
|
||||
font-family: {{ theme_headfont }};
|
||||
color: {{ theme_sidebartextcolor }};
|
||||
background: #3E4D5E url("rnd.png") no-repeat top left;
|
||||
height: 16px;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
padding: 10px 5px 10px 18px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar form {
|
||||
margin: 0;
|
||||
padding: 10px;
|
||||
background-color: #292929;
|
||||
{%- if theme_rightsidebar|tobool %}
|
||||
border-right: 1px solid {{ theme_bordercolor }};
|
||||
{%- endif %}
|
||||
}
|
||||
|
||||
div.sphinxsidebar p {
|
||||
background-color: #292929;
|
||||
padding: 5px 10px 10px 10px;
|
||||
color: {{ theme_sidebartextcolor }};
|
||||
{%- if theme_rightsidebar|tobool %}
|
||||
border-right: 1px solid {{ theme_bordercolor }};
|
||||
{%- endif %}
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
div.sphinxsidebar p.topless {
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul {
|
||||
background-color: #292929;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: {{ theme_sidebartextcolor }};
|
||||
}
|
||||
|
||||
div.sphinxsidebar > div > ul {
|
||||
margin-bottom: 25px;
|
||||
padding:10px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar a {
|
||||
color: {{ theme_sidebarlinkcolor }};
|
||||
}
|
||||
|
||||
div.sphinxsidebar input {
|
||||
border: 1px solid {{ theme_sidebarlinkcolor }};
|
||||
font-family: sans-serif;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
/* -- body styles ----------------------------------------------------------- */
|
||||
|
||||
a {
|
||||
color: {{ theme_linkcolor }};
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/*div.body h1,*/
|
||||
div.body h2,
|
||||
div.body h3,
|
||||
div.body h4,
|
||||
div.body h5,
|
||||
div.body h6 {
|
||||
font-family: {{ theme_headfont }};
|
||||
background-color: {{ theme_headbgcolor }};
|
||||
font-weight: bold;
|
||||
color: {{ theme_headtextcolor }};
|
||||
/* border-bottom: 1px solid #ccc;*/
|
||||
margin: 20px -20px 10px -20px;
|
||||
padding: 3px 0 3px 10px;
|
||||
}
|
||||
|
||||
div.body h1 { margin-top: 0; font-size: 200%;
|
||||
color:#FFFAE0;
|
||||
font-family:"Helvetica","Arial",sans-serif;
|
||||
font-size:34px;
|
||||
font-weight:normal;
|
||||
left:32px;
|
||||
line-height:26px;
|
||||
margin-top:0;
|
||||
position:absolute;
|
||||
top:36px;
|
||||
}
|
||||
div.body h2 { font-size: 160%; }
|
||||
div.body h3 { font-size: 140%; }
|
||||
div.body h4 { font-size: 120%; }
|
||||
div.body h5 { font-size: 110%; }
|
||||
div.body h6 { font-size: 100%; }
|
||||
|
||||
a.headerlink {
|
||||
color: {{ theme_headlinkcolor }};
|
||||
font-size: 0.8em;
|
||||
padding: 0 4px 0 4px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
h1:hover > a.headerlink {
|
||||
display:none;
|
||||
}
|
||||
|
||||
a.headerlink:hover {
|
||||
background-color: {{ theme_headlinkcolor }};
|
||||
color: white;
|
||||
}
|
||||
|
||||
div.body p, div.body dd, div.body li {
|
||||
text-align: justify;
|
||||
line-height: 130%;
|
||||
}
|
||||
|
||||
div.note, div.seealso, div.topic, div.warning {
|
||||
color:white;
|
||||
}
|
||||
|
||||
div.admonition p.admonition-title + p {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
div.note {
|
||||
background-color: #555;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
div.seealso {
|
||||
background-color: #525241;
|
||||
border: 1px solid #ff6;
|
||||
}
|
||||
|
||||
div.topic {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
div.warning {
|
||||
background-color: #B64444;
|
||||
border: 1px solid #990606;
|
||||
}
|
||||
|
||||
p.admonition-title {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
p.admonition-title:after {
|
||||
content: ":";
|
||||
}
|
||||
|
||||
dl div.admonition {
|
||||
border:medium none;
|
||||
margin:0;
|
||||
padding:2px 5px 2px 0;
|
||||
}
|
||||
|
||||
dl.class > dd > div.warning p.admonition-title,
|
||||
dl.class > dd > div.note p.admonition-title {
|
||||
display:none;
|
||||
}
|
||||
|
||||
dl.class > dd > div.admonition.warning p,
|
||||
dl.class > dd > div.admonition.note p {
|
||||
margin:0;
|
||||
}
|
||||
|
||||
dl.class > dd > div.admonition.warning,
|
||||
dl.class > dd > div.admonition.note {
|
||||
margin-bottom:12px;
|
||||
}
|
||||
|
||||
dl div.admonition.note p.admonition-title, dl div.admonition.warning p.admonition-title {
|
||||
color:inherit;
|
||||
}
|
||||
|
||||
dl div.admonition.warning p {
|
||||
font-weight:bold;
|
||||
line-height:150%;
|
||||
}
|
||||
|
||||
dl div.admonition.warning p * {
|
||||
font-weight:normal;
|
||||
}
|
||||
|
||||
dl div.admonition p.admonition-title {
|
||||
color:#555555;
|
||||
display:block;
|
||||
float:left;
|
||||
margin:0;
|
||||
padding-right:12px;
|
||||
text-align:right;
|
||||
width:90px;
|
||||
}
|
||||
|
||||
dl div.admonition p.admonition-title+p, dl div.admonition p {
|
||||
display:block;
|
||||
margin:0 0 0 102px;
|
||||
}
|
||||
|
||||
dl div.note {
|
||||
background:none;
|
||||
color:#E8E481;
|
||||
}
|
||||
|
||||
dl div.warning {
|
||||
background:none;
|
||||
color:#FC3030;
|
||||
}
|
||||
|
||||
dl div.seealso {
|
||||
background:none;
|
||||
}
|
||||
|
||||
dl div.admonition.seealso p+p {
|
||||
color:#222;
|
||||
}
|
||||
|
||||
dl div.seealso a {
|
||||
margin-left:-1.3ex;
|
||||
}
|
||||
|
||||
div.admonition.warning pre {
|
||||
background: #0F0704;
|
||||
color: #fc3030;
|
||||
}
|
||||
|
||||
div.admonition pre {
|
||||
margin: 6px 0;
|
||||
overflow: visible;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
pre {
|
||||
padding: 10px;
|
||||
background-color: #000;
|
||||
color: #fff;
|
||||
line-height: normal;
|
||||
border: 0 solid white;
|
||||
}
|
||||
|
||||
dl.function>dt, dl.method>dt {
|
||||
text-indent:-118px;
|
||||
padding-left: 118px;
|
||||
}
|
||||
|
||||
dl.function>dt em, dl.method>dt em {
|
||||
color: #97b9cf;
|
||||
}
|
||||
|
||||
dl.function>dd em, dl.method>dd em {
|
||||
color: #97b9cf;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
dl.function table.field-list tr:first-child td.field-body, dl.method table.field-list tr:first-child td.field-body {
|
||||
color: #728c96;
|
||||
}
|
||||
|
||||
dl.function>dt em:before, dl.method>dt em:before {
|
||||
content: " ";
|
||||
display: block;
|
||||
}
|
||||
|
||||
dl.function>dd>p,dl.method>dd>p,dl.attribute>dd>p,
|
||||
dl[class]>dd>ol,dl[class]>dd>ul {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
dl.data>dt {
|
||||
color:#08C659;
|
||||
}
|
||||
|
||||
dl.data>dd>p {
|
||||
color:#069643;
|
||||
}
|
||||
|
||||
dl.class>dt {
|
||||
color: #82a3c7;
|
||||
}
|
||||
|
||||
dl.class>dd>p,dl.class>dd>ol,dl.class>dd>ul {
|
||||
color: #637b96;
|
||||
}
|
||||
|
||||
dl.function>dt,dl.method>dt,dl.attribute>dt {
|
||||
color: #fcb100;
|
||||
}
|
||||
|
||||
dl.function>dd>p,dl.method>dd>p,dl.attribute>dd>p,
|
||||
dl.function>dd>p+ol,dl.method>dd>p+ol,dl.attribute>dd>p+ol,
|
||||
dl.function>dd>p+ul,dl.method>dd>p+ul,dl.attribute>dd>p+ul {
|
||||
color: #cb8f00;
|
||||
}
|
||||
|
||||
dl.function>dd>p, dl.method>dd>p, dl.attribute>dd>p {
|
||||
margin: 0 0 3px 102px;
|
||||
}
|
||||
|
||||
dl.function>dd>p:first-child:before, dl.method>dd>p:first-child:before, dl.attribute>dd>p:first-child:before {
|
||||
content:"Description:";
|
||||
color:#555;
|
||||
font-weight:bold;
|
||||
font-style:normal;
|
||||
width:90px;
|
||||
display:inline-block;
|
||||
margin-left:-102px;
|
||||
text-align:right;
|
||||
padding-right:12px;
|
||||
}
|
||||
|
||||
dt:target, .highlight {
|
||||
color: #444;
|
||||
background: #333;
|
||||
}
|
||||
|
||||
.highlight {
|
||||
background: #E2C788;
|
||||
}
|
||||
|
||||
h1 .highlight {
|
||||
color:inherit;
|
||||
background:inherit;
|
||||
}
|
||||
|
||||
dl {
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
dd {
|
||||
margin: 3px 0 10px 15px;
|
||||
}
|
||||
|
||||
.field-body tt.literal {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
tt {
|
||||
background-color: #444;
|
||||
padding: 0 1px 0 1px;
|
||||
font-size: 0.95em;
|
||||
}
|
||||
|
||||
.warning tt {
|
||||
background: #cc6262;
|
||||
}
|
||||
|
||||
.note tt {
|
||||
background: #444;
|
||||
}
|
||||
|
||||
dl .warning tt {
|
||||
background:#0F0704;
|
||||
display:block;
|
||||
}
|
||||
|
||||
dl .note tt {
|
||||
background:#2C2A1B;
|
||||
}
|
||||
|
||||
table.indextable tr.cap {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
col.field-name {
|
||||
width:90px;
|
||||
}
|
||||
|
||||
dd table {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
table.field-list th {
|
||||
color:#555;
|
||||
padding:0;
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
table.field-list td.field-body {
|
||||
color:#999999;
|
||||
padding-left:12px;
|
||||
}
|
||||
|
||||
table.field-list td.field-body ul.first {
|
||||
padding-left:0;
|
||||
list-style:none;
|
||||
margin-left:0;
|
||||
}
|
||||
|
||||
dl.function>dd>ol, dl.method>dd>ol, dl.attribute>dd>ol,
|
||||
dl.function>dd>ul, dl.method>dd>ul, dl.attribute>dd>ul,
|
||||
dl.function>dd>div[class|="highlight"], dl.method>dd>div[class|="highlight"],
|
||||
dl.attribute>dd>div[class|="highlight"] {
|
||||
margin-left:102px;
|
||||
}
|
||||
|
||||
dl.function>dd>ol, dl.method>dd>ol, dl.attribute>dd>ol,
|
||||
dl.function>dd>ul, dl.method>dd>ul, dl.attribute>dd>ul,
|
||||
dl.class>dd>ol, dl.class>dd>ul {
|
||||
padding-left:20px;
|
||||
}
|
BIN
doc/python_api/blender-org/static/favicon.ico
Normal file
BIN
doc/python_api/blender-org/static/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
26
doc/python_api/blender-org/static/jquery.sidebar.js
Normal file
26
doc/python_api/blender-org/static/jquery.sidebar.js
Normal file
@@ -0,0 +1,26 @@
|
||||
$(document).ready(function () {
|
||||
var top = $('.sphinxsidebarwrapper').offset().top - parseFloat($('.sphinxsidebarwrapper').css ('marginTop').replace(/auto/, 0));
|
||||
var colheight = parseFloat($('.sphinxsidebarwrapper').css('height').replace(/auto/, 0));
|
||||
|
||||
|
||||
$(window).scroll(function (event) {
|
||||
// what the y position of the scroll is
|
||||
var y = $(this).scrollTop();
|
||||
|
||||
// whether that's below the form
|
||||
if (y >= top) {
|
||||
//colheight is checked and according to its vaule the scrolling
|
||||
//is triggered or not
|
||||
if (colheight <= window.innerHeight) {
|
||||
// if so, ad the fixed class
|
||||
$('.sphinxsidebarwrapper').addClass('fixed');
|
||||
} else {
|
||||
// otherwise remove it
|
||||
$('.sphinxsidebarwrapper').removeClass('fixed');
|
||||
}
|
||||
} else {
|
||||
// otherwise remove it
|
||||
$('.sphinxsidebarwrapper').removeClass('fixed');
|
||||
}
|
||||
});
|
||||
});
|
61
doc/python_api/blender-org/static/pygments.css
Normal file
61
doc/python_api/blender-org/static/pygments.css
Normal file
@@ -0,0 +1,61 @@
|
||||
.hll { background-color: #ffffcc }
|
||||
.c { color: #7f7f7f; font-style: italic } /* Comment */
|
||||
.err { border: 1px solid #FF0000 } /* Error */
|
||||
.k { color: #0088ff; font-weight: bold } /* Keyword */
|
||||
.o { color: #993399 } /* Operator */
|
||||
.cm { color: #7f7f7f; font-style: italic } /* Comment.Multiline */
|
||||
.cp { color: #007020 } /* Comment.Preproc */
|
||||
.c1 { color: #408090; font-style: italic } /* Comment.Single */
|
||||
.cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
|
||||
.gd { color: #A00000 } /* Generic.Deleted */
|
||||
.ge { font-style: italic } /* Generic.Emph */
|
||||
.gr { color: #FF0000 } /* Generic.Error */
|
||||
.gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
||||
.gi { color: #00A000 } /* Generic.Inserted */
|
||||
.go { color: #303030 } /* Generic.Output */
|
||||
.gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
|
||||
.gs { font-weight: bold } /* Generic.Strong */
|
||||
.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
||||
.gt { color: #0040D0 } /* Generic.Traceback */
|
||||
.kc { color: #007020; font-weight: bold } /* Keyword.Constant */
|
||||
.kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
|
||||
.kn { color: #FFFF32; font-weight: bold } /* Keyword.Namespace */
|
||||
.kp { color: #007020 } /* Keyword.Pseudo */
|
||||
.kr { color: #FFFF32; font-weight: bold } /* Keyword.Reserved */
|
||||
.kt { color: #902000 } /* Keyword.Type */
|
||||
.m { color: #00BAFF } /* Literal.Number */
|
||||
.s { color: #B7C274 } /* Literal.String */
|
||||
.na { color: #4070a0 } /* Name.Attribute */
|
||||
.nb { color: #007020 } /* Name.Builtin */
|
||||
.nc { color: #0e84b5; font-weight: bold } /* Name.Class */
|
||||
.no { color: #60add5 } /* Name.Constant */
|
||||
.nd { color: #555555; font-weight: bold } /* Name.Decorator */
|
||||
.ni { color: #d55537; font-weight: bold } /* Name.Entity */
|
||||
.ne { color: #007020 } /* Name.Exception */
|
||||
.nf { color: #06287e } /* Name.Function */
|
||||
.nl { color: #002070; font-weight: bold } /* Name.Label */
|
||||
.nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
|
||||
.nt { color: #062873; font-weight: bold } /* Name.Tag */
|
||||
.nv { color: #bb60d5 } /* Name.Variable */
|
||||
.ow { color: #007020; font-weight: bold } /* Operator.Word */
|
||||
.w { color: #bbbbbb } /* Text.Whitespace */
|
||||
.mf { color: #00BAFF } /* Literal.Number.Float */
|
||||
.mh { color: #00BAFF } /* Literal.Number.Hex */
|
||||
.mi { color: #00BAFF } /* Literal.Number.Integer */
|
||||
.mo { color: #00BAFF } /* Literal.Number.Oct */
|
||||
.sb { color: #B7C274 } /* Literal.String.Backtick */
|
||||
.sc { color: #B7C274 } /* Literal.String.Char */
|
||||
.sd { color: #B7C274; font-style: italic } /* Literal.String.Doc */
|
||||
.s2 { color: #B7C274 } /* Literal.String.Double */
|
||||
.se { color: #B7C274; font-weight: bold } /* Literal.String.Escape */
|
||||
.sh { color: #B7C274 } /* Literal.String.Heredoc */
|
||||
.si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
|
||||
.sx { color: #c65d09 } /* Literal.String.Other */
|
||||
.sr { color: #235388 } /* Literal.String.Regex */
|
||||
.s1 { color: #4070a0 } /* Literal.String.Single */
|
||||
.ss { color: #517918 } /* Literal.String.Symbol */
|
||||
.bp { color: #007020 } /* Name.Builtin.Pseudo */
|
||||
.vc { color: #bb60d5 } /* Name.Variable.Class */
|
||||
.vg { color: #bb60d5 } /* Name.Variable.Global */
|
||||
.vi { color: #bb60d5 } /* Name.Variable.Instance */
|
||||
.il { color: #00BAFF } /* Literal.Number.Integer.Long */
|
BIN
doc/python_api/blender-org/static/rnd.png
Normal file
BIN
doc/python_api/blender-org/static/rnd.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 173 B |
BIN
doc/python_api/blender-org/static/rndbl.png
Normal file
BIN
doc/python_api/blender-org/static/rndbl.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 190 B |
BIN
doc/python_api/blender-org/static/rndbr.png
Normal file
BIN
doc/python_api/blender-org/static/rndbr.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 188 B |
30
doc/python_api/blender-org/theme.conf
Normal file
30
doc/python_api/blender-org/theme.conf
Normal file
@@ -0,0 +1,30 @@
|
||||
[theme]
|
||||
inherit = basic
|
||||
stylesheet = default.css
|
||||
pygments_style = sphinx
|
||||
|
||||
[options]
|
||||
rightsidebar = true
|
||||
stickysidebar = true
|
||||
|
||||
footerbgcolor = #000000
|
||||
footertextcolor = #ffffff
|
||||
sidebarbgcolor = #1c4e63
|
||||
sidebartextcolor = #ffffff
|
||||
sidebarlinkcolor = #97b9cf
|
||||
relbarbgcolor = #2C3845
|
||||
relbartextcolor = #D3E0E9
|
||||
relbarlinkcolor = #D3E0E9
|
||||
relbaractlinkcolor = #f39410
|
||||
bgcolor = #232323
|
||||
bordercolor = #363636
|
||||
textcolor = #ffffff
|
||||
headbgcolor = #232323
|
||||
headtextcolor = #ffffff
|
||||
headlinkcolor = #97b9cf
|
||||
linkcolor = #97b9cf
|
||||
codebgcolor = #eeffcc
|
||||
codetextcolor = #333333
|
||||
|
||||
bodyfont = "Lucida Grande","Lucida Sans Unicode","Lucida Sans","Lucida",Verdana,sans-serif
|
||||
headfont = "Lucida Grande","Lucida Sans Unicode","Lucida Sans","Lucida",Verdana,sans-serif
|
1807
doc/python_api/epy/BGL.py
Normal file
1807
doc/python_api/epy/BGL.py
Normal file
File diff suppressed because it is too large
Load Diff
189
doc/python_api/epy/Geometry.py
Normal file
189
doc/python_api/epy/Geometry.py
Normal file
@@ -0,0 +1,189 @@
|
||||
# Blender.Geometry module and its subtypes
|
||||
|
||||
"""
|
||||
The Blender.Geometry submodule.
|
||||
|
||||
Geometry
|
||||
========
|
||||
(when accessing it from the Game Engine use Geometry instead of Blender.Geometry)
|
||||
|
||||
This new module provides access to a geometry function.
|
||||
"""
|
||||
|
||||
def Intersect(vec1, vec2, vec3, ray, orig, clip=1):
|
||||
"""
|
||||
Return the intersection between a ray and a triangle, if possible, return None otherwise.
|
||||
@type vec1: Vector object.
|
||||
@param vec1: A 3d vector, one corner of the triangle.
|
||||
@type vec2: Vector object.
|
||||
@param vec2: A 3d vector, one corner of the triangle.
|
||||
@type vec3: Vector object.
|
||||
@param vec3: A 3d vector, one corner of the triangle.
|
||||
@type ray: Vector object.
|
||||
@param ray: A 3d vector, the orientation of the ray. the length of the ray is not used, only the direction.
|
||||
@type orig: Vector object.
|
||||
@param orig: A 3d vector, the origin of the ray.
|
||||
@type clip: integer
|
||||
@param clip: if 0, don't restrict the intersection to the area of the triangle, use the infinite plane defined by the triangle.
|
||||
@rtype: Vector object
|
||||
@return: The intersection between a ray and a triangle, if possible, None otherwise.
|
||||
"""
|
||||
|
||||
def TriangleArea(vec1, vec2, vec3):
|
||||
"""
|
||||
Return the area size of the 2D or 3D triangle defined.
|
||||
@type vec1: Vector object.
|
||||
@param vec1: A 2d or 3d vector, one corner of the triangle.
|
||||
@type vec2: Vector object.
|
||||
@param vec2: A 2d or 3d vector, one corner of the triangle.
|
||||
@type vec3: Vector object.
|
||||
@param vec3: A 2d or 3d vector, one corner of the triangle.
|
||||
@rtype: float
|
||||
@return: The area size of the 2D or 3D triangle defined.
|
||||
"""
|
||||
|
||||
def TriangleNormal(vec1, vec2, vec3):
|
||||
"""
|
||||
Return the normal of the 3D triangle defined.
|
||||
@type vec1: Vector object.
|
||||
@param vec1: A 3d vector, one corner of the triangle.
|
||||
@type vec2: Vector object.
|
||||
@param vec2: A 3d vector, one corner of the triangle.
|
||||
@type vec3: Vector object.
|
||||
@param vec3: A 3d vector, one corner of the triangle.
|
||||
@rtype: float
|
||||
@return: The normal of the 3D triangle defined.
|
||||
"""
|
||||
|
||||
def QuadNormal(vec1, vec2, vec3, vec4):
|
||||
"""
|
||||
Return the normal of the 3D quad defined.
|
||||
@type vec1: Vector object.
|
||||
@param vec1: A 3d vector, the first vertex of the quad.
|
||||
@type vec2: Vector object.
|
||||
@param vec2: A 3d vector, the second vertex of the quad.
|
||||
@type vec3: Vector object.
|
||||
@param vec3: A 3d vector, the third vertex of the quad.
|
||||
@type vec4: Vector object.
|
||||
@param vec4: A 3d vector, the fourth vertex of the quad.
|
||||
@rtype: float
|
||||
@return: The normal of the 3D quad defined.
|
||||
"""
|
||||
|
||||
def LineIntersect(vec1, vec2, vec3, vec4):
|
||||
"""
|
||||
Return a tuple with the points on each line respectively closest to the other
|
||||
(when both lines intersect, both vector hold the same value).
|
||||
The lines are evaluated as infinite lines in space, the values returned may not be between the 2 points given for each line.
|
||||
@type vec1: Vector object.
|
||||
@param vec1: A 3d vector, one point on the first line.
|
||||
@type vec2: Vector object.
|
||||
@param vec2: A 3d vector, another point on the first line.
|
||||
@type vec3: Vector object.
|
||||
@param vec3: A 3d vector, one point on the second line.
|
||||
@type vec4: Vector object.
|
||||
@param vec4: A 3d vector, another point on the second line.
|
||||
@rtype: (Vector object, Vector object)
|
||||
@return: A tuple with the points on each line respectively closest to the other.
|
||||
"""
|
||||
|
||||
def PolyFill(polylines):
|
||||
"""
|
||||
Takes a list of polylines and calculates triangles that would fill in the polylines.
|
||||
Multiple lines can be used to make holes inside a polyline, or fill in 2 separate lines at once.
|
||||
@type polylines: List of lists containing vectors, each representing a closed polyline.
|
||||
@rtype: list
|
||||
@return: a list if tuples each a tuple of 3 ints representing a triangle indexing the points given.
|
||||
@note: 2D Vectors will have an assumed Z axis of zero, 4D Vectors W axis is ignored.
|
||||
@note: The order of points in a polyline effect the direction returned triangles face, reverse the order of a polyline to flip the normal of returned faces.
|
||||
|
||||
I{B{Example:}}
|
||||
|
||||
The example below creates 2 polylines and fills them in with faces, then makes a mesh in the current scene::
|
||||
import Blender
|
||||
Vector= Blender.mathutils.Vector
|
||||
|
||||
# Outline of 5 points
|
||||
polyline1= [Vector(-2.0, 1.0, 1.0), Vector(-1.0, 2.0, 1.0), Vector(1.0, 2.0, 1.0), Vector(1.0, -1.0, 1.0), Vector(-1.0, -1.0, 1.0)]
|
||||
polyline2= [Vector(-1, 1, 1.0), Vector(0, 1, 1.0), Vector(0, 0, 1.0), Vector(-1.0, 0.0, 1.0)]
|
||||
fill= Blender.Geometry.PolyFill([polyline1, polyline2])
|
||||
|
||||
# Make a new mesh and add the truangles into it
|
||||
me= Blender.Mesh.New()
|
||||
me.verts.extend(polyline1)
|
||||
me.verts.extend(polyline2)
|
||||
me.faces.extend(fill) # Add the faces, they reference the verts in polyline 1 and 2
|
||||
|
||||
scn = Blender.Scene.GetCurrent()
|
||||
ob = scn.objects.new(me)
|
||||
Blender.Redraw()
|
||||
"""
|
||||
|
||||
def LineIntersect2D(vec1, vec2, vec3, vec4):
|
||||
"""
|
||||
Takes 2 lines vec1, vec2 for the 2 points of the first line and vec2, vec3 for the 2 points of the second line.
|
||||
@rtype: Vector
|
||||
@return: a 2D Vector for the intersection or None where there is no intersection.
|
||||
"""
|
||||
|
||||
def ClosestPointOnLine(pt, vec1, vec2):
|
||||
"""
|
||||
Takes 2 lines vec1, vec2 for the 2 points of the first line and vec2, vec3 for the 2 points of the second line.
|
||||
@rtype: tuple
|
||||
@return: a tuple containing a vector and a float, the vector is the closest point on the line, the float is the position on the line, between 0 and 1 the point is on the line.
|
||||
"""
|
||||
|
||||
def PointInTriangle2D(pt, tri_pt1, tri_pt2, tri_pt3):
|
||||
"""
|
||||
Takes 4 vectors (one for the test point and 3 for the triangle)
|
||||
This is a 2d function so only X and Y are used, Z and W will be ignored.
|
||||
@rtype: int
|
||||
@return: 1 for a clockwise intersection, -1 for counter clockwise intersection, 0 when there is no intersection.
|
||||
"""
|
||||
|
||||
def PointInQuad2D(pt, quad_pt1, quad_pt2, quad_pt3):
|
||||
"""
|
||||
Takes 5 vectors (one for the test point and 5 for the quad)
|
||||
This is a 2d function so only X and Y are used, Z and W will be ignored.
|
||||
@rtype: int
|
||||
@return: 1 for a clockwise intersection, -1 for counter clockwise intersection, 0 when there is no intersection.
|
||||
"""
|
||||
|
||||
def BoxPack2D(boxlist):
|
||||
"""
|
||||
Takes a list of 2D boxes and packs them into a square.
|
||||
Each box in boxlist must be a list of at least 4 items - [x,y,w,h], after running this script,
|
||||
the X and Y values in each box will be moved to packed, non overlapping locations.
|
||||
|
||||
Example::
|
||||
|
||||
# Make 500 random boxes, pack them and make a mesh from it
|
||||
from Blender import Geometry, Scene, Mesh
|
||||
import random
|
||||
boxes = []
|
||||
for i in xrange(500):
|
||||
boxes.append( [0,0, random.random()+0.1, random.random()+0.1] )
|
||||
boxsize = Geometry.BoxPack2D(boxes)
|
||||
print 'BoxSize', boxsize
|
||||
me = Mesh.New()
|
||||
for x in boxes:
|
||||
me.verts.extend([(x[0],x[1], 0), (x[0],x[1]+x[3], 0), (x[0]+x[2],x[1]+x[3], 0), (x[0]+x[2],x[1], 0) ])
|
||||
v1= me.verts[-1]
|
||||
v2= me.verts[-2]
|
||||
v3= me.verts[-3]
|
||||
v4= me.verts[-4]
|
||||
me.faces.extend([(v1,v2,v3,v4)])
|
||||
scn = Scene.GetCurrent()
|
||||
scn.objects.new(me)
|
||||
|
||||
@note: Each boxlist item can be longer then 4, the extra items are ignored and stay untouched.
|
||||
@rtype: tuple
|
||||
@return: a tuple pair - (width, height) of all the packed boxes.
|
||||
"""
|
||||
def BezierInterp(vec_knot_1, vec_handle_1, vec_handle_2, vec_knot_2, resolution):
|
||||
"""
|
||||
Takes 4 vectors representing a bezier curve and returns a list of vector points.
|
||||
@note: any vector size is supported, the largest dimension from the input will be used for all returned vectors/
|
||||
@rtype: list
|
||||
@return: a list of vectors the size of resolution including the start and end points (vec_knot_1 and vec_knot_2)
|
||||
"""
|
132
doc/python_api/epy/IDProp.py
Normal file
132
doc/python_api/epy/IDProp.py
Normal file
@@ -0,0 +1,132 @@
|
||||
class IDGroup:
|
||||
"""
|
||||
The IDGroup Type
|
||||
================
|
||||
This type supports both iteration and the []
|
||||
operator to get child ID properties.
|
||||
|
||||
You can also add new properties using the [] operator.
|
||||
For example::
|
||||
|
||||
group['a float!'] = 0.0
|
||||
group['an int!'] = 0
|
||||
group['a string!'] = "hi!"
|
||||
group['an array!'] = [0, 0, 1.0, 0]
|
||||
|
||||
group['a subgroup!] = {"float": 0.0, "an int": 1.0, "an array": [1, 2],
|
||||
"another subgroup": {"a": 0.0, "str": "bleh"}}
|
||||
|
||||
Note that for arrays, the array type defaults to int unless a float is found
|
||||
while scanning the template list; if any floats are found, then the whole
|
||||
array is float. Note that double-precision floating point numbers are used for
|
||||
python-created float ID properties and arrays (though the internal C api does
|
||||
support single-precision floats, and the python code will read them).
|
||||
|
||||
You can also delete properties with the del operator. For example:
|
||||
|
||||
del group['property']
|
||||
|
||||
To get the type of a property, use the type() operator, for example::
|
||||
|
||||
if type(group['bleh']) == str: pass
|
||||
|
||||
To tell if the property is a group or array type, import the Blender.Types module and test
|
||||
against IDGroupType and IDArrayType, like so::
|
||||
|
||||
from Blender.Types import IDGroupType, IDArrayType.
|
||||
|
||||
if type(group['bleghr']) == IDGroupType:
|
||||
(do something)
|
||||
|
||||
@ivar name: The name of the property
|
||||
@type name: string
|
||||
"""
|
||||
|
||||
def pop(item):
|
||||
"""
|
||||
Pop an item from the group property.
|
||||
@type item: string
|
||||
@param item: The item name.
|
||||
@rtype: can be dict, list, int, float or string.
|
||||
@return: The removed property.
|
||||
"""
|
||||
|
||||
def update(updatedict):
|
||||
"""
|
||||
Updates items in the dict, similar to normal python
|
||||
dictionary method .update().
|
||||
@type updatedict: dict
|
||||
@param updatedict: A dict of simple types to derive updated/new IDProperties from.
|
||||
@rtype: None
|
||||
@return: None
|
||||
"""
|
||||
|
||||
def keys():
|
||||
"""
|
||||
Returns a list of the keys in this property group.
|
||||
@rtype: list of strings.
|
||||
@return: a list of the keys in this property group.
|
||||
"""
|
||||
|
||||
def values():
|
||||
"""
|
||||
Returns a list of the values in this property group.
|
||||
|
||||
Note that unless a value is itself a property group or an array, you
|
||||
cannot change it by changing the values in this list, you must change them
|
||||
in the parent property group.
|
||||
|
||||
For example,
|
||||
|
||||
group['some_property'] = new_value
|
||||
|
||||
. . .is correct, while,
|
||||
|
||||
values = group.values()
|
||||
values[0] = new_value
|
||||
|
||||
. . .is wrong.
|
||||
|
||||
@rtype: list of strings.
|
||||
@return: a list of the values in this property group.
|
||||
"""
|
||||
|
||||
def iteritems():
|
||||
"""
|
||||
Implements the python dictionary iteritmes method.
|
||||
|
||||
For example::
|
||||
|
||||
for k, v in group.iteritems():
|
||||
print "Property name: " + k
|
||||
print "Property value: " + str(v)
|
||||
|
||||
@rtype: an iterator that spits out items of the form [key, value]
|
||||
@return: an iterator.
|
||||
"""
|
||||
|
||||
def convert_to_pyobject():
|
||||
"""
|
||||
Converts the entire property group to a purely python form.
|
||||
|
||||
@rtype: dict
|
||||
@return: A python dictionary representing the property group
|
||||
"""
|
||||
|
||||
class IDArray:
|
||||
"""
|
||||
The IDArray Type
|
||||
================
|
||||
|
||||
@ivar type: returns the type of the array, can be either IDP_Int or IDP_Float
|
||||
"""
|
||||
|
||||
def __getitem__(index):
|
||||
pass
|
||||
|
||||
def __setitem__(index, value):
|
||||
pass
|
||||
|
||||
def __len__():
|
||||
pass
|
||||
|
156
doc/python_api/epy/Mathutils.py
Normal file
156
doc/python_api/epy/Mathutils.py
Normal file
@@ -0,0 +1,156 @@
|
||||
# Blender.mathutils module and its subtypes
|
||||
|
||||
|
||||
|
||||
class Vector:
|
||||
"""
|
||||
|
||||
@attention: Vector data can be wrapped or non-wrapped. When a object is wrapped it
|
||||
means that the object will give you direct access to the data inside of blender. Modification
|
||||
of this object will directly change the data inside of blender. To copy a wrapped object
|
||||
you need to use the object's constructor. If you copy and object by assignment you will not get
|
||||
a second copy but a second reference to the same data. Only certain functions will return
|
||||
wrapped data. This will be indicated in the method description.
|
||||
"""
|
||||
|
||||
def __init__(list = None):
|
||||
"""
|
||||
Create a new 2d, 3d, or 4d Vector object from a list of floating point numbers.
|
||||
@note: that python uses higher precission floating point numbers, so values assigned to a vector may have some rounding error.
|
||||
|
||||
|
||||
Example::
|
||||
v = Vector(1,0,0)
|
||||
v = Vector(myVec)
|
||||
v = Vector(list)
|
||||
@type list: PyList of float or int
|
||||
@param list: The list of values for the Vector object. Can be a sequence or raw numbers.
|
||||
Must be 2, 3, or 4 values. The list is mapped to the parameters as [x,y,z,w].
|
||||
@rtype: Vector object.
|
||||
@return: It depends wheter a parameter was passed:
|
||||
- (list): Vector object initialized with the given values;
|
||||
- (): An empty 3 dimensional vector.
|
||||
"""
|
||||
|
||||
class Euler:
|
||||
"""
|
||||
The Euler object
|
||||
================
|
||||
This object gives access to Eulers in Blender.
|
||||
@note: You can access a euler object like a sequence
|
||||
- x = euler[0]
|
||||
@note: Comparison operators can be done:
|
||||
- ==, != test numeric values within epsilon
|
||||
@attention: Euler data can be wrapped or non-wrapped. When a object is wrapped it
|
||||
means that the object will give you direct access to the data inside of blender. Modification
|
||||
of this object will directly change the data inside of blender. To copy a wrapped object
|
||||
you need to use the object's constructor. If you copy and object by assignment you will not get
|
||||
a second copy but a second reference to the same data. Only certain functions will return
|
||||
wrapped data. This will be indicated in the method description.
|
||||
"""
|
||||
|
||||
def __init__(list = None):
|
||||
"""
|
||||
Create a new euler object.
|
||||
|
||||
Example::
|
||||
euler = Euler(45,0,0)
|
||||
euler = Euler(myEuler)
|
||||
euler = Euler(sequence)
|
||||
@type list: PyList of float/int
|
||||
@param list: 3d list to initialize euler
|
||||
@rtype: Euler object
|
||||
@return: Euler representing heading, pitch, bank.
|
||||
@note: Values are in degrees.
|
||||
"""
|
||||
|
||||
class Quaternion:
|
||||
"""
|
||||
The Quaternion object
|
||||
=====================
|
||||
This object gives access to Quaternions in Blender.
|
||||
@note: Comparison operators can be done:
|
||||
- ==, != test numeric values within epsilon
|
||||
@note: Math can be performed on Quaternion classes
|
||||
- quat + quat
|
||||
- quat - quat
|
||||
- quat * float/int
|
||||
- quat * vec
|
||||
- quat * quat
|
||||
@note: You can access a quaternion object like a sequence
|
||||
- x = quat[0]
|
||||
@attention: Quaternion data can be wrapped or non-wrapped. When a object is wrapped it
|
||||
means that the object will give you direct access to the data inside of blender. Modification
|
||||
of this object will directly change the data inside of blender. To copy a wrapped object
|
||||
you need to use the object's constructor. If you copy and object by assignment you will not get
|
||||
a second copy but a second reference to the same data. Only certain functions will return
|
||||
wrapped data. This will be indicated in the method description.
|
||||
"""
|
||||
|
||||
def __init__(list, angle = None):
|
||||
"""
|
||||
Create a new quaternion object from initialized values.
|
||||
|
||||
Example::
|
||||
quat = Quaternion(1,2,3,4)
|
||||
quat = Quaternion(axis, angle)
|
||||
quat = Quaternion()
|
||||
quat = Quaternion(180, list)
|
||||
|
||||
@type list: PyList of int/float
|
||||
@param list: A 3d or 4d list to initialize quaternion.
|
||||
4d if intializing [w,x,y,z], 3d if used as an axis of rotation.
|
||||
@type angle: float (optional)
|
||||
@param angle: An arbitrary rotation amount around 'list'.
|
||||
List is used as an axis of rotation in this case.
|
||||
@rtype: New quaternion object.
|
||||
@return: It depends wheter a parameter was passed:
|
||||
- (list/angle): Quaternion object initialized with the given values;
|
||||
- (): An identity 4 dimensional quaternion.
|
||||
"""
|
||||
|
||||
class Matrix:
|
||||
"""
|
||||
The Matrix Object
|
||||
=================
|
||||
@note: Math can be performed on Matrix classes
|
||||
- mat + mat
|
||||
- mat - mat
|
||||
- mat * float/int
|
||||
- mat * vec
|
||||
- mat * mat
|
||||
@note: Comparison operators can be done:
|
||||
- ==, != test numeric values within epsilon
|
||||
@note: You can access a quaternion object like a 2d sequence
|
||||
- x = matrix[0][1]
|
||||
- vector = matrix[2]
|
||||
@attention: Quaternion data can be wrapped or non-wrapped. When a object is wrapped it
|
||||
means that the object will give you direct access to the data inside of blender. Modification
|
||||
of this object will directly change the data inside of blender. To copy a wrapped object
|
||||
you need to use the object's constructor. If you copy and object by assignment you will not get
|
||||
a second copy but a second reference to the same data. Only certain functions will return
|
||||
wrapped data. This will be indicated in the method description.
|
||||
"""
|
||||
|
||||
def __init__(list1 = None, list2 = None, list3 = None, list4 = None):
|
||||
"""
|
||||
Create a new matrix object from initialized values.
|
||||
|
||||
Example::
|
||||
matrix = Matrix([1,1,1],[0,1,0],[1,0,0])
|
||||
matrix = Matrix(mat)
|
||||
matrix = Matrix(seq1, seq2, vector)
|
||||
|
||||
@type list1: PyList of int/float
|
||||
@param list1: A 2d,3d or 4d list.
|
||||
@type list2: PyList of int/float
|
||||
@param list2: A 2d,3d or 4d list.
|
||||
@type list3: PyList of int/float
|
||||
@param list3: A 2d,3d or 4d list.
|
||||
@type list4: PyList of int/float
|
||||
@param list4: A 2d,3d or 4d list.
|
||||
@rtype: New matrix object.
|
||||
@return: It depends wheter a parameter was passed:
|
||||
- (list1, etc.): Matrix object initialized with the given values;
|
||||
- (): An empty 3 dimensional matrix.
|
||||
"""
|
45
doc/python_api/epy/testbgl.py
Normal file
45
doc/python_api/epy/testbgl.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# Testing the BGL module
|
||||
|
||||
import Blender
|
||||
from Blender.BGL import *
|
||||
from Blender import Draw
|
||||
|
||||
R = G = B = 0
|
||||
A = 1
|
||||
|
||||
instructions = "Hold mouse buttons to change the background color."
|
||||
quitting = " Press ESC or q to quit."
|
||||
|
||||
def show_win():
|
||||
glClearColor(R,G,B,A) # define color used to clear buffers
|
||||
glClear(GL_COLOR_BUFFER_BIT) # use it to clear the color buffer
|
||||
glColor3f(1,1,1) # change default color
|
||||
glRasterPos2i(50,100) # move cursor to x = 50, y = 100
|
||||
Draw.Text("Testing BGL + Draw") # draw this text there
|
||||
glRasterPos2i(350,20) # move cursor again
|
||||
Draw.Text(instructions + quitting) # draw another msg
|
||||
glBegin(GL_LINE_LOOP) # begin a vertex-data list
|
||||
glVertex2i(46,92)
|
||||
glVertex2i(120,92)
|
||||
glVertex2i(120,115)
|
||||
glVertex2i(46,115)
|
||||
glEnd() # close this list
|
||||
glColor3f(0.35,0.18,0.92) # change default color again
|
||||
glBegin(GL_POLYGON) # another list, for a polygon
|
||||
glVertex2i(315, 292)
|
||||
glVertex2i(412, 200)
|
||||
glVertex2i(264, 256)
|
||||
glEnd()
|
||||
Draw.Redraw(1) # make changes visible.
|
||||
|
||||
def ev(evt, val): # this is a callback for Draw.Register()
|
||||
global R,G,B,A # it handles input events
|
||||
if evt == Draw.ESCKEY or evt == Draw.QKEY:
|
||||
Draw.Exit() # this quits the script
|
||||
elif evt == Draw.LEFTMOUSE: R = 1 - R
|
||||
elif evt == Draw.MIDDLEMOUSE: G = 1 - G
|
||||
elif evt == Draw.RIGHTMOUSE: B = 1 - B
|
||||
else:
|
||||
Draw.Register(show_win, ev, None)
|
||||
|
||||
Draw.Register(show_win, ev, None) # start the main loop
|
29
doc/python_api/examples/bpy.data.py
Normal file
29
doc/python_api/examples/bpy.data.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import bpy
|
||||
|
||||
|
||||
# print all objects
|
||||
for obj in bpy.data.objects:
|
||||
print(obj.name)
|
||||
|
||||
|
||||
# print all scene names in a list
|
||||
print(bpy.data.scenes.keys())
|
||||
|
||||
|
||||
# remove mesh Cube
|
||||
if "Cube" in bpy.data.meshes:
|
||||
mesh = bpy.data.meshes["Cube"]
|
||||
print("removing mesh", mesh)
|
||||
bpy.data.meshes.unlink(mesh)
|
||||
|
||||
|
||||
# write images into a file next to the blend
|
||||
import os
|
||||
file = open(os.path.splitext(bpy.data.filepath)[0] + ".txt", 'w')
|
||||
|
||||
for image in bpy.data.images:
|
||||
file.write("%s %dx%d\n" % (image.filepath, image.size[0], image.size[1]))
|
||||
|
||||
file.close()
|
||||
|
||||
|
3
doc/python_api/examples/mathutils.Euler.py
Normal file
3
doc/python_api/examples/mathutils.Euler.py
Normal file
@@ -0,0 +1,3 @@
|
||||
import mathutils
|
||||
|
||||
# todo
|
3
doc/python_api/examples/mathutils.Matrix.py
Normal file
3
doc/python_api/examples/mathutils.Matrix.py
Normal file
@@ -0,0 +1,3 @@
|
||||
import mathutils
|
||||
|
||||
# todo
|
3
doc/python_api/examples/mathutils.Quaternion.py
Normal file
3
doc/python_api/examples/mathutils.Quaternion.py
Normal file
@@ -0,0 +1,3 @@
|
||||
import mathutils
|
||||
|
||||
# todo
|
55
doc/python_api/examples/mathutils.Vector.py
Normal file
55
doc/python_api/examples/mathutils.Vector.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import mathutils
|
||||
|
||||
# zero length vector
|
||||
vec = mathutils.Vector((0, 0, 1))
|
||||
|
||||
# unit length vector
|
||||
vec_a = vec.copy().normalize()
|
||||
|
||||
vec_b = mathutils.Vector((0, 1, 2))
|
||||
|
||||
vec2d = mathutils.Vector((1, 2))
|
||||
vec3d = mathutils.Vector((1, 0, 0))
|
||||
vec4d = vec_a.copy().resize4D()
|
||||
|
||||
# other mathutuls types
|
||||
quat = mathutils.Quaternion()
|
||||
matrix = mathutils.Matrix()
|
||||
|
||||
# Comparison operators can be done on Vector classes:
|
||||
|
||||
# greater and less then test vector length.
|
||||
vec_a > vec_b
|
||||
vec_a >= vec_b
|
||||
vec_a < vec_b
|
||||
vec_a <= vec_b
|
||||
|
||||
# ==, != test vector values e.g. 1,2,3 != 3,2,1 even if they are the same length
|
||||
vec_a == vec_b
|
||||
vec_a != vec_b
|
||||
|
||||
|
||||
# Math can be performed on Vector classes
|
||||
vec_a + vec_b
|
||||
vec_a - vec_b
|
||||
vec_a * vec_b
|
||||
vec_a * 10.0
|
||||
vec_a * matrix
|
||||
vec_a * vec_b
|
||||
vec_a * quat
|
||||
-vec_a
|
||||
|
||||
|
||||
# You can access a vector object like a sequence
|
||||
x = vec_a[0]
|
||||
len(vec)
|
||||
vec_a[:] = vec_b
|
||||
vec2d[:] = vec3d[:2]
|
||||
|
||||
|
||||
# Vectors support 'swizzle' operations
|
||||
# See http://en.wikipedia.org/wiki/Swizzling_(computer_graphics)
|
||||
vec.xyz = vec.zyx
|
||||
vec.xy = vec4d.zw
|
||||
vec.xyz = vec4d.wzz
|
||||
vec4d.wxyz = vec.yxyx
|
18
doc/python_api/examples/mathutils.py
Normal file
18
doc/python_api/examples/mathutils.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import mathutils
|
||||
from math import radians
|
||||
|
||||
vec = mathutils.Vector((1.0, 2.0, 3.0))
|
||||
|
||||
mat_rot = mathutils.Matrix.Rotation(radians(90), 4, 'X')
|
||||
mat_trans = mathutils.Matrix.Translation(vec)
|
||||
|
||||
mat = mat_trans * mat_rot
|
||||
mat.invert()
|
||||
|
||||
mat3 = mat.rotation_part()
|
||||
quat1 = mat.to_quat()
|
||||
quat2 = mat3.to_quat()
|
||||
|
||||
angle = quat1.difference(quat2)
|
||||
|
||||
print(angle)
|
250
doc/python_api/rst/bge.events.rst
Normal file
250
doc/python_api/rst/bge.events.rst
Normal file
@@ -0,0 +1,250 @@
|
||||
|
||||
Game Engine bge.events module
|
||||
=============================
|
||||
|
||||
*****
|
||||
Intro
|
||||
*****
|
||||
|
||||
This module holds key constants for the SCA_KeyboardSensor.
|
||||
|
||||
.. module:: bge.events
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Set a connected keyboard sensor to accept F1
|
||||
import bge
|
||||
|
||||
co = bge.logic.getCurrentController()
|
||||
# 'Keyboard' is a keyboard sensor
|
||||
sensor = co.sensors["Keyboard"]
|
||||
sensor.key = bge.events.F1KEY
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Do the all keys thing
|
||||
import bge
|
||||
|
||||
co = bge.logic.getCurrentController()
|
||||
# 'Keyboard' is a keyboard sensor
|
||||
sensor = co.sensors["Keyboard"]
|
||||
|
||||
for key,status in sensor.events:
|
||||
# key[0] == bge.events.keycode, key[1] = status
|
||||
if status == bge.logic.KX_INPUT_JUST_ACTIVATED:
|
||||
if key == bge.events.WKEY:
|
||||
# Activate Forward!
|
||||
if key == bge.events.SKEY:
|
||||
# Activate Backward!
|
||||
if key == bge.events.AKEY:
|
||||
# Activate Left!
|
||||
if key == bge.events.DKEY:
|
||||
# Activate Right!
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# The all keys thing without a keyboard sensor (but you will
|
||||
# need an always sensor with pulse mode on)
|
||||
import bge
|
||||
|
||||
# Just shortening names here
|
||||
keyboard = bge.logic.keyboard
|
||||
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
|
||||
|
||||
if keyboard.events[bge.events.WKEY] == JUST_ACTIVATED:
|
||||
print("Activate Forward!")
|
||||
if keyboard.events[bge.events.SKEY] == JUST_ACTIVATED:
|
||||
print("Activate Backward!")
|
||||
if keyboard.events[bge.events.AKEY] == JUST_ACTIVATED:
|
||||
print("Activate Left!")
|
||||
if keyboard.events[bge.events.DKEY] == JUST_ACTIVATED:
|
||||
print("Activate Right!")
|
||||
|
||||
|
||||
*********
|
||||
Functions
|
||||
*********
|
||||
|
||||
.. function:: EventToString(event)
|
||||
|
||||
Return the string name of a key event. Will raise a ValueError error if its invalid.
|
||||
|
||||
:arg event: key event from bge.keys or the keyboard sensor.
|
||||
:type event: int
|
||||
:rtype: string
|
||||
|
||||
.. function:: EventToCharacter(event, shift)
|
||||
|
||||
Return the string name of a key event. Returns an empty string if the event cant be represented as a character.
|
||||
|
||||
:type event: int
|
||||
:arg event: key event from :mod:`bge.keys` or the keyboard sensor.
|
||||
:type shift: bool
|
||||
:arg shift: set to true if shift is held.
|
||||
:rtype: string
|
||||
|
||||
****************
|
||||
Keys (Constants)
|
||||
****************
|
||||
|
||||
.. _mouse-keys:
|
||||
|
||||
==========
|
||||
Mouse Keys
|
||||
==========
|
||||
|
||||
.. data:: LEFTMOUSE
|
||||
.. data:: MIDDLEMOUSE
|
||||
.. data:: RIGHTMOUSE
|
||||
.. data:: WHEELUPMOUSE
|
||||
.. data:: WHEELDOWNMOUSE
|
||||
.. data:: MOUSEX
|
||||
.. data:: MOUSEY
|
||||
|
||||
.. _keyboard-keys:
|
||||
|
||||
=============
|
||||
Keyboard Keys
|
||||
=============
|
||||
|
||||
-------------
|
||||
Alphabet keys
|
||||
-------------
|
||||
|
||||
.. data:: AKEY
|
||||
.. data:: BKEY
|
||||
.. data:: CKEY
|
||||
.. data:: DKEY
|
||||
.. data:: EKEY
|
||||
.. data:: FKEY
|
||||
.. data:: GKEY
|
||||
.. data:: HKEY
|
||||
.. data:: IKEY
|
||||
.. data:: JKEY
|
||||
.. data:: KKEY
|
||||
.. data:: LKEY
|
||||
.. data:: MKEY
|
||||
.. data:: NKEY
|
||||
.. data:: OKEY
|
||||
.. data:: PKEY
|
||||
.. data:: QKEY
|
||||
.. data:: RKEY
|
||||
.. data:: SKEY
|
||||
.. data:: TKEY
|
||||
.. data:: UKEY
|
||||
.. data:: VKEY
|
||||
.. data:: WKEY
|
||||
.. data:: XKEY
|
||||
.. data:: YKEY
|
||||
.. data:: ZKEY
|
||||
|
||||
-----------
|
||||
Number keys
|
||||
-----------
|
||||
|
||||
.. data:: ZEROKEY
|
||||
.. data:: ONEKEY
|
||||
.. data:: TWOKEY
|
||||
.. data:: THREEKEY
|
||||
.. data:: FOURKEY
|
||||
.. data:: FIVEKEY
|
||||
.. data:: SIXKEY
|
||||
.. data:: SEVENKEY
|
||||
.. data:: EIGHTKEY
|
||||
.. data:: NINEKEY
|
||||
|
||||
--------------
|
||||
Modifiers Keys
|
||||
--------------
|
||||
|
||||
.. data:: CAPSLOCKKEY
|
||||
.. data:: LEFTCTRLKEY
|
||||
.. data:: LEFTALTKEY
|
||||
.. data:: RIGHTALTKEY
|
||||
.. data:: RIGHTCTRLKEY
|
||||
.. data:: RIGHTSHIFTKEY
|
||||
.. data:: LEFTSHIFTKEY
|
||||
|
||||
----------
|
||||
Arrow Keys
|
||||
----------
|
||||
|
||||
.. data:: LEFTARROWKEY
|
||||
.. data:: DOWNARROWKEY
|
||||
.. data:: RIGHTARROWKEY
|
||||
.. data:: UPARROWKEY
|
||||
|
||||
--------------
|
||||
Numberpad Keys
|
||||
--------------
|
||||
|
||||
.. data:: PAD0
|
||||
.. data:: PAD1
|
||||
.. data:: PAD2
|
||||
.. data:: PAD3
|
||||
.. data:: PAD4
|
||||
.. data:: PAD5
|
||||
.. data:: PAD6
|
||||
.. data:: PAD7
|
||||
.. data:: PAD8
|
||||
.. data:: PAD9
|
||||
.. data:: PADPERIOD
|
||||
.. data:: PADSLASHKEY
|
||||
.. data:: PADASTERKEY
|
||||
.. data:: PADMINUS
|
||||
.. data:: PADENTER
|
||||
.. data:: PADPLUSKEY
|
||||
|
||||
-------------
|
||||
Function Keys
|
||||
-------------
|
||||
|
||||
.. data:: F1KEY
|
||||
.. data:: F2KEY
|
||||
.. data:: F3KEY
|
||||
.. data:: F4KEY
|
||||
.. data:: F5KEY
|
||||
.. data:: F6KEY
|
||||
.. data:: F7KEY
|
||||
.. data:: F8KEY
|
||||
.. data:: F9KEY
|
||||
.. data:: F10KEY
|
||||
.. data:: F11KEY
|
||||
.. data:: F12KEY
|
||||
.. data:: F13KEY
|
||||
.. data:: F14KEY
|
||||
.. data:: F15KEY
|
||||
.. data:: F16KEY
|
||||
.. data:: F17KEY
|
||||
.. data:: F18KEY
|
||||
.. data:: F19KEY
|
||||
|
||||
----------
|
||||
Other Keys
|
||||
----------
|
||||
|
||||
.. data:: ACCENTGRAVEKEY
|
||||
.. data:: BACKSLASHKEY
|
||||
.. data:: BACKSPACEKEY
|
||||
.. data:: COMMAKEY
|
||||
.. data:: DELKEY
|
||||
.. data:: ENDKEY
|
||||
.. data:: EQUALKEY
|
||||
.. data:: ESCKEY
|
||||
.. data:: HOMEKEY
|
||||
.. data:: INSERTKEY
|
||||
.. data:: LEFTBRACKETKEY
|
||||
.. data:: LINEFEEDKEY
|
||||
.. data:: MINUSKEY
|
||||
.. data:: PAGEDOWNKEY
|
||||
.. data:: PAGEUPKEY
|
||||
.. data:: PAUSEKEY
|
||||
.. data:: PERIODKEY
|
||||
.. data:: QUOTEKEY
|
||||
.. data:: RIGHTBRACKETKEY
|
||||
.. data:: RETKEY (Deprecated: use bge.events.ENTERKEY)
|
||||
.. data:: ENTERKEY
|
||||
.. data:: SEMICOLONKEY
|
||||
.. data:: SLASHKEY
|
||||
.. data:: SPACEKEY
|
||||
.. data:: TABKEY
|
932
doc/python_api/rst/bge.logic.rst
Normal file
932
doc/python_api/rst/bge.logic.rst
Normal file
@@ -0,0 +1,932 @@
|
||||
|
||||
Game Engine bge.logic Module
|
||||
============================
|
||||
*****
|
||||
Intro
|
||||
*****
|
||||
|
||||
Module to access logic functions, imported automatically into the python controllers namespace.
|
||||
|
||||
.. module:: bge.logic
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# To get the controller thats running this python script:
|
||||
cont = bge.logic.getCurrentController() # bge.logic is automatically imported
|
||||
|
||||
# To get the game object this controller is on:
|
||||
obj = cont.owner
|
||||
|
||||
:class:`~bge.types.KX_GameObject` and :class:`~bge.types.KX_Camera` or :class:`bge.types.~KX_LightObject` methods are available depending on the type of object
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# To get a sensor linked to this controller.
|
||||
# "sensorname" is the name of the sensor as defined in the Blender interface.
|
||||
# +---------------------+ +--------+
|
||||
# | Sensor "sensorname" +--+ Python +
|
||||
# +---------------------+ +--------+
|
||||
sens = cont.sensors["sensorname"]
|
||||
|
||||
# To get a sequence of all sensors:
|
||||
sensors = co.sensors
|
||||
|
||||
See the sensor's reference for available methods:
|
||||
|
||||
.. hlist::
|
||||
:columns: 3
|
||||
|
||||
* :class:`~bge.types.KX_MouseFocusSensor`
|
||||
* :class:`~bge.types.KX_NearSensor`
|
||||
* :class:`~bge.types.KX_NetworkMessageSensor`
|
||||
* :class:`~bge.types.KX_RadarSensor`
|
||||
* :class:`~bge.types.KX_RaySensor`
|
||||
* :class:`~bge.types.KX_TouchSensor`
|
||||
* :class:`~bge.types.SCA_DelaySensor`
|
||||
* :class:`~bge.types.SCA_JoystickSensor`
|
||||
* :class:`~bge.types.SCA_KeyboardSensor`
|
||||
* :class:`~bge.types.SCA_MouseSensor`
|
||||
* :class:`~bge.types.SCA_PropertySensor`
|
||||
* :class:`~bge.types.SCA_RandomSensor`
|
||||
|
||||
You can also access actuators linked to the controller
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# To get an actuator attached to the controller:
|
||||
# +--------+ +-------------------------+
|
||||
# + Python +--+ Actuator "actuatorname" |
|
||||
# +--------+ +-------------------------+
|
||||
actuator = co.actuators["actuatorname"]
|
||||
|
||||
# Activate an actuator
|
||||
controller.activate(actuator)
|
||||
|
||||
See the actuator's reference for available methods
|
||||
|
||||
.. hlist::
|
||||
:columns: 3
|
||||
|
||||
* :class:`~bge.types.BL_ActionActuator`
|
||||
* :class:`~bge.types.BL_ShapeActionActuator`
|
||||
* :class:`~bge.types.KX_CameraActuator`
|
||||
* :class:`~bge.types.KX_ConstraintActuator`
|
||||
* :class:`~bge.types.KX_GameActuator`
|
||||
* :class:`~bge.types.KX_IpoActuator`
|
||||
* :class:`~bge.types.KX_NetworkMessageActuator`
|
||||
* :class:`~bge.types.KX_ObjectActuator`
|
||||
* :class:`~bge.types.KX_ParentActuator`
|
||||
* :class:`~bge.types.KX_SCA_AddObjectActuator`
|
||||
* :class:`~bge.types.KX_SCA_DynamicActuator`
|
||||
* :class:`~bge.types.KX_SCA_EndObjectActuator`
|
||||
* :class:`~bge.types.KX_SCA_ReplaceMeshActuator`
|
||||
* :class:`~bge.types.KX_SceneActuator`
|
||||
* :class:`~bge.types.KX_SoundActuator`
|
||||
* :class:`~bge.types.KX_StateActuator`
|
||||
* :class:`~bge.types.KX_TrackToActuator`
|
||||
* :class:`~bge.types.KX_VisibilityActuator`
|
||||
* :class:`~bge.types.SCA_2DFilterActuator`
|
||||
* :class:`~bge.types.SCA_PropertyActuator`
|
||||
* :class:`~bge.types.SCA_RandomActuator`
|
||||
|
||||
Most logic brick's methods are accessors for the properties available in the logic buttons.
|
||||
Consult the logic bricks documentation for more information on how each logic brick works.
|
||||
|
||||
There are also methods to access the current :class:`bge.types.KX_Scene`
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Get the current scene
|
||||
scene = bge.logic.getCurrentScene()
|
||||
|
||||
# Get the current camera
|
||||
cam = scene.active_camera
|
||||
|
||||
Matricies as used by the game engine are **row major**
|
||||
``matrix[row][col] = float``
|
||||
|
||||
:class:`bge.types.KX_Camera` has some examples using matricies.
|
||||
|
||||
*********
|
||||
Variables
|
||||
*********
|
||||
|
||||
.. data:: globalDict
|
||||
|
||||
A dictionary that is saved between loading blend files so you can use it to store inventory and other variables you want to store between scenes and blend files.
|
||||
It can also be written to a file and loaded later on with the game load/save actuators.
|
||||
|
||||
.. note:: only python built in types such as int/string/bool/float/tuples/lists can be saved, GameObjects, Actuators etc will not work as expected.
|
||||
|
||||
.. data:: keyboard
|
||||
|
||||
The current keyboard wrapped in an :class:`~bge.types.SCA_PythonKeyboard` object.
|
||||
|
||||
.. data:: mouse
|
||||
|
||||
The current mouse wrapped in an :class:`~bge.types.SCA_PythonMouse` object.
|
||||
|
||||
*****************
|
||||
General functions
|
||||
*****************
|
||||
|
||||
.. function:: getCurrentController()
|
||||
|
||||
Gets the Python controller associated with this Python script.
|
||||
|
||||
:rtype: :class:`bge.types.SCA_PythonController`
|
||||
|
||||
.. function:: getCurrentScene()
|
||||
|
||||
Gets the current Scene.
|
||||
|
||||
:rtype: :class:`bge.types.KX_Scene`
|
||||
|
||||
.. function:: getSceneList()
|
||||
|
||||
Gets a list of the current scenes loaded in the game engine.
|
||||
|
||||
:rtype: list of :class:`bge.types.KX_Scene`
|
||||
|
||||
.. note:: Scenes in your blend file that have not been converted wont be in this list. This list will only contain scenes such as overlays scenes.
|
||||
|
||||
.. function:: loadGlobalDict()
|
||||
|
||||
Loads bge.logic.globalDict from a file.
|
||||
|
||||
.. function:: saveGlobalDict()
|
||||
|
||||
Saves bge.logic.globalDict to a file.
|
||||
|
||||
.. function:: startGame(blend)
|
||||
|
||||
Loads the blend file.
|
||||
|
||||
:arg blend: The name of the blend file
|
||||
:type blend: string
|
||||
|
||||
.. function:: endGame()
|
||||
|
||||
Ends the current game.
|
||||
|
||||
.. function:: restartGame()
|
||||
|
||||
Restarts the current game by reloading the .blend file (the last saved version, not what is currently running).
|
||||
|
||||
.. function:: LibLoad(blend, type, data)
|
||||
|
||||
Converts the all of the datablocks of the given type from the given blend.
|
||||
|
||||
:arg blend: The path to the blend file (or the name to use for the library if data is supplied)
|
||||
:type blend: string
|
||||
:arg type: The datablock type (currently only "Action", "Mesh" and "Scene" are supported)
|
||||
:type type: string
|
||||
:arg data: Binary data from a blend file (optional)
|
||||
:type data: bytes
|
||||
|
||||
.. function:: LibNew(name, type, data)
|
||||
|
||||
Uses existing datablock data and loads in as a new library.
|
||||
|
||||
:arg name: A unique library name used for removal later
|
||||
:type name: string
|
||||
:arg type: The datablock type (currently only "Mesh" is supported)
|
||||
:type type: string
|
||||
:arg data: A list of names of the datablocks to load
|
||||
:type data: list of strings
|
||||
|
||||
.. function:: LibFree(name)
|
||||
|
||||
Frees a library, removing all objects and meshes from the currently active scenes.
|
||||
|
||||
:arg name: The name of the library to free (the name used in LibNew)
|
||||
:type name: string
|
||||
|
||||
.. function:: addScene(name, overlay=1)
|
||||
|
||||
Loads a scene into the game engine.
|
||||
|
||||
:arg name: The name of the scene
|
||||
:type name: string
|
||||
:arg overlay: Overlay or underlay (optional)
|
||||
:type overlay: integer
|
||||
|
||||
.. function:: sendMessage(subject, body="", to="", message_from="")
|
||||
|
||||
Sends a message to sensors in any active scene.
|
||||
|
||||
:arg subject: The subject of the message
|
||||
:type subject: string
|
||||
:arg body: The body of the message (optional)
|
||||
:type body: string
|
||||
:arg to: The name of the object to send the message to (optional)
|
||||
:type to: string
|
||||
:arg message_from: The name of the object that the message is coming from (optional)
|
||||
:type message_from: string
|
||||
|
||||
.. function:: setGravity(gravity)
|
||||
|
||||
Sets the world gravity.
|
||||
|
||||
:type gravity: list [fx, fy, fz]
|
||||
|
||||
.. function:: getSpectrum()
|
||||
|
||||
Returns a 512 point list from the sound card.
|
||||
This only works if the fmod sound driver is being used.
|
||||
|
||||
:rtype: list [float], len(getSpectrum()) == 512
|
||||
|
||||
.. function:: stopDSP()
|
||||
|
||||
Stops the sound driver using DSP effects.
|
||||
|
||||
Only the fmod sound driver supports this.
|
||||
DSP can be computationally expensive.
|
||||
|
||||
.. function:: getMaxLogicFrame()
|
||||
|
||||
Gets the maximum number of logic frames per render frame.
|
||||
|
||||
:return: The maximum number of logic frames per render frame
|
||||
:rtype: integer
|
||||
|
||||
.. function:: setMaxLogicFrame(maxlogic)
|
||||
|
||||
Sets the maximum number of logic frames that are executed per render frame.
|
||||
This does not affect the physic system that still runs at full frame rate.
|
||||
|
||||
:arg maxlogic: The new maximum number of logic frames per render frame. Valid values: 1..5
|
||||
:type maxlogic: integer
|
||||
|
||||
.. function:: getMaxPhysicsFrame()
|
||||
|
||||
Gets the maximum number of physics frames per render frame.
|
||||
|
||||
:return: The maximum number of physics frames per render frame
|
||||
:rtype: integer
|
||||
|
||||
.. function:: setMaxPhysicsFrame(maxphysics)
|
||||
|
||||
Sets the maximum number of physics timestep that are executed per render frame.
|
||||
Higher value allows physics to keep up with realtime even if graphics slows down the game.
|
||||
Physics timestep is fixed and equal to 1/tickrate (see setLogicTicRate)
|
||||
maxphysics/ticrate is the maximum delay of the renderer that physics can compensate.
|
||||
|
||||
:arg maxphysics: The new maximum number of physics timestep per render frame. Valid values: 1..5.
|
||||
:type maxphysics: integer
|
||||
|
||||
.. function:: getLogicTicRate()
|
||||
|
||||
Gets the logic update frequency.
|
||||
|
||||
:return: The logic frequency in Hz
|
||||
:rtype: float
|
||||
|
||||
.. function:: setLogicTicRate(ticrate)
|
||||
|
||||
Sets the logic update frequency.
|
||||
|
||||
The logic update frequency is the number of times logic bricks are executed every second.
|
||||
The default is 60 Hz.
|
||||
|
||||
:arg ticrate: The new logic update frequency (in Hz).
|
||||
:type ticrate: float
|
||||
|
||||
.. function:: getPhysicsTicRate()
|
||||
|
||||
Gets the physics update frequency
|
||||
|
||||
:return: The physics update frequency in Hz
|
||||
:rtype: float
|
||||
|
||||
.. warning: Not implimented yet
|
||||
|
||||
.. function:: setPhysicsTicRate(ticrate)
|
||||
|
||||
Sets the physics update frequency
|
||||
|
||||
The physics update frequency is the number of times the physics system is executed every second.
|
||||
The default is 60 Hz.
|
||||
|
||||
:arg ticrate: The new update frequency (in Hz).
|
||||
:type ticrate: float
|
||||
|
||||
.. warning: Not implimented yet
|
||||
|
||||
*****************
|
||||
Utility functions
|
||||
*****************
|
||||
|
||||
.. function:: expandPath(path)
|
||||
|
||||
Converts a blender internal path into a proper file system path.
|
||||
|
||||
Use / as directory separator in path
|
||||
You can use '//' at the start of the string to define a relative path;
|
||||
Blender replaces that string by the directory of the startup .blend or runtime file
|
||||
to make a full path name (doesn't change during the game, even if you load other .blend).
|
||||
The function also converts the directory separator to the local file system format.
|
||||
|
||||
:arg path: The path string to be converted/expanded.
|
||||
:type path: string
|
||||
:return: The converted string
|
||||
:rtype: string
|
||||
|
||||
.. function:: getAverageFrameRate()
|
||||
|
||||
Gets the estimated average framerate
|
||||
|
||||
:return: The estimed average framerate in frames per second
|
||||
:rtype: float
|
||||
|
||||
.. function:: getBlendFileList(path = "//")
|
||||
|
||||
Returns a list of blend files in the same directory as the open blend file, or from using the option argument.
|
||||
|
||||
:arg path: Optional directory argument, will be expanded (like expandPath) into the full path.
|
||||
:type path: string
|
||||
:return: A list of filenames, with no directory prefix
|
||||
:rtype: list
|
||||
|
||||
.. function:: getRandomFloat()
|
||||
|
||||
Returns a random floating point value in the range [0 - 1)
|
||||
|
||||
.. function:: PrintGLInfo()
|
||||
|
||||
Prints GL Extension Info into the console
|
||||
|
||||
*********
|
||||
Constants
|
||||
*********
|
||||
|
||||
.. data:: KX_TRUE
|
||||
|
||||
True value used by some modules.
|
||||
|
||||
.. data:: KX_FALSE
|
||||
|
||||
False value used by some modules.
|
||||
|
||||
=======
|
||||
Sensors
|
||||
=======
|
||||
|
||||
.. _sensor-status:
|
||||
|
||||
-------------
|
||||
Sensor Status
|
||||
-------------
|
||||
|
||||
.. data:: KX_SENSOR_INACTIVE
|
||||
.. data:: KX_SENSOR_JUST_ACTIVATED
|
||||
.. data:: KX_SENSOR_ACTIVE
|
||||
.. data:: KX_SENSOR_JUST_DEACTIVATED
|
||||
|
||||
.. _logic-property-sensor:
|
||||
|
||||
---------------
|
||||
Property Sensor
|
||||
---------------
|
||||
|
||||
.. data:: KX_PROPSENSOR_EQUAL
|
||||
|
||||
Activate when the property is equal to the sensor value.
|
||||
|
||||
:value: 1
|
||||
|
||||
.. data:: KX_PROPSENSOR_NOTEQUAL
|
||||
|
||||
Activate when the property is not equal to the sensor value.
|
||||
|
||||
:value: 2
|
||||
|
||||
.. data:: KX_PROPSENSOR_INTERVAL
|
||||
|
||||
Activate when the property is between the specified limits.
|
||||
|
||||
:value: 3
|
||||
|
||||
.. data:: KX_PROPSENSOR_CHANGED
|
||||
|
||||
Activate when the property changes
|
||||
|
||||
:value: 4
|
||||
|
||||
.. data:: KX_PROPSENSOR_EXPRESSION
|
||||
|
||||
Activate when the expression matches
|
||||
|
||||
:value: 5
|
||||
|
||||
------------
|
||||
Radar Sensor
|
||||
------------
|
||||
|
||||
See :class:`bge.types.KX_RadarSensor`
|
||||
|
||||
.. data:: KX_RADAR_AXIS_POS_X
|
||||
.. data:: KX_RADAR_AXIS_POS_Y
|
||||
.. data:: KX_RADAR_AXIS_POS_Z
|
||||
.. data:: KX_RADAR_AXIS_NEG_X
|
||||
.. data:: KX_RADAR_AXIS_NEG_Y
|
||||
.. data:: KX_RADAR_AXIS_NEG_Z
|
||||
|
||||
----------
|
||||
Ray Sensor
|
||||
----------
|
||||
|
||||
See :class:`bge.types.KX_RaySensor`
|
||||
|
||||
.. data:: KX_RAY_AXIS_POS_X
|
||||
.. data:: KX_RAY_AXIS_POS_Y
|
||||
.. data:: KX_RAY_AXIS_POS_Z
|
||||
.. data:: KX_RAY_AXIS_NEG_X
|
||||
.. data:: KX_RAY_AXIS_NEG_Y
|
||||
.. data:: KX_RAY_AXIS_NEG_Z
|
||||
|
||||
|
||||
=========
|
||||
Actuators
|
||||
=========
|
||||
|
||||
.. _action-actuator:
|
||||
|
||||
---------------
|
||||
Action Actuator
|
||||
---------------
|
||||
|
||||
See :class:`bge.types.BL_ActionActuator`
|
||||
|
||||
.. data:: KX_ACTIONACT_PLAY
|
||||
.. data:: KX_ACTIONACT_FLIPPER
|
||||
.. data:: KX_ACTIONACT_LOOPSTOP
|
||||
.. data:: KX_ACTIONACT_LOOPEND
|
||||
.. data:: KX_ACTIONACT_PROPERTY
|
||||
|
||||
-------------------
|
||||
Constraint Actuator
|
||||
-------------------
|
||||
|
||||
.. _constraint-actuator-option:
|
||||
|
||||
See :class:`bge.types.KX_ConstraintActuator.option`
|
||||
|
||||
* Applicable to Distance constraint:
|
||||
|
||||
.. data:: KX_ACT_CONSTRAINT_NORMAL
|
||||
|
||||
Activate alignment to surface
|
||||
|
||||
.. data:: KX_ACT_CONSTRAINT_DISTANCE
|
||||
|
||||
Activate distance control
|
||||
|
||||
.. data:: KX_ACT_CONSTRAINT_LOCAL
|
||||
|
||||
Direction of the ray is along the local axis
|
||||
|
||||
* Applicable to Force field constraint:
|
||||
|
||||
.. data:: KX_ACT_CONSTRAINT_DOROTFH
|
||||
|
||||
Force field act on rotation as well
|
||||
|
||||
* Applicable to both:
|
||||
|
||||
.. data:: KX_ACT_CONSTRAINT_MATERIAL
|
||||
|
||||
Detect material rather than property
|
||||
|
||||
.. data:: KX_ACT_CONSTRAINT_PERMANENT
|
||||
|
||||
No deactivation if ray does not hit target
|
||||
|
||||
.. _constraint-actuator-limit:
|
||||
|
||||
See :class:`bge.types.KX_ConstraintActuator.limit`
|
||||
|
||||
.. data:: KX_CONSTRAINTACT_LOCX
|
||||
|
||||
Limit X coord.
|
||||
|
||||
.. data:: KX_CONSTRAINTACT_LOCY
|
||||
|
||||
Limit Y coord
|
||||
|
||||
.. data:: KX_CONSTRAINTACT_LOCZ
|
||||
|
||||
Limit Z coord
|
||||
|
||||
.. data:: KX_CONSTRAINTACT_ROTX
|
||||
|
||||
Limit X rotation
|
||||
|
||||
.. data:: KX_CONSTRAINTACT_ROTY
|
||||
|
||||
Limit Y rotation
|
||||
|
||||
.. data:: KX_CONSTRAINTACT_ROTZ
|
||||
|
||||
Limit Z rotation
|
||||
|
||||
.. data:: KX_CONSTRAINTACT_DIRNX
|
||||
|
||||
Set distance along negative X axis
|
||||
|
||||
.. data:: KX_CONSTRAINTACT_DIRNY
|
||||
|
||||
Set distance along negative Y axis
|
||||
|
||||
.. data:: KX_CONSTRAINTACT_DIRNZ
|
||||
|
||||
Set distance along negative Z axis
|
||||
|
||||
.. data:: KX_CONSTRAINTACT_DIRPX
|
||||
|
||||
Set distance along positive X axis
|
||||
|
||||
.. data:: KX_CONSTRAINTACT_DIRPY
|
||||
|
||||
Set distance along positive Y axis
|
||||
|
||||
.. data:: KX_CONSTRAINTACT_DIRPZ
|
||||
|
||||
Set distance along positive Z axis
|
||||
|
||||
.. data:: KX_CONSTRAINTACT_ORIX
|
||||
|
||||
Set orientation of X axis
|
||||
|
||||
.. data:: KX_CONSTRAINTACT_ORIY
|
||||
|
||||
Set orientation of Y axis
|
||||
|
||||
.. data:: KX_CONSTRAINTACT_ORIZ
|
||||
|
||||
Set orientation of Z axis
|
||||
|
||||
.. data:: KX_ACT_CONSTRAINT_FHNX
|
||||
|
||||
Set force field along negative X axis
|
||||
|
||||
.. data:: KX_ACT_CONSTRAINT_FHNY
|
||||
|
||||
Set force field along negative Y axis
|
||||
|
||||
.. data:: KX_ACT_CONSTRAINT_FHNZ
|
||||
|
||||
Set force field along negative Z axis
|
||||
|
||||
.. data:: KX_ACT_CONSTRAINT_FHPX
|
||||
|
||||
Set force field along positive X axis
|
||||
|
||||
.. data:: KX_ACT_CONSTRAINT_FHPY
|
||||
|
||||
Set force field along positive Y axis
|
||||
|
||||
.. data:: KX_ACT_CONSTRAINT_FHPZ
|
||||
|
||||
Set force field along positive Z axis
|
||||
|
||||
----------------
|
||||
Dynamic Actuator
|
||||
----------------
|
||||
|
||||
See :class:`bge.types.KX_SCA_DynamicActuator`
|
||||
|
||||
.. data:: KX_DYN_RESTORE_DYNAMICS
|
||||
.. data:: KX_DYN_DISABLE_DYNAMICS
|
||||
.. data:: KX_DYN_ENABLE_RIGID_BODY
|
||||
.. data:: KX_DYN_DISABLE_RIGID_BODY
|
||||
.. data:: KX_DYN_SET_MASS
|
||||
|
||||
.. _game-actuator:
|
||||
|
||||
-------------
|
||||
Game Actuator
|
||||
-------------
|
||||
|
||||
See :class:`bge.types.KX_GameActuator`
|
||||
|
||||
.. data:: KX_GAME_LOAD
|
||||
.. data:: KX_GAME_START
|
||||
.. data:: KX_GAME_RESTART
|
||||
.. data:: KX_GAME_QUIT
|
||||
.. data:: KX_GAME_SAVECFG
|
||||
.. data:: KX_GAME_LOADCFG
|
||||
|
||||
.. _ipo-actuator:
|
||||
|
||||
------------
|
||||
IPO Actuator
|
||||
------------
|
||||
|
||||
See :class:`bge.types.KX_IpoActuator`
|
||||
|
||||
.. data:: KX_IPOACT_PLAY
|
||||
.. data:: KX_IPOACT_PINGPONG
|
||||
.. data:: KX_IPOACT_FLIPPER
|
||||
.. data:: KX_IPOACT_LOOPSTOP
|
||||
.. data:: KX_IPOACT_LOOPEND
|
||||
.. data:: KX_IPOACT_FROM_PROP
|
||||
|
||||
---------------
|
||||
Parent Actuator
|
||||
---------------
|
||||
|
||||
.. data:: KX_PARENT_REMOVE
|
||||
.. data:: KX_PARENT_SET
|
||||
|
||||
.. _logic-random-distributions:
|
||||
|
||||
--------------------
|
||||
Random Distributions
|
||||
--------------------
|
||||
|
||||
See :class:`bge.types.SCA_RandomActuator`
|
||||
|
||||
.. data:: KX_RANDOMACT_BOOL_CONST
|
||||
.. data:: KX_RANDOMACT_BOOL_UNIFORM
|
||||
.. data:: KX_RANDOMACT_BOOL_BERNOUILLI
|
||||
.. data:: KX_RANDOMACT_INT_CONST
|
||||
.. data:: KX_RANDOMACT_INT_UNIFORM
|
||||
.. data:: KX_RANDOMACT_INT_POISSON
|
||||
.. data:: KX_RANDOMACT_FLOAT_CONST
|
||||
.. data:: KX_RANDOMACT_FLOAT_UNIFORM
|
||||
.. data:: KX_RANDOMACT_FLOAT_NORMAL
|
||||
.. data:: KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL
|
||||
|
||||
--------------
|
||||
Scene Actuator
|
||||
--------------
|
||||
|
||||
See :class:`bge.types.KX_SceneActuator`
|
||||
|
||||
.. data:: KX_SCENE_RESTART
|
||||
.. data:: KX_SCENE_SET_SCENE
|
||||
.. data:: KX_SCENE_SET_CAMERA
|
||||
.. data:: KX_SCENE_ADD_FRONT_SCENE
|
||||
.. data:: KX_SCENE_ADD_BACK_SCENE
|
||||
.. data:: KX_SCENE_REMOVE_SCENE
|
||||
.. data:: KX_SCENE_SUSPEND
|
||||
.. data:: KX_SCENE_RESUME
|
||||
|
||||
.. _shape-action-actuator:
|
||||
|
||||
---------------------
|
||||
Shape Action Actuator
|
||||
---------------------
|
||||
|
||||
See :class:`bge.types.BL_ActionActuator`
|
||||
|
||||
.. data:: KX_ACTIONACT_PLAY
|
||||
.. data:: KX_ACTIONACT_FLIPPER
|
||||
.. data:: KX_ACTIONACT_LOOPSTOP
|
||||
.. data:: KX_ACTIONACT_LOOPEND
|
||||
.. data:: KX_ACTIONACT_PROPERTY
|
||||
|
||||
.. _logic-sound-actuator:
|
||||
|
||||
--------------
|
||||
Sound Actuator
|
||||
--------------
|
||||
|
||||
See :class:`bge.types.KX_SoundActuator`
|
||||
|
||||
.. data:: KX_SOUNDACT_PLAYSTOP
|
||||
|
||||
:value: 1
|
||||
|
||||
.. data:: KX_SOUNDACT_PLAYEND
|
||||
|
||||
:value: 2
|
||||
|
||||
.. data:: KX_SOUNDACT_LOOPSTOP
|
||||
|
||||
:value: 3
|
||||
|
||||
.. data:: KX_SOUNDACT_LOOPEND
|
||||
|
||||
:value: 4
|
||||
|
||||
.. data:: KX_SOUNDACT_LOOPBIDIRECTIONAL
|
||||
|
||||
:value: 5
|
||||
|
||||
.. data:: KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP
|
||||
|
||||
:value: 6
|
||||
|
||||
|
||||
=======
|
||||
Various
|
||||
=======
|
||||
|
||||
.. _input-status:
|
||||
|
||||
------------
|
||||
Input Status
|
||||
------------
|
||||
|
||||
See :class:`bge.types.SCA_PythonKeyboard`, :class:`bge.types.SCA_PythonMouse`, :class:`bge.types.SCA_MouseSensor`, :class:`bge.types.SCA_KeyboardSensor`
|
||||
|
||||
.. data:: KX_INPUT_NONE
|
||||
.. data:: KX_INPUT_JUST_ACTIVATED
|
||||
.. data:: KX_INPUT_ACTIVE
|
||||
.. data:: KX_INPUT_JUST_RELEASED
|
||||
|
||||
-------------
|
||||
Mouse Buttons
|
||||
-------------
|
||||
|
||||
See :class:`bge.types.SCA_MouseSensor`
|
||||
|
||||
.. data:: KX_MOUSE_BUT_LEFT
|
||||
.. data:: KX_MOUSE_BUT_MIDDLE
|
||||
.. data:: KX_MOUSE_BUT_RIGHT
|
||||
|
||||
------
|
||||
States
|
||||
------
|
||||
|
||||
See :class:`bge.types.KX_StateActuator`
|
||||
|
||||
.. data:: KX_STATE1
|
||||
.. data:: KX_STATE2
|
||||
.. data:: KX_STATE3
|
||||
.. data:: KX_STATE4
|
||||
.. data:: KX_STATE5
|
||||
.. data:: KX_STATE6
|
||||
.. data:: KX_STATE7
|
||||
.. data:: KX_STATE8
|
||||
.. data:: KX_STATE9
|
||||
.. data:: KX_STATE10
|
||||
.. data:: KX_STATE11
|
||||
.. data:: KX_STATE12
|
||||
.. data:: KX_STATE13
|
||||
.. data:: KX_STATE14
|
||||
.. data:: KX_STATE15
|
||||
.. data:: KX_STATE16
|
||||
.. data:: KX_STATE17
|
||||
.. data:: KX_STATE18
|
||||
.. data:: KX_STATE19
|
||||
.. data:: KX_STATE20
|
||||
.. data:: KX_STATE21
|
||||
.. data:: KX_STATE22
|
||||
.. data:: KX_STATE23
|
||||
.. data:: KX_STATE24
|
||||
.. data:: KX_STATE25
|
||||
.. data:: KX_STATE26
|
||||
.. data:: KX_STATE27
|
||||
.. data:: KX_STATE28
|
||||
.. data:: KX_STATE29
|
||||
.. data:: KX_STATE30
|
||||
|
||||
.. _state-actuator-operation:
|
||||
|
||||
See :class:`bge.types.KX_StateActuator.operation`
|
||||
|
||||
.. data:: KX_STATE_OP_CLR
|
||||
|
||||
Substract bits to state mask
|
||||
|
||||
:value: 0
|
||||
|
||||
.. data:: KX_STATE_OP_CPY
|
||||
|
||||
Copy state mask
|
||||
|
||||
:value: 1
|
||||
|
||||
.. data:: KX_STATE_OP_NEG
|
||||
|
||||
Invert bits to state mask
|
||||
|
||||
:value: 2
|
||||
|
||||
.. data:: KX_STATE_OP_SET
|
||||
|
||||
Add bits to state mask
|
||||
|
||||
:value: 3
|
||||
|
||||
.. _Two-D-FilterActuator-mode:
|
||||
|
||||
---------
|
||||
2D Filter
|
||||
---------
|
||||
|
||||
.. data:: RAS_2DFILTER_BLUR
|
||||
|
||||
:value: 2
|
||||
|
||||
.. data:: RAS_2DFILTER_CUSTOMFILTER
|
||||
|
||||
Customer filter, the code code is set via shaderText property.
|
||||
|
||||
:value: 12
|
||||
|
||||
.. data:: RAS_2DFILTER_DILATION
|
||||
|
||||
:value: 4
|
||||
|
||||
.. data:: RAS_2DFILTER_DISABLED
|
||||
|
||||
Disable the filter that is currently active
|
||||
|
||||
:value: -1
|
||||
|
||||
.. data:: RAS_2DFILTER_ENABLED
|
||||
|
||||
Enable the filter that was previously disabled
|
||||
|
||||
:value: -2
|
||||
|
||||
.. data:: RAS_2DFILTER_EROSION
|
||||
|
||||
:value: 5
|
||||
|
||||
.. data:: RAS_2DFILTER_GRAYSCALE
|
||||
|
||||
:value: 9
|
||||
|
||||
.. data:: RAS_2DFILTER_INVERT
|
||||
|
||||
:value: 11
|
||||
|
||||
.. data:: RAS_2DFILTER_LAPLACIAN
|
||||
|
||||
:value: 6
|
||||
|
||||
.. data:: RAS_2DFILTER_MOTIONBLUR
|
||||
|
||||
Create and enable preset filters
|
||||
|
||||
:value: 1
|
||||
|
||||
.. data:: RAS_2DFILTER_NOFILTER
|
||||
|
||||
Disable and destroy the filter that is currently active
|
||||
|
||||
:value: 0
|
||||
|
||||
.. data:: RAS_2DFILTER_PREWITT
|
||||
|
||||
:value: 8
|
||||
|
||||
.. data:: RAS_2DFILTER_SEPIA
|
||||
|
||||
:value: 10
|
||||
|
||||
.. data:: RAS_2DFILTER_SHARPEN
|
||||
|
||||
:value: 3
|
||||
|
||||
.. data:: RAS_2DFILTER_SOBEL
|
||||
|
||||
:value: 7
|
||||
|
||||
------
|
||||
Shader
|
||||
------
|
||||
|
||||
.. data:: VIEWMATRIX
|
||||
.. data:: VIEWMATRIX_INVERSE
|
||||
.. data:: VIEWMATRIX_INVERSETRANSPOSE
|
||||
.. data:: VIEWMATRIX_TRANSPOSE
|
||||
.. data:: MODELMATRIX
|
||||
.. data:: MODELMATRIX_INVERSE
|
||||
.. data:: MODELMATRIX_INVERSETRANSPOSE
|
||||
.. data:: MODELMATRIX_TRANSPOSE
|
||||
.. data:: MODELVIEWMATRIX
|
||||
.. data:: MODELVIEWMATRIX_INVERSE
|
||||
.. data:: MODELVIEWMATRIX_INVERSETRANSPOSE
|
||||
.. data:: MODELVIEWMATRIX_TRANSPOSE
|
||||
.. data:: CAM_POS
|
||||
|
||||
Current camera position
|
||||
|
||||
.. data:: CONSTANT_TIMER
|
||||
|
||||
User a timer for the uniform value.
|
||||
|
||||
.. data:: SHD_TANGENT
|
||||
|
||||
----------------
|
||||
Blender Material
|
||||
----------------
|
||||
|
||||
.. data:: BL_DST_ALPHA
|
||||
.. data:: BL_DST_COLOR
|
||||
.. data:: BL_ONE
|
||||
.. data:: BL_ONE_MINUS_DST_ALPHA
|
||||
.. data:: BL_ONE_MINUS_DST_COLOR
|
||||
.. data:: BL_ONE_MINUS_SRC_ALPHA
|
||||
.. data:: BL_ONE_MINUS_SRC_COLOR
|
||||
.. data:: BL_SRC_ALPHA
|
||||
.. data:: BL_SRC_ALPHA_SATURATE
|
||||
.. data:: BL_SRC_COLOR
|
||||
.. data:: BL_ZERO
|
242
doc/python_api/rst/bge.render.rst
Normal file
242
doc/python_api/rst/bge.render.rst
Normal file
@@ -0,0 +1,242 @@
|
||||
|
||||
Game Engine bge.render Module
|
||||
=============================
|
||||
|
||||
*****
|
||||
Intro
|
||||
*****
|
||||
|
||||
.. module:: bge.render
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Example Uses an L{SCA_MouseSensor}, and two L{KX_ObjectActuator}s to implement MouseLook::
|
||||
# To use a mouse movement sensor "Mouse" and a
|
||||
# motion actuator to mouse look:
|
||||
import bge.render
|
||||
import bge.logic
|
||||
|
||||
# SCALE sets the speed of motion
|
||||
SCALE=[1, 0.5]
|
||||
|
||||
co = bge.logic.getCurrentController()
|
||||
obj = co.getOwner()
|
||||
mouse = co.getSensor("Mouse")
|
||||
lmotion = co.getActuator("LMove")
|
||||
wmotion = co.getActuator("WMove")
|
||||
|
||||
# Transform the mouse coordinates to see how far the mouse has moved.
|
||||
def mousePos():
|
||||
x = (bge.render.getWindowWidth()/2 - mouse.getXPosition())*SCALE[0]
|
||||
y = (bge.render.getWindowHeight()/2 - mouse.getYPosition())*SCALE[1]
|
||||
return (x, y)
|
||||
|
||||
pos = mousePos()
|
||||
|
||||
# Set the amount of motion: X is applied in world coordinates...
|
||||
lmotion.setTorque(0.0, 0.0, pos[0], False)
|
||||
# ...Y is applied in local coordinates
|
||||
wmotion.setTorque(-pos[1], 0.0, 0.0, True)
|
||||
|
||||
# Activate both actuators
|
||||
bge.logic.addActiveActuator(lmotion, True)
|
||||
bge.logic.addActiveActuator(wmotion, True)
|
||||
|
||||
# Centre the mouse
|
||||
bge.render.setMousePosition(bge.render.getWindowWidth()/2, bge.render.getWindowHeight()/2)
|
||||
|
||||
*********
|
||||
Constants
|
||||
*********
|
||||
|
||||
.. data:: KX_TEXFACE_MATERIAL
|
||||
|
||||
Materials as defined by the texture face settings.
|
||||
|
||||
.. data:: KX_BLENDER_MULTITEX_MATERIAL
|
||||
|
||||
Materials approximating blender materials with multitexturing.
|
||||
|
||||
.. data:: KX_BLENDER_GLSL_MATERIAL
|
||||
|
||||
Materials approximating blender materials with GLSL.
|
||||
|
||||
*********
|
||||
Functions
|
||||
*********
|
||||
|
||||
.. function:: getWindowWidth()
|
||||
|
||||
Gets the width of the window (in pixels)
|
||||
|
||||
:rtype: integer
|
||||
|
||||
.. function:: getWindowHeight()
|
||||
|
||||
Gets the height of the window (in pixels)
|
||||
|
||||
:rtype: integer
|
||||
|
||||
.. function:: makeScreenshot(filename)
|
||||
|
||||
Writes a screenshot to the given filename.
|
||||
|
||||
If filename starts with // the image will be saved relative to the current directory.
|
||||
If the filename contains # it will be replaced with the frame number.
|
||||
|
||||
The standalone player saves .png files. It does not support colour space conversion
|
||||
or gamma correction.
|
||||
|
||||
When run from Blender, makeScreenshot supports Iris, IrisZ, TGA, Raw TGA, PNG, HamX, and Jpeg.
|
||||
Gamma, Colourspace conversion and Jpeg compression are taken from the Render settings panels.
|
||||
|
||||
:type filename: string
|
||||
|
||||
|
||||
.. function:: enableVisibility(visible)
|
||||
|
||||
Doesn't really do anything...
|
||||
|
||||
|
||||
.. function:: showMouse(visible)
|
||||
|
||||
Enables or disables the operating system mouse cursor.
|
||||
|
||||
:type visible: boolean
|
||||
|
||||
|
||||
.. function:: setMousePosition(x, y)
|
||||
|
||||
Sets the mouse cursor position.
|
||||
|
||||
:type x: integer
|
||||
:type y: integer
|
||||
|
||||
|
||||
.. function:: setBackgroundColor(rgba)
|
||||
|
||||
Sets the window background colour.
|
||||
|
||||
:type rgba: list [r, g, b, a]
|
||||
|
||||
|
||||
.. function:: setMistColor(rgb)
|
||||
|
||||
Sets the mist colour.
|
||||
|
||||
:type rgb: list [r, g, b]
|
||||
|
||||
|
||||
.. function:: setAmbientColor(rgb)
|
||||
|
||||
Sets the color of ambient light.
|
||||
|
||||
:type rgb: list [r, g, b]
|
||||
|
||||
|
||||
.. function:: setMistStart(start)
|
||||
|
||||
Sets the mist start value. Objects further away than start will have mist applied to them.
|
||||
|
||||
:type start: float
|
||||
|
||||
|
||||
.. function:: setMistEnd(end)
|
||||
|
||||
Sets the mist end value. Objects further away from this will be coloured solid with
|
||||
the colour set by setMistColor().
|
||||
|
||||
:type end: float
|
||||
|
||||
|
||||
.. function:: disableMist()
|
||||
|
||||
Disables mist.
|
||||
|
||||
.. note:: Set any of the mist properties to enable mist.
|
||||
|
||||
|
||||
.. function:: setEyeSeparation(eyesep)
|
||||
|
||||
Sets the eye separation for stereo mode. Usually Focal Length/30 provides a confortable value.
|
||||
|
||||
:arg eyesep: The distance between the left and right eye.
|
||||
:type eyesep: float
|
||||
|
||||
|
||||
.. function:: getEyeSeparation()
|
||||
|
||||
Gets the current eye separation for stereo mode.
|
||||
|
||||
:rtype: float
|
||||
|
||||
|
||||
.. function:: setFocalLength(focallength)
|
||||
|
||||
Sets the focal length for stereo mode. It uses the current camera focal length as initial value.
|
||||
|
||||
:arg focallength: The focal length.
|
||||
:type focallength: float
|
||||
|
||||
.. function:: getFocalLength()
|
||||
|
||||
Gets the current focal length for stereo mode.
|
||||
|
||||
:rtype: float
|
||||
|
||||
.. function:: setMaterialMode(mode)
|
||||
|
||||
Set the material mode to use for OpenGL rendering.
|
||||
|
||||
:type mode: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL
|
||||
|
||||
.. note:: Changes will only affect newly created scenes.
|
||||
|
||||
|
||||
.. function:: getMaterialMode(mode)
|
||||
|
||||
Get the material mode to use for OpenGL rendering.
|
||||
|
||||
:rtype: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL
|
||||
|
||||
|
||||
.. function:: setGLSLMaterialSetting(setting, enable)
|
||||
|
||||
Enables or disables a GLSL material setting.
|
||||
|
||||
:type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
|
||||
:type enable: boolean
|
||||
|
||||
|
||||
.. function:: getGLSLMaterialSetting(setting, enable)
|
||||
|
||||
Get the state of a GLSL material setting.
|
||||
|
||||
:type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
|
||||
:rtype: boolean
|
||||
|
||||
|
||||
.. function:: drawLine(fromVec,toVec,color)
|
||||
|
||||
Draw a line in the 3D scene.
|
||||
|
||||
:arg fromVec: the origin of the line
|
||||
:type fromVec: list [x, y, z]
|
||||
:arg toVec: the end of the line
|
||||
:type toVec: list [x, y, z]
|
||||
:arg color: the color of the line
|
||||
:type color: list [r, g, b]
|
||||
|
||||
|
||||
.. function:: enableMotionBlur(factor)
|
||||
|
||||
Enable the motion blur effect.
|
||||
|
||||
:arg factor: the ammount of motion blur to display.
|
||||
:type factor: float [0.0 - 1.0]
|
||||
|
||||
|
||||
.. function:: disableMotionBlur()
|
||||
|
||||
Disable the motion blur effect.
|
||||
|
5227
doc/python_api/rst/bge.types.rst
Normal file
5227
doc/python_api/rst/bge.types.rst
Normal file
File diff suppressed because it is too large
Load Diff
872
doc/python_api/sphinx_doc_gen.py
Normal file
872
doc/python_api/sphinx_doc_gen.py
Normal file
@@ -0,0 +1,872 @@
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# Contributor(s): Campbell Barton
|
||||
#
|
||||
# #**** END GPL LICENSE BLOCK #****
|
||||
|
||||
script_help_msg = '''
|
||||
Usage:
|
||||
|
||||
For HTML generation
|
||||
-------------------
|
||||
- Run this script from blenders root path once you have compiled blender
|
||||
|
||||
./blender.bin -b -P doc/python_api/sphinx_doc_gen.py
|
||||
|
||||
This will generate python files in doc/python_api/sphinx-in/,
|
||||
assuming that ./blender.bin is or links to the blender executable
|
||||
|
||||
- Generate html docs by running...
|
||||
|
||||
sphinx-build doc/python_api/sphinx-in doc/python_api/sphinx-out
|
||||
|
||||
assuming that you have sphinx 0.6.7 installed
|
||||
|
||||
For PDF generation
|
||||
------------------
|
||||
- After you have built doc/python_api/sphinx-in (see above), run:
|
||||
|
||||
sphinx-build -b latex doc/python_api/sphinx-in doc/python_api/sphinx-out
|
||||
cd doc/python_api/sphinx-out
|
||||
make
|
||||
'''
|
||||
|
||||
# import rpdb2; rpdb2.start_embedded_debugger('test')
|
||||
|
||||
import os
|
||||
import inspect
|
||||
import bpy
|
||||
import rna_info
|
||||
reload(rna_info)
|
||||
|
||||
# lame, python wont give some access
|
||||
ClassMethodDescriptorType = type(dict.__dict__['fromkeys'])
|
||||
MethodDescriptorType = type(dict.get)
|
||||
GetSetDescriptorType = type(int.real)
|
||||
|
||||
EXAMPLE_SET = set()
|
||||
EXAMPLE_SET_USED = set()
|
||||
|
||||
_BPY_STRUCT_FAKE = "bpy_struct"
|
||||
_BPY_FULL_REBUILD = False
|
||||
|
||||
def undocumented_message(module_name, type_name, identifier):
|
||||
message = "Undocumented (`contribute " \
|
||||
"<http://wiki.blender.org/index.php/Dev:2.5/Py/API/Documentation/Contribute" \
|
||||
"?action=edit§ion=new&preload=Dev:2.5/Py/API/Documentation/Contribute/Howto-message" \
|
||||
"&preloadtitle=%s.%s.%s>`_)\n\n" % (module_name, type_name, identifier)
|
||||
return message
|
||||
|
||||
|
||||
def range_str(val):
|
||||
'''
|
||||
Converts values to strings for the range directive.
|
||||
(unused function it seems)
|
||||
'''
|
||||
if val < -10000000: return '-inf'
|
||||
if val > 10000000: return 'inf'
|
||||
if type(val)==float:
|
||||
return '%g' % val
|
||||
else:
|
||||
return str(val)
|
||||
|
||||
|
||||
def write_example_ref(ident, fw, example_id, ext="py"):
|
||||
if example_id in EXAMPLE_SET:
|
||||
fw("%s.. literalinclude:: ../examples/%s.%s\n\n" % (ident, example_id, ext))
|
||||
EXAMPLE_SET_USED.add(example_id)
|
||||
else:
|
||||
if bpy.app.debug:
|
||||
print("\tskipping example:", example_id)
|
||||
|
||||
|
||||
def write_indented_lines(ident, fn, text, strip=True):
|
||||
'''
|
||||
Apply same indentation to all lines in a multilines text.
|
||||
'''
|
||||
if text is None:
|
||||
return
|
||||
for l in text.split("\n"):
|
||||
if strip:
|
||||
fn(ident + l.strip() + "\n")
|
||||
else:
|
||||
fn(ident + l + "\n")
|
||||
|
||||
|
||||
def pymethod2sphinx(ident, fw, identifier, py_func):
|
||||
'''
|
||||
class method to sphinx
|
||||
'''
|
||||
arg_str = inspect.formatargspec(*inspect.getargspec(py_func))
|
||||
if arg_str.startswith("(self, "):
|
||||
arg_str = "(" + arg_str[7:]
|
||||
func_type = "method"
|
||||
elif arg_str.startswith("(cls, "):
|
||||
arg_str = "(" + arg_str[6:]
|
||||
func_type = "classmethod"
|
||||
else:
|
||||
func_type = "staticmethod"
|
||||
|
||||
fw(ident + ".. %s:: %s%s\n\n" % (func_type, identifier, arg_str))
|
||||
if py_func.__doc__:
|
||||
write_indented_lines(ident + " ", fw, py_func.__doc__)
|
||||
fw("\n")
|
||||
|
||||
|
||||
def pyfunc2sphinx(ident, fw, identifier, py_func, is_class=True):
|
||||
'''
|
||||
function or class method to sphinx
|
||||
'''
|
||||
arg_str = inspect.formatargspec(*inspect.getargspec(py_func))
|
||||
|
||||
if not is_class:
|
||||
func_type = "function"
|
||||
|
||||
# ther rest are class methods
|
||||
elif arg_str.startswith("(self, "):
|
||||
arg_str = "(" + arg_str[7:]
|
||||
func_type = "method"
|
||||
elif arg_str.startswith("(cls, "):
|
||||
arg_str = "(" + arg_str[6:]
|
||||
func_type = "classmethod"
|
||||
else:
|
||||
func_type = "staticmethod"
|
||||
|
||||
fw(ident + ".. %s:: %s%s\n\n" % (func_type, identifier, arg_str))
|
||||
if py_func.__doc__:
|
||||
write_indented_lines(ident + " ", fw, py_func.__doc__.strip())
|
||||
fw("\n")
|
||||
|
||||
|
||||
def py_descr2sphinx(ident, fw, descr, module_name, type_name, identifier):
|
||||
if identifier.startswith("_"):
|
||||
return
|
||||
|
||||
doc = descr.__doc__
|
||||
if not doc:
|
||||
doc = undocumented_message(module_name, type_name, identifier)
|
||||
|
||||
if type(descr) == GetSetDescriptorType:
|
||||
fw(ident + ".. attribute:: %s\n\n" % identifier)
|
||||
write_indented_lines(ident + " ", fw, doc, False)
|
||||
elif type(descr) in (MethodDescriptorType, ClassMethodDescriptorType):
|
||||
write_indented_lines(ident, fw, doc, False)
|
||||
else:
|
||||
raise TypeError("type was not GetSetDescriptorType, MethodDescriptorType or ClassMethodDescriptorType")
|
||||
|
||||
write_example_ref(ident, fw, module_name + "." + type_name + "." + identifier)
|
||||
fw("\n")
|
||||
|
||||
|
||||
def py_c_func2sphinx(ident, fw, module_name, type_name, identifier, py_func, is_class=True):
|
||||
'''
|
||||
c defined function to sphinx.
|
||||
'''
|
||||
|
||||
# dump the docstring, assume its formatted correctly
|
||||
if py_func.__doc__:
|
||||
write_indented_lines(ident, fw, py_func.__doc__, False)
|
||||
fw("\n")
|
||||
else:
|
||||
fw(ident + ".. function:: %s()\n\n" % identifier)
|
||||
fw(ident + " " + undocumented_message(module_name, type_name, identifier))
|
||||
|
||||
|
||||
def pyprop2sphinx(ident, fw, identifier, py_prop):
|
||||
'''
|
||||
python property to sphinx
|
||||
'''
|
||||
# readonly properties use "data" directive, variables use "attribute" directive
|
||||
if py_prop.fset is None:
|
||||
fw(ident + ".. data:: %s\n\n" % identifier)
|
||||
else:
|
||||
fw(ident + ".. attribute:: %s\n\n" % identifier)
|
||||
write_indented_lines(ident + " ", fw, py_prop.__doc__)
|
||||
if py_prop.fset is None:
|
||||
fw(ident + " (readonly)\n\n")
|
||||
|
||||
|
||||
def pymodule2sphinx(BASEPATH, module_name, module, title):
|
||||
import types
|
||||
attribute_set = set()
|
||||
filepath = os.path.join(BASEPATH, module_name + ".rst")
|
||||
|
||||
file = open(filepath, "w")
|
||||
|
||||
fw = file.write
|
||||
|
||||
fw(title + "\n")
|
||||
fw(("=" * len(title)) + "\n\n")
|
||||
|
||||
fw(".. module:: %s\n\n" % module_name)
|
||||
|
||||
if module.__doc__:
|
||||
# Note, may contain sphinx syntax, dont mangle!
|
||||
fw(module.__doc__.strip())
|
||||
fw("\n\n")
|
||||
|
||||
write_example_ref("", fw, module_name)
|
||||
|
||||
# write members of the module
|
||||
# only tested with PyStructs which are not exactly modules
|
||||
for key, descr in sorted(type(module).__dict__.items()):
|
||||
if type(descr) == types.MemberDescriptorType:
|
||||
if descr.__doc__:
|
||||
fw(".. data:: %s\n\n" % key)
|
||||
write_indented_lines(" ", fw, descr.__doc__, False)
|
||||
attribute_set.add(key)
|
||||
fw("\n")
|
||||
del key, descr
|
||||
|
||||
classes = []
|
||||
|
||||
for attribute in sorted(dir(module)):
|
||||
if not attribute.startswith("_"):
|
||||
|
||||
if attribute in attribute_set:
|
||||
continue
|
||||
|
||||
if attribute.startswith("n_"): # annoying exception, needed for bpy.app
|
||||
continue
|
||||
|
||||
value = getattr(module, attribute)
|
||||
|
||||
value_type = type(value)
|
||||
|
||||
if value_type == types.FunctionType:
|
||||
pyfunc2sphinx("", fw, attribute, value, is_class=False)
|
||||
elif value_type in (types.BuiltinMethodType, types.BuiltinFunctionType): # both the same at the moment but to be future proof
|
||||
# note: can't get args from these, so dump the string as is
|
||||
# this means any module used like this must have fully formatted docstrings.
|
||||
py_c_func2sphinx("", fw, module_name, module, attribute, value, is_class=False)
|
||||
elif value_type == type:
|
||||
classes.append((attribute, value))
|
||||
elif value_type in (bool, int, float, str, tuple):
|
||||
# constant, not much fun we can do here except to list it.
|
||||
# TODO, figure out some way to document these!
|
||||
fw(".. data:: %s\n\n" % attribute)
|
||||
write_indented_lines(" ", fw, "constant value %s" % repr(value), False)
|
||||
fw("\n")
|
||||
else:
|
||||
print("\tnot documenting %s.%s" % (module_name, attribute))
|
||||
continue
|
||||
|
||||
attribute_set.add(attribute)
|
||||
# TODO, more types...
|
||||
|
||||
# write collected classes now
|
||||
for (type_name, value) in classes:
|
||||
# May need to be its own function
|
||||
fw(".. class:: %s\n\n" % type_name)
|
||||
if value.__doc__:
|
||||
write_indented_lines(" ", fw, value.__doc__, False)
|
||||
fw("\n")
|
||||
write_example_ref(" ", fw, module_name + "." + type_name)
|
||||
|
||||
descr_items = [(key, descr) for key, descr in sorted(value.__dict__.items()) if not key.startswith("__")]
|
||||
|
||||
for key, descr in descr_items:
|
||||
if type(descr) == ClassMethodDescriptorType:
|
||||
py_descr2sphinx(" ", fw, descr, module_name, type_name, key)
|
||||
|
||||
for key, descr in descr_items:
|
||||
if type(descr) == MethodDescriptorType:
|
||||
py_descr2sphinx(" ", fw, descr, module_name, type_name, key)
|
||||
|
||||
for key, descr in descr_items:
|
||||
if type(descr) == GetSetDescriptorType:
|
||||
py_descr2sphinx(" ", fw, descr, module_name, type_name, key)
|
||||
|
||||
fw("\n\n")
|
||||
|
||||
file.close()
|
||||
|
||||
|
||||
|
||||
def rna2sphinx(BASEPATH):
|
||||
|
||||
structs, funcs, ops, props = rna_info.BuildRNAInfo()
|
||||
|
||||
try:
|
||||
os.mkdir(BASEPATH)
|
||||
except:
|
||||
pass
|
||||
|
||||
# conf.py - empty for now
|
||||
filepath = os.path.join(BASEPATH, "conf.py")
|
||||
file = open(filepath, "w")
|
||||
fw = file.write
|
||||
|
||||
|
||||
version_string = bpy.app.version_string.split("(")[0]
|
||||
if bpy.app.build_revision != "Unknown":
|
||||
version_string = version_string + " r" + bpy.app.build_revision
|
||||
|
||||
# for use with files
|
||||
version_string_fp = "_".join(str(v) for v in bpy.app.version)
|
||||
|
||||
fw("project = 'Blender'\n")
|
||||
# fw("master_doc = 'index'\n")
|
||||
fw("copyright = u'Blender Foundation'\n")
|
||||
fw("version = '%s - UNSTABLE API'\n" % version_string)
|
||||
fw("release = '%s - UNSTABLE API'\n" % version_string)
|
||||
fw("html_theme = 'blender-org'\n")
|
||||
fw("html_theme_path = ['../']\n")
|
||||
fw("html_favicon = 'favicon.ico'\n")
|
||||
# not helpful since the source us generated, adds to upload size.
|
||||
fw("html_copy_source = False\n")
|
||||
fw("\n")
|
||||
# needed for latex, pdf gen
|
||||
fw("latex_documents = [ ('contents', 'contents.tex', 'Blender Index', 'Blender Foundation', 'manual'), ]\n")
|
||||
fw("latex_paper_size = 'a4paper'\n")
|
||||
file.close()
|
||||
|
||||
|
||||
filepath = os.path.join(BASEPATH, "contents.rst")
|
||||
file = open(filepath, "w")
|
||||
fw = file.write
|
||||
|
||||
fw("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n")
|
||||
fw(" Blender Documentation contents\n")
|
||||
fw("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n")
|
||||
fw("\n")
|
||||
fw("This document is an API reference for Blender %s. built %s.\n" % (version_string, bpy.app.build_date))
|
||||
fw("\n")
|
||||
fw("An introduction to Blender and Python can be found at <http://wiki.blender.org/index.php/Dev:2.5/Py/API/Intro>\n")
|
||||
fw("\n")
|
||||
fw("`A PDF version of this document is also available <blender_python_reference_%s.pdf>`__\n" % version_string_fp)
|
||||
fw("\n")
|
||||
fw(".. warning:: The Python API in Blender is **UNSTABLE**, It should only be used for testing, any script written now may break in future releases.\n")
|
||||
fw(" \n")
|
||||
fw(" The following areas are subject to change.\n")
|
||||
fw(" * operator names and arguments\n")
|
||||
fw(" * render api\n")
|
||||
fw(" * function calls with the data api (any function calls with values accessed from bpy.data), including functions for importing and exporting meshes\n")
|
||||
fw(" * class registration (Operator, Panels, Menus, Headers)\n")
|
||||
fw(" * modules: bpy.props, blf)\n")
|
||||
fw(" * members in the bpy.context have to be reviewed\n")
|
||||
fw(" * python defined modal operators, especially drawing callbacks are highly experemental\n")
|
||||
fw(" \n")
|
||||
fw(" These parts of the API are relatively stable and are unlikely to change significantly\n")
|
||||
fw(" * data API, access to attributes of blender data such as mesh verts, material color, timeline frames and scene objects\n")
|
||||
fw(" * user interface functions for defining buttons, creation of menus, headers, panels\n")
|
||||
fw(" * modules: bgl, mathutils and geometry\n")
|
||||
fw(" * game engine modules\n")
|
||||
fw("\n")
|
||||
|
||||
fw("===================\n")
|
||||
fw("Application Modules\n")
|
||||
fw("===================\n")
|
||||
fw("\n")
|
||||
fw(".. toctree::\n")
|
||||
fw(" :maxdepth: 1\n\n")
|
||||
fw(" bpy.data.rst\n\n") # note: not actually a module
|
||||
fw(" bpy.ops.rst\n\n")
|
||||
fw(" bpy.types.rst\n\n")
|
||||
|
||||
# py modules
|
||||
fw(" bpy.utils.rst\n\n")
|
||||
fw(" bpy.path.rst\n\n")
|
||||
fw(" bpy.app.rst\n\n")
|
||||
|
||||
# C modules
|
||||
fw(" bpy.props.rst\n\n")
|
||||
|
||||
fw("==================\n")
|
||||
fw("Standalone Modules\n")
|
||||
fw("==================\n")
|
||||
fw("\n")
|
||||
fw(".. toctree::\n")
|
||||
fw(" :maxdepth: 1\n\n")
|
||||
|
||||
|
||||
fw(" mathutils.rst\n\n")
|
||||
fw(" blf.rst\n\n")
|
||||
fw(" aud.rst\n\n")
|
||||
|
||||
# game engine
|
||||
fw("===================\n")
|
||||
fw("Game Engine Modules\n")
|
||||
fw("===================\n")
|
||||
fw("\n")
|
||||
fw(".. toctree::\n")
|
||||
fw(" :maxdepth: 1\n\n")
|
||||
fw(" bge.types.rst\n\n")
|
||||
fw(" bge.logic.rst\n\n")
|
||||
fw(" bge.render.rst\n\n")
|
||||
fw(" bge.events.rst\n\n")
|
||||
|
||||
file.close()
|
||||
|
||||
|
||||
# internal modules
|
||||
filepath = os.path.join(BASEPATH, "bpy.ops.rst")
|
||||
file = open(filepath, "w")
|
||||
fw = file.write
|
||||
fw("Operators (bpy.ops)\n")
|
||||
fw("===================\n\n")
|
||||
fw(".. toctree::\n")
|
||||
fw(" :glob:\n\n")
|
||||
fw(" bpy.ops.*\n\n")
|
||||
file.close()
|
||||
|
||||
filepath = os.path.join(BASEPATH, "bpy.types.rst")
|
||||
file = open(filepath, "w")
|
||||
fw = file.write
|
||||
fw("Types (bpy.types)\n")
|
||||
fw("=================\n\n")
|
||||
fw(".. toctree::\n")
|
||||
fw(" :glob:\n\n")
|
||||
fw(" bpy.types.*\n\n")
|
||||
file.close()
|
||||
|
||||
|
||||
# not actually a module, only write this file so we
|
||||
# can reference in the TOC
|
||||
filepath = os.path.join(BASEPATH, "bpy.data.rst")
|
||||
file = open(filepath, "w")
|
||||
fw = file.write
|
||||
fw("Data Access (bpy.data)\n")
|
||||
fw("======================\n\n")
|
||||
fw(".. module:: bpy\n")
|
||||
fw("\n")
|
||||
fw("This module is used for all blender/python access.\n")
|
||||
fw("\n")
|
||||
fw(".. literalinclude:: ../examples/bpy.data.py\n")
|
||||
fw("\n")
|
||||
fw(".. data:: data\n")
|
||||
fw("\n")
|
||||
fw(" Access to blenders internal data\n")
|
||||
fw("\n")
|
||||
fw(" :type: :class:`bpy.types.BlendData`\n")
|
||||
file.close()
|
||||
|
||||
EXAMPLE_SET_USED.add("bpy.data")
|
||||
|
||||
|
||||
# python modules
|
||||
from bpy import utils as module
|
||||
pymodule2sphinx(BASEPATH, "bpy.utils", module, "Utilities (bpy.utils)")
|
||||
|
||||
from bpy import path as module
|
||||
pymodule2sphinx(BASEPATH, "bpy.path", module, "Path Utilities (bpy.path)")
|
||||
|
||||
# C modules
|
||||
from bpy import app as module
|
||||
pymodule2sphinx(BASEPATH, "bpy.app", module, "Application Data (bpy.app)")
|
||||
|
||||
from bpy import props as module
|
||||
pymodule2sphinx(BASEPATH, "bpy.props", module, "Property Definitions (bpy.props)")
|
||||
|
||||
import mathutils as module
|
||||
pymodule2sphinx(BASEPATH, "mathutils", module, "Math Types & Utilities (mathutils)")
|
||||
del module
|
||||
|
||||
import blf as module
|
||||
pymodule2sphinx(BASEPATH, "blf", module, "Font Drawing (blf)")
|
||||
del module
|
||||
|
||||
import aud as module
|
||||
pymodule2sphinx(BASEPATH, "aud", module, "Audio System (aud)")
|
||||
del module
|
||||
|
||||
## game engine
|
||||
import shutil
|
||||
# copy2 keeps time/date stamps
|
||||
shutil.copy2(os.path.join(BASEPATH,"..","rst","bge.types.rst"), BASEPATH)
|
||||
shutil.copy2(os.path.join(BASEPATH,"..","rst","bge.logic.rst"), BASEPATH)
|
||||
shutil.copy2(os.path.join(BASEPATH,"..","rst","bge.render.rst"), BASEPATH)
|
||||
shutil.copy2(os.path.join(BASEPATH,"..","rst","bge.events.rst"), BASEPATH)
|
||||
|
||||
|
||||
if 0:
|
||||
filepath = os.path.join(BASEPATH, "bpy.rst")
|
||||
file = open(filepath, "w")
|
||||
fw = file.write
|
||||
|
||||
fw("\n")
|
||||
|
||||
title = ":mod:`bpy` --- Blender Python Module"
|
||||
fw("%s\n%s\n\n" % (title, "=" * len(title)))
|
||||
fw(".. module:: bpy.types\n\n")
|
||||
file.close()
|
||||
|
||||
def write_param(ident, fw, prop, is_return=False):
|
||||
if is_return:
|
||||
id_name = "return"
|
||||
id_type = "rtype"
|
||||
kwargs = {"as_ret": True, "class_fmt": ":class:`%s`"}
|
||||
identifier = ""
|
||||
else:
|
||||
id_name = "arg"
|
||||
id_type = "type"
|
||||
kwargs = {"as_arg": True, "class_fmt": ":class:`%s`"}
|
||||
identifier = " %s" % prop.identifier
|
||||
|
||||
type_descr = prop.get_type_description(**kwargs)
|
||||
if prop.name or prop.description:
|
||||
fw(ident + ":%s%s: %s\n" % (id_name, identifier, ", ".join(val for val in (prop.name, prop.description) if val)))
|
||||
fw(ident + ":%s%s: %s\n" % (id_type, identifier, type_descr))
|
||||
|
||||
def write_struct(struct):
|
||||
#if not struct.identifier.startswith("Sc") and not struct.identifier.startswith("I"):
|
||||
# return
|
||||
|
||||
#if not struct.identifier == "Object":
|
||||
# return
|
||||
|
||||
filepath = os.path.join(BASEPATH, "bpy.types.%s.rst" % struct.identifier)
|
||||
file = open(filepath, "w")
|
||||
fw = file.write
|
||||
|
||||
base_id = getattr(struct.base, "identifier", "")
|
||||
|
||||
if _BPY_STRUCT_FAKE:
|
||||
if not base_id:
|
||||
base_id = _BPY_STRUCT_FAKE
|
||||
|
||||
if base_id:
|
||||
title = "%s(%s)" % (struct.identifier, base_id)
|
||||
else:
|
||||
title = struct.identifier
|
||||
|
||||
fw("%s\n%s\n\n" % (title, "=" * len(title)))
|
||||
|
||||
fw(".. module:: bpy.types\n\n")
|
||||
|
||||
base_ids = [base.identifier for base in struct.get_bases()]
|
||||
|
||||
if _BPY_STRUCT_FAKE:
|
||||
base_ids.append(_BPY_STRUCT_FAKE)
|
||||
|
||||
base_ids.reverse()
|
||||
|
||||
if base_ids:
|
||||
if len(base_ids) > 1:
|
||||
fw("base classes --- ")
|
||||
else:
|
||||
fw("base class --- ")
|
||||
|
||||
fw(", ".join((":class:`%s`" % base_id) for base_id in base_ids))
|
||||
fw("\n\n")
|
||||
|
||||
subclass_ids = [s.identifier for s in structs.values() if s.base is struct if not rna_info.rna_id_ignore(s.identifier)]
|
||||
if subclass_ids:
|
||||
fw("subclasses --- \n" + ", ".join((":class:`%s`" % s) for s in subclass_ids) + "\n\n")
|
||||
|
||||
base_id = getattr(struct.base, "identifier", "")
|
||||
|
||||
if _BPY_STRUCT_FAKE:
|
||||
if not base_id:
|
||||
base_id = _BPY_STRUCT_FAKE
|
||||
|
||||
if base_id:
|
||||
fw(".. class:: %s(%s)\n\n" % (struct.identifier, base_id))
|
||||
else:
|
||||
fw(".. class:: %s\n\n" % struct.identifier)
|
||||
|
||||
fw(" %s\n\n" % struct.description)
|
||||
|
||||
# properties sorted in alphabetical order
|
||||
sorted_struct_properties = struct.properties[:]
|
||||
sorted_struct_properties.sort(key=lambda prop: prop.identifier)
|
||||
|
||||
for prop in sorted_struct_properties:
|
||||
type_descr = prop.get_type_description(class_fmt=":class:`%s`")
|
||||
# readonly properties use "data" directive, variables properties use "attribute" directive
|
||||
if 'readonly' in type_descr:
|
||||
fw(" .. data:: %s\n\n" % prop.identifier)
|
||||
else:
|
||||
fw(" .. attribute:: %s\n\n" % prop.identifier)
|
||||
if prop.description:
|
||||
fw(" %s\n\n" % prop.description)
|
||||
fw(" :type: %s\n\n" % type_descr)
|
||||
|
||||
# python attributes
|
||||
py_properties = struct.get_py_properties()
|
||||
py_prop = None
|
||||
for identifier, py_prop in py_properties:
|
||||
pyprop2sphinx(" ", fw, identifier, py_prop)
|
||||
del py_properties, py_prop
|
||||
|
||||
for func in struct.functions:
|
||||
args_str = ", ".join(prop.get_arg_default(force=False) for prop in func.args)
|
||||
|
||||
fw(" .. %s:: %s(%s)\n\n" % ("classmethod" if func.is_classmethod else "method", func.identifier, args_str))
|
||||
fw(" %s\n\n" % func.description)
|
||||
|
||||
for prop in func.args:
|
||||
write_param(" ", fw, prop)
|
||||
|
||||
if len(func.return_values) == 1:
|
||||
write_param(" ", fw, func.return_values[0], is_return=True)
|
||||
elif func.return_values: # multiple return values
|
||||
fw(" :return (%s):\n" % ", ".join(prop.identifier for prop in func.return_values))
|
||||
for prop in func.return_values:
|
||||
type_descr = prop.get_type_description(as_ret=True, class_fmt=":class:`%s`")
|
||||
descr = prop.description
|
||||
if not descr:
|
||||
descr = prop.name
|
||||
fw(" `%s`, %s, %s\n\n" % (prop.identifier, descr, type_descr))
|
||||
|
||||
fw("\n")
|
||||
|
||||
|
||||
# python methods
|
||||
py_funcs = struct.get_py_functions()
|
||||
py_func = None
|
||||
|
||||
for identifier, py_func in py_funcs:
|
||||
pyfunc2sphinx(" ", fw, identifier, py_func, is_class=True)
|
||||
del py_funcs, py_func
|
||||
|
||||
lines = []
|
||||
|
||||
if struct.base or _BPY_STRUCT_FAKE:
|
||||
bases = list(reversed(struct.get_bases()))
|
||||
|
||||
# props
|
||||
lines[:] = []
|
||||
|
||||
if _BPY_STRUCT_FAKE:
|
||||
descr_items = [(key, descr) for key, descr in sorted(bpy.types.Struct.__bases__[0].__dict__.items()) if not key.startswith("__")]
|
||||
|
||||
if _BPY_STRUCT_FAKE:
|
||||
for key, descr in descr_items:
|
||||
if type(descr) == GetSetDescriptorType:
|
||||
lines.append(" * :class:`%s.%s`\n" % (_BPY_STRUCT_FAKE, key))
|
||||
|
||||
for base in bases:
|
||||
for prop in base.properties:
|
||||
lines.append(" * :class:`%s.%s`\n" % (base.identifier, prop.identifier))
|
||||
|
||||
for identifier, py_prop in base.get_py_properties():
|
||||
lines.append(" * :class:`%s.%s`\n" % (base.identifier, identifier))
|
||||
|
||||
for identifier, py_prop in base.get_py_properties():
|
||||
lines.append(" * :class:`%s.%s`\n" % (base.identifier, identifier))
|
||||
|
||||
if lines:
|
||||
fw(".. rubric:: Inherited Properties\n\n")
|
||||
|
||||
fw(".. hlist::\n")
|
||||
fw(" :columns: 2\n\n")
|
||||
|
||||
for line in lines:
|
||||
fw(line)
|
||||
fw("\n")
|
||||
|
||||
|
||||
# funcs
|
||||
lines[:] = []
|
||||
|
||||
if _BPY_STRUCT_FAKE:
|
||||
for key, descr in descr_items:
|
||||
if type(descr) == MethodDescriptorType:
|
||||
lines.append(" * :class:`%s.%s`\n" % (_BPY_STRUCT_FAKE, key))
|
||||
|
||||
for base in bases:
|
||||
for func in base.functions:
|
||||
lines.append(" * :class:`%s.%s`\n" % (base.identifier, func.identifier))
|
||||
for identifier, py_func in base.get_py_functions():
|
||||
lines.append(" * :class:`%s.%s`\n" % (base.identifier, identifier))
|
||||
|
||||
if lines:
|
||||
fw(".. rubric:: Inherited Functions\n\n")
|
||||
|
||||
fw(".. hlist::\n")
|
||||
fw(" :columns: 2\n\n")
|
||||
|
||||
for line in lines:
|
||||
fw(line)
|
||||
fw("\n")
|
||||
|
||||
lines[:] = []
|
||||
|
||||
|
||||
if struct.references:
|
||||
# use this otherwise it gets in the index for a normal heading.
|
||||
fw(".. rubric:: References\n\n")
|
||||
|
||||
fw(".. hlist::\n")
|
||||
fw(" :columns: 2\n\n")
|
||||
|
||||
for ref in struct.references:
|
||||
ref_split = ref.split(".")
|
||||
if len(ref_split) > 2:
|
||||
ref = ref_split[-2] + "." + ref_split[-1]
|
||||
fw(" * :class:`%s`\n" % ref)
|
||||
fw("\n")
|
||||
|
||||
|
||||
for struct in structs.values():
|
||||
# TODO, rna_info should filter these out!
|
||||
if "_OT_" in struct.identifier:
|
||||
continue
|
||||
write_struct(struct)
|
||||
|
||||
# special case, bpy_struct
|
||||
if _BPY_STRUCT_FAKE:
|
||||
filepath = os.path.join(BASEPATH, "bpy.types.%s.rst" % _BPY_STRUCT_FAKE)
|
||||
file = open(filepath, "w")
|
||||
fw = file.write
|
||||
|
||||
fw("%s\n" % _BPY_STRUCT_FAKE)
|
||||
fw("=" * len(_BPY_STRUCT_FAKE) + "\n")
|
||||
fw("\n")
|
||||
fw(".. module:: bpy.types\n")
|
||||
fw("\n")
|
||||
|
||||
subclass_ids = [s.identifier for s in structs.values() if s.base is None if not rna_info.rna_id_ignore(s.identifier)]
|
||||
if subclass_ids:
|
||||
fw("subclasses --- \n" + ", ".join((":class:`%s`" % s) for s in sorted(subclass_ids)) + "\n\n")
|
||||
|
||||
fw(".. class:: %s\n\n" % _BPY_STRUCT_FAKE)
|
||||
fw(" built-in base class for all classes in bpy.types.\n\n")
|
||||
fw(" .. note::\n\n")
|
||||
fw(" Note that bpy.types.%s is not actually available from within blender, it only exists for the purpose of documentation.\n\n" % _BPY_STRUCT_FAKE)
|
||||
|
||||
descr_items = [(key, descr) for key, descr in sorted(bpy.types.Struct.__bases__[0].__dict__.items()) if not key.startswith("__")]
|
||||
|
||||
for key, descr in descr_items:
|
||||
if type(descr) == MethodDescriptorType: # GetSetDescriptorType, GetSetDescriptorType's are not documented yet
|
||||
py_descr2sphinx(" ", fw, descr, "bpy.types", _BPY_STRUCT_FAKE, key)
|
||||
|
||||
for key, descr in descr_items:
|
||||
if type(descr) == GetSetDescriptorType:
|
||||
py_descr2sphinx(" ", fw, descr, "bpy.types", _BPY_STRUCT_FAKE, key)
|
||||
|
||||
|
||||
# operators
|
||||
def write_ops():
|
||||
API_BASEURL='https://svn.blender.org/svnroot/bf-blender/trunk/blender/release/scripts'
|
||||
fw = None
|
||||
last_mod = ''
|
||||
|
||||
for op_key in sorted(ops.keys()):
|
||||
op = ops[op_key]
|
||||
|
||||
if last_mod != op.module_name:
|
||||
filepath = os.path.join(BASEPATH, "bpy.ops.%s.rst" % op.module_name)
|
||||
file = open(filepath, "w")
|
||||
fw = file.write
|
||||
|
||||
title = "%s Operators" % (op.module_name[0].upper() + op.module_name[1:])
|
||||
fw("%s\n%s\n\n" % (title, "=" * len(title)))
|
||||
|
||||
fw(".. module:: bpy.ops.%s\n\n" % op.module_name)
|
||||
last_mod = op.module_name
|
||||
|
||||
args_str = ", ".join(prop.get_arg_default(force=True) for prop in op.args)
|
||||
fw(".. function:: %s(%s)\n\n" % (op.func_name, args_str))
|
||||
|
||||
# if the description isn't valid, we output the standard warning
|
||||
# with a link to the wiki so that people can help
|
||||
if not op.description or op.description == "(undocumented operator)":
|
||||
operator_description = undocumented_message('bpy.ops',op.module_name,op.func_name)
|
||||
else:
|
||||
operator_description = op.description
|
||||
|
||||
fw(" %s\n\n" % operator_description)
|
||||
for prop in op.args:
|
||||
write_param(" ", fw, prop)
|
||||
if op.args:
|
||||
fw("\n")
|
||||
|
||||
location = op.get_location()
|
||||
if location != (None, None):
|
||||
fw(" :file: `%s <%s/%s>`_:%d\n\n" % (location[0],API_BASEURL,location[0],location[1]))
|
||||
|
||||
write_ops()
|
||||
|
||||
file.close()
|
||||
|
||||
def main():
|
||||
import bpy
|
||||
if 'bpy' not in dir():
|
||||
print("\nError, this script must run from inside blender2.5")
|
||||
print(script_help_msg)
|
||||
else:
|
||||
import shutil
|
||||
|
||||
script_dir = os.path.dirname(__file__)
|
||||
path_in = os.path.join(script_dir,'sphinx-in')
|
||||
path_out = os.path.join(script_dir,'sphinx-out')
|
||||
path_examples = os.path.join(script_dir,'examples')
|
||||
# only for partial updates
|
||||
path_in_tmp = path_in + "-tmp"
|
||||
|
||||
if not os.path.exists(path_in):
|
||||
os.mkdir(path_in)
|
||||
|
||||
for f in os.listdir(path_examples):
|
||||
if f.endswith(".py"):
|
||||
EXAMPLE_SET.add(os.path.splitext(f)[0])
|
||||
|
||||
|
||||
# only for full updates
|
||||
if _BPY_FULL_REBUILD:
|
||||
shutil.rmtree(path_in, True)
|
||||
shutil.rmtree(path_out, True)
|
||||
else:
|
||||
# write here, then move
|
||||
shutil.rmtree(path_in_tmp, True)
|
||||
|
||||
rna2sphinx(path_in_tmp)
|
||||
|
||||
if not _BPY_FULL_REBUILD:
|
||||
import filecmp
|
||||
|
||||
# now move changed files from 'path_in_tmp' --> 'path_in'
|
||||
file_list_path_in = set(os.listdir(path_in))
|
||||
file_list_path_in_tmp = set(os.listdir(path_in_tmp))
|
||||
|
||||
# remove deprecated files that have been removed.
|
||||
for f in sorted(file_list_path_in):
|
||||
if f not in file_list_path_in_tmp:
|
||||
print("\tdeprecated: %s" % f)
|
||||
os.remove(os.path.join(path_in, f))
|
||||
|
||||
# freshen with new files.
|
||||
for f in sorted(file_list_path_in_tmp):
|
||||
f_from = os.path.join(path_in_tmp, f)
|
||||
f_to = os.path.join(path_in, f)
|
||||
|
||||
do_copy = True
|
||||
if f in file_list_path_in:
|
||||
if filecmp.cmp(f_from, f_to):
|
||||
do_copy = False
|
||||
|
||||
if do_copy:
|
||||
print("\tupdating: %s" % f)
|
||||
shutil.copy(f_from, f_to)
|
||||
'''else:
|
||||
print("\tkeeping: %s" % f) # eh, not that useful'''
|
||||
|
||||
|
||||
EXAMPLE_SET_UNUSED = EXAMPLE_SET - EXAMPLE_SET_USED
|
||||
if EXAMPLE_SET_UNUSED:
|
||||
print("\nUnused examples found in '%s'..." % path_examples)
|
||||
for f in EXAMPLE_SET_UNUSED:
|
||||
print(" %s.py" % f)
|
||||
print(" %d total\n" % len(EXAMPLE_SET_UNUSED))
|
||||
|
||||
import sys
|
||||
sys.exit()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
37
doc/python_api/sphinx_doc_gen.sh
Executable file
37
doc/python_api/sphinx_doc_gen.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
# run from the blender source dir
|
||||
# bash source/blender/python/doc/sphinx_doc_gen.sh
|
||||
# ssh upload means you need an account on the server
|
||||
|
||||
BLENDER="./blender.bin"
|
||||
SSH_HOST="ideasman42@emo.blender.org"
|
||||
SSH_UPLOAD="/data/www/vhosts/www.blender.org/documentation" # blender_python_api_VERSION, added after
|
||||
|
||||
# sed string from hell, 'Blender 2.53 (sub 1) Build' --> '2_53_1'
|
||||
# "_".join(str(v) for v in bpy.app.version)
|
||||
# custom blender vars
|
||||
blender_srcdir=$(dirname $0)/../../
|
||||
blender_version=$(grep BLENDER_VERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | tr -dc 0-9)
|
||||
blender_subversion=$(grep BLENDER_SUBVERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | tr -dc 0-9)
|
||||
BLENDER_VERSION=$(expr $blender_version / 100)_$(expr $blender_version % 100)_$blender_subversion
|
||||
|
||||
BLENDER_VERSION=`$BLENDER --version | cut -f2-4 -d" " | sed 's/(//g' | sed 's/)//g' | sed 's/ sub /./g' | sed 's/\./_/g'`
|
||||
SSH_UPLOAD_FULL=$SSH_UPLOAD/"blender_python_api_"$BLENDER_VERSION
|
||||
|
||||
SPHINXBASE=doc/python_api/
|
||||
|
||||
# dont delete existing docs, now partial updates are used for quick builds.
|
||||
$BLENDER --background --python $SPHINXBASE/sphinx_doc_gen.py
|
||||
|
||||
# html
|
||||
sphinx-build $SPHINXBASE/sphinx-in $SPHINXBASE/sphinx-out
|
||||
cp $SPHINXBASE/sphinx-out/contents.html $SPHINXBASE/sphinx-out/index.html
|
||||
ssh ideasman42@emo.blender.org 'rm -rf '$SSH_UPLOAD_FULL'/*'
|
||||
rsync --progress -avze "ssh -p 22" $SPHINXBASE/sphinx-out/* $SSH_HOST:$SSH_UPLOAD_FULL/
|
||||
|
||||
# pdf
|
||||
sphinx-build -b latex $SPHINXBASE/sphinx-in $SPHINXBASE/sphinx-out
|
||||
cd $SPHINXBASE/sphinx-out
|
||||
make
|
||||
cd -
|
||||
rsync --progress -avze "ssh -p 22" $SPHINXBASE/sphinx-out/contents.pdf $SSH_HOST:$SSH_UPLOAD_FULL/blender_python_reference_$BLENDER_VERSION.pdf
|
Reference in New Issue
Block a user