Page 1 of 3

IDOLM@STER One For All .pmd

Posted: Mon Sep 02, 2019 6:08 pm
by MarieRose1301
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:

Code: Select all

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)
   noesis.logPopup()
       #print
   return 1

NOEPY_HEADER = "PMD"

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
   print(BoneCount)
   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
   print(BoneNames)
   
   bs.seek(0xF448, NOESEEK_ABS) #PME - Mesh block
   
   bs.seek(0x13, NOESEEK_REL)
   MeshCount = bs.read("i") #Mesh count
   print(MeshCount)
   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)
   VCount=bs.read("i")
   print(VCount)
   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()
   mdlList.append(mdl)
   
   bs.seek(0x10C240, NOESEEK_ABS) #PTE - Texture block

   bs.seek(0x13, NOESEEK_REL) #Texture count
   TexCount = bs.read("i")
   print(TexCount)
   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)
   print(TexNames)
   
   rapi.rpgClearBufferBinds()   
   return 1

Re: IDOLM@STER One For All .pmd

Posted: Sat Sep 07, 2019 5:56 pm
by MarieRose1301
Anyone? I have been able to identify the faces but still nothing on vertices

Re: IDOLM@STER One For All .pmd

Posted: Sat Sep 07, 2019 9:14 pm
by shakotay2
MarieRose1301 wrote:
Sat Sep 07, 2019 5:56 pm
Anyone? I have been able to identify the faces but still nothing on vertices
the faces (face indices) generally don't really help.
Usually you start finding point clouds. That's the way how I do it.
Then you search for suiting face indices.

In this case I'm not sure about the format, HF or shorts:
.
-pmd.png

Re: IDOLM@STER One For All .pmd

Posted: Sun Sep 08, 2019 4:17 am
by Bigchillghost
Image
chr_body_all.png
Might need to take care of some extra faces.

Re: IDOLM@STER One For All .pmd

Posted: Sun Sep 08, 2019 7:58 am
by MarieRose1301
Bigchillghost wrote:
Sun Sep 08, 2019 4:17 am
Image
chr_body_all.png

Might need to take care of some extra faces.
Thank you so much, this is very helpful :D
However, I don't quite understand how to calculate vertex count. Do you mind explaining that part?

Re: IDOLM@STER One For All .pmd

Posted: Sun Sep 08, 2019 8:26 am
by Bigchillghost
pmd.png

Re: IDOLM@STER One For All .pmd

Posted: Sun Sep 08, 2019 10:59 am
by MarieRose1301
Bigchillghost wrote:
Sun Sep 08, 2019 8:26 am
pmd.png
Thank you, almost got every mesh down, except of slender_dShape and ACCHEAD_Shape
Do I understand correctly that for example the slender_dShape mesh has 72 vertices and 143 poly indices, and that indices start at 0x105FB4 and vertex data at 0xF1110 ? Because for some reason I am unable to preview mesh, but vertex cloud works just fine
Here's one of working meshes on the other hand :D
slender_cShape1-min.png

Re: IDOLM@STER One For All .pmd

Posted: Sun Sep 08, 2019 11:41 am
by Bigchillghost
MarieRose1301 wrote:
Sun Sep 08, 2019 10:59 am
almost got every mesh down, except of slender_dShape and ACCHEAD_Shape
ACCHEAD_Shape:
ACC_HEADShape.png
MarieRose1301 wrote:
Sun Sep 08, 2019 10:59 am
Do I understand correctly that for example the slender_dShape mesh has 72 vertices and 143 poly indices, and that indices start at 0x105FB4 and vertex data at 0xF1110 ?
Yep.
MarieRose1301 wrote:
Sun Sep 08, 2019 10:59 am
Because for some reason I am unable to preview mesh, but vertex cloud works just fine
Coz the amount of vertex is below 256 and the format is using 8-bit integer to store the indices, which's out of AMR's expectation.
MarieRose1301 wrote:
Sun Sep 08, 2019 10:59 am
Here's one of working meshes on the other hand :D
slender_cShape1-min.png
Congratulations, you've already get the hang of that app. :)

Re: IDOLM@STER One For All .pmd

Posted: Sun Sep 08, 2019 1:59 pm
by MarieRose1301
Bigchillghost wrote:
Sun Sep 08, 2019 11:41 am
MarieRose1301 wrote:
Sun Sep 08, 2019 10:59 am
almost got every mesh down, except of slender_dShape and ACCHEAD_Shape
ACCHEAD_Shape:
ACC_HEADShape.png
MarieRose1301 wrote:
Sun Sep 08, 2019 10:59 am
Do I understand correctly that for example the slender_dShape mesh has 72 vertices and 143 poly indices, and that indices start at 0x105FB4 and vertex data at 0xF1110 ?
Yep.
MarieRose1301 wrote:
Sun Sep 08, 2019 10:59 am
Because for some reason I am unable to preview mesh, but vertex cloud works just fine
Coz the amount of vertex is below 256 and the format is using 8-bit integer to store the indices, which's out of AMR's expectation.
MarieRose1301 wrote:
Sun Sep 08, 2019 10:59 am
Here's one of working meshes on the other hand :D
slender_cShape1-min.png
Congratulations, you've already get the hang of that app. :)
Here's what I got working :D Thank you very much for your help, I hope I have enough info to start reading meshes in Noesis now :D
ranko.PNG

Re: IDOLM@STER One For All .pmd

Posted: Sun Sep 08, 2019 4:31 pm
by MarieRose1301
Almost complete geometry, only misses slender_dShape from main body files and kurome_O_OBJ_O_SORTBIASm4__O_AU from head file
ranko_almost.PNG

Re: IDOLM@STER One For All .pmd

Posted: Mon Sep 09, 2019 7:49 pm
by shakotay2
I've updated the Make_obj tool for creating all submeshes (tested with chr_body_rank_104_a_slender.pmd only!):
shakotay2 wrote:
Mon Sep 09, 2019 7:47 pm
(some superfluous vertices)
.
chr_body_rank_104_a_slender-pmd.png

Re: IDOLM@STER One For All .pmd

Posted: Tue Sep 10, 2019 2:52 pm
by MarieRose1301
shakotay2 wrote:
Mon Sep 09, 2019 7:49 pm
I've updated the Make_obj tool for creating all submeshes (tested with chr_body_rank_104_a_slender.pmd only!):
shakotay2 wrote:
Mon Sep 09, 2019 7:47 pm
(some superfluous vertices)
.
chr_body_rank_104_a_slender-pmd.png
I have just gotten to try the program, it actually does work on other models as well, but with the same issue as the AMR, it won't convert meshes with few faces like eyes for example. Do you think you could link me the source so I can study it? C is the only programming language I actually understand on more than surface/basic level

Re: IDOLM@STER One For All .pmd

Posted: Tue Sep 10, 2019 3:14 pm
by Bigchillghost
MarieRose1301 wrote:
Tue Sep 10, 2019 2:52 pm
but with the same issue as the AMR, it won't convert meshes with few faces like eyes for example.
I don't understand. If you can load the rest of the meshes into noesis, why can't that one? It's just the same format but using unsigned char instead of short for the face indices storage.

Re: IDOLM@STER One For All .pmd

Posted: Tue Sep 10, 2019 3:47 pm
by MarieRose1301
Bigchillghost wrote:
Tue Sep 10, 2019 3:14 pm
MarieRose1301 wrote:
Tue Sep 10, 2019 2:52 pm
but with the same issue as the AMR, it won't convert meshes with few faces like eyes for example.
I don't understand. If you can load the rest of the meshes into noesis, why can't that one? It's just the same format but using unsigned char instead of short for the face indices storage.
I cannot load anything in noesis yet in fact as I haven't been able to code anything yet ^^"

Re: IDOLM@STER One For All .pmd

Posted: Tue Sep 10, 2019 5:42 pm
by MarieRose1301
I feel completely stupid right now but I have no idea how to read a number stored in 4 bytes...
dunno.PNG