block_transform = glm::rotate(block_transform, 3.5f, glm::vec3(1.0f, 0.0f, 0.0f));
block_transform = glm::rotate(block_transform, 0.35f, glm::vec3(0.0f, 1.0f, 0.0f));
- crosshair.vertices = std::vector<glm::vec3>({
+ OutlineModel::Buffer buf;
+ buf.vertices = std::vector<glm::vec3>({
{ -10.0f, 0.0f, 0.0f }, { 10.0f, 0.0f, 0.0f },
{ 0.0f, -10.0f, 0.0f }, { 0.0f, 10.0f, 0.0f },
});
- crosshair.indices = std::vector<OutlineModel::Index>({
+ buf.indices = std::vector<OutlineModel::Index>({
0, 1, 2, 3
});
- crosshair.colors.resize(4, { 10.0f, 10.0f, 10.0f });
- crosshair.Invalidate();
+ buf.colors.resize(4, { 10.0f, 10.0f, 10.0f });
+ crosshair.Update(buf);
block_label.Position(
glm::vec3(50.0f, 85.0f, 0.0f),
const BlockType &type = types.Get(b.type);
block_buf.Clear();
- type.FillModel(block_buf, b.Transform());
+ type.FillEntityModel(block_buf, b.Transform());
block.Update(block_buf);
block_label.Set(font, type.label);
counter_text.Position(glm::vec3(-25.0f, 25.0f, 0.0f), Gravity::NORTH_EAST);
counter_text.Foreground(glm::vec4(1.0f));
counter_text.Background(glm::vec4(0.5f));
+ position_text.Hide();
+ position_text.Position(glm::vec3(-25.0f, 25.0f + font.LineSkip(), 0.0f), Gravity::NORTH_EAST);
+ position_text.Foreground(glm::vec4(1.0f));
+ position_text.Background(glm::vec4(0.5f));
messages.Position(glm::vec3(25.0f, -25.0f, 0.0f), Gravity::SOUTH_WEST);
messages.Foreground(glm::vec4(1.0f));
messages.Background(glm::vec4(0.5f));
ToggleVisual();
break;
case SDLK_F3:
- ToggleCounter();
+ ToggleDebug();
break;
case SDLK_F4:
ToggleAudio();
}
}
-void Interface::ToggleCounter() {
+void Interface::ToggleDebug() {
counter_text.Toggle();
+ position_text.Toggle();
if (counter_text.Visible()) {
UpdateCounter();
+ UpdatePosition();
}
}
counter_text.Set(font, text);
}
+void Interface::UpdatePosition() {
+ std::stringstream s;
+ s << std::setprecision(3) << "pos: " << ctrl.Controlled().AbsolutePosition();
+ position_text.Set(font, s.str());
+}
+
void Interface::Handle(const SDL_MouseMotionEvent &event) {
if (config.mouse_disabled) return;
if (counter_text.Visible() && counter.Changed()) {
UpdateCounter();
}
+ if (position_text.Visible()) {
+ UpdatePosition();
+ }
+}
+
+namespace {
+
+OutlineModel::Buffer outl_buf;
+
}
void Interface::CheckAim() {
float dist;
if (world.Intersection(aim, glm::mat4(1.0f), aim_chunk, aim_block, dist, aim_normal)) {
- outline.Clear();
- aim_chunk->Type(aim_chunk->BlockAt(aim_block)).FillOutlineModel(outline);
+ outl_buf.Clear();
+ aim_chunk->Type(aim_chunk->BlockAt(aim_block)).FillOutlineModel(outl_buf);
+ outline.Update(outl_buf);
outline_transform = glm::scale(glm::vec3(1.0002f));
outline_transform *= aim_chunk->Transform(world.Player().ChunkCoords());
outline_transform *= aim_chunk->ToTransform(Chunk::ToPos(aim_block), aim_block);
if (counter_text.Visible()) {
counter_text.Render(viewport);
}
+ if (position_text.Visible()) {
+ position_text.Render(viewport);
+ }
if (msg_timer.Running()) {
messages.Render(viewport);