PDA

View Full Version : urgent help on shrinking and rotating objects!!



sar22
03-24-2002, 12:17 AM
Hi everyone
i am working on a project where i have to create a 7 layered tree. the problem i am having is that either i can shrink the line (the trunk of the tree) or i can rotate it. but i can't do both. even if it rotates, it doesn't rotate at the proper angle. and it doesn't have to do with the angle i specify.
i am using the glrotatef and gltranslatef functions.

the procedure i am following:
-initialize the two points to draw the first line.(the trunk)
-shrink the line(for branch) and create new coordinates and draw smaller line
-translate the smaller line back to the origin to rotate
-rotate the line
-translate back to it's original position so it loooks like the branch of the tree.
i appreciate any feedback on this...thanks in advance.

Morglum
03-24-2002, 04:23 AM
>>even if it rotates, it doesn't rotate at the proper angle. and it doesn't have to do with the angle i specify.<<

That's clear : you've forgotten to convert radians to degrees !

Jambolo
03-24-2002, 11:25 AM
Remember that transformations are cumulative. After you scale or rotate, translations are done in the scaled or rotated coordinate system. After you translate, rotations and scaling are done in the translated coordinate system.

When someone writes, "translate to the origin, rotate, translate back", it usually means they don't understand this.

Think of it this way:

1. Translation moves the origin (not the object).
2. Rotation and scaling operate on the coordinate system, not the object.
3. Transformations are relative to the current (aka local) coordinate system.
4. Drawing (e.i. glVertex, glNormal, etc.) are done in the current coordinate system.