It is currently Sun Nov 18, 2018 10:37 pm

 All times are UTC + 1 hour

 Page 1 of 2 [ 26 posts ] Go to page 1, 2  Next
 Print view Previous topic | Next topic
Author Message
 Post subject: Very Basic model format conversion (Shaiya).Posted: Sun Sep 27, 2009 1:45 am
 Moderator

Joined: Sun May 18, 2008 3:01 pm
Posts: 2501
Has thanked: 57 times
Have thanks: 1246 times

```

```

You can make the ads go away by registering

In this tutorial you will learn the VERY basic way to convert a 3d model into verts that can be loaded into a 3d application.
I hope to expand on these tutorials and use better tools to automate the job and code it completely proper.
for this tutorial you will need a few tools

2. HxD (free hex editor)
3 excel (2007)
4 Deep exploration (program able to view an obj with just verts

1) Ok so open the model folder after you extract them and open the file demf_boots001.3DC
in the program HxD

2)Now if we know the model format lets see how to break it down
Quote:
#Provided from Fatduck
dword constant00
dword numBones
struct Bone {
float_16 Matrix4X4
}
dword numVerts
struct Vert {
float_3 CoordXYZ
float Weight
byte BoneID01
byte BoneID02
byte NULL1
byte NULL2
float_3 NormalXYZ
float_2 TexCoordUV
}
dword numFaces
struct Face {
word_3 FaceIndices123
}

3) a dword is 4 bytes
a 32 bit float (these are 32 bit floats) is equal to 4 bytes
float_X is the number of floats in a row so float_2 would be 8 bytes
and a byte is 1 byte
a word is 2 bytes

4) So knowing this lets look at the first line
dword constant00
this tells us our first 4 bytes are 00 and if we check this they are

5) The next line is
dword numBones
so the Number of bones is in the next 4 bytes
which shows us 2C 00 00 00 so that converts into 00 00 00 2C
and 2C in decimal is 44
so now we know we have 44 bones

6) The next part is
struct Bone {
float_16 Matrix4X4
}
so this means we have a float which is 4 bytes then the underscore 16 means each bone has 16 floats
so in decimal we do 4 x 16 = 64 then we convert this number to hex which is 0x40
we multiply 0x40 bye the number of bones 2C and we get B00
If you highlight this section you should get a screen looking just like mine
7) The next line is
dword numVerts
this means the next 4 bytes tell us how many verts we will have in our model
so we take AE 01 00 00 and convert it to 00 00 01 AE and that equals 430
so there are 430 vertexes.

8 The next line is the most important for the tutorial
float_3 CoordXYZ
this means we have a float which is 4 bytes and we have 3 in a row representing x , y z coordinates.
so our first set of cordiantes should look like this
X)FE F8 A1 BE
Y)00 00 C8 36
Z)4A CA BF BD

9) The next line
float Weight
means the next 4 bytes are the weighting information
00 00 80 3F

10) the next 4 lines tell us what bones our weighting information has influence on
byte BoneID01
byte BoneID02
byte NULL1
byte NULL2
22 00 00 00
break these apart byte by byte so this vertex is effected bye bone 22 and 00
you can ignore the NULL parts

11)This next line tells us our normal coordinates
float_3 NormalXYZ
it is a float value so its 4 bytes and it is in a series of 3 so its 12 bytes total
X)08 7D 7D BF
Y)E2 5A 0D 3E
Z)AC 99 B1 BC

12) The last line of the vertex definition tells us our UV coordinates.
float_2 TexCoordUV
U)BB DA 08 3F
V)F2 60 7A 3F
so it is again a float of 4 bytes and there are 2 in a row so it is 8 bytes total

13) The next line tells us how many faces we have
dword numFaces
so it is a dword of 4 bytes
98 01 00 00 so convert it to 00 00 01 98 and in decimal that is 408
so we have 408 Faces

14)The next 2 lines tell us the face structure
struct Face {
word_3 FaceIndices123
}
so we have a word 2 bytes and 3 in a row so thats 6 bytes
so 408 / 3 = 158

15) Now to the converting the vertex part
highlight the whole vertex section and copy it into a new hxd file called vertex.dat
start offset B0C
end offset 4E3B
length 4330

16)now we use float2txt on our dat file
float2txt.exe vertex.dat vertex.txt 10
we take the arguments float2txt.exe input file output file number of floats
we choose 10 because there are 10 groups of 4 bytes that make up our vertex structure.

17)now we open excel and it will ask is this a delimited file choose tab and space check boxes and hit import.
you will end up with columns a - j

18)delete columns d - j so you are only left with
a b and c
inert a column before a and fill it with the letter v until you reach the end of your vertex list
(line 430)

19) save the file as a csv file
open the file in hxd
do a replace and replace in hex 2C with 20
and save the file as testobj.txt

Code:
# 3ds Max Wavefront OBJ Exporter v0.94b - (c)2007 guruware
# File Created: 26.09.2009 19:47:31

mtllib test.mtl

#
# object NET
#

and at the end of your file put
Code:
# 430 vertices

ok now save your file as test.obj

21)Open your file in deep exploration and see the boots

Attachments:

You do not have the required permissions to view the files attached to this post. Register to gain access.

Last edited by chrrox on Thu Oct 01, 2009 1:03 am, edited 4 times in total.

Top

 Post subject: Re: Very Basic model format conversion (Shaiya).Posted: Sun Sep 27, 2009 1:47 am
 n00b

Joined: Sun Sep 27, 2009 12:54 am
Posts: 16
Has thanked: 5 times
Have thanks: 0 time
Hope to see this completed.

Now, converting models into a usable file is one thing, but how about converting them back to their original file?

Then we'd be good.

Unless there's a tutorial on this and I can't see it.

Top

 Post subject: Re: Very Basic model format conversion (Shaiya).Posted: Sun Sep 27, 2009 2:20 am
 Moderator

Joined: Sun May 18, 2008 3:01 pm
Posts: 2501
Has thanked: 57 times
Have thanks: 1246 times
I will attempt to make more tutorials this one is done for now.
and I will try to teach people how to do this in max script
or a simple model viewer code.

Top

 Post subject: Re: Very Basic model format conversion (Shaiya).Posted: Mon Sep 28, 2009 3:38 pm
 ultra-veteran

Joined: Mon Aug 11, 2008 11:30 pm
Posts: 423
Has thanked: 26 times
Have thanks: 15 times
This is really great info. Probably easy to use because you showed all commands from fatduck but maybe hard to do by your own from scratch But still, impressive

Top

 Post subject: Re: Very Basic model format conversion (Shaiya).Posted: Fri Oct 02, 2009 2:55 am
 Moderator

Joined: Sun May 18, 2008 3:01 pm
Posts: 2501
Has thanked: 57 times
Have thanks: 1246 times
I will write a max script import tutorial soon for shaiya so you can see how it is done.

Top

 Post subject: Re: Very Basic model format conversion (Shaiya).Posted: Wed Oct 14, 2009 10:43 pm
 ultra-n00b

Joined: Wed Oct 14, 2009 9:57 pm
Posts: 1
Has thanked: 1 time
Have thanks: 0 time
Thanks you for this tutorial.

chrrox wrote:
14)The next 2 lines tell us the face structure
struct Face {
word_3 FaceIndices123
}
so we have a word 2 bytes and 3 in a row so thats 6 bytes
so 408 / 3 = 158

looks like this should be: we have 408 faces, which have 408 * 3 = 1224 vertex index numbers in total of a length of 2 bytes each.

Looking forward for your next tutorial about importing it to max, since I had some issues with the converter:
- I had to trow away the first vertex (v), vertex uv's (vt) and vertex normal (vn) in order to get the mesh loaded visually correct.
- I needed to flip the uv verticaly too

Thank you again (and Fatduck of curse)

Just for fun I made a command line tool to automate this.
Here are some some results:

Top

 Post subject: Re: Very Basic model format conversion (Shaiya).Posted: Sun Oct 18, 2009 5:29 am
 beginner

Joined: Mon Sep 28, 2009 7:52 pm
Posts: 21
Location: Amber
Has thanked: 11 times
Have thanks: 5 times
Thanks for tutorial.
As i understand, this method can be used for exploring file format. Right?
I can check if some portion of data represents vertexes, but how about triangles, bones and normals? Then we'd be good.

Also.
Quote:
19) save the file as a csv file
open the file in hxd
do a replace and replace in hex 2C with 20

There is a better way to do this. Just choose space delimeter instead of comma when you save file as csv.

P.S. Moar tutorials like this please

_________________
All your packages is belong to us!

Top

 Post subject: Re: Very Basic model format conversion (Shaiya).Posted: Tue Oct 20, 2009 5:01 pm
 mega-veteran

Joined: Sun Jan 18, 2009 1:45 pm
Posts: 217
Location: Sagittarius
Has thanked: 225 times
Have thanks: 12 times
DEAR chrrox please insert the images in full size , because for saving the tutorials , for offline reading !

_________________
ILLUSORY VIDEO GAMES ARE MORE IMPORTANT THAN PRECIOUS INTERNATIONAL FOOTBALLs

Top

 Post subject: Re: Very Basic model format conversion (Shaiya).Posted: Fri Oct 30, 2009 4:14 am
 beginner

Joined: Sun Mar 01, 2009 7:11 am
Posts: 24
Has thanked: 3 times
Have thanks: 0 time
Any word on a maxscript for this?

Top

 Post subject: Re: Very Basic model format conversion (Shaiya).Posted: Sun Dec 06, 2009 3:34 am
 Moderator

Joined: Sun May 18, 2008 3:01 pm
Posts: 2501
Has thanked: 57 times
Have thanks: 1246 times
Here is a max script that will work on these files

Code:

fname = "C:\\temp\\test.3dc"  --file name
f = fopen fname "rb"   --open file in read only format
Vert_array = #()    --define arrays for verts, normals, UV and Faces
Normal_array = #()
UV_array = #()
Face_array = #()
Weight_array = #()
Bone_array = #()
fseek f 4 #seek_cur

for i = 1 to bray do (   --* number of Bones
)
for i = 1 to vray do (
append Vert_array [vx,vy,vz] --save verts to Vert_array
--append Weight_array [w1,bo1,bo2,bo3,bo4]
append Normal_array [nx,ny,nz] --save normals to Normal_array
tv = (readfloat f) * -1
append UV_array [tu,tv,0]  --save UVs to UV_array
)
for i = 1 to nray do (
f1 = (readshort f) + 1   --read face indices, games are start form 0, but Max start from 1
f2 = (readshort f) + 1   --so we add 1 to each index
f3 = (readshort f) + 1
append Face_array [f1,f2,f3] --save faces to Face_array
)
fclose f     --close file
msh = mesh vertices:Vert_array faces:Face_array   --build mesh
msh.numTVerts = UV_array.count
buildTVFaces msh
for j = 1 to UV_array.count     do setTVert  msh j UV_array[j]
for j = 1 to Face_array.count   do setTVFace msh j Face_array[j]
for j = 1 to Normal_array.count do setNormal msh j Normal_array[j]

Top

 Post subject: Re: Very Basic model format conversion (Shaiya).Posted: Sun Dec 06, 2009 10:01 am
 mega-veteran

Joined: Sun Jan 18, 2009 1:45 pm
Posts: 217
Location: Sagittarius
Has thanked: 225 times
Have thanks: 12 times
is there any script or MEL for maya that works in similar way ?
thanks

_________________
ILLUSORY VIDEO GAMES ARE MORE IMPORTANT THAN PRECIOUS INTERNATIONAL FOOTBALLs

Top

 Post subject: Re: Very Basic model format conversion (Shaiya).Posted: Sat Mar 20, 2010 2:02 pm
 beginner

Joined: Thu Dec 17, 2009 9:59 am
Posts: 30
Has thanked: 0 time
Have thanks: 0 time
Wow thanks a lot of this!

What I would also love is a nice tutorial on writing an import maxscript for 3d models

Top

 Post subject: Re: Very Basic model format conversion (Shaiya).Posted: Mon Aug 02, 2010 11:36 pm
 mega-veteran

Joined: Mon Apr 26, 2010 6:51 am
Posts: 288
Has thanked: 81 times
Have thanks: 12 times
This can also apply to any 3D format once you know its structure, right?

Top

 Post subject: Re: Very Basic model format conversion (Shaiya).Posted: Thu Feb 24, 2011 9:43 pm
 veteran

Joined: Sun Jan 23, 2011 5:31 am
Posts: 97
Has thanked: 2 times
Have thanks: 2 times
Thanks so much for the tutorial! You are awesome! I still suck at most of this, but having things spelled out with lots of pictures helps a whole lot.

Top

 Post subject: Re: Very Basic model format conversion (Shaiya).Posted: Thu Jul 21, 2011 7:09 am
 ultra-n00b

Joined: Thu Jul 21, 2011 6:37 am
Posts: 1
Has thanked: 0 time
Have thanks: 0 time
i dont understand how you know 2C meens 44 bones, i have 3C an i dont see anywhere a number or i dont know

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 2 [ 26 posts ] Go to page 1, 2  Next

 All times are UTC + 1 hour

#### Who is online

Users browsing this forum: DarthAhsoka and 0 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ General Discussion    Holy Cow!    Game news    Game Tech Tips    Cool mods    Website Game Modding    Tutorials    3D/2D models    Audio file formats    Graphic file formats    Video file formats    Game Archive    Compressed files and methods    Code Talk    Game Localization    Savegames    Old posts    Retro games MultiEx Commander Tools & Programs    Game specific tools    General game tools