batch
This commit is contained in:
parent
c3b83de9cb
commit
8364b19892
@ -36,7 +36,7 @@ from NinjaMotion import NinjaMotion
|
|||||||
|
|
||||||
class NinjaModel:
|
class NinjaModel:
|
||||||
|
|
||||||
def __init__(self, model_name, tex_name):
|
def __init__(self, model_name, tex_name = ''):
|
||||||
|
|
||||||
# File Information
|
# File Information
|
||||||
self.model_name = model_name
|
self.model_name = model_name
|
||||||
|
37
PowerVR.py
37
PowerVR.py
@ -67,9 +67,11 @@ class PowerVR: # {
|
|||||||
def __init__(self, filename): # {
|
def __init__(self, filename): # {
|
||||||
|
|
||||||
# File Information
|
# File Information
|
||||||
|
|
||||||
|
base = os.path.basename(filename)
|
||||||
|
self.name = os.path.splitext(base)[0]
|
||||||
|
print(self.name)
|
||||||
self.path = 'input/' + filename
|
self.path = 'input/' + filename
|
||||||
self.file = open(self.path, 'rb')
|
|
||||||
self.length = os.path.getsize(self.path)
|
|
||||||
|
|
||||||
# Textures
|
# Textures
|
||||||
self.tex_list = []
|
self.tex_list = []
|
||||||
@ -78,15 +80,31 @@ class PowerVR: # {
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def parse(self):
|
def parse(self):
|
||||||
bytes = self.file.read(4)
|
|
||||||
|
|
||||||
if bytes == b'PVMH':
|
self.file = open(self.path, 'rb')
|
||||||
self.readPvm()
|
self.length = os.path.getsize(self.path)
|
||||||
elif bytes == b'PVRT':
|
|
||||||
|
while self.file.tell() < self.length:
|
||||||
|
|
||||||
bytes = self.file.read(4)
|
bytes = self.file.read(4)
|
||||||
p = struct.unpack('I', bytes)
|
|
||||||
pvrt_len = p[0]
|
if bytes == b'PVMH':
|
||||||
self.readPvr()
|
self.readPvm()
|
||||||
|
break
|
||||||
|
elif bytes == b'PVRT':
|
||||||
|
print("-- READ PVRT--")
|
||||||
|
bytes = self.file.read(4)
|
||||||
|
p = struct.unpack('I', bytes)
|
||||||
|
pvrt_len = p[0]
|
||||||
|
tex = NinjaTexture()
|
||||||
|
tex.setIndex(0)
|
||||||
|
tex.setName(self.name)
|
||||||
|
raw = self.readPvr()
|
||||||
|
tex.setRaw(raw)
|
||||||
|
tex.setWidth(self.width)
|
||||||
|
tex.setHeight(self.height)
|
||||||
|
self.tex_list.append(tex)
|
||||||
|
break
|
||||||
|
|
||||||
for tex in self.tex_list:
|
for tex in self.tex_list:
|
||||||
if not tex.raw:
|
if not tex.raw:
|
||||||
@ -119,7 +137,6 @@ class PowerVR: # {
|
|||||||
flags = p[0]
|
flags = p[0]
|
||||||
tex_count = p[1]
|
tex_count = p[1]
|
||||||
|
|
||||||
self.tex_list = []
|
|
||||||
for i in range(tex_count):
|
for i in range(tex_count):
|
||||||
bytes = self.file.read(2)
|
bytes = self.file.read(2)
|
||||||
p = struct.unpack('H', bytes)
|
p = struct.unpack('H', bytes)
|
||||||
|
80
__init__.py
80
__init__.py
@ -25,16 +25,82 @@
|
|||||||
|
|
||||||
from NinjaModel import NinjaModel
|
from NinjaModel import NinjaModel
|
||||||
|
|
||||||
|
########################################################
|
||||||
|
## MODELS (MISC) ##
|
||||||
|
########################################################
|
||||||
|
|
||||||
|
model_file = 'MISC/BUTTON01.NJ'
|
||||||
|
texture_file = 'MISC/BUTTON01.PVR'
|
||||||
|
nj = NinjaModel(model_file, texture_file)
|
||||||
|
nj.parse()
|
||||||
|
nj.export()
|
||||||
|
|
||||||
|
model_file = 'MISC/BUTTON02.NJ'
|
||||||
|
texture_file = 'MISC/BUTTON01.PVR'
|
||||||
|
nj = NinjaModel(model_file, texture_file)
|
||||||
|
nj.parse()
|
||||||
|
nj.export()
|
||||||
|
|
||||||
|
model_file = 'MISC/CLOUD01.NJ'
|
||||||
|
texture_file = 'MISC/CLOUD01.PVM'
|
||||||
|
nj = NinjaModel(model_file, texture_file)
|
||||||
|
nj.parse()
|
||||||
|
nj.export()
|
||||||
|
|
||||||
|
model_file = 'MISC/DEMO1.NJ'
|
||||||
|
texture_file = 'MISC/DEMO1.PVM'
|
||||||
|
nj = NinjaModel(model_file, texture_file)
|
||||||
|
nj.parse()
|
||||||
|
nj.export()
|
||||||
|
|
||||||
|
model_file = 'MISC/END000A_20SKY.NJ'
|
||||||
|
texture_file = 'MISC/END000A_20SKY.PVM'
|
||||||
|
nj = NinjaModel(model_file, texture_file)
|
||||||
|
nj.parse()
|
||||||
|
nj.export()
|
||||||
|
|
||||||
|
model_file = 'MISC/END000A_BIRDS.NJ'
|
||||||
|
texture_file = 'MISC/END000A_BIRDS.PVM'
|
||||||
|
nj = NinjaModel(model_file, texture_file)
|
||||||
|
nj.parse()
|
||||||
|
nj.export()
|
||||||
|
|
||||||
|
model_file = 'MISC/KIRI.NJ'
|
||||||
|
texture_file = 'MISC/KIRI.PVM'
|
||||||
|
nj = NinjaModel(model_file, texture_file)
|
||||||
|
nj.parse()
|
||||||
|
nj.export()
|
||||||
|
|
||||||
|
model_file = 'MISC/KUMO01_KUMO01_1.NJ'
|
||||||
|
nj = NinjaModel(model_file)
|
||||||
|
nj.parse()
|
||||||
|
nj.export()
|
||||||
|
|
||||||
|
model_file = 'MISC/KUMO01_KUMO02_1.NJ'
|
||||||
|
nj = NinjaModel(model_file)
|
||||||
|
nj.parse()
|
||||||
|
nj.export()
|
||||||
|
|
||||||
|
model_file = 'MISC/LEVEL01.NJ'
|
||||||
|
nj = NinjaModel(model_file)
|
||||||
|
nj.parse()
|
||||||
|
nj.export()
|
||||||
|
|
||||||
|
model_file = 'MISC/LEVEL02.NJ'
|
||||||
|
nj = NinjaModel(model_file)
|
||||||
|
nj.parse()
|
||||||
|
nj.export()
|
||||||
|
|
||||||
|
########################################################
|
||||||
|
## MODELS (OBJ) ##
|
||||||
|
########################################################
|
||||||
|
|
||||||
model_file = 'OBJ/IKAL.NJ'
|
model_file = 'OBJ/IKAL.NJ'
|
||||||
texture_file = 'OBJ/IKAL.PVM'
|
texture_file = 'OBJ/IKAL.PVM'
|
||||||
nj = NinjaModel(model_file, texture_file)
|
nj = NinjaModel(model_file, texture_file)
|
||||||
nj.parse()
|
nj.parse()
|
||||||
nj.export()
|
nj.export()
|
||||||
|
|
||||||
"""
|
########################################################
|
||||||
model_file = 'MISC/BUTTON01.NJ'
|
## MODELS (END) ##
|
||||||
texture_file = 'MISC/BUTTON01.PVR'
|
########################################################
|
||||||
nj = NinjaModel(model_file, texture_file)
|
|
||||||
nj.parse()
|
|
||||||
nj.export()
|
|
||||||
"""
|
|
||||||
|
Loading…
Reference in New Issue
Block a user