|
|
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
with a black color that has the 4th component set to 0.5 for shadows.
open(file)
read in an ASCII line ('P3')
read in two ASCII values, xres and yres (resolution, e.g., 256, 256)
read in another ASCII value (e.g. max value = 255)
k = 0;
for i=0 to yres
for j=0 to xres
Read three ASCII integers from file: r,g,b
data[k++] = r;
data[k++] = g;
data[k++] = b;
close(file)
glGenTextures(1,&texture);
glBindTexture(GL_TEXTURE_2D,texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D,3,xres,yres,GL_RGB,GL_UNSIGNED_BYTE,data);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
glBindTexture(GL_TEXTURE_2D,texture1);
glTexCoord2d(0.0,0.0); glVertex3f(-100.0,0.0,-100.0); ...
glDisable(GL_TEXTURE_2D);
getModelCabPostion(&cx,&cy,&cz) getModelDirection(&dx,&dy,&dz) glLookAt(cx,cy,cz,cx+dx,cy+dy-0.05,cz+dz,0.0,1.0,0.0);This has the first person view looking down at the road a little bit.
The direction vector is just the sine and cosine of the y-axis rotation of the vehicle for the x and z coordinates with y=0. The cab position would be computed using the model's position in the scene, the dimensions of the vehicle, and possibly the direction vector to calculate the position for the cab (the location of the operator of the vehicle) in the scene.
k = 0;
for i=0 to yres
for j=0 to xres
Read three ASCII integers from file: r,g,b
data[k++] = r;
data[k++] = g;
data[k++] = b;
data[k++] = ((r+g+b) > 600) ? 0 : 255;
close(file)
gluBuild2DMipmaps(GL_TEXTURE_2D,4,xres,yres,GL_RGBA,GL_UNSIGNED_BYTE,data);
glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, treeTexture ); glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); ...draw quadrilateral with texture coordinates glDisable( GL_TEXTURE_2D ); glDisable(GL_BLEND);
GLubytehalftone[] = {
0xAA,0xAA,0xAA,0xAA,0x55,0x55,0x55,0x55,
...
glEnable(GL_POLYGON_STIPPLE);
glPolygonStipple(halftone);
<draw polygon>
glDisable(GL_POLYGON_STIPPLE);
NOTES: