Skip to content

Commit

Permalink
mesh editor clear and export normalised
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerboa-app committed Dec 14, 2023
1 parent 7f79d6d commit 203cfea
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tools/meshEditor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,32 @@ int main(int argc, char ** argv)
if (display.getEvent(GLFW_KEY_G).type == Hop::Display::EventType::PRESS) { grid = !grid; }
if (display.getEvent(GLFW_KEY_SPACE).type == Hop::Display::EventType::PRESS) { paused = !paused; }

if (display.getEvent(GLFW_KEY_C).type == Hop::Display::EventType::PRESS)
{
unsigned n = object.mesh.size();
for (unsigned i = 0; i < n; i++)
{
object.mesh.remove(0);
}
}

if (display.getEvent(GLFW_KEY_E).type == Hop::Display::EventType::PRESS)
{
double x = 0.0;
double y = 0.0;
for (unsigned i = 0; i < object.mesh.size(); i++)
{
x += object.mesh.getModelVertex(i)->x;
y += object.mesh.getModelVertex(i)->y;
}
x /= object.mesh.size();
y /= object.mesh.size();
std::ofstream file("mesh");
file << "{\n";
for (unsigned i = 0; i < object.mesh.size(); i++)
{
file << " {" << object.mesh.getModelVertex(i)->x
<< ", " << object.mesh.getModelVertex(i)->y
file << " {" << object.mesh.getModelVertex(i)->x - x
<< ", " << object.mesh.getModelVertex(i)->y - y
<< ", " << object.mesh.getModelVertex(i)->r
<< "}";

Expand Down

0 comments on commit 203cfea

Please sign in to comment.