Example #1
0
void SkyboxObject::load ( trObjectParserBlock &parserBlock )
{

	float skyboxSize = 500;
	skybox.SetTexturePath("data/skyboxes");

	// scan elements
	tvStringPairList::iterator itr = parserBlock.elements.begin();

	while (  itr != parserBlock.elements.end() )
	{
		if ( !basicElement( *itr ) )
		{
			std::string tag = string_util::toupper(itr->first);

			if ( tag == "BOUNDS" )
				skyboxSize = (float)atof(itr->second.c_str());
			else if ( tag == "ZSHIFT" )
				skybox.SetZShift((float)atof(itr->second.c_str()));
		}
		itr++;
	}

	skybox.Create(skyboxSize,name.c_str());
	MapBaseObject::load(parserBlock);
}
void GL_init(void) 
{
	glClearColor (1.0, 1.0, 1.0, 0.0);

	glEnable(GL_CULL_FACE);
	glEnable(GL_DEPTH_TEST);

	static GLfloat light_ambient[] = { 0.01, 0.01, 0.01, 1.0 };
	static GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
	static GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };

	glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
	glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);

	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);

	models[0].CreateBlock(2.0, 1.6, 1.0, 4.0, 2.0, 2.0);
	models[1].CreateSphere(1.0, 80, 80, 1.0, 1.0);
	models[2].CreateCylinder(0.5, 2.0, 40, 20, 3.0, 2.0, 1.0);
	models[3].CreateTorus(0.2, 0.8, 40, 20, 8.0, 2.0);
	ground_model.CreateTerrainFromHeightMap(140.0, 140.0, 32.0, 32.0,
		"../textures/terrain_height-01.jpg", -21.0f, 0.3f);

	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
	glPixelStorei(GL_PACK_ALIGNMENT, 1);

	model_textures[0]=Load2DTexture("../textures/wood01.jpg");
	model_textures[1]=Load2DTexture("../textures/earth.jpg");
	model_textures[2]=Load2DTexture("../textures/metal01.jpg");
	model_textures[3]=Load2DTexture("../textures/glass01.jpg");
	ground_texture=Load2DMipmapTexture("../textures/rock01.jpg");

	glEnable(GL_TEXTURE_2D);
	glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);

	//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

	camera.Init(CVector3D(15.0, 0.0, 1.0), 
		CVector3D(0.0, 0.0, 1.0), CVector3D(1.0, 0.0, 0.0));

	// Sky Box
	sky_box.size=1000.0f;
	sky_box.Create();
	env_texture=LoadCubemapTexture(
		"../textures/Skybox01_left.jpg",
		"../textures/Skybox01_right.jpg",
		"../textures/Skybox01_up.jpg",
		"../textures/Skybox01_down.jpg",
		"../textures/Skybox01_front.jpg",
		"../textures/Skybox01_back.jpg"
	);

	water_surface.Create(140.0, 140.0, 64, 64);
	water_surface.plane_waves[0].A=0.4f;
	water_surface.plane_waves[0].f=0.5f;
	water_surface.plane_waves[0].Lx_rcp=4.0f/100.0f;
	water_surface.plane_waves[0].Ly_rcp=0.0f/100.0f;
	water_surface.plane_waves[1].A=0.1f;
	water_surface.plane_waves[1].f=1.0f;
	water_surface.plane_waves[1].Lx_rcp=10.0f/100.0f;
	water_surface.plane_waves[1].Ly_rcp=10.0f/100.0f;

	current_time=timeGetTime();
}