PDA

View Full Version : Anisotropic Scaling



ae97004
09-04-2002, 10:58 AM
Hi,

This is a piece of code i wrote.
The aim is to apply difft rotation matrices to the modelview matrix for the normals and the points.

glMatrixMode(GL_MODELVIEW);
glMultMatrixf(TranslationMatrix);
glMultMatrix(ScalingMatrix);
glBegin()
for(i=1;i<=NumberofTriangles;i++)
{
glPushMatrix();
glMultMatrixf(TransposeRotationMatrix);
//Set the normal
glPopMatrix();
glMultMatrixf(RotationMatrix);
//plot the verices
}
glEnd();

Error: If i gave the glMultMatrix outside the glBegin() End() loop then using only one rotation matrix iam able to get it to work, but if i give it as such inside with two difft matrices for normals and rotation i can only get the object to translate and scale but iam not able to get it to rotate at all.

Any comments to fix this, or another alternative method would be greatly appreciated.

Thanks
Prashanth

Deiussum
09-04-2002, 11:04 AM
From MSDN documentation of glMultMatrixf. The same goes for glTranslatef, glScalef, glRotatef, etc.



Error Codes
The following is the error code and its condition.

Error code Condition
GL_INVALID_OPERATION glMultMatrix was called between a call to glBegin and the corresponding call to glEnd.

ae97004
09-04-2002, 11:24 AM
Yeah,
I did notice that, is there some way to overcome this... i need to use two difft matrices.. inside the loop...
thanks
Prashanth

Deiussum
09-04-2002, 11:48 AM
I'm not quite sure what you are trying to accomplish, but there is no way to use those gl calls that affect the matrix between glBegin and glEnd.

If you are trying to use scaling and don't want the normals affected, just use glEnable(GL_NORMALIZE).

Not quite sure what the glMultMatrixf(TransposeRotationMatrix) is supposed to be for either. Normals get multiplied by the inverse model-view matrix.

If you really need to have a different rotation for normals than the vertices, the only way I can really think of is to do all your own matrix math on each normal before passing them to glNormal.

ae97004
09-04-2002, 12:57 PM
Thanks a lot, thats precisely what i was looking for... inverse of modelview matrix multiplication to the normals.

Problem solved!!

[This message has been edited by ae97004 (edited 09-04-2002).]