Quantcast

Jump to content

» «
Photo

[DOC]IV model formats - .wft, .wdr, .wdd

366 replies to this topic
DexX
  • DexX

    Black Hat

  • Feroci
  • Joined: 16 May 2002

#1

Posted 11 December 2008 - 06:31 PM Edited by DexX, 01 July 2009 - 10:41 PM.

Released Exporters and Tools:
Experimental Zmodeler 2 .wft filter from Oleg

Old info from here down


Based on models uploaded in this topic and discussion from the last post there...

QUOTE (mr.Dageron)

Ask GooD-NTS or Alexander Blade... I am only a person who is looking for progress, compare information from differen forums and post it here))

You want to keep everything in a secret like other information about GTAIV formats? Please, not...

Model format is hacking by CrashBandicoot and listener (I just only translated their speech to english)

CrashBandicoot:
QUOTE

Model file has symmetrical structure, and what he needed.
Here's what new research showed.
Usually, the files coords 3D data points are written in succession on 12 bytes. 1 point = 12 bytes (float x, float y, float z). Considering model with the bat (file rpg.wdr.rsc) proved that point is 36 bytes. The first 12 - are coordinates x, y, z. The next 12 bytes this point on the circle around bits (that is, is the "garbage" around bits). But next 12 bytes - is not clear at all that: The first 4 bytes - not the number (not exactly float), second and third quite similar to the number of type float.

1 point is this:
offset | description
-----------------
0 float coord_X
4 float coord_Y
8 float coord_Z
12 float unk_X
16 float unk_Y
20 float unk_Z
24 unk2
28 float unk3_1
32 float unk3_2

unk2 - the number does not seem to be some flags. For example, what it can be value: 9B 9B 9B FF, B3 B3 B3 FF, 96 96 96 FF, 9C 9C 9C FF, 93 93 93 FF, B5 B5 B5 FF, 94 94 94 FF, etc.

At the expense of unk3_1 and unk_3_2 - float values from 0 to 1. Perhaps texture coordinates.


listener:
QUOTE

In bat file, at 0x1000 begins GPU-segment. All that it is to be standart D3D structures.

Lhen it is possible to saw vertex and index array. (Fields filled 0xCD - not-inicialised data). Total size of the buffer index produced 480 triangles.

i'll re-iterate a bit. All my discussion is based on w_bat_wdr.rsc

rsc_info.txt
HeaderLength, offset into file where raw vertex data begins.
DataLength, total amount of data to read in, including any padding (0xCD) and face indices.

The vertex structure should be as follows:
0 float position x
4 float position y
8 float position z
12 float normal x
16 float normal y
20 float normal z
24 dword color (RGBA)
28 float texcoord u
32 float texcoord v

size of 1 vertex = 36 bytes
size of vertex array = 0x1ef0
0x1ef0 / 36 = 220 verts (vertex count isn't listed in file anywhere? i can't find it..)

dword unknown
dword unknown
dword unknown (material indices?)
padding (0xCDCDCDCD)
offset 0x3000, face indices?
face index array is 0x5A0 bytes long (also 16-bit face indices, see Directx dox)
padding until 0x3FFF
eof

Notes on vertex structures: Earlier in the file, 0xBC0 for the bat, there a list of shaders that will be used for the materials on the geometry. The vertices should have the data that the shaders expect, and different shaders will expect different data. Peds have boneweights, and some geometry has tangents, or multiple uv coordinates. Be sure to sure to cross check the shaders listed in the model, with common\shaders\db, and the vertex declarations in common\shaders\dcl.

Edit: The *.dcl files have been changed with R* patches (1.0.2.0 for sure, 1.0.1.0 is untested) and no longer contain full vertex declarations mad.gif
Anyone using that data needs to grab the files from a 1.0.0.0 install.

oCain
  • oCain

    Crackhead

  • Members
  • Joined: 02 Oct 2005

#2

Posted 11 December 2008 - 07:58 PM Edited by oCain, 11 December 2008 - 10:18 PM.

Whoot! Really Fast! Nice one DexX! smile.gif

Here my results...
user posted image user posted image user posted image
...the AK seems to have two parts. (maybe?!)

I'm not really good in file description, so I just upload the test-max-scripts...
http://rapidshare.co...t_Test.rar.html
...really raw(noobish) and "static", 'cause I also couldn't found any vertex-count or something like that.

But what I can say is that the shooting-weapons (AK&RPG) have some more floats(?).
0 float position x
4 float position y
8 float position z
12 float normal x
16 float normal y
20 float normal z
24 dword color (RGBA)
28 float texcoord u
32 float texcoord v

36 unkFloat?
40 unkFloat?
44 unkFloat?
48 unkFloat?

That's it...for now.

Greetz!

//Edit-->
user posted image
Normals, VertexColors & UV-Mapping...

DexX
  • DexX

    Black Hat

  • Feroci
  • Joined: 16 May 2002

#3

Posted 11 December 2008 - 11:01 PM Edited by DexX, 11 December 2008 - 11:41 PM.

QUOTE
36 unkFloat?
40 unkFloat?
44 unkFloat?
48 unkFloat?

Tangents, used for setting up the normal map correctly in the shader (since R* almost certainly used tangent-space normal maps).
36 tangent x
40 tangent y
44 tangent z
48 tangent w

QUOTE
...the AK seems to have two parts. (maybe?!)

There's vertex data @ 0x2000, and 0x22000 (with corresponding face data @ 0x2e4400). So yea, 2 sets of geometry data.

Edit, aha, there's another piece at 0x21D70 - this has the default vertex structure i listed in my first post - no tangents.

QUOTE
Normals, VertexColors & UV-Mapping...

You beat me to it, bastard tounge.gif

The geometry structure seems to be basically this:
initial vertex data/geometry offset
--begin of vertex data (based on vertex declaration)
--read until 0xCDCDCDCD
--begin face index for these verts
--read until 0xCDCDCDCD
-next set of vertex data, loop
repeat until EOF

Other notes:
There are *.sps files mentioned in the section before the geometry data is stored. The sps files seem to contain references to which shader will be used. For example gta_alpha.sps, references gta_default, and there is no gta_alpha shader. There are 131 .sps files, and only 90 shaders.

Gforce
  • Gforce

  • Feroci
  • Joined: 17 Sep 2003
  • United-Kingdom

#4

Posted 12 December 2008 - 12:52 AM

QUOTE (oCain @ Dec 11 2008, 19:58)

...the AK seems to have two parts. (maybe?!)

possibly because gun weapons use a seperate muzzle flash model, they did in SA wink.gif

great work so far gentlemen smile.gif

EvilRaptor
  • EvilRaptor

    The Ranger

  • Members
  • Joined: 14 Jun 2007

#5

Posted 12 December 2008 - 01:14 AM

Weapons use two different models because when the player reloads, the magazine's pulled off and replaced by one on the player's person... like the rocket launcher, only you're replacing more than one ammo at a time tounge.gif
The rocket's still in another model file, just like before, and just like that, the other weapons have adopted this sort-of system of having a sub-model, the minigun in SA had two model parts, for example... and now the AK has another model for it's clip... simple.

Gforce
  • Gforce

  • Feroci
  • Joined: 17 Sep 2003
  • United-Kingdom

#6

Posted 12 December 2008 - 01:36 AM Edited by Gforce, 12 December 2008 - 01:49 AM.

ah yes, i forgot to look at the pic's, i thought he meant the model file he was looking at had 2 parts blush.gif

Edit: max scripts re-uploaded due to RS hit a 10 DL limit confused.gif

http://www.savefile.com/files/1926534

lpgunit
  • lpgunit

    It's L, as in Lpgunit, not I.

  • Feroci
  • Joined: 24 May 2008
  • Philippines

#7

Posted 12 December 2008 - 01:47 AM

Nice... Don't know much about cracking file formats, but it is quite epic; any more and we'll end up with custom vehicles for IV... cookie.gif cookie.gif

_CP_
  • _CP_

    Group: Vice City Stories team

  • Feroci
  • Joined: 27 Dec 2007
  • Poland
  • Best Map 2013 "ViceCityStories PC Edition"

#8

Posted 12 December 2008 - 09:19 AM

Wow! It's epic! Now we can make mods with models of cars!

mr.Dageron
  • mr.Dageron

    Bbobik - my old nickname

  • BUSTED!
  • Joined: 25 Nov 2008

#9

Posted 12 December 2008 - 11:28 AM

News from gtamaps.net:
user posted image

aru
  • aru

    *poof*

  • Feroci
  • Joined: 20 Jun 2005
  • None

#10

Posted 12 December 2008 - 01:37 PM

Here's a little template I wrote for 010 Editor (its a hex editor) that parsed out most of the outer non-model data from the decompressed xbox360 xdr model files. Non-model data meaning things like... headers, # of geometry parts, vertex count, indice count, etc. I think the only sections I hadn't written structures for was the ones linking the shaders. The windows wdr might be a little different... but this might help in either case:

http://aru.nd4spdwor.../pic/iv-xdru.bt

Some really good work here though! Keep it up.

xadet3
  • xadet3

    Player Hater

  • Members
  • Joined: 13 Dec 2008

#11

Posted 13 December 2008 - 02:07 AM

Nice work. First time I've ever played around with GTA related files, so I quickly whipped this up today out of pure boredom tounge.gif .

user posted image

Do most of the file formats usually get reversed and released publicly? Or should I attempt them myself?

mr.Dageron
  • mr.Dageron

    Bbobik - my old nickname

  • BUSTED!
  • Joined: 25 Nov 2008

#12

Posted 13 December 2008 - 11:39 AM

Our:
user posted image

oCain
  • oCain

    Crackhead

  • Members
  • Joined: 02 Oct 2005

#13

Posted 13 December 2008 - 02:25 PM Edited by oCain, 13 December 2008 - 02:56 PM.

Nice Pictures! (Progress wink.gif )

I've just found a tiny thing...

offset: 96 [0x60] = Object Count
(Weapons only...maybe other objects too?!)

--

user posted image
...nothing special, but you can see the different parts of the AK.

Keep at up!

//Edit-->
QUOTE
You beat me to it, bastard  tounge2.gif

HeHe...Sorry Dude, but there was nothing on TV. wink.gif

//Editē-->
VertexBlockOffsetTheory:

If we could read the whole Header(+Texture/ShaderInfo Stuff)and got the the size.
Then the vertexBlock starts at the next PowerOfTwo value.
Let's say the Header++ beats the 2048, so the VertexBlock starts at 4096 and if it beats the 4096,
the VertexBlock starts at 8192.

strange Idea + poor english = bad mixture...I know. blush.gif

mr.Dageron
  • mr.Dageron

    Bbobik - my old nickname

  • BUSTED!
  • Joined: 25 Nov 2008

#14

Posted 13 December 2008 - 05:50 PM

oCain, your work is great! icon14.gif Can you try to open some car files?

LiveLife
  • LiveLife

  • Members
  • Joined: 11 Aug 2007

#15

Posted 14 December 2008 - 08:00 PM

Sorry for the following OT, but my content is realy important for us.

Hey oCain,
I'm writing this as my personal last request to you. Please read what I have to say and think about it. I'll write this text to make some things absolutly clear and to show that we, the members of the GTA United modification, want you back. You are a very talented GTA modder and you were it back months ago aswell. Over a half year ago you simply disaapeard one day, from the one day to the next. Let me define something clean. If some of us said some inappropriate thing or in any way bad thing to you: we doesn't meant it that way. We talked to each other, if someone knows why you simply disaapered; but nobody noticed something. If it should be like this way, we want to apologize us. Like I wrote earlier on YouTube, if the reason should be personal things/school/other thing we would really understand that, if someone doesn't want to do anything more with GTA, we respect that. The only thing we really would like to see is, if you could at least tell us, what you're gonna do. I personally thought back then that you are a cool and talented guy, really, but seeing now as you ignored us for months and appeard now again with that real bomb you showed in this thread is a bit sad for us. In the name of AMD, Aschratt, myself and all others, I can only hope that you tell us what you're reasons were & are! We do not know that we have done something wrong, if we have done it. We still want you back oCain, please keep that in mind.

Greetz,
CD

GamerShotgun
  • GamerShotgun

    The main protagonist.

  • Members
  • Joined: 03 Oct 2005

#16

Posted 14 December 2008 - 10:46 PM

Did you know that GTAForums has a Private Messaging system, which you can use for these kind of messages? sarcasm.gif

DexX
  • DexX

    Black Hat

  • Feroci
  • Joined: 16 May 2002

#17

Posted 15 December 2008 - 04:22 AM

Dageron, do you guys extract the models differently? The sample files you uploaded have the extra text files, that contain the offset/size data. REspawn just released his img extractor, and the models (.wft) files are slightly different - larger.
Fixed in REspawns last update.

mr.Dageron
  • mr.Dageron

    Bbobik - my old nickname

  • BUSTED!
  • Joined: 25 Nov 2008

#18

Posted 15 December 2008 - 12:40 PM

Maybe extractor is a bit different. Our ones were extracted with OpenIV.

Textures:
user posted image

ChrisBenoit!
  • ChrisBenoit!

    Player Hater

  • Members
  • Joined: 27 Dec 2005

#19

Posted 15 December 2008 - 08:36 PM

QUOTE (MasterK @ Dec 14 2008, 22:46)
Did you know that GTAForums has a Private Messaging system, which you can use for these kind of messages? sarcasm.gif

We know this but he donīt send an answer... T_T

DexX
  • DexX

    Black Hat

  • Feroci
  • Joined: 16 May 2002

#20

Posted 17 December 2008 - 03:32 AM Edited by DexX, 18 December 2008 - 10:15 PM.

i've been looking into the *.sps files in common\shaders\db, and there seems to be an attribute that many of them share;
CODE
__rage_drawbucket {
int 1
}

The 'int' value can be 1-5, or in some cases, 29 or 30. I gave it limited testing in "gta_vehicle_vehglass.sps", trying it at 1, 3, and 5 (what seemed to be the most popular uses, based on my research).

at 1: http://img101.images...wbucket1rm4.jpg
Alpha is normal.

at 3: http://img211.images...wbucket3dr7.jpg
Alpha is opaque.

at 5: http://img126.images...wbucket5oy0.jpg
Alpha is gone.

29 was seen in gta_vehicle_nosplash.sps
30 was seen in gta_vehicle_nowater.sps

For some of the other sps files, there are other attributes that can be edited. For example:
CODE
SpecularColor {
float 0.150000
}
Specular {
float 180
}

...from "gta_vehicle_vehglass.sps", controls the spec amount for the glass materials. Although the parameters here seem to be matched with variables in the shader file (in this case, gta_vehicle_vehglass.fxc), it seems only certain vars can be changed with this method.

Dec 18
Not related to the above stuff - The models are in more than one format;
.wft
.wdr
.wdd

Component peds use both .wdd and wft model types. Regarding peds the .wdd files seem to contain the texture and material lists, object names, and other data. The wft file seems to have bone and matrix info. Both contain mesh data, although the mesh data from the wft files is extremely small in many cases, compared to the mesh data from the wdd file, which appears to be the bulk of the model.

Vehicles only seem to use wft files, so the above does not apply to them (vehicle wft files have all the necessary info). Weapons (mainly .wdr) and ped props (mainly .wdd) have no wft's. wdr and wdd formats seem to be very similar.

A cursory examination of the Map imgs, reveals that they use primarily wdr files, with a few wdd files here and there. Very few wft files, probably those are animated, or otherwise special map objects.

DexX
  • DexX

    Black Hat

  • Feroci
  • Joined: 16 May 2002

#21

Posted 20 December 2008 - 06:53 PM

Pinned to feed my ego. Hot damn. Actually, if anyone ever wants to see new car and ped models ingame, this stuff needs to be cracked. Having it fall behind the other topics won't help a bit.

Oh yea, been documenting the system data (*.sys, if using SparkIV / Resoursaur).
It's slightly out of date (thank you aru), but it's a start:
www.3dhole.com/iv/system_notes.txt

listener
  • listener

    Monkey with a disassembler

  • Members
  • Joined: 06 Sep 2007
  • None

#22

Posted 20 December 2008 - 09:09 PM

DexX, I thinking, your approach is... ineffective. RSC is not a sequence of chunks, like a RenderWare stream, but dumped out block of memory.
So, if we will read RSC contents and relocate all pointers, we got nice linked object structure.

My info on wdr, wdd and and wtd structures: http://public.sannyb...GTA4/rsc_en.txt

DexX
  • DexX

    Black Hat

  • Feroci
  • Joined: 16 May 2002

#23

Posted 20 December 2008 - 09:43 PM

Effective enough to import the segments in max, and build a simple hierarchy though. But this topic exists for this exact reason - for discussion, and thats some quality work you posted icon14.gif

aru
  • aru

    *poof*

  • Feroci
  • Joined: 20 Jun 2005
  • None

#24

Posted 20 December 2008 - 10:51 PM Edited by aru, 20 December 2008 - 11:04 PM.

QUOTE (listener @ Dec 20 2008, 16:09)
DexX, I thinking, your approach is... ineffective. RSC is not a sequence of chunks, like a RenderWare stream, but dumped out block of memory.
So, if we will read RSC contents and relocate all pointers, we got nice linked object structure.

My info on wdr, wdd and and wtd structures: http://public.sannyb...GTA4/rsc_en.txt

Updated a bit:
CODE

struct rage::grmGeometry : public rage::datBase {  // size = 0x4C
  DWORD _f4;  // +4
  DWORD   _f8;
  rage::grcVertexBufferD3D * m_vertexBuffers[4];  // +0xC
  rage::grcIndexBufferD3D  * m_indexBuffers[4];  // +0x1C
  DWORD   m_dwIndexCount;
  DWORD   m_dwFaceCount;
  WORD   m_wVertexCount;
  WORD   m_wIndicesPerFace;
  void *  _f38;  
  WORD   m_wVertexStride;   // Essentially size of each vertex
  WORD   _f3E;
  DWORD   _f40;
  void * _f44;
  DWORD   _f48;
};


New struct (I suck at this, so excuse the mistakes tounge.gif )....

CODE

struct rage::grmShaderGroup : public rage::datBase { // size = ??
  DWORD _f4;
  CPtrCollection<SomeShaderStruct> m_shaders;
  DWORD _f10[12];   // Type might be wrong (might not even be an array).. needs checking
  CSimpleCollection<DWORD> m_unknown1;
  CSimpleCollection<DWORD> m_unknown2;
};


SomeShaderStruct has ptrs to shader name and sps file name.


@listener... does the game use all 4 of those defined Vertex/Index buffers? Or just the first one?

mr.Dageron
  • mr.Dageron

    Bbobik - my old nickname

  • BUSTED!
  • Joined: 25 Nov 2008

#25

Posted 21 December 2008 - 01:07 PM Edited by mr.Dageron, 21 December 2008 - 01:13 PM.

WDR Viewer+3ds max import plugin by CrashBandicoot (gtamaps.net&OpenIV team)

DOWNLOAD

1) Extract models from IMG in *.wdr format.
2) If you need textures, extract them in JPEG format.
3) Open WDR in programm.
4) Export model file.
5) Open it with importer in 3ds max.
smile.gif

JostVice
  • JostVice

    realtime, not prerendered

  • Feroci
  • Joined: 30 Oct 2005
  • None

#26

Posted 21 December 2008 - 01:17 PM

Holy crap. works great, another great tool by the red army. Can't wait for the wfts though smile.gif

listener
  • listener

    Monkey with a disassembler

  • Members
  • Joined: 06 Sep 2007
  • None

#27

Posted 21 December 2008 - 02:38 PM

QUOTE (aru @ Dec 20 2008, 22:51)
@listener... does the game use all 4 of those defined Vertex/Index buffers? Or just the first one?

thanks, aru

game code initializes all 4 buffers, but create vertex declaration only for the first vertex buffer.
I shall make resource scanner, for finding some unusual data (volume/cube textures, geometries with more than one vertex/index buffer, etc.)

File updated (more info on grmShaderGroup)

Picolini
  • Picolini

    ZOMG ROFL XD!!!!11

  • BUSTED!
  • Joined: 07 Dec 2002

#28

Posted 21 December 2008 - 04:52 PM

Glad to see people working on all this technical stuff, keep it up guys icon14.gif
I wouldn't know where to start.

You're the core of proper modding!

simkas
  • simkas

    That guy

  • Members
  • Joined: 13 Dec 2006

#29

Posted 21 December 2008 - 05:12 PM

QUOTE (mr.Dageron @ Dec 21 2008, 13:07)
WDR Viewer+3ds max import plugin by CrashBandicoot (gtamaps.net&OpenIV team)

DOWNLOAD

1) Extract models from IMG in *.wdr format.
2) If you need textures, extract them in JPEG format.
3) Open WDR in programm.
4) Export model file.
5) Open it with importer in 3ds max.
smile.gif

Awesome, but how do I get the textures to show up correctly in 3dmax?

mr.Dageron
  • mr.Dageron

    Bbobik - my old nickname

  • BUSTED!
  • Joined: 25 Nov 2008

#30

Posted 21 December 2008 - 06:16 PM Edited by mr.Dageron, 22 December 2008 - 10:10 AM.

QUOTE (simkas @ Dec 21 2008, 16:52)
Awesome, but how do I get the textures to show up correctly in 3dmax?

Impossible yet confused.gif




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users