Have you ever felt like a caveman who has been shown fire by ancient astronauts? LOL
-LOL-
Ok well, let's try to understand what you have , but let's be like the caveman, as if we didn't know 3D then -lol-
Here comes the SPACE astronaut with a lot of SPACE theory:
Vertex v is usually specified in the LOCAL space of an object O such that:
v' = M * v
This is noted here as a right-to-left multiplication of a Homogeneous Position Vector v by a Transformation Matrix M which is object O's LOCAL space transform, in other word:
M transforms v (which is also in O's LOCAL space) to v' which is in GLOBAL space.
If this GLOBAL space has for origin (0,0,0) then v' has ended up in WORLD space.
M is defined as: M = T * R * S,
where:
- S is the scale matrix that O has been scaled by to become the size that it is in GLOBAL space not LOCAL (in other words, this GLOBAL space scaling contributes to O's LOCAL space )
- R is the orientation or rotation that O has gone through in GLOBAL space (not LOCAL) (in other words, this GLOBAL space orientation/rotate contributes to O's LOCAL space)
- T is the translation that O was moved by to be where it is in GLOBAL space (not LOCAL) (in other words, this GLOBAL space translation has contributed to O's LOCAL space origin)
therefore by substitution, we can write on the cave wall:
v' = T * R * S * v
this is a LOCAL-TO-GLOBAL space transform of v to v'
and if the scale is always going to be 1 on all axis, this can simplified to:
v' = T * R * v
I'm going to assume now that S is 1, that means M must contain some rotational and translation values, right:
M =
[ r1 r4 r7 tx ]
[ r2 r5 r8 ty ]
[ r3 r6 r9 tz ]
[ 0 0 0 1 ]
in column-major
where (r1,r2,r3) represent X-axis rotational coefficients and thus define the LOCAL space X-axis (not GLOBAL)
where (r4,r5,r6) represent Y-axis rotational coefficients and thus define the LOCAL space Y-axis (not GLOBAL)
where (r7,r8,r9) represent Z-axis rotational coefficients and thus define the LOCAL space Z-axis (not GLOBAL)
where (tx,ty,tz) represent translation coefficients and thus define the LOCAL space origin (not the GLOBAL space origin)
Right, because we now have a orthonormal definition of space, any 3D object that has 3 orthonormal basis vectors, which have their origin at point T, can use this M notation;
for example,
the astronaut didn't come empty-handed, he brought a SONY xdcam model pxw-x70 camera snuggled at the right lobe of his helmet at a point P. This way, everytime dude moves his head to take a picture of the frog-like half-naked pre-cambrian ancestral, his helmet's chip re-adjusts the camera's orientation defined by (Forward, Up, Left or Right) vectors;
at the delight of NASA folks out here, the helmet's chip uses those 3 unit orthogonal vectors at point P to form the camera's LOCAL space (aka VIEW space or EYE space, but not the GLOBAL space);
and here is how those NASA folks defined the camera's VIEW space computed by the chip in a language of their own:
camera's Forward F vector to be aligned with +Z axis (r7,r8,r9), insert F into 3rd column;
camera's Up U vector to be aligned with +Y axis (r4,r5,r6), insert U into 2nd column;
camera's Left L vector will be aligned with -X axis (r1,r2,r3), insert L into 1st column;
and translation P set as origin of VIEW space, insert into 4th column;
return error;
crash if u want;
in other words:
View =
[ -Lx Ux Fx Px ]
[ -Ly Uy Fy Py ]
[ -Lz Uz Fz Pz ]
[ 0 0 0 1 ]
with this functionality coded in, any vertex v'' (which is in WORLD space, this is a space where the GLOBAL space is at (0,0,0)) multiplied by this View matrix will be transformed to v''' which will be in CAMERA space or VIEW space. Job done.
Then everything we said thus far can be written as:
v_global = M_local * v_local (1)
v_world = Mworld * v_global (2)
(1) into (2)
v_world = M_world * M_local * v_local (3)
v_view = M_view * v_world (4)
(3) into (4)
v_view = M_view * M_world * M_local * v_local (5)
and (5) is none other then the familiar:
v_view = VIEW * WORLD * MODEL * v; // v is v_local
this v_view vertex in VIEW space can then be projected to be this vertex into PROJECTION or CLIPPED space:
v_proj = PROJECTION * VIEW * WORLD * MODEL * v;
and this v_proj in PROJECTION or CLIPPED space can be normalized for viewport rendering like so:
v_normalized = NORMALIZE * PROJECTION * VIEW * WORLD * MODEL * v;
v_normalized is the vertex that we see onscreen. End of story;
Now, why did we have this story?
Well, if u look at what Joej did, which u also changed later:
JoeJ said:
Matrix4x3 mat;
mat[0] = normalize(geodesic_dir); // tangent
mat[1] = normalize(temp_dir); // make up vector (...be orthogonal to .., ..we would need to orthonormalize...)
mat[2] = cross(mat[0], mat[1]);
mat[3] = temp_dir * displacement;
you both built LOCAL space transforms of your chess pawns ?
taby said:
What's not obvious to me is why it works. LOL. Anyone care to decipher the magic code?
… and this story deciphers it, it all started in a cave ?
have fun ?