#103284 - Rajveer - Wed Sep 20, 2006 5:42 pm
hi guys. i have a matrix for an objects 3d rotation. since the math library is in fixed point math, eventually after loads of multiplications of matrices the tiny discontinuities become large enough to scale/stretch my object. normalising each axis ever frame (the 1st 3 columns of the matrix) helps but eventually the object still becomes distorted. ive used different methods i.e. creating the matrix every frame so i start with a "fresh" matrix every frame, but there are some advantages to keeping the same matrix. what would you guys suggest?
#103285 - AN_D_K - Wed Sep 20, 2006 5:51 pm
Are you saving the translated vectors? You shouldn't.
Each frame you should be translating the original local model vertices each time. This will stop any major distortions.
#103288 - Rajveer - Wed Sep 20, 2006 6:11 pm
by saving the translated vectors, do you mean the rotation matrix? i am, im using a 4x4 matrix which im multiplying to each frame. i was calculating the matrix by scratch each frame, but the problem lies when rotating and then adding another rotation to it. to be specific i was trying to rotate between ground polygons smoothly. i guess ill go back and try to create it each frame, its the best way :)
#103292 - sajiimori - Wed Sep 20, 2006 6:33 pm
Before renormalizing, you have to reorthogonalize to ensure that the axis vectors stay 90 degrees apart. Code: |
void orthogonalize(Vector3* x, Vector3* y, Vector3* z)
{
*z = cross(x, y);
*y = cross(z, x);
} |
#103295 - Rajveer - Wed Sep 20, 2006 6:47 pm
cheers for the reply, ill try it now :)
in your function, im not sure what the * means, is that a pointer?
or are *z and *y different variables to z and y so that you dont use the "new" variable in the calculations?
#103300 - sajiimori - Wed Sep 20, 2006 8:07 pm
Yeah, * does at least 3 duties in C: multiplication, declaring pointers, and dereferencing pointers.
I'd recommend getting more familiar with the C language before getting too far. It'll save frustration later on.
#103312 - Rajveer - Wed Sep 20, 2006 10:09 pm
cheers for the reply! yep this is my first real project, done some stuff in vb (eugh!) in college and java in uni and learned alot of programming concepts, using this project to teach myself c++ :) cheers once again cheers for the help!