diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/targets.cc | 59 | ||||
| -rw-r--r-- | src/client/view.cc | 10 | ||||
| -rw-r--r-- | src/math/axis.cc | 8 | ||||
| -rw-r--r-- | src/math/axis.h | 3 | 
4 files changed, 63 insertions, 17 deletions
diff --git a/src/client/targets.cc b/src/client/targets.cc index 8dc5c07..e140df2 100644 --- a/src/client/targets.cc +++ b/src/client/targets.cc @@ -10,6 +10,7 @@  #include <iomanip>  #include "audio/audio.h" +#include "auxiliary/functions.h"  #include "audio/sources.h"  #include "client/input.h"  #include "client/view.h" @@ -18,6 +19,7 @@  #include "core/entity.h"  #include "core/func.h"  #include "core/gameinterface.h" +#include "math/axis.h"  #include "math/vector3f.h"  #include "render/gl.h"  #include "render/render.h" @@ -347,6 +349,8 @@ void draw_target()  	core::Entity *entity = current_target; +	 +  	// if target is in visible space  	Vector3f v(entity->state()->location() - render::Camera::eye());  	v.normalize(); @@ -364,17 +368,58 @@ void draw_target()  			+ plane_normal.y * (entity->state()->location().y - render::Camera::eye().y)  			+ plane_normal.z * (entity->state()->location().z - render::Camera::eye().z); -		Vector3f intersection = render::Camera::eye() + (entity->state()->location() - render::Camera::eye()) * t; +		//Vector3f intersection = render::Camera::eye() + (entity->state()->location() - render::Camera::eye()) * t; +		//intersection -=  render::Camera::eye() +		Vector3f intersection =  (entity->state()->location() - render::Camera::eye()) * t; + +		Vector3f center(render::Camera::axis().transpose()*intersection); + +		float cx = video::width * (0.5 - center.y); +		float cy = video::height * (0.5 - center.z  * render::Camera::aspect()); + +		const float pointer_size = 48.0f; +		const float r = pointer_size; + +		render::gl::disable(GL_TEXTURE_2D); + +		render::gl::color(0, 0, 0, 1); +		render::gl::begin(render::gl::LineLoop); +		glVertex3f(cx+r, cy+2, 0); +		glVertex3f(cx, cy+r+2, 0); +		glVertex3f(cx-r, cy+2, 0); +		glVertex3f(cx, cy-r+2, 0); +		render::gl::end(); -		// draw the target cursor in the frustum front plane, but in real world coordinates -		const float r = 0.05;  		render::gl::color(1, 1, 1, 1);  		render::gl::begin(render::gl::LineLoop); -		render::gl::vertex(intersection + render::Camera::axis().up() * r); -		render::gl::vertex(intersection + render::Camera::axis().left() * r); -		render::gl::vertex(intersection - render::Camera::axis().up() * r); -		render::gl::vertex(intersection - render::Camera::axis().left() * r); +		glVertex3f(cx+r, cy, 0); +		glVertex3f(cx, cy+r, 0); +		glVertex3f(cx-r, cy, 0); +		glVertex3f(cx, cy-r, 0);  		render::gl::end(); +		 +		render::gl::enable(GL_TEXTURE_2D); + +		std::stringstream str; + +		// entity name	 +		render::Text::setcolor('B'); +		render::Text::draw(cx-aux::text_length(entity->name()) * render::Text::fontwidth()*0.5f, cy-r-4- render::Text::fontheight(), entity->name()); +	 + +		d = math::distance(core::localcontrol()->location(), entity->state()->location()) - entity->radius() - core::localcontrol()->radius(); +		if (d > 0 ) { +			if (d > 100) { +				str << roundf(d * 0.1f) << "km"; +			} else { +				str << roundf(d * 100.0f) << "m"; +			} +		} else { +			str << "--"; +		} +		render::Text::setcolor('B'); +		render::Text::draw(cx - aux::text_length(str.str()) * render::Text::fontwidth() * 0.5f, cy - render::Text::fontheight() * 0.5f, str); +  	}  } diff --git a/src/client/view.cc b/src/client/view.cc index 6c792d6..4fe7a33 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -214,7 +214,7 @@ void draw_cursor()  		return;  	float angle = 0; -	float pointer_size = 48.0f; +	const float pointer_size = 48.0f;  	float x = (float) input::mouse_position_x() - (pointer_size / 2.0f);  	float y = (float) input::mouse_position_y() - (pointer_size / 2.0f);  	bool cursor_animated = false; @@ -392,9 +392,6 @@ void frame(float seconds)  	if (core::application()->connected() && core::game()->serverframetime()) {  		render::draw(seconds);		// draw the world  		targets::frame(); -		if (draw_ui->value()) { -			targets::draw_target(); -		}  	}  	// switch to orthographic projection to draw the GUI @@ -423,7 +420,10 @@ void frame(float seconds)  	// draw text elements  	if (draw_ui->value()) {  		Text::setfont("bitmaps/fonts/gui", 12, 18); -		 + +		// draw the current target selection	 +		targets::draw_target(); +  		// draw the player status  		draw_status();		 diff --git a/src/math/axis.cc b/src/math/axis.cc index aa35d92..e6442eb 100644 --- a/src/math/axis.cc +++ b/src/math/axis.cc @@ -91,17 +91,15 @@ void Axis::rotate(Vector3f const &normal, float angle)  	}  } -/* -Axis const Axis::transpose() +Axis Axis::transpose() const  { -	Axis` t; +	Axis t;  	for (size_t i = 0; i < 3; i++)  		for (size_t j = 0; j < 3; j++) -			t.axis_vector[j][i] = axis_vector[j][i]; +			t.axis_vector[i][j] = axis_vector[j][i];  	return t;  } -*/  // write an axis to a std::ostream  std::ostream &operator<<(std::ostream & os, Axis const & axis) diff --git a/src/math/axis.h b/src/math/axis.h index 1422564..1396521 100644 --- a/src/math/axis.h +++ b/src/math/axis.h @@ -51,6 +51,9 @@ public:  	/// rotation about an arbitrary axis  	void rotate(Vector3f const &normal, float angle); +	/// return the transpose of this matrix +	Axis transpose() const; +  private:  	Vector3f		axis_vector[3];  };  | 
