@ -743,11 +743,11 @@ class Model:
#Encode data into the main block.
#Encode data into the main block.
#note: PackData should go first, otherwise other ptr types might point to the start of the data block, which would result in a 0 point, which is treated as not present.
#note: PackData should go first, otherwise other ptr types might point to the start of the data block, which would result in a 0 point, which is treated as not present.
self . pack_tris = self . geo . encodeMainDataPackedDeltas ( self . tris , 3 , len ( self . tris ) , " I " , 1 )
self . pack_tris = self . geo . encodeMainDataPackedDeltas ( self . tris , 3 , self . tris and len ( self . tris ) , " I " , 1 )
self . pack_verts = self . geo . encodeMainDataPackedDeltas ( self . verts , 3 , len ( self . verts ) , " f " , 0x8000 )
self . pack_verts = self . geo . encodeMainDataPackedDeltas ( self . verts , 3 , self . verts and len ( self . verts ) , " f " , 0x8000 )
self . pack_norms = self . geo . encodeMainDataPackedDeltas ( self . norms , 3 , len ( self . norms ) , " f " , 0x100 )
self . pack_norms = self . geo . encodeMainDataPackedDeltas ( self . norms , 3 , self . norms and len ( self . norms ) , " f " , 0x100 )
self . pack_sts = self . geo . encodeMainDataPackedDeltas ( self . sts , 2 , len ( self . ver ts) , " f " , 0x1000 )
self . pack_sts = self . geo . encodeMainDataPackedDeltas ( self . sts , 2 , self . sts and len ( self . s ts) , " f " , 0x1000 )
self . pack_sts3 = self . geo . encodeMainDataPackedDeltas ( self . sts3 , 2 , len ( self . verts ) , " f " , 0x8000 )
self . pack_sts3 = self . geo . encodeMainDataPackedDeltas ( self . sts3 , 2 , self . sts3 and len ( self . sts3 ) , " f " , 0x8000 )
self . pack_weights = self . geo . encodeMainDataPacked ( self . weights_data )
self . pack_weights = self . geo . encodeMainDataPacked ( self . weights_data )
self . pack_matidxs = self . geo . encodeMainDataPacked ( self . matidxs_data )
self . pack_matidxs = self . geo . encodeMainDataPacked ( self . matidxs_data )
self . pack_grid = self . geo . encodeMainDataPacked ( self . grid_data )
self . pack_grid = self . geo . encodeMainDataPacked ( self . grid_data )
@ -780,8 +780,8 @@ class Model:
for t in self . tex_idx :
for t in self . tex_idx :
texidx_data . encode ( " <HH " , * t )
texidx_data . encode ( " <HH " , * t )
self . tex_count = len ( self . tex_idx )
self . tex_count = len ( self . tex_idx )
self . vert_count = len ( self . verts )
self . vert_count = self . verts and len ( self . verts ) or 0
self . tri_count = len ( self . tris )
self . tri_count = self . tris and len ( self . tris ) or 0
self . name_ptr = len ( self . geo . header_objname_data )
self . name_ptr = len ( self . geo . header_objname_data )
self . geo . header_objname_data + = self . name + ZERO_BYTE
self . geo . header_objname_data + = self . name + ZERO_BYTE
self . geo . header_objnames . append ( self . name )
self . geo . header_objnames . append ( self . name )
@ -1221,22 +1221,24 @@ class Geo:
return self . models [ - 1 ]
return self . models [ - 1 ]
if __name__ == " __main__ " :
if __name__ == " __main__ " :
if len ( sys . argv ) < = 1 :
if len ( sys . argv ) < = 1 or len ( sys . argv ) > 3 :
print ( " Usage: " )
print ( " Usage: " )
print ( " %s <file_in> [<file_out>] " )
print ( " %s <file_in> [<file_out>] " % ( sys . argv [ 0 ] , ) )
print ( " Test loads a .geo file, dumps its content, and optionally writes its content out. " )
print ( " Test loads a .geo file, dumps its content, and optionally writes its content out. " )
exit ( 0 )
exit ( 0 )
fh = open ( sys . argv [ 1 ] , " rb " )
fh = open ( sys . argv [ 1 ] , " rb " )
geo = Geo ( )
geo . loadFromFile ( fh )
fh . close ( )
#print(sys.argv)
#print(sys.argv)
if len ( sys . argv ) < = 2 :
if len ( sys . argv ) < = 2 :
fho = None
fho = None
else :
else :
fho = open ( sys . argv [ 2 ] , " wb " )
fho = open ( sys . argv [ 2 ] , " wb " )
geo = Geo ( )
geo . loadFromFile ( fh )
if fho is not None :
if fho is not None :
data = geo . saveToData ( )
#geo.dump()
#geo.dump()
geo. saveToFile ( fho )
fho. write ( data )
else :
else :
geo . dump ( )
geo . dump ( )
#print("%s" % [geo.header_data])
#print("%s" % [geo.header_data])