Skip to content
Snippets Groups Projects
Commit 8c158d48 authored by Pascal Engeler's avatar Pascal Engeler
Browse files

Fixed leveler

parent baef481f
No related branches found
No related tags found
No related merge requests found
......@@ -44,7 +44,6 @@ int main(int argc, char** argv) {
std::cout << "Loading Heightmap" << std::endl << std::flush;
heightmaps.push_back(ResourceManager::fetch_heightmap(std::string(HEIGHTMAP_LOC)+"drum1.asc"));
float zRangeUmReference = heightmaps.back()->zRangeUm();
positions.push_back(glm::vec3(-0.5, -0.5, 0));
positions.push_back(glm::vec3(0.0, 0.0, 0));
models.push_back(glm::translate(scale_z(heightmaps.back()->minZ(), scale), positions.back()));
std::cout << "Loading complete" << std::endl << std::flush;
......@@ -138,7 +137,7 @@ int main(int argc, char** argv) {
}
ImGui::BeginTooltip();
std::string tool_tip_str = "Height (";
tool_tip_str += (height_measured != NOT_ON_SURFACE) ? std::to_string(hmap_hovered_index) + "): " : "-1";
tool_tip_str += (height_measured != NOT_ON_SURFACE) ? std::to_string(hmap_hovered_index) + "): " : "-1): ";
tool_tip_str += (height_measured != NOT_ON_SURFACE) ? std::to_string(height_measured) + " um" : "N/A";
ImGui::Text(tool_tip_str.c_str());
ImGui::EndTooltip();
......@@ -151,7 +150,18 @@ int main(int argc, char** argv) {
//get highlighting point
glm::vec2 mowopos = camera.GetWorldXyFromMouse(InputState::mpos_x, InputState::mpos_y);
if (InputState::lmb_click && height_measured != NOT_ON_SURFACE) {//Have new point
Leveler::place(mowopos);
//transform coordinates from world to model
glm::vec4 p_world(mowopos[0], mowopos[1], 0.f, 1.f);
glm::vec4 p_model = glm::inverse(models[hmap_hovered_index]) * p_world;
p_model[2] = heightmaps[hmap_hovered_index]->getAverageSurfaceHeight(glm::vec2(p_model[0], p_model[1]));
p_world = models[hmap_hovered_index] * p_model;
Leveler::place(glm::vec3(p_world[0], p_world[1], p_world[2]), glm::inverse(models[hmap_hovered_index]));
if (Leveler::transformationValid) {
models[hmap_hovered_index] = Leveler::transformation * models[hmap_hovered_index];
heightmaps[hmap_hovered_index]->setZRangeUmOffset(height_measured);
heightmaps[hmap_hovered_index]->calculateNewZRange(Leveler::rotation);
heightmaps[hmap_hovered_index]->setModelspaceRot(Leveler::rotation);
}
}
for (auto heightmap : heightmaps) { //highlight selection
heightmap->enableHighlighting(mowopos);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment