Recommended Posts

I have an object (a flower petal) that has all its vertices stored in terms of the world coordinate axis (xyz). When it's drawn it runs along the y axis.
However, this petal object has its own local coordinate system (abc) and I would like to transform the petal so that instead of being drawn down the y axis (of the xyz coordinate system) it is drawn down the b axis of its own local coordinate system.
Unfortunately I can't get the transformation to happen. In fact, my petal object completely disappears from view.
This is what I have been doing.

Note that the origin of the xyz coordinate axis is the same as the abc local coordinate axis. If I draw the local and world axes to the screen they are all in the right place. Also, if I was to do something like:

then it does the right thing, so the problem is definitely with the matrix or how I'm using it, so obviously I've misinterpreted things somewhere.
Cheers
Glenn
[Edit]
Well, after talking to some of my colleagues, I was informed of three issues. Yes, three, that's almost all of it. The matrix was back to front, the matrix mode should have been before the pushMatrix and I should have used glMultMatrixf. This is the working code for anyone who stumbles as much as I.

Share this post

Link to post

Share on other sites

If the Origin and Scale of your local coordinate system are equal to those of the modelview space it doesn't matter whether you use glLoadMatrix or glMultMatrix. In fact, if you translated or scaled modelview space but don't want your own one to be affected by modelview transforms you should use glLoadMatrix instead of glMultMatrix.

Furthermore you also don't have to write column vectors... just use ARB_TRANSPOSE_MATRIX which is supported anywhere anyway ( use glLoadTransposeMatrixfARB instead of glLoadMatrixf )