here is a little explanation of some of the code. Please bear in mind that C is not a language that i'm very familiar with, and i haven't delved in OGL for about half a year.
this is the part of the draw_bone function that draws the kite shaped thingamy-hedrons:
Code: Select all
/* Section 1*/
vec= vec= 0;
vec= -bulge; vec= bulge;
vec= 0; vec= length;
vec= bulge; vec= bulge;
vec= 0; vec= 0;
now, i'll try to take you through it piece by piece...
means that we are beginning a sequence of OpenGL commands to draw something onto the screen. glEnd()
, suprise suprise, signifies the end of the sequence. GL_LINE_STRIP creates a sequence of connected lines from point to point. Everthing in between is executed when the screen is refreshed, or whatever.
vec= vec= 0;
sets the start of the line strip to the root of the bone. vec is an array with two values, both initially set to 0, the root.
Now, I know what you're thinking - isn't this 3D? how can the shape be displayed with only 2 values?
Well, lines are of course 2D, so can only take 2 values per vertex (glVertex2fv() - an OpenGL vertex with 2 floating point values). The depth comes from the matrix, i think. This sort of stuff always messed me up with OGL, which is why i stopped attempting to program.
Anyway, next comes vec= -bulge; vec= bulge; glVertex2fv(vec);
. The bulge value is established earlier in the function, related to the length of the bone (bulge=length*0.1;). Draw a line from the first point (0,0), to the second (-bulge, bulge).
It should be obvious what happens next. Line to the tip, back up to the opposite bulge, then finally to the root. et voila! half of our octahedron is complete.
you can follow the function along as it draws the other parts (tip -> do some reading on the GL transform functions on www.opengl.org
From there, you're on your own, Mr Money.
There are plenty of things you can do to play around. For example, try changing the line bulge=length*0.1
to a lower value, like *0.05, to make the bones really skinny, like in other apps.
please take all of this with a pinch of salt. I am not so good with C, so this could all be complete crap.