2

I am reverse engineering a 3d file format for a game. I know the file is a mesh since I was able to identify the XYZ Coordinates for each vector as well as the MeshFaces. Each Vector XYZ Coordinate has 3 floats like so:

[this is pulled from an actual file]

41FC39C0 73480640 3AC87240 6038BF3E DF545D3F E620ACBE 00000000 0000403F

And this is the float representation of the hex:

-2.9060214 2.0981719 3.7934709 = X Y Z
0.37347698 0.86457628 -0.3361885 0.0 0.75 = Not sure what this this is.

I want to say the first 2 values could possibly be tU, tV values, but from what I know with DirectX, texture coordinates are usually between 0 and 1. Even though this file, the numbers fit between, I could bring up another file when those first 2 numbers are something like -.50 or even above 1 so I can't say they are text coordinates for sure.

The last 3 values I have no idea.

This 3d Mesh File is for a online game that uses a custom built DirectX 9 engine and from what I gather so far, is loosely based on Direct3D's .X file specifications.

I am able to pull out the XYZ coordinates into a list that can be imported into Cinema 4D and I have confirmed the XYZ is accurate based on the object that is drawn. In this case, a rock.

Here is floats for the first 3 data points within this file:

1. -2.9060214 2.0981719 3.7934709 0.37347698 0.86457628 -0.3361885 0.0 0.75
2. -2.7679636 2.0897043 2.6395969 0.16878456 0.98563963 5.1173517e-003 0.0 0.5
3. -2.7679636 6.2550635 2.7174740 0.20584901 -0.96193141 -0.17976092 1.0 0.5

From my experience with reverse engineering 3D date, if a floating point number is exponential, it most likely is being read wrong, so the '5.1173517e-003' on the 2nd line towards the end may not even be a floating point number, but then its other possible values:

INT8    117
UINT8   117
INT16   -20619
UINT16  44917
INT32   1000845173
UINT32  1000845172
HALF FLOAT -0.11651611

don't make much sense either.

2
  • This is a wild guess. But as the first 3 floats seem to be vertices in 3D space, the second 3 could be delta values to the first 3 that denote material thickness. What happens if you add values 4, 5 and 6 to 1, 2 and 3, and import the result? What if you import both files and use different colors, does the 2nd mesh envelope the 1st one nicely? The last two might have something to do with alpha values/reflection/whatever. I wouldn't think too much about the 5.1e-3, i'd guess that's just a zero with rounding errors. Commented May 23, 2014 at 16:38
  • I imported both files and this is the result: bayimg.com/aaoijAAFf The orange object is the 4th, 5th and 6th values being imported and when looked from the top, has roughly the same outline, but is stretched in Y axis. Commented May 23, 2014 at 20:11

1 Answer 1

4

I think the second vector of three floats is the normal vector. Which is basically the front facing direction of the vertex. It looks like the length is 1 so it's normalized which would correspond well with what you'd expect of a normal vector. The last two I believe are UV mapping coordinates for texturing but it's hard to be positive without full data files.

3
  • Normal vector sounds good, at least with the data the OP provided, because sqrt(sum(n^2)) is 1 in all cases. But, how do you define the normal vector of a vertex, as opposed to a plane or surface? Commented May 23, 2014 at 19:44
  • I was under the impression that each polygon face is facing front or back based on which direction its drawn. In Cinema4D if you create a triangle and going clockwise around the points, it faces front. If counter clockwise it faces back. Commented May 23, 2014 at 20:21
  • @clrx Imagine a sphere. It can't be perfectly represented by a triangle model so the it needs to be approximated. A vertex on this sphere is shared among many triangles. You want the interpolation of light over the surface to be smooth and not have sharp edges, or bands. Compare flat shading to Gouraud and Phong shading. This is why you also need a normal for a point. The normal is the perfect representation of the slope of the surface. In order to do back and front face culling the order of the vertices of the polygon is usually used in order to define a normal for the polygon. Commented May 23, 2014 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.