Compare commits

...

2 Commits

Author SHA1 Message Date
Potter360 90b006be67 STLAscii converter 1.0 2023-01-11 00:00:11 +01:00
Potter360 e64e5cac69 commenting STL converter 2023-01-08 18:22:13 +01:00
11 changed files with 2950 additions and 376 deletions

View File

@ -8,6 +8,8 @@ include(GenerateG1A)
include(GenerateG3A)
include(Fxconv)
find_package(Gint 2.1 REQUIRED)
include(Fxconv)
fxconv_declare_converters(assets-fx/converters.py)
set(SOURCES
src/Geometry.cpp
@ -27,10 +29,13 @@ set(SOURCES
# Shared assets, fx-9860G-only assets and fx-CG-50-only assets
set(ASSETS
# ...
)
set(ASSETS_fx
assets-fx/example.png
assets-fx/img/windmill.png
assets-fx/cube.stl
assets-fx/humanoid_tri.stl
# ...
)
set(ASSETS_cg

Binary file not shown.

Binary file not shown.

105
assets-fx/converters.py Normal file
View File

@ -0,0 +1,105 @@
import fxconv as fx
class Lexer:
def __init__(self,Data):
# remove first line...
Data = Data.split("\n",1)[1]
self.data = Data.split()
# ... and last line
self.data = self.data[0:len(self.data)-2]
def lex(self,indice):
return self.data[indice]
def getData(self):
return self.data
class Parser:
def __init__(self,Lexer):
self.lexer = Lexer
def parse(self,Data):
list_triangles = [[[0,0,0],[0,0,0],[0,0,0]] for i in range(int(len(Data)/21))]
triangle=0
# for all the triangles
for i in range(0,len(Data),21):
# parsing X
for j in range(0,3):
list_triangles[triangle][0][j] = float(self.lexer.lex(i+8+j))
# parsing Y
for j in range(0,3):
list_triangles[triangle][1][j] = float(self.lexer.lex(i+12+j))
# parsing Z
for j in range(0,3):
list_triangles[triangle][2][j] = float(self.lexer.lex(i+16+j))
triangle+=1
return list_triangles
def format(data):
vertex_list = []
for i in data:
for j in i:
if not j in vertex_list:
vertex_list.append(j)
face_list = []
for i in data:
vertex = []
for j in i:
vertex.append(vertex_list.index(j))
face_list.append(vertex)
return vertex_list,face_list
def multiplybyfactor(array, factor):
a = 0
for i in array:
b=0
for j in i:
array[a][b] = j*factor
b+=1
a+=1
return array
def convert(input, output, params, target):
if params["custom-type"] == "stl":
convert_stl(input, output, params, target)
return 0
else:
return 1
def convert_stl(input,output,params,target):
with open(input) as file:
data = file.read()
lexer = Lexer(data)
Data = lexer.getData()
parser = Parser(lexer)
vertexlist,facelist = format(parser.parse(Data))
vertexlist = multiplybyfactor(vertexlist,(1/max(max(vertexlist, key=max)))*30)
vertex = fx.Structure()
for i in vertexlist:
vertex += fx.u32(int(i[0]))+fx.u32(int(i[1]))+fx.u32(int(i[2]))
vertex += bytes(2)
texture = fx.Structure()
texture += fx.u32(0) + fx.u32(1)
face = fx.Structure()
for z in facelist:
face += fx.ptr("tex_black")
face += fx.ptr("tex_black")
face += fx.u8(int(z[0]))+fx.u8(int(z[1]))+fx.u8(int(z[2])) + fx.u8(0) + fx.u8(0) + fx.u8(0)
face += fx.u8(1)
face += bytes(1)
mesh = fx.Structure()
mesh += fx.ptr(vertex)
mesh += fx.u32(len(vertexlist))
mesh += fx.ptr(texture)
mesh += fx.u32(1)
mesh += fx.ptr(face)
mesh += fx.u32(len(facelist))
fx.elf(mesh, output, "_" + params["name"], **target)

86
assets-fx/cube.stl Executable file
View File

@ -0,0 +1,86 @@
solid cube
facet normal 0.000000 0.000000 1.000000
outer loop
vertex 1.000000 1.000000 1.000000
vertex -1.000000 1.000000 1.000000
vertex -1.000000 -1.000000 1.000000
endloop
endfacet
facet normal 0.000000 0.000000 1.000000
outer loop
vertex 1.000000 1.000000 1.000000
vertex -1.000000 -1.000000 1.000000
vertex 1.000000 -1.000000 1.000000
endloop
endfacet
facet normal 0.000000 -1.000000 0.000000
outer loop
vertex 1.000000 -1.000000 -1.000000
vertex 1.000000 -1.000000 1.000000
vertex -1.000000 -1.000000 1.000000
endloop
endfacet
facet normal 0.000000 -1.000000 0.000000
outer loop
vertex 1.000000 -1.000000 -1.000000
vertex -1.000000 -1.000000 1.000000
vertex -1.000000 -1.000000 -1.000000
endloop
endfacet
facet normal -1.000000 0.000000 0.000000
outer loop
vertex -1.000000 -1.000000 -1.000000
vertex -1.000000 -1.000000 1.000000
vertex -1.000000 1.000000 1.000000
endloop
endfacet
facet normal -1.000000 0.000000 0.000000
outer loop
vertex -1.000000 -1.000000 -1.000000
vertex -1.000000 1.000000 1.000000
vertex -1.000000 1.000000 -1.000000
endloop
endfacet
facet normal 0.000000 0.000000 -1.000000
outer loop
vertex -1.000000 1.000000 -1.000000
vertex 1.000000 1.000000 -1.000000
vertex 1.000000 -1.000000 -1.000000
endloop
endfacet
facet normal 0.000000 0.000000 -1.000000
outer loop
vertex -1.000000 1.000000 -1.000000
vertex 1.000000 -1.000000 -1.000000
vertex -1.000000 -1.000000 -1.000000
endloop
endfacet
facet normal 1.000000 0.000000 0.000000
outer loop
vertex 1.000000 1.000000 -1.000000
vertex 1.000000 1.000000 1.000000
vertex 1.000000 -1.000000 1.000000
endloop
endfacet
facet normal 1.000000 0.000000 0.000000
outer loop
vertex 1.000000 1.000000 -1.000000
vertex 1.000000 -1.000000 1.000000
vertex 1.000000 -1.000000 -1.000000
endloop
endfacet
facet normal 0.000000 1.000000 0.000000
outer loop
vertex -1.000000 1.000000 -1.000000
vertex -1.000000 1.000000 1.000000
vertex 1.000000 1.000000 1.000000
endloop
endfacet
facet normal 0.000000 1.000000 0.000000
outer loop
vertex -1.000000 1.000000 -1.000000
vertex 1.000000 1.000000 1.000000
vertex 1.000000 1.000000 -1.000000
endloop
endfacet
endsolid cube

View File

@ -4,4 +4,12 @@ example.png:
img/windmill.png:
type: bopti-image
name: img_windmill
name: img_windmill
cube.stl:
  custom-type: stl
  name_regex: cube.stl object_cube
humanoid_tri.stl:
  custom-type: stl
  name_regex: humanoid_tri.stl object_humanoid

1391
assets-fx/fxconv.py Normal file

File diff suppressed because it is too large Load Diff

1346
assets-fx/humanoid_tri.stl Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,4 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=https://people.sc.fsu.edu/~jburkardt/data/stla/stla.html
HostUrl=https://people.sc.fsu.edu/~jburkardt/data/stla/humanoid_tri.stl

View File

@ -10,7 +10,8 @@
//-----------------------------------------------------------------------------
#include "windmill.hpp"
extern Mesh object_cube;
extern Mesh object_humanoid;
// SPRITES
const unsigned char sprite_planche_bois[]={
0x81,0x04,0x08,0x20,
@ -231,340 +232,8 @@ Texture tex_mur_moulin = {sprite_planche_bois, NULL, 32, 32, 0, 0};
Texture tex_pale_moulin = {sprite_pale_moulin, NULL, 16, 64, 0, 0};
const VertexPoint huma_v[] = {
{3, -2, 14},
{3, -2, 9},
{3, 2, 9},
{3, 2, 14},
{0, -2, 14},
{0, -2, 9},
{0, 2, 14},
{0, 2, 9},
{3, -1, 17},
{3, -1, 15},
{3, 1, 15},
{3, 1, 17},
{0, -1, 17},
{0, -1, 15},
{0, 1, 17},
{0, 1, 15},
{3, -2, 8},
{3, -2, 3},
{3, 0, 3},
{3, 0, 8},
{0, -2, 8},
{0, -2, 3},
{0, 0, 8},
{0, 0, 3},
{3, -3, 14},
{3, -3, 9},
{3, -2, 9},
{3, -2, 14},
{0, -3, 14},
{0, -3, 9},
{0, -2, 14},
{0, -2, 9},
{3, 2, 14},
{3, 2, 9},
{3, 3, 9},
{3, 3, 14},
{0, 2, 14},
{0, 2, 9},
{0, 3, 14},
{0, 3, 9},
{2, 0, 15},
{2, 0, 14},
{2, 0, 14},
{2, 0, 15},
{1, 0, 15},
{1, 0, 14},
{1, 0, 15},
{1, 0, 14},
{3, -2, 9},
{3, -2, 8},
{3, 2, 8},
{3, 2, 9},
{0, -2, 9},
{0, -2, 8},
{0, 2, 9},
{0, 2, 8},
{3, 0, 8},
{3, 0, 3},
{3, 2, 3},
{3, 2, 8},
{0, 0, 8},
{0, 0, 3},
{0, 2, 8},
{0, 2, 3},
{13, -2, 14},
{13, -2, 9},
{13, 2, 9},
{13, 2, 14},
{10, -2, 14},
{10, -2, 9},
{10, 2, 14},
{10, 2, 9},
{13, -1, 17},
{13, -1, 15},
{13, 1, 15},
{13, 1, 17},
{10, -1, 17},
{10, -1, 15},
{10, 1, 17},
{10, 1, 15},
{13, -2, 8},
{13, -2, 3},
{13, 0, 3},
{13, 0, 8},
{10, -2, 8},
{10, -2, 3},
{10, 0, 8},
{10, 0, 3},
{13, -3, 14},
{13, -3, 9},
{13, -2, 9},
{13, -2, 14},
{10, -3, 14},
{10, -3, 9},
{10, -2, 14},
{10, -2, 9},
{13, 2, 14},
{13, 2, 9},
{13, 3, 9},
{13, 3, 14},
{10, 2, 14},
{10, 2, 9},
{10, 3, 14},
{10, 3, 9},
{12, 0, 15},
{12, 0, 14},
{12, 0, 14},
{12, 0, 15},
{11, 0, 15},
{11, 0, 14},
{11, 0, 15},
{11, 0, 14},
{13, -2, 9},
{13, -2, 8},
{13, 2, 8},
{13, 2, 9},
{10, -2, 9},
{10, -2, 8},
{10, 2, 9},
{10, 2, 8},
{13, 0, 8},
{13, 0, 3},
{13, 2, 3},
{13, 2, 8},
{10, 0, 8},
{10, 0, 3},
{10, 2, 8},
{10, 2, 3},
};
const TexturePoint huma_t[] = {
{0,1}
};
const Face huma_f[] = {
{&tex_black, &tex_black, {0, 1, 2}, {0,0,0}},
{&tex_black, &tex_black, {0, 2, 3}, {0,0,0}},
{&tex_black, &tex_black, {4, 5, 1}, {0,0,0}},
{&tex_black, &tex_black, {4, 1, 0}, {0,0,0}},
{&tex_black, &tex_black, {6, 7, 5}, {0,0,0}},
{&tex_black, &tex_black, {6, 5, 4}, {0,0,0}},
{&tex_black, &tex_black, {3, 2, 7}, {0,0,0}},
{&tex_black, &tex_black, {3, 7, 6}, {0,0,0}},
{&tex_black, &tex_black, {6, 4, 0}, {0,0,0}},
{&tex_black, &tex_black, {6, 0, 3}, {0,0,0}},
{&tex_black, &tex_black, {1, 5, 7}, {0,0,0}},
{&tex_black, &tex_black, {1, 7, 2}, {0,0,0}},
{&tex_black, &tex_black, {8, 9, 10}, {0,0,0}},
{&tex_black, &tex_black, {8, 10, 11}, {0,0,0}},
{&tex_black, &tex_black, {12, 13, 9}, {0,0,0}},
{&tex_black, &tex_black, {12, 9, 8}, {0,0,0}},
{&tex_black, &tex_black, {14, 15, 13}, {0,0,0}},
{&tex_black, &tex_black, {14, 13, 12}, {0,0,0}},
{&tex_black, &tex_black, {11, 10, 15}, {0,0,0}},
{&tex_black, &tex_black, {11, 15, 14}, {0,0,0}},
{&tex_black, &tex_black, {14, 12, 8}, {0,0,0}},
{&tex_black, &tex_black, {14, 8, 11}, {0,0,0}},
{&tex_black, &tex_black, {9, 13, 15}, {0,0,0}},
{&tex_black, &tex_black, {9, 15, 10}, {0,0,0}},
{&tex_black, &tex_black, {16, 17, 18}, {0,0,0}},
{&tex_black, &tex_black, {16, 18, 19}, {0,0,0}},
{&tex_black, &tex_black, {20, 21, 17}, {0,0,0}},
{&tex_black, &tex_black, {20, 17, 16}, {0,0,0}},
{&tex_black, &tex_black, {22, 23, 21}, {0,0,0}},
{&tex_black, &tex_black, {22, 21, 20}, {0,0,0}},
{&tex_black, &tex_black, {19, 18, 23}, {0,0,0}},
{&tex_black, &tex_black, {19, 23, 22}, {0,0,0}},
{&tex_black, &tex_black, {22, 20, 16}, {0,0,0}},
{&tex_black, &tex_black, {22, 16, 19}, {0,0,0}},
{&tex_black, &tex_black, {17, 21, 23}, {0,0,0}},
{&tex_black, &tex_black, {17, 23, 18}, {0,0,0}},
{&tex_black, &tex_black, {24, 25, 26}, {0,0,0}},
{&tex_black, &tex_black, {24, 26, 27}, {0,0,0}},
{&tex_black, &tex_black, {28, 29, 25}, {0,0,0}},
{&tex_black, &tex_black, {28, 25, 24}, {0,0,0}},
{&tex_black, &tex_black, {30, 31, 29}, {0,0,0}},
{&tex_black, &tex_black, {30, 29, 28}, {0,0,0}},
{&tex_black, &tex_black, {27, 26, 31}, {0,0,0}},
{&tex_black, &tex_black, {27, 31, 30}, {0,0,0}},
{&tex_black, &tex_black, {30, 28, 24}, {0,0,0}},
{&tex_black, &tex_black, {30, 24, 27}, {0,0,0}},
{&tex_black, &tex_black, {25, 29, 31}, {0,0,0}},
{&tex_black, &tex_black, {25, 31, 26}, {0,0,0}},
{&tex_black, &tex_black, {32, 33, 34}, {0,0,0}},
{&tex_black, &tex_black, {32, 34, 35}, {0,0,0}},
{&tex_black, &tex_black, {36, 37, 33}, {0,0,0}},
{&tex_black, &tex_black, {36, 33, 32}, {0,0,0}},
{&tex_black, &tex_black, {38, 39, 37}, {0,0,0}},
{&tex_black, &tex_black, {38, 37, 36}, {0,0,0}},
{&tex_black, &tex_black, {35, 34, 39}, {0,0,0}},
{&tex_black, &tex_black, {35, 39, 38}, {0,0,0}},
{&tex_black, &tex_black, {38, 36, 32}, {0,0,0}},
{&tex_black, &tex_black, {38, 32, 35}, {0,0,0}},
{&tex_black, &tex_black, {33, 37, 39}, {0,0,0}},
{&tex_black, &tex_black, {33, 39, 34}, {0,0,0}},
{&tex_black, &tex_black, {40, 41, 42}, {0,0,0}},
{&tex_black, &tex_black, {40, 42, 43}, {0,0,0}},
{&tex_black, &tex_black, {44, 45, 41}, {0,0,0}},
{&tex_black, &tex_black, {44, 41, 40}, {0,0,0}},
{&tex_black, &tex_black, {46, 47, 45}, {0,0,0}},
{&tex_black, &tex_black, {46, 45, 44}, {0,0,0}},
{&tex_black, &tex_black, {43, 42, 47}, {0,0,0}},
{&tex_black, &tex_black, {43, 47, 46}, {0,0,0}},
{&tex_black, &tex_black, {46, 44, 40}, {0,0,0}},
{&tex_black, &tex_black, {46, 40, 43}, {0,0,0}},
{&tex_black, &tex_black, {41, 45, 47}, {0,0,0}},
{&tex_black, &tex_black, {41, 47, 42}, {0,0,0}},
{&tex_black, &tex_black, {48, 49, 50}, {0,0,0}},
{&tex_black, &tex_black, {48, 50, 51}, {0,0,0}},
{&tex_black, &tex_black, {52, 53, 49}, {0,0,0}},
{&tex_black, &tex_black, {52, 49, 48}, {0,0,0}},
{&tex_black, &tex_black, {54, 55, 53}, {0,0,0}},
{&tex_black, &tex_black, {54, 53, 52}, {0,0,0}},
{&tex_black, &tex_black, {51, 50, 55}, {0,0,0}},
{&tex_black, &tex_black, {51, 55, 54}, {0,0,0}},
{&tex_black, &tex_black, {54, 52, 48}, {0,0,0}},
{&tex_black, &tex_black, {54, 48, 51}, {0,0,0}},
{&tex_black, &tex_black, {49, 53, 55}, {0,0,0}},
{&tex_black, &tex_black, {49, 55, 50}, {0,0,0}},
{&tex_black, &tex_black, {56, 57, 58}, {0,0,0}},
{&tex_black, &tex_black, {56, 58, 59}, {0,0,0}},
{&tex_black, &tex_black, {60, 61, 57}, {0,0,0}},
{&tex_black, &tex_black, {60, 57, 56}, {0,0,0}},
{&tex_black, &tex_black, {62, 63, 61}, {0,0,0}},
{&tex_black, &tex_black, {62, 61, 60}, {0,0,0}},
{&tex_black, &tex_black, {59, 58, 63}, {0,0,0}},
{&tex_black, &tex_black, {59, 63, 62}, {0,0,0}},
{&tex_black, &tex_black, {62, 60, 56}, {0,0,0}},
{&tex_black, &tex_black, {62, 56, 59}, {0,0,0}},
{&tex_black, &tex_black, {57, 61, 63}, {0,0,0}},
{&tex_black, &tex_black, {57, 63, 58}, {0,0,0}},
{&tex_black, &tex_black, {64, 65, 66}, {0,0,0}},
{&tex_black, &tex_black, {64, 66, 67}, {0,0,0}},
{&tex_black, &tex_black, {68, 69, 65}, {0,0,0}},
{&tex_black, &tex_black, {68, 65, 64}, {0,0,0}},
{&tex_black, &tex_black, {70, 71, 69}, {0,0,0}},
{&tex_black, &tex_black, {70, 69, 68}, {0,0,0}},
{&tex_black, &tex_black, {67, 66, 71}, {0,0,0}},
{&tex_black, &tex_black, {67, 71, 70}, {0,0,0}},
{&tex_black, &tex_black, {70, 68, 64}, {0,0,0}},
{&tex_black, &tex_black, {70, 64, 67}, {0,0,0}},
{&tex_black, &tex_black, {65, 69, 71}, {0,0,0}},
{&tex_black, &tex_black, {65, 71, 66}, {0,0,0}},
{&tex_black, &tex_black, {72, 73, 74}, {0,0,0}},
{&tex_black, &tex_black, {72, 74, 75}, {0,0,0}},
{&tex_black, &tex_black, {76, 77, 73}, {0,0,0}},
{&tex_black, &tex_black, {76, 73, 72}, {0,0,0}},
{&tex_black, &tex_black, {78, 79, 77}, {0,0,0}},
{&tex_black, &tex_black, {78, 77, 76}, {0,0,0}},
{&tex_black, &tex_black, {75, 74, 79}, {0,0,0}},
{&tex_black, &tex_black, {75, 79, 78}, {0,0,0}},
{&tex_black, &tex_black, {78, 76, 72}, {0,0,0}},
{&tex_black, &tex_black, {78, 72, 75}, {0,0,0}},
{&tex_black, &tex_black, {73, 77, 79}, {0,0,0}},
{&tex_black, &tex_black, {73, 79, 74}, {0,0,0}},
{&tex_black, &tex_black, {80, 81, 82}, {0,0,0}},
{&tex_black, &tex_black, {80, 82, 83}, {0,0,0}},
{&tex_black, &tex_black, {84, 85, 81}, {0,0,0}},
{&tex_black, &tex_black, {84, 81, 80}, {0,0,0}},
{&tex_black, &tex_black, {86, 87, 85}, {0,0,0}},
{&tex_black, &tex_black, {86, 85, 84}, {0,0,0}},
{&tex_black, &tex_black, {83, 82, 87}, {0,0,0}},
{&tex_black, &tex_black, {83, 87, 86}, {0,0,0}},
{&tex_black, &tex_black, {86, 84, 80}, {0,0,0}},
{&tex_black, &tex_black, {86, 80, 83}, {0,0,0}},
{&tex_black, &tex_black, {81, 85, 87}, {0,0,0}},
{&tex_black, &tex_black, {81, 87, 82}, {0,0,0}},
{&tex_black, &tex_black, {88, 89, 90}, {0,0,0}},
{&tex_black, &tex_black, {88, 90, 91}, {0,0,0}},
{&tex_black, &tex_black, {92, 93, 89}, {0,0,0}},
{&tex_black, &tex_black, {92, 89, 88}, {0,0,0}},
{&tex_black, &tex_black, {94, 95, 93}, {0,0,0}},
{&tex_black, &tex_black, {94, 93, 92}, {0,0,0}},
{&tex_black, &tex_black, {91, 90, 95}, {0,0,0}},
{&tex_black, &tex_black, {91, 95, 94}, {0,0,0}},
{&tex_black, &tex_black, {94, 92, 88}, {0,0,0}},
{&tex_black, &tex_black, {94, 88, 91}, {0,0,0}},
{&tex_black, &tex_black, {89, 93, 95}, {0,0,0}},
{&tex_black, &tex_black, {89, 95, 90}, {0,0,0}},
{&tex_black, &tex_black, {96, 97, 98}, {0,0,0}},
{&tex_black, &tex_black, {96, 98, 99}, {0,0,0}},
{&tex_black, &tex_black, {100, 101, 97}, {0,0,0}},
{&tex_black, &tex_black, {100, 97, 96}, {0,0,0}},
{&tex_black, &tex_black, {102, 103, 101}, {0,0,0}},
{&tex_black, &tex_black, {102, 101, 100}, {0,0,0}},
{&tex_black, &tex_black, {99, 98, 103}, {0,0,0}},
{&tex_black, &tex_black, {99, 103, 102}, {0,0,0}},
{&tex_black, &tex_black, {102, 100, 96}, {0,0,0}},
{&tex_black, &tex_black, {102, 96, 99}, {0,0,0}},
{&tex_black, &tex_black, {97, 101, 103}, {0,0,0}},
{&tex_black, &tex_black, {97, 103, 98}, {0,0,0}},
{&tex_black, &tex_black, {104, 105, 106}, {0,0,0}},
{&tex_black, &tex_black, {104, 106, 107}, {0,0,0}},
{&tex_black, &tex_black, {108, 109, 105}, {0,0,0}},
{&tex_black, &tex_black, {108, 105, 104}, {0,0,0}},
{&tex_black, &tex_black, {110, 111, 109}, {0,0,0}},
{&tex_black, &tex_black, {110, 109, 108}, {0,0,0}},
{&tex_black, &tex_black, {107, 106, 111}, {0,0,0}},
{&tex_black, &tex_black, {107, 111, 110}, {0,0,0}},
{&tex_black, &tex_black, {110, 108, 104}, {0,0,0}},
{&tex_black, &tex_black, {110, 104, 107}, {0,0,0}},
{&tex_black, &tex_black, {105, 109, 111}, {0,0,0}},
{&tex_black, &tex_black, {105, 111, 106}, {0,0,0}},
{&tex_black, &tex_black, {112, 113, 114}, {0,0,0}},
{&tex_black, &tex_black, {112, 114, 115}, {0,0,0}},
{&tex_black, &tex_black, {116, 117, 113}, {0,0,0}},
{&tex_black, &tex_black, {116, 113, 112}, {0,0,0}},
{&tex_black, &tex_black, {118, 119, 117}, {0,0,0}},
{&tex_black, &tex_black, {118, 117, 116}, {0,0,0}},
{&tex_black, &tex_black, {115, 114, 119}, {0,0,0}},
{&tex_black, &tex_black, {115, 119, 118}, {0,0,0}},
{&tex_black, &tex_black, {118, 116, 112}, {0,0,0}},
{&tex_black, &tex_black, {118, 112, 115}, {0,0,0}},
{&tex_black, &tex_black, {113, 117, 119}, {0,0,0}},
{&tex_black, &tex_black, {113, 119, 114}, {0,0,0}},
{&tex_black, &tex_black, {120, 121, 122}, {0,0,0}},
{&tex_black, &tex_black, {120, 122, 123}, {0,0,0}},
{&tex_black, &tex_black, {124, 125, 121}, {0,0,0}},
{&tex_black, &tex_black, {124, 121, 120}, {0,0,0}},
{&tex_black, &tex_black, {126, 127, 125}, {0,0,0}},
{&tex_black, &tex_black, {126, 125, 124}, {0,0,0}},
{&tex_black, &tex_black, {123, 122, 127}, {0,0,0}},
{&tex_black, &tex_black, {123, 127, 126}, {0,0,0}},
{&tex_black, &tex_black, {126, 124, 120}, {0,0,0}},
{&tex_black, &tex_black, {126, 120, 123}, {0,0,0}},
{&tex_black, &tex_black, {121, 125, 127}, {0,0,0}},
{&tex_black, &tex_black, {121, 127, 122}, {0,0,0}},
};
const Mesh huma_m = {huma_v, 128, huma_t, 1, huma_f, 192};
Object huma_o1 = {&huma_m, {0, 20, 0}, N, 0};
Object* objects_exemple[] = {&huma_o1};
Object cube_o1 = {&object_humanoid, {0, 0, 0}, N, 0};
Object* objects_exemple[] = {&cube_o1};
Map map_exemple = {objects_exemple, 1, true, true};

View File

@ -1,40 +0,0 @@
class Lexer:
def __init__(self,Data):
Data = Data.split("\n",1)[1]
self.data = Data.split()
self.data = self.data[0:len(self.data)-2]
def lex(self,indice):
return self.data[indice]
def getData(self):
return self.data
class Parser:
def __init__(self,Lexer):
self.lexer = Lexer
def parse(self,Data):
list_triangles = [[[0,0,0],[0,0,0],[0,0,0]] for i in range(int(len(Data)/21))]
a=0
for i in range(0,len(Data),21):
for j in range(0,3):
list_triangles[a][0][j] = float(self.lexer.lex(i+8+j))
for j in range(0,3):
list_triangles[a][1][j] = float(self.lexer.lex(i+12+j))
for j in range(0,3):
list_triangles[a][2][j] = float(self.lexer.lex(i+16+j))
a+=1
return list_triangles
with open("cube.stl") as file:
data = file.read()
lexer = Lexer(data)
Data = lexer.getData()
parser = Parser(lexer)
import pprint
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(parser.parse(Data))