PDA

View Full Version : Hex Editing and S3D


Madox58
01-10-11, 08:23 PM
Before anyone gets all upset with me, this is NOT a bash of S3D!
It's about how they can be used, hand-in-hand, to reach a goal.

I started a new 3D model for the Large Lifeboat.
The one in Game is rather, lacking, shall we say?
:hmmm:

I noticed the oars the rowers have were color screwed!
I want this corrected now!
So I export with S3D and change UV's for the oars.
Then import with S3D.

Now S3D does some animations but not SH4 animations.
So I get a Blob rowing the Lifeboat.
BUT! The oars are not whacked!
So I started digging by looking at the exported obj files in Notepad.
I saw that there were several breakdowns of the faces.
Which means that several textures were used for some reason, but not included in the dat.
Or not assigned in the dat.
I need to fix that issue in the lest intrusive way I can come up with.
Here is where Hex work and S3D work together!

More to follow if anyone is interested.
:03:

Madox58
01-14-11, 06:16 PM
Well, as We can't re-import to the Secondary.dat without wrecking the animations, I used a hex editor on the dat itself.

The structure of the files in SH3 and SH4 is pretty well documented and many of the older Modders that worked in hex in 'the old days' gave what knowledge they had to assist Skwasjer with S3D.

So, if you open the STOCK Secondary.dat in SH4 and export the
AM_SOL_MRNP_01 3d Model and then open one of the obj files with note pad you can see the problem.

Scroll down to the faces,
(they look like this)
f 17/1 35/4 38/3
f 38/3 12/2 17/1
f 151/219 150/218 3/5
f 3/5 28/8 151/219
f 278/9 147/12 106/11
and on and on............

You'll see they are broken up but call the same texture in the usemtl statements.
That's what I fixed by hexing the file.
Export the same 3d model from the adjusted Secondary.dat file and open it with Notepad and compare the difference.
You'll see two textures and 2 faces sections.
The second group of faces is the oar.

1st, I added the needed texture stuff with S3D.
(You'll see that in the dat I modified as calling wood.dds, which is a stock dds file in the tex folders.)

Next I wrote down the ID for the AM_SOL_MRNP_01 3D model.
In S3D, you see it as this:
0xe7c2a0129fed0bc7
In a Hex editor it's reversed:
c70bed9f12a0c2e7

I'm done with S3D at this point as it can't help us any further.
It's not designed to adjust every little thing and that's fine.
No one Tool for ANY job does everything!

Next post will be the hex editing part after I get some files uploaded you may want to assist following along.

Madox58
01-15-11, 02:46 PM
The files I wanted to upload?
I can not find.
So I'll explain as I go.
I use xvi32 hex editor.

Here's the break down of the area we are interested in.
With the Hex editor you use, search for the ID posted above.
That will take you to the 3D object it the dat itself and you will see this line:
c7 0b ed 9f 12 a0 c2 e7 00 60 01 00 00
we are interested in the 60 01 00 00, it equal the Verts of the object.
60 01 00 00 = 366, We need to jump down in Hex after we convert our jump length.
The jump length is 366 x 3 x 4 + 1 = 4393
Why that must be done is simple.
A Vert is 3 readings for the X Y Z placement and the dat uses 4 bytes for each axis. So a Vert is 12 bytes long, plus we need 1 to hit the faces count.
Start from the last 00 in the 60 01 00 00

This will place you at the Faces section of the model.
This is where I made the adjustments that changed the oar colors.
You should be at B8 02 00 00 which = 696 which is our faces count.
We need to jump down once again.
The math for that is 696 x 13 = 9048
Why 13?
Each Face takes 12 bytes PLUS a texture assignment.
It's the texture assignment we need to change.
Why must we change this?
Texture assignment works like this.
00 is the base texture.
01 is the next texture,
02 the next and on and on.
BUT if only one texture is assigned in the dat?
It gets goofy as the numbers roll over.
01 = 00
02 = 00
And such as we don't have enuff textures assigned.
Adding textures to the dat only partly fixes things.
We want a complete solution.