Beispiel #1
0
void init (void) 
{
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);    
    glShadeModel (GL_SMOOTH);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    glEnable(GL_TEXTURE_2D);
    texture[0] = loadtextures("texture.raw", 256,256);
    texture[1] = loadtextures("texture.raw", 256,256);
}
Beispiel #2
0
void initializeGraphics()
{
	//Build Pop Up Menu
	BuildPopupMenu();
	glutAttachMenu (GLUT_RIGHT_BUTTON);

	//inittextures
	for(int i=0;i<MAXTEXTURES;i++)
		textures[i]=0;
		
	// disable Lighting
    glDisable( GL_LIGHTING );

    glClearColor (0.0f, 0.0f, 0.0f, 0.0f);

    glEnable( GL_DEPTH_TEST );
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glGetFloatv( GL_MODELVIEW_MATRIX, modelViewMatrix );  // save MY copy in modelViewMatrix

    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    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);
    glEnable(GL_TEXTURE_2D);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

	//Load Textures
	textures[SIRENID] = loadtextures(sirenFile, 52,45);
	textures[VEHICLEID] = loadtextures(vehicleFile, 207,177);
	textures[WALLID] = loadtextures(wallFile, 512,512);
	textures[FLOORID] = loadtextures(floorFile, 512,512);
	textures[CARROTID] = loadtextures(carrotFile, 52,45);
	textures[BUTTONID] = loadtextures(buttonFile, 52,45);
	textures[PARTICLEID]=textures[VEHICLEID];
	textures[PONDID] = loadtextures(marbleFile,225,225);
	textures[WATERID] = loadtextures(waterFile,393,385);
	
	//snow drifts
	snowcave.resetPoints(snowCavePoints);
	snowcave.setBoundingBoxes(driftBuffer);

	snowcave2.resetPoints(snowCavePoints2);
//	snowcave2.setBoundingBox(-50,-27, //min max X
//							-50,-30, //min max Y
//							-50,10); //min max z
	snowcave2.setBoundingBoxes(driftBuffer);
	//snowman
	snowman = Snowman(snowmanOrigin,
		SNOWMANID,
		snowmanSize,
		textures[FLOORID],
		textures[CARROTID], 
		textures[BUTTONID]);


	snowman2 = Snowman(snowmanOrigin2,
		SNOWMANID,
		snowmanSize,
		textures[FLOORID],
		textures[CARROTID], 
		textures[BUTTONID]);

	snowman3 = Snowman(snowmanOrigin3,
		SNOWMANID,
		snowmanSize,
		textures[FLOORID],
		textures[CARROTID], 
		textures[BUTTONID]);

	//Pond 
	pond = Pond(pondOrigin,PONDID,pondRadius,pondHeight);
	pond.setSpaceDimensions(Point(10,10,10));
	pond.setBoundingBox(pondOrigin.x-10,pondOrigin.x+10,-50,pondOrigin.y+5,pondOrigin.z-10,pondOrigin.z+10);

	//Gifts
	gifts[0] = Gift(giftOrigin1,GIFT1ID,giftSize);
	gifts[1] = Gift(giftOrigin2,GIFT2ID,giftSize);
	gifts[2] = Gift(giftOrigin3,GIFT3ID,giftSize);
	gifts[3] = Gift(giftOrigin4,GIFT4ID,giftSize);
	gifts[4] = Gift(giftOrigin5,GIFT5ID,giftSize);

	//enemy 
	npc.setSpeed(npcSpeed);
	npc.setSpaceDimensions(Point(bodyRadius/2,bodyRadius/2,bodyRadius/2));
	npc.setThrowRange(20);
	npc.setInDanger(true);

	//vehicle
	vehicle.setDamage(0);
	vehicle.setMaxDamage(100);
	vehicle.setIsAlive(true);
	vehicle.setStrikeRange(30);


	//init shadow paramteres
   glEnable(GL_COLOR_MATERIAL);
   glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
   glEnable(GL_DEPTH_TEST);
   glDepthFunc(GL_LEQUAL);    
   glShadeModel (GL_SMOOTH);
   glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

	//this is defined 
	//bool (*fp_processCollision)(Obstacle);
	fp_processCollision = &processCollision;


	//Map Creation assessment
	currMap.createMap(minCoords, 
					maxCoords, 
					npc, 
					gifts, 
					giftCount, 
					fp_processCollision
					);
	currMap.printState();

	//setup the controller
	controller = PathController(&currMap,&npc,&vehicle);
	controller.setNextTarget(); //set the target
	controller.setMaxPath(100);

	
}