Archived

This topic is now archived and is closed to further replies.

HanSoL0

The _44 member of a matrix

Recommended Posts

HanSoL0    1210
I can''t for the life of me find any documentation describing the purpose or function of the _44 member of a matrix. I know that _41, _42, and _43 represent the position (x, y, z) but what is that fourth one in that row, and why does it always have to be 1? Thanks in advance! HanSolo Sector 13 Games

Share this post


Link to post
Share on other sites
FantasyGuy    122
In order for _41, _42, and _43 to function properly, the vertex matrix (or vector, which is a 1X4 matrix) should be [x,y,z,1]. If the fourth member of this vector is not 1, the values of _41, _42, and _43 will be multiplied before being added to x, y, and z respectively causing wrong results. If you put _44 to any value other than 1, you''ll cause the resulted vector to have a value other than 1 in the fourth element. This won''t have any effect on the resulted x, y, and z, but its effect will appear if you further transformed this vector. As you know, many transformation matrices are applied to a vector to convert it from world space to screen space. All these matrices should have their _44 member set to 1 except for the final matrix which is the projection matrix which doesn''t have its _44 member set to 1, it has _44 set to 0 instead.

Share this post


Link to post
Share on other sites
HanSoL0    1210
The reason I ask is because I''m trying to come up with a good way of "destroying" an instance of ammo (a laser beam) after it either hits something or burns out after a certain time. In my engine test program, you can fly several different starfighters around in space, run them into each other (they bounce off each other taking into consideration mass, velocity, momentum, acceleration, etc.), fire their lasers, and blow each other up. However, I can only fire one instance of ammo from each gun. When you fire again, the first instance just resets its position inside the barrel of the gun and it fires again.

I created a list which is simply an array of transformation matrices. When a laser is fired, it spawns from an offset from the firing ship''s center. Every frame, its transformation matrix is copied to the next highest slot in the array after the translation has been applied. When all the matrices in the array have been updated, they are all rendered. When the matrix has been copied to the last element in the array, or when it collides with another mesh (collision detection code works fine) I want to stop rendering that instance of the laser. But if I simply stop rendering it, the geometry of the mesh is technically still there, and things can still collide with it.

Can anybody think of a way completely destroy that instance of geometry? This is probably a ridiculously simple thing to do, but my brain is still stunned and fried from seeing my beautiful ships blow to pieces. I had thought that nulling out the transformation matrix would be effective, or maybe just nulling out that _44 element would work, but I don''t know. Any suggestions?


HanSolo
Sector 13 Games

Share this post


Link to post
Share on other sites
FantasyGuy    122
Floating point operations is computationaly expensive. Try to minimize them. Maybe nulling the matrix is enough to disable the collision detection code but there will still be unnecessary floating point operations. Adding a flag with each matrix specifiying whether it''s active or not is more efficient and more clear than nulling it.

Share this post


Link to post
Share on other sites
HanSoL0    1210
Wow, that''s really quite a good idea. And thanks for the info on floaters....that will help more than you know. Thanks a lot!



HanSolo
Sector 13 Games

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
The 4,4 entry is a bit of mathematical treachery designed to
make the translation matrix compatible with all the other transformations. In order to do this we use the homogenous
3d coordinates (x, y, z, w) w is usually 1 but not all transformations preserve w. When w is not one all the other elements in your vector need to be multiplied by 1/w to correct them. w is kind of a magnitude divisor. Or multiplier depending
on how you wanna look at it.

Share this post


Link to post
Share on other sites