Ridge Racer 6 mdl extract from X360

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
Bl4z3_Ice
Posts: 15
Joined: Fri Mar 18, 2022 8:03 am

Ridge Racer 6 mdl extract from X360

Post by Bl4z3_Ice »

can anyone help me with Ridge Racer 6 MDL file to objs along with textures pls?
Bl4z3_Ice
Posts: 15
Joined: Fri Mar 18, 2022 8:03 am

Re: Ridge Racer 6 mdl extract from X360

Post by Bl4z3_Ice »

file sample
h3x3r
Posts: 165
Joined: Wed Jun 01, 2016 5:53 pm

Re: Ridge Racer 6 mdl extract from X360

Post by h3x3r »

Here is bms for tex file. Just add *.dat extension bcs qbms don't like extensionless files. It just dump what is inside. No conversion... Maybe i can write noesis script for textures.

Code: Select all

################################
# Ridge Racer 6 - Tex Unpacker #
################################
get BaseFileName basename
get FileSize asize
endian big

getdstring Dummy 0x10
savepos BaseOffset
get texCount uint32

for i = 0 < texCount
	get texOffset uint32
	savepos TMP
	get texNextOffset uint32
	xmath texOffset_tmp "texOffset + BaseOffset"
	xmath texNextOffset_tmp "texNextOffset + BaseOffset"
	xmath texDataSize "texNextOffset - texOffset"
	xmath texLastDataSize "FileSize - texOffset_tmp"
	goto texOffset_tmp
	getdstring Dummy 0x8
	get texFileId uint32
	string Name p= "%s/0x%08X.tex" BaseFileName texFileId
		
	if texNextOffset == 1379292160
		log Name texOffset_tmp texLastDataSize
	else
		log Name texOffset_tmp texDataSize
	endif
	goto TMP
next i
And here is Noesis script supporting provided samples.

Code: Select all

from inc_noesis import *
import noesis
import rapi
import os

def registerNoesisTypes():
   handle = noesis.register("Ridge Racer 6 - Texture", ".tex")
   noesis.setHandlerTypeCheck(handle, noepyCheckType)
   noesis.setHandlerLoadRGBA(handle, noepyLoadRGBA)
   noesis.logPopup()
   return 1
        
def noepyCheckType(data):
   bs = NoeBitStream(data,NOE_BIGENDIAN)
   if len(data) < 20:
      return 0
   if bs.readUInt() != 0x52365400:
      return 0
   return 1
   
def noepyLoadRGBA(data, texList):
    bs = NoeBitStream(data,NOE_BIGENDIAN)
    texBaseName = rapi.getExtensionlessName(rapi.getLocalFileName(rapi.getInputName()))
    texMagic = bs.readUInt()
    bs.readBytes(4)
    texFileId = bs.readUInt()
    bs.readBytes(11)
    texPixelFormat = bs.readUByte()
    texWidth = bs.readUInt()
    texHeight = bs.readUInt()
    bs.readBytes(16)
        
    if texPixelFormat == 113:
        bs.texSize = texWidth * texHeight # RGB8
        print("Pixel Format > RGB8 Normal Map")
    elif texPixelFormat == 84:
        bs.texSize = texWidth * texHeight # DXT5
        print("Pixel Format > DXT5")
    elif texPixelFormat == 134:
        bs.texSize = texWidth * texHeight *4 # RGBA8
        print("Pixel Format > RGBA8")
        
    data = bs.readBytes(bs.texSize)
    if texPixelFormat == 113:
        data = rapi.imageUntile360DXT(rapi.swapEndianArray(data, 2), texWidth, texHeight, 16)
        data = rapi.imageDecodeDXT(data, texWidth, texHeight, noesis.FOURCC_ATI2)
        texFmt = noesis.NOESISTEX_RGBA32
    elif texPixelFormat == 84:
        data = rapi.imageUntile360DXT(rapi.swapEndianArray(data, 2), texWidth, texHeight, 16)
        texFmt = noesis.NOESISTEX_DXT5
    elif texPixelFormat == 134:
        data = rapi.imageUntile360Raw(data, texWidth, texHeight, 4)
        data = rapi.imageDecodeRaw(data, texWidth, texHeight, "a8r8g8b8")
        texFmt = noesis.NOESISTEX_RGBA32
            
    texList.append(NoeTexture(rapi.getInputName(), texWidth, texHeight, data, texFmt))
    return 1
Not sure about some of textures dimension. Mostly small ones have problem with size and are displayed incorrectly. Hope it will not be a big deal for you.
Bl4z3_Ice
Posts: 15
Joined: Fri Mar 18, 2022 8:03 am

Re: Ridge Racer 6 mdl extract from X360

Post by Bl4z3_Ice »

thx for noesis script for texture part, but have you figured out to get models out of MDL file?
Bl4z3_Ice
Posts: 15
Joined: Fri Mar 18, 2022 8:03 am

Re: Ridge Racer 6 mdl extract from X360

Post by Bl4z3_Ice »

Also the blender plugin made by GreenTrafficLight supports RR6 along with PS3 RR7 but I had an error that says "unpack requires a buffer of 4 bytes" and mdl file without extension in my sample contains R6C header.

https://github.com/GreenTrafficLight/Ri ... nder-Addon