Initial import.
parent
a9cb4fa622
commit
5c33ac8b38
@ -1,3 +1,24 @@
|
||||
# geopy
|
||||
|
||||
Python tool for manipulating .geo files.
|
||||
Python tools for manipulating .geo files. The long term plan is to be able to export .geos direct from Blender.
|
||||
|
||||
## geo.py
|
||||
Contains the Geo class, which represents the contents of .geo files. Can be run to test the reading and writing functionality.
|
||||
|
||||
geo.py <infile.geo> [<outfile.geo>]
|
||||
|
||||
If only an input file is specified, it will read the input and dump the contents of the .geo to the console.
|
||||
|
||||
If an output file is specified, it will read the input file, and write the contents to the output as a new .geo file.
|
||||
|
||||
## stl_dump
|
||||
Dumps the meshes of a .geo file to .stl files. Used for testing and validation, as .stl isn't useful for games.
|
||||
|
||||
stl_dump.py <file.geo>
|
||||
|
||||
Dumps all the meshes contained in <file.geo> to <geo_name>/<model_name.stl>. <geo_name> and <model_name> are read from the .geo.
|
||||
|
||||
|
||||
##Known issues:
|
||||
- Not all structures are read from the .geo file. (AltPivotInfo)
|
||||
- Not all structures are regenerated when writing a .geo file. (PolyGrid and Reductions)
|
||||
|
@ -0,0 +1,120 @@
|
||||
|
||||
|
||||
#List of bone ids. Should be kept strictly ordered.
|
||||
BONES_LIST = [
|
||||
"BONEID_HIPS",
|
||||
"BONEID_WAIST",
|
||||
"BONEID_CHEST",
|
||||
"BONEID_NECK",
|
||||
"BONEID_HEAD",
|
||||
"BONEID_COL_R",
|
||||
"BONEID_COL_L",
|
||||
"BONEID_UARMR",
|
||||
"BONEID_UARML",
|
||||
"BONEID_LARMR",
|
||||
"BONEID_LARML",
|
||||
"BONEID_HANDR",
|
||||
"BONEID_HANDL",
|
||||
"BONEID_F1_R",
|
||||
"BONEID_F1_L",
|
||||
"BONEID_F2_R",
|
||||
"BONEID_F2_L",
|
||||
"BONEID_T1_R",
|
||||
"BONEID_T1_L",
|
||||
"BONEID_T2_R",
|
||||
"BONEID_T2_L",
|
||||
"BONEID_T3_R",
|
||||
"BONEID_T3_L",
|
||||
"BONEID_ULEGR",
|
||||
"BONEID_ULEGL",
|
||||
"BONEID_LLEGR",
|
||||
"BONEID_LLEGL",
|
||||
"BONEID_FOOTR",
|
||||
"BONEID_FOOTL",
|
||||
"BONEID_TOER",
|
||||
"BONEID_TOEL",
|
||||
|
||||
"BONEID_FACE",
|
||||
"BONEID_DUMMY",
|
||||
"BONEID_BREAST",
|
||||
"BONEID_BELT",
|
||||
"BONEID_GLOVEL",
|
||||
"BONEID_GLOVER",
|
||||
"BONEID_BOOTL",
|
||||
"BONEID_BOOTR",
|
||||
"BONEID_RINGL",
|
||||
"BONEID_RINGR",
|
||||
"BONEID_WEPL",
|
||||
"BONEID_WEPR",
|
||||
"BONEID_HAIR",
|
||||
"BONEID_EYES",
|
||||
"BONEID_EMBLEM",
|
||||
"BONEID_SPADL",
|
||||
"BONEID_SPADR",
|
||||
"BONEID_BACK",
|
||||
"BONEID_NECKLINE",
|
||||
"BONEID_CLAWL",
|
||||
"BONEID_CLAWR",
|
||||
"BONEID_GUN",
|
||||
|
||||
"BONEID_RWING1",
|
||||
"BONEID_RWING2",
|
||||
"BONEID_RWING3",
|
||||
"BONEID_RWING4",
|
||||
|
||||
"BONEID_LWING1",
|
||||
"BONEID_LWING2",
|
||||
"BONEID_LWING3",
|
||||
"BONEID_LWING4",
|
||||
|
||||
"BONEID_MYSTIC",
|
||||
|
||||
"BONEID_SLEEVEL",
|
||||
"BONEID_SLEEVER",
|
||||
"BONEID_ROBE",
|
||||
"BONEID_BENDMYSTIC",
|
||||
|
||||
"BONEID_COLLAR",
|
||||
"BONEID_BROACH",
|
||||
|
||||
"BONEID_BOSOMR",
|
||||
"BONEID_BOSOML",
|
||||
|
||||
"BONEID_TOP",
|
||||
"BONEID_SKIRT",
|
||||
"BONEID_SLEEVES",
|
||||
|
||||
"BONEID_BROW",
|
||||
"BONEID_CHEEKS",
|
||||
"BONEID_CHIN",
|
||||
"BONEID_CRANIUM",
|
||||
"BONEID_JAW",
|
||||
"BONEID_NOSE",
|
||||
|
||||
"BONEID_HIND_ULEGL",
|
||||
"BONEID_HIND_LLEGL",
|
||||
"BONEID_HIND_FOOTL",
|
||||
"BONEID_HIND_TOEL",
|
||||
"BONEID_HIND_ULEGR",
|
||||
"BONEID_HIND_LLEGR",
|
||||
"BONEID_HIND_FOOTR",
|
||||
"BONEID_HIND_TOER",
|
||||
"BONEID_FORE_ULEGL",
|
||||
"BONEID_FORE_LLEGL",
|
||||
"BONEID_FORE_FOOTL",
|
||||
"BONEID_FORE_TOEL",
|
||||
"BONEID_FORE_ULEGR",
|
||||
"BONEID_FORE_LLEGR",
|
||||
"BONEID_FORE_FOOTR",
|
||||
"BONEID_FORE_TOER",
|
||||
|
||||
"BONEID_LEG_L_JET1",
|
||||
"BONEID_LEG_L_JET2",
|
||||
"BONEID_LEG_R_JET1",
|
||||
"BONEID_LEG_R_JET2",
|
||||
]
|
||||
|
||||
BONES_LOOKUP = {}
|
||||
|
||||
for i in range(len(BONES_LIST)):
|
||||
BONES_LOOKUP[BONES_LIST[i]] = i
|
@ -0,0 +1,42 @@
|
||||
import struct
|
||||
import geo
|
||||
import sys
|
||||
import os
|
||||
import os.path
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage:")
|
||||
print(" %s <file.geo>")
|
||||
print("Dumps all the meshes contained in <file.geo> to <geo_name>/<model_name.stl>.")
|
||||
print("<geo_name> and <model_name> are read from the .geo.")
|
||||
|
||||
fh = open(sys.argv[1], "rb")
|
||||
g = geo.Geo()
|
||||
g.loadFromFile(fh)
|
||||
|
||||
geo_name = g.header_modelheader_name.decode("utf-8")
|
||||
if not os.path.exists(geo_name):
|
||||
os.mkdir(geo_name)
|
||||
|
||||
for i in range(len(g.models)):
|
||||
model = g.models[i]
|
||||
model_name = model.name.decode("utf-8")
|
||||
filename = geo_name + "/" + model_name + ".stl"
|
||||
print(filename)
|
||||
ofh = open(filename, "wb")
|
||||
ofh.write(b"\x00" * 80)
|
||||
ofh.write(struct.pack("<i", model.tri_count))
|
||||
for i in range(model.tri_count):
|
||||
tri_index = model.tris[i]
|
||||
tri_verts = (model.verts[tri_index[0]],
|
||||
model.verts[tri_index[1]],
|
||||
model.verts[tri_index[2]])
|
||||
t = b""
|
||||
#print "%5d: %s" % (i, tri_verts)
|
||||
t += struct.pack("<fff", 0, 0, 0)
|
||||
for v in tri_verts:
|
||||
t += struct.pack("<fff", v[0], v[1], v[2])
|
||||
t += b"\x00\x00"
|
||||
ofh.write(t)
|
||||
ofh.close()
|
||||
|
Loading…
Reference in New Issue