ASE normals loading problem

hi,

I created a ASE file loader with doc found on www.wotsit.org one month ago. It works fine but normal aren’t right, it loads the right value that 3DS Max gives but it doesn’t work. I switch the y and z value as written in the doc and invert the z then.
I tried many files from 3DS MAX 3.0 and 2.0 but I’ve got the same result.
Any iD? anyone did a loader which works? any URL?

Cheers

Arath

That took me a while to figure this out !

You know, for each object, you have a Transformation Matrix like this:

	*TM_ROW0 1.0000	0.0000	0.0000
	*TM_ROW1 0.0000	1.0000	0.0000
	*TM_ROW2 0.0000	0.0000	1.0000
	*TM_ROW3 0.0000	0.0000	0.0000

You need to multiply the normals of the file by the transpose of this matrix !

And then everything is fine…

Regards.

Eric

Thanks Eric but it doesn’t work definitely.

I load the matrix, let’s take your example :

/* for TM_ROW0 */
transform[0][0] = 1.0f; transform[1][0] = 0.0f; transform[2][0] = 0.0f;

and so on for the rest of the row then I multiply each vertex and normal like this :

vertices[faces[index].vertices[i]].normal[X] = transform[0][0] * fx + transform[0][1] * fy + transform[0][2] * fz + transform[0][3];

when fx, fy and fz are value read from file for a normal.

Am I doing the right multiplication? or am I wrong?

That’s how I do it:

The transform matrix is a GLdouble[16];

When you parse the ASE file, fill the Matrix array like that:

TM_ROW0:

Matrix[0],Matrix[1],Matrix[2];

TM_ROW1:

Matrix[4],Matrix[5],Matrix[6];

TM_ROW2:

Matrix[8],Matrix[9],Matrix[10];

TM_ROW3:

Matrix[12],Matrix[13],Matrix[14];

Then:

Matrix[3]=0;
Matrix[7]=0;
Matrix[11]=0;
Matrix[15]=1;

Then, you have an “OpenGL” matrix (these are the indices of your Matrix array):

[ 0 4 8 12 ]
[ 1 5 9 13 ]
[ 2 6 10 14 ]
[ 3 7 11 15 ]

That’s why I meant ‘transpose’ (what they call “ROW” in ASE file is a Column for us !).

Now, for each normal that is in the ASE file (u,v,w), you obtain the proper normal (ru,rv,rw) like this:

ru=Matrix[0]*u+Matrix[4]*v+Matrix[8]w;
rv=Matrix[1]*u+Matrix[5]*v+Matrix[9]*w;
rw=Matrix[2]*u+Matrix[6]*v+Matrix[10]*w;

Now, to display your object, simply start with a glTranslated that will bring your object in the correct position:

glTranslated(Matrix[12],Matrix[13],Matrix[14]);

Then send your vertices like they are in the ASE file (THEY ARE ALREADY TRANSFORMED BY THE GIVEN MATRIX !) and send the normals as we just calculated them.

It definitely works !!!

Regards.

Eric

thx Eric,

now it’s working but I’ve got to rotate the mesh around the Y axis (90 °)
the main goal is reached, I can import ASE file.

Thanks a lot for spending time with this little problem.

You said you switched Y and Z components and inverted the Z when loading the normal. This has to be done with all vertices you load aswell, because the whole coordinate system in MAX is like this, Z is up instead of “into the screen” as in OpenGL. This is why you need to rotate the model to get it right.

Yes, I forgot that: in my programs, Z is always going up… Don’t ask me why, I just think it feels better (hey, altitude is always expressed on the Z axis !).

I am glad you have your import working !

Regards.

Eric

Can you tell me where did you find ase format description? I tried to find it on wotsit.org but it isn’t there.

barce,

I basically saved a few easy models (a cube, a sphere, a group containing both, …) with 3DS max into ASE format… Then I opened the files with Ultra-Edit32 and I understood the format pretty easily…

I know most of people here have done exactly the same !!!

Regards.

Eric

Yeah, I agree with you Eric, that’s what I did too. Just open the file and have a look. No description needed.

Hello Eric,

What is Ultra-Edit32? is it a software ? where can I download it ?

Thank you for the moment

Best regards

Kurt

Just use any standard text editor. ASE files are just text, that’s what makes them so nice.

Ryan

HurtCob,

Ultra-Edit32 is a text-editor available at www.ultraedit.com. It features a 30-day trial only… Then either you buy it, either you reinstall it… That’s boring but I used it for editing ASE files with a 30-day trial period… I am thinking about buying it now !

Regards.

Eric

Ok Ok,
Sorry I thought that it is a special editor, sorry for the stupid question.

Thank you guys.

Kurt