add text3d.get_axis_x, .set_axis_x, .get_axis_y, .set_axis_y
This commit is contained in:
parent
525cf1ed4b
commit
a8388a6243
@ -28,10 +28,10 @@ function on_hud_open()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
note = gfx.text3d.new({0.5, 99.5, 0.0015}, "Segmentation fault", {
|
note = gfx.text3d.new({0.5, 99.5, 0.0015}, "Segmentation fault", {
|
||||||
|
scale=0.005,
|
||||||
color={0, 0, 0, 1},
|
color={0, 0, 0, 1},
|
||||||
display="projected",
|
display="static_billboard",
|
||||||
perspective=1.0,
|
xray_opacity=0.2
|
||||||
scale=2.0
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -29,3 +29,19 @@ void TextNote::setPosition(const glm::vec3& position) {
|
|||||||
const glm::vec3& TextNote::getPosition() const {
|
const glm::vec3& TextNote::getPosition() const {
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const glm::vec3& TextNote::getAxisX() const {
|
||||||
|
return xAxis;
|
||||||
|
}
|
||||||
|
|
||||||
|
const glm::vec3& TextNote::getAxisY() const {
|
||||||
|
return yAxis;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextNote::setAxisX(const glm::vec3& vec) {
|
||||||
|
xAxis = vec;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextNote::setAxisY(const glm::vec3& vec) {
|
||||||
|
yAxis = vec;
|
||||||
|
}
|
||||||
|
|||||||
@ -7,6 +7,9 @@ class TextNote {
|
|||||||
std::wstring text;
|
std::wstring text;
|
||||||
NotePreset preset;
|
NotePreset preset;
|
||||||
glm::vec3 position;
|
glm::vec3 position;
|
||||||
|
|
||||||
|
glm::vec3 xAxis {1, 0, 0};
|
||||||
|
glm::vec3 yAxis {0, 1, 0};
|
||||||
public:
|
public:
|
||||||
TextNote(std::wstring text, NotePreset preset, glm::vec3 position);
|
TextNote(std::wstring text, NotePreset preset, glm::vec3 position);
|
||||||
|
|
||||||
@ -19,6 +22,11 @@ public:
|
|||||||
void updatePreset(const dv::value& data);
|
void updatePreset(const dv::value& data);
|
||||||
|
|
||||||
void setPosition(const glm::vec3& position);
|
void setPosition(const glm::vec3& position);
|
||||||
|
|
||||||
const glm::vec3& getPosition() const;
|
const glm::vec3& getPosition() const;
|
||||||
|
|
||||||
|
const glm::vec3& getAxisX() const;
|
||||||
|
const glm::vec3& getAxisY() const;
|
||||||
|
|
||||||
|
void setAxisX(const glm::vec3& vec);
|
||||||
|
void setAxisY(const glm::vec3& vec);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -47,8 +47,8 @@ void TextsRenderer::renderNote(
|
|||||||
}
|
}
|
||||||
const auto& font = assets.require<Font>("normal");
|
const auto& font = assets.require<Font>("normal");
|
||||||
|
|
||||||
glm::vec3 xvec {1, 0, 0};
|
glm::vec3 xvec = note.getAxisX();
|
||||||
glm::vec3 yvec {0, 1, 0};
|
glm::vec3 yvec = note.getAxisY();
|
||||||
|
|
||||||
int width = font.calcWidth(text, text.length());
|
int width = font.calcWidth(text, text.length());
|
||||||
if (preset.displayMode == NoteDisplayMode::Y_FREE_BILLBOARD ||
|
if (preset.displayMode == NoteDisplayMode::Y_FREE_BILLBOARD ||
|
||||||
|
|||||||
@ -48,7 +48,6 @@ static int l_get_pos(lua::State* L) {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_set_pos(lua::State* L) {
|
static int l_set_pos(lua::State* L) {
|
||||||
if (auto note = renderer->texts->get(lua::tointeger(L, 1))) {
|
if (auto note = renderer->texts->get(lua::tointeger(L, 1))) {
|
||||||
note->setPosition(lua::tovec3(L, 2));
|
note->setPosition(lua::tovec3(L, 2));
|
||||||
@ -56,6 +55,33 @@ static int l_set_pos(lua::State* L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_get_axis_x(lua::State* L) {
|
||||||
|
if (auto note = renderer->texts->get(lua::tointeger(L, 1))) {
|
||||||
|
return lua::pushvec(L, note->getAxisX());
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static int l_set_axis_x(lua::State* L) {
|
||||||
|
if (auto note = renderer->texts->get(lua::tointeger(L, 1))) {
|
||||||
|
note->setAxisX(lua::tovec3(L, 2));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int l_get_axis_y(lua::State* L) {
|
||||||
|
if (auto note = renderer->texts->get(lua::tointeger(L, 1))) {
|
||||||
|
return lua::pushvec(L, note->getAxisY());
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static int l_set_axis_y(lua::State* L) {
|
||||||
|
if (auto note = renderer->texts->get(lua::tointeger(L, 1))) {
|
||||||
|
note->setAxisY(lua::tovec3(L, 2));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int l_update_settings(lua::State* L) {
|
static int l_update_settings(lua::State* L) {
|
||||||
if (auto note = renderer->texts->get(lua::tointeger(L, 1))) {
|
if (auto note = renderer->texts->get(lua::tointeger(L, 1))) {
|
||||||
note->updatePreset(lua::tovalue(L, 2));
|
note->updatePreset(lua::tovalue(L, 2));
|
||||||
@ -70,6 +96,10 @@ const luaL_Reg text3dlib[] = {
|
|||||||
{"set_text", lua::wrap<l_set_text>},
|
{"set_text", lua::wrap<l_set_text>},
|
||||||
{"get_pos", lua::wrap<l_get_pos>},
|
{"get_pos", lua::wrap<l_get_pos>},
|
||||||
{"set_pos", lua::wrap<l_set_pos>},
|
{"set_pos", lua::wrap<l_set_pos>},
|
||||||
|
{"get_axis_x", lua::wrap<l_get_axis_x>},
|
||||||
|
{"set_axis_x", lua::wrap<l_set_axis_x>},
|
||||||
|
{"get_axis_y", lua::wrap<l_get_axis_y>},
|
||||||
|
{"set_axis_y", lua::wrap<l_set_axis_y>},
|
||||||
{"update_settings", lua::wrap<l_update_settings>},
|
{"update_settings", lua::wrap<l_update_settings>},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user