RE: [Algorithms] Scaling Models
Brought to you by:
vexxed72
From: Tom H. <to...@3d...> - 2000-07-28 21:41:15
|
At 11:18 AM 7/28/2000 +0100, you wrote: ><snipped stuff about scaling and normals> > >Just out of interest, one thing I did a while back when I needed to treat >both normals and vertex positions uniformly when applying an animation >matrix to them was set the W component of the normals to 0, whilst leaving >the W component of the positions at 1. This worked because the animation >matrix never contained a scale, and I just wanted to not translate the >normals. Is this a well-known technique that I just haven't run across >before, and is there any theoretical basis for it? Yeah, the general term I see used for it is homogenous matrices. I set up my math libs to work with a class that describes a 4x4 homogenous matrix, a class that describes a 1x3 vector and a derived class that describes a 1x3 point. The matrix class has overloaded functions for multiplication where one takes a point and the other takes a vector. When a vector is used, the unspecified fourth component is assumed to be 0. When a point is used, the unspecified fourth component is assumed to be 1. In both cases the matrix math is simpler than a full transform since the constant allow some of the operations to be removed. I also have a 1x4 vector class for general transforms. I don't generally use scales on matrices this way (and the description is atrocious from a math standpoint) so Ron can correct me here as needed, but I seem to recall there being two ways to add a scale to a matrix. For a non-uniform scale you can monkey with the different components to get what ya need, or for a uniform scale you can insert the scale value directly into the lower right corner of the matrix. If you're doing a uniform scale, and using homogenous matrices as I've described above you wouldn't need to re-normalize the normal since the uniform scale would be ignored for vectors (since the 4th component is zero). Vectors will still be affected by the more traditional scales, and even if they're uniform, will need to be normalized before they can be used in most lighting and environment mapping situations. Tom |