PDA

View Full Version : Simple skeleton in OpenGL using FreeGLUT



iKubik
01-02-2016, 10:20 AM
Hello, I want to draw simple skeleton of a man using glutSolidSphere and glutSolidCylinder.
I want to have something like this, but in OpenGL:

Image link (http://s7.postimg.org/s2okjmitn/Bez_nazwy_4.png)

So, I want to "connect" spheres using cylinders. I need this for animation. I want to animate those spheres using glTranslatef() and I have no idea how to animate those cylinders. Question is: how to use coordinates of those spheres to animate cylinders? Is it possible?

P.S.
Why I can't put a url in my post?

Dark Photon
01-04-2016, 06:33 AM
Why I can't put a url in my post?

New users can't post image links (avoids spam from new users that have no interest in OpenGL). After a few posts you'll be able to post image links.

To answer your original question, you first compute the two joint locations in some space. You then find the distance between those two points. That becomes your cylinder height. Before drawing the cylinder, you then put yourself in a space where one joint is at the origin and the other joint is oriented along the +Z axis. Then draw the cylinder.