back-face culling performance boost!

This commit is contained in:
wgroeneveld 2020-07-15 12:03:50 +02:00
parent 52b55d91e6
commit 47d685a41c
15 changed files with 174 additions and 918 deletions

View File

@ -56,6 +56,16 @@ There is a fast way to lines into VRAM. I tried implementing Z-buffering, but th
At this point, I do not think it's that interesting to go on to texture mapping other than the fun of it. Even with a lot of haxx and tricks, the colored monkey won't ever spin at 30FPS...
#### **Demo 3b**: with back-face culling
It did improve performance. I exported a few Babylon meshes, and the octahedron with 8 faces does run at 20FPS compared to 11FPS when back-face culling was implemented (that omits rendering certain faces if z < 0)
![design](https://github.com/wgroeneveld/gba-bitmap-engine/blob/master/img/octa.gif?raw=true)
Changing colors indicate certain triangles were not drawn (into the background). It does not help a lot with our monkey, alas. Too many vertices...
More examples of meshes (box, cylinder, octahedron, sphere, torus) included.
### GBA-Specific problems
**Fixed-point math** sums up things nicely.

View File

@ -23,9 +23,13 @@ function addMesh(x, y, z) {
result += `\t obj->add(VectorFx::fromFloat(${x}, ${y}, ${z}));\n`;
vertices++;
}
function addMeshWithNormals(x, y, z, nx, ny, nz) {
result += `\t obj->add(VectorFx::fromFloat(${x}, ${y}, ${z}), VectorFx::fromFloat(${nx}, ${ny}, ${nz}));\n`;
vertices++;
}
var faces = 0;
function addFace(a, b, c) {
result += `\t obj->addFace({ ${a}, ${b}, ${c}});\n`;
result += `\t obj->addFace(${a}, ${b}, ${c});\n`;
faces++;
}
function setPosition(position) {
@ -39,14 +43,14 @@ function done() {
for(var meshIndex = 0; meshIndex < jsonObject.meshes.length; meshIndex++) {
const mesh = jsonObject.meshes[meshIndex];
var data = undefined;
var verticesArray = mesh.vertices;
var indicesArray = mesh.indices;
var uvCount = mesh.uvCount;
if(mesh.geometryId) {
const data = jsonObject.geometries.vertexData.find(v => v.id === mesh.geometryId);
verticesArray = data.positions
indicesArray = data.indices
// also contains .normals and .uvs
data = jsonObject.geometries.vertexData.find(v => v.id === mesh.geometryId);
verticesArray = data.positions;
indicesArray = data.indices;
}
var verticesStep = 1;
@ -73,7 +77,19 @@ for(var meshIndex = 0; meshIndex < jsonObject.meshes.length; meshIndex++) {
var z = verticesArray[index * verticesStep + 2];
if(x !== undefined && y !== undefined && z !== undefined) {
addMesh(x, y, z);
if(data && data.normals) {
var nx = data.normals[index * verticesStep];
var ny = data.normals[index * verticesStep + 1];
var nz = data.normals[index * verticesStep + 2];
addMeshWithNormals(x, y, z, nx, ny, nz);
} else {
var nx = verticesArray[index * verticesStep + 3];
var ny = verticesArray[index * verticesStep + 4];
var nz = verticesArray[index * verticesStep + 5];
addMeshWithNormals(x, y, z, nx, ny, nz);
}
} else {
console.log(`WARN; vertices index ${index} with step ${verticesStep} contains invalid data: ${x}, ${y}, ${z}`)
}

View File

@ -1,873 +1,38 @@
#include <libgba-bitmap-engine/mesh.h>
Mesh* createMesh() {
auto obj = new Mesh();
obj->add(VectorFx::fromFloat(1.5308085657314598e-17, 3.061616997868383e-17, 0.25));
obj->add(VectorFx::fromFloat(1.647334429390665e-17, -0.09567085809127242, 0.26903011687217826));
obj->add(VectorFx::fromFloat(1.9791720139357513e-17, -0.17677669529663687, 0.3232233047033631));
obj->add(VectorFx::fromFloat(2.4758020552349235e-17, -0.23096988312782163, 0.40432914190872743));
obj->add(VectorFx::fromFloat(3.0616171314629196e-17, -0.25, 0.49999999999999994));
obj->add(VectorFx::fromFloat(3.6474322076909154e-17, -0.23096988312782166, 0.5956708580912725));
obj->add(VectorFx::fromFloat(4.1440622489900873e-17, -0.17677669529663692, 0.6767766952966369));
obj->add(VectorFx::fromFloat(4.475899833535174e-17, -0.0956708580912726, 0.7309698831278216));
obj->add(VectorFx::fromFloat(4.5924256971943795e-17, -6.123233995736766e-17, 0.75));
obj->add(VectorFx::fromFloat(4.475899833535174e-17, 0.09567085809127249, 0.7309698831278217));
obj->add(VectorFx::fromFloat(4.144062248990088e-17, 0.17677669529663684, 0.676776695296637));
obj->add(VectorFx::fromFloat(3.647432207690916e-17, 0.23096988312782163, 0.5956708580912726));
obj->add(VectorFx::fromFloat(3.06161713146292e-17, 0.25, 0.5000000000000001));
obj->add(VectorFx::fromFloat(2.4758020552349244e-17, 0.23096988312782168, 0.40432914190872754));
obj->add(VectorFx::fromFloat(1.979172013935753e-17, 0.1767766952966371, 0.32322330470336336));
obj->add(VectorFx::fromFloat(1.6473344293906656e-17, 0.09567085809127263, 0.26903011687217837));
obj->add(VectorFx::fromFloat(1.5308085657314598e-17, 9.184850993605148e-17, 0.25));
obj->add(VectorFx::fromFloat(0.09567085653543472, 3.061616997868383e-17, 0.2309698760509491));
obj->add(VectorFx::fromFloat(0.10295336685995762, -0.09567085809127242, 0.24855141099175748));
obj->add(VectorFx::fromFloat(0.12369220165273821, -0.17677669529663687, 0.2986193864964557));
obj->add(VectorFx::fromFloat(0.15473006131458114, -0.23096988312782163, 0.37355140716178153));
obj->add(VectorFx::fromFloat(0.19134171307086942, -0.25, 0.46193975210189814));
obj->add(VectorFx::fromFloat(0.22795336482715772, -0.23096988312782166, 0.5503280970420148));
obj->add(VectorFx::fromFloat(0.25899122448900064, -0.17677669529663692, 0.6252601177073406));
obj->add(VectorFx::fromFloat(0.27973005928178124, -0.0956708580912726, 0.6753280932120389));
obj->add(VectorFx::fromFloat(0.28701256960630417, -6.123233995736766e-17, 0.6929096281528473));
obj->add(VectorFx::fromFloat(0.27973005928178124, 0.09567085809127249, 0.6753280932120389));
obj->add(VectorFx::fromFloat(0.2589912244890007, 0.17677669529663684, 0.6252601177073407));
obj->add(VectorFx::fromFloat(0.22795336482715775, 0.23096988312782163, 0.5503280970420149));
obj->add(VectorFx::fromFloat(0.19134171307086947, 0.25, 0.46193975210189825));
obj->add(VectorFx::fromFloat(0.1547300613145812, 0.23096988312782168, 0.3735514071617816));
obj->add(VectorFx::fromFloat(0.12369220165273831, 0.1767766952966371, 0.2986193864964559));
obj->add(VectorFx::fromFloat(0.10295336685995767, 0.09567085809127263, 0.24855141099175757));
obj->add(VectorFx::fromFloat(0.09567085653543472, 9.184850993605148e-17, 0.2309698760509491));
obj->add(VectorFx::fromFloat(0.1767766922712326, 3.061616997868383e-17, 0.1767766922712326));
obj->add(VectorFx::fromFloat(0.19023301672802723, -0.09567085809127242, 0.19023301672802723));
obj->add(VectorFx::fromFloat(0.22855338668174907, -0.17677669529663687, 0.22855338668174907));
obj->add(VectorFx::fromFloat(0.2859038731819626, -0.23096988312782163, 0.2859038731819626));
obj->add(VectorFx::fromFloat(0.35355338454246515, -0.25, 0.35355338454246515));
obj->add(VectorFx::fromFloat(0.4212028959029678, -0.23096988312782166, 0.4212028959029678));
obj->add(VectorFx::fromFloat(0.4785533824031813, -0.17677669529663692, 0.4785533824031813));
obj->add(VectorFx::fromFloat(0.5168737523569031, -0.0956708580912726, 0.5168737523569031));
obj->add(VectorFx::fromFloat(0.5303300768136978, -6.123233995736766e-17, 0.5303300768136978));
obj->add(VectorFx::fromFloat(0.5168737523569031, 0.09567085809127249, 0.5168737523569031));
obj->add(VectorFx::fromFloat(0.47855338240318135, 0.17677669529663684, 0.47855338240318135));
obj->add(VectorFx::fromFloat(0.4212028959029679, 0.23096988312782163, 0.4212028959029679));
obj->add(VectorFx::fromFloat(0.35355338454246527, 0.25, 0.35355338454246527));
obj->add(VectorFx::fromFloat(0.28590387318196264, 0.23096988312782168, 0.28590387318196264));
obj->add(VectorFx::fromFloat(0.22855338668174924, 0.1767766952966371, 0.22855338668174924));
obj->add(VectorFx::fromFloat(0.19023301672802728, 0.09567085809127263, 0.19023301672802728));
obj->add(VectorFx::fromFloat(0.1767766922712326, 9.184850993605148e-17, 0.1767766922712326));
obj->add(VectorFx::fromFloat(0.2309698760509491, 3.061616997868383e-17, 0.09567085653543472));
obj->add(VectorFx::fromFloat(0.24855141099175748, -0.09567085809127242, 0.10295336685995762));
obj->add(VectorFx::fromFloat(0.2986193864964557, -0.17677669529663687, 0.12369220165273821));
obj->add(VectorFx::fromFloat(0.37355140716178153, -0.23096988312782163, 0.15473006131458114));
obj->add(VectorFx::fromFloat(0.46193975210189814, -0.25, 0.19134171307086942));
obj->add(VectorFx::fromFloat(0.5503280970420148, -0.23096988312782166, 0.22795336482715772));
obj->add(VectorFx::fromFloat(0.6252601177073406, -0.17677669529663692, 0.25899122448900064));
obj->add(VectorFx::fromFloat(0.6753280932120389, -0.0956708580912726, 0.27973005928178124));
obj->add(VectorFx::fromFloat(0.6929096281528473, -6.123233995736766e-17, 0.28701256960630417));
obj->add(VectorFx::fromFloat(0.6753280932120389, 0.09567085809127249, 0.27973005928178124));
obj->add(VectorFx::fromFloat(0.6252601177073407, 0.17677669529663684, 0.2589912244890007));
obj->add(VectorFx::fromFloat(0.5503280970420149, 0.23096988312782163, 0.22795336482715775));
obj->add(VectorFx::fromFloat(0.46193975210189825, 0.25, 0.19134171307086947));
obj->add(VectorFx::fromFloat(0.3735514071617816, 0.23096988312782168, 0.1547300613145812));
obj->add(VectorFx::fromFloat(0.2986193864964559, 0.1767766952966371, 0.12369220165273831));
obj->add(VectorFx::fromFloat(0.24855141099175757, 0.09567085809127263, 0.10295336685995767));
obj->add(VectorFx::fromFloat(0.2309698760509491, 9.184850993605148e-17, 0.09567085653543472));
obj->add(VectorFx::fromFloat(0.25, 3.061616997868383e-17, 0));
obj->add(VectorFx::fromFloat(0.26903011687217826, -0.09567085809127242, 0));
obj->add(VectorFx::fromFloat(0.3232233047033631, -0.17677669529663687, 0));
obj->add(VectorFx::fromFloat(0.40432914190872743, -0.23096988312782163, 0));
obj->add(VectorFx::fromFloat(0.49999999999999994, -0.25, 0));
obj->add(VectorFx::fromFloat(0.5956708580912725, -0.23096988312782166, 0));
obj->add(VectorFx::fromFloat(0.6767766952966369, -0.17677669529663692, 0));
obj->add(VectorFx::fromFloat(0.7309698831278216, -0.0956708580912726, 0));
obj->add(VectorFx::fromFloat(0.75, -6.123233995736766e-17, 0));
obj->add(VectorFx::fromFloat(0.7309698831278217, 0.09567085809127249, 0));
obj->add(VectorFx::fromFloat(0.676776695296637, 0.17677669529663684, 0));
obj->add(VectorFx::fromFloat(0.5956708580912726, 0.23096988312782163, 0));
obj->add(VectorFx::fromFloat(0.5000000000000001, 0.25, 0));
obj->add(VectorFx::fromFloat(0.40432914190872754, 0.23096988312782168, 0));
obj->add(VectorFx::fromFloat(0.32322330470336336, 0.1767766952966371, 0));
obj->add(VectorFx::fromFloat(0.26903011687217837, 0.09567085809127263, 0));
obj->add(VectorFx::fromFloat(0.25, 9.184850993605148e-17, 0));
obj->add(VectorFx::fromFloat(0.2309698760509491, 3.061616997868383e-17, -0.09567085653543472));
obj->add(VectorFx::fromFloat(0.24855141099175748, -0.09567085809127242, -0.10295336685995762));
obj->add(VectorFx::fromFloat(0.2986193864964557, -0.17677669529663687, -0.12369220165273821));
obj->add(VectorFx::fromFloat(0.37355140716178153, -0.23096988312782163, -0.15473006131458114));
obj->add(VectorFx::fromFloat(0.46193975210189814, -0.25, -0.19134171307086942));
obj->add(VectorFx::fromFloat(0.5503280970420148, -0.23096988312782166, -0.22795336482715772));
obj->add(VectorFx::fromFloat(0.6252601177073406, -0.17677669529663692, -0.25899122448900064));
obj->add(VectorFx::fromFloat(0.6753280932120389, -0.0956708580912726, -0.27973005928178124));
obj->add(VectorFx::fromFloat(0.6929096281528473, -6.123233995736766e-17, -0.28701256960630417));
obj->add(VectorFx::fromFloat(0.6753280932120389, 0.09567085809127249, -0.27973005928178124));
obj->add(VectorFx::fromFloat(0.6252601177073407, 0.17677669529663684, -0.2589912244890007));
obj->add(VectorFx::fromFloat(0.5503280970420149, 0.23096988312782163, -0.22795336482715775));
obj->add(VectorFx::fromFloat(0.46193975210189825, 0.25, -0.19134171307086947));
obj->add(VectorFx::fromFloat(0.3735514071617816, 0.23096988312782168, -0.1547300613145812));
obj->add(VectorFx::fromFloat(0.2986193864964559, 0.1767766952966371, -0.12369220165273831));
obj->add(VectorFx::fromFloat(0.24855141099175757, 0.09567085809127263, -0.10295336685995767));
obj->add(VectorFx::fromFloat(0.2309698760509491, 9.184850993605148e-17, -0.09567085653543472));
obj->add(VectorFx::fromFloat(0.1767766922712326, 3.061616997868383e-17, -0.1767766922712326));
obj->add(VectorFx::fromFloat(0.19023301672802723, -0.09567085809127242, -0.19023301672802723));
obj->add(VectorFx::fromFloat(0.22855338668174907, -0.17677669529663687, -0.22855338668174907));
obj->add(VectorFx::fromFloat(0.2859038731819626, -0.23096988312782163, -0.2859038731819626));
obj->add(VectorFx::fromFloat(0.35355338454246515, -0.25, -0.35355338454246515));
obj->add(VectorFx::fromFloat(0.4212028959029678, -0.23096988312782166, -0.4212028959029678));
obj->add(VectorFx::fromFloat(0.4785533824031813, -0.17677669529663692, -0.4785533824031813));
obj->add(VectorFx::fromFloat(0.5168737523569031, -0.0956708580912726, -0.5168737523569031));
obj->add(VectorFx::fromFloat(0.5303300768136978, -6.123233995736766e-17, -0.5303300768136978));
obj->add(VectorFx::fromFloat(0.5168737523569031, 0.09567085809127249, -0.5168737523569031));
obj->add(VectorFx::fromFloat(0.47855338240318135, 0.17677669529663684, -0.47855338240318135));
obj->add(VectorFx::fromFloat(0.4212028959029679, 0.23096988312782163, -0.4212028959029679));
obj->add(VectorFx::fromFloat(0.35355338454246527, 0.25, -0.35355338454246527));
obj->add(VectorFx::fromFloat(0.28590387318196264, 0.23096988312782168, -0.28590387318196264));
obj->add(VectorFx::fromFloat(0.22855338668174924, 0.1767766952966371, -0.22855338668174924));
obj->add(VectorFx::fromFloat(0.19023301672802728, 0.09567085809127263, -0.19023301672802728));
obj->add(VectorFx::fromFloat(0.1767766922712326, 9.184850993605148e-17, -0.1767766922712326));
obj->add(VectorFx::fromFloat(0.09567085653543472, 3.061616997868383e-17, -0.2309698760509491));
obj->add(VectorFx::fromFloat(0.10295336685995762, -0.09567085809127242, -0.24855141099175748));
obj->add(VectorFx::fromFloat(0.12369220165273821, -0.17677669529663687, -0.2986193864964557));
obj->add(VectorFx::fromFloat(0.15473006131458114, -0.23096988312782163, -0.37355140716178153));
obj->add(VectorFx::fromFloat(0.19134171307086942, -0.25, -0.46193975210189814));
obj->add(VectorFx::fromFloat(0.22795336482715772, -0.23096988312782166, -0.5503280970420148));
obj->add(VectorFx::fromFloat(0.25899122448900064, -0.17677669529663692, -0.6252601177073406));
obj->add(VectorFx::fromFloat(0.27973005928178124, -0.0956708580912726, -0.6753280932120389));
obj->add(VectorFx::fromFloat(0.28701256960630417, -6.123233995736766e-17, -0.6929096281528473));
obj->add(VectorFx::fromFloat(0.27973005928178124, 0.09567085809127249, -0.6753280932120389));
obj->add(VectorFx::fromFloat(0.2589912244890007, 0.17677669529663684, -0.6252601177073407));
obj->add(VectorFx::fromFloat(0.22795336482715775, 0.23096988312782163, -0.5503280970420149));
obj->add(VectorFx::fromFloat(0.19134171307086947, 0.25, -0.46193975210189825));
obj->add(VectorFx::fromFloat(0.1547300613145812, 0.23096988312782168, -0.3735514071617816));
obj->add(VectorFx::fromFloat(0.12369220165273831, 0.1767766952966371, -0.2986193864964559));
obj->add(VectorFx::fromFloat(0.10295336685995767, 0.09567085809127263, -0.24855141099175757));
obj->add(VectorFx::fromFloat(0.09567085653543472, 9.184850993605148e-17, -0.2309698760509491));
obj->add(VectorFx::fromFloat(1.5308085657314598e-17, 3.061616997868383e-17, -0.25));
obj->add(VectorFx::fromFloat(1.647334429390665e-17, -0.09567085809127242, -0.26903011687217826));
obj->add(VectorFx::fromFloat(1.9791720139357513e-17, -0.17677669529663687, -0.3232233047033631));
obj->add(VectorFx::fromFloat(2.4758020552349235e-17, -0.23096988312782163, -0.40432914190872743));
obj->add(VectorFx::fromFloat(3.0616171314629196e-17, -0.25, -0.49999999999999994));
obj->add(VectorFx::fromFloat(3.6474322076909154e-17, -0.23096988312782166, -0.5956708580912725));
obj->add(VectorFx::fromFloat(4.1440622489900873e-17, -0.17677669529663692, -0.6767766952966369));
obj->add(VectorFx::fromFloat(4.475899833535174e-17, -0.0956708580912726, -0.7309698831278216));
obj->add(VectorFx::fromFloat(4.5924256971943795e-17, -6.123233995736766e-17, -0.75));
obj->add(VectorFx::fromFloat(4.475899833535174e-17, 0.09567085809127249, -0.7309698831278217));
obj->add(VectorFx::fromFloat(4.144062248990088e-17, 0.17677669529663684, -0.676776695296637));
obj->add(VectorFx::fromFloat(3.647432207690916e-17, 0.23096988312782163, -0.5956708580912726));
obj->add(VectorFx::fromFloat(3.06161713146292e-17, 0.25, -0.5000000000000001));
obj->add(VectorFx::fromFloat(2.4758020552349244e-17, 0.23096988312782168, -0.40432914190872754));
obj->add(VectorFx::fromFloat(1.979172013935753e-17, 0.1767766952966371, -0.32322330470336336));
obj->add(VectorFx::fromFloat(1.6473344293906656e-17, 0.09567085809127263, -0.26903011687217837));
obj->add(VectorFx::fromFloat(1.5308085657314598e-17, 9.184850993605148e-17, -0.25));
obj->add(VectorFx::fromFloat(-0.09567085653543472, 3.061616997868383e-17, -0.2309698760509491));
obj->add(VectorFx::fromFloat(-0.10295336685995762, -0.09567085809127242, -0.24855141099175748));
obj->add(VectorFx::fromFloat(-0.12369220165273821, -0.17677669529663687, -0.2986193864964557));
obj->add(VectorFx::fromFloat(-0.15473006131458114, -0.23096988312782163, -0.37355140716178153));
obj->add(VectorFx::fromFloat(-0.19134171307086942, -0.25, -0.46193975210189814));
obj->add(VectorFx::fromFloat(-0.22795336482715772, -0.23096988312782166, -0.5503280970420148));
obj->add(VectorFx::fromFloat(-0.25899122448900064, -0.17677669529663692, -0.6252601177073406));
obj->add(VectorFx::fromFloat(-0.27973005928178124, -0.0956708580912726, -0.6753280932120389));
obj->add(VectorFx::fromFloat(-0.28701256960630417, -6.123233995736766e-17, -0.6929096281528473));
obj->add(VectorFx::fromFloat(-0.27973005928178124, 0.09567085809127249, -0.6753280932120389));
obj->add(VectorFx::fromFloat(-0.2589912244890007, 0.17677669529663684, -0.6252601177073407));
obj->add(VectorFx::fromFloat(-0.22795336482715775, 0.23096988312782163, -0.5503280970420149));
obj->add(VectorFx::fromFloat(-0.19134171307086947, 0.25, -0.46193975210189825));
obj->add(VectorFx::fromFloat(-0.1547300613145812, 0.23096988312782168, -0.3735514071617816));
obj->add(VectorFx::fromFloat(-0.12369220165273831, 0.1767766952966371, -0.2986193864964559));
obj->add(VectorFx::fromFloat(-0.10295336685995767, 0.09567085809127263, -0.24855141099175757));
obj->add(VectorFx::fromFloat(-0.09567085653543472, 9.184850993605148e-17, -0.2309698760509491));
obj->add(VectorFx::fromFloat(-0.1767766922712326, 3.061616997868383e-17, -0.1767766922712326));
obj->add(VectorFx::fromFloat(-0.19023301672802723, -0.09567085809127242, -0.19023301672802723));
obj->add(VectorFx::fromFloat(-0.22855338668174907, -0.17677669529663687, -0.22855338668174907));
obj->add(VectorFx::fromFloat(-0.2859038731819626, -0.23096988312782163, -0.2859038731819626));
obj->add(VectorFx::fromFloat(-0.35355338454246515, -0.25, -0.35355338454246515));
obj->add(VectorFx::fromFloat(-0.4212028959029678, -0.23096988312782166, -0.4212028959029678));
obj->add(VectorFx::fromFloat(-0.4785533824031813, -0.17677669529663692, -0.4785533824031813));
obj->add(VectorFx::fromFloat(-0.5168737523569031, -0.0956708580912726, -0.5168737523569031));
obj->add(VectorFx::fromFloat(-0.5303300768136978, -6.123233995736766e-17, -0.5303300768136978));
obj->add(VectorFx::fromFloat(-0.5168737523569031, 0.09567085809127249, -0.5168737523569031));
obj->add(VectorFx::fromFloat(-0.47855338240318135, 0.17677669529663684, -0.47855338240318135));
obj->add(VectorFx::fromFloat(-0.4212028959029679, 0.23096988312782163, -0.4212028959029679));
obj->add(VectorFx::fromFloat(-0.35355338454246527, 0.25, -0.35355338454246527));
obj->add(VectorFx::fromFloat(-0.28590387318196264, 0.23096988312782168, -0.28590387318196264));
obj->add(VectorFx::fromFloat(-0.22855338668174924, 0.1767766952966371, -0.22855338668174924));
obj->add(VectorFx::fromFloat(-0.19023301672802728, 0.09567085809127263, -0.19023301672802728));
obj->add(VectorFx::fromFloat(-0.1767766922712326, 9.184850993605148e-17, -0.1767766922712326));
obj->add(VectorFx::fromFloat(-0.2309698760509491, 3.061616997868383e-17, -0.09567085653543472));
obj->add(VectorFx::fromFloat(-0.24855141099175748, -0.09567085809127242, -0.10295336685995762));
obj->add(VectorFx::fromFloat(-0.2986193864964557, -0.17677669529663687, -0.12369220165273821));
obj->add(VectorFx::fromFloat(-0.37355140716178153, -0.23096988312782163, -0.15473006131458114));
obj->add(VectorFx::fromFloat(-0.46193975210189814, -0.25, -0.19134171307086942));
obj->add(VectorFx::fromFloat(-0.5503280970420148, -0.23096988312782166, -0.22795336482715772));
obj->add(VectorFx::fromFloat(-0.6252601177073406, -0.17677669529663692, -0.25899122448900064));
obj->add(VectorFx::fromFloat(-0.6753280932120389, -0.0956708580912726, -0.27973005928178124));
obj->add(VectorFx::fromFloat(-0.6929096281528473, -6.123233995736766e-17, -0.28701256960630417));
obj->add(VectorFx::fromFloat(-0.6753280932120389, 0.09567085809127249, -0.27973005928178124));
obj->add(VectorFx::fromFloat(-0.6252601177073407, 0.17677669529663684, -0.2589912244890007));
obj->add(VectorFx::fromFloat(-0.5503280970420149, 0.23096988312782163, -0.22795336482715775));
obj->add(VectorFx::fromFloat(-0.46193975210189825, 0.25, -0.19134171307086947));
obj->add(VectorFx::fromFloat(-0.3735514071617816, 0.23096988312782168, -0.1547300613145812));
obj->add(VectorFx::fromFloat(-0.2986193864964559, 0.1767766952966371, -0.12369220165273831));
obj->add(VectorFx::fromFloat(-0.24855141099175757, 0.09567085809127263, -0.10295336685995767));
obj->add(VectorFx::fromFloat(-0.2309698760509491, 9.184850993605148e-17, -0.09567085653543472));
obj->add(VectorFx::fromFloat(-0.25, 3.061616997868383e-17, -3.0616171314629196e-17));
obj->add(VectorFx::fromFloat(-0.26903011687217826, -0.09567085809127242, -3.29466885878133e-17));
obj->add(VectorFx::fromFloat(-0.3232233047033631, -0.17677669529663687, -3.9583440278715026e-17));
obj->add(VectorFx::fromFloat(-0.40432914190872743, -0.23096988312782163, -4.951604110469847e-17));
obj->add(VectorFx::fromFloat(-0.49999999999999994, -0.25, -6.123234262925839e-17));
obj->add(VectorFx::fromFloat(-0.5956708580912725, -0.23096988312782166, -7.294864415381831e-17));
obj->add(VectorFx::fromFloat(-0.6767766952966369, -0.17677669529663692, -8.288124497980175e-17));
obj->add(VectorFx::fromFloat(-0.7309698831278216, -0.0956708580912726, -8.951799667070348e-17));
obj->add(VectorFx::fromFloat(-0.75, -6.123233995736766e-17, -9.184851394388759e-17));
obj->add(VectorFx::fromFloat(-0.7309698831278217, 0.09567085809127249, -8.951799667070348e-17));
obj->add(VectorFx::fromFloat(-0.676776695296637, 0.17677669529663684, -8.288124497980176e-17));
obj->add(VectorFx::fromFloat(-0.5956708580912726, 0.23096988312782163, -7.294864415381832e-17));
obj->add(VectorFx::fromFloat(-0.5000000000000001, 0.25, -6.12323426292584e-17));
obj->add(VectorFx::fromFloat(-0.40432914190872754, 0.23096988312782168, -4.951604110469849e-17));
obj->add(VectorFx::fromFloat(-0.32322330470336336, 0.1767766952966371, -3.958344027871506e-17));
obj->add(VectorFx::fromFloat(-0.26903011687217837, 0.09567085809127263, -3.294668858781331e-17));
obj->add(VectorFx::fromFloat(-0.25, 9.184850993605148e-17, -3.0616171314629196e-17));
obj->add(VectorFx::fromFloat(-0.2309698760509491, 3.061616997868383e-17, 0.09567085653543472));
obj->add(VectorFx::fromFloat(-0.24855141099175748, -0.09567085809127242, 0.10295336685995762));
obj->add(VectorFx::fromFloat(-0.2986193864964557, -0.17677669529663687, 0.12369220165273821));
obj->add(VectorFx::fromFloat(-0.37355140716178153, -0.23096988312782163, 0.15473006131458114));
obj->add(VectorFx::fromFloat(-0.46193975210189814, -0.25, 0.19134171307086942));
obj->add(VectorFx::fromFloat(-0.5503280970420148, -0.23096988312782166, 0.22795336482715772));
obj->add(VectorFx::fromFloat(-0.6252601177073406, -0.17677669529663692, 0.25899122448900064));
obj->add(VectorFx::fromFloat(-0.6753280932120389, -0.0956708580912726, 0.27973005928178124));
obj->add(VectorFx::fromFloat(-0.6929096281528473, -6.123233995736766e-17, 0.28701256960630417));
obj->add(VectorFx::fromFloat(-0.6753280932120389, 0.09567085809127249, 0.27973005928178124));
obj->add(VectorFx::fromFloat(-0.6252601177073407, 0.17677669529663684, 0.2589912244890007));
obj->add(VectorFx::fromFloat(-0.5503280970420149, 0.23096988312782163, 0.22795336482715775));
obj->add(VectorFx::fromFloat(-0.46193975210189825, 0.25, 0.19134171307086947));
obj->add(VectorFx::fromFloat(-0.3735514071617816, 0.23096988312782168, 0.1547300613145812));
obj->add(VectorFx::fromFloat(-0.2986193864964559, 0.1767766952966371, 0.12369220165273831));
obj->add(VectorFx::fromFloat(-0.24855141099175757, 0.09567085809127263, 0.10295336685995767));
obj->add(VectorFx::fromFloat(-0.2309698760509491, 9.184850993605148e-17, 0.09567085653543472));
obj->add(VectorFx::fromFloat(-0.1767766922712326, 3.061616997868383e-17, 0.1767766922712326));
obj->add(VectorFx::fromFloat(-0.19023301672802723, -0.09567085809127242, 0.19023301672802723));
obj->add(VectorFx::fromFloat(-0.22855338668174907, -0.17677669529663687, 0.22855338668174907));
obj->add(VectorFx::fromFloat(-0.2859038731819626, -0.23096988312782163, 0.2859038731819626));
obj->add(VectorFx::fromFloat(-0.35355338454246515, -0.25, 0.35355338454246515));
obj->add(VectorFx::fromFloat(-0.4212028959029678, -0.23096988312782166, 0.4212028959029678));
obj->add(VectorFx::fromFloat(-0.4785533824031813, -0.17677669529663692, 0.4785533824031813));
obj->add(VectorFx::fromFloat(-0.5168737523569031, -0.0956708580912726, 0.5168737523569031));
obj->add(VectorFx::fromFloat(-0.5303300768136978, -6.123233995736766e-17, 0.5303300768136978));
obj->add(VectorFx::fromFloat(-0.5168737523569031, 0.09567085809127249, 0.5168737523569031));
obj->add(VectorFx::fromFloat(-0.47855338240318135, 0.17677669529663684, 0.47855338240318135));
obj->add(VectorFx::fromFloat(-0.4212028959029679, 0.23096988312782163, 0.4212028959029679));
obj->add(VectorFx::fromFloat(-0.35355338454246527, 0.25, 0.35355338454246527));
obj->add(VectorFx::fromFloat(-0.28590387318196264, 0.23096988312782168, 0.28590387318196264));
obj->add(VectorFx::fromFloat(-0.22855338668174924, 0.1767766952966371, 0.22855338668174924));
obj->add(VectorFx::fromFloat(-0.19023301672802728, 0.09567085809127263, 0.19023301672802728));
obj->add(VectorFx::fromFloat(-0.1767766922712326, 9.184850993605148e-17, 0.1767766922712326));
obj->add(VectorFx::fromFloat(-0.09567085653543472, 3.061616997868383e-17, 0.2309698760509491));
obj->add(VectorFx::fromFloat(-0.10295336685995762, -0.09567085809127242, 0.24855141099175748));
obj->add(VectorFx::fromFloat(-0.12369220165273821, -0.17677669529663687, 0.2986193864964557));
obj->add(VectorFx::fromFloat(-0.15473006131458114, -0.23096988312782163, 0.37355140716178153));
obj->add(VectorFx::fromFloat(-0.19134171307086942, -0.25, 0.46193975210189814));
obj->add(VectorFx::fromFloat(-0.22795336482715772, -0.23096988312782166, 0.5503280970420148));
obj->add(VectorFx::fromFloat(-0.25899122448900064, -0.17677669529663692, 0.6252601177073406));
obj->add(VectorFx::fromFloat(-0.27973005928178124, -0.0956708580912726, 0.6753280932120389));
obj->add(VectorFx::fromFloat(-0.28701256960630417, -6.123233995736766e-17, 0.6929096281528473));
obj->add(VectorFx::fromFloat(-0.27973005928178124, 0.09567085809127249, 0.6753280932120389));
obj->add(VectorFx::fromFloat(-0.2589912244890007, 0.17677669529663684, 0.6252601177073407));
obj->add(VectorFx::fromFloat(-0.22795336482715775, 0.23096988312782163, 0.5503280970420149));
obj->add(VectorFx::fromFloat(-0.19134171307086947, 0.25, 0.46193975210189825));
obj->add(VectorFx::fromFloat(-0.1547300613145812, 0.23096988312782168, 0.3735514071617816));
obj->add(VectorFx::fromFloat(-0.12369220165273831, 0.1767766952966371, 0.2986193864964559));
obj->add(VectorFx::fromFloat(-0.10295336685995767, 0.09567085809127263, 0.24855141099175757));
obj->add(VectorFx::fromFloat(-0.09567085653543472, 9.184850993605148e-17, 0.2309698760509491));
obj->add(VectorFx::fromFloat(-4.5924253663221344e-17, 3.061616997868383e-17, 0.25));
obj->add(VectorFx::fromFloat(-4.9420029321136e-17, -0.09567085809127242, 0.26903011687217826));
obj->add(VectorFx::fromFloat(-5.937515614024773e-17, -0.17677669529663687, 0.3232233047033631));
obj->add(VectorFx::fromFloat(-7.427405630579606e-17, -0.23096988312782163, 0.40432914190872743));
obj->add(VectorFx::fromFloat(-9.184850732644268e-17, -0.25, 0.49999999999999994));
obj->add(VectorFx::fromFloat(-1.0942295834708929e-16, -0.23096988312782166, 0.5956708580912725));
obj->add(VectorFx::fromFloat(-1.2432185851263765e-16, -0.17677669529663692, 0.6767766952966369));
obj->add(VectorFx::fromFloat(-1.3427698533174937e-16, -0.0956708580912726, 0.7309698831278216));
obj->add(VectorFx::fromFloat(-1.3777276098966403e-16, -6.123233995736766e-17, 0.75));
obj->add(VectorFx::fromFloat(-1.3427698533174937e-16, 0.09567085809127249, 0.7309698831278217));
obj->add(VectorFx::fromFloat(-1.2432185851263765e-16, 0.17677669529663684, 0.676776695296637));
obj->add(VectorFx::fromFloat(-1.0942295834708931e-16, 0.23096988312782163, 0.5956708580912726));
obj->add(VectorFx::fromFloat(-9.18485073264427e-17, 0.25, 0.5000000000000001));
obj->add(VectorFx::fromFloat(-7.427405630579609e-17, 0.23096988312782168, 0.40432914190872754));
obj->add(VectorFx::fromFloat(-5.937515614024777e-17, 0.1767766952966371, 0.32322330470336336));
obj->add(VectorFx::fromFloat(-4.942002932113602e-17, 0.09567085809127263, 0.26903011687217837));
obj->add(VectorFx::fromFloat(-4.5924253663221344e-17, 9.184850993605148e-17, 0.25));
obj->addFace({ 0, 1, 17});
obj->addFace({ 1, 18, 17});
obj->addFace({ 1, 2, 18});
obj->addFace({ 2, 19, 18});
obj->addFace({ 2, 3, 19});
obj->addFace({ 3, 20, 19});
obj->addFace({ 3, 4, 20});
obj->addFace({ 4, 21, 20});
obj->addFace({ 4, 5, 21});
obj->addFace({ 5, 22, 21});
obj->addFace({ 5, 6, 22});
obj->addFace({ 6, 23, 22});
obj->addFace({ 6, 7, 23});
obj->addFace({ 7, 24, 23});
obj->addFace({ 7, 8, 24});
obj->addFace({ 8, 25, 24});
obj->addFace({ 8, 9, 25});
obj->addFace({ 9, 26, 25});
obj->addFace({ 9, 10, 26});
obj->addFace({ 10, 27, 26});
obj->addFace({ 10, 11, 27});
obj->addFace({ 11, 28, 27});
obj->addFace({ 11, 12, 28});
obj->addFace({ 12, 29, 28});
obj->addFace({ 12, 13, 29});
obj->addFace({ 13, 30, 29});
obj->addFace({ 13, 14, 30});
obj->addFace({ 14, 31, 30});
obj->addFace({ 14, 15, 31});
obj->addFace({ 15, 32, 31});
obj->addFace({ 15, 16, 32});
obj->addFace({ 16, 33, 32});
obj->addFace({ 16, 0, 33});
obj->addFace({ 0, 17, 33});
obj->addFace({ 17, 18, 34});
obj->addFace({ 18, 35, 34});
obj->addFace({ 18, 19, 35});
obj->addFace({ 19, 36, 35});
obj->addFace({ 19, 20, 36});
obj->addFace({ 20, 37, 36});
obj->addFace({ 20, 21, 37});
obj->addFace({ 21, 38, 37});
obj->addFace({ 21, 22, 38});
obj->addFace({ 22, 39, 38});
obj->addFace({ 22, 23, 39});
obj->addFace({ 23, 40, 39});
obj->addFace({ 23, 24, 40});
obj->addFace({ 24, 41, 40});
obj->addFace({ 24, 25, 41});
obj->addFace({ 25, 42, 41});
obj->addFace({ 25, 26, 42});
obj->addFace({ 26, 43, 42});
obj->addFace({ 26, 27, 43});
obj->addFace({ 27, 44, 43});
obj->addFace({ 27, 28, 44});
obj->addFace({ 28, 45, 44});
obj->addFace({ 28, 29, 45});
obj->addFace({ 29, 46, 45});
obj->addFace({ 29, 30, 46});
obj->addFace({ 30, 47, 46});
obj->addFace({ 30, 31, 47});
obj->addFace({ 31, 48, 47});
obj->addFace({ 31, 32, 48});
obj->addFace({ 32, 49, 48});
obj->addFace({ 32, 33, 49});
obj->addFace({ 33, 50, 49});
obj->addFace({ 33, 17, 50});
obj->addFace({ 17, 34, 50});
obj->addFace({ 34, 35, 51});
obj->addFace({ 35, 52, 51});
obj->addFace({ 35, 36, 52});
obj->addFace({ 36, 53, 52});
obj->addFace({ 36, 37, 53});
obj->addFace({ 37, 54, 53});
obj->addFace({ 37, 38, 54});
obj->addFace({ 38, 55, 54});
obj->addFace({ 38, 39, 55});
obj->addFace({ 39, 56, 55});
obj->addFace({ 39, 40, 56});
obj->addFace({ 40, 57, 56});
obj->addFace({ 40, 41, 57});
obj->addFace({ 41, 58, 57});
obj->addFace({ 41, 42, 58});
obj->addFace({ 42, 59, 58});
obj->addFace({ 42, 43, 59});
obj->addFace({ 43, 60, 59});
obj->addFace({ 43, 44, 60});
obj->addFace({ 44, 61, 60});
obj->addFace({ 44, 45, 61});
obj->addFace({ 45, 62, 61});
obj->addFace({ 45, 46, 62});
obj->addFace({ 46, 63, 62});
obj->addFace({ 46, 47, 63});
obj->addFace({ 47, 64, 63});
obj->addFace({ 47, 48, 64});
obj->addFace({ 48, 65, 64});
obj->addFace({ 48, 49, 65});
obj->addFace({ 49, 66, 65});
obj->addFace({ 49, 50, 66});
obj->addFace({ 50, 67, 66});
obj->addFace({ 50, 34, 67});
obj->addFace({ 34, 51, 67});
obj->addFace({ 51, 52, 68});
obj->addFace({ 52, 69, 68});
obj->addFace({ 52, 53, 69});
obj->addFace({ 53, 70, 69});
obj->addFace({ 53, 54, 70});
obj->addFace({ 54, 71, 70});
obj->addFace({ 54, 55, 71});
obj->addFace({ 55, 72, 71});
obj->addFace({ 55, 56, 72});
obj->addFace({ 56, 73, 72});
obj->addFace({ 56, 57, 73});
obj->addFace({ 57, 74, 73});
obj->addFace({ 57, 58, 74});
obj->addFace({ 58, 75, 74});
obj->addFace({ 58, 59, 75});
obj->addFace({ 59, 76, 75});
obj->addFace({ 59, 60, 76});
obj->addFace({ 60, 77, 76});
obj->addFace({ 60, 61, 77});
obj->addFace({ 61, 78, 77});
obj->addFace({ 61, 62, 78});
obj->addFace({ 62, 79, 78});
obj->addFace({ 62, 63, 79});
obj->addFace({ 63, 80, 79});
obj->addFace({ 63, 64, 80});
obj->addFace({ 64, 81, 80});
obj->addFace({ 64, 65, 81});
obj->addFace({ 65, 82, 81});
obj->addFace({ 65, 66, 82});
obj->addFace({ 66, 83, 82});
obj->addFace({ 66, 67, 83});
obj->addFace({ 67, 84, 83});
obj->addFace({ 67, 51, 84});
obj->addFace({ 51, 68, 84});
obj->addFace({ 68, 69, 85});
obj->addFace({ 69, 86, 85});
obj->addFace({ 69, 70, 86});
obj->addFace({ 70, 87, 86});
obj->addFace({ 70, 71, 87});
obj->addFace({ 71, 88, 87});
obj->addFace({ 71, 72, 88});
obj->addFace({ 72, 89, 88});
obj->addFace({ 72, 73, 89});
obj->addFace({ 73, 90, 89});
obj->addFace({ 73, 74, 90});
obj->addFace({ 74, 91, 90});
obj->addFace({ 74, 75, 91});
obj->addFace({ 75, 92, 91});
obj->addFace({ 75, 76, 92});
obj->addFace({ 76, 93, 92});
obj->addFace({ 76, 77, 93});
obj->addFace({ 77, 94, 93});
obj->addFace({ 77, 78, 94});
obj->addFace({ 78, 95, 94});
obj->addFace({ 78, 79, 95});
obj->addFace({ 79, 96, 95});
obj->addFace({ 79, 80, 96});
obj->addFace({ 80, 97, 96});
obj->addFace({ 80, 81, 97});
obj->addFace({ 81, 98, 97});
obj->addFace({ 81, 82, 98});
obj->addFace({ 82, 99, 98});
obj->addFace({ 82, 83, 99});
obj->addFace({ 83, 100, 99});
obj->addFace({ 83, 84, 100});
obj->addFace({ 84, 101, 100});
obj->addFace({ 84, 68, 101});
obj->addFace({ 68, 85, 101});
obj->addFace({ 85, 86, 102});
obj->addFace({ 86, 103, 102});
obj->addFace({ 86, 87, 103});
obj->addFace({ 87, 104, 103});
obj->addFace({ 87, 88, 104});
obj->addFace({ 88, 105, 104});
obj->addFace({ 88, 89, 105});
obj->addFace({ 89, 106, 105});
obj->addFace({ 89, 90, 106});
obj->addFace({ 90, 107, 106});
obj->addFace({ 90, 91, 107});
obj->addFace({ 91, 108, 107});
obj->addFace({ 91, 92, 108});
obj->addFace({ 92, 109, 108});
obj->addFace({ 92, 93, 109});
obj->addFace({ 93, 110, 109});
obj->addFace({ 93, 94, 110});
obj->addFace({ 94, 111, 110});
obj->addFace({ 94, 95, 111});
obj->addFace({ 95, 112, 111});
obj->addFace({ 95, 96, 112});
obj->addFace({ 96, 113, 112});
obj->addFace({ 96, 97, 113});
obj->addFace({ 97, 114, 113});
obj->addFace({ 97, 98, 114});
obj->addFace({ 98, 115, 114});
obj->addFace({ 98, 99, 115});
obj->addFace({ 99, 116, 115});
obj->addFace({ 99, 100, 116});
obj->addFace({ 100, 117, 116});
obj->addFace({ 100, 101, 117});
obj->addFace({ 101, 118, 117});
obj->addFace({ 101, 85, 118});
obj->addFace({ 85, 102, 118});
obj->addFace({ 102, 103, 119});
obj->addFace({ 103, 120, 119});
obj->addFace({ 103, 104, 120});
obj->addFace({ 104, 121, 120});
obj->addFace({ 104, 105, 121});
obj->addFace({ 105, 122, 121});
obj->addFace({ 105, 106, 122});
obj->addFace({ 106, 123, 122});
obj->addFace({ 106, 107, 123});
obj->addFace({ 107, 124, 123});
obj->addFace({ 107, 108, 124});
obj->addFace({ 108, 125, 124});
obj->addFace({ 108, 109, 125});
obj->addFace({ 109, 126, 125});
obj->addFace({ 109, 110, 126});
obj->addFace({ 110, 127, 126});
obj->addFace({ 110, 111, 127});
obj->addFace({ 111, 128, 127});
obj->addFace({ 111, 112, 128});
obj->addFace({ 112, 129, 128});
obj->addFace({ 112, 113, 129});
obj->addFace({ 113, 130, 129});
obj->addFace({ 113, 114, 130});
obj->addFace({ 114, 131, 130});
obj->addFace({ 114, 115, 131});
obj->addFace({ 115, 132, 131});
obj->addFace({ 115, 116, 132});
obj->addFace({ 116, 133, 132});
obj->addFace({ 116, 117, 133});
obj->addFace({ 117, 134, 133});
obj->addFace({ 117, 118, 134});
obj->addFace({ 118, 135, 134});
obj->addFace({ 118, 102, 135});
obj->addFace({ 102, 119, 135});
obj->addFace({ 119, 120, 136});
obj->addFace({ 120, 137, 136});
obj->addFace({ 120, 121, 137});
obj->addFace({ 121, 138, 137});
obj->addFace({ 121, 122, 138});
obj->addFace({ 122, 139, 138});
obj->addFace({ 122, 123, 139});
obj->addFace({ 123, 140, 139});
obj->addFace({ 123, 124, 140});
obj->addFace({ 124, 141, 140});
obj->addFace({ 124, 125, 141});
obj->addFace({ 125, 142, 141});
obj->addFace({ 125, 126, 142});
obj->addFace({ 126, 143, 142});
obj->addFace({ 126, 127, 143});
obj->addFace({ 127, 144, 143});
obj->addFace({ 127, 128, 144});
obj->addFace({ 128, 145, 144});
obj->addFace({ 128, 129, 145});
obj->addFace({ 129, 146, 145});
obj->addFace({ 129, 130, 146});
obj->addFace({ 130, 147, 146});
obj->addFace({ 130, 131, 147});
obj->addFace({ 131, 148, 147});
obj->addFace({ 131, 132, 148});
obj->addFace({ 132, 149, 148});
obj->addFace({ 132, 133, 149});
obj->addFace({ 133, 150, 149});
obj->addFace({ 133, 134, 150});
obj->addFace({ 134, 151, 150});
obj->addFace({ 134, 135, 151});
obj->addFace({ 135, 152, 151});
obj->addFace({ 135, 119, 152});
obj->addFace({ 119, 136, 152});
obj->addFace({ 136, 137, 153});
obj->addFace({ 137, 154, 153});
obj->addFace({ 137, 138, 154});
obj->addFace({ 138, 155, 154});
obj->addFace({ 138, 139, 155});
obj->addFace({ 139, 156, 155});
obj->addFace({ 139, 140, 156});
obj->addFace({ 140, 157, 156});
obj->addFace({ 140, 141, 157});
obj->addFace({ 141, 158, 157});
obj->addFace({ 141, 142, 158});
obj->addFace({ 142, 159, 158});
obj->addFace({ 142, 143, 159});
obj->addFace({ 143, 160, 159});
obj->addFace({ 143, 144, 160});
obj->addFace({ 144, 161, 160});
obj->addFace({ 144, 145, 161});
obj->addFace({ 145, 162, 161});
obj->addFace({ 145, 146, 162});
obj->addFace({ 146, 163, 162});
obj->addFace({ 146, 147, 163});
obj->addFace({ 147, 164, 163});
obj->addFace({ 147, 148, 164});
obj->addFace({ 148, 165, 164});
obj->addFace({ 148, 149, 165});
obj->addFace({ 149, 166, 165});
obj->addFace({ 149, 150, 166});
obj->addFace({ 150, 167, 166});
obj->addFace({ 150, 151, 167});
obj->addFace({ 151, 168, 167});
obj->addFace({ 151, 152, 168});
obj->addFace({ 152, 169, 168});
obj->addFace({ 152, 136, 169});
obj->addFace({ 136, 153, 169});
obj->addFace({ 153, 154, 170});
obj->addFace({ 154, 171, 170});
obj->addFace({ 154, 155, 171});
obj->addFace({ 155, 172, 171});
obj->addFace({ 155, 156, 172});
obj->addFace({ 156, 173, 172});
obj->addFace({ 156, 157, 173});
obj->addFace({ 157, 174, 173});
obj->addFace({ 157, 158, 174});
obj->addFace({ 158, 175, 174});
obj->addFace({ 158, 159, 175});
obj->addFace({ 159, 176, 175});
obj->addFace({ 159, 160, 176});
obj->addFace({ 160, 177, 176});
obj->addFace({ 160, 161, 177});
obj->addFace({ 161, 178, 177});
obj->addFace({ 161, 162, 178});
obj->addFace({ 162, 179, 178});
obj->addFace({ 162, 163, 179});
obj->addFace({ 163, 180, 179});
obj->addFace({ 163, 164, 180});
obj->addFace({ 164, 181, 180});
obj->addFace({ 164, 165, 181});
obj->addFace({ 165, 182, 181});
obj->addFace({ 165, 166, 182});
obj->addFace({ 166, 183, 182});
obj->addFace({ 166, 167, 183});
obj->addFace({ 167, 184, 183});
obj->addFace({ 167, 168, 184});
obj->addFace({ 168, 185, 184});
obj->addFace({ 168, 169, 185});
obj->addFace({ 169, 186, 185});
obj->addFace({ 169, 153, 186});
obj->addFace({ 153, 170, 186});
obj->addFace({ 170, 171, 187});
obj->addFace({ 171, 188, 187});
obj->addFace({ 171, 172, 188});
obj->addFace({ 172, 189, 188});
obj->addFace({ 172, 173, 189});
obj->addFace({ 173, 190, 189});
obj->addFace({ 173, 174, 190});
obj->addFace({ 174, 191, 190});
obj->addFace({ 174, 175, 191});
obj->addFace({ 175, 192, 191});
obj->addFace({ 175, 176, 192});
obj->addFace({ 176, 193, 192});
obj->addFace({ 176, 177, 193});
obj->addFace({ 177, 194, 193});
obj->addFace({ 177, 178, 194});
obj->addFace({ 178, 195, 194});
obj->addFace({ 178, 179, 195});
obj->addFace({ 179, 196, 195});
obj->addFace({ 179, 180, 196});
obj->addFace({ 180, 197, 196});
obj->addFace({ 180, 181, 197});
obj->addFace({ 181, 198, 197});
obj->addFace({ 181, 182, 198});
obj->addFace({ 182, 199, 198});
obj->addFace({ 182, 183, 199});
obj->addFace({ 183, 200, 199});
obj->addFace({ 183, 184, 200});
obj->addFace({ 184, 201, 200});
obj->addFace({ 184, 185, 201});
obj->addFace({ 185, 202, 201});
obj->addFace({ 185, 186, 202});
obj->addFace({ 186, 203, 202});
obj->addFace({ 186, 170, 203});
obj->addFace({ 170, 187, 203});
obj->addFace({ 187, 188, 204});
obj->addFace({ 188, 205, 204});
obj->addFace({ 188, 189, 205});
obj->addFace({ 189, 206, 205});
obj->addFace({ 189, 190, 206});
obj->addFace({ 190, 207, 206});
obj->addFace({ 190, 191, 207});
obj->addFace({ 191, 208, 207});
obj->addFace({ 191, 192, 208});
obj->addFace({ 192, 209, 208});
obj->addFace({ 192, 193, 209});
obj->addFace({ 193, 210, 209});
obj->addFace({ 193, 194, 210});
obj->addFace({ 194, 211, 210});
obj->addFace({ 194, 195, 211});
obj->addFace({ 195, 212, 211});
obj->addFace({ 195, 196, 212});
obj->addFace({ 196, 213, 212});
obj->addFace({ 196, 197, 213});
obj->addFace({ 197, 214, 213});
obj->addFace({ 197, 198, 214});
obj->addFace({ 198, 215, 214});
obj->addFace({ 198, 199, 215});
obj->addFace({ 199, 216, 215});
obj->addFace({ 199, 200, 216});
obj->addFace({ 200, 217, 216});
obj->addFace({ 200, 201, 217});
obj->addFace({ 201, 218, 217});
obj->addFace({ 201, 202, 218});
obj->addFace({ 202, 219, 218});
obj->addFace({ 202, 203, 219});
obj->addFace({ 203, 220, 219});
obj->addFace({ 203, 187, 220});
obj->addFace({ 187, 204, 220});
obj->addFace({ 204, 205, 221});
obj->addFace({ 205, 222, 221});
obj->addFace({ 205, 206, 222});
obj->addFace({ 206, 223, 222});
obj->addFace({ 206, 207, 223});
obj->addFace({ 207, 224, 223});
obj->addFace({ 207, 208, 224});
obj->addFace({ 208, 225, 224});
obj->addFace({ 208, 209, 225});
obj->addFace({ 209, 226, 225});
obj->addFace({ 209, 210, 226});
obj->addFace({ 210, 227, 226});
obj->addFace({ 210, 211, 227});
obj->addFace({ 211, 228, 227});
obj->addFace({ 211, 212, 228});
obj->addFace({ 212, 229, 228});
obj->addFace({ 212, 213, 229});
obj->addFace({ 213, 230, 229});
obj->addFace({ 213, 214, 230});
obj->addFace({ 214, 231, 230});
obj->addFace({ 214, 215, 231});
obj->addFace({ 215, 232, 231});
obj->addFace({ 215, 216, 232});
obj->addFace({ 216, 233, 232});
obj->addFace({ 216, 217, 233});
obj->addFace({ 217, 234, 233});
obj->addFace({ 217, 218, 234});
obj->addFace({ 218, 235, 234});
obj->addFace({ 218, 219, 235});
obj->addFace({ 219, 236, 235});
obj->addFace({ 219, 220, 236});
obj->addFace({ 220, 237, 236});
obj->addFace({ 220, 204, 237});
obj->addFace({ 204, 221, 237});
obj->addFace({ 221, 222, 238});
obj->addFace({ 222, 239, 238});
obj->addFace({ 222, 223, 239});
obj->addFace({ 223, 240, 239});
obj->addFace({ 223, 224, 240});
obj->addFace({ 224, 241, 240});
obj->addFace({ 224, 225, 241});
obj->addFace({ 225, 242, 241});
obj->addFace({ 225, 226, 242});
obj->addFace({ 226, 243, 242});
obj->addFace({ 226, 227, 243});
obj->addFace({ 227, 244, 243});
obj->addFace({ 227, 228, 244});
obj->addFace({ 228, 245, 244});
obj->addFace({ 228, 229, 245});
obj->addFace({ 229, 246, 245});
obj->addFace({ 229, 230, 246});
obj->addFace({ 230, 247, 246});
obj->addFace({ 230, 231, 247});
obj->addFace({ 231, 248, 247});
obj->addFace({ 231, 232, 248});
obj->addFace({ 232, 249, 248});
obj->addFace({ 232, 233, 249});
obj->addFace({ 233, 250, 249});
obj->addFace({ 233, 234, 250});
obj->addFace({ 234, 251, 250});
obj->addFace({ 234, 235, 251});
obj->addFace({ 235, 252, 251});
obj->addFace({ 235, 236, 252});
obj->addFace({ 236, 253, 252});
obj->addFace({ 236, 237, 253});
obj->addFace({ 237, 254, 253});
obj->addFace({ 237, 221, 254});
obj->addFace({ 221, 238, 254});
obj->addFace({ 238, 239, 255});
obj->addFace({ 239, 256, 255});
obj->addFace({ 239, 240, 256});
obj->addFace({ 240, 257, 256});
obj->addFace({ 240, 241, 257});
obj->addFace({ 241, 258, 257});
obj->addFace({ 241, 242, 258});
obj->addFace({ 242, 259, 258});
obj->addFace({ 242, 243, 259});
obj->addFace({ 243, 260, 259});
obj->addFace({ 243, 244, 260});
obj->addFace({ 244, 261, 260});
obj->addFace({ 244, 245, 261});
obj->addFace({ 245, 262, 261});
obj->addFace({ 245, 246, 262});
obj->addFace({ 246, 263, 262});
obj->addFace({ 246, 247, 263});
obj->addFace({ 247, 264, 263});
obj->addFace({ 247, 248, 264});
obj->addFace({ 248, 265, 264});
obj->addFace({ 248, 249, 265});
obj->addFace({ 249, 266, 265});
obj->addFace({ 249, 250, 266});
obj->addFace({ 250, 267, 266});
obj->addFace({ 250, 251, 267});
obj->addFace({ 251, 268, 267});
obj->addFace({ 251, 252, 268});
obj->addFace({ 252, 269, 268});
obj->addFace({ 252, 253, 269});
obj->addFace({ 253, 270, 269});
obj->addFace({ 253, 254, 270});
obj->addFace({ 254, 271, 270});
obj->addFace({ 254, 238, 271});
obj->addFace({ 238, 255, 271});
obj->addFace({ 255, 256, 272});
obj->addFace({ 256, 273, 272});
obj->addFace({ 256, 257, 273});
obj->addFace({ 257, 274, 273});
obj->addFace({ 257, 258, 274});
obj->addFace({ 258, 275, 274});
obj->addFace({ 258, 259, 275});
obj->addFace({ 259, 276, 275});
obj->addFace({ 259, 260, 276});
obj->addFace({ 260, 277, 276});
obj->addFace({ 260, 261, 277});
obj->addFace({ 261, 278, 277});
obj->addFace({ 261, 262, 278});
obj->addFace({ 262, 279, 278});
obj->addFace({ 262, 263, 279});
obj->addFace({ 263, 280, 279});
obj->addFace({ 263, 264, 280});
obj->addFace({ 264, 281, 280});
obj->addFace({ 264, 265, 281});
obj->addFace({ 265, 282, 281});
obj->addFace({ 265, 266, 282});
obj->addFace({ 266, 283, 282});
obj->addFace({ 266, 267, 283});
obj->addFace({ 267, 284, 283});
obj->addFace({ 267, 268, 284});
obj->addFace({ 268, 285, 284});
obj->addFace({ 268, 269, 285});
obj->addFace({ 269, 286, 285});
obj->addFace({ 269, 270, 286});
obj->addFace({ 270, 287, 286});
obj->addFace({ 270, 271, 287});
obj->addFace({ 271, 288, 287});
obj->addFace({ 271, 255, 288});
obj->addFace({ 255, 272, 288});
obj->addFace({ 272, 273, 0});
obj->addFace({ 273, 1, 0});
obj->addFace({ 273, 274, 1});
obj->addFace({ 274, 2, 1});
obj->addFace({ 274, 275, 2});
obj->addFace({ 275, 3, 2});
obj->addFace({ 275, 276, 3});
obj->addFace({ 276, 4, 3});
obj->addFace({ 276, 277, 4});
obj->addFace({ 277, 5, 4});
obj->addFace({ 277, 278, 5});
obj->addFace({ 278, 6, 5});
obj->addFace({ 278, 279, 6});
obj->addFace({ 279, 7, 6});
obj->addFace({ 279, 280, 7});
obj->addFace({ 280, 8, 7});
obj->addFace({ 280, 281, 8});
obj->addFace({ 281, 9, 8});
obj->addFace({ 281, 282, 9});
obj->addFace({ 282, 10, 9});
obj->addFace({ 282, 283, 10});
obj->addFace({ 283, 11, 10});
obj->addFace({ 283, 284, 11});
obj->addFace({ 284, 12, 11});
obj->addFace({ 284, 285, 12});
obj->addFace({ 285, 13, 12});
obj->addFace({ 285, 286, 13});
obj->addFace({ 286, 14, 13});
obj->addFace({ 286, 287, 14});
obj->addFace({ 287, 15, 14});
obj->addFace({ 287, 288, 15});
obj->addFace({ 288, 16, 15});
obj->addFace({ 288, 272, 16});
obj->addFace({ 272, 0, 16});
obj->add(VectorFx::fromFloat(0, 0, 1.414214), VectorFx::fromFloat(0.5773502691896258, 0.5773502691896258, 0.5773502691896258));
obj->add(VectorFx::fromFloat(1.414214, 0, 0), VectorFx::fromFloat(0.5773502691896258, 0.5773502691896258, 0.5773502691896258));
obj->add(VectorFx::fromFloat(0, 1.414214, 0), VectorFx::fromFloat(0.5773502691896258, 0.5773502691896258, 0.5773502691896258));
obj->add(VectorFx::fromFloat(0, 0, 1.414214), VectorFx::fromFloat(-0.5773502691896258, 0.5773502691896258, 0.5773502691896258));
obj->add(VectorFx::fromFloat(0, 1.414214, 0), VectorFx::fromFloat(-0.5773502691896258, 0.5773502691896258, 0.5773502691896258));
obj->add(VectorFx::fromFloat(-1.414214, 0, 0), VectorFx::fromFloat(-0.5773502691896258, 0.5773502691896258, 0.5773502691896258));
obj->add(VectorFx::fromFloat(0, 0, 1.414214), VectorFx::fromFloat(-0.5773502691896258, -0.5773502691896258, 0.5773502691896258));
obj->add(VectorFx::fromFloat(-1.414214, 0, 0), VectorFx::fromFloat(-0.5773502691896258, -0.5773502691896258, 0.5773502691896258));
obj->add(VectorFx::fromFloat(0, -1.414214, 0), VectorFx::fromFloat(-0.5773502691896258, -0.5773502691896258, 0.5773502691896258));
obj->add(VectorFx::fromFloat(0, 0, 1.414214), VectorFx::fromFloat(0.5773502691896258, -0.5773502691896258, 0.5773502691896258));
obj->add(VectorFx::fromFloat(0, -1.414214, 0), VectorFx::fromFloat(0.5773502691896258, -0.5773502691896258, 0.5773502691896258));
obj->add(VectorFx::fromFloat(1.414214, 0, 0), VectorFx::fromFloat(0.5773502691896258, -0.5773502691896258, 0.5773502691896258));
obj->add(VectorFx::fromFloat(1.414214, 0, 0), VectorFx::fromFloat(0.5773502691896258, -0.5773502691896258, -0.5773502691896258));
obj->add(VectorFx::fromFloat(0, -1.414214, 0), VectorFx::fromFloat(0.5773502691896258, -0.5773502691896258, -0.5773502691896258));
obj->add(VectorFx::fromFloat(0, 0, -1.414214), VectorFx::fromFloat(0.5773502691896258, -0.5773502691896258, -0.5773502691896258));
obj->add(VectorFx::fromFloat(1.414214, 0, 0), VectorFx::fromFloat(0.5773502691896258, 0.5773502691896258, -0.5773502691896258));
obj->add(VectorFx::fromFloat(0, 0, -1.414214), VectorFx::fromFloat(0.5773502691896258, 0.5773502691896258, -0.5773502691896258));
obj->add(VectorFx::fromFloat(0, 1.414214, 0), VectorFx::fromFloat(0.5773502691896258, 0.5773502691896258, -0.5773502691896258));
obj->add(VectorFx::fromFloat(0, 1.414214, 0), VectorFx::fromFloat(-0.5773502691896258, 0.5773502691896258, -0.5773502691896258));
obj->add(VectorFx::fromFloat(0, 0, -1.414214), VectorFx::fromFloat(-0.5773502691896258, 0.5773502691896258, -0.5773502691896258));
obj->add(VectorFx::fromFloat(-1.414214, 0, 0), VectorFx::fromFloat(-0.5773502691896258, 0.5773502691896258, -0.5773502691896258));
obj->add(VectorFx::fromFloat(-1.414214, 0, 0), VectorFx::fromFloat(-0.5773502691896258, -0.5773502691896258, -0.5773502691896258));
obj->add(VectorFx::fromFloat(0, 0, -1.414214), VectorFx::fromFloat(-0.5773502691896258, -0.5773502691896258, -0.5773502691896258));
obj->add(VectorFx::fromFloat(0, -1.414214, 0), VectorFx::fromFloat(-0.5773502691896258, -0.5773502691896258, -0.5773502691896258));
obj->addFace(0, 2, 1);
obj->addFace(3, 5, 4);
obj->addFace(6, 8, 7);
obj->addFace(9, 11, 10);
obj->addFace(12, 14, 13);
obj->addFace(15, 17, 16);
obj->addFace(18, 20, 19);
obj->addFace(21, 23, 22);
obj->setPosition(VectorFx::fromInt(0, 0, 0));
return obj;
}

View File

@ -23,7 +23,7 @@ add_library(${PROJECT_NAME}
src/renderer/pixelrenderer.cpp
src/renderer/wirerenderer.cpp
src/math.cpp
src/sound_control.cpp src/scene.cpp src/timer.cpp src/vectorfx.cpp src/mesh.cpp src/renderer/raserizerrenderer.cpp)
src/sound_control.cpp src/scene.cpp src/timer.cpp src/vectorfx.cpp src/mesh.cpp src/renderer/rasterizerrenderer.cpp)
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>

View File

@ -0,0 +1,32 @@
//
// Created by Wouter Groeneveld on 15/07/20.
//
#ifndef GBA_BITMAP_ENGINE_PROJECT_FACE_H
#define GBA_BITMAP_ENGINE_PROJECT_FACE_H
#include <libgba-bitmap-engine/vectorfx.h>
class Face {
private:
int theA, theB, theC;
VectorFx norm;
public:
Face(int newA, int newB, int newC, const Vertex& va, const Vertex& vb, const Vertex& vc) : theA(newA), theB(newB), theC(newC), norm(VectorFx()) {
normalize(va, vb, vc);
}
inline const VectorFx& normal() const { return norm; };
inline int a() { return theA; };
inline int b() { return theB; };
inline int c() { return theC; };
inline void normalize(const Vertex& va, const Vertex& vb, const Vertex& vc) {
norm = (va.normal() + vb.normal() + vc.normal()).scale(fxdiv(int2fx(1), int2fx(3)));
norm.normalize();
}
};
#endif //GBA_BITMAP_ENGINE_PROJECT_FACE_H

View File

@ -115,6 +115,13 @@ public:
return "(" + mstr(12) + "," + mstr(13) + "," + mstr(14) + "," + mstr(15) +")";
}
inline static VectorFx transformNormal(const VectorFx& vector, const MatrixFx &transformation) {
FIXED x = fxmul(vector.x(), transformation.mAt(0)) + fxmul(vector.y(), transformation.mAt(4)) + fxmul(vector.z(), transformation.mAt(8));
FIXED y = fxmul(vector.x(), transformation.mAt(1)) + fxmul(vector.y(), transformation.mAt(5)) + fxmul(vector.z(), transformation.mAt(9));
FIXED z = fxmul(vector.x(), transformation.mAt(2)) + fxmul(vector.y(), transformation.mAt(6)) + fxmul(vector.z(), transformation.mAt(10));
return VectorFx(x, y, z);
}
inline static VectorFx transformCoordinates(const VectorFx &vector, const MatrixFx &transformation) {
FIXED x = fxmul(vector.x(), transformation.mAt(0)) + fxmul(vector.y(), transformation.mAt(4)) + fxmul(vector.z(), transformation.mAt(8)) + transformation.mAt(12);
FIXED y = fxmul(vector.x(), transformation.mAt(1)) + fxmul(vector.y(), transformation.mAt(5)) + fxmul(vector.z(), transformation.mAt(9)) + transformation.mAt(13);

View File

@ -5,34 +5,32 @@
#ifndef GBA_BITMAP_ENGINE_PROJECT_MESH_H
#define GBA_BITMAP_ENGINE_PROJECT_MESH_H
#include "vectorfx.h"
#include <libgba-bitmap-engine/vertex.h>
#include <libgba-bitmap-engine/vectorfx.h>
#include <libgba-bitmap-engine/face.h>
#include <vector>
#include <memory>
typedef struct {
int a;
int b;
int c;
} Face;
class Mesh {
private:
VectorFx pos;
VectorFx rot;
u8 cIndex;
std::vector<std::unique_ptr<VectorFx>> verticesArr;
std::vector<Face> facesArr;
std::vector<std::unique_ptr<Vertex>> verticesArr;
std::vector<std::unique_ptr<Face>> facesArr;
public:
void add(VectorFx coords, VectorFx normal);
void add(VectorFx v);
void addFace(Face f);
inline std::vector<std::unique_ptr<VectorFx>> const& vertices() const {