def build_meshes(self):

        matCount = 0
        for i in range(len(self.meshList)):
            mesh = self.meshList[i]
            if mesh.matNum != -1:
                mat = self.tempMats[mesh.matNum]
            rapi.rpgSetName(mesh.meshName)
            rapi.rpgBindPositionBufferOfs(mesh.vertBuff,
                                          noesis.RPGEODATA_FLOAT, 56, 0)
            rapi.rpgBindNormalBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT,
                                        56, 12)
            rapi.rpgBindUV1BufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 56,
                                     24)

            for j in range(len(mesh.faceGroups)):
                numIdx, idxBuff = mesh.faceGroups[j]
                if numIdx == 0:
                    continue
                matName = "Material[%d]" % matCount
                texName = mat.texNames[i]

                material = NoeMaterial(matName, texName)
                self.matList.append(material)
                rapi.rpgSetMaterial(matName)
                rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT,
                                        numIdx, noesis.RPGEO_TRIANGLE, 1)
 def build_meshes(self):
     
     rapi.rpgSetOption(noesis.RPGOPT_TRIWINDBACKWARD, 1)
     for mesh in self.meshList:
         
         print(mesh.vertSize)
         if mesh.vertSize == 28:
             rapi.rpgBindPositionBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 28, 0)
         elif mesh.vertSize == 32:
             rapi.rpgBindPositionBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 32, 0)
             #rapi.rpgBindNormalBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 32, 20)
             rapi.rpgBindUV1BufferOfs(mesh.vertBuff, noesis.RPGEODATA_HALFFLOAT, 32, 16)
         elif mesh.vertSize == 36:
             rapi.rpgBindPositionBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 36, 0)
         elif mesh.vertSize == 40:
             rapi.rpgBindPositionBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 40, 0)
         elif mesh.vertSize == 44:
             rapi.rpgBindPositionBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 44, 0)
         
         
         #for j in range(mesh.numFaceGroups): # Not sure
         for j in range(1):
             numIdx = mesh.numIndices[j]
             idxBuff = mesh.idxBuffs[j]
             rapi.rpgSetMaterial("WP_A_1550small.tga")
             rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE_STRIP, 1)
Beispiel #3
0
    def build_meshes(self):

        for i in range(len(self.idxBuffs)):
            idxBuff, numIdx, matNum = self.idxBuffs[i]
            vertBuff, vertType = self.vertBuffs[i]
            if matNum != -1:
                matName = self.matList[matNum].name
                rapi.rpgSetMaterial(matName)

            if vertType == 0.125:
                rapi.rpgBindPositionBufferOfs(vertBuff,
                                              noesis.RPGEODATA_HALFFLOAT, 16,
                                              0)
                rapi.rpgBindNormalBufferOfs(vertBuff,
                                            noesis.RPGEODATA_HALFFLOAT, 16, 6)
                rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_HALFFLOAT,
                                         16, 12)

            elif vertType in [0.0333, 0.0335]:
                rapi.rpgBindPositionBufferOfs(vertBuff,
                                              noesis.RPGEODATA_HALFFLOAT, 22,
                                              0)
                rapi.rpgBindNormalBufferOfs(vertBuff,
                                            noesis.RPGEODATA_HALFFLOAT, 22, 6)
                rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_HALFFLOAT,
                                         22, 18)

            rapi.rpgSetOption(noesis.RPGOPT_TRIWINDBACKWARD, 1)

            rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx,
                                    noesis.RPGEO_TRIANGLE, 1)
    def build_mesh_quads(self, vertList, quadBuffs):

        for matNum in quadBuffs:
            numIdx = 0
            idxBuff = bytes()
            vertBuff = bytes()
            idxList = quadBuffs[matNum]["idxList"]
            uvBuff = quadBuffs[matNum]["uvBuff"]
            for index in idxList:
                coords = vertList[index]
                vertBuff += struct.pack("3f", *(map(float, coords)))
                idxBuff += struct.pack("L", numIdx)
                numIdx += 1

            matName = self.matList[matNum].name
            rapi.rpgSetMaterial(matName)
            rapi.rpgBindPositionBuffer(vertBuff, noesis.RPGEODATA_FLOAT, 12)

            if uvBuff:
                rapi.rpgBindUV1Buffer(uvBuff, noesis.RPGEODATA_FLOAT, 8)
            # RPGEO_QUAD, //ABC_DCB
            # RPGEO_QUAD_ABC_BCD,
            # RPGEO_QUAD_ABC_ACD,
            # RPGEO_QUAD_ABC_DCA
            rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_UINT, numIdx,
                                    noesis.RPGEO_QUAD_ABC_ACD, 1)
    def parse_file(self):

        idstring = self.inFile.readUInt()
        hasMat, numMesh = self.inFile.read('2H')
        if hasMat:
            numMat = self.inFile.readUInt()
            for i in range(numMat):
                name = self.read_name(64)
                self.inFile.read('4L')

            #just hardcode matName for now
            matName = self.parse_material()

            numIdx = self.inFile.readUInt()
            numVerts = self.inFile.readUInt()
        else:
            matName = self.parse_material()
            numIdx, numVerts = self.inFile.read('2L')

        idxBuff = self.parse_faces(numIdx, matName)
        self.parse_vertices(numVerts)

        rapi.rpgSetMaterial(matName)
        rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx,
                                noesis.RPGEO_TRIANGLE, 1)
 def parse_meshes(self, numMesh):
     
     for i in range(numMesh):
         self.inFile.read('2L')
         numVerts, numIdx = self.inFile.read("2L")
         
         idxBuff = self.parse_faces(numIdx)
         numSections = self.inFile.readUInt()
         
         for i in range(numSections):
             chunkType, unk2 = self.inFile.read('2L')
             size = self.inFile.readUInt()
             
             if chunkType == 2:
                 vertBuff = self.parse_vertices(numVerts)
             elif chunkType == 3:
                 self.inFile.seek(size, 1)
             elif chunkType == 4:
                 self.inFile.seek(size, 1)
             elif chunkType == 1:
                 self.inFile.seek(size, 1)
         
         self.inFile.readInt()
         count = self.inFile.readUInt()
         self.parse_unk1(count)
         count2 = self.inFile.readUInt()
         self.parse_unk2(count2)
         count3 = self.inFile.readUInt()
         self.parse_unk3(count3)
         
         print (self.inFile.tell())
         rapi.rpgBindPositionBuffer(vertBuff, noesis.RPGEODATA_FLOAT, 12)
         rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)
Beispiel #7
0
    def CreateModel(self):

        for n in range(self.numMesh):
            rapi.rpgBindPositionBufferOfs(self.vertBuff[n],
                                          noesis.RPGEODATA_HALFFLOAT, 64, 0)
            rapi.rpgBindUV1BufferOfs(self.vertBuff[n], noesis.RPGEODATA_SHORT,
                                     64, 16)
            rapi.rpgBindUV2BufferOfs(self.vertBuff[n], noesis.RPGEODATA_SHORT,
                                     64, 16)

            idxBuffer = self.idxBuff[n][:]
            for i in range(self.numDrawCall[n]):
                numDrawFace = self.drawCallFace[n][i]
                idxBuff = idxBuffer[:numDrawFace * 6]
                idxBuffer = idxBuffer[numDrawFace * 6:]
                rapi.rpgSetMaterial(self.matList[self.matID[n][i]].name)
                if self.matID[n][i] in self.matEmis:
                    #rapi.rpgSetLightmap(self.matEmis[self.matID[n][i]].name)
                    self.matList[self.matID[n][i]].setNextPass(
                        self.matEmis[self.matID[n][i]])
                rapi.rpgSetOption(noesis.RPGOPT_TRIWINDBACKWARD, 1)
                if SKIPTOID:
                    rapi.rpgBindBoneIndexBufferOfs(self.boneBuff[n],
                                                   noesis.RPGEODATA_UBYTE, 4,
                                                   0, 4)
                else:
                    rapi.rpgBindBoneIndexBufferOfs(self.vertBuff[n],
                                                   noesis.RPGEODATA_UBYTE, 64,
                                                   44, 4)
                rapi.rpgBindBoneWeightBufferOfs(self.vertBuff[n],
                                                noesis.RPGEODATA_FLOAT, 64, 28,
                                                4)
                rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT,
                                        numDrawFace * 3, noesis.RPGEO_TRIANGLE,
                                        1)
    def parse_file(self):
        '''Main parser method'''

        idstring = self.inFile.readBytes(6)
        self.inFile.readShort()
        self.inFile.readShort()
        self.read_name()
        meshName = self.read_name()

        self.inFile.readByte()  # delim?
        bbox = self.inFile.read('6f')

        self.inFile.readUInt()
        self.inFile.readUInt()
        numVerts, numIdx = self.inFile.read('2H')
        vertBuff = self.parse_vertices(numVerts)
        idxBuff = self.parse_faces(numIdx)

        self.parse_materials()

        rapi.rpgSetName(meshName)
        rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 0)
        rapi.rpgBindNormalBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 12)
        rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 24)
        rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_SHORT, numIdx,
                                noesis.RPGEO_TRIANGLE, 1)
 def parse_file(self):
     '''Main parser method'''
     
     idstring = self.inFile.readBytes(6)
     self.inFile.readShort()
     self.inFile.readShort()
     self.read_name()
     meshName = self.read_name()
     
     self.inFile.readByte() # delim?
     bbox = self.inFile.read('6f')
     
     self.inFile.readUInt()
     self.inFile.readUInt()
     numVerts, numIdx = self.inFile.read('2H')
     vertBuff = self.parse_vertices(numVerts)
     idxBuff = self.parse_faces(numIdx)
     
     self.parse_materials()
     
     rapi.rpgSetName(meshName)
     rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 0)
     rapi.rpgBindNormalBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 12)
     rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 24)
     rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_SHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)
Beispiel #10
0
    def parse_meshes(self, numMesh):

        for i in range(numMesh):
            self.inFile.read('2L')
            numVerts, numIdx = self.inFile.read("2L")

            idxBuff = self.parse_faces(numIdx)
            numSections = self.inFile.readUInt()

            for i in range(numSections):
                chunkType, unk2 = self.inFile.read('2L')
                size = self.inFile.readUInt()

                if chunkType == 2:
                    vertBuff = self.parse_vertices(numVerts)
                elif chunkType == 3:
                    self.inFile.seek(size, 1)
                elif chunkType == 4:
                    self.inFile.seek(size, 1)
                elif chunkType == 1:
                    self.inFile.seek(size, 1)

            self.inFile.readInt()
            count = self.inFile.readUInt()
            self.parse_unk1(count)
            count2 = self.inFile.readUInt()
            self.parse_unk2(count2)
            count3 = self.inFile.readUInt()
            self.parse_unk3(count3)

            print(self.inFile.tell())
            rapi.rpgBindPositionBuffer(vertBuff, noesis.RPGEODATA_FLOAT, 12)
            rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx,
                                    noesis.RPGEO_TRIANGLE, 1)
 def parse_mesh(self, numMesh):
     
     for i in range(numMesh):
         self.read_name() #scene root
         meshName = self.read_name()
         rapi.rpgSetName(meshName)
         numVerts, numIdx, unk = self.inFile.read('3L')
         triStrip, flag1, unk, unk = self.inFile.read('4B')
         self.inFile.seek(496, 1)
         idxBuff = self.parse_faces(numIdx)
         self.parse_vertices(numVerts)
         print(self.inFile.tell())
         if self.hasBones:
             numBones = self.inFile.readUInt()
             self.parse_mesh_bones(numBones)
 
         texName = meshName + ".dds"
         matName = "material"
         material = NoeMaterial(matName, texName)
         self.matList.append(material)
         print(self.inFile.tell())
         
         rapi.rpgSetMaterial(matName)
         if triStrip:
             rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE_STRIP, 1)
         else:
             rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)
 def build_meshes(self):
     
     for i in range(len(self.vertBuffs)):
         idxBuff, numIdx, strips = self.idxBuffs[i]
         vertBuff, vertSize, numVerts =  self.vertBuffs[i]
         #render verts
         if vertSize == 12:
             rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 12, 0)
         elif vertSize == 24:
             rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 24, 0)
         elif vertSize == 32:
             rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 0)
             rapi.rpgBindNormalBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 12)
         elif vertSize == 36:
             rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 36, 0)
         elif vertSize == 40:
             rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 40, 0)
         elif vertSize == 44:
             rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 44, 0)
         elif vertSize == 48:
             rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 48, 8)
         elif vertSize == 72:
             rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 72, 0)
         elif vertSize == 76:
             rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 76, 0)
         elif vertSize == 92:
             rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 92, 20)
         self.plot_points(numVerts)
         #render faces
         if strips:
             #print("strips")
             rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)
         else:
             #print("triangles")
             rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)                    
    def parse_faces(self, numIdx):

        idxBuff = self.inFile.readBytes(numIdx * 2)
        rapi.rpgSetOption(noesis.RPGOPT_TRIWINDBACKWARD, 1)

        rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx,
                                noesis.RPGEO_TRIANGLE, 1)
def noepyLoadModel(data, mdlList):
    '''Build the model, set materials, bones, and animations. You do not
    need all of them as long as they are empty lists (they are by default)'''

    parser = SanaeParser(data)
    parser.parse_file()
    ctx = rapi.rpgCreateContext()

    for i in range(len(parser.vertBuffs)):

        vertBuff, numVerts = parser.vertBuffs[i]
        idxBuff, numIdx, matNum = parser.idxBuffs[i]
        matList = [parser.matList[matNum]]
        texList = [parser.texList[matNum]]
        matName = matList[0].name

        rapi.rpgReset()
        rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 0)
        rapi.rpgBindNormalBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 12)
        rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 24)
        rapi.rpgSetMaterial(matName)
        rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx,
                                noesis.RPGEO_TRIANGLE, 1)

        mdl = rapi.rpgConstructModel()

        mdl.setModelMaterials(NoeModelMaterials(texList, matList))
        mdl.setBones(parser.boneList)
        mdl.setAnims(parser.animList)
        mdlList.append(mdl)
    return 1
def noepyLoadModel(data, mdlList):
    '''Build the model, set materials, bones, and animations. You do not
    need all of them as long as they are empty lists (they are by default)'''
    

    parser = SanaeParser(data)
    parser.parse_file()
    ctx = rapi.rpgCreateContext()
    
    for i in range(len(parser.vertBuffs)):
        
        vertBuff, numVerts = parser.vertBuffs[i]
        idxBuff, numIdx, matNum = parser.idxBuffs[i]
        matList = [parser.matList[matNum]]
        texList = [parser.texList[matNum]]
        matName = matList[0].name
        
        rapi.rpgReset()
        rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 0)
        rapi.rpgBindNormalBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 12)
        rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 24)        
        rapi.rpgSetMaterial(matName)
        rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)    
        
        
        mdl = rapi.rpgConstructModel()
        
        mdl.setModelMaterials(NoeModelMaterials(texList, matList))
        mdl.setBones(parser.boneList)
        mdl.setAnims(parser.animList)
        mdlList.append(mdl)
    return 1
 def build_meshes(self):
         
     rapi.rpgSetOption(noesis.RPGOPT_TRIWINDBACKWARD, 1)
     for i in range(len(self.meshList)):
         mesh = self.meshList[i]        
         rapi.rpgSetName(mesh.name)
         if mesh.vertSize == 32:
             rapi.rpgBindPositionBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 32, 0)
             rapi.rpgBindNormalBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 32, 12)
             rapi.rpgBindUV1BufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 32, 24)
         elif mesh.vertSize == 40:
             rapi.rpgBindPositionBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 40, 0)
             rapi.rpgBindNormalBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 40, 20)
             rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 40, 32)
         elif mesh.vertSize == 48:
             rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 48, 0)
             rapi.rpgBindNormalBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 48, 28)
             rapi.rpgBindUV1BufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 48, 40)
                         
         for sub in mesh.submeshes:            
             idxStart = sub.idxOfs
             idxEnd = idxStart + sub.numIdx * 2
             idxBuff = mesh.idxBuff[idxStart:idxEnd]
         
             rapi.rpgSetMaterial(self.tex)
             rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, sub.numIdx, noesis.RPGEO_TRIANGLE, 1)
 def parse_mesh(self):
         
     meshName = self.read_name()
     null, matNum = self.inFile.read("2L")
     numMat = self.inFile.readUInt()
     if numMat:
         self.inFile.readUInt()
         if numMat > 1:
             self.inFile.readUInt()
     
     self.parse_materials(numMat)
     self.inFile.readUInt()
     self.inFile.read('2f')
     self.inFile.read('3L')
     flag1 = self.inFile.readUInt()
     numVerts = self.inFile.readUInt()
     numNorms = self.inFile.readUInt()
     numIdx = self.inFile.readUInt() * 3
     numBones = self.inFile.readUInt()
     numWeights = self.inFile.readUInt()
     self.inFile.read('50f')
     self.parse_vertices(numVerts, numNorms, numWeights)
     idxBuff = self.parse_faces(numIdx)
     #idxBuff2 = self.parse_faces(numIdx)
     
     if numIdx:
         matName = self.matList[matNum].name
         rapi.rpgSetMaterial(matName)
         rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_UINT, numIdx, noesis.RPGEO_TRIANGLE, 1)        
def noepyLoadModel(data, mdlList):
    '''Build the model, set materials, bones, and animations. You do not
    need all of them as long as they are empty lists (they are by default)'''
    
    ctx = rapi.rpgCreateContext()
    parser = SanaeParser(data)
    parser.parse_file()
    
    #build meshes
    for pose in parser.vertGroups.keys():
        print(pose, len(parser.vertGroups[pose]))
    vertBuffs = parser.vertGroups["walk"]
    for i in range(len(vertBuffs)):
        idxBuff, numIdx, matNum = parser.idxBuffs[i%len(parser.idxBuffs)]
        vertBuff = vertBuffs[i]
        rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 0)
        rapi.rpgBindNormalBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 12)
        rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 24)
        
        matName = parser.matList[matNum].name
        rapi.rpgSetMaterial(matName)
        rapi.rpgSetOption(noesis.RPGOPT_TRIWINDBACKWARD, 1)
        rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)    
    
    mdl = rapi.rpgConstructModel()
    mdl.setModelMaterials(NoeModelMaterials(parser.texList, parser.matList))
    mdl.setBones(parser.boneList)
    mdl.setAnims(parser.animList)
    mdlList.append(mdl)
    return 1
 def parse_meshes(self, numMesh):
     
     for i in range(numMesh):
         meshNum = self.inFile.readUInt()
         print(meshNum, self.inFile.tell())
         self.inFile.seek(28, 1)
         unk, numMat, unk, unk = self.inFile.read('4L')
         unk, numVerts, unk1, numIdx = self.inFile.read('4L')
         self.inFile.read('12f')
         self.inFile.seek(16, 1)
         
         self.parse_material(numMat)
         self.read_name()
         self.inFile.read('8L')
         self.inFile.read('16f')
         self.inFile.read('16f')
         self.inFile.seek(116, 1)
         
         count1, count2 = self.inFile.read('2L')
         self.inFile.seek(52, 1)
         self.parse_vertices(numVerts)
         idxBuff = self.parse_faces(numIdx)
         rapi.rpgSetOption(noesis.RPGOPT_TRIWINDBACKWARD, 1)
         rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)
         
         
         count = self.inFile.readUInt()
         while count > abs(meshNum + 2) or count == 0:
             count = self.inFile.readUInt()
             if self.inFile.tell() == self.inFile.dataSize:
                 break
         self.inFile.seek(-4, 1)
    def parse_mesh(self):

        meshName = self.read_name()
        null, matNum = self.inFile.read("2L")
        numMat = self.inFile.readUInt()
        if numMat:
            self.inFile.readUInt()
            if numMat > 1:
                self.inFile.readUInt()

        self.parse_materials(numMat)
        self.inFile.readUInt()
        self.inFile.read('2f')
        self.inFile.read('3L')
        flag1 = self.inFile.readUInt()
        numVerts = self.inFile.readUInt()
        numNorms = self.inFile.readUInt()
        numIdx = self.inFile.readUInt() * 3
        numBones = self.inFile.readUInt()
        numWeights = self.inFile.readUInt()
        self.inFile.read('50f')
        self.parse_vertices(numVerts, numNorms, numWeights)
        idxBuff = self.parse_faces(numIdx)
        #idxBuff2 = self.parse_faces(numIdx)

        if numIdx:
            matName = self.matList[matNum].name
            rapi.rpgSetMaterial(matName)
            rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_UINT, numIdx,
                                    noesis.RPGEO_TRIANGLE, 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 parse_file(self, filename):
     
     idstring = self.inFile.readBytes(6)
     unk, numMesh = self.inFile.read('2H')
     self.read_name()
     modelName = self.read_name()
     self.inFile.readByte() #?
     self.inFile.read('6f')
     self.inFile.read('2L')
     numVerts, numIdx = self.inFile.read('2H')
     self.parse_vertices(numVerts)
     idxBuff = self.parse_faces(numIdx)
     matName = self.parse_material()
     
     rapi.rpgSetMaterial(matName)
     rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)
     ##unknowns
     #self.parse_unk()
     #count = self.inFile.readUInt()
     #self.parse_unk2(count)
     #count2 = self.inFile.readUInt()
     #self.parse_unk3(count2)
     #count3 = self.inFile.readUInt()
     #self.parse_unk4(count3)
     
     
     
Beispiel #23
0
    def build_mesh(self):

        print(len(self.idxBuffs), len(self.matList))
        for i in range(len(self.idxBuffs)):
            vertBuff, vertSize = self.vertBuffs[i]
            idxBuff, numIdx = self.idxBuffs[i]

            if i < len(self.matList):
                matName = self.matList[i].name
            else:
                matName = self.matList[-1].name

            if vertSize == 56:
                rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT,
                                              56, 0)
                rapi.rpgBindPositionUV1Ofs(vertBuff, noesis.RPGEODATA_FLOAT,
                                           56, 12)
                rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 56,
                                         28)
            elif vertSize == 72:
                rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT,
                                              72, 0)
                rapi.rpgBindNormalBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT,
                                            72, 28)
                rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 72,
                                         44)
            rapi.rpgSetMaterial(matName)
            rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx,
                                    noesis.RPGEO_TRIANGLE, 1)
Beispiel #24
0
    def parse_file(self):
        '''Main parser method'''

        rapi.rpgSetMaterial(self.basename)
        header, meshType = self.inFile.read('2L')
        if meshType == 0:
            self.inFile.read('9f')
            self.inFile.read('76B')
            numBones, numVerts, numUnk = self.inFile.read('3L')
            numIdx = self.inFile.readUInt() * 3
            self.inFile.read('40B')
            print(numVerts, numBones, numIdx)
            self.parse_vertices(numVerts)
            self.parse_bones(numBones)
            idxBuff = self.parse_faces(numIdx)

            rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx,
                                    noesis.RPGEO_TRIANGLE, 1)
        elif meshType == 1:
            print("mobject")
            self.inFile.read('9f')
            self.inFile.read('76B')
            numAnims, numVerts, numUnk = self.inFile.read('3L')
            numIdx = self.inFile.readUInt() * 3

            print(numAnims, numVerts, numIdx)

            #self.parse_animations(numAnims)
            #print(self.inFile.tell())
            self.parse_vertices(numVerts)
            self.plot_points(numIdx)
Beispiel #25
0
 def SubObj(self, count):
     for i in range(count):
         self.data.seek(4, 1)
         numVert = self.data.readUInt()
         #print("numVert",numVert)
         offset = self.Serialise()
         #self.vertList.append([])
         vertList = b''
         for t in range(numVert):
             vertList += self.data.readBytes(12)
             self.data.seek(32, 1)
         self.data.seek(offset)
         self.data.seek(4 + 8 + 4, 1)
         numIdx = self.data.readUInt()
         #print("numIdx",numIdx,self.data.tell())
         offset = self.Serialise()
         idxList = b''
         for t in range(numIdx):
             idxList += self.data.readBytes(2)
         self.data.seek(offset)
         self.data.seek(4 + 8 + 4 + 4 + 4 + 4 + 128 + 128 + 24 + 4 + 8 + 8,
                        1)
         rapi.rpgBindPositionBufferOfs(vertList, noesis.RPGEODATA_FLOAT, 12,
                                       0)
         rapi.rpgCommitTriangles(idxList, noesis.RPGEODATA_USHORT, numIdx,
                                 noesis.RPGEO_TRIANGLE, 1)
Beispiel #26
0
    def __init__(self, data, i):
        data.seek(2, 1)
        self.numVert = data.readUShort()
        self.ptr = data.readUInt()
        data.seek(28, 1)
        self.xyz = data.read('3f')
        current = data.tell()
        data.seek(self.ptr + 2)
        self.headers = data.readUShort()
        pLine = 'SubMesh: \n  numVert: %d\n  Headers: %d' % (self.numVert,
                                                             self.headers)
        print(pLine)
        #if self.headers != 1:    print('Not Header 1',data.tell());data.seek(current);return
        data.seek(4, 1)
        ptrs = data.read('5I')

        data.seek(ptrs[0])
        rapi.rpgBindPositionBuffer(data.readBytes(self.numVert * 12),
                                   noesis.RPGEODATA_FLOAT, 12)
        data.seek(ptrs[1])
        rapi.rpgBindUV1Buffer(data.readBytes(self.numVert * 12),
                              noesis.RPGEODATA_FLOAT, 12)
        data.seek(ptrs[2])
        data.seek(current)
        mat = NoeMaterial(str(i), str(i))
        rapi.rpgSetMaterial(str(i))
        rapi.rpgCommitTriangles(None, noesis.RPGEODATA_UINT, self.numVert,
                                noesis.RPGEO_TRIANGLE_STRIP_FLIPPED, 1)
Beispiel #27
0
 def parse_file(self):
     
     meshName = self.read_name()
     matName = self.read_name()
     texName = meshName
     
     numIdx = self.inFile.readUInt() * 3
     numVerts, numUV = self.inFile.read('2L')
     vertBuff = self.parse_vertices(numVerts)
     idxBuff = self.parse_faces(numIdx)
     uvBuff = self.parse_uv(numUV)
     self.parse_uv_index(numIdx)
     
     #create material
     material = NoeMaterial(matName, texName)
     self.matList.append(material)        
     
     #build mesh
     rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 24, 0)
     rapi.rpgBindNormalBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 24, 12)
     
     #commit triangles
     rapi.rpgSetMaterial(texName)
     rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)
     
     #what to do with these UV's?
     rapi.rpgBindUV1Buffer(uvBuff, noesis.RPGEODATA_FLOAT, 8)        
     
     
    def build_vertices(self, mesh, meshName):
        
        vertBuff = bytes()
        normBuff = bytes()
        uvBuff = bytes()
        idxBuff = bytes()
        rapi.rpgSetName(meshName)
        for i in range(mesh.numIdx):
            index = mesh.idxList[i]
            vertBuff += struct.pack('3f', *mesh.vertList[index])
            normBuff += struct.pack('3f', *mesh.normList[index])
            uvBuff += struct.pack('2f', *mesh.uvList[i])
            idxBuff += struct.pack('H', i)
            
        rapi.rpgBindPositionBuffer(vertBuff, noesis.RPGEODATA_FLOAT, 12)
        rapi.rpgBindNormalBuffer(normBuff, noesis.RPGEODATA_FLOAT, 12)
        rapi.rpgBindUV1Buffer(uvBuff, noesis.RPGEODATA_FLOAT, 8)
        

        matName = meshName
        material = NoeMaterial(matName, self.basename)
        material.setDefaultBlend(0)
        self.matList.append(material)
        
        rapi.rpgSetMaterial(meshName)
        rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, mesh.numIdx, noesis.RPGEO_TRIANGLE, 1)
def noepyLoadModel(data, mdlList):
    '''Build the model, set materials, bones, and animations. You do not
    need all of them as long as they are empty lists (they are by default)'''

    ctx = rapi.rpgCreateContext()
    parser = SanaeParser(data)
    parser.parse_file()

    #build meshes
    for pose in parser.vertGroups.keys():
        print(pose, len(parser.vertGroups[pose]))
    vertBuffs = parser.vertGroups["walk"]
    for i in range(len(vertBuffs)):
        idxBuff, numIdx, matNum = parser.idxBuffs[i % len(parser.idxBuffs)]
        vertBuff = vertBuffs[i]
        rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 0)
        rapi.rpgBindNormalBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 12)
        rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 32, 24)

        matName = parser.matList[matNum].name
        rapi.rpgSetMaterial(matName)
        rapi.rpgSetOption(noesis.RPGOPT_TRIWINDBACKWARD, 1)
        rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx,
                                noesis.RPGEO_TRIANGLE, 1)

    mdl = rapi.rpgConstructModel()
    mdl.setModelMaterials(NoeModelMaterials(parser.texList, parser.matList))
    mdl.setBones(parser.boneList)
    mdl.setAnims(parser.animList)
    mdlList.append(mdl)
    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_vertices(self, mesh, meshName):

        vertBuff = bytes()
        normBuff = bytes()
        uvBuff = bytes()
        idxBuff = bytes()
        rapi.rpgSetName(meshName)
        for i in range(mesh.numIdx):
            index = mesh.idxList[i]
            vertBuff += struct.pack('3f', *mesh.vertList[index])
            normBuff += struct.pack('3f', *mesh.normList[index])
            uvBuff += struct.pack('2f', *mesh.uvList[i])
            idxBuff += struct.pack('H', i)

        rapi.rpgBindPositionBuffer(vertBuff, noesis.RPGEODATA_FLOAT, 12)
        rapi.rpgBindNormalBuffer(normBuff, noesis.RPGEODATA_FLOAT, 12)
        rapi.rpgBindUV1Buffer(uvBuff, noesis.RPGEODATA_FLOAT, 8)

        matName = meshName
        material = NoeMaterial(matName, self.basename)
        material.setDefaultBlend(0)
        self.matList.append(material)

        rapi.rpgSetMaterial(meshName)
        rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, mesh.numIdx,
                                noesis.RPGEO_TRIANGLE, 1)
    def parse_mesh(self, numMesh):

        for i in range(numMesh):
            self.read_name()  # scene root
            meshName = self.read_name()
            rapi.rpgSetName(meshName)
            numVerts, numIdx, unk = self.inFile.read("3L")
            triStrip, flag1, unk, unk = self.inFile.read("4B")
            self.inFile.seek(496, 1)
            idxBuff = self.parse_faces(numIdx)
            self.parse_vertices(numVerts)
            print(self.inFile.tell())
            if self.hasBones:
                numBones = self.inFile.readUInt()
                self.parse_mesh_bones(numBones)

            texName = meshName + ".dds"
            matName = "material"
            material = NoeMaterial(matName, texName)
            self.matList.append(material)
            print(self.inFile.tell())

            rapi.rpgSetMaterial(matName)
            if triStrip:
                rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE_STRIP, 1)
            else:
                rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)
    def build_meshes(self):

        for i in range(len(self.idxBuffs)):
            idxBuff, numIdx = self.idxBuffs[i]
            matName = self.matList[i].name

            rapi.rpgSetMaterial(matName)
            rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)
 def build_meshes(self):
     
     for mesh in self.meshList:
         
         rapi.rpgBindPositionBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 44, 0)
         rapi.rpgBindNormalBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 44, 12)
         rapi.rpgBindUV1BufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 44, 28)
         rapi.rpgCommitTriangles(mesh.idxBuff, noesis.RPGEODATA_USHORT, mesh.numIdx, noesis.RPGEO_TRIANGLE, 1)
Beispiel #35
0
 def parse_faces(self, numFaces):
     
     idxBuff = bytes()
     for i in range(numFaces):
         self.inFile.readUInt()
         idxBuff += self.inFile.readBytes(12)
         
     rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_UINT, numFaces * 3, noesis.RPGEO_TRIANGLE, 1)
    def build_extras(self):

        for i in range(len(self.extraList)):
            mesh = self.extraList[i]
            rapi.rpgBindPositionBuffer(mesh.vertBuff, noesis.RPGEODATA_FLOAT,
                                       12)
            rapi.rpgCommitTriangles(mesh.idxBuff, noesis.RPGEODATA_USHORT,
                                    mesh.numIdx, noesis.RPGEO_TRIANGLE, 1)
 def build_meshes(self):
     
     for i in range(len(self.idxBuffs)):
         idxBuff, numIdx = self.idxBuffs[i]
         matName = self.matList[i].name
         
         rapi.rpgSetMaterial(matName)
         rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)                
 def build_mesh(self, meshType):
     
     for i in range(len(self.idxBuffs)):
         idxBuff, numIdx = self.idxBuffs[i]
         
         if meshType == 0:
             rapi.rpgSetOption(noesis.RPGOPT_TRIWINDBACKWARD, 1)
         rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)
Beispiel #39
0
    def CreateGeo(self):
        print(len(self.idxs))
        x = 0
        y = len(self.geos)  #8
        n = []  #[5,6,7]
        GEO_C = 0
        self.matList = []
        self.texList = []
        dirPath = rapi.getDirForFilePath(rapi.getInputName())
        for mat in self.mats:
            self.matList.append(mat.material)
            mat = mat.material
            diffuse = mat.texName
            normal = mat.nrmTexName
            specular = mat.specTexName
            for t in [diffuse, normal, specular]:
                try:
                    tex = open(dirPath + '/' + t, 'rb').read()
                    tex = rapi.loadTexByHandler(tex, '.dds')
                    tex.name = t
                    self.texList.append(tex)
                except:
                    raise

        for i in range(x, x + y):
            #for i in range(len(self.idxs)):
            idx = self.idxs[i]
            geo = self.geos[i]
            prop = geo.props
            print("%d: " % i, idx.name, " | ", geo.name)
            print(idx.numTri, idx.numIdx, geo.numVert)
            if not i in n:

                #material = self.matList[MaterialLink[idx.name]]
                rapi.rpgSetMaterial(MaterialLink[idx.name])
                rapi.rpgBindPositionBufferOfs(geo.vertBuffer,
                                              noesis.RPGEODATA_FLOAT,
                                              geo.vertLength, prop['position'])
                rapi.rpgBindUV1BufferOfs(geo.uvBuffer, noesis.RPGEODATA_FLOAT,
                                         geo.uvLength, prop['tex0'])
                rapi.rpgBindNormalBufferOfs(geo.vertBuffer,
                                            noesis.RPGEODATA_FLOAT,
                                            geo.vertLength, prop['normal'])
                rapi.rpgBindTangentBufferOfs(geo.vertBuffer,
                                             noesis.RPGEODATA_FLOAT,
                                             geo.vertLength, prop['tangent'])
                rapi.rpgCommitTriangles(idx.idxBuffer, noesis.RPGEODATA_USHORT,
                                        idx.numIdx, noesis.RPGEO_TRIANGLE, 1)
                #rapi.rpgCommitTriangles         (idx.idxBuffer,    noesis.RPGEODATA_USHORT, idx.numTri,     noesis.RPGEO_TRIANGLE, 1)
            if GEO_C == 1:
                bs = NoeBitStream()
                fileG = open("geo-%d.p3ddump" % i, 'wb')
                bs.writeUInt(geo.numVert)
                bs.writeBytes(geo.vertBuffer)
                bs.writeUInt(idx.numTri)
                bs.writeBytes(idx.idxBuffer)
                fileG.write(bs.getBuffer())
                fileG.close()
 def build_mesh(self, idxBuff):
     
     for matInfo in self.materials:
         one, start, count, matNum = matInfo
         end = start*2 + count*2
         idxList = idxBuff[start*2:end]
         matName = self.matList[matNum].name
         rapi.rpgSetMaterial(matName)
         rapi.rpgCommitTriangles(idxList, noesis.RPGEODATA_USHORT, count, noesis.RPGEO_TRIANGLE, 1)
  def build_mesh(self):
      
      for i in range(len(self.meshList)):
          mesh = self.meshList[i]
          rapi.rpgBindPositionBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 32, 0)
          rapi.rpgBindNormalBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 32, 12)
          rapi.rpgBindUV1BufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 32, 24)
 
          rapi.rpgCommitTriangles(mesh.idxBuff, noesis.RPGEODATA_UINT, mesh.numIdx, noesis.RPGEO_TRIANGLE, 1)         
 def build_mesh(self, mesh):
 
     rapi.rpgBindPositionBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 24, 0)
     rapi.rpgBindNormalBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 24, 12)
     #rapi.rpgSetName(mesh.name)
     #self.plot_points(mesh.numVerts)
     if mesh.triCount:
         rapi.rpgCommitTriangles(mesh.triBuff, noesis.RPGEODATA_USHORT,  mesh.triCount, noesis.RPGEO_TRIANGLE, 1)
     if mesh.quadCount:
         rapi.rpgCommitTriangles(mesh.quadBuff, noesis.RPGEODATA_USHORT, mesh.quadCount, noesis.RPGEO_QUAD_ABC_ACD, 1)
Beispiel #43
0
 def parse_face_section(self, numSects):
     
     for i in range(numSects):
         numIdx = self.inFile.readInt()
         idxList = self.parse_faces(numIdx)
         self.inFile.readInt()
         matName = self.read_name()
         
         rapi.rpgSetMaterial(matName)
         rapi.rpgCommitTriangles(idxList, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)
    def build_mesh(self, idxBuff):

        for matInfo in self.materials:
            one, start, count, matNum = matInfo
            end = start * 2 + count * 2
            idxList = idxBuff[start * 2:end]
            matName = self.matList[matNum].name
            rapi.rpgSetMaterial(matName)
            rapi.rpgCommitTriangles(idxList, noesis.RPGEODATA_USHORT, count,
                                    noesis.RPGEO_TRIANGLE, 1)
    def build_mesh(self):
        
        for mesh in self.meshList:
            rapi.rpgBindPositionBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 92, 0)
            rapi.rpgBindNormalBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 92, 12)
            rapi.rpgBindUV1BufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 92, 28)                        
            rapi.rpgSetName(mesh.meshName)

            matName = self.matList[mesh.matNum].name
            rapi.rpgSetMaterial(matName)
            rapi.rpgCommitTriangles(mesh.idxBuff, noesis.RPGEODATA_UINT, mesh.numIdx, noesis.RPGEO_TRIANGLE, 1)
 def build_mesh(self):
     
     for i in range(len(self.meshList)):
         mesh = self.meshList[i]
         rapi.rpgBindPositionBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 48, 0)
         rapi.rpgBindNormalBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 48, 28)
         rapi.rpgBindUV1BufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 48, 40)            
         
         matName = self.matList[i].name
         rapi.rpgSetMaterial(matName)
         rapi.rpgCommitTriangles(mesh.idxBuff, noesis.RPGEODATA_USHORT, mesh.numIdx, noesis.RPGEO_TRIANGLE, 1)
 def build_faces(self, idxBuff, matUsed, materials):
     
     start = 0
     for i in range(len(matUsed)):
         numIdx = matUsed[i] * 3
         end = start + numIdx * 4
         buff = idxBuff[start:end]
         rapi.rpgSetMaterial(materials[i])
         rapi.rpgCommitTriangles(buff, noesis.RPGEODATA_UINT, numIdx, noesis.RPGEO_TRIANGLE, 1)
         
         start = end
 def parse_faces(self, numIdx, strips=0):
    
     #print(numIdx, self.inFile.tell()) 
     idxBuff = self.inFile.readBytes(numIdx*2)
     self.idxBuffs.append([idxBuff, numIdx, strips])
     
     if strips:
         #print("strips")
         rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE_STRIP, 1)
     else:
         #print("triangles")
         rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)     
 def build_mesh(self):
     
     for mesh in self.meshList:
     
         rapi.rpgBindPositionBuffer(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 12)
         self.plot_points(mesh.numVerts)
         rapi.rpgSetName(mesh.name)
         
         if mesh.triCount:
             rapi.rpgCommitTriangles(mesh.triBuff, noesis.RPGEODATA_UINT, mesh.triCount, noesis.RPGEO_TRIANGLE, 1)
         if mesh.quadCount:
             rapi.rpgCommitTriangles(mesh.quadBuff, noesis.RPGEODATA_UINT, mesh.quadCount, noesis.RPGEO_QUAD_ABC_ACD, 1)
 def parse_vertex_groups(self, numGroups):
     
     for i in range(numGroups):
         mesh = Mesh()
         self.inFile.read('3L')
         mesh.numVerts = self.inFile.readShort()
         self.inFile.readShort()
         mesh.vertBuff = self.parse_vertices(mesh.numVerts)
         #self.write_mesh(mesh)
         
         rapi.rpgBindPositionBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 32, 0)
         rapi.rpgCommitTriangles(None, noesis.RPGEODATA_USHORT, mesh.numVerts, noesis.RPGEO_POINTS, 1)
    def build_meshes(self):
        
        for i in range(len(self.meshList)):
            mesh = self.meshList[i]
            rapi.rpgBindPositionBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 32, 0)
            rapi.rpgBindNormalBufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 32, 12)
            rapi.rpgBindUV1BufferOfs(mesh.vertBuff, noesis.RPGEODATA_FLOAT, 32, 24)

            print(mesh.matNum)
            matName = self.matList[mesh.matNum].name
            rapi.rpgSetMaterial(matName)
            rapi.rpgCommitTriangles(mesh.idxBuff, noesis.RPGEODATA_USHORT, mesh.numIdx, noesis.RPGEO_TRIANGLE_STRIP, 1)
 def assign_face_material(self, numMat, numIdx):
     '''Have to split the idxList into separate parts, where each index
     is an integer'''
     
     for i in range(numMat):
         start = self.faceMats[i][0]
         count = self.faceMats[i][1]
         end = start*4 + count*4
         idxList = self.idxList[start*4:end]
         matName = self.matList[i].name
         rapi.rpgSetMaterial(matName)
         if count:
             rapi.rpgCommitTriangles(idxList, noesis.RPGEODATA_UINT, count, noesis.RPGEO_TRIANGLE, 1)