Followers 0

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

## 4 posts in this topic

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(); please I need some advice
0

##### Share on other sites

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.

0

##### Share on other sites
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
0

##### Share on other sites

but they all messed up

0

##### Share on other sites
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
0

## Create an account

Register a new account