Dynamically created molecule builder

i am trying to create a molecule builder,
which reads from an array the structure of the molecule eg:

ch3

what i want to do is to build this molecule dynamically ie without any given coordinates using opengl,how can i do this?

the problem is that for each individual atom ie let us take c for carbon & h for hydrogen, i want to specify the colour,and then to render the two molecules, at coordinates which i build dynamically. how can i do this without just having one molecule output onto the screen?

You’ll need to do some dynamic memory allocation of some sorts.

With C, you can use linked lists to read the data and add as many elements to the list as you require. You then walk through the list and draw each molecule in its given location.

The other method is to use the memory allocation functions,

‘calloc()’
‘malloc()’
‘realloc()’

to allocate memory in arrays or other sturctures in which to store this data.

Basically, if you want to know about it, pick up a programming text book and read up on dynamic memory allocation.

( alternatively, create a sata structure that is not dynamic, but holds the maximum number of molecules that you could possibly need, and dump the data in there. This is far from being the best way to do it, but its easier)

Sounds like quite an interesting project. Have you got all the rules for where the various atoms are going to be?

Paul.

Check out the Red book. There is a good example about a molecule builder which uses linked list. I think, this is the best approach when it comes to molecules. Let’s keep in touch 'cause I’m working on developing molecular GUI and simulator.

Vanleurth (the matrix has you)

yes that would be excellent,

have you any idea on how i might be able render the molecules correctly in space.

i am going to build from basics really and then go from their.

i thought of using the valencies of the atoms to keep a track of what should go where, but as the user is not specifying any co-ordinates, what would be a good way of holding the molecules in the correct place?

have you any ideas for a novice in OpenGL

yes that would be excellent,

have you any idea on how i might be able render the molecules correctly in space.

i am going to build from basics really and then go from their.

i thought of using the valencies of the atoms to keep a track of what should go where, but as the user is not specifying any co-ordinates, what would be a good way of holding the molecules in the correct place?

have you any ideas for a novice in OpenGL

Have you looked at what other people have done? Try looking at the Scientific Applications on Linux site. There are molecule viewing applications on there, iirc. Some may or may not have OpenGL capability but you can get some idea of how it was done.

[This message has been edited by shawge (edited 08-10-2000).]