Jump to content

Extracting simple 3D models (quick 'n dirty)


shak-otay

Recommended Posts

Btw, this is NOT a clone of my tutorial from Xentax. It just might serve as a starting point for beginners. (Not to be continued!)

This is just a very short introduction into analysing of binary 3D models (not a tutorial, and won't become).

Other than most analysing tutorials it doesn't introduce floats and such.

In above mentioned "Extracting simple models" tutorial I faced the problem that many too many beginners had extremely difficulties
to dive into 3D analysing of binary data using a hex editor.

So here I show what I think being a better approach:
understanding a basic 3D model (a cube) using a modelling program such as blender.

This should take an hour only (understanding blender will take months).

We start with a picture screenshot from here:
https://all3dp.com/2/3d-modeling-basics-simply-explained/

then I opened blender (see 2nd pic).

3D-Models.png

blender.png

Edited by shak-otay
  • Thanks 1
Link to comment
Share on other sites

First learn, what a coordinate (x,y,z) is.
Understand normals.

I scaled blender's start up cube to 2.5 in x-axis.
This is the exported cube_x2.5.obj (should be called cuboid now, maybe):

Spoiler

# Blender v2.82 (sub 7) OBJ File: ''
# www.blender.org
mtllib cube_x2.5.mtl
o Cube
v 2.500000 1.000000 -1.000000
v 2.500000 -1.000000 -1.000000
v 2.500000 1.000000 1.000000
v 2.500000 -1.000000 1.000000
v -2.500000 1.000000 -1.000000
v -2.500000 -1.000000 -1.000000
v -2.500000 1.000000 1.000000
v -2.500000 -1.000000 1.000000
vt 0.875000 0.500000
vt 0.625000 0.750000
vt 0.625000 0.500000
vt 0.375000 1.000000
vt 0.375000 0.750000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.375000 0.000000
vt 0.375000 0.500000
vt 0.125000 0.750000
vt 0.125000 0.500000
vt 0.625000 0.250000
vt 0.875000 0.750000
vt 0.625000 1.000000
vn 0.0000 1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
usemtl Material
s off
f 5/1/1 3/2/1 1/3/1
f 3/2/2 8/4/2 4/5/2
f 7/6/3 6/7/3 8/8/3
f 2/9/4 8/10/4 6/11/4
f 1/3/5 4/5/5 2/9/5
f 5/12/6 2/9/6 6/7/6
f 5/1/1 7/13/1 3/2/1
f 3/2/2 7/14/2 8/4/2
f 7/6/3 5/12/3 6/7/3
f 2/9/4 4/5/4 8/10/4
f 1/3/5 3/2/5 4/5/5
f 5/12/6 1/3/6 2/9/6

8 lines with vertices (points), 
14 lines with texture coordinates,
6 lines with normals
and
12 lines with faces (triangles here)

A face line
f 5/1/1 3/2/1 1/3/1
uses line numbers as indices
f v/vt/vn/ /v/vt/vn /v/vt/vn

Learn to understand how the vertices 5, 3 and 1
build this face (triangle).

Btw, faces might be built as quads using 4 vertices.

The order v, vt, vn might be v, vn, vt for other formats.
----------------------

I'd suggest to play around with the cube in blender.
Depending on your interests you might try to texture it.

There's a whole bunch of good texturing tutorials out there.
I suppose you'll find one that fits your needs.

Maybe you'll become a modeller then and forget the idea
of analysing binary model data...

Edited by shak-otay
Link to comment
Share on other sites

Well, not fond of being a modeller? Then let's dive into harder things.
If you need more detailed explanations you'll need to wait for others.
Maybe some former Xentax authors will re-upload their tutorials on reshax again.
----------------------
I've exported the cube/cuboid to some binary format, .3ds

Although we know the result already (cube_x2.5.obj) I'll try to get it
from the binary data now.
It's a very short introduction only when diving into the cube_x2.5.3ds.
For details refer to more detailed tutorials.

1) you need to know what "hexedecimal address" means.
2) a float value 1.0 is 00 00 80 3F as a hexadecimal value (byte order: little endian).
You may use this converter to gain more understanding:
https://www.h-schmidt.net/FloatConverter/IEEE754.html

I've marked vertex and the faceIndex block by rectangles.
Since a float has 4 bytes and a vertex 12 (components x,y,z) the vertex block
size is 96 bytes (8x12, from 0x71 to 0xD1).

For the face indices block it's a little bit more complicated since each face
is followed by 00 00 (special for 3ds format!). The size is 36 words + 12x2 zero bytes= 96 bytes
(from 0xD9 to 0x138).

 

cube_x2.5.3ds.png

Edited by shak-otay
Link to comment
Share on other sites

I used hex2obj ("MeshExtractor", see pic in previous post) to create a wavefront obj from that 3ds file then

(normals and texture coordinates ignored):

Spoiler

# 0x71: verts= 8
v 2.500000 1.000000 -1.000000
v 2.500000 -1.000000 -1.000000
v -2.500000 -1.000000 -1.000000
v -2.499999 1.000000 -1.000000
v 2.500001 0.999999 1.000000
v 2.499998 -1.000001 1.000000
v -2.500001 -1.000000 1.000000
v -2.500000 1.000000 1.000000
# 0xd1
g submesh_0
f 1 2 3 
f 1 3 4 
f 5 8 7 
f 5 7 6 
f 1 5 6 
f 1 6 2 
f 2 6 7 
f 2 7 3 
f 3 7 8 
f 3 8 4 
f 5 1 4 
f 5 4 8 

The faces' indices are different from the source (see top of 2nd post)
but you may have dozens if not hundreds of questions now.
Please google for them because I'm a little bit tired of making tutorials.
Sorry.

Result of extraction see appended picture.

 

Finally: there's about 5 or 6 good hex editors, such as Hxd or WinHex.

This one comes with source:
HexEdit by Andrew W Phillips
https://github.com/AndrewWPhillips/HexEdit

If you can't compile it you'll need to search for the exe.
(Latest version is 5.0, iirc.)

 

Btw, I forgot to mention 3D rippers (one of the reasons for Xentax going down, imho).

They allow you extracting 3D models and bypassing deeper learning and understanding.
 

Cuboid.png

Edited by shak-otay
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...