rotating cylinder in open GL


    Mar 23 2010 | 10:47 pm
    Hi there,
    i need to rotate a cylinder in open GL, but the basic rotation is around the middle point, if i need to rotate around one edge is there any solution?
    i can mask half of it, but it's gonna cover other objects
    otherwise i can use linesegment in sketch but there's no 3d in it...
    Any idea?
    Alberto

    • Mar 23 2010 | 11:25 pm
      you can do this using gl.sketch and proper ordering of calls to gltranslate/glrotate.
      to rotate something offset from it's center point, you call glrotate before calling gltranslate with the offset amount:
    • Mar 24 2010 | 2:14 pm
      Great robtherich, this is exactly what i needed. The sketch object seems to have a lot of possibilities, so now i see... i have another question i kept for quite some time, is it possible to group objects together in openGL in a way of using them as a macro-new-defined object? for example a Sphere and a Cylinder form a pendulum, if i link the sphere relative to the cylinder i can just rotate the cylinder thing without specifying the rotation for the sphere?
    • Mar 29 2010 | 7:49 am
      as long as you're not doing anything too intensive, you could tell a sketch (mysketch1) to drawobject mysphere and drawobject mycylinder (name your sphere and cylinder)
      then you'd call "drawobject mysketch1" on a new SECOND sketch, "mysketch2"
      nested sketches, yep.