The swarm of insect: how to in opengl

I need the algorithm of doing such simulation. Where to find the reference for it. How to program the movement of particular insect and the swarm in the whole. What laws rules such things. I found on igeo but there is additional library that do not work on JOGL. I also want to know did the swarm of insect is different from swarm of points that is refered on IGEO web site. Should the insects to be with dimension but not points? I need the swarm of insects with diffferent colours that defines its velocity.

I was told such algorithm in the words: there is central insect and the swarm should comprise some kind of polygon (with the center of this insect) and other insects should not be out of this polygon. So I do not understand should be the central insect moves along the center of the polygon or it may be moving in the central area (small polygon) of the main swarm polygon (or maybe it could be circle)? But the main question is that the velocities of insects should be according to its colour: so it should be constant in modulus. But teacher told that I should use Random functio? How and for what? For the direction of velocities? Or the random fucntion should be applied when the certain insect tries to go out of boundary of swarm? Anyway the first task is the programming of main insect how its move then we can program the other insects with the restrictions relating to the sawrm boundary? Who can briefly refer to the right algoright with some kind of code?

How to use "random" c++ function? For its position, for the velocity (but its direction as they shoud be constant by modulus).

These aspects are quite independent of OpenGL and you will have a better chance of getting useful answers by asking in a general programming forum.

I don't know how swarms are simulated, but I would recommend you try to ask a more specific question than what is essentially: "how do I simulate an insect swarm?" Such generic questions require somebody knowledgeable to write half a book chapter to answer, so that makes it unlikely to happen in practice. Please see also Forum Posting Guidelines for suggestions how to ask good questions.

2

http://stackoverflow.com/questions/24098901/swarm-of-inswects-with-different-velocities-according-to-its-colaur--here is my code. Can anyone to link the code there. I have additional questions about how to use the field of particle structure vec4 pos in array like manner particle[i].position[j]...except it there is colour field in integer value in particle structure. So how to use in for rgb colors. // it is particle system. But as for swarm I was said by teacher to have some central insect. So should it be in constant position in the centre of cube. Or this cube shoved move along this insect so it can not have collisions. Despite in this way its movement and the whole cube should be in one direction.