Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Sun Sep 15, 2019 8:35 pm

All times are UTC

Post new topic  Reply to topic  [ 1 post ] 
Author Message
PostPosted: Tue Sep 03, 2019 2:17 pm 

Joined: Sun Mar 31, 2019 7:14 am
Posts: 5
Hello, I'm trying to make a .pmd idolmaster ofa extension plugin, and so far have managed to get bone count and names, texture count and names and mesh count, however i can't seem to be able to make sense of vertex format. I think that vertex data for the first submesh, ACC_HEADShape starts at 0xF5D4 but I'm not sure how to parse it and where the vertex/face count for each submesh is stored, and there's one strange issue with the printf function for texture names not diplaying the first 4 characters in texture name. Could anyone help me out with this? I'm pretty new to Python and reverse engineering game data in general so I'm a bit lost here. Here's the sample model: https://www.dropbox.com/s/pqpm8bki9vzwy ... r.pmd?dl=0
And this is my code:
from inc_noesis import *

import noesis
import rapi

def registerNoesisTypes():
   handle = noesis.register("The IDOLM@STER One For All Model", ".pmd")
   noesis.setHandlerTypeCheck(handle, noepyCheckType)
   noesis.setHandlerLoadModel(handle, noepyLoadModel)
   return 1


def noepyCheckType(data):

   bs = NoeBitStream(data)
   if len(data) < 3:
      return 0
   if bs.readBytes(3).decode("ASCII").rstrip("\0") != NOEPY_HEADER:
      return 0
   return 1       

def noepyLoadModel(data, mdlList):
   ctx = rapi.rpgCreateContext()
   bs = NoeBitStream(data)

   bs.seek(0x10, NOESEEK_ABS) #PTR - Bone block

   bs.seek(0x13, NOESEEK_REL)
   BoneCount = bs.read("i") #Bone count
   bs.seek(0x70C, NOESEEK_ABS) #Bones
   bs.seek(0xFC, NOESEEK_REL) #First bone data
   BoneNames = []
   for i in range(0, BoneCount[0]-1):
      BoneNames.append (bs.readBytes(32).decode("UTF-8").rstrip("\0"))
      bs.seek(0xFC, NOESEEK_REL) #Skip bone data
   bs.seek(0xF448, NOESEEK_ABS) #PME - Mesh block
   bs.seek(0x13, NOESEEK_REL)
   MeshCount = bs.read("i") #Mesh count
   MeshNames = []
   #for i in range(0, MeshCount[0]):
   bs.seek(0x49, NOESEEK_REL) #Seek to mesh name
   MeshNames.append (bs.readBytes(32).decode("UTF-8").rstrip("\0"))
   bs.seek(0x17, NOESEEK_REL)
   bs.seek(0x125, NOESEEK_REL) #Seek to vertex data
   VertBuff = bs.readBytes(VCount[0] * 0x2C)
   rapi.rpgBindPositionBufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, 44, 0)
   rapi.rpgCommitTriangles(None, noesis.RPGEODATA_USHORT, VCount[0], noesis.RPGEO_POINTS, 1)
   mdl = rapi.rpgConstructModel()
   bs.seek(0x10C240, NOESEEK_ABS) #PTE - Texture block

   bs.seek(0x13, NOESEEK_REL) #Texture count
   TexCount = bs.read("i")
   bs.seek(0xA9, NOESEEK_REL)
   TexNames = []
   for i in range(0, TexCount[0]):
      TexNames.append (bs.readBytes(40).decode("UTF-8").rstrip("\0")+".gtf")
      bs.seek(0x148, NOESEEK_REL)
   return 1

Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 1 post ] 

All times are UTC

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited