Follow these steps:
% cd demo % cp ~/../spowers/public/Makefile . % cp ~/../spowers/public/demo-boids.c . % cp ~/../spowers/public/rgbimage.* . % cp ~/../spowers/public/brick-boids.rgb .
Now, you will want to use the Makefile...so copy it back one directory (% cp Makefile ..). You will then need to edit the Makefile and change the name of the program and the name of your source file. After these changes, you should be able to compile again without problems.
To interface with the boids library, you will need to be aware of how it works. First off, you must create the boid simulation. This defines things like the world dimensions, the dimension of each boid, and the number of boids to create. Everything else is taken care of, with regard to creating the simulation. Next you will need to define your obstacles. You can do this in your function for creating the landscape. Obstacles can be either spheres or rectangles. This does not mean the obstacle that is rendered (the one you draw on the screen) needs to be a rectangle or sphere, as you will never see the obstacle as the boid does internally. Finally, you will need to call into the boid library to find out the new position of the boid. This will be done in your display function.
Here are the steps as done in the demo-boids.c program:
createBoidSim(NUMBOIDS,
10,
10,
10,
500,
500,
700);
Here is the prototype as specified in the header file:
int createBoidSim(int numBoids, /* number of boids */
float bwidth, /* boid width */
float bheight, /* boid height */
float blength, /* boid length */
float wwidth, /* world width */
float wheight, /* world height */
float wlength); /* world length */
So, you will need to specify your own parameters. If your boid
dimensions are different, you will need to be sure to make them
the correct size. Please note this is the "scaled" size if you
are scaling your boid down.
int createBoxObstacle(float rulx, float ruly, float rulz, /* rear up left */
float flrx, float flry, float flrz); /* frnt low right */
int createSphereObstacle(float cx, float cy, float cz, /* center */
float radius); /* radius */
The box obstacle takes 2 points, the upper left rear corner and
the lower right front corner. The sphere takes the center point and
the radius of the sphere. If you need further explanation, ask.
if (!updateBoids()) {
return;
}
This is so the boids update much smoother and faster. Next, you'll
need to draw the boids. This example calls "draw_borg" which
draws one cube with or without texture mapping.
for (i=0; i<NUMBOIDS; i++) {
glPushMatrix();
glTranslatef(boidList[i].x,
boidList[i].y,
boidList[i].z);
glRotatef(boidList[i].pitch,1,0,0);
glRotatef(boidList[i].yaw,0,1,0);
glRotatef(boidList[i].roll,0,0,1);
draw_borg();
glPopMatrix();
}
That's all there is to it.