1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/*
client/rader.cc
This file is part of the Osirion project and is distributed under
the terms of the GNU General Public License version 2
*/
#include "auxiliary/functions.h"
#include "core/core.h"
#include "client/radar.h"
#include "client/video.h"
#include "render/draw.h"
#include "render/render.h"
#include "render/text.h"
namespace client
{
void Radar::draw() {
using namespace render;
if (!core::localcontrol())
return;
float y = 4 + Text::fontheight();
Text::draw(4, y, "^N------------ ^BRadar test ^N--------------");
y += Text::fontheight();
gl::color(1.0f, 1.0f, 1.0f, 1.0f);
std::map<unsigned int, core::Entity *>::iterator it;
for (it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
core::Entity *entity = (*it).second;
core::ClientState *state = entity->state();
if (state && state->targetable() && entity->label().size()) {
gl::color(entity->color());
std::ostringstream line;
line << aux::pad_right(entity->name(), 24) <<
state->state_screenlocation[0] << " " <<
state->state_screenlocation[1] << " " <<
state->state_screenlocation[2] << " ";
Text::draw(4, y, line.str());
y += Text::fontheight();
}
}
}
/*
void Radar::draw()
{
using namespace render;
if (!core::localcontrol())
return;
const float width = (float) video::width/4;
const float height = (float) video::height/4;
const float margin = 16;
const float xscale = 128;
const float yscale = xscale * height / width;
const float left = video::width - margin - width;
const float top = video::height -margin - height;
gl::disable(GL_TEXTURE_2D);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
//glEnableClientState(GL_COLOR_ARRAY);
// draw the transparent radar background
gl::color(0.0f, 0.0f, 0.0f, 0.2f);
gl::begin(gl::Quads);
gl::vertex(left, top, 0.0f);
gl::vertex(left + width, top, 0.0f);
gl::vertex(left + width, top + height, 0.0f);
gl::vertex(left, top + height, 0.0f);
gl::end();
math::Vector3f center(core::localcontrol()->location());
gl::begin(gl::Points);
std::map<unsigned int, core::Entity *>::iterator it;
for (it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
core::Entity *entity = (*it).second;
math::Vector3f position(entity->state()->location() - center);
if ((position.x > -yscale) && (position.x < yscale) && (position.y > -xscale) && (position.y < xscale)) {
float x = left + width/2 - position.y / xscale * width/2;
float y = top + height/2 - position.x / xscale * width/2;
if (entity->type() == core::Entity::Globe) {
gl::end();
gl::push();
gl::translate(x, y, 0);
float r = entity->radius() / xscale * width/2;
draw_sphere(entity->color(), r);
gl::pop();
gl::begin(gl::Points);
} else {
gl::color(entity->color());
gl::vertex(x , y , 0);
}
}
}
gl::end();
gl::enable(GL_TEXTURE_2D);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
//glDisableClientState(GL_COLOR_ARRAY);
}
*/
}
|