diff options
| author | Stijn Buys <ingar@osirion.org> | 2008-08-01 20:56:47 +0000 | 
|---|---|---|
| committer | Stijn Buys <ingar@osirion.org> | 2008-08-01 20:56:47 +0000 | 
| commit | d2f36485dd3fbda7c9eb212ac9ffde919af5f8e1 (patch) | |
| tree | c9c717afa45ea0ca251bc0e9454b7ad9c4898dbd /src/render | |
| parent | 089cb5f96e400d4ab7c9d8041cb51eb8f118d9c1 (diff) | |
revert renderer camera location, fix r_restart
Diffstat (limited to 'src/render')
| -rw-r--r-- | src/render/camera.cc | 15 | ||||
| -rw-r--r-- | src/render/draw.cc | 33 | ||||
| -rw-r--r-- | src/render/dust.cc | 9 | ||||
| -rw-r--r-- | src/render/render.cc | 7 | 
4 files changed, 29 insertions, 35 deletions
diff --git a/src/render/camera.cc b/src/render/camera.cc index a9aa1ca..e708b71 100644 --- a/src/render/camera.cc +++ b/src/render/camera.cc @@ -300,10 +300,8 @@ void Camera::draw()  	// Change to the projection matrix and set our viewing volume large enough for the skysphere  	gl::matrixmode(GL_PROJECTION);  	gl::loadidentity(); -//	gl::frustum(-camera_frustum_size*Camera::aspect(), camera_frustum_size*Camera::aspect(),  -//		-camera_frustum_size, camera_frustum_size, camera_frustum_front, 2048.0f); -	gl::frustum(-camera_frustum_size, camera_frustum_size, -camera_frustum_size/Camera::aspect(), camera_frustum_size/Camera::aspect(), camera_frustum_front, 2048.0f); +	gl::frustum(-camera_frustum_size, camera_frustum_size, -camera_frustum_size/Camera::aspect(), camera_frustum_size/Camera::aspect(), camera_frustum_front, 1023.0f);  	gl::matrixmode(GL_MODELVIEW);  	gl::loadidentity(); @@ -315,15 +313,8 @@ void Camera::draw()  	math::Matrix4f matrix;  	matrix.assign(camera_axis);  	gl::multmatrix(matrix.transpose()); -/* -	// match the camera with the current target -	gl::translate(-1.0f * camera_target); -	 -	// apply camera offset -	gl::translate(distance * camera_axis.forward()); -*/ -	// camera sticks at 0,0,0 -	//gl::translate(camera_target - camera_eye); + +	gl::translate(-1.0f * camera_eye);  }  void Camera::set_direction(float direction) diff --git a/src/render/draw.cc b/src/render/draw.cc index 2752030..d440706 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -403,7 +403,6 @@ void pass_prepare(float seconds)  					Light *light = (*lit);  					// load light texture -					// FIXME optimize  					std::stringstream flarename;  					flarename << "bitmaps/fx/flare" << std::setfill('0') << std::setw(2) << light->flare();  					light->render_texture = Textures::load(flarename.str()); @@ -415,7 +414,6 @@ void pass_prepare(float seconds)  					if (!engine->flare()) engine->engine_flare = 1;  					// load engine texture -					// FIXME optimize  					std::stringstream flarename;  					flarename << "bitmaps/fx/flare" << std::setfill('0') << std::setw(2) << engine->flare();  					engine->render_texture = Textures::load(flarename.str()); @@ -425,7 +423,6 @@ void pass_prepare(float seconds)  					Flare *flare = (*flit);  					// load flare texture -					// FIXME optimize  					std::stringstream flarename;  					flarename << "bitmaps/fx/flare" << std::setfill('0') << std::setw(2) << flare->flare();  					flare->render_texture = Textures::load(flarename.str()); @@ -461,7 +458,8 @@ void pass_prepare(float seconds)  			entity->state()->state_visible = true;	  			if (entity->type() == core::Entity::Globe) {  -				core::EntityGlobe *globe = (core::EntityGlobe *) entity; + +				core::EntityGlobe *globe = static_cast<core::EntityGlobe *>(entity);  				if (flag_is_set(globe->flags(), core::Entity::Bright)) { @@ -472,7 +470,7 @@ void pass_prepare(float seconds)  					GLfloat specular_light[] = { 0.2f, 0.2f, 0.2f, 1.0f };  					for (size_t i=0; i <3; i++) { -						light_position[i] = globe->location()[i] - render::Camera::eye()[i]; +						light_position[i] = globe->location()[i];  						diffuse_light[i] = globe->color()[i] * 0.4;  					}  					light_position[3] = 1.0f; @@ -486,11 +484,12 @@ void pass_prepare(float seconds)  				} else {  					// load globe textures -					// FIXME optimize -					if (globe->texture().size()) { +					if (!globe->render_texture && globe->texture().size()) {  						std::stringstream texname;  						texname << "textures/" << globe->texture();  						globe->render_texture = Textures::load(texname.str()); +						if (!globe->render_texture) +							globe->entity_texture.clear();  					}  				}  			}		 @@ -507,7 +506,7 @@ void draw_pass_default()  		// draw entities without model  		if (!entity->model()) {  			gl::push(); -			gl::translate(entity->state()->location() - Camera::eye()); +			gl::translate(entity->state()->location());  			gl::multmatrix(entity->state()->axis());  			if (flag_is_set(entity->flags(), core::Entity::Bright)) { @@ -548,7 +547,7 @@ void draw_pass_default()  			gl::color(entity->color());  			gl::push(); -			gl::translate(entity->state()->location() - Camera::eye()); +			gl::translate(entity->state()->location());  			gl::multmatrix(entity->state()->axis());  			// top @@ -592,7 +591,7 @@ void draw_pass_model_fragments()  		if (entity->model() && entity->state()->visible()) {  			gl::push(); -			gl::translate(entity->state()->location()  - Camera::eye()); +			gl::translate(entity->state()->location());  			gl::multmatrix(entity->state()->axis());  			draw_model_fragments(entity); @@ -645,7 +644,7 @@ void draw_pass_model_fx(float elapsed)  				if (light->strobe())  					t = (core::application()->time() + entity->state()->fuzz() - light->offset()) * light->frequency();  				if ((!light->strobe()) || (( t - floorf(t)) <= light->time())) { -					location.assign(entity->state()->location()  - Camera::eye() + (entity->state()->axis() * light->location())); +					location.assign(entity->state()->location() + (entity->state()->axis() * light->location()));  					light_size = 0.0625 * light->radius();  					if (current_texture != light->texture()) { @@ -688,7 +687,7 @@ void draw_pass_model_fx(float elapsed)  					if (flare->angle())  						flare_axis.change_direction(flare->angle()); -					location.assign(entity->state()->location()  - Camera::eye() + (entity->state()->axis() * flare->location())); +					location.assign(entity->state()->location() + (entity->state()->axis() * flare->location()));  					light_size = 0.0625 * flare->radius();  					if (current_texture != flare->texture()) { @@ -740,7 +739,7 @@ void draw_pass_model_fx(float elapsed)  					for(model::Model::Engines::iterator eit = entity->model()->engines().begin(); eit != entity->model()->engines().end(); eit++) {  						engine = (*eit); -						location.assign(entity->state()->location()  - Camera::eye() + (entity->state()->axis() * engine->location())); +						location.assign(entity->state()->location() + (entity->state()->axis() * engine->location()));  						engine_size = 0.0625 * engine->radius();			  						if (current_texture != engine->texture() ) { @@ -833,7 +832,7 @@ void draw_pass_model_corona()  		if (entity->model() && entity->state()->visible()) {  			gl::push(); -			gl::translate(entity->state()->location()  - Camera::eye()); +			gl::translate(entity->state()->location());  			math::Color color = entity->color();  			color.a = 0.25f;  			draw_sphere(color, entity->model()->radius()); @@ -867,8 +866,8 @@ void draw_pass_sky()  	gl::enable(GL_TEXTURE_2D);  	gl::push(); -	//gl::translate(Camera::eye());	 -	draw_sphere_inside(math::Color(), 128); +	gl::translate(Camera::eye());	 +	draw_sphere_inside(math::Color(), 1016.0f);  	gl::pop();  	gl::disable(GL_TEXTURE_2D); @@ -887,7 +886,7 @@ void draw_pass_spacegrid()  	float dy =  Camera::target().y - floorf(Camera::target().y);  	gl::push(); -	gl::translate(Camera::target() - Camera::eye()); +	gl::translate(Camera::target());  	gl::color(0,0, 1.0f);  	gl::normal(0, 0, 1.0f); diff --git a/src/render/dust.cc b/src/render/dust.cc index d58be1b..96a9d67 100644 --- a/src/render/dust.cc +++ b/src/render/dust.cc @@ -125,18 +125,17 @@ void Dust::draw()  		float dsquare = 0;  		for (size_t j = 0; j < 3; j++) {  			dsquare += (core::localcontrol()->location()[j] - dust[i*3+j]) * (core::localcontrol()->location()[j] - dust[i*3+j]); -			v[j] = dust[i*3+j] - Camera::eye()[j]; +			v[j] = dust[i*3+j] - core::localcontrol()->state()->axis().forward()[j] * traillength;  		}  		if (dsquare > (core::localcontrol()->radius() + DUSTDISTANCE)*(core::localcontrol()->radius() + DUSTDISTANCE)) {  			for (size_t j = 0; j < 3; j++) {  				dust[i*3+j] = core::localcontrol()->location()[j] +  (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius()); -				v[j] = dust[i*3+j] - Camera::eye()[j]; +				v[j] = dust[i*3+j] - core::localcontrol()->state()->axis().forward()[j] * traillength;  			}  		} -		gl::vertex(v); - -		v -= core::localcontrol()->state()->axis().forward() * traillength; +		 +		glVertex3fv(&dust[i*3]);  		gl::vertex(v);  	} diff --git a/src/render/render.cc b/src/render/render.cc index c8c6225..e91be23 100644 --- a/src/render/render.cc +++ b/src/render/render.cc @@ -113,12 +113,17 @@ void shutdown()  		zone->set_sky_texture(0);  	} -	// clear entity models, this will force a reload +	// clear entity models, and globe textures, this will force a reload  	for (core::Entity::Registry::iterator it = core::Entity::registry().begin(); it != core::Entity::registry().end(); it++) {  		core::Entity *entity = (*it).second;  		if (entity->model())  			entity->entity_model = 0; + +		if (entity->type() == core::Entity::Globe) {  +			core::EntityGlobe *globe = static_cast<core::EntityGlobe *>(entity); +			globe->render_texture = 0; +		}  	}  	// clear models  | 
