Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.



This topic is 5370 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Maybe the kid desparately needed help. I''m pretty sure nehe.gamedev.net provides some sort of online tutorial on this situation.

Drawing cylinders or any quadric in OpenGL is quite simple. If you want to alter it''s position you''d have to use the glTranslate function since you can''t really apply a vertex position for quadrics(like you would for Quads, Triangles and other generic polygons).

"Do you believe in Ghost?"

Share this post

Link to post
Share on other sites
I know what u say but you misunderstand me :-
How to make a Function that Draws A Cylinder Like this

void DrawCylinder(double *p1,double *p2,int raduis)
//Some transformations Here and this is the question

Share this post

Link to post
Share on other sites
read up on gluCylinder();

namely on msdn or other such docs.

and read up on glTranslatef()

[edited by - DerAngeD on February 7, 2004 8:43:24 AM]

Share this post

Link to post
Share on other sites
You guys still arn''t getting him, you need help with the math right.

Your right so far, translate to the first point. Im sure the gluCylinder function takes a height and radius and probably a slices or something parameter. Anyways, height will be the distance between your two points.

sqrt( (p2[0]-p1[0])*(p2[0]-p1[0]) + (p2[1]-p1[1])*(p2[1]-p1[1]) + (p2[2]-p1[2])*(p2[2]-p1[2]))

In order to get your cylinder to point towards the second point your going to have to do some glRotate''s search on how to rotate into the direction of a vector, rotate into p2 - p1. Or use trig and sin-1 and cos-1''s to figure out the angles to rotate.

Share this post

Link to post
Share on other sites
I could find my answer to question the one who wants to know how this could be done :-



Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!