matrix math and 3ds files

matrix math and 3ds files

Post by DeadHamste » Tue, 10 Dec 2002 11:28:12



I have written a 3ds file reader for use in my game.  I have run into a bit
of an issue it seems.  The 3ds file does not store world corrdinates for
each mesh, instead it stores a 4x3 matrix for each mesh, and the vertices
are based on that.  I would like to know how to apply this matrix to each
vertex in code, so that I can store the world coordinates instead of the
modified ones.  Does anyone have experience with this?

-DH

 
 
 

matrix math and 3ds files

Post by PC Joh » Tue, 10 Dec 2002 23:37:38


AFAIK, 3ds vertex coordinates are already in global coordinates.
Transformation chunks are there for internal 3d studio modeling purposes.
I have never used them.
BTW: Best documentation I have ever seen is at
www.*loonies.com/3dsftk.html .
John

> I have written a 3ds file reader for use in my game.  I have run into a bit
> of an issue it seems.  The 3ds file does not store world corrdinates for
> each mesh, instead it stores a 4x3 matrix for each mesh, and the vertices
> are based on that.  I would like to know how to apply this matrix to each
> vertex in code, so that I can store the world coordinates instead of the
> modified ones.  Does anyone have experience with this?

> -DH


 
 
 

matrix math and 3ds files

Post by Jukka Liimatt » Wed, 11 Dec 2002 03:31:45


Quote:> I have written a 3ds file reader for use in my game.  I have run into a
bit
> of an issue it seems.  The 3ds file does not store world corrdinates for
> each mesh, instead it stores a 4x3 matrix for each mesh, and the vertices
> are based on that.  I would like to know how to apply this matrix to each
> vertex in code, so that I can store the world coordinates instead of the
> modified ones.  Does anyone have experience with this?

Actually the vertices are defined in world coordinates, and the matrix tells
what the matrix was. If you want to define the vertices in model
coordinates, you have to multiply'em by inverse of the 4x3 matrix. You need
to do this if you want to begin to apply the animation/keyframing tracks,
those are defined in local (=model) coordinates relative to each node's
parent.

Last but not least, there is offset (=pivot) transformation which is applied
before drawing the node, but is not inherited.

So ; if you don't care about hierarchy or animation, you can simply draw in
world coordinates.

 
 
 

matrix math and 3ds files

Post by DeadHamste » Wed, 11 Dec 2002 06:16:04


Ok, thanks for the info. Would you have any idea then why when I draw the
model, the meshes are in the wrong places? I have a 3ds file with 3 meshes
and 3 materials, and when it is drawn in my program, the meshes are all on
top of each other.  I assumed it was that matrix I wasnt using. is there
anything that defines the location of the mesh that I missed?

-DH


Quote:> > I have written a 3ds file reader for use in my game.  I have run into a
> bit
> > of an issue it seems.  The 3ds file does not store world corrdinates for
> > each mesh, instead it stores a 4x3 matrix for each mesh, and the
vertices
> > are based on that.  I would like to know how to apply this matrix to
each
> > vertex in code, so that I can store the world coordinates instead of the
> > modified ones.  Does anyone have experience with this?

> Actually the vertices are defined in world coordinates, and the matrix
tells
> what the matrix was. If you want to define the vertices in model
> coordinates, you have to multiply'em by inverse of the 4x3 matrix. You
need
> to do this if you want to begin to apply the animation/keyframing tracks,
> those are defined in local (=model) coordinates relative to each node's
> parent.

> Last but not least, there is offset (=pivot) transformation which is
applied
> before drawing the node, but is not inherited.

> So ; if you don't care about hierarchy or animation, you can simply draw
in
> world coordinates.

 
 
 

matrix math and 3ds files

Post by Jukka Liimatt » Wed, 11 Dec 2002 06:50:07


Quote:> Ok, thanks for the info. Would you have any idea then why when I draw the
> model, the meshes are in the wrong places? I have a 3ds file with 3 meshes
> and 3 materials, and when it is drawn in my program, the meshes are all on
> top of each other.  I assumed it was that matrix I wasnt using. is there
> anything that defines the location of the mesh that I missed?

Seems you bring the meshes into local coordinates when you are reading them,
do you use pre-written code or your own?

j.

 
 
 

matrix math and 3ds files

Post by DeadHamste » Wed, 11 Dec 2002 07:23:07


I am using my own code, though it is based mostly on digiben's tut on
gametutorials.com  I made a few changes to read in bump maps and material
properties among other things.

-DH


Quote:> > Ok, thanks for the info. Would you have any idea then why when I draw
the
> > model, the meshes are in the wrong places? I have a 3ds file with 3
meshes
> > and 3 materials, and when it is drawn in my program, the meshes are all
on
> > top of each other.  I assumed it was that matrix I wasnt using. is there
> > anything that defines the location of the mesh that I missed?

> Seems you bring the meshes into local coordinates when you are reading
them,
> do you use pre-written code or your own?

> j.

 
 
 

1. matrix math (translating and rotating)

I am having some trouble utilizing 3ds files because the meshes each have
their own origin. I have been reading in the mesh matrices, but I am not
sure how to utilize them.  its a 4x3 matrix (missing the bottom row for
opengl).

first, what is the difference between these two, since they seem to have
very different effects:

glTranslatef(5,5,5);

or....

m=   [1,0,0,5]
        [0,1,0,5]
        [0,0,1,5]
        [0,0,0,1]
glMultMatrix(m);

My problem is simple. If I read in the mesh matrix from the 3ds file, and
there are no scales or rotations in it, then I can use glTranslate() to
move, and all is well. but if I use glMultMatrix() my meshes end up in the
wrong place.  my mesh matrix is a float[16] and when I translate I use
values 3,7,11 from the mesh matrix to translate.  I just do not understand
how to utilize this mesh matrix to get my stuff in the right location.

2. best Open-GL card for LW?

3. Fast matrix math ?

4. 3dmax

5. Matrix math and projections (from 3D to 2D)

6. Shadows w/out light

7. question for matrix math experts...

8. Posting binaries

9. I need HELP with Matrix Math.

10. Need help with matrix math on vectors...

11. need macros for matrix math in Excel

12. Matrix math and rotations