PDA

View Full Version : Atomic Ball & Stick Model



Johnny5
03-17-2004, 04:43 AM
I must come up with a model for a molecule.
How do you utilise gluSphere and coordinates
so that various 'atoms'(the spheres) can be placed at certain locations.

dvm
03-17-2004, 04:58 AM
gluSphere is a glu Quadric.
Here's some code:



//Initialization
GlUquadric *mySphere;
mySphere = gluNewQuadric();
// Draw the sphere, we give a pointer to the quadric object
// followed by the radius of the sphere, the
// slices and the stacks. The radius speeks
// for itself. Slices and stacks is how
// smooth you want your sphere.
gluSphere(mySphere, 10, 20, 20);
// Termination
gluDeleteQuadric(mySphere);
mySphere = NULL;

Initialization and Termination should be done usually only once and not every frame. Also search google for gluSphere and other glu functions. There are a lot of parameters you can define on how you want your object to be drawn.

[This message has been edited by moucard (edited 03-17-2004).]

Johnny5
03-18-2004, 03:15 AM
Thanks for that code, but how do I allocate each sphere with its own coordinates to place them at different positions?

malancha
03-18-2004, 11:07 PM
Use glTranslatef to move to a desired location and then draw your sphere there. Repeat as required.