About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
Dealing with matrices
Author Message
Zervox Offline
Silver Supporter

Post: #1
Dealing with matrices
Anyone here have good experience with matrices that could help me on this?
Trying to convert EE matrix for use in a third party library and I am not sure I am assigning the correct variables to the correct spots in the arrays.

Also anyone know of a function to get ProjectionView matrix from Esenthel?
or do I have to write my own hacky way of getting it?

Code:
/*//Guideline Projection
//m[0] = projection.M11; m[1] = projection.M12; m[2] = projection.M13; m[3] = projection.M14;
//m[4] = projection.M21; m[5] = projection.M22; m[6] = projection.M23; m[7] = projection.M24;
//m[8] = projection.M31; m[9] = projection.M32; m[10] = projection.M33; m[11] = projection.M34;
//m[12] = projection.M41; m[13] = projection.M42; m[14] = projection.M43; m[15] = projection.M44;
*/
Code:
Dbl arr[16];
arr[0] = projview.x.x;
arr[1] = projview.y.x;
arr[2] = projview.z.x;
arr[3] = projview.pos.x;
arr[4] = projview.x.y;
arr[5] = projview.y.y;
arr[6] = projview.z.y;
arr[7] = projview.pos.y;
arr[8] = projview.x.z;
arr[9] = projview.y.z;
arr[10] = projview.z.z;
arr[11] = projview.pos.z;
arr[12] = projview.x.w;
arr[13] = projview.y.w;
arr[14] = projview.z.w;
arr[15] = projview.pos.w;
//\param p A pointer to 16 doubles representing a 4x4 projection matrix.
//void SetProjectionMatrix(const double *p);
environment->SetProjectionMatrix((Dbl*)&arr);

Matrix4 view = Cam.matrix;
Code:
arr[0] = view.x.x;
arr[1] = view.y.x;
arr[2] = view.z.x;
arr[3] =
arr[4] = view.x.y;
arr[5] = view.y.y;
arr[6] = view.z.y;
arr[7] = 0;
arr[8] = view.z.x;
arr[9] = view.z.y;
arr[10] = view.z.z;
arr[11] = 0;
arr[12] = view.pos.x;
arr[13] = view.pos.y;
arr[14] = view.pos.z;
arr[15] = 1;
//param m A pointer to 16 doubles representing a 4x4 modelview matrix.
//void SetCameraMatrix(const double *m);
environment->SetCameraMatrix((Dbl*)&arr);
05-17-2015 10:25 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Dealing with matrices
If you want to use a 4x4 matrix, then you can first convert EE Matrix to EE Matrix4
Matrix m;
Matrix4 m4=m;

then you can try 2 attempts:
Flt *f=(Flt*)&m4;
external_lib_matrix4[x + y*4]=m[x + y*4]
or
external_lib_matrix4[x + y*4]=m[y + x*4]
05-17-2015 11:33 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Silver Supporter

Post: #3
RE: Dealing with matrices
Ok, so apparently I need to get ModelViewMatrix, how is the procedure for this?

Edit: I found a way to work around it although it looks like I needed to use my source access for it. objectmatrix*inversecamera(without having to inverse the matrix additionally myself that is).
(This post was last modified: 05-18-2015 07:04 AM by Zervox.)
05-18-2015 02:31 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Dealing with matrices
Added some information in response to your PM:
http://www.esenthel.com/?id=doc#Units
05-21-2015 10:45 PM
Find all posts by this user Quote this message in a reply
Post Reply