mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-13 23:11:49 +00:00
add 3d text 'font' property
This commit is contained in:
parent
4295af15cc
commit
3de2a41092
4 changed files with 11 additions and 2 deletions
|
|
@ -162,6 +162,8 @@ static inline void draw_text(
|
||||||
const FontStylesScheme* styles,
|
const FontStylesScheme* styles,
|
||||||
size_t styleMapOffset
|
size_t styleMapOffset
|
||||||
) {
|
) {
|
||||||
|
bool is3d = std::is_same<Batch, Batch3D>();
|
||||||
|
|
||||||
static FontStylesScheme defStyles {{{}}, {0}};
|
static FontStylesScheme defStyles {{{}}, {0}};
|
||||||
|
|
||||||
if (styles == nullptr) {
|
if (styles == nullptr) {
|
||||||
|
|
@ -200,7 +202,7 @@ static inline void draw_text(
|
||||||
if (charpage == page){
|
if (charpage == page){
|
||||||
batch.texture(font.getPage(charpage));
|
batch.texture(font.getPage(charpage));
|
||||||
draw_glyph(
|
draw_glyph(
|
||||||
batch, pos, glm::vec2(x, y - yOffset / static_cast<float>(font.getLineHeight())), c, right, up, interval, style
|
batch, pos, glm::vec2(x, y - yOffset * (is3d ? -1 : 1) / static_cast<float>(font.getLineHeight())), c, right, up, interval, style
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (charpage > page && charpage < next){
|
else if (charpage > page && charpage < next){
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,10 @@ void TextsRenderer::renderNote(
|
||||||
}
|
}
|
||||||
opacity = preset.xrayOpacity;
|
opacity = preset.xrayOpacity;
|
||||||
}
|
}
|
||||||
auto& font = assets.require<Font>(FONT_DEFAULT);
|
|
||||||
|
auto specifiedFont = assets.get<Font>(preset.font);
|
||||||
|
auto& font =
|
||||||
|
specifiedFont ? *specifiedFont : assets.require<Font>(FONT_DEFAULT);
|
||||||
|
|
||||||
glm::vec3 xvec = note.getAxisX();
|
glm::vec3 xvec = note.getAxisX();
|
||||||
glm::vec3 yvec = note.getAxisY();
|
glm::vec3 yvec = note.getAxisY();
|
||||||
|
|
@ -118,6 +121,7 @@ void TextsRenderer::renderNote(
|
||||||
}
|
}
|
||||||
auto color = preset.color;
|
auto color = preset.color;
|
||||||
batch.setColor(glm::vec4(color.r, color.g, color.b, color.a * opacity));
|
batch.setColor(glm::vec4(color.r, color.g, color.b, color.a * opacity));
|
||||||
|
|
||||||
font.draw(
|
font.draw(
|
||||||
batch,
|
batch,
|
||||||
text,
|
text,
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ dv::value NotePreset::serialize() const {
|
||||||
{"render_distance", renderDistance},
|
{"render_distance", renderDistance},
|
||||||
{"xray_opacity", xrayOpacity},
|
{"xray_opacity", xrayOpacity},
|
||||||
{"perspective", perspective},
|
{"perspective", perspective},
|
||||||
|
{"font", font},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -27,4 +28,5 @@ void NotePreset::deserialize(const dv::value& src) {
|
||||||
src.at("render_distance").get(renderDistance);
|
src.at("render_distance").get(renderDistance);
|
||||||
src.at("xray_opacity").get(xrayOpacity);
|
src.at("xray_opacity").get(xrayOpacity);
|
||||||
src.at("perspective").get(perspective);
|
src.at("perspective").get(perspective);
|
||||||
|
src.at("font").get(font);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ struct NotePreset : public Serializable {
|
||||||
float renderDistance = 32.0f;
|
float renderDistance = 32.0f;
|
||||||
float xrayOpacity = 0.0f;
|
float xrayOpacity = 0.0f;
|
||||||
float perspective = 1.0f;
|
float perspective = 1.0f;
|
||||||
|
std::string font {};
|
||||||
|
|
||||||
dv::value serialize() const override;
|
dv::value serialize() const override;
|
||||||
void deserialize(const dv::value& src) override;
|
void deserialize(const dv::value& src) override;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue