Here's the file: http://www.mediafire.com/download/mvk9j ... n_1973.a3x
So far I've found the Vert Count at 0xF4 and the vertices starting at 0xF8 stored in Little Endian Floats together with the normals. The Face Count for this file can be found at 0x1A50FC and the Face Indexes start right after that together with what I think is UV data (?). I've tried writing a Python importer and thanks to chrrox' tutorial I believe I managed to get the basics going. Not elegant of course, but I can get the vertices into Noesis if I leave the Face data untouched. What I can't get my head around is the Face Indexes bundled together with the other data. I've been trying a few things and been on Google to understand better but the logic still eludes me. I think there might be a simple solution if you know what you're doing but with Python I'm just not there yet. It's only one mesh and I'm not sure if I'm even gonna use it, but it puzzles me. So before I spend too much time trying to figure it all out by myself maybe someone might have a quick look and steer me in the right direction.
Code: Select all
#Noesis Python model import+export test module, imports/exports some data from/to a made-up format
from inc_noesis import *
import noesis
#rapi methods should only be used during handler callbacks
import rapi
#registerNoesisTypes is called by Noesis to allow the script to register formats.
#Do not implement this function in script files unless you want them to be dedicated format modules!
def registerNoesisTypes():
handle = noesis.register("Aras 360", ".a3x")
noesis.setHandlerTypeCheck(handle, noepyCheckType)
noesis.setHandlerLoadModel(handle, noepyLoadModel) #see also noepyLoadModelRPG
#noesis.setHandlerWriteModel(handle, noepyWriteModel)
#noesis.setHandlerWriteAnim(handle, noepyWriteAnim)
noesis.logPopup()
#print("The log can be useful for catching debug prints from preview loads.\nBut don't leave it on when you release your script, or it will probably annoy people.")
return 1
NOEPY_HEADER = "a3x"
#check if it's this type based on the data
def noepyCheckType(data):
bs = NoeBitStream(data)
if len(data) < 8:
return 0
if bs.readBytes(8).decode("ASCII").rstrip("\0") != NOEPY_HEADER:
return 0
return 1
#load the model
def noepyLoadModel(data, mdlList):
ctx = rapi.rpgCreateContext()
bs = NoeBitStream(data)
bs.seek(0xf4, NOESEEK_ABS)
VCount = bs.read("i")
print(VCount)
pos = bs.tell()
print(pos)
bs.seek(0x1a50fc, NOESEEK_ABS)
FCount = bs.read("i")
print(FCount)
pos = bs.tell()
print(pos)
bs.seek(0xf8, NOESEEK_ABS)
VertBuff = bs.readBytes(VCount[0] * 0x18)
rapi.rpgBindPositionBufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, 24, 0)
rapi.rpgBindNormalBufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, 24, 12)
rapi.rpgCommitTriangles(None, noesis.RPGEODATA_USHORT, VCount[0], noesis.RPGEO_POINTS, 1)
pos = bs.tell()
print(pos)
bs.seek(0x1a5100, NOESEEK_ABS)
FaceBuff = bs.readBytes(FCount[0] * 0x18)
rapi.rpgBindPositionBufferOfs(VertBuff, noesis.RPGEODATA_USHORT, 24, 0)
rapi.rpgBindUV1BufferOfs(VertBuff, noesis.RPGEODATA_USHORT, 24, 12)
rapi.rpgCommitTriangles(VertBuff, noesis.RPGEODATA_USHORT, FCount[0], noesis.RPGEO_TRIANGLE_STRIP, 1)
pos = bs.tell()
print(pos)
mdl = rapi.rpgConstructModel()
mdlList.append(mdl) #important, don't forget to put your loaded model in the mdlList
rapi.rpgClearBufferBinds()
return 1

