C1 grand prix / tokyo xtreme racer drift 2
Posted: Tue Jul 07, 2020 1:01 pm
Hello there,
i'd like to have some help figuring out the face format of these 2 games, the car models are kinda weird, first of all, the files use a buffer of vertex data, mostly 50 vertexes at a time, inside there are the vertexes in 3 Float(little endian) form, afterwards the uvs in 2Short, then there is something weird, that looks a bit like some normals, and lastly some kind of signature, but this is where it all gets kinda funky, because this part is the one that designates faces in the track geometry or even in other games, so if you guys might have a look and tell me about it...
(blue are ps2 render pipeline flags? maybe mips assembly to tell what is what, havent found much info on that regard besides having the vertcount on the 3rd byte)(both red are my hints to what could be normals/fis)
here the test files
https://gofile.io/d/IDFoME
000004b8.dat (Subaru wrx wagon; C1 test file)
000000a6.sdb(Honda civic; TXRD2 test file)
for now this is what i get using a simple count tristrip generator, but i guess there must be jumps to avoid the extra triangulation
although i know that both should use TIM2 textures, txrd2 seems to obfuscate the header of the textures, any hint on that regard would also be great...
also in case anyone needs some hints how i did it, here the code im using in mrp
i'd like to have some help figuring out the face format of these 2 games, the car models are kinda weird, first of all, the files use a buffer of vertex data, mostly 50 vertexes at a time, inside there are the vertexes in 3 Float(little endian) form, afterwards the uvs in 2Short, then there is something weird, that looks a bit like some normals, and lastly some kind of signature, but this is where it all gets kinda funky, because this part is the one that designates faces in the track geometry or even in other games, so if you guys might have a look and tell me about it...
(blue are ps2 render pipeline flags? maybe mips assembly to tell what is what, havent found much info on that regard besides having the vertcount on the 3rd byte)(both red are my hints to what could be normals/fis)
here the test files
https://gofile.io/d/IDFoME
000004b8.dat (Subaru wrx wagon; C1 test file)
000000a6.sdb(Honda civic; TXRD2 test file)
for now this is what i get using a simple count tristrip generator, but i guess there must be jumps to avoid the extra triangulation
although i know that both should use TIM2 textures, txrd2 seems to obfuscate the header of the textures, any hint on that regard would also be great...
also in case anyone needs some hints how i did it, here the code im using in mrp
Code: Select all
import mrp
import sys
f = mrp.get_bfile()
positions = []
contp = [0]
bytenum = []
mat = open('newoffs.txt', 'w')
crap = open('crap.txt', 'w')
f.seek(0xD170)
double = f.readDouble()
#-----------------------------------------------------------------
modelflag1 = 0x01000202
modelflag2 = 0x6c028000
containerflag = 0x60000000
endflag = 0x17000000
f.seek(0,2)
eof = f.tell()-8
#deviation
f.seek(0x8)
#eof = f.readInt()+32
#override
#eof = 0x48F0
f.seek(0)
#testing = f.readDouble()
pointer = f.tell()
#while testing != double:
maxn = 0
f.seek(0)
while pointer < eof:
testing = f.readInt()
nextint = f.readInt()
pointer = f.tell()
if testing == modelflag1 and nextint == modelflag2:
curpos = f.tell()
byte = f.readByte()
f.seek(-1,1)
#print(curpos,(curpos%16),byte,file = mat)
positions.append(curpos)
elif testing == containerflag:
curpos = f.tell()
contp.append(curpos)
f.seek(8,1)
f.seek(0)
verts = []
faces = []
uvs = []
normals = []
meshes = []
curfi = 0
count = 0
end = 0
positions.append(0)
contp.append(0)
print(len(positions))
while end == 0:
#for i in range(1):
for i in range(len(contp)):#len(contp)
pos = f.tell()
verts = []
faces = []
uvs = []
normals = []
#normalsflag = 0
curnum = i+1
curmesha = "mesh"+str(i)
curfi = 0
reps = 0
if count > (len(positions)-2):
nextpos = 0
end = 1
curnum = 99999
else:
#print(count + 1, len positions)
nextpos = positions[count+1]
#print("--------------" + str(count)+"\t" +str(contp[i+1])+"-------------"+str(f.tellHex())+"\t"+str(hex(positions[count])))
#print(hex(pos), hex(contp[curnum]), hex(nextpos), hex(contp[curnum]))
if end == 0:
if nextpos > contp[curnum]:
curnum = curnum + 1
print(curnum, len(contp))
while pos < contp[curnum] and nextpos < contp[curnum]and count < len(positions) and end == 0:
verts = []
faces = []
uvs = []
curfi = 0
#normals = []
curmesh = curmesha+"_"+str(reps)
print(curmesh, file = crap)
reps = reps + 1
jump = positions[count]
if curnum == 12:
print(f.tellHex())
f.seek(jump)
#print((jump -8)%16)
count = count+1
#print(count, f.tellHex(),vc)
f.seek(38,1)
vc = f.readByte()
f.seek(1,1)
for i in range(vc):
vert = f.read3Float()
verts.append(vert)
f.seek(4,1)
for i in range(vc):
uv = f.read2Short()
uvs.append(uv)
f.seek(4,1)
for i in range(vc):
a = f.readbyte()
b = f.readbyte()
c = f.readbyte()
normal = (a,b,c)
normalbin = (str(bin(a)),str(bin(b)),str(bin(c)))
print((normal,normalbin), file = crap)
normals.append(normal)
#f.seek(4,1)
pos = f.tell()
rest = 16 -(f.tell() % 16)
f.seek(rest+3,1)
#print (rest,hex(pos))
test = f.readbyte()
print(f.tellHex(),count,curmesh)
if test == 98:
ffcheck = 0
#curfi = 0
#print(f.tellHex(),count,curmesh)
for i in range(vc):
test2 = f.readbyte()
binar = str(bin(test2))
binary = int(binar[-1])
if binary == 1:
if ffcheck == 0:
#faces.append(65535)
ffcheck = 1
else:
ffcheck = 0
else:
ffcheck = 0
faces.append(curfi)
curfi = curfi + 1
else:
for i in range(vc):
faces.append(curfi)
curfi = curfi + 1
#faces.append(65535)
#pos = f.tell()
if count > (len(positions)-1):
end = 1
nextpos = 0
else:
nextpos = positions[count]
#print("normals "+str(normalsflag))
#print (curmesh,curnum, reps)
if len(verts) != 0 and len(faces) != 0:
mrp.create_mesh(curmesh)
mesh = mrp.get_mesh(curmesh)
#mesh = mrp.get_mesh()
meshes.append(curmesh)
#print(test)
mesh.set_vertices(verts)
mesh.set_faces(faces,fm="TStripFF")
mesh.set_uvs(uvs,tp="Short")
mesh.set_uvs_indices(faces,fm="TStripFF")
mesh.set_normals(normals)
#meshes.append(curmesh)
print(vc,len(verts))
print(curfi,len(faces))
mrp.render(meshes)
mrp.view_uvs()
mrp.print_mesh()
print("ok", f.tellHex(),count,hex(positions[count+1]),hex(nextpos))
print(len(contp),len(positions),hex(eof))
sys.exit("script halt")#--------------------------------------------