When I was working on my Ph.D., I wrote a simulator that did what you wanted to do. Just remember that while your code may look object oriented, the OpenGL engine still does things in a consistent manner. Also, the consistent nature of the matrix algrebra under the hood in OpenGL is sometimes not in the order you think logically (when will I translate, when will I draw, when will I rotate, etc.?).
Remember LOGO in the old days? He had a turtle that was a pen, and you moved the turtle, and she drew lines. If the pen was down, she painted, if the pen had risen, this is not so. So I thought about my work on this program. I would start the โturtleโ at the familiar coordinate (0, 0, 0) and use the math to translate it (move it to the center of the object I want to draw), and then call the draw () methods trying to write to draw my shape on basis of the relative coordinate system, where the "turtle" and not absolute (0, 0, 0). Then I would move, tortoise, draw, etc. Hope this helps ...
source share