Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

3 Dimensional Chat / Normals in .X files

Author
Message
JeroenNL
21
Years of Service
User Offline
Joined: 4th Sep 2003
Location:
Posted: 1st Dec 2003 11:09
I've almost finished my .X exporter tool in DeleD (removed a few nasty bugs) but I wonder about the normals stored in an .X file. Can anybody tell me how they work? Seems that an .X file stores a vector per vertice and then uses index values to get to a face-normal. Is that correct? And if so, how is the vertice-vector calculated?

Use DeleD to get skilled in 3d editing! Visit http://www.gamefortress.com/delgine for more info.
las6
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Finland
Posted: 1st Dec 2003 13:15
Quote: "MeshNormals {
8; // define 8 normals
0.333333;0.666667;-0.666667;,
-0.816497;0.408248;-0.408248;,
-0.333333;0.666667;0.666667;,
0.816497;0.408248;0.408248;,
0.666667;-0.666667;-0.333333;,
-0.408248;-0.408248;-0.816497;,
-0.666667;-0.666667;0.333333;,
0.408248;-0.408248;0.816497;;
12; // For the 12 faces,
3;0,1,2;, // define the normals
3;0,2,3;,
3;0,4,5;,
3;0,5,1;,
3;1,5,6;,
3;1,6,2;,
3;2,6,7;,
3;2,7,3;,
3;3,7,4;,
3;3,4,0;,
3;4,7,6;,
3;4,6,5;;
}
"


that's an example I ripped off from a site explaining the .x file format. So .x file format uses per-face/polygon format. kinda.

So basically you save all the different Normals you need, then go through all the faces and apply the appropriate normals.

It's pretty confusing at first. Because you can have as many normals as you want (let's you do smoothing groups, sort of) but you'll need to sort them out. Probably the easiest way for exporter is to save a normal for each vertex and not worry about making duplicates. then just write out the numbers of the vertices in a face, and you get the normals right too.

it is a bit trickier to calculate the vectors. Well, not exactly, as long as you know which way a face is looking. Basically those three values are just x/y/z values between 0 and 1.0. Simple as that. but you decide how you want to play them out. If you know the "direction", just point the object and get the x/y/z distances.

Keyboard not detected. Press F1 to continue.
JeroenNL
21
Years of Service
User Offline
Joined: 4th Sep 2003
Location:
Posted: 1st Dec 2003 15:53
The thing is that I have a routine to calculate a face-normal perfectly. I could just store that normal right away but it seems that .X files store the normals in another way, using vertex normals. That's what's confusing to me right now.

In the above example, it really seems that they're calculating a normal for each vertice, don't they? And then they describe the face normal by using 3 different vertice normals...

That's pretty weird, if you ask me. I would calculate all face normals seperately and then calculate vertice normals by taking the average of all the normals of all polygons that use that vertice (thus resulting in an averaged normal).

Use DeleD to get skilled in 3d editing! Visit http://www.gamefortress.com/delgine for more info.
Dr OcCuLt
22
Years of Service
User Offline
Joined: 27th Nov 2002
Location: a Dark Deep Dark pit, it dark in here
Posted: 1st Dec 2003 17:03
you do not have to ues 3 different normals, unless your uesing different normals to make the odject look smooth

this is a unsmoothed polygon (all the normals for the ploygon go the same way)


this is a very smoothed polygon (not all the normels go the same way so there a different in light fall over the ploygon makeing it look smoother then it is)


i think the normals has to have the same form as the vertice
position ever vertice has a normel at it same position and the faces linking has to be the same.

--Dr 0--
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 1st Dec 2003 17:16 Edited at: 1st Dec 2003 17:19
Here's a little idea for calculating normals.

Get the vertice location, and step through each vertice that is attached to the first vertice - until you have the average location.

For each vert that is related to your first vert, add the location to a total for each axis, until there are no more connected verts, then divide by the number of connected verts. This should give a location that can be checked with the original vert location to make the vector - if you imagine a pyramid, and you want to calculate the tip's normal vector, you'd find that the connected verts average out at the base, in the centre - meaning the vector goes between the base and the tip of the pyramid. I reckon that'd be a good method to look into.
From what I've learned from formats, I'd say that it's more likely that each vertice has it's own normalisation data, in the case of DBPro, each vert has a colour, a normal X,Y,Z, and a UV X and Y. I reckon you should watch for duplicate vertices, which might not be anything to do with normals, maybe UV data though.


Van-B


I laugh in the face of fate!
deX
21
Years of Service
User Offline
Joined: 12th Nov 2003
Location:
Posted: 2nd Dec 2003 09:26
im not sure if this will help, but i just downloaded an .x exporter for 3dsmax... it has 2 radio buttons for normals: vertex normals, and face normals. it seems that when vertex normals is selected, the object looks nice and smooth.. and if face normals is selected u can see all the individual polys quite clearly. so im guessing the .x format supports both methods.


-deX
las6
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Finland
Posted: 2nd Dec 2003 10:03
I think that just shows that .x file format doesn't support face normals. Well, not directly.

Basically it uses vertex normals, but you'll still have to set 3 vertex normals per face. Thing is, if you have multiple similar faces, you can reuse the vertex normals. I'm sure you'll get a hold of it if you just keep thinking about it.

One odd way to calculate the normals (per vertex) in a ubersmooth way would be to use the direction vector from the center of mass to the vertex. Or simply from 0,0,0 to the vertex position. (that requires that your model is fully symmetric And positioned correctly. not that useful. But then again, you could try this and Average the results using the method Van-B posted... Now that could look interesting.

Keyboard not detected. Press F1 to continue.

Login to post a reply

Server time is: 2025-06-27 16:06:35
Your offset time is: 2025-06-27 16:06:35