ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Wed Dec 12, 2018 3:52 am

All times are UTC




Post new topic  Reply to topic  [ 8 posts ] 
Author Message
 Post subject: WRC 7 .P3D models
PostPosted: Sun Nov 11, 2018 3:15 am 

Joined: Sun Nov 11, 2018 2:27 am
Posts: 9
I attempted to use Ninja Ripper on the game in vain, but it turns out that aluigi wrote a script for WRC 7's PKG file formats and that using it reveals a surprisingly good amount of content, all conveniently labelled.

That being said, the .P3D and .PTX files use RIFF as a container, but I figured there's more to it than just that. Maybe some of you 3D experts could figure out how to break this down so that we could port these cars to some other game easily.

Here are sample files I extracted using the BMS scripts mentioned above:
https://www73.zippyshare.com/v/vcUnAAjj/file.html
https://www73.zippyshare.com/v/AauPpLjC/file.html

EDIT: I opened the P3D and PTX files using Riffpad and the nodes seem neatly laid out and labelled (vertex positions, vertex normals, tangents, vertex uvs, indices...). Then again I'm not an expert with deciphering them floats and vert positions so I'll leave those to whoever can understand them:
Image


Top
   
 Post subject: Re: WRC 7 .P3D models
PostPosted: Wed Nov 14, 2018 11:55 pm 

Joined: Wed Jun 01, 2016 5:53 pm
Posts: 22
As I expect. Puzzle. Just few parts are on correct position + no wheels. +1 LOD inside which make mess.
Image

All floats.
Struct from string vpos
Code:
uint vpos;
uint VTBSize;
VertexCount=VTBSize/12;
struct VERTICES {
for (i=0;i<VertexCount;i++)
struct Vertex {
        float VTX;
        float VTY;
        float VTZ;
        Printf("%s %f %f %f\n", s0, VTX*50, VTY*50, VTZ*50);
        }vt;
}vertices;

uint vnor;
uint VNBSize;
VertexCount=VNBSize/8;
struct NORMALS {
for (i=0;i<VertexCount;i++)
struct VNormals {
        hfloat VNX;
        hfloat VNY;
        hfloat VNZ;
        hfloat VNW;
        Printf("%s %f %f %f\n", s1, VNX, VNY, VNZ);
        }vtn;
}normals;

uint vtan;
uint VTGBSize;
FSkip(VTGBSize);

uint vuvs;
uint UVBSize;
VertexCount=UVBSize/4;
struct UV {
for (i=0;i<VertexCount;i++)
struct UVs {
        hfloat VTU;
        hfloat VTV;
        Printf("%s %f %f\n", s2, VTU*2000, -VTV*2000+1); not sure if position is really correct
        }uv;
}unitvector;

uint indx;
uint FBSize;
FaceCount=FBSize/2;
struct FACES {
for (i=0;i<FaceCount/3;i++)
struct Face {
        ushort FX;
        ushort FY;
        ushort FZ;
        Printf("%s %u/%u/%u %u/%u/%u %u/%u/%u\n", s3, FX+1,FX+1,FX+1, FY+1,FY+1,FY+1, FZ+1,FZ+1,FZ+1);
        }face;
}faces;


Top
   
 Post subject: Re: WRC 7 .P3D models
PostPosted: Thu Nov 15, 2018 3:03 pm 

Joined: Sat Aug 29, 2015 1:13 pm
Posts: 90
To build a model, a skeleton is necessary. Each part of the car is associated with a specific bone. It's not difficult to see that the structure of the riff file is similar to the parent-child pattern.

Build a skeleton and then you can attach the wheels to the matching bone.


Attachments:
yaris.png [517.79 KiB]
Not downloaded yet
car.jpg [233.62 KiB]
Not downloaded yet


Last edited by Szkaradek123 on Fri Nov 23, 2018 2:53 pm, edited 1 time in total.
Top
   
 Post subject: Re: WRC 7 .P3D models
PostPosted: Fri Nov 23, 2018 11:08 am 

Joined: Sun Nov 11, 2018 2:27 am
Posts: 9
Szkaradek123 wrote:
To build a model, a skeleton is necessary. Each part of the car is associated with a specific bone. It's not difficult to see that the structure of the riff file is similar to the parent-child pattern.

Build a skeleton and then you can attach the wheels to the matching bone.

I presume this one has the UVs intact, right? Also, is it possible to get the skeleton data from the model itself or do I have to look elsewhere?


Top
   
 Post subject: Re: WRC 7 .P3D models
PostPosted: Fri Nov 23, 2018 3:54 pm 

Joined: Sat Aug 29, 2015 1:13 pm
Posts: 90
As for the details of how to build a skeleton:

The "NoHe" element contains information about the bone name and its local transformation (matrix 4x4) relative to its parent.
And so for the "Piston_FR" bone the parent is "D_Main".
For the bone "D_Main" the parent is "Root". And so on.

The Mesh element has the "NoHe" element transformation and can be composed of more than one "Geom" type element.
"Mesh" and "Geom" have the name of their "NoHe".

Here is an example of using a recursive function to load a tree of bones (python).

Code:

def recurse(parent,g,n):
   bone=None
   tag=g.word(4)
   len=g.i(1)[0]
   n+=4
   tm=g.tell()
   if tag in ['RIFF','LIST']:
      node=Node()
      node.data=parent.data.copy()
      parent.children.append(node)
      chunk=g.word(4)
      node.chunk=chunk   
      node.off=g.tell()   
      write(txt,[tag,':',len,chunk,tm],n)
      while(True):
         pos=recurse(node,g,n)
         if pos==tm+len:break
   else:
      write(txt,[tag,len,tm],n)
      if tag=='NoHe':   
         a=g.H(1)[0]
         b=g.word(g.i(1)[0])[-25:]
         c=g.H(1)[0]
         d=g.f(16)
         e=g.B(12)   
         matrix=Matrix4x4(d)
         write(txt,[a,b,c,d,e],n)
         #parent.matrix=parent.data['matrix'].copy()
         #write(txt,parent.matrix[0],n)
         #write(txt,parent.matrix[1],n)
         #write(txt,parent.matrix[2],n)
         #write(txt,parent.matrix[3],n)
         #parent.data['matrix']=matrix.invert()
         bone=Bone()
         bone.name=b
         skeleton.boneList.append(bone)
         bone.matrix=matrix#.invert()#.transpose()
         if parent.data['name']:bone.parentName=parent.data['name']
         parent.data['name']=b
      if tag=='Mesh':
         model=Model()
         modelList.append(model)
         model.boneName=parent.data['name']
         parent.data['model']=model
         #model.matrix=parent.matrix
      if tag=='Geom':
         mesh=Mesh()
         #mesh.matrix=parent.matrix
         mesh.info=None
         #if parent.model:
         parent.data['model'].meshList.append(mesh)
      if tag=='SuGe':
         info=g.H(1)+g.i(2)+g.H(1)
         mesh=parent.data['model'].meshList[-1]
         mesh.info=info
         write(txt,info,n+4)
      if tag=='vpos':
         mesh=parent.data['model'].meshList[-1]
         vertCount=mesh.info[1]
         for m in range(vertCount):
            mesh.vertPosList.append(g.f(3))
      if tag=='vuvs':
         mesh=parent.data['model'].meshList[-1]
         vertCount=mesh.info[1]
         for m in range(vertCount):
            mesh.vertUVList.append(g.short(2))
      if tag=='vcol':
         mesh=parent.data['model'].meshList[-1]
         vertCount=mesh.info[1]
         for m in range(vertCount):            
            mesh.vertColList.append(g.B(4))
            #print mesh.vertColList[-1]
      if tag=='indx':
         mesh=parent.data['model'].meshList[-1]
         #print mesh.info
         faceCount=mesh.info[2]
         for m in range(faceCount):
            mesh.faceList.append(g.H(3))
         #mesh.draw()
         #model=parent.data['model']
         #mesh.object.setMatrix(parent.data['matrix'])
         
      
   g.seek(tm+len)
   return g.tell()
   
def setBoneMatrix(object,skeletonObject,boneName):
   bones=skeletonObject.getData().bones
   if boneName in bones.keys():
      matrix=bones[boneName].matrix['ARMATURESPACE']
      object.setMatrix(matrix)   

def p3dParser(filename,g):
   global modelList,skeleton
   skeleton=Skeleton()
   #skeleton.ARMATURESPACE=True
   #skeleton.SORT=True
   skeleton.BONESPACE=True
   modelList=[]
   n=0
   root=Node()
   recurse(root,g,n)


Updated:2018-11-26

Blender importer for p3d files.

You need:
http://download.blender.org/release/Ble ... indows.exe
and
https://www.python.org/ftp/python/2.6.6 ... -2.6.6.msi

Unpack archive, doubleclick on file "Blender249.blend" , press alt+p in Blender Text Window and
1
- import car "*.p3d"
2.
- select skeleton in Blender 3D view
3.
- import wheel "*.p3d"

http://www.mediafire.com/file/1s4fr6uuj ... 1-24%5D.7z


Attachments:
cc.png [40.75 KiB]
Not downloaded yet
Top
   
 Post subject: Re: WRC 7 .P3D models
PostPosted: Sat Dec 01, 2018 7:37 am 

Joined: Sun Nov 11, 2018 2:27 am
Posts: 9
How's the UVW maps on this though?


Top
   
 Post subject: Re: WRC 7 .P3D models
PostPosted: Sat Dec 01, 2018 2:02 pm 

Joined: Sat Aug 29, 2015 1:13 pm
Posts: 90
I do not understand.
For me meshes have uv mapping. And for you don't ?


Attachments:
sr.jpg [424.05 KiB]
Not downloaded yet
Top
   
 Post subject: Re: WRC 7 .P3D models
PostPosted: Sun Dec 02, 2018 2:27 am 

Joined: Sun Nov 11, 2018 2:27 am
Posts: 9
Szkaradek123 wrote:
I do not understand.
For me meshes have uv mapping. And for you don't ?

Yeah, it does check out fine. I just had to make sure that I chose the right export options for converting them to Wavefront OBJ, as it would end up being a spaghetti-esque mess otherwise.

Image

I had to manually rename the objects too, but that may have to be merged and renamed in case I convert this to let's say GTA San Andreas or some other racing game.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 8 posts ] 

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