diff options
| author | Stijn Buys <ingar@osirion.org> | 2008-05-10 21:44:58 +0000 | 
|---|---|---|
| committer | Stijn Buys <ingar@osirion.org> | 2008-05-10 21:44:58 +0000 | 
| commit | 17e9ce54ee3972b9804174b874652ec0856efcd0 (patch) | |
| tree | 33ec140d65fdcf42a467e3903647efc1be0d4e02 /src | |
| parent | d3afb677b6ea5942c042b8a83aa5d9ace1dec787 (diff) | |
interpolation & oscilating debugging
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/camera.cc | 48 | ||||
| -rw-r--r-- | src/game/ship.cc | 33 | ||||
| -rw-r--r-- | src/render/draw.cc | 2 | 
3 files changed, 53 insertions, 30 deletions
| diff --git a/src/client/camera.cc b/src/client/camera.cc index 28f60c5..c4a60b0 100644 --- a/src/client/camera.cc +++ b/src/client/camera.cc @@ -178,28 +178,43 @@ void draw(float seconds)  		}  		if (mode == Track) { - 			if (core::localcontrol()->state() && core::localcontrol()->model()) -				target += core::localcontrol()->model()->maxbbox().x * core::localcontrol()->state()->axis().forward(); + 			if (core::localcontrol()->state() && core::localcontrol()->model()) { +				target -= (core::localcontrol()->model()->maxbbox().x + 0.1f) * core::localcontrol()->state()->axis().forward(); + +				target += (core::localcontrol()->model()->maxbbox().z + 0.3f ) * +				core::localcontrol()->state()->axis().up(); +			}  			// make the camera swing while turning  			target_direction = core::localcontrol()->target_direction; -			pitch_target = core::localcontrol()->target_pitch; +			target_pitch = core::localcontrol()->target_pitch; + +			yaw_target =  - 30 * target_direction; +			pitch_target = - 30 * target_pitch; +			//pitch_target = pitch_track - 30 * target_pitch; -			yaw_target =  - 25 * target_direction; -			pitch_target = pitch_track - 25 * target_pitch; +			distance = 0.0f;  		} else if (mode == Free) {  			yaw_target =  yaw_current - 90 * target_direction;  			pitch_target = pitch_current - 90 * target_pitch; + +			if (core::localcontrol()->model()) { +				distance = core::localcontrol()->model()->radius(); +			} else { +				distance = 1.0f; +			}  		} else if (mode == Cockpit) {  			if (core::localcontrol()->state() && core::localcontrol()->model()) -				target += core::localcontrol()->model()->maxbbox().x * core::localcontrol()->state()->axis().forward(); +				target += core::localcontrol()->model()->maxbbox().x * +					 core::localcontrol()->state()->axis().forward(); +			 +			distance = 0.0f;  		} -  		if (mode != Cockpit) {  			// adjust direction  			d = degrees180f(yaw_current - yaw_target); @@ -210,11 +225,6 @@ void draw(float seconds)  			d = degrees180f(pitch_current - pitch_target);  			pitch_current = degrees360f(pitch_current -  d *seconds);  			axis.change_pitch(pitch_current); -		 -			if (core::localcontrol()->model())  -				distance = 1+core::localcontrol()->model()->radius(); -			else -				distance = 1.5f;  		}  	} @@ -231,15 +241,13 @@ void draw(float seconds)  	// match the camera with the current target  	gl::translate(-1.0f * target); -	if (mode != Cockpit) { -		// apply camera offset -		gl::translate((1.0f+distance) * axis.forward()); +	// apply camera offset +	gl::translate((1.0 + distance) * axis.forward()); + +	// calculate eye position +	eye = target - ((1.0f+distance) * axis.forward()); +	eye.assign(target); -		// calculate eye position -		eye = target - ((1.0f+distance) * axis.forward()); -	} else { -		eye.assign(target); -	}  }  void set_direction(float direction) diff --git a/src/game/ship.cc b/src/game/ship.cc index 525bf71..5c36205 100644 --- a/src/game/ship.cc +++ b/src/game/ship.cc @@ -47,12 +47,17 @@ void Ship::frame(float seconds)  	// update pitch  	math::clamp(target_pitch, -1.0f, 1.0f); -	if (current_target_pitch - target_pitch < 0) { +	if (current_target_pitch < target_pitch) {  		current_target_pitch += direction_change_speed * seconds; -	} else if (current_target_pitch - target_pitch > 0) { +		if (current_target_pitch > target_pitch) +			current_target_pitch = target_pitch; +	} else if (current_target_pitch > target_pitch) {  		current_target_pitch -= direction_change_speed * seconds; +		if (current_target_pitch < target_pitch) +			current_target_pitch = target_pitch;  	} -	if (fabs(current_target_pitch) < direction_change_speed * seconds) { +	 +	if (fabs(seconds*current_target_pitch) < 0.00005f) {  		current_target_pitch = 0.0f;  	} else {  		math::clamp(current_target_pitch, -1.0f, 1.0f); @@ -62,12 +67,18 @@ void Ship::frame(float seconds)  	// update direction  	math::clamp(target_direction, -1.0f, 1.0f); -	if (current_target_direction - target_direction < 0) { +	if (current_target_direction < target_direction) {  		current_target_direction += direction_change_speed * seconds; -	} else if (current_target_direction - target_direction > 0) { +		if (current_target_direction > target_direction) { +			current_target_direction = target_direction; +		} +	} else if (current_target_direction > target_direction) {  		current_target_direction -= direction_change_speed * seconds; +		if (current_target_direction < target_direction) { +			current_target_direction = target_direction; +		}  	} -	if (fabs(current_target_direction) < direction_change_speed * seconds) { +	if (fabs(seconds*current_target_direction) < 0.00005f) {  		current_target_direction = 0.0f;  	} else {  		math::clamp(current_target_direction, -1.0f, 1.0f); @@ -77,12 +88,16 @@ void Ship::frame(float seconds)  	// update roll  	math::clamp(target_roll, -1.0f, 1.0f); -	if (current_target_roll - target_roll < 0) { +	if (current_target_roll < target_roll) {  		current_target_roll += direction_change_speed * seconds; -	} else if (current_target_roll - target_roll > 0) { +		if (current_target_roll > target_roll) +			current_target_roll = target_roll; +	} else if (current_target_roll > target_roll) {  		current_target_roll -= direction_change_speed * seconds; +		if (current_target_roll < target_roll) +			current_target_roll = target_roll;  	} -	if (fabs(current_target_roll) < direction_change_speed * seconds) { +	if (fabs(current_target_roll) < 0.00005f) {  		current_target_roll = 0.0f;  	} else {  		math::clamp(current_target_roll, -1.0f, 1.0f); diff --git a/src/render/draw.cc b/src/render/draw.cc index 7a780bf..e2037e2 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -515,7 +515,7 @@ void draw_pass_model_corona()  	for (std::map<unsigned int, core::Entity *>::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {  		core::Entity *entity = (*it).second; -		if ((entity->shape() != core::Entity::Sphere) && entity->state() && entity->state()->visible()) { +		if (entity->model() && entity->state() && entity->state()->visible()) {  			gl::push();  			gl::translate(entity->state()->location());  			math::Color color = entity->color(); | 
