Right now, when I use Nehe''s quadratic tutorial to draw cylinders, I have to glTranslatef to somewhere, then draw it. It''s always straight (horizontal) though, so to get it diagonal, I have to rotate it after. I want a way to just say: start drawing at xyz, then finish drawing at xyz. So I can tell it where to draw both ends....
And what''s this about primitives in glut? Thanks!
You mean you''ve given the center line of the cylinder with the end vertices of this line, A and B, and you''ve given the radius r? I haven''t read Nehe''s tutorial, I don''t know how Nehe draws a cylinder, but I can tell you how I do: For the parametric cylinder description with the parameters s and t, firstly you need the direction vector of the cylinder, which is v = B-A. Then you''ll need two vectors perpendicular to each other and perpendicular to v. You could get one of the perpendicular vectors, n1, with n1.x=-v.y, n1.y = v.x and n1.z = 0. For the second one, n2, you need the cross product: n2 = v x n1 Now we''ve got the equation: x(s,t) = A + v*s + r*sin(t)*n1 + r*cos(t)*n2 where x(s,t) is a vertex of the cylinder surface. Let s run from 0 to 1 and t from 0 to 2*PI to get the vertices.
Hmmm, well in Nehe''s tutorial, you just say the length, radius at start, radius at end, and number of faces.... You have to translate to tell it where to draw. So I was wondering if I could tell it coordinates to start and end at instead.... I''ll try to figure out what you said though