• Create Account

## How to multiply a .3DS local matrix with a Mesh

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

### #1Gl_Terminator  Members

451
Like
0Likes
Like

Posted 18 June 2013 - 01:53 PM

I have succesfully loaded a 3DS file into my C#, but I have a problem
I dont know how to interpret the Matrices that I am reading

Here is the code

case kMeshXFMatrix:
{
// Local transformation matrix
int i, j;
float[][] mat = new float[4][];
for (i = 0; i < 4; i++)
{
for (j = 0; j < 3; j++)
{
mat[i] = new float[4];
mat[i][j] = ctx.PopFloat();
}
}

lmat = new Matrix(mat[0][0], mat[0][1], mat[0][2], mat[0][3],
mat[1][0], mat[1][1], mat[1][2], mat[1][3],
mat[2][0], mat[2][1], mat[2][2], mat[2][3],
mat[3][0], mat[3][1], mat[3][2], mat[3][3]);
}

my question is how do I multiply this maxtrix with the mesh.

I translated this matrix into a 16 float array
and I place this code

GL.glPushMatrix();
Gl.glMulmAtrixf(mesh.matrix);
mesh.draw();
Gl.glPopMatrix();

### #2RobTheBloke  Members

2536
Like
0Likes
Like

Posted 20 June 2013 - 04:37 AM

mat and lmat, don't seem to affect mesh.matrix at all? Maybe store the values in mesh.matrix instead? By the way, this is insane:

mat[i] = new float[4];

Why not just do:

float mat[4][4];

It might also be a good idea to set mat[3][3] to 1.0f, and make sure that mat[0][3], mat[1][3], and mat[2][3], are all set to zero.

### #3Gl_Terminator  Members

451
Like
0Likes
Like

Posted 20 June 2013 - 02:53 PM

Hello
i change this
mat[i] = new float[4];
into this
float mat[4 ,4];
and I placed 0 0 0 1 to the matrix
now the objects appear
but they all messed up

### #4RobTheBloke  Members

2536
Like
0Likes
Like

Posted 21 June 2013 - 12:45 PM

but they all messed up

### #5Gl_Terminator  Members

451
Like
0Likes
Like

Posted 26 June 2013 - 10:27 AM

public static Matrix CreateTranslation(float x, float y, float z) { return new Matrix(new float[4, 4]); } public static Matrix CreateScale(float x, float y, float z) { return new Matrix(new float[4, 4]); } public static Matrix CreateFromAxisAngle(Vector3 v, float r) { return new Matrix(new float[4, 4]); } it seems that I need this functions coded. but I cant find them on the web

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.