patterns: Added rotation and scale sliders to 3D visualizer
This commit is contained in:
parent
6cecc12d04
commit
35437c0300
2
lib/external/pattern_language
vendored
2
lib/external/pattern_language
vendored
@ -1 +1 @@
|
||||
Subproject commit 0df8fabdbf2ef22bcae2cbb717454245d8fa44ba
|
||||
Subproject commit 58e115e621687506a822378529f83deb773005fa
|
@ -75,6 +75,13 @@ namespace hex::gl {
|
||||
return copy;
|
||||
}
|
||||
|
||||
auto operator==(const Vector<T, Size>& other) {
|
||||
for (size_t i = 0; i < Size; i++)
|
||||
if (this->m_data[i] != other[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
std::array<T, Size> m_data;
|
||||
};
|
||||
|
@ -54,6 +54,7 @@
|
||||
"hex.builtin.common.range.entire_data": "Entire Data",
|
||||
"hex.builtin.common.range.selection": "Selection",
|
||||
"hex.builtin.common.region": "Region",
|
||||
"hex.builtin.common.reset": "Reset",
|
||||
"hex.builtin.common.set": "Set",
|
||||
"hex.builtin.common.size": "Size",
|
||||
"hex.builtin.common.type": "Type",
|
||||
@ -344,6 +345,8 @@
|
||||
"hex.builtin.pattern_drawer.var_name": "Name",
|
||||
"hex.builtin.pattern_drawer.visualizer.unknown": "Unknown visualizer",
|
||||
"hex.builtin.pattern_drawer.visualizer.invalid_parameter_count": "Invalid parameter count",
|
||||
"hex.builtin.pl_visualizer.3d.rotation": "Rotation",
|
||||
"hex.builtin.pl_visualizer.3d.scale": "Scale",
|
||||
"hex.builtin.popup.close_provider.desc": "There are unsaved changes made to this Provider\nthat haven't been saved to a Project yet.\n\nAre you sure you want to close it?",
|
||||
"hex.builtin.popup.close_provider.title": "Close Provider?",
|
||||
"hex.builtin.popup.error.create": "Failed to create new file!",
|
||||
|
@ -184,11 +184,14 @@ namespace hex::plugin::builtin {
|
||||
auto indicesPattern = arguments[1].toPattern();
|
||||
|
||||
static ImGui::Texture texture;
|
||||
static float scaling = 0.5F;
|
||||
static gl::Vector<float, 3> rotation = { { 1.0F, -1.0F, 0.0F } };
|
||||
|
||||
static gl::Vector<float, 3> translation;
|
||||
static gl::Vector<float, 3> rotation = { { 1.0F, -1.0F, 0.0F } };
|
||||
static float scaling = 0.1F;
|
||||
|
||||
static std::vector<float> vertices, normals;
|
||||
static std::vector<u32> indices;
|
||||
|
||||
static gl::Shader shader;
|
||||
static gl::VertexArray vertexArray;
|
||||
static gl::Buffer<float> vertexBuffer, normalBuffer;
|
||||
@ -264,7 +267,7 @@ namespace hex::plugin::builtin {
|
||||
{
|
||||
gl::FrameBuffer frameBuffer;
|
||||
|
||||
gl::Texture renderTexture(512, 512);
|
||||
gl::Texture renderTexture(400_scaled, 400_scaled);
|
||||
frameBuffer.attachTexture(renderTexture);
|
||||
|
||||
frameBuffer.bind();
|
||||
@ -298,7 +301,54 @@ namespace hex::plugin::builtin {
|
||||
texture = ImGui::Texture(renderTexture.release(), renderTexture.getWidth(), renderTexture.getHeight());
|
||||
}
|
||||
|
||||
ImGui::Image(texture, texture.getSize(), ImVec2(0, 1), ImVec2(1, 0));
|
||||
auto textureSize = texture.getSize();
|
||||
|
||||
if (ImGui::BeginTable("##3DVisualizer", 2, ImGuiTableFlags_SizingFixedFit)) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
if (ImGui::BeginChild("##image", textureSize, true, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
|
||||
ImGui::Image(texture, textureSize, ImVec2(0, 1), ImVec2(1, 0));
|
||||
}
|
||||
ImGui::EndChild();
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted("hex.builtin.pl_visualizer.3d.rotation"_lang);
|
||||
ImGui::VSliderFloat("##X", ImVec2(18_scaled, textureSize.y), &rotation.data()[0], 0, std::numbers::pi * 2, "", ImGuiSliderFlags_AlwaysClamp);
|
||||
ImGui::SameLine();
|
||||
ImGui::VSliderFloat("##Y", ImVec2(18_scaled, textureSize.y), &rotation.data()[1], 0, std::numbers::pi * 2, "", ImGuiSliderFlags_AlwaysClamp);
|
||||
ImGui::SameLine();
|
||||
ImGui::VSliderFloat("##Z", ImVec2(18_scaled, textureSize.y), &rotation.data()[2], 0, std::numbers::pi * 2, "", ImGuiSliderFlags_AlwaysClamp);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::TextUnformatted("hex.builtin.pl_visualizer.3d.scale"_lang);
|
||||
ImGui::SameLine();
|
||||
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x);
|
||||
ImGui::SliderFloat("##Scale", &scaling, 0.0001F, 0.2F, "");
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
for (u8 i = 0; i < 3; i++) {
|
||||
while (rotation.data()[i] > std::numbers::pi * 2)
|
||||
rotation.data()[i] -= std::numbers::pi * 2;
|
||||
while (rotation.data()[i] < 0)
|
||||
rotation.data()[i] += std::numbers::pi * 2;
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
if (ImGui::Button("hex.builtin.common.reset"_lang, ImVec2(ImGui::GetContentRegionAvail().x, 0))) {
|
||||
translation = gl::Vector<float, 3>({ 0.0F, 0.0F, 0.0F });
|
||||
rotation = gl::Vector<float, 3>({ 0.0F, 0.0F, 0.0F });
|
||||
scaling = 0.1F;
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void drawSoundVisualizer(pl::ptrn::Pattern &, pl::ptrn::Iteratable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
|
Loading…
Reference in New Issue
Block a user