READ THE RULES: Click here

Follow us on Facebook: https://www.facebook.com/xentax/ :)

Spotlight: Señor Casaroja's Noesis

General game file tools that are useful for more than one game
Beedy
beginner
Posts: 36
Joined: Mon Dec 05, 2016 11:12 am
Has thanked: 4 times
Been thanked: 8 times

Re: Spotlight: Señor Casaroja's Noesis

Post by Beedy » Wed Oct 09, 2019 5:49 pm

I tried to read materials from modelcontainer with 153 meshes, 65 materials and 41 textures. I assign textures to every material and then read materials to MatList and construct models with 153 range loop. When I load the file it appears 9945 (=153 x 65) materials in Noesis. It reads right material for every meshes but Noesis crashes when I go to Data Viewer because of huge amount of materials. When I move mdl.setModelMaterials(NoeModelMaterials(TexList, MatList)) out of range loop it appears 153 materials in Noesis but materials isn't loaded for meshes. What I do wrong?

Code: Select all

#Noesis python importer - EA NHL games stadium container .rx2 files - version 1.0
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("NHL Legacy (X360)", ".rx2")
	noesis.setHandlerTypeCheck(handle, noepyCheckType)
	noesis.setHandlerLoadModel(handle, noepyLoadModel)
	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
#check if it's this type based on the data
def noepyCheckType(data):
    bs = NoeBitStream(data)
    Magic = bs.readBytes(7)
    if Magic != b'\x89\x52\x57\x34\x78\x62\x32':
        return 0
    return 1  

#load the model
def noepyLoadModel(data, mdlList):
   VInfo = []
   VOff = []
   VBufferSize = []
   FInfo = []   
   FOff = []
   FBufferSize = []
   MatInfo = []
   MatIndexInfo = []
   MatIndexTable = []
   TexIndexInfo = []
   TexIndex = []   
   MatNames = []
   NameInfo = []
   TexList = []
   MatList = []
   MaterialInfo = []
   
   ctx = rapi.rpgCreateContext()
   bs = NoeBitStream(data, NOE_BIGENDIAN)
   bs.seek(0x20, NOESEEK_ABS)
   fileCount = bs.read(">i")
   bs.seek(12, NOESEEK_REL)
   fileTable = bs.read(">i")
   bs.seek(16, NOESEEK_REL)
   hdrSize = bs.read(">i")  
   bs.seek(fileTable[0], NOESEEK_ABS)
   meshCount = 0
   texCount = 0
   materialCount = 0
   ebCount = 0
   
   for i in range(0, fileCount[0]):
	    fileInfo = bs.read(">iiiii")
	    fileType = bs.readBytes(4)
	   			    
	    elif fileType == b'\x00\x02\x00\x05':
	   		bs.seek(-48, NOESEEK_REL)
	   		info = bs.read(">iiiiiiiiiiii")
	   		VOff.append([info[0]])
	   		VBufferSize.append([info[2]])
	   		VInfo.append([info[6]])
	   				 			   		
	    elif fileType == b'\x00\x02\x00\x07':
	   		bs.seek(-48, NOESEEK_REL)
	   		info = bs.read(">iiiiiiiiiiii")
	   		FOff.append([info[0]])
	   		FBufferSize.append([info[2]])
	   		FInfo.append([info[6]])	   		

	    elif fileType == b'\x00\x02\x00\x09':
	   		meshCount +=1 
	   		
	    elif fileType == b'\x00\xEB\x00\x03':
	   		MatIndexInfo.append([fileInfo[0]])
	   		ebCount +=1
	   		
	    elif fileType == b'\x00\xEC\x00\x10':
	   		NameInfo.append([fileInfo[0]])
	    
	    elif fileType == b'\x00\xEF\x00\x01':
	   		TexIndexInfo.append([fileInfo[0]])

	    elif fileType == b'\x00\xEF\x00\x05':
	   		MatInfo.append([fileInfo[0]])
	   		materialCount +=1				 			   		
   
#Read material names
   bs.seek(NameInfo[0][0], NOESEEK_ABS)
   nameCount = bs.read(">HH")
   bs.seek(4, NOESEEK_REL)
   for i in range(0, nameCount[1]):
   		nameOff = bs.read(">i")
   		nameType = bs.readBytes(4)
   		nameIndex = bs.read(">i")
   		pos = bs.tell()
   		if nameType == b'\x00\xEF\x00\x05':
   			bs.seek(nameOff[0], NOESEEK_ABS)
   			MatNames.append(bs.readString())
   			bs.seek(pos, NOESEEK_ABS)	
   			
#Read material indices for meshes
   for i in range(0, ebCount):
   		bs.seek(MatIndexInfo[i][0] + 0x10, NOESEEK_ABS)
   		contents = bs.read(">i")
   		tablesize = bs.read(">i")
   		bs.seek(tablesize[0] + 12, NOESEEK_REL)
   		for j in range(0, contents[0]):
   				materialIndex = bs.read(">i")
   				MatIndexTable.append(materialIndex[0])
   				bs.seek(40, NOESEEK_REL)

#Read texture indices for materials
   for i in range(0, materialCount):
   		bs.seek(TexIndexInfo[i][0] + 256, NOESEEK_ABS)
   		index = bs.read(">i")
   		textindex = index[0] // 2
   		TexIndex.append(str(textindex)+".tga")
   		
   for i in range(0, materialCount):
   		material = NoeMaterial(MatNames[i], TexIndex[i])
   		MatList.append(material) 
   		
 #Construct Models		  			   
   for i in range(0, meshCount):
   		bs.seek(VInfo[i][0] + 32, NOESEEK_ABS) #Seek to vertices info
   		VData = bs.read(">HHi") 
   		VBsize = VData[0]
   		VCount = VData[2]
   		bs.seek(FInfo[i][0] + 32, NOESEEK_ABS) #Seek to faces info  
   		FCount = bs.read(">HH")   
   		bs.seek(VOff[i][0] + hdrSize[0], NOESEEK_ABS) #Seek to Vertices Start
   		VertBuff = bs.readBytes(VBufferSize[i][0])
   		rapi.rpgSetOption(noesis.RPGOPT_BIGENDIAN, 1)
   		rapi.rpgBindPositionBufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, VBsize, 0)
   		rapi.rpgBindUV1BufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, VBsize, 16)
   		bs.seek(FOff[i][0] + hdrSize[0], NOESEEK_ABS) #Seek to Faces Start
   		FaceBuff = bs.readBytes(FBufferSize[i][0])
   		rapi.rpgSetMaterial(MatNames[((MatIndexTable[i] - 1) // 3) - 28])
   		rapi.rpgCommitTriangles(FaceBuff, noesis.RPGEODATA_USHORT, FCount[1], noesis.RPGEO_TRIANGLE, 1)
   		mdl = rapi.rpgConstructModel()
   		mdl.setModelMaterials(NoeModelMaterials(TexList, MatList))
   		mdlList.append(mdl)         #important, don't forget to put your loaded model in the mdlList
   		rapi.rpgClearBufferBinds()
   		rapi.rpgReset()   
   
   return 1

Beedy
beginner
Posts: 36
Joined: Mon Dec 05, 2016 11:12 am
Has thanked: 4 times
Been thanked: 8 times

Re: Spotlight: Señor Casaroja's Noesis

Post by Beedy » Thu Oct 10, 2019 7:36 am

I think that solution is read submeshes instead of construct every meshes to single model. Now I have 153 models 153 meshes 153 textures and 9945 materials. Can someone help me to fix the script to read 1 model 153 submeshes and 65 materials? I extract textures separately with name of texture index 1-41.
Here is model sample file with extracted textures:
https://app.box.com/s/gjpzsy19pb45g9cuncwrwl2ewifeg9dd
mdl_nhl_rx2_mat.py.zip
You do not have the required permissions to view the files attached to this post.

Beedy
beginner
Posts: 36
Joined: Mon Dec 05, 2016 11:12 am
Has thanked: 4 times
Been thanked: 8 times

Re: Spotlight: Señor Casaroja's Noesis

Post by Beedy » Thu Oct 10, 2019 1:09 pm

Issue solved. I move mdl = rapi.rpgConstructModel(), mdl.setModelMaterials(NoeModelMaterials(TexList, MatList)), mdlList.append(mdl), rapi.rpgClearBufferBinds() and rapi.rpgReset() out of mesh loop.

Code: Select all

 #Construct Model		  			   
   for i in range(0, meshCount):
   		print(UVpos[i])
   		bs.seek(VInfo[i][0] + 32, NOESEEK_ABS) #Seek to vertices info
   		VData = bs.read(">HHi") 
   		VBsize = VData[0]
   		VCount = VData[2]
   		bs.seek(FInfo[i][0] + 32, NOESEEK_ABS) #Seek to faces info  
   		FCount = bs.read(">HH")   
   		bs.seek(VOff[i][0] + hdrSize[0], NOESEEK_ABS) #Seek to Vertices Start
   		VertBuff = bs.readBytes(VBufferSize[i][0])
   		rapi.rpgSetName("mesh" + str(i))
   		rapi.rpgSetOption(noesis.RPGOPT_BIGENDIAN, 1)
   		rapi.rpgBindPositionBufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, VBsize, 0)
   		rapi.rpgBindUV1BufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, VBsize, UVpos[i])
   		bs.seek(FOff[i][0] + hdrSize[0], NOESEEK_ABS) #Seek to Faces Start
   		FaceBuff = bs.readBytes(FBufferSize[i][0])
   		rapi.rpgSetMaterial(MatNames[((MatIndexTable[i] - 1) // 3) - 28])
   		rapi.rpgCommitTriangles(FaceBuff, noesis.RPGEODATA_USHORT, FCount[1], noesis.RPGEO_TRIANGLE, 1)  
   mdl = rapi.rpgConstructModel()
   mdl.setModelMaterials(NoeModelMaterials(TexList, MatList))
   mdlList.append(mdl)
   rapi.rpgClearBufferBinds()
   rapi.rpgReset() 

ISKA
n00b
Posts: 10
Joined: Tue Apr 10, 2018 9:52 am

Re: Spotlight: Señor Casaroja's Noesis

Post by ISKA » Tue Oct 15, 2019 1:47 pm

Hi everyone. Im looking red dead redemption 1 fonts.
Can anyone say me font names and folders?
I found one folder is name fonts but even edit not change ingame anyone characters.

artworkplay
veteran
Posts: 114
Joined: Wed Oct 05, 2011 9:40 pm
Has thanked: 49 times
Been thanked: 4 times

Re: Spotlight: Señor Casaroja's Noesis

Post by artworkplay » Wed Oct 30, 2019 11:59 pm

I hope its ok to ask here...I've been unable to open Noesis on my new pc running windows 10 64 bit, it throws an error saying "noesis has stopped working" once i try to open it. is there a workaround for this? TIA

EDIT Added screenshot
Image

Lazov
advanced
Posts: 59
Joined: Sat Oct 08, 2016 11:56 am
Has thanked: 16 times
Been thanked: 40 times

Re: Spotlight: Señor Casaroja's Noesis

Post by Lazov » Mon Nov 18, 2019 5:18 pm

Such a problem. The skeleton is displayed correctly during animation. But the model is distorted - very elongated. What could be the problem? In the transformation matrices?
Image

Post Reply