Start lua documentation
get mesh object type implemented
This commit is contained in:
parent
f767fdf8ab
commit
5a7a876207
2
skelatool64/config.ld
Normal file
2
skelatool64/config.ld
Normal file
|
@ -0,0 +1,2 @@
|
|||
project = "skeletool64"
|
||||
file = {'./src/lua_generator', './lua'}
|
64
skelatool64/doc/index.html
Normal file
64
skelatool64/doc/index.html
Normal file
|
@ -0,0 +1,64 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>Reference</title>
|
||||
<link rel="stylesheet" href="ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>skeletool64</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="modules/LuaScene.html">LuaScene</a></li>
|
||||
<li><a href="modules/vector3.html">vector3</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<table class="module_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/LuaScene.html">LuaScene</a></td>
|
||||
<td class="summary">Scene functions</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/vector3.html">vector3</a></td>
|
||||
<td class="summary"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated 2022-10-01 11:25:20 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
303
skelatool64/doc/ldoc.css
Normal file
303
skelatool64/doc/ldoc.css
Normal file
|
@ -0,0 +1,303 @@
|
|||
/* BEGIN RESET
|
||||
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 2.8.2r1
|
||||
*/
|
||||
html {
|
||||
color: #000;
|
||||
background: #FFF;
|
||||
}
|
||||
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
fieldset,img {
|
||||
border: 0;
|
||||
}
|
||||
address,caption,cite,code,dfn,em,strong,th,var,optgroup {
|
||||
font-style: inherit;
|
||||
font-weight: inherit;
|
||||
}
|
||||
del,ins {
|
||||
text-decoration: none;
|
||||
}
|
||||
li {
|
||||
margin-left: 20px;
|
||||
}
|
||||
caption,th {
|
||||
text-align: left;
|
||||
}
|
||||
h1,h2,h3,h4,h5,h6 {
|
||||
font-size: 100%;
|
||||
font-weight: bold;
|
||||
}
|
||||
q:before,q:after {
|
||||
content: '';
|
||||
}
|
||||
abbr,acronym {
|
||||
border: 0;
|
||||
font-variant: normal;
|
||||
}
|
||||
sup {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
sub {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
legend {
|
||||
color: #000;
|
||||
}
|
||||
input,button,textarea,select,optgroup,option {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
font-style: inherit;
|
||||
font-weight: inherit;
|
||||
}
|
||||
input,button,textarea,select {*font-size:100%;
|
||||
}
|
||||
/* END RESET */
|
||||
|
||||
body {
|
||||
margin-left: 1em;
|
||||
margin-right: 1em;
|
||||
font-family: arial, helvetica, geneva, sans-serif;
|
||||
background-color: #ffffff; margin: 0px;
|
||||
}
|
||||
|
||||
code, tt { font-family: monospace; font-size: 1.1em; }
|
||||
span.parameter { font-family:monospace; }
|
||||
span.parameter:after { content:":"; }
|
||||
span.types:before { content:"("; }
|
||||
span.types:after { content:")"; }
|
||||
.type { font-weight: bold; font-style:italic }
|
||||
|
||||
body, p, td, th { font-size: .95em; line-height: 1.2em;}
|
||||
|
||||
p, ul { margin: 10px 0 0 0px;}
|
||||
|
||||
strong { font-weight: bold;}
|
||||
|
||||
em { font-style: italic;}
|
||||
|
||||
h1 {
|
||||
font-size: 1.5em;
|
||||
margin: 20px 0 20px 0;
|
||||
}
|
||||
h2, h3, h4 { margin: 15px 0 10px 0; }
|
||||
h2 { font-size: 1.25em; }
|
||||
h3 { font-size: 1.15em; }
|
||||
h4 { font-size: 1.06em; }
|
||||
|
||||
a:link { font-weight: bold; color: #004080; text-decoration: none; }
|
||||
a:visited { font-weight: bold; color: #006699; text-decoration: none; }
|
||||
a:link:hover { text-decoration: underline; }
|
||||
|
||||
hr {
|
||||
color:#cccccc;
|
||||
background: #00007f;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
blockquote { margin-left: 3em; }
|
||||
|
||||
ul { list-style-type: disc; }
|
||||
|
||||
p.name {
|
||||
font-family: "Andale Mono", monospace;
|
||||
padding-top: 1em;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: rgb(245, 245, 245);
|
||||
border: 1px solid #C0C0C0; /* silver */
|
||||
padding: 10px;
|
||||
margin: 10px 0 10px 0;
|
||||
overflow: auto;
|
||||
font-family: "Andale Mono", monospace;
|
||||
}
|
||||
|
||||
pre.example {
|
||||
font-size: .85em;
|
||||
}
|
||||
|
||||
table.index { border: 1px #00007f; }
|
||||
table.index td { text-align: left; vertical-align: top; }
|
||||
|
||||
#container {
|
||||
margin-left: 1em;
|
||||
margin-right: 1em;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
#product {
|
||||
text-align: center;
|
||||
border-bottom: 1px solid #cccccc;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#product big {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
#main {
|
||||
background-color: #f0f0f0;
|
||||
border-left: 2px solid #cccccc;
|
||||
}
|
||||
|
||||
#navigation {
|
||||
float: left;
|
||||
width: 14em;
|
||||
vertical-align: top;
|
||||
background-color: #f0f0f0;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
#navigation h2 {
|
||||
background-color:#e7e7e7;
|
||||
font-size:1.1em;
|
||||
color:#000000;
|
||||
text-align: left;
|
||||
padding:0.2em;
|
||||
border-top:1px solid #dddddd;
|
||||
border-bottom:1px solid #dddddd;
|
||||
}
|
||||
|
||||
#navigation ul
|
||||
{
|
||||
font-size:1em;
|
||||
list-style-type: none;
|
||||
margin: 1px 1px 10px 1px;
|
||||
}
|
||||
|
||||
#navigation li {
|
||||
text-indent: -1em;
|
||||
display: block;
|
||||
margin: 3px 0px 0px 22px;
|
||||
}
|
||||
|
||||
#navigation li li a {
|
||||
margin: 0px 3px 0px -1em;
|
||||
}
|
||||
|
||||
#content {
|
||||
margin-left: 14em;
|
||||
padding: 1em;
|
||||
width: 700px;
|
||||
border-left: 2px solid #cccccc;
|
||||
border-right: 2px solid #cccccc;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#about {
|
||||
clear: both;
|
||||
padding: 5px;
|
||||
border-top: 2px solid #cccccc;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
@media print {
|
||||
body {
|
||||
font: 12pt "Times New Roman", "TimeNR", Times, serif;
|
||||
}
|
||||
a { font-weight: bold; color: #004080; text-decoration: underline; }
|
||||
|
||||
#main {
|
||||
background-color: #ffffff;
|
||||
border-left: 0px;
|
||||
}
|
||||
|
||||
#container {
|
||||
margin-left: 2%;
|
||||
margin-right: 2%;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#content {
|
||||
padding: 1em;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#navigation {
|
||||
display: none;
|
||||
}
|
||||
pre.example {
|
||||
font-family: "Andale Mono", monospace;
|
||||
font-size: 10pt;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
}
|
||||
|
||||
table.module_list {
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: #cccccc;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.module_list td {
|
||||
border-width: 1px;
|
||||
padding: 3px;
|
||||
border-style: solid;
|
||||
border-color: #cccccc;
|
||||
}
|
||||
table.module_list td.name { background-color: #f0f0f0; min-width: 200px; }
|
||||
table.module_list td.summary { width: 100%; }
|
||||
|
||||
|
||||
table.function_list {
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: #cccccc;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.function_list td {
|
||||
border-width: 1px;
|
||||
padding: 3px;
|
||||
border-style: solid;
|
||||
border-color: #cccccc;
|
||||
}
|
||||
table.function_list td.name { background-color: #f0f0f0; min-width: 200px; }
|
||||
table.function_list td.summary { width: 100%; }
|
||||
|
||||
ul.nowrap {
|
||||
overflow:auto;
|
||||
white-space:nowrap;
|
||||
}
|
||||
|
||||
dl.table dt, dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;}
|
||||
dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;}
|
||||
dl.table h3, dl.function h3 {font-size: .95em;}
|
||||
|
||||
/* stop sublists from having initial vertical space */
|
||||
ul ul { margin-top: 0px; }
|
||||
ol ul { margin-top: 0px; }
|
||||
ol ol { margin-top: 0px; }
|
||||
ul ol { margin-top: 0px; }
|
||||
|
||||
/* make the target distinct; helps when we're navigating to a function */
|
||||
a:target + * {
|
||||
background-color: #FF9;
|
||||
}
|
||||
|
||||
|
||||
/* styles for prettification of source */
|
||||
pre .comment { color: #558817; }
|
||||
pre .constant { color: #a8660d; }
|
||||
pre .escape { color: #844631; }
|
||||
pre .keyword { color: #aa5050; font-weight: bold; }
|
||||
pre .library { color: #0e7c6b; }
|
||||
pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; }
|
||||
pre .string { color: #8080ff; }
|
||||
pre .number { color: #f8660d; }
|
||||
pre .operator { color: #2239a8; font-weight: bold; }
|
||||
pre .preprocessor, pre .prepro { color: #a33243; }
|
||||
pre .global { color: #800080; }
|
||||
pre .user-keyword { color: #800080; }
|
||||
pre .prompt { color: #558817; }
|
||||
pre .url { color: #272fc2; text-decoration: underline; }
|
||||
|
94
skelatool64/doc/modules/LuaScene.html
Normal file
94
skelatool64/doc/modules/LuaScene.html
Normal file
|
@ -0,0 +1,94 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>Reference</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>skeletool64</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><strong>LuaScene</strong></li>
|
||||
<li><a href="../modules/vector3.html">vector3</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>LuaScene</code></h1>
|
||||
<p>Scene functions</p>
|
||||
<p></p>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#export_default_mesh">export_default_mesh ()</a></td>
|
||||
<td class="summary">Generates mesh and animation data from the current scene</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "export_default_mesh"></a>
|
||||
<strong>export_default_mesh ()</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Generates mesh and animation data from the current scene
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated 2022-10-01 11:25:20 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
106
skelatool64/doc/modules/vector3.html
Normal file
106
skelatool64/doc/modules/vector3.html
Normal file
|
@ -0,0 +1,106 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>Reference</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>skeletool64</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/LuaScene.html">LuaScene</a></li>
|
||||
<li><strong>vector3</strong></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>vector3</code></h1>
|
||||
<p></p>
|
||||
<p></p>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#vector3">vector3 (x, y, z)</a></td>
|
||||
<td class="summary">creates a new 3d vector</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "vector3"></a>
|
||||
<strong>vector3 (x, y, z)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
creates a new 3d vector
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">x</span>
|
||||
the x value for the vector
|
||||
</li>
|
||||
<li><span class="parameter">y</span>
|
||||
the x value for the vector
|
||||
</li>
|
||||
<li><span class="parameter">z</span>
|
||||
the x value for the vector
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated 2022-10-01 11:25:20 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
6
skelatool64/lua/box3.lua
Normal file
6
skelatool64/lua/box3.lua
Normal file
|
@ -0,0 +1,6 @@
|
|||
|
||||
Box3 = {}
|
||||
|
||||
function box3(min, max)
|
||||
return setmetatable({ min = min, max = max }, Box3)
|
||||
end
|
|
@ -46,11 +46,11 @@ local function validate_definition(data, visited, name_path)
|
|||
|
||||
local data_type = type(data)
|
||||
|
||||
if (data_type == "nil" or data_type == "boolean" or data_type == "number" or data_type == "string") then
|
||||
if (data_type == "nil" or data_type == "boolean" or data_type == "number" or data_type == "string" or data_type == "userdata") then
|
||||
return true
|
||||
end
|
||||
|
||||
if (data_type == "function" or data_type == "userdata" or data_type == "thread") then
|
||||
if (data_type == "function" or data_type == "thread") then
|
||||
error("Cannot use '" .. data_type .. "' in a c file definition for path '" .. name_path .. "'")
|
||||
return false
|
||||
end
|
||||
|
|
|
@ -16,4 +16,19 @@ function node_with_name(name)
|
|||
end
|
||||
|
||||
return node_name_cache[name]
|
||||
end
|
||||
|
||||
function export_default_mesh()
|
||||
local allNodes = {}
|
||||
|
||||
|
||||
for k, value in pairs(nodes_for_type("")) do
|
||||
local renderChunks = generate_render_chunks(value.node)
|
||||
|
||||
for _, toAdd in pairs(renderChunks) do
|
||||
table.insert(allNodes, toAdd)
|
||||
end
|
||||
end
|
||||
|
||||
generate_mesh(allNodes, "_geo")
|
||||
end
|
|
@ -1,6 +1,12 @@
|
|||
---
|
||||
-- @module vector3
|
||||
|
||||
Vector3 = {}
|
||||
|
||||
--- creates a new 3d vector
|
||||
--- @param x the x value for the vector
|
||||
--- @param y the x value for the vector
|
||||
--- @param z the x value for the vector
|
||||
function vector3(x, y, z)
|
||||
return setmetatable({ x = x, y = y, z = z }, Vector3)
|
||||
end
|
||||
|
|
|
@ -45,4 +45,7 @@ build/skeletool.deb: skeletool64 control
|
|||
cp skeletool64 build/skeletool/usr/local/bin
|
||||
mkdir build/skeletool/DEBIAN -p
|
||||
cp control build/skeletool/DEBIAN
|
||||
dpkg-deb --build build/skeletool
|
||||
dpkg-deb --build build/skeletool
|
||||
|
||||
docs:
|
||||
ldoc .
|
|
@ -97,8 +97,8 @@ bool parseCommandLineArguments(int argc, char *argv[], struct CommandLineArgumen
|
|||
} else if (strcmp(curr, "--boneless") == 0) {
|
||||
output.mBonesAsVertexGroups = true;
|
||||
} else if (strcmp(curr, "--level") == 0) {
|
||||
output.mOutputType = FileOutputType::Level;
|
||||
output.mExportAnimation = false;
|
||||
output.mOutputType = FileOutputType::Level;
|
||||
output.mExportAnimation = false;
|
||||
} else if (strcmp(curr, "--default-material") == 0) {
|
||||
lastParameter = "default-material";
|
||||
} else if (strcmp(curr, "--force-material") == 0) {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "../MeshWriter.h"
|
||||
#include "AnimationGenerator.h"
|
||||
#include "../StringUtils.h"
|
||||
#include "MaterialGenerator.h"
|
||||
|
||||
bool extractMaterialAutoTileParameters(Material* material, double& sTile, double& tTile) {
|
||||
if (!material) {
|
||||
|
@ -93,6 +94,10 @@ void MeshDefinitionGenerator::AppendRenderChunks(const aiScene* scene, aiNode* n
|
|||
}
|
||||
|
||||
void MeshDefinitionGenerator::GenerateDefinitions(const aiScene* scene, CFileDefinition& fileDefinition) {
|
||||
GenerateDefinitionsWithResults(scene, fileDefinition);
|
||||
}
|
||||
|
||||
MeshDefinitionResults MeshDefinitionGenerator::GenerateDefinitionsWithResults(const aiScene* scene, CFileDefinition& fileDefinition) {
|
||||
std::vector<RenderChunk> renderChunks;
|
||||
|
||||
auto animInfo = findNodesForWithAnimation(scene, mIncludedNodes, mSettings.mModelScale);
|
||||
|
@ -105,9 +110,14 @@ void MeshDefinitionGenerator::GenerateDefinitions(const aiScene* scene, CFileDef
|
|||
AppendRenderChunks(scene, *node, fileDefinition, mSettings, renderChunks);
|
||||
}
|
||||
|
||||
generateMesh(scene, fileDefinition, renderChunks, mSettings, "_geo");
|
||||
MeshDefinitionResults result;
|
||||
|
||||
result.modelName = generateMesh(scene, fileDefinition, renderChunks, mSettings, "_geo");
|
||||
result.materialMacro = MaterialGenerator::MaterialIndexMacroName(mSettings.mDefaultMaterialName);
|
||||
|
||||
if (fileDefinition.GetBoneHierarchy().HasData() && !mSettings.mBonesAsVertexGroups) {
|
||||
generateAnimationForScene(scene, fileDefinition, mSettings);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
|
@ -5,12 +5,19 @@
|
|||
#include "../DisplayListSettings.h"
|
||||
#include "../RenderChunk.h"
|
||||
|
||||
struct MeshDefinitionResults {
|
||||
public:
|
||||
std::string modelName;
|
||||
std::string materialMacro;
|
||||
};
|
||||
|
||||
class MeshDefinitionGenerator : public DefinitionGenerator {
|
||||
public:
|
||||
MeshDefinitionGenerator(const DisplayListSettings& settings);
|
||||
|
||||
virtual bool ShouldIncludeNode(aiNode* node);
|
||||
virtual void GenerateDefinitions(const aiScene* scene, CFileDefinition& fileDefinition);
|
||||
MeshDefinitionResults GenerateDefinitionsWithResults(const aiScene* scene, CFileDefinition& fileDefinition);
|
||||
|
||||
static void AppendRenderChunks(const aiScene* scene, aiNode* node, CFileDefinition& fileDefinition, const DisplayListSettings& settings, std::vector<RenderChunk>& renderChunks);
|
||||
private:
|
||||
|
|
|
@ -15,6 +15,11 @@ void toLua(lua_State* L, int number) {
|
|||
lua_pushinteger(L, number);
|
||||
}
|
||||
|
||||
|
||||
void toLua(lua_State* L, unsigned int number) {
|
||||
lua_pushinteger(L, number);
|
||||
}
|
||||
|
||||
void fromLua(lua_State* L, int& number) {
|
||||
number = lua_tointeger(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
@ -27,4 +32,9 @@ void toLua(lua_State* L, double number) {
|
|||
void fromLua(lua_State* L, double& number) {
|
||||
number = lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
void fromLua(lua_State* L, float& number) {
|
||||
number = (float)lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
|
@ -13,6 +13,7 @@ void toLua(lua_State* L, const std::string& string);
|
|||
void fromLua(lua_State* L, std::string& string);
|
||||
|
||||
void toLua(lua_State* L, int number);
|
||||
void toLua(lua_State* L, unsigned int number);
|
||||
|
||||
void fromLua(lua_State* L, int& number);
|
||||
|
||||
|
@ -20,6 +21,8 @@ void toLua(lua_State* L, double number);
|
|||
|
||||
void fromLua(lua_State* L, double& number);
|
||||
|
||||
void fromLua(lua_State* L, float& number);
|
||||
|
||||
template <typename T> void toLua(lua_State* L, const std::vector<T> vector) {
|
||||
lua_createtable(L, vector.size(), 0);
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "LuaGenerator.h"
|
||||
#include "../StringUtils.h"
|
||||
#include "LuaMesh.h"
|
||||
|
||||
std::unique_ptr<DataChunk> buildDataChunk(lua_State* L);
|
||||
|
||||
|
@ -114,6 +115,20 @@ std::unique_ptr<DataChunk> buildDataChunk(lua_State* L) {
|
|||
return buildStructureChunk(L);
|
||||
}
|
||||
|
||||
if (type == LUA_TUSERDATA) {
|
||||
if (luaIsLazyVector3DArray(L, -1)) {
|
||||
struct aiVector3DArray* array = (struct aiVector3DArray*)lua_touserdata(L, -1);
|
||||
|
||||
std::unique_ptr<StructureDataChunk> result(new StructureDataChunk());
|
||||
|
||||
for (int i = 0; i < array->length; ++i) {
|
||||
result->Add(std::unique_ptr<StructureDataChunk>(new StructureDataChunk(array->vertices[i])));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return std::unique_ptr<DataChunk>(nullptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ void generateFromLuaScript(
|
|||
lua_settop(L, stackSize);
|
||||
}
|
||||
|
||||
populateLuaScene(L, scene);
|
||||
populateLuaScene(L, scene, fileDefinition, settings);
|
||||
|
||||
std::string directory = DirectoryName(filename) + "/?.lua;";
|
||||
|
||||
|
|
40
skelatool64/src/lua_generator/LuaGeometry.cpp
Normal file
40
skelatool64/src/lua_generator/LuaGeometry.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include "LuaGeometry.h"
|
||||
|
||||
#include "LuaBasicTypes.h"
|
||||
|
||||
void toLua(lua_State* L, const aiVector3D& vector) {
|
||||
lua_getglobal(L, "vector3");
|
||||
toLua(L, vector.x);
|
||||
toLua(L, vector.y);
|
||||
toLua(L, vector.z);
|
||||
lua_call(L, 3, 1);
|
||||
}
|
||||
|
||||
void toLua(lua_State* L, const aiQuaternion& quaternion) {
|
||||
lua_getglobal(L, "quaternion");
|
||||
toLua(L, quaternion.x);
|
||||
toLua(L, quaternion.y);
|
||||
toLua(L, quaternion.z);
|
||||
toLua(L, quaternion.w);
|
||||
lua_call(L, 4, 1);
|
||||
}
|
||||
|
||||
void toLua(lua_State* L, const aiAABB& box) {
|
||||
lua_getglobal(L, "box3");
|
||||
toLua(L, box.mMin);
|
||||
toLua(L, box.mMax);
|
||||
lua_call(L, 2, 1);
|
||||
}
|
||||
|
||||
void fromLua(lua_State* L, aiVector3D& vector) {
|
||||
lua_getfield(L, -1, "x");
|
||||
fromLua(L, vector.x);
|
||||
|
||||
lua_getfield(L, -1, "y");
|
||||
fromLua(L, vector.y);
|
||||
|
||||
lua_getfield(L, -1, "z");
|
||||
fromLua(L, vector.z);
|
||||
|
||||
lua_pop(L, 1);
|
||||
}
|
13
skelatool64/src/lua_generator/LuaGeometry.h
Normal file
13
skelatool64/src/lua_generator/LuaGeometry.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#ifndef __LUA_GEOMETRY_H__
|
||||
#define __LUA_GEOMETRY_H__
|
||||
|
||||
#include <lua.hpp>
|
||||
#include <assimp/scene.h>
|
||||
|
||||
void toLua(lua_State* L, const aiQuaternion& quaternion);
|
||||
void toLua(lua_State* L, const aiVector3D& vector);
|
||||
void toLua(lua_State* L, const aiAABB& box);
|
||||
|
||||
void fromLua(lua_State* L, aiVector3D& vector);
|
||||
|
||||
#endif
|
|
@ -7,6 +7,71 @@
|
|||
#include "../MeshWriter.h"
|
||||
#include "./LuaDisplayListSettings.h"
|
||||
|
||||
#include "./LuaGeometry.h"
|
||||
#include "./LuaTransform.h"
|
||||
|
||||
int luaGetVector3ArrayElement(lua_State* L) {
|
||||
struct aiVector3DArray* array = (struct aiVector3DArray*)luaL_checkudata(L, 1, "aiVector3DArray");
|
||||
int index = luaL_checkinteger(L, 2);
|
||||
|
||||
if (index <= 0 || index > array->length) {
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
toLua(L, array->vertices[index - 1]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int luaSetVector3ArrayElement(lua_State* L) {
|
||||
lua_settop(L, 3);
|
||||
|
||||
aiVector3D value;
|
||||
fromLua(L, value);
|
||||
|
||||
struct aiVector3DArray* array = (struct aiVector3DArray*)luaL_checkudata(L, 1, "aiVector3DArray");
|
||||
int index = luaL_checkinteger(L, 2);
|
||||
|
||||
if (index <= 0 || index > array->length) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
array->vertices[index - 1] = value;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int luaGetVector3ArrayLength(lua_State* L) {
|
||||
struct aiVector3DArray* array = (struct aiVector3DArray*)luaL_checkudata(L, 1, "aiVector3DArray");
|
||||
lua_pushinteger(L, array->length);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void toLuaLazyArray(lua_State* L, aiVector3D* vertices, unsigned count) {
|
||||
struct aiVector3DArray* result = (struct aiVector3DArray*)lua_newuserdata(L, sizeof(struct aiVector3DArray));
|
||||
|
||||
result->vertices = vertices;
|
||||
result->length = count;
|
||||
|
||||
if(luaL_newmetatable(L, "aiVector3DArray")) {
|
||||
lua_pushcfunction(L, luaGetVector3ArrayElement);
|
||||
lua_setfield(L, -2, "__index");
|
||||
|
||||
lua_pushcfunction(L, luaSetVector3ArrayElement);
|
||||
lua_setfield(L, -2, "__newindex");
|
||||
|
||||
lua_pushcfunction(L, luaGetVector3ArrayLength);
|
||||
lua_setfield(L, -2, "__len");
|
||||
}
|
||||
|
||||
lua_setmetatable(L, -2);
|
||||
}
|
||||
|
||||
bool luaIsLazyVector3DArray(lua_State* L, int index) {
|
||||
return luaL_testudata(L, index, "aiVector3DArray");
|
||||
}
|
||||
|
||||
void toLua(lua_State* L, Material* material) {
|
||||
if (!material) {
|
||||
lua_pushnil(L);
|
||||
|
@ -15,7 +80,7 @@ void toLua(lua_State* L, Material* material) {
|
|||
|
||||
lua_createtable(L, 1, 0);
|
||||
|
||||
luaL_getmetatable(L, "Material");
|
||||
lua_getglobal(L, "Material");
|
||||
lua_setmetatable(L, -2);
|
||||
|
||||
toLua(L, material->mName);
|
||||
|
@ -40,11 +105,51 @@ void fromLua(lua_State* L, Material *& material) {
|
|||
lua_pop(L, 2);
|
||||
}
|
||||
|
||||
void toLua(lua_State* L, const aiFace& face) {
|
||||
toLua(L, face.mIndices, face.mNumIndices);
|
||||
}
|
||||
|
||||
int luaTransformMesh(lua_State* L) {
|
||||
lua_settop(L, 2);
|
||||
|
||||
aiMatrix4x4 transform;
|
||||
fromLua(L, transform);
|
||||
|
||||
std::shared_ptr<ExtendedMesh> mesh;
|
||||
meshFromLua(L, mesh);
|
||||
|
||||
std::shared_ptr<ExtendedMesh> result = mesh->Transform(transform);
|
||||
|
||||
meshToLua(L, result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void meshToLua(lua_State* L, std::shared_ptr<ExtendedMesh> mesh) {
|
||||
lua_createtable(L, 0, 1);
|
||||
|
||||
lua_getglobal(L, "Mesh");
|
||||
lua_setmetatable(L, -2);
|
||||
|
||||
toLua(L, mesh);
|
||||
lua_setfield(L, -2, "ptr");
|
||||
|
||||
toLua(L, mesh->bbMin);
|
||||
lua_setfield(L, -2, "bbMin");
|
||||
|
||||
toLua(L, mesh->bbMax);
|
||||
lua_setfield(L, -2, "bbMax");
|
||||
|
||||
lua_pushcfunction(L, luaTransformMesh);
|
||||
lua_setfield(L, -2, "transform");
|
||||
|
||||
toLuaLazyArray(L, mesh->mMesh->mVertices, mesh->mMesh->mNumVertices);
|
||||
lua_setfield(L, -2, "vertices");
|
||||
|
||||
toLuaLazyArray(L, mesh->mMesh->mNormals, mesh->mMesh->mNumVertices);
|
||||
lua_setfield(L, -2, "normals");
|
||||
|
||||
toLua(L, mesh->mMesh->mFaces, mesh->mMesh->mNumFaces);
|
||||
lua_setfield(L, -2, "faces");
|
||||
}
|
||||
|
||||
void meshFromLua(lua_State* L, std::shared_ptr<ExtendedMesh>& mesh) {
|
||||
|
@ -156,7 +261,10 @@ int luaGenerateMesh(lua_State* L) {
|
|||
|
||||
void populateLuaMesh(lua_State* L, const aiScene* scene, CFileDefinition& fileDefinition, const DisplayListSettings& settings) {
|
||||
lua_newtable(L);
|
||||
luaL_setmetatable(L, "Material");
|
||||
lua_setglobal(L, "Material");
|
||||
|
||||
lua_newtable(L);
|
||||
lua_setglobal(L, "Mesh");
|
||||
|
||||
lua_pushlightuserdata(L, const_cast<aiScene*>(scene));
|
||||
lua_pushlightuserdata(L, &fileDefinition);
|
||||
|
|
|
@ -6,7 +6,15 @@
|
|||
#include "../CFileDefinition.h"
|
||||
#include "../DisplayListSettings.h"
|
||||
|
||||
struct aiVector3DArray {
|
||||
aiVector3D* vertices;
|
||||
int length;
|
||||
};
|
||||
|
||||
void fromLua(lua_State* L, Material *& material);
|
||||
void meshToLua(lua_State* L, std::shared_ptr<ExtendedMesh> mesh);
|
||||
void meshFromLua(lua_State* L, std::shared_ptr<ExtendedMesh>& mesh);
|
||||
bool luaIsLazyVector3DArray(lua_State* L, int index);
|
||||
|
||||
void populateLuaMesh(lua_State* L, const aiScene* scene, CFileDefinition& fileDefinition, const DisplayListSettings& settings);
|
||||
|
||||
|
|
|
@ -1,9 +1,19 @@
|
|||
/// Scene functions
|
||||
|
||||
#include "LuaScene.h"
|
||||
|
||||
#include "LuaBasicTypes.h"
|
||||
#include "LuaTransform.h"
|
||||
#include "LuaMesh.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "../definition_generator/MeshDefinitionGenerator.h"
|
||||
|
||||
const aiScene* gLuaCurrentScene;
|
||||
CFileDefinition* gLuaCurrentFileDefinition;
|
||||
const DisplayListSettings* gLuaCurrentSettings;
|
||||
|
||||
|
||||
aiMatrix4x4 nodeFullTrasformation(lua_State* L, const aiNode* node) {
|
||||
aiMatrix4x4 result;
|
||||
|
||||
|
@ -22,6 +32,10 @@ aiMatrix4x4 nodeFullTrasformation(lua_State* L, const aiNode* node) {
|
|||
return (*modelTransform) * result;
|
||||
}
|
||||
|
||||
void luaGetMeshByIndex(lua_State* L, int indexAt0) {
|
||||
meshToLua(L, gLuaCurrentFileDefinition->GetExtendedMesh(gLuaCurrentScene->mMeshes[indexAt0]));
|
||||
}
|
||||
|
||||
void toLua(lua_State* L, const aiNode* node) {
|
||||
if (!node) {
|
||||
lua_pushnil(L);
|
||||
|
@ -70,6 +84,13 @@ void toLua(lua_State* L, const aiNode* node) {
|
|||
toLua(L, node->mChildren, node->mNumChildren);
|
||||
lua_setfield(L, tableIndex, "children");
|
||||
|
||||
lua_createtable(L, node->mNumMeshes, 0);
|
||||
for (unsigned i = 0; i < node->mNumMeshes; ++i) {
|
||||
luaGetMeshByIndex(L, node->mMeshes[i]);
|
||||
lua_seti(L, -2, i + 1);
|
||||
}
|
||||
lua_setfield(L, tableIndex, "meshes");
|
||||
|
||||
lua_remove(L, nodeCache);
|
||||
}
|
||||
|
||||
|
@ -123,7 +144,7 @@ void toLua(lua_State* L, const aiCamera* camera) {
|
|||
lua_setfield(L, -2, "local_transform");
|
||||
}
|
||||
|
||||
void toLua(lua_State* L, const aiScene* scene) {
|
||||
void toLua(lua_State* L, const aiScene* scene, CFileDefinition& fileDefinition) {
|
||||
lua_createtable(L, 0, 2);
|
||||
int tableIndex = lua_gettop(L);
|
||||
luaL_getmetatable(L, "aiScene");
|
||||
|
@ -137,12 +158,59 @@ void toLua(lua_State* L, const aiScene* scene) {
|
|||
|
||||
toLua(L, scene->mCameras, scene->mNumCameras);
|
||||
lua_setfield(L, tableIndex, "cameras");
|
||||
|
||||
lua_createtable(L, scene->mNumMeshes, 0);
|
||||
for (unsigned i = 0; i < scene->mNumMeshes; ++i) {
|
||||
meshToLua(L, fileDefinition.GetExtendedMesh(scene->mMeshes[i]));
|
||||
lua_seti(L, -2, i + 1);
|
||||
}
|
||||
lua_setfield(L, tableIndex, "meshes");
|
||||
}
|
||||
|
||||
void populateLuaScene(lua_State* L, const aiScene* scene) {
|
||||
/***
|
||||
Generates mesh and animation data from the current scene
|
||||
@function export_default_mesh
|
||||
*/
|
||||
int luaExportDefaultMesh(lua_State* L) {
|
||||
const aiScene* scene = (const aiScene*)lua_touserdata(L, lua_upvalueindex(1));
|
||||
CFileDefinition* fileDefinition = (CFileDefinition*)lua_touserdata(L, lua_upvalueindex(2));
|
||||
DisplayListSettings* settings = (DisplayListSettings*)lua_touserdata(L, lua_upvalueindex(3));
|
||||
|
||||
MeshDefinitionGenerator meshGenerator(*settings);
|
||||
std::cout << "Generating mesh definitions" << std::endl;
|
||||
meshGenerator.TraverseScene(scene);
|
||||
MeshDefinitionResults results = meshGenerator.GenerateDefinitionsWithResults(scene, *fileDefinition);
|
||||
|
||||
|
||||
lua_createtable(L, 0, 2);
|
||||
|
||||
lua_getglobal(L, "raw");
|
||||
toLua(L, results.modelName);
|
||||
lua_call(L, 1, 1);
|
||||
lua_setfield(L, -2, "model");
|
||||
|
||||
lua_getglobal(L, "raw");
|
||||
toLua(L, results.materialMacro);
|
||||
lua_call(L, 1, 1);
|
||||
lua_setfield(L, -2, "material");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void populateLuaScene(lua_State* L, const aiScene* scene, CFileDefinition& fileDefinition, const DisplayListSettings& settings) {
|
||||
gLuaCurrentScene = scene;
|
||||
gLuaCurrentFileDefinition = &fileDefinition;
|
||||
gLuaCurrentSettings = &settings;
|
||||
|
||||
lua_newtable(L);
|
||||
lua_setglobal(L, "node_cache");
|
||||
|
||||
toLua(L, scene);
|
||||
toLua(L, scene, fileDefinition);
|
||||
lua_setglobal(L, "scene");
|
||||
|
||||
lua_pushlightuserdata(L, const_cast<aiScene*>(scene));
|
||||
lua_pushlightuserdata(L, &fileDefinition);
|
||||
lua_pushlightuserdata(L, const_cast<DisplayListSettings*>(&settings));
|
||||
lua_pushcclosure(L, luaExportDefaultMesh, 3);
|
||||
lua_setglobal(L, "export_default_mesh");
|
||||
}
|
|
@ -4,10 +4,13 @@
|
|||
#include <assimp/scene.h>
|
||||
#include <lua.hpp>
|
||||
|
||||
#include "../DisplayListSettings.h"
|
||||
#include "../CFileDefinition.h"
|
||||
|
||||
void toLua(lua_State* L, const aiNode* node);
|
||||
|
||||
void fromLua(lua_State* L, aiNode *& node);
|
||||
|
||||
void populateLuaScene(lua_State* L, const aiScene* scene);
|
||||
void populateLuaScene(lua_State* L, const aiScene* scene, CFileDefinition& fileDefinition, const DisplayListSettings& setting);
|
||||
|
||||
#endif
|
|
@ -2,23 +2,6 @@
|
|||
|
||||
#include "LuaBasicTypes.h"
|
||||
|
||||
void toLua(lua_State* L, const aiVector3D& vector) {
|
||||
lua_getglobal(L, "vector3");
|
||||
toLua(L, vector.x);
|
||||
toLua(L, vector.y);
|
||||
toLua(L, vector.z);
|
||||
lua_call(L, 3, 1);
|
||||
}
|
||||
|
||||
void toLua(lua_State* L, const aiQuaternion& quaternion) {
|
||||
lua_getglobal(L, "quaternion");
|
||||
toLua(L, quaternion.x);
|
||||
toLua(L, quaternion.y);
|
||||
toLua(L, quaternion.z);
|
||||
toLua(L, quaternion.w);
|
||||
lua_call(L, 4, 1);
|
||||
}
|
||||
|
||||
void toLua(lua_State* L, const aiMatrix4x4& matrix) {
|
||||
aiMatrix4x4* result = (aiMatrix4x4*)lua_newuserdata(L, sizeof(aiMatrix4x4));
|
||||
new(result) aiMatrix4x4(matrix);
|
||||
|
@ -27,6 +10,15 @@ void toLua(lua_State* L, const aiMatrix4x4& matrix) {
|
|||
lua_setmetatable(L, -2);
|
||||
}
|
||||
|
||||
|
||||
void fromLua(lua_State* L, aiMatrix4x4& matrix) {
|
||||
aiMatrix4x4* ptr = (aiMatrix4x4*)luaL_checkudata(L, -1, "aiMatrix4x4");
|
||||
if (ptr) {
|
||||
matrix = *ptr;
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
int luaTransformDecomponse(lua_State* L) {
|
||||
aiMatrix4x4* mtx = (aiMatrix4x4*)luaL_checkudata(L, 1, "aiMatrix4x4");
|
||||
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
#include <lua.hpp>
|
||||
#include <assimp/scene.h>
|
||||
|
||||
#include "LuaGeometry.h"
|
||||
|
||||
void toLua(lua_State* L, const aiMatrix4x4& matrix);
|
||||
void toLua(lua_State* L, const aiVector3D& vector);
|
||||
void toLua(lua_State* L, const aiQuaternion& quaternion);
|
||||
void fromLua(lua_State* L, aiMatrix4x4& matrix);
|
||||
|
||||
void generateLuaTransform(lua_State* L);
|
||||
|
||||
|
|
Loading…
Reference in a new issue