def noepyLoadModel(data, mdlList):
    ctx = rapi.rpgCreateContext()
    #noesis.logPopup()
    file = MSH(data)
    mdlList.append(file.mdl)
    rapi.rpgClearBufferBinds()
    return 1
def noepyLoadModel(data, mdlList):
	ctx = rapi.rpgCreateContext()
	parser =appFile(data)
	mdl=parser.parse_file()
	mdlList.append(mdl)
	rapi.rpgClearBufferBinds()
	return 1
 def build_meshes(self):
         
     for meshInfo in self.meshInfo:
         
         vertBuff = meshInfo[0]
         idxBuff = meshInfo[1]
         numIdx = meshInfo[2]
         matNum = meshInfo[3]
         meshName = meshInfo[4]
         
         if self.xxFormat >= 4:
             rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 70, 2)
             rapi.rpgBindNormalBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 70, 30)
             rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 70, 42)
         else:
             rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 52, 4)
             rapi.rpgBindNormalBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 52, 32)
             rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 52, 44)
         
         if len(self.matList) > matNum:
             mat = self.matList[matNum]            
             matName = mat.name
             rapi.rpgSetMaterial(matName)
         rapi.rpgSetName(meshName)
         rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)
         rapi.rpgClearBufferBinds()    
 def build_model(self):
     
     for mesh in self.meshes:
         
         positions = mesh["pos"]
         rapi.rpgBindPositionBuffer(positions, noesis.RPGEODATA_FLOAT, 12)
         
         if "norms" in mesh:
             normals = mesh["norms"]
             #rapi.rpgBindNormalBuffer(normals, noesis.RPGEODATA_FLOAT, 12)
         if "uv" in mesh:
             uv = mesh["uv"]
             rapi.rpgBindUV1Buffer(uv, noesis.RPGEODATA_FLOAT, 8)
             
         if "matIndexes" in mesh:
             matUsed = mesh["matIndexes"]
             
         idxBuff = mesh["idx"]
         numIdx = mesh["numIdx"]
         #print(numIdx)
         if "materials" in mesh:
             materials = mesh["materials"]
         else:
             materials = self.materials
         #rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_UINT, numIdx, noesis.RPGEO_TRIANGLE, 1)
         self.build_faces(idxBuff, matUsed, materials)
         rapi.rpgClearBufferBinds()
def noepyLoadModel(data, mdlList):
    
    ctx = rapi.rpgCreateContext()
    
    file = MODEL(data)
    mdlList.append(file.mdl)
    rapi.rpgClearBufferBinds()
    return 1
def noepyLoadModel(data, mdlList):
    ctx = rapi.rpgCreateContext()
    mesh = TLMesh(data)
    mesh.Parser()
    mdl=mesh.MakeModel()
    mdlList.append(mdl)
    print(mdlList)
    rapi.rpgClearBufferBinds()
    return 1
def noepyLoadModel(data, mdlList):
    
    ctx = rapi.rpgCreateContext()
    global dirPath
    global fileName
    dirPath     = rapi.getDirForFilePath(rapi.getInputName())
    fileName    = rapi.getLocalFileName(rapi.getInputName()) 
    file = GOBJ(data)
    mdlList.append(file.mdl)
    rapi.rpgClearBufferBinds()
    return 1
def noepyLoadModel(data,mdlList):
    ctx = rapi.rpgCreateContext()
    pfFile = PFfile(data)
    rapi.setPreviewOption('setAngOfs',"0 90 180")
    try:
        pfFile.Bones = rapi.multiplyBones(pfFile.Bones)
        mdl = rapi.rpgConstructModel()
        mdl.setModelMaterials(NoeModelMaterials(pfFile.texList, pfFile.matList))
        mdl.setBones(pfFile.Bones)
        mdlList.append(mdl)
    except:pass
    rapi.rpgClearBufferBinds()
    return 1
def noepyLoadModel(data, mdlList):
   ctx = rapi.rpgCreateContext()
   
   #parse file
   parser = CrucisFatalFake_LMD(data)
   parser.parse_file()
   
   #build model
   mdl = rapi.rpgConstructModel()
   mdl.setModelMaterials(NoeModelMaterials(parser.texList, parser.matList))
   mdlList.append(mdl)
   
   rapi.rpgClearBufferBinds()  
   return 1
def psaLoadModel(data, mdlList):
	ctx = rapi.rpgCreateContext()
	bs = NoeBitStream(data)
	bs.setEndian(NOE_BIGENDIAN)
	rapi.rpgSetOption(noesis.RPGOPT_BIGENDIAN, 1)
	rapi.rpgSetOption(noesis.RPGOPT_TRIWINDBACKWARD, 1)
	IdMagic = bs.readBytes(4).decode("ASCII")
	version = bs.readUInt()
	modelCount = bs.readUInt()
	fvfTableOffset = bs.readUInt()
	bs.seek(fvfTableOffset, NOESEEK_ABS)
	for i in range(0, modelCount):
		bs.seek(fvfTableOffset + (0x80 * i), NOESEEK_ABS)
		bs.seek(0x08, NOESEEK_REL)
		vertexCount = bs.readUShort()
		indexCount = bs.readUShort()
		#print('Index Count: ' + str(indexCount))
		bs.seek(0x04, NOESEEK_REL)
		indexOffset = bs.readUInt()
		#print('Index Offset: ' + str(indexOffset))
		indexSize = bs.readUShort()
		unk01 = bs.readUShort()
		vertexOffset = bs.readUInt()
		unkown01Offset = bs.readUInt()
		vertexSize = bs.readUShort()
		bs.seek(0x5E, NOESEEK_REL)
		bs.seek(indexOffset, NOESEEK_ABS)
		edgeData = bs.readBytes(indexSize)
		edgeDecomp = rapi.decompressEdgeIndices(edgeData, indexCount)
		for i in range(0, indexCount): #decompressEdgeIndices returns indices in little-endian, so swap back to big because rpg is in bigendian mode
			t = edgeDecomp[i*2]
			edgeDecomp[i*2] = edgeDecomp[i*2 + 1]
			edgeDecomp[i*2 + 1] = t
			
		bs.seek(vertexOffset, NOESEEK_ABS)
		vertexSize = 16 * vertexCount
		vertbuff = bs.readBytes(vertexSize)
		rapi.rpgBindPositionBufferOfs(vertbuff, noesis.RPGEODATA_FLOAT, 16, 0)
		#print(outputIndices[len(outputIndices) - 1])
		#print(outputIndices)
		rapi.rpgSetName(str(i))
		#rapi.rpgCommitTriangles(None, noesis.RPGEODATA_USHORT, (vertexSize // 16), noesis.RPGEO_POINTS, 1)
		rapi.rpgCommitTriangles(edgeDecomp, noesis.RPGEODATA_USHORT, indexCount, noesis.RPGEO_TRIANGLE, 1)
	mdl = rapi.rpgConstructModel()
	mdlList.append(mdl)
	rapi.rpgClearBufferBinds()	
	return 1
예제 #11
0
파일: inc_noesis.py 프로젝트: r-lyeh/eve
	def bindBuffers(self, vertexData, bindWeights = True):
		rapi.rpgClearBufferBinds()
		if self.posType != 0:
			bindTypes = (0, noesis.RPGEODATA_BYTE, noesis.RPGEODATA_SHORT, noesis.RPGEODATA_FLOAT)
			rapi.rpgBindPositionBufferOfs(vertexData, bindTypes[self.posType], self.vertexSize, self.posOfs)
		if self.normalType != 0:
			bindTypes = (0, noesis.RPGEODATA_BYTE, noesis.RPGEODATA_SHORT, noesis.RPGEODATA_FLOAT)
			rapi.rpgBindNormalBufferOfs(vertexData, bindTypes[self.normalType], self.vertexSize, self.normalOfs)
		if self.uvType != 0:
			bindTypes = (0, noesis.RPGEODATA_UBYTE, noesis.RPGEODATA_USHORT, noesis.RPGEODATA_FLOAT)
			rapi.rpgBindUV1BufferOfs(vertexData, bindTypes[self.uvType], self.vertexSize, self.uvOfs)
		if self.colorType == 7:
			#binding is not natively supported for the other color formats. if you want to use them, you need to decode them before binding.
			rapi.rpgBindColorBufferOfs(vertexData, noesis.RPGEODATA_UBYTE, self.vertexSize, self.colorOfs, 4)
		if bindWeights is True and self.weightType != 0:
			bindTypes = (0, noesis.RPGEODATA_UBYTE, noesis.RPGEODATA_USHORT, noesis.RPGEODATA_FLOAT)
			rapi.rpgBindBoneWeightBufferOfs(vertexData, bindTypes[self.weightType], self.vertexSize, self.weightOfs, self.numWeights)
예제 #12
0
def noepyLoadModel(data, mdlList):
    ctx = rapi.rpgCreateContext()
    bs = NoeBitStream(data)
    bs.setEndian(NOE_BIGENDIAN)
    rapi.rpgSetOption(noesis.RPGOPT_BIGENDIAN, 1)
    fvfInto = []
    texList = []
    matList = []

    header = bs.readBytes(4).decode("ASCII")
    version1 = bs.readInt()
    version2 = bs.readInt()
    modelSize = bs.readInt()
    unk01 = bs.readUShort()
    sceneName = bs.readBytes(30).decode("ASCII").rstrip("\0")
    offset00 = bs.readInt()  #Bone Matrix / Parent / 0x80
    count00 = bs.readInt()
    offset01 = bs.readInt()  #info related to section before last? / 0x40
    count01 = bs.readInt()
    faceInfoOff = bs.readInt()  #Face Info /0x40
    faceInfoSize = bs.readInt()
    materialOff = bs.readInt()
    materialCount = bs.readInt()
    offset04 = bs.readInt()  #? / 0x10
    count04 = bs.readInt()
    offset05 = bs.readInt()  #Some Matrix / 0x40
    count05 = bs.readInt()
    vertInfoOff = bs.readInt()  #Vertex Info / 0x20
    vertInfoSize = bs.readInt()
    vertOff = bs.readInt()  #Vertex Start / 1
    vertOffSize = bs.readInt()
    texOff = bs.readInt()  #Some Names / 0x20
    texCount = bs.readInt()
    offset09 = bs.readInt()  #Some Names / 0x20
    count09 = bs.readInt()
    offset10 = bs.readInt()  #Bone Names / 0x20
    count10 = bs.readInt()
    faceOff = bs.readInt()  #Some Face Info / 2
    faceOffSize = bs.readInt()
    offset12 = bs.readInt()  #? / 1
    count12 = bs.readInt()
    offset13 = bs.readInt()  #? / 1
    count13 = bs.readInt()

    texName = []
    bs.seek(texOff, NOESEEK_ABS)
    for i in range(0, texCount):
        id = bs.readUShort()
        tmp = bs.readBytes(30).decode("ASCII").rstrip("\0")
        texName.append(tmp)

    bs.seek(materialOff, NOESEEK_ABS)
    for i in range(0, materialCount):
        matInfo = bs.read(">" + "h" * 32)
        matInfo2 = bs.read(">" + "f" * 16)
        material = NoeMaterial((str(i)), "")
        if matInfo[17] != -1:
            material.setTexture(texName[matInfo[17]] + ".dds")
        matList.append(material)
        #print(matInfo)

    faceInfo = []
    bs.seek(faceInfoOff, NOESEEK_ABS)
    for i in range(0, faceInfoSize):
        faceInfoTmp = bs.read(">iiiiiiiiiiiiiiii")
        #print(faceInfoTmp)
        faceInfo.append(faceInfoTmp)
    #for i in range(0, faceInfoSize):
    #	print(faceInfo[i])
    from operator import itemgetter
    faceInfo = sorted(faceInfo, key=itemgetter(2, 1))
    #for i in range(0, faceInfoSize):
    #print(faceInfo[i])
    faceInfo2 = []
    for i in range(0, vertInfoSize):
        tmp = []
        for a in range(0, faceInfoSize):
            if faceInfo[a][2] == i:
                tmp.append(faceInfo[a])
        faceInfo2.append(tmp)
    #print(faceInfo2)

    bs.seek(vertInfoOff, NOESEEK_ABS)
    for i in range(0, vertInfoSize):
        meshID = bs.readInt()
        vertCount = bs.readInt()
        fvf00 = bs.readUByte()
        fvf01 = bs.readUByte()
        fvf02 = bs.readUByte()
        fvf03 = bs.readUByte()
        fvf04 = bs.readUByte()
        fvf05 = bs.readUByte()
        fvf06 = bs.readUByte()
        fvf07 = bs.readUByte()
        vertStart = bs.readInt()
        vertDataSize = bs.readInt()
        vertSize = bs.readInt()
        null = bs.readInt()
        fvfInto.append([
            meshID, vertCount, vertStart, vertDataSize, vertSize, fvf00, fvf01,
            fvf02, fvf03, fvf04, fvf05, fvf06, fvf07
        ])
    print(fvfInto)
    for i in range(0, vertInfoSize):
        bs.seek((vertOff + fvfInto[i][2]), NOESEEK_ABS)
        VertBuff = bs.readBytes(fvfInto[i][3])
        rapi.rpgBindPositionBufferOfs(VertBuff, noesis.RPGEODATA_FLOAT,
                                      fvfInto[i][4], 0)
        if fvfInto[i][8] == 4:
            rapi.rpgBindUV1BufferOfs(VertBuff, noesis.RPGEODATA_HALFFLOAT,
                                     fvfInto[i][4], (fvfInto[i][4] - 4))
        if fvfInto[i][8] == 0x44:
            rapi.rpgBindUV1BufferOfs(VertBuff, noesis.RPGEODATA_HALFFLOAT,
                                     fvfInto[i][4], (fvfInto[i][4] - 8))
        for a in range(0, len(faceInfo2[i])):
            rapi.rpgSetName(str(faceInfo2[i][a][1]))
            rapi.rpgSetMaterial(str(faceInfo2[i][a][1]))
            bs.seek(faceOff + (2 * faceInfo2[i][a][5]), NOESEEK_ABS)
            FaceBuff = bs.readBytes(faceInfo2[i][a][4] * 2)
            rapi.rpgCommitTriangles(FaceBuff, noesis.RPGEODATA_USHORT,
                                    faceInfo2[i][a][4], noesis.RPGEO_TRIANGLE,
                                    1)
            bs.seek(faceOff + (2 * faceInfo2[i][a][7]), NOESEEK_ABS)
            FaceBuff = bs.readBytes(faceInfo2[i][a][6] * 2)
            rapi.rpgCommitTriangles(FaceBuff, noesis.RPGEODATA_USHORT,
                                    faceInfo2[i][a][6],
                                    noesis.RPGEO_TRIANGLE_STRIP, 1)
            bs.seek(faceOff + (2 * faceInfo2[i][a][9]), NOESEEK_ABS)
            FaceBuff = bs.readBytes(faceInfo2[i][a][8] * 2)
            rapi.rpgCommitTriangles(FaceBuff, noesis.RPGEODATA_USHORT,
                                    faceInfo2[i][a][8],
                                    noesis.RPGEO_TRIANGLE_STRIP, 1)

    mdl = rapi.rpgConstructModel()
    mdl.setModelMaterials(NoeModelMaterials(texList, matList))
    mdlList.append(mdl)
    rapi.rpgClearBufferBinds()
    return 1
예제 #13
0
def psaLoadModel(data, mdlList):
	ctx = rapi.rpgCreateContext()
	bs = NoeBitStream(data)
	bs.setEndian(NOE_BIGENDIAN)
	rapi.rpgSetOption(noesis.RPGOPT_BIGENDIAN, 1)
	rapi.rpgSetOption(noesis.RPGOPT_TRIWINDBACKWARD, 1)
	IdMagic = bs.readBytes(4).decode("ASCII")
	version = bs.readUInt()
	modelCount = bs.readUInt()
	fvfTableOffset = bs.readUInt()
	bs.seek(fvfTableOffset, NOESEEK_ABS)
	for i in range(0, modelCount):
		bs.seek(fvfTableOffset + (0x80 * i), NOESEEK_ABS)
		bs.seek(0x08, NOESEEK_REL)
		vertexCount = bs.readUShort()
		indexCount = bs.readUShort()
		#print('Index Count: ' + str(indexCount))
		bs.seek(0x04, NOESEEK_REL)
		indexOffset = bs.readUInt()
		#print('Index Offset: ' + str(indexOffset))
		indexSize = bs.readUShort()
		unk01 = bs.readUShort()
		vertexOffset = bs.readUInt()
		unkown01Offset = bs.readUInt()
		vertexSize = bs.readUShort()
		bs.seek(0x5E, NOESEEK_REL)
		bs.seek(indexOffset, NOESEEK_ABS)
		# read EDGE indices header
		numIndices = bs.readUShort()
		#print('Num Indices: ' + str(numIndices))
		indexBase = bs.readUShort()
		#print('Base Index: ' + str(indexBase))
		sequenceSize = bs.readUShort()
		#print('Sequence Size: ' + str(sequenceSize))
		indexBitSize = bs.readUByte()
		#print('Index Bit Size: ' + str(indexBitSize))
		bs.readUByte() # padding
		# setup sequence bit stream
		sequenceCount = sequenceSize * 8
		#print('Sequence Count: ' + str(sequenceCount))
		sequenceBytes = bs.readBytes(sequenceSize)
		spec = ['data', {"count" : sequenceCount, "spec" : ["value", 1]}]
		reader = BitReader(spec, BitReader.BIG_ENDIAN)
		sequenceStream = reader.read(sequenceBytes)
		# setup triangle bit stream
		triangleCount = indexCount // 3
		#print('Triangle Count: ' + str(triangleCount))
		triangleSize = ((triangleCount * 2) + 7) // 8
		#print('Trangle Size: ' + str(triangleSize))
		triangleBytes = bs.readBytes(triangleSize)
		spec = ['data', {"count" : triangleCount, "spec" : ["value", 2]}]
		reader = BitReader(spec, BitReader.BIG_ENDIAN)
		triangleStream = reader.read(triangleBytes)
		# setup indices bit stream
		indicesSize = ((numIndices * indexBitSize) + 7) // 8
		#print('Indices Size: ' + str(indicesSize))
		#print('Indices Offset: ' + str(bs.getOffset()))
		indicesBytes = bs.readBytes(indicesSize)
		spec = ['data', {"count" : numIndices, "spec" : ["value", indexBitSize]}]
		reader = BitReader(spec, BitReader.BIG_ENDIAN)
		indicesStream = reader.read(indicesBytes)
		# indicesStream = NoeBitStream(indicesBytes)
		# indicesStream.setEndian(NOE_BIGENDIAN)
		# read delta compressed indices
		deltaIndices = array('H')
		for i in range(0, numIndices):
			value = indicesStream.data[i].value
			if i == 1:
				pass
				#print('Index Bit Value: ' + str(value) + ' Index: ' + str(i))
			value -= indexBase
			if i > 7:
				value += deltaIndices[i - 8]
			deltaIndices.append(value)
		# create sequence indices
		inputIndices = array('H')
		sequencedIndex = 0
		unorderedIndex = 0
		for i in range(0, sequenceCount):
			value = sequenceStream.data[i].value
			if value == 0:
				inputIndices.append(sequencedIndex)
				sequencedIndex += 1
			else:
				inputIndices.append(deltaIndices[unorderedIndex])
				unorderedIndex += 1
		# create triangle indices
		outputIndices = array('H')
		currentIndex = 0
		triangleIndices = [0, 0, 0]
		# triangleIndices = {0:0, 1:0, 2:0}
		for i in range(0, triangleCount):
			value = triangleStream.data[i].value
			if value == 0:
				triangleIndices[1] = triangleIndices[2]
				triangleIndices[2] = inputIndices[currentIndex]
				currentIndex += 1
			elif value == 1:
				triangleIndices[0] = triangleIndices[2]
				triangleIndices[2] = inputIndices[currentIndex]
				currentIndex += 1
			elif value == 2:
				tempIndex = triangleIndices[0]
				triangleIndices[0] = triangleIndices[1]
				triangleIndices[1] = tempIndex
				triangleIndices[2] = inputIndices[currentIndex]
				currentIndex += 1
			else: # value == 3:
				triangleIndices[0] = inputIndices[currentIndex]
				currentIndex += 1
				triangleIndices[1] = inputIndices[currentIndex]
				currentIndex += 1
				triangleIndices[2] = inputIndices[currentIndex]
				currentIndex += 1
			outputIndices.append(triangleIndices[0])
			outputIndices.append(triangleIndices[1])
			outputIndices.append(triangleIndices[2])
		bs.seek(vertexOffset, NOESEEK_ABS)
		vertexSize = 16 * vertexCount
		vertbuff = bs.readBytes(vertexSize)
		rapi.rpgBindPositionBufferOfs(vertbuff, noesis.RPGEODATA_FLOAT, 16, 0)
		faceBuff = struct.pack(">" + 'h'*len(outputIndices), *outputIndices)
		#print(outputIndices[len(outputIndices) - 1])
		#print(outputIndices)
		rapi.rpgSetName(str(i))
		#rapi.rpgCommitTriangles(None, noesis.RPGEODATA_USHORT, (vertexSize // 16), noesis.RPGEO_POINTS, 1)
		rapi.rpgCommitTriangles(faceBuff, noesis.RPGEODATA_USHORT, len(outputIndices), noesis.RPGEO_TRIANGLE, 1)
	mdl = rapi.rpgConstructModel()
	mdlList.append(mdl)
	rapi.rpgClearBufferBinds()	
	return 1
def noepyLoadModel(data, mdlList):
	ctx = rapi.rpgCreateContext()
	bs = NoeBitStream(data)
	#rapi.rpgSetPosScaleBias((-1,-1,1),(0,0,0))
	boneList = []

	boneCount = bs.readInt()
	boneOffset = bs.tell() + bs.readInt()
	texCount = bs.readInt()
	texOffset = bs.tell() + bs.readInt()
	matCount = bs.readInt()
	matOffset = bs.tell() + bs.readInt()
	meshCount = bs.readInt()
	meshOffset = bs.tell() + bs.readInt()

	bs.seek(boneOffset, NOESEEK_ABS)
	for i in range(0, boneCount):
		boneName = bs.readBytes(0x20).decode("ASCII").rstrip("\0")
		boneMtx = NoeMat44.fromBytes(bs.readBytes(0x40)).toMat43()
		bs.readBytes(0x40)
		boneParent = bs.readInt()
		bs.readBytes(0x8)
		pos = NoeVec3.fromBytes(bs.readBytes(12))
		bs.readBytes(0x8)
		quat = NoeQuat.fromBytes(bs.readBytes(16))
		NoeVec3.fromBytes(bs.readBytes(12))
		bs.readBytes(0x14)
		boneMtx = quat.toMat43()
		boneMtx[3] = pos
		newBone = NoeBone(i, boneName, boneMtx, None, boneParent)
		boneList.append(newBone)
	boneList = rapi.multiplyBones(boneList)

	texInfo = []
	texList = []
	bs.seek(texOffset, NOESEEK_ABS)
	for i in range(0, texCount):
		texName = bs.readBytes(0x20).decode("ASCII").rstrip("\0")
		texStart = bs.tell() + bs.readInt()
		bs.readBytes(0xC)
		texInfo.append([texName,texStart])
	#print(texInfo)
	for i in range(0, texCount):
		bs.seek(texInfo[i][1], NOESEEK_ABS)
		bs.readBytes(0xC)
		palOff = bs.tell() + bs.readInt()
		texType, unk02, pixWidth, pixHeight, unk03, unk04 = bs.read("6H")
		texSize = bs.readInt()
		texOff = bs.tell() + bs.readInt()
		bs.seek(texOff, NOESEEK_ABS)
		texData = bs.readBytes(texSize)
		bs.seek(palOff, NOESEEK_ABS)
		unk11, unk22 = bs.read("2H")
		palSize, Null = bs.read("2I")
		palStart = bs.tell() + bs.readInt()
		bs.seek(palStart, NOESEEK_ABS)
		palData = []
		for a in range(0, palSize // 4):
			pR, pG, pB, pA = bs.read("4B")
			if pR == 0 and pG == 255 and pB == 0 and pA == 255:
				pG = 0
				pA = 0
			palData.append(pR)
			palData.append(pG)
			palData.append(pB)
			palData.append(pA)
		palData = struct.pack("<" + 'B'*len(palData), *palData)
		if texType == 5:
			pix = rapi.imageUntwiddlePSP(texData, pixWidth, pixHeight, 8)
			pix = rapi.imageDecodeRawPal(pix, palData, pixWidth, pixHeight, 8, "r8g8b8a8")
		elif texType == 4:
			pix = rapi.imageUntwiddlePSP(texData, pixWidth, pixHeight, 4)
			pix = rapi.imageDecodeRawPal(pix, palData, pixWidth, pixHeight, 4, "r8g8b8a8")
		texList.append(NoeTexture(texInfo[i][0], pixWidth, pixHeight, pix, noesis.NOESISTEX_RGBA32))

	matList = []
	bs.seek(matOffset, NOESEEK_ABS)
	for i in range(0, matCount):
		matName = bs.readBytes(0x20).decode("ASCII").rstrip("\0")
		bs.readBytes(0xC)
		texID = bs.readInt()
		unk01, unk02, unk03, unk04 = bs.read("4B")
		bs.readBytes(0x8)
		material = NoeMaterial(matName, "")
		if texID >= 0:
			material.setTexture(texInfo[texID][0])
			#material.setOpacityTexture(texInfo[texID][0])
		matList.append(material)

	meshList = []
	bs.seek(meshOffset, NOESEEK_ABS)
	for i in range(0, meshCount):
		meshName = bs.readBytes(0x20).decode("ASCII").rstrip("\0")
		mshCount = bs.readInt()
		unk11 = bs.readInt()
		meshStart = bs.tell() + bs.readInt()
		bs.readBytes(0xC)
		meshList.append([meshName, meshStart, mshCount, unk11])
	#print(meshList)

	for a in range(0, len(meshList)):
		mshInfo = []
		#print(meshList[a][0])
		bs.seek(meshList[a][1], NOESEEK_ABS)
		for b in range(0, meshList[a][2]):
			unk20 = bs.readInt()
			matID = bs.readInt()
			mshC = bs.readInt()
			MshOff = bs.tell() + bs.readInt()
			mshInfo.append([matID, mshC, MshOff])
		#print(mshInfo)
		mshInfo2 = []
		for b in range(0, len(mshInfo)):
			bs.seek(mshInfo[b][2], NOESEEK_ABS)
			for c in range(0, mshInfo[b][1]):
				meshPc = bs.readInt()
				vType  = bs.readInt()
				meshPc2  = bs.readInt()
				mshPo  = bs.tell() + bs.readInt()
				mshPo2 = bs.tell() + bs.readInt()
				mshInfo2.append([meshPc, vType, meshPc2, mshPo, mshPo2, matList[(mshInfo[b][0])].name])
		#print(mshInfo2)
		for b in range(0, len(mshInfo2)):
			mshInfo3 = []
			rapi.rpgSetMaterial(mshInfo2[b][5])
			bs.seek(mshInfo2[b][3], NOESEEK_ABS)
			idxList = [[0, 0, 0, 0, 0, 0, 0, 0]]
			for c in range(0, mshInfo2[b][2]):
				idxList[0][c] = bs.readInt()
			bs.seek(mshInfo2[b][4], NOESEEK_ABS)
			#print(idxList)
			for c in range(0, mshInfo2[b][0]):
				mshId2     = bs.readInt()
				vertCount  = bs.readInt()
				vertStart  = bs.tell() + bs.readInt()
				mshInfo3.append([mshId2, vertCount, vertStart])
			#print(mshInfo3)
			for c in range(0, len(mshInfo3)):
				#print(mshInfo3[c])
				bs.seek(mshInfo3[c][2], NOESEEK_ABS)
				rapi.rpgSetName(meshList[a][0])
				#rapi.rpgSetName(meshList[a][0] + "_" + str(b) + "_" + str(c) + "_" + str(mshInfo2[b][1]))

				vertStride = 0
				if mshInfo2[b][1] == 7:
					vertStride = 0x18
					vertBuff = bs.readBytes(mshInfo3[c][1] * vertStride)
					rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0xC)
					rapi.rpgBindColorBufferOfs(vertBuff, noesis.RPGEODATA_UBYTE, vertStride, 0x8, 4)
					rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0)
				elif mshInfo2[b][1] == 24:
					vertStride = 0x1C
					vertBuff = bs.readBytes(mshInfo3[c][1] * vertStride)
					rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0x10)
					rapi.rpgBindColorBufferOfs(vertBuff, noesis.RPGEODATA_UBYTE, vertStride, 0xC, 4)
					rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0x4)
				elif mshInfo2[b][1] == 25:
					vertStride = 0x1C
					vertBuff = bs.readBytes(mshInfo3[c][1] * vertStride)
					rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0x10)
					rapi.rpgBindColorBufferOfs(vertBuff, noesis.RPGEODATA_UBYTE, vertStride, 0xC, 4)
					rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0x4)
				elif mshInfo2[b][1] == 26:
					vertStride = 0x20
					vertBuff = bs.readBytes(mshInfo3[c][1] * vertStride)
					rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0x14)
					rapi.rpgBindColorBufferOfs(vertBuff, noesis.RPGEODATA_UBYTE, vertStride, 0x10, 4)
					rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0x8)
				elif mshInfo2[b][1] == 27:
					vertStride = 0x20
					vertBuff = bs.readBytes(mshInfo3[c][1] * vertStride)
					rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0x14)
					rapi.rpgBindColorBufferOfs(vertBuff, noesis.RPGEODATA_UBYTE, vertStride, 0x10, 4)
					rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0x8)
				elif mshInfo2[b][1] == 28:
					vertStride = 0x24
					vertBuff = bs.readBytes(mshInfo3[c][1] * vertStride)
					rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0x18)
					rapi.rpgBindColorBufferOfs(vertBuff, noesis.RPGEODATA_UBYTE, vertStride, 0x14, 4)
					rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0xC)
				elif mshInfo2[b][1] == 29:
					vertStride = 0x24
					vertBuff = bs.readBytes(mshInfo3[c][1] * vertStride)
					rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0x18)
					rapi.rpgBindColorBufferOfs(vertBuff, noesis.RPGEODATA_UBYTE, vertStride, 0x14, 4)
					rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0xC)
				elif mshInfo2[b][1] == 30:
					vertStride = 0x28
					vertBuff = bs.readBytes(mshInfo3[c][1] * vertStride)
					rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0x1C)
					rapi.rpgBindColorBufferOfs(vertBuff, noesis.RPGEODATA_UBYTE, vertStride, 0x18, 4)
					rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0x10)
				elif mshInfo2[b][1] == 23:
					vertStride = 0x28
					vertBuff = bs.readBytes(mshInfo3[c][1] * vertStride)
					rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0x1C)
					rapi.rpgBindColorBufferOfs(vertBuff, noesis.RPGEODATA_UBYTE, vertStride, 0x18, 4)
					rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, vertStride, 0x10)

				else:
					print(bs.tell())
					print("unknown found " + str(mshInfo2[b][1]))
				
				vs = NoeBitStream(vertBuff)
				tmp = []
				tmp2 = []
				weight = []
				index = []
				if vertStride == 0x18:
					for d in range(0, mshInfo3[c][1]):
						w1, w2, w3, w4, w5, w6, w7, w8 = [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
						index.append(idxList[0][0]); index.append(idxList[0][1]); index.append(idxList[0][2]); index.append(idxList[0][3])
						index.append(idxList[0][4]); index.append(idxList[0][5]); index.append(idxList[0][6]); index.append(idxList[0][7])
						weight.append(w1); weight.append(w2); weight.append(w3); weight.append(w4); weight.append(w5); weight.append(w6); weight.append(w7); weight.append(w8)
						vs.readBytes(0xC)
						tmp.append([vs.readUInt(), vs.readUInt(), vs.readUInt()])
				elif vertStride == 0x1C:
					for d in range(0, mshInfo3[c][1]):
						w1, w2, w3, w4, w5, w6, w7, w8 = [vs.readUShort() / 0x7FFF, vs.readUShort() / 0x7FFF, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
						index.append(idxList[0][0]); index.append(idxList[0][1]); index.append(idxList[0][2]); index.append(idxList[0][3])
						index.append(idxList[0][4]); index.append(idxList[0][5]); index.append(idxList[0][6]); index.append(idxList[0][7])
						weight.append(w1); weight.append(w2); weight.append(w3); weight.append(w4); weight.append(w5); weight.append(w6); weight.append(w7); weight.append(w8)
						vs.readBytes(0xC)
						tmp.append([vs.readUInt(), vs.readUInt(), vs.readUInt()])
				elif vertStride == 0x20:
					for d in range(0, mshInfo3[c][1]):
						w1, w2, w3, w4, w5, w6, w7, w8 = [vs.readUShort() / 0x7FFF, vs.readUShort() / 0x7FFF, vs.readUShort() / 0x7FFF, vs.readUShort() / 0x7FFF, 0.0, 0.0, 0.0, 0.0]
						index.append(idxList[0][0]); index.append(idxList[0][1]); index.append(idxList[0][2]); index.append(idxList[0][3])
						index.append(idxList[0][4]); index.append(idxList[0][5]); index.append(idxList[0][6]); index.append(idxList[0][7])
						weight.append(w1); weight.append(w2); weight.append(w3); weight.append(w4); weight.append(w5); weight.append(w6); weight.append(w7); weight.append(w8)
						vs.readBytes(0xC)
						tmp.append([vs.readUInt(), vs.readUInt(), vs.readUInt()])
				elif vertStride == 0x24:
					for d in range(0, mshInfo3[c][1]):
						w1, w2, w3, w4, w5, w6, w7, w8 = [vs.readUShort() / 0x7FFF, vs.readUShort() / 0x7FFF, vs.readUShort() / 0x7FFF, vs.readUShort() / 0x7FFF, vs.readUShort() / 0x7FFF, vs.readUShort() / 0x7FFF, 0.0, 0.0]
						index.append(idxList[0][0]); index.append(idxList[0][1]); index.append(idxList[0][2]); index.append(idxList[0][3])
						index.append(idxList[0][4]); index.append(idxList[0][5]); index.append(idxList[0][6]); index.append(idxList[0][7])
						weight.append(w1); weight.append(w2); weight.append(w3); weight.append(w4); weight.append(w5); weight.append(w6); weight.append(w7); weight.append(w8)
						vs.readBytes(0xC)
						tmp.append([vs.readUInt(), vs.readUInt(), vs.readUInt()])
				elif vertStride == 0x28:
					for d in range(0, mshInfo3[c][1]):
						w1, w2, w3, w4, w5, w6, w7, w8 = [vs.readUShort() / 0x7FFF, vs.readUShort() / 0x7FFF, vs.readUShort() / 0x7FFF, vs.readUShort() / 0x7FFF, vs.readUShort() / 0x7FFF, vs.readUShort() / 0x7FFF, vs.readUShort() / 0x7FFF, vs.readUShort() / 0x7FFF]
						index.append(idxList[0][0]); index.append(idxList[0][1]); index.append(idxList[0][2]); index.append(idxList[0][3])
						index.append(idxList[0][4]); index.append(idxList[0][5]); index.append(idxList[0][6]); index.append(idxList[0][7])
						weight.append(w1); weight.append(w2); weight.append(w3); weight.append(w4); weight.append(w5); weight.append(w6); weight.append(w7); weight.append(w8)
						vs.readBytes(0xC)
						tmp.append([vs.readUInt(), vs.readUInt(), vs.readUInt()])
				indexBuff  = struct.pack('B'*len(index), *index)
				weightBuff = struct.pack('f'*len(weight), *weight)
				rapi.rpgBindBoneIndexBuffer(indexBuff, noesis.RPGEODATA_BYTE, 8, 8)
				rapi.rpgBindBoneWeightBuffer(weightBuff, noesis.RPGEODATA_FLOAT, 0x20, 8)
				flip = 0
				step = 1
				if mshInfo3[c][0] == 0:
					step = 3
				for d in range(0, mshInfo3[c][1] - 2, step):
					if (tmp[d] != tmp[(d + 1)]) and (tmp[d] != tmp[(d + 2)]) and (tmp[d + 1] != tmp[(d + 2)]):
						tmp2.append(d)
						tmp2.append(d + 1 + flip)
						tmp2.append(d + 2 - flip)
						if mshInfo3[c][0] != 0:
							flip = 1 - flip
					else:
						flip = 0
						#print(d)
				faceBuff = struct.pack('H'*len(tmp2), *tmp2)
				if len(faceBuff) > 3:
					rapi.rpgCommitTriangles(faceBuff, noesis.RPGEODATA_USHORT, len(tmp2), noesis.RPGEO_TRIANGLE, 1)
				rapi.rpgClearBufferBinds() 

	mdl = rapi.rpgConstructModel()
	mdl.setModelMaterials(NoeModelMaterials(texList, matList))
	mdlList.append(mdl)
	mdl.setBones(boneList)

  
	return 1
def noepyLoadModel(data, mdlList):
	bs = NoeBitStream(data)
	if bs.readInt() != NOEPY_HEADER:
		return 0
	if bs.readInt() != NOEPY_VERSION:
		return 0

	#no need to explicitly free the context (created contexts are auto-freed after the handler), but DO NOT hold any references to it outside of this method
	ctx = rapi.rpgCreateContext()

	numMeshes = bs.readInt()
	for i in range(0, numMeshes):
		meshName = bs.readString()
		meshMat = bs.readString()
		numIdx = bs.readInt()
		numPos = bs.readInt()
		numNrm = bs.readInt()
		numUVs = bs.readInt()
		numTan = bs.readInt()
		numClr = bs.readInt()
		numWeights = bs.readInt()
		numBoneRefs = bs.readInt()
		if numBoneRefs > 0:
			boneMap = bs.read("i"*numBoneRefs)
			rapi.rpgSetBoneMap(boneMap) #set the bone map

		rapi.rpgSetName(meshName)
		rapi.rpgSetMaterial(meshMat)

		triangles = bs.readBytes(numIdx * 4)
		positions = bs.readBytes(numPos * 12)
		normals = bs.readBytes(numPos * 12) if numNrm == numPos else None
		uvs = bs.readBytes(numPos * 12) if numUVs == numPos else None
		tans = bs.readBytes(numPos * 48) if numTan == numPos else None
		colors = bs.readBytes(numPos * 16) if numClr == numPos else None

		rapi.rpgBindPositionBuffer(positions, noesis.RPGEODATA_FLOAT, 12)
		rapi.rpgBindNormalBuffer(normals, noesis.RPGEODATA_FLOAT, 12)
		rapi.rpgBindUV1Buffer(uvs, noesis.RPGEODATA_FLOAT, 12)
		rapi.rpgBindColorBuffer(colors, noesis.RPGEODATA_FLOAT, 16, 4)
		if numWeights > 0:
			vwList = []
			for j in range(0, numWeights):
				vwNum = bs.readInt()
				bidx = []
				bwgt = []
				for k in range(0, vwNum):
					bidx.append(bs.readInt())
				for k in range(0, vwNum):
					bwgt.append(bs.readFloat())
				vwList.append(NoeVertWeight(bidx, bwgt))
			fw = NoeFlatWeights(vwList)
			rapi.rpgBindBoneIndexBuffer(fw.flatW[:fw.weightValOfs], noesis.RPGEODATA_INT, 4*fw.weightsPerVert, fw.weightsPerVert)
			rapi.rpgBindBoneWeightBuffer(fw.flatW[fw.weightValOfs:], noesis.RPGEODATA_FLOAT, 4*fw.weightsPerVert, fw.weightsPerVert)
		numMorphFrames = bs.readInt()
		for j in range(0, numMorphFrames):
			numMFPos = bs.readInt()
			numMFNrm = bs.readInt()
			morphPosAr = bs.readBytes(numMFPos * 12)
			rapi.rpgFeedMorphTargetPositions(morphPosAr, noesis.RPGEODATA_FLOAT, 12)
			if numMFNrm > 0:
				morphNrmAr = bs.readBytes(numMFNrm * 12)
				rapi.rpgFeedMorphTargetNormals(morphNrmAr, noesis.RPGEODATA_FLOAT, 12)
			rapi.rpgCommitMorphFrame(numMFPos)
		rapi.rpgCommitMorphFrameSet()

		rapi.rpgCommitTriangles(triangles, noesis.RPGEODATA_INT, numIdx, noesis.RPGEO_TRIANGLE, 1)
		rapi.rpgClearBufferBinds() #reset in case a subsequent mesh doesn't have the same components

	mdl = rapi.rpgConstructModel()

	bones = []
	numBones = bs.readInt()
	for i in range(0, numBones):
		bone = noepyReadBone(bs)
		bones.append(bone)

	anims = []
	numAnims = bs.readInt()
	for i in range(0, numAnims):
		animName = bs.readString()
		numAnimBones = bs.readInt()
		animBones = []
		for j in range(0, numAnimBones):
			animBone = noepyReadBone(bs)
			animBones.append(animBone)
		animNumFrames = bs.readInt()
		animFrameRate = bs.readFloat()
		numFrameMats = bs.readInt()
		animFrameMats = []
		for j in range(0, numFrameMats):
			frameMat = NoeMat43.fromBytes(bs.readBytes(48))
			animFrameMats.append(frameMat)
		anim = NoeAnim(animName, animBones, animNumFrames, animFrameMats, animFrameRate)
		anims.append(anim)

	mdl.setBones(bones)
	mdl.setAnims(anims)
	mdlList.append(mdl)			#important, don't forget to put your loaded model in the mdlList
	return 1
예제 #16
0
def noepyLoadModel(data, mdlList):
    ctx = rapi.rpgCreateContext()
    bs = NoeBitStream(data)
    bs.seek(0x18, NOESEEK_ABS)  #seek 0x18h/24
    numMeshes = bs.read("h")  #number of meshes
    numTextures = bs.read("h")  #number of textures
    bs.seek(0x50, NOESEEK_ABS)  #seek 0x50h/80
    offset50offset = bs.read("i")
    offsetMeshHeader = bs.read("i")
    offsetMaterialNameOffsets = bs.read("i")
    bs.seek(0x70, NOESEEK_ABS)  #seek to Mesh Header
    meshHeader = []  #mesh header data
    meshName = []  #mesh names
    matName = []  #materialname used by meshes
    texName = []  #texture names will be used
    matList = []  #Noesis built-in must have material list
    texList = []  #Noesis built-in must have texture list
    offsetMaterialUsageMesh = []
    offsetMaterialUsageTexture = []

    #for loop to get meshHeader data
    for i in range(0, numMeshes[0]):
        offsetMeshName = bs.read("i")
        unkFloat = bs.read("f")  #nem kell offsetMeshName olvassa
        numUsedTextures = bs.read("h")
        numBones = bs.read("h")
        unKnown = bs.read("h")  #nem kell numBones olvassa
        numVertexBytes = bs.read("h")
        numVertices = bs.read("i")
        numFaces = bs.read("i")
        offsetVertices = bs.read("i")
        offsetMaterialUsage = bs.read("i")
        offsetFace = bs.read("i")
        unkOffset = bs.read("i")  #nem kell offsetFace olvassa
        meshHeader.append([
            offsetMeshName[0], numUsedTextures[0], numVertexBytes[0],
            numVertices[0], numFaces[0], offsetVertices[0],
            offsetMaterialUsage[0], offsetFace[0]
        ])
        #0					#1					#2			#3				#4				#5					#6					#7
    #-------------------------------------------------------------

    #for loop to get meshName data
    for i in range(0, numMeshes[0]):
        bs.seek((meshHeader[i][0]), NOESEEK_ABS)
        nameLength = 0
        boolP = True
        while (boolP == True):
            wak = bs.read("b")
            if (wak[0] != 0):
                nameLength = nameLength + 1
            else:
                boolP = False
        bs.seek((meshHeader[i][0]), NOESEEK_ABS)
        meshName.append(bs.readBytes(nameLength).decode("ASCII").rstrip("\0"))
    #-------------------------------------------------------------

    #for loop to get matName data
    matNameOffsetList = []
    bs.seek(offsetMaterialNameOffsets[0],
            NOESEEK_ABS)  #seek to 0x50 offsetMaterialNameOffset
    for i in range(0, numTextures[0]):  #fill matNameOffsetList
        matNameOffsetList.append(bs.read("i"))

    for i in range(0, numTextures[0]):
        bs.seek((matNameOffsetList[i][0]), NOESEEK_ABS)
        nameLength = 0
        boolP = True
        while (boolP == True):
            wak = bs.read("b")
            if (wak[0] != 0):
                nameLength = nameLength + 1
            else:
                boolP = False
        bs.seek(matNameOffsetList[i][0], NOESEEK_ABS)
        matName.append(bs.readBytes(nameLength).decode("ASCII").rstrip("\0"))
        texName = [s + "_d" for s in matName]
    #-------------------------------------------------------------

    #for loop to get materialUsage data
    for i in range(0, numMeshes[0]):  # meshszamszor vegrehajt pl 3 mesh
        bs.seek((meshHeader[i][6]), NOESEEK_ABS)
        for j in range(0,
                       (meshHeader[i][1]
                        )):  #hasznalt textura szamszor vegrehajt pl 4 texture
            materialFacesIndex = bs.read("i")
            materialNumFaces = bs.read(
                "i")  #szorozni harommal a vertex szamhoz
            textureID = bs.read("i")
            numIdx = materialNumFaces * 3
            bs.seek(0x24, NOESEEK_REL)
            offsetMaterialUsageMesh.append([
                materialFacesIndex[0], materialNumFaces[0], textureID[0],
                numIdx[0]
            ])
            #0					#1					#2		    #3
        offsetMaterialUsageTexture.append(offsetMaterialUsageMesh)
        offsetMaterialUsageMesh = []
    #-------------------------------------------------------------

    #material naming
    for i in range(0, numTextures[0]):
        material = NoeMaterial(matName[i], "")
        material.setTexture(matName[i] + "_d.dds")
        material.nrmTexName = (matName[i] + "_n.dds")
        material.specTexName = (matName[i] + "_s.dds")
        material.setDefaultBlend(0)
        matList.append(material)
    #-------------------------------------------------------------

    #the draw
    for i in range(0, numMeshes[0]):
        bs.seek(meshHeader[i][5], NOESEEK_ABS)  #set pointer to vertex offset
        if meshHeader[i][2] == 12:
            VertBuff = bs.seek(((meshHeader[i][3]) * 0xC), NOESEEK_REL)
            #rapi.rpgBindPositionBufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, 12, 0)
        elif meshHeader[i][2] == 24:
            VertBuff = bs.readBytes((meshHeader[i][3]) * 0x18)
            rapi.rpgBindPositionBufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, 24,
                                          0)
            rapi.rpgBindUV1BufferOfs(VertBuff, noesis.RPGEODATA_HALFFLOAT, 24,
                                     20)
        elif meshHeader[i][2] == 32:
            VertBuff = bs.readBytes((meshHeader[i][3]) * 0x20)
            rapi.rpgBindPositionBufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, 32,
                                          0)
            rapi.rpgBindUV1BufferOfs(VertBuff, noesis.RPGEODATA_HALFFLOAT, 32,
                                     28)
        #rapi.rpgCommitTriangles(None, noesis.RPGEODATA_USHORT, meshHeader[i][3], noesis.RPGEO_POINTS, 1)
        bs.seek(meshHeader[i][7], NOESEEK_ABS)
        for j in range(0, meshHeader[i][1]):
            FaceBuff = bs.readBytes(
                (offsetMaterialUsageTexture[i][j][1] * 3) * 2)
            rapi.rpgSetMaterial(matName[offsetMaterialUsageTexture[i][j][2]])
            rapi.rpgSetName(meshName[i])
            rapi.rpgCommitTriangles(FaceBuff, noesis.RPGEODATA_USHORT,
                                    offsetMaterialUsageTexture[i][j][1] * 3,
                                    noesis.RPGEO_TRIANGLE, 1)
        rapi.rpgClearBufferBinds()
    mdl = rapi.rpgConstructModel()
    mdl.setModelMaterials(NoeModelMaterials(texList, matList))
    mdlList.append(mdl)
    rapi.rpgClearBufferBinds()
    return 1
예제 #17
0
    def __init__(self, bs, offset, mesh, boneSect, brntre, impl):
        bs.seekAbs(offset)
        if bs.readString() != "GPR":
            raise ValueError("GPR section expected to be second")

        # calculate offset for far section
        bs.readBytes(0xC)
        self.farOffset = bs.tell()
        bs.readBytes(0x18)
        self.farOffset += bs.readInt()

        # go into GPR descriptors
        bs.seekAbs(offset + 0x40)

        # read HEAP
        if bs.readFixedString(4) != "HEAP":
            raise ValueError("HEAP data expected")
        bs.readInt()
        bs.readInt()
        gprDesSize = bs.readInt()
        bs.readInt()
        heapSize = bs.readInt()
        bs.readInt()
        gprDesCount = bs.readInt()

        self.descriptors = []
        for _ in range(gprDesCount):
            self.descriptors.append(
                GprDes(bs.readFixedString(4), bs.readInt(), bs.readInt(),
                       bs.readInt(), bs.readInt(), bs.readInt(), bs.readInt(),
                       bs.readInt()))

        bs.readBytes(heapSize)
        modelName = bs.readString()
        log("Model name: " + modelName)
        bs.seekAlign(0x10)

        self.nearOffset = bs.tell()

        dlog("GPR near offset: " + hex(self.nearOffset))
        dlog("GPR far offset: " + hex(self.farOffset))

        # Collect IXBF, VXBF, VXST
        ixbfList = []
        vxbfList = []
        vxstList = []
        for _, des in enumerate(self.descriptors):
            if des.name == "IXBF":
                ixbfList.append(des)
            if des.name == "VXBF":
                vxbfList.append(des)
            if des.name == "VXST":
                vxstList.append(des)

        vxstEntryCount = []
        for _, des in enumerate(vxstList):
            bs.seek(des.offset + self.nearOffset, NOESEEK_ABS)
            bs.readBytes(impl.getVxstEntryCountOffset())
            vxstEntryCount.append(bs.readInt())

        vxbfEntryCount = []
        vxbfEntryLen = []
        for _, des in enumerate(vxbfList):
            bs.seek(des.offset + self.nearOffset, NOESEEK_ABS)
            bs.readBytes(0x8)
            vxbfEntryCount.append(bs.readInt())
            vxbfEntryLen.append(bs.readInt())

        # ddump(vxstEntryCount)
        # ddump(vxbfEntryCount)
        # ddump(vxbfEntryLen)

        if len(vxbfList) > len(ixbfList):
            warn("VXBF count > IXBF count, some data not processed")
            # not sure if this will work for Link
            idxToRemove = []
            for i, length in enumerate(vxbfEntryLen):
                if length <= 16:
                    idxToRemove.append(i)
            for idx in sorted(idxToRemove, reverse=True):
                del vxbfList[idx]
                del vxbfEntryCount[idx]
                del vxbfEntryLen[idx]
        elif len(vxbfList) < len(ixbfList):
            warn("VXBF count < IXBF count, some data not processed")

        for i, des in enumerate(vxbfList):
            rapi.rpgSetName(mesh.stringBank[mesh.primInfo[i].meshGeomNameSid])
            bs.seek(des.farOffset + self.farOffset, NOESEEK_ABS)
            vertStride = vxbfEntryLen[i]
            dlog("Parse verts at " + hex(bs.tell()) + " with stride " +
                 str(vertStride))
            vertBuff = bs.readBytes(des.farSize)

            def bindBones(boneOffset, weightOffset, stride):
                VertexBones(boneOffset, weightOffset, stride)

            class VertexBones:
                def __init__(self, boneOffset, weightOffset, stride):
                    if boneSect is None:
                        return

                    self.boneOffset = boneOffset
                    self.weightOffset = weightOffset
                    self.stride = stride
                    self.boneData = []
                    self.weightData = []

                    self.collectBones()
                    self.collectWeights()
                    self.mapBones()
                    flatten = lambda l: [
                        item for sublist in l for item in sublist
                    ]
                    boneBuf = struct.pack("B" * (vxbfEntryCount[i] * 4),
                                          *flatten(self.boneData))
                    rapi.rpgBindBoneIndexBuffer(boneBuf, noesis.RPGEODATA_BYTE,
                                                0x4, 4)
                    weightBuf = struct.pack("f" * (vxbfEntryCount[i] * 4),
                                            *flatten(self.weightData))
                    rapi.rpgBindBoneWeightBuffer(weightBuf,
                                                 noesis.RPGEODATA_FLOAT, 0x10,
                                                 4)

                def collectBones(self):
                    bsi = NoeBitStream(vertBuff)
                    for _ in range(vxbfEntryCount[i]):
                        bsi.readBytes(self.boneOffset)
                        b1 = bsi.readUByte()
                        b2 = bsi.readUByte()
                        b3 = bsi.readUByte()
                        b4 = bsi.readUByte()
                        bsi.readBytes(self.stride - self.boneOffset - 0x4)
                        self.boneData.append([b1, b2, b3, b4])

                def collectWeights(self):
                    wsi = NoeBitStream(vertBuff)
                    for _ in range(vxbfEntryCount[i]):
                        wsi.readBytes(self.weightOffset)
                        w1 = wsi.readUByte() / 255.0
                        w2 = wsi.readUByte() / 255.0
                        w3 = wsi.readUByte() / 255.0
                        w4 = wsi.readUByte() / 255.0
                        wsi.readBytes(self.stride - self.weightOffset - 0x4)
                        self.weightData.append((w1, w2, w3, w4))

                def mapBones(self):
                    for b, w in zip(self.boneData, self.weightData):
                        for i, (bv, wv) in enumerate(zip(b, w)):
                            if wv != 0:
                                try:
                                    b[i] = brntre.boneMeshToSkelMap[bv]
                                except KeyError:
                                    #warn("Missing mapping for mesh bone " + str(bv))
                                    pass

            impl.bindVertStride(modelName, rapi, des, vertBuff, vertStride,
                                bindBones)
            bs.seek(ixbfList[i].farOffset + self.farOffset, NOESEEK_ABS)

            faceList = impl.getFaceList(bs, vxstEntryCount[i])
            faceBuff = struct.pack('H' * len(faceList), *faceList)

            rapi.rpgSetMaterial(mesh.materials[mesh.primInfo[i].matId].name)
            if impl.needsUVFlip():
                rapi.rpgSetUVScaleBias(NoeVec3((1.0, -1.0, 1.0)),
                                       NoeVec3((1.0, 1.0, 1.0)))
            rapi.rpgCommitTriangles(faceBuff, noesis.RPGEODATA_USHORT,
                                    len(faceList), noesis.RPGEO_TRIANGLE, 1)
            if impl.needsOptimize():
                rapi.rpgOptimize()
            rapi.rpgClearBufferBinds()
예제 #18
0
def pso2LoadModel(data, mdlList):
	ctx = rapi.rpgCreateContext()
	bs = NoeBitStream(data)
	Bones = []
	Bone_Pallet = []
	Bone_Matrix = []
	Bone_Name = []
	Bone_Parent = []
	vertSize = []
	vertCount = []
	vtxeOffset = []
	vtxlOffset = []
	psetOffset = []

	boneFileName = rapi.getDirForFilePath(rapi.getInputName()) + rapi.getLocalFileName(rapi.getInputName()).rstrip(".aqo") + ".aqn"
	if (rapi.checkFileExists(boneFileName)):
		boneData = rapi.loadIntoByteArray(boneFileName)
		if boneData is not None:
			bd = NoeBitStream(boneData)
		bd.seek(0xC, NOESEEK_ABS)
		start = bd.readInt()
		bd.seek(start + 0x10, NOESEEK_ABS)
		while not bd.checkEOF():
			chunkStart = bd.tell()
			chunkType = bd.readBytes(4).decode("ASCII")
			chunkSize = bd.readInt()
			subChunkType = bd.readBytes(4).decode("ASCII")
			#print([chunkType,chunkSize,subChunkType])

			for case in switch(subChunkType):
				if case('AQGF'):
					bd.seek(chunkStart + chunkSize, NOESEEK_ABS)
					break
				if case('ROOT'):
					bd.seek(chunkStart + 8 + chunkSize, NOESEEK_ABS)
					break
				if case('NODE'):
					bd.seek(6, NOESEEK_REL)
					while bd.tell() < chunkStart + 8 + chunkSize:
						nodeChunkStart = bd.tell()
						nodeChunkType = bd.readUShort()
						#print([nodeChunkType,nodeChunkStart])
						for case in switch(nodeChunkType):
							if case(0x903):
								nodeTest1 = bd.readInt()
								break
							if case(0x804):
								BoneParent = bd.readInt()
								Bone_Parent.append(BoneParent)
								break
							if case(0x80F):
								nodeTest1 = bd.readInt()
								break
							if case(0x805):
								nodeTest1 = bd.readInt()
								break
							if case(0x806):
								nodeTest1 = bd.readInt()
								break
							if case(0x4A07):
								bd.seek(0xD, NOESEEK_REL)
								break
							if case(0x4A08):
								bd.seek(0xD, NOESEEK_REL)
								break
							if case(0x4A09):
								bd.seek(0xD, NOESEEK_REL)
								break
							if case(0xCA0A):
								bd.seek(0x2, NOESEEK_REL)
								BoneMatrix = NoeMat44.fromBytes(bd.readBytes(64)).toMat43()
								Bone_Matrix.append(BoneMatrix.inverse())
								break
							if case(0x90B):
								nodeTest1 = bd.readInt()
								break
							if case(0x90C):
								nodeTest1 = bd.readInt()
								break
							if case(0x20D):
								nSize = bd.readUByte()
								boneName = bd.readBytes(nSize).decode("ASCII")
								Bone_Name.append(boneName)
								break
							if case(0xFD):
								break
					break
				if case('NODO'):
					bd.seek(bd.getSize(), NOESEEK_ABS)
					break
				if case(): # default, could also just omit condition or 'if True'
					bd.seek(chunkStart + 8 + chunkSize, NOESEEK_ABS)
					# No need to break here, it'll stop anyway
		for a in range(0, len(Bone_Matrix)):
			bn = NoeBone(a, Bone_Name[a], Bone_Matrix[a], None, Bone_Parent[a])
			Bones.append(bn)
	aqoMagic = bs.readInt()
	while not bs.checkEOF():
		chunkStart = bs.tell()
		chunkType = bs.readBytes(4).decode("ASCII")
		chunkSize = bs.readInt()
		subChunkType = bs.readBytes(4).decode("ASCII")
		#print([chunkType,chunkSize,subChunkType])

		for case in switch(subChunkType):
			if case('AQGF'):
				bs.seek(chunkStart + chunkSize, NOESEEK_ABS)
				break
			if case('ROOT'):
				bs.seek(chunkStart + 8 + chunkSize, NOESEEK_ABS)
				break
			if case('OBJC'):
				bs.seek(chunkStart + 8 + chunkSize, NOESEEK_ABS)
				break
			if case('VSET'):
				while bs.tell() < chunkStart + 8 + chunkSize:
					vsetChunkStart = bs.tell()
					vsetChunkType = bs.readUShort()
					#print([vsetChunkStart,vsetChunkType])
					for case in switch(vsetChunkType):
						if case(0x9B6):
							vsetVertSize = bs.readInt()
							vertSize.append(vsetVertSize)
							#print([vsetChunkType,vsetVertSize])
							break
						if case(0x9BF):
							vsetUnk01 = bs.readInt()
							break
						if case(0x9B9):
							vsetVertCount = bs.readInt()
							vertCount.append(vsetVertCount)
							#print([vsetChunkType,vsetVertCount])
							break
						if case(0x9C4):
							vsetUnk01 = bs.readInt()
							break
						if case(0x9BD):
							vsetUnk01 = bs.readInt()
							if vsetUnk01 == 0:
								Bone_Pallet.append(())
							break
						if case(0x86BE):
							test = bs.readByte()
							test = bs.readUByte()
							BonePallet = bs.read("H"*(test + 1))
							Bone_Pallet.append(BonePallet)
							break
						if case(0x6BE):
							test = bs.readByte()
							test = bs.readUByte()
							Bone_Pallet.append(())
							break
						if case(0x9C8):
							vsetUnk01 = bs.readInt()
							break
						if case(0x9CC):
							vsetUnk01 = bs.readInt()
							break
						if case(0x9C9):
							vsetUnk01 = bs.readInt()
							break
						if case(0xFD):
							break

				bs.seek(chunkStart + 8 + chunkSize, NOESEEK_ABS)
				break
			if case('VTXE'):
				vtxeOffset.append([chunkStart,chunkSize])
				bs.seek(chunkStart + 8 + chunkSize, NOESEEK_ABS)
				break
			if case('MESH'):
				bs.seek(chunkStart + 8 + chunkSize, NOESEEK_ABS)
				break
			if case('REND'):
				bs.seek(chunkStart + 8 + chunkSize, NOESEEK_ABS)
				break
			if case('SHAD'):
				bs.seek(chunkStart + 8 + chunkSize, NOESEEK_ABS)
				break
			if case('SHAP'):
				bs.seek(chunkStart + 8 + chunkSize, NOESEEK_ABS)
				break
			if case('TSTA'):
				bs.seek(chunkStart + 8 + chunkSize, NOESEEK_ABS)
				break
			if case('TSET'):
				bs.seek(chunkStart + 8 + chunkSize, NOESEEK_ABS)
				break
			if case('VTXL'):
				vtxlOffset.append([chunkStart,chunkSize])
				bs.seek(chunkStart + 8 + chunkSize, NOESEEK_ABS)
				break
			if case('TEXF'):
				bs.seek(chunkStart + 8 + chunkSize, NOESEEK_ABS)
				break
			if case('PSET'):
				psetOffset.append(chunkStart)
				bs.seek(chunkStart + 8 + chunkSize, NOESEEK_ABS)
				break
			if case(): # default, could also just omit condition or 'if True'
				bs.seek(chunkStart + 8 + chunkSize, NOESEEK_ABS)
				# No need to break here, it'll stop anyway
		
	#bs.readBytes(8).decode("ASCII").rstrip("\0")
	FaceOff = psetOffset[0] + 18
	rapi.rpgSetUVScaleBias(NoeVec3 ((1.0, -1.0, 1.0)), NoeVec3 ((1.0, 1.0, 1.0)))
	for i in range(0, len(vertSize)):
		bs.seek(vtxlOffset[i][0] + 18, NOESEEK_ABS)
		test = bs.readByte()
		if test == 8:
			test = bs.readUByte()
			VertBuff = bs.readBytes(vtxlOffset[i][1] - 12)
		elif test == 24:
			test = bs.readInt()
			VertBuff = bs.readBytes(vtxlOffset[i][1] - 15)
		else:
			test = bs.readUShort()
			VertBuff = bs.readBytes(vtxlOffset[i][1] - 13)
		bs.seek(vtxeOffset[i][0] + 18, NOESEEK_ABS)
		for j in range(0, (vtxeOffset[i][1] - 10) // 26):
			vtxeChunkTypeid = bs.readUShort()
			vtxeChunkType = bs.readInt()
			vtxeChunkType2id = bs.readUShort()
			vtxeChunkType2 = bs.readInt()
			vtxeChunkPosId = bs.readUShort()
			vtxeChunkPos = bs.readInt()
			vtxeChunkUnkid = bs.readUShort()
			vtxeChunkUnk = bs.readInt()
			vtxeChunkTerm = bs.readUShort()
			if vtxeChunkType == 0:
				rapi.rpgBindPositionBufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, vertSize[i], vtxeChunkPos)
			elif vtxeChunkType == 1:
				rapi.rpgBindBoneWeightBufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, vertSize[i], vtxeChunkPos, 4)
			elif vtxeChunkType == 2:
				#rapi.rpgBindNormalBufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, vertSize[i], vtxeChunkPos)
				pass
			elif vtxeChunkType == 3:
				rapi.rpgBindColorBufferOfs(VertBuff, noesis.RPGEODATA_UBYTE, vertSize[i], vtxeChunkPos, 4)
			elif vtxeChunkType == 4:
				pass#4 bytes as floats 2nd vertex color?
			elif vtxeChunkType == 11:
				rapi.rpgBindBoneIndexBufferOfs(VertBuff, noesis.RPGEODATA_UBYTE, vertSize[i], vtxeChunkPos, 4)
			elif vtxeChunkType == 16:
				rapi.rpgBindUV1BufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, vertSize[i], vtxeChunkPos)
			elif vtxeChunkType == 17:
				rapi.rpgBindUV2BufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, vertSize[i], vtxeChunkPos)
			elif vtxeChunkType == 32:
				pass#tangents?
			elif vtxeChunkType == 33:
				pass#binormals/tangents?
			else:
				print(vtxeChunkType)
		bs.seek(FaceOff, NOESEEK_ABS)
		bs.seek(0x1A, NOESEEK_REL)
		test = bs.readByte()
		if test == 8:
			FaceCount = bs.readUByte()
			FaceBuff = bs.readBytes((FaceCount + 1) * 2)
		elif test == 16:
			FaceCount = bs.readUShort()
			FaceBuff = bs.readBytes((FaceCount + 1) * 2)
		else:
			FaceCount = bs.readInt()
			FaceBuff = bs.readBytes((FaceCount + 1) * 2)
		bs.seek(0x8, NOESEEK_REL)
		FaceOff = bs.tell()
		rapi.rpgSetName(str(i))
		rapi.rpgSetMaterial(str(i))
		material = NoeMaterial((str(i)), "")
		if len(Bone_Pallet) > 0:
			if len(Bone_Pallet[i]) > 0:
				rapi.rpgSetBoneMap(Bone_Pallet[i])
		
		rapi.rpgCommitTriangles(FaceBuff, noesis.RPGEODATA_USHORT, FaceCount + 1, noesis.RPGEO_TRIANGLE_STRIP, 1)
	mdl = rapi.rpgConstructModel()
	mdl.setBones(Bones)
	mdlList.append(mdl)
	rapi.rpgClearBufferBinds()	
	return 1
def noepyXmlLoadModel(data, mdlList):
	ctx = rapi.rpgCreateContext()
	bs = NoeBitStream(data)
	rapi.rpgClearBufferBinds()	
	return 1
예제 #20
0
def noepyLoadModel(data, mdlList):
	ctx = rapi.rpgCreateContext()
	bs = NoeBitStream(data)
	bs.setEndian(NOE_BIGENDIAN)
	rapi.rpgSetOption(noesis.RPGOPT_BIGENDIAN, 1)
	fvfInto = []
	texList = []
	matList = []

	header = bs.readBytes(4).decode("ASCII")
	version1 = bs.readInt()
	version2 = bs.readInt()
	modelSize = bs.readInt()
	unk01 = bs.readUShort()
	sceneName = bs.readBytes(30).decode("ASCII").rstrip("\0")
	offset00 = bs.readInt()#Bone Matrix / Parent / 0x80
	count00  = bs.readInt()
	offset01 = bs.readInt()#info related to section before last? / 0x40
	count01  = bs.readInt()
	faceInfoOff = bs.readInt()#Face Info /0x40
	faceInfoSize = bs.readInt()
	materialOff = bs.readInt()
	materialCount  = bs.readInt()
	offset04 = bs.readInt()#? / 0x10
	count04  = bs.readInt()
	offset05 = bs.readInt()#Some Matrix / 0x40
	count05  = bs.readInt()
	vertInfoOff = bs.readInt()#Vertex Info / 0x20
	vertInfoSize  = bs.readInt()
	vertOff = bs.readInt()#Vertex Start / 1
	vertOffSize  = bs.readInt()
	texOff = bs.readInt()#Some Names / 0x20
	texCount  = bs.readInt()
	offset09 = bs.readInt()#Some Names / 0x20
	count09  = bs.readInt()
	offset10 = bs.readInt()#Bone Names / 0x20
	count10  = bs.readInt()
	faceOff = bs.readInt()#Some Face Info / 2
	faceOffSize  = bs.readInt()
	offset12 = bs.readInt()#? / 1
	count12  = bs.readInt()
	offset13 = bs.readInt()#? / 1
	count13  = bs.readInt()

	texName = []
	bs.seek(texOff, NOESEEK_ABS)
	for i in range(0, texCount):
		id = bs.readUShort()
		tmp = bs.readBytes(30).decode("ASCII").rstrip("\0")
		texName.append(tmp)

	bs.seek(materialOff, NOESEEK_ABS)
	for i in range(0, materialCount):
		matInfo = bs.read(">" + "h"*32)
		matInfo2 = bs.read(">" + "f"*16)
		material = NoeMaterial((str(i)), "")
		if matInfo[17] != -1:
			material.setTexture(texName[matInfo[17]] + ".dds")
		matList.append(material)
		#print(matInfo)

	faceInfo = []
	bs.seek(faceInfoOff, NOESEEK_ABS)
	for i in range(0, faceInfoSize):
		faceInfoTmp = bs.read(">iiiiiiiiiiiiiiii")
		#print(faceInfoTmp)
		faceInfo.append(faceInfoTmp)
	#for i in range(0, faceInfoSize):
	#	print(faceInfo[i])
	from operator import itemgetter
	faceInfo = sorted(faceInfo, key=itemgetter(2,1))
	#for i in range(0, faceInfoSize):
		#print(faceInfo[i])
	faceInfo2 = []
	for i in range(0, vertInfoSize):
		tmp = []
		for a in range(0, faceInfoSize):
			if faceInfo[a][2] == i:
				tmp.append(faceInfo[a])
		faceInfo2.append(tmp)
	#print(faceInfo2)

	bs.seek(vertInfoOff, NOESEEK_ABS)
	for i in range(0, vertInfoSize):
		meshID = bs.readInt()
		vertCount = bs.readInt()
		fvf00 = bs.readUByte()	
		fvf01 = bs.readUByte()
		fvf02 = bs.readUByte()
		fvf03 = bs.readUByte()
		fvf04 = bs.readUByte()
		fvf05 = bs.readUByte()
		fvf06 = bs.readUByte()
		fvf07 = bs.readUByte()
		vertStart = bs.readInt()
		vertDataSize = bs.readInt()
		vertSize = bs.readInt()
		null = bs.readInt()
		fvfInto.append([meshID,vertCount,vertStart,vertDataSize,vertSize,fvf00,fvf01,fvf02,fvf03,fvf04,fvf05,fvf06,fvf07])
	print(fvfInto)
	for i in range(0, vertInfoSize):
		bs.seek((vertOff + fvfInto[i][2]), NOESEEK_ABS)
		VertBuff = bs.readBytes(fvfInto[i][3])
		rapi.rpgBindPositionBufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, fvfInto[i][4], 0)
		if fvfInto[i][8] == 4:
			rapi.rpgBindUV1BufferOfs(VertBuff, noesis.RPGEODATA_HALFFLOAT, fvfInto[i][4], (fvfInto[i][4] - 4))
		if fvfInto[i][8] == 0x44:
			rapi.rpgBindUV1BufferOfs(VertBuff, noesis.RPGEODATA_HALFFLOAT, fvfInto[i][4], (fvfInto[i][4] - 8))
		for a in range(0, len(faceInfo2[i])):
			rapi.rpgSetName(str(faceInfo2[i][a][1]))
			rapi.rpgSetMaterial(str(faceInfo2[i][a][1]))
			bs.seek(faceOff + (2 * faceInfo2[i][a][5]), NOESEEK_ABS)
			FaceBuff = bs.readBytes(faceInfo2[i][a][4] * 2)
			rapi.rpgCommitTriangles(FaceBuff, noesis.RPGEODATA_USHORT, faceInfo2[i][a][4], noesis.RPGEO_TRIANGLE, 1)
			bs.seek(faceOff + (2 * faceInfo2[i][a][7]), NOESEEK_ABS)
			FaceBuff = bs.readBytes(faceInfo2[i][a][6] * 2)
			rapi.rpgCommitTriangles(FaceBuff, noesis.RPGEODATA_USHORT, faceInfo2[i][a][6], noesis.RPGEO_TRIANGLE_STRIP, 1)
			bs.seek(faceOff + (2 * faceInfo2[i][a][9]), NOESEEK_ABS)
			FaceBuff = bs.readBytes(faceInfo2[i][a][8] * 2)
			rapi.rpgCommitTriangles(FaceBuff, noesis.RPGEODATA_USHORT, faceInfo2[i][a][8], noesis.RPGEO_TRIANGLE_STRIP, 1)

	mdl = rapi.rpgConstructModel()	
	mdl.setModelMaterials(NoeModelMaterials(texList, matList))
	mdlList.append(mdl)
	rapi.rpgClearBufferBinds()	
	return 1