Graphics : How to create a 3D cylinder around a line segment in opengl? -
i have line segment 2 end points, wanted create cylinder around radius r.
there enough examples on web, here's simple description. think of cylinder cd-rack. consider "bottom surface" of cylinder. know center of surface 1 end of line segment. edge vertices of surface, vertices of group of triangles (say 8) made 1 vertex center of surface. make cylinder complete, make stack of such surfaces till other end of line segment.
how find vertices of each line intersecting surface (ex, there 8 lines in below figure) ? loop goes this:
for(each line) { float angle_degrees = 360 * (id of line) / (number of lines); float x = radius * cos(angle_radians); float y = radius * sin(angle_radians); }
zwiggler drawing:
some other discussions on subject: number of sides required draw circle in opengl
Comments
Post a Comment