Important information: this site is currently scheduled to go offline indefinitely by end of the year.

Resident Evil 2 PC, EMD model format

Post questions about game models here, or help out others!
PmData
beginner
Posts: 33
Joined: Mon Oct 30, 2006 6:56 pm
Location: France
Been thanked: 2 times
Contact:

Resident Evil 2 PC, EMD model format

Post by PmData »

Hello,

I finished writing a page about why I know about the EMD file format:
http://rewiki.regengedanken.de/wiki/.EM ... il_2_PC%29
I hope it is clear enough to understand. Atm, I documented only one part of the file. The rest seems to holds links between parts, and maybe animations steps.

Attached is a screenshot of a model with a self made viewer. I translated the different parts of the model a bit, to avoid having them mixed at the same place.

From right to left, body, head, wings, and more stuff. Triangles are purple, quads are blue. I did not try texturing at this stage.
You do not have the required permissions to view the files attached to this post.
User avatar
lionheartuk
double-veteran
double-veteran
Posts: 749
Joined: Tue May 16, 2006 10:55 pm
Location: Everywhere
Has thanked: 34 times
Been thanked: 42 times

Post by lionheartuk »

Cool man.
Another addition to the supported formats list i guess.
Strange to see such an old game shown.
have u been doing it since it was released or only recently?
PmData
beginner
Posts: 33
Joined: Mon Oct 30, 2006 6:56 pm
Location: France
Been thanked: 2 times
Contact:

Started recently

Post by PmData »

lionheartuk wrote: have u been doing it since it was released or only recently?
I only started 6-7 weeks ago, to play with OllyDbg and IdaPro, and see what I could use them for. Especially since the IdaPro 4.3 freeware runs on Linux/x86 using Wine.

So I first tried to RE the ADT file format, because this is the first file the game loads. It took me 3 weeks to get the decompression routine in C, from the disassembled asm x86.

The EMD format is a bit like the playstation TMD file format, regarding how primitives are stored, so this was a bit easier to get, hum 2 weeks of work.
PmData
beginner
Posts: 33
Joined: Mon Oct 30, 2006 6:56 pm
Location: France
Been thanked: 2 times
Contact:

Now with texturing

Post by PmData »

Here is Claire Redfield, in parts, with texturing.

There is not much left to document in the file, but it may be the harder part.

As you can see, only body, head and legs (both left and right), no arms, so they must be taken from another model in the game.
You do not have the required permissions to view the files attached to this post.
UnpackerX
ultra-n00b
Posts: 5
Joined: Mon May 07, 2007 11:26 pm

Post by UnpackerX »

I was heard that all Resident Evil games was build on Microsoft Softimage,
about the RDT files they contain the camera information, room information, textures in TM2 format and if the game was in other languages it contains the subtitles show in the game from dialogs, maybe someone can make a tool to extract the RDT subtitles from dialogs?
Maybe the models was build with Softimage also but with a custom export plugin :)
In PSX the RDT can viewed in the latest Sony Movie Converter 3.6 just rename from RDT to BS and it work, if the data are too large the program crash then you need to split the files in 64kb then it work.
PmData
beginner
Posts: 33
Joined: Mon Oct 30, 2006 6:56 pm
Location: France
Been thanked: 2 times
Contact:

Post by PmData »

UnpackerX wrote:In PSX the RDT can viewed in the latest Sony Movie Converter 3.6 just rename from RDT to BS and it work, if the data are too large the program crash then you need to split the files in 64kb then it work.
What is more likely to happen is that this tool just seek in the file till it finds the signature of a BS data stream (starting with 0x3800 value), and just depack image from this location. I know the RDT contains some 2D images (I also found some in TIM format) mainly the sprites to be drawn above the background.
BillyRubin
ultra-n00b
Posts: 3
Joined: Wed May 16, 2007 1:28 am

Post by BillyRubin »

I converted the models of BIO1 to lwo, but haven't been able to extract the models of BIO2. Any chance you can upload them in lwo or obj?
BillyRubin
ultra-n00b
Posts: 3
Joined: Wed May 16, 2007 1:28 am

Post by BillyRubin »

So I first tried to RE the ADT file format, because this is the first file the game loads. It took me 3 weeks to get the decompression routine in C, from the disassembled asm x86.
Wow. That's some fine work. I did it the hard way :oops:

I've been trying to unlock the beta stuff for a while now. BTW, for anyone who hasn't figured out how the .SAP files work they're in RIFF wav format. All you need is a hex editor to change the header, convert it to wav and play it on winamp exp.

Image
UnpackerX
ultra-n00b
Posts: 5
Joined: Mon May 07, 2007 11:26 pm

Post by UnpackerX »

I have take a look in the original Sony documentation about the models and found that EMD model are the same as PMD model (packet model)
this format can contain the model, texture and scripts. The models was build using the Alias 8.0 with official plugins that pack the model in PMD format. Inside the PMD format contain the TMD model encrypted, the TIM textures not encrypted, the models animations called TOD format.

#define TEX_ADDR 0x801c0000 /* texture address */
#define PMD_ADDR 0x801a0000 /* PMD object address */
#define OTLENGTH 8 /* OT depth */
#define OTSIZE (1<<OTLENGTH)
#define SCR_Z 1024

static int pad_read(void);
static void RotPMD(u_long *ot, int id);
static void loadTIM(u_long *addr);

main()
{
u_long otbuf[2][1<<OTLENGTH]; /* OT */
int id; /* double buffer ID */

db_init(640, 480, SCR_Z, 60, 120, 120); /* init */
loadTIM((u_long *)TEX_ADDR); /* load texture */
SetDispMask(1); /* start display */

while (pad_read() == 0) {
id = id? 0: 1; /* swap */
ClearOTagR(otbuf[id], OTSIZE); /* clear OT */
RotPMD(otbuf[id], id); /* add PMD to OT */
FntPrint("PMD viewer(1)\n"); /* message */
db_swap(otbuf[id]+OTSIZE-1); /* draw OT */
}
PadStop(); /* quit */
StopCallback();
return(0);
}

Load TIM data from main memory to the frame buffer

static void loadTIM(u_long *addr)
{
TIM_IMAGE image; /* TIM header */

OpenTIM(addr); /* open TIM */
while (ReadTIM(&image)) {
if (image.caddr) /* load CLUT (if needed) */
LoadImage(image.crect, image.caddr);
if (image.paddr) /* load texture pattern */
LoadImage(image.prect, image.paddr);
}
}



PMD functions
There are 16 PMD functions accroding to its vertex format


/* independent vertex type (8 type) */
static void (*PMD_func[])() = {
RotPMD_FT3, RotPMD_FT4, RotPMD_GT3, RotPMD_GT4,
RotPMD_F3, RotPMD_F4, RotPMD_G3, RotPMD_G4,
};

/* shared vertex type (8 type) */
static void (*PMD_SV_func[])() = {
RotPMD_SV_FT3, RotPMD_SV_FT4, RotPMD_SV_GT3, RotPMD_SV_GT4,
RotPMD_SV_F3, RotPMD_SV_F4, RotPMD_SV_G3, RotPMD_SV_G4,
};

/*
* draw PMD
: PMD ‚ð•`‰æ‚·‚é
*/
static void RotPMD(u_long *ot, int id)
{
int i,j;
long *pmdtop; /*PMD file PRIMITIVE Gp top address*/
long *pmdwc; /*PMD file word counter*/
long pointer; /*PMD file POINTER */
long *ptop; /*PMD file PRIMITIVE Gp Block top address*/
long pid; /*PMD file pid*/
long *primtop; /*PMD file PRIMITIVE Gp top address*/
long nobj; /*PMD file NOBJ*/
long nptr; /*PMD file NPTR*/
long type_npacket; /*PMD file PRIMITIVE Gp header*/
short type; /*PMD file PRIMITIVE Gp type*/
short ltype; /*PMD file PRIMITIVE Gp local type*/
long *svtop; /*PMD file Vertex top address*/
long backc; /*PMD file Back clip ON/OFF flag*/

pmdwc = pmdtop = (long *)PMD_ADDR;

pid = *pmdwc; pmdwc++;
ptop = pmdtop + ((*pmdwc)>>2); pmdwc++;
svtop = pmdtop + ((*pmdwc)>>2); pmdwc++;
nobj = *pmdwc; pmdwc++;

for(i = 0;i < nobj; i++) {
nptr = *pmdwc;
pmdwc++;
for(j = 0;j < nptr; j++){
pointer = *pmdwc;
primtop = pmdtop+(pointer>>2);
type_npacket = *(primtop);
type = type_npacket>>16;
ltype = type&0x000f;
backc = (type&0x0020)>>5;

/* independent vertex type */
if (ltype < 0x8)
(*PMD_func[type])(primtop,
ot, OTLENGTH, id, backc);
/* shared vertex type */
else if (ltype < 0x10)
(*PMD_SV_func[ltype&0x0f])(primtop, svtop,
ot, OTLENGTH, id, backc);
pmdwc++;
}
}
}

This are the official PSX PMD format that Resident Evil 2, 3 use. Resident Evil 1 dont use the packet PMD format only the simple TMD format.
If anyone want try to create a Windows tool to extract the models, view etc i can show more about the formats :)
UnpackerX
ultra-n00b
Posts: 5
Joined: Mon May 07, 2007 11:26 pm

Post by UnpackerX »

Here is a TMD normal model and one packed PMD (EMD model)
Anyone know where i can buy the Alias 8.0 or 9.0?
You do not have the required permissions to view the files attached to this post.
PmData
beginner
Posts: 33
Joined: Mon Oct 30, 2006 6:56 pm
Location: France
Been thanked: 2 times
Contact:

Post by PmData »

Thanks for the info,

Anyway I have nearly finished my viewer for game backgrounds. I think my next step is either a 3D model viewer, or the room description.
Goomba
n00b
Posts: 11
Joined: Sat May 19, 2007 10:48 pm

Post by Goomba »

Hey UnpackerX, the source code you showed can you make a 3D viewer and converter? Lowest system requirements PLEASE! Old computer me have! :( or just show the way to create my own tool. Thanks!

Or maybe PmData, You have made good progress with your work. Can you make a Resident Evil2/3 model viewer and converter. I would like the models to convert to .obj, .ma, 3d max. Or just .obj! :D

And also PmData, I have compiled the code you wrote on Rewiki, and it returns a 1 and it has errors? I do not understand how to use it? I just want to view and convert models.
Goomba
n00b
Posts: 11
Joined: Sat May 19, 2007 10:48 pm

Post by Goomba »

Has anyone tried 3D Ripper DX? Can it extract and convert re2 models? If so put a link to them, preferably Maya format. :wink: I hope I am not annoying people here
UnpackerX
ultra-n00b
Posts: 5
Joined: Mon May 07, 2007 11:26 pm

Post by UnpackerX »

Goomba writed: Has anyone tried 3D Ripper DX? Can it extract and convert re2 models? If so put a link to them, preferably Maya format. I hope I am not annoying people here
Well i can say that DX 3D Ripper DX supports only DirectX 9.0 applications. OpenGL, older versions of DirectX and software renderers are not supported. So, Resident Evil 2 and 3 dont use D3D9, its not possible.

Regards
PmData
beginner
Posts: 33
Joined: Mon Oct 30, 2006 6:56 pm
Location: France
Been thanked: 2 times
Contact:

Started writing a Python import plugin for Blender

Post by PmData »

Hello,

After hours of work, and learning Python from scratch, I managed to load an EMD model inside Blender.

However, like my previous model viewer, I don't know where links between body parts are stored. And I still have texturing to add to it.
You do not have the required permissions to view the files attached to this post.
Post Reply