OpenScadRenderer.cpp 921 B

1234567891011121314151617181920212223242526
  1. // Include own headers
  2. #include "OpenScadRenderer.hpp"
  3. // Include dependencies
  4. #include <iostream>
  5. #include <fstream>
  6. const char* openScadBase =
  7. "$fn = 100;\n"
  8. "module optiTrackPointBase(translation, rotation) {\n"
  9. "translate(translation) rotate(rotation) cylinder(10, 1, 1, false);\n"
  10. "}\n";
  11. void OpenScadRenderer::render(std::vector<TrackPoint*> points) {
  12. std::ofstream scadFile;
  13. scadFile.open("/tmp/output.scad");
  14. scadFile << openScadBase;
  15. scadFile << "import(\"testbutton.stl\");\n";
  16. for (TrackPoint* point: points) {
  17. osg::Vec3 translation = point->getTranslation();
  18. osg::Vec3 rotation = point->getRotation();
  19. scadFile << "optiTrackPointBase([" << translation.x() << "," << translation.y() << "," << translation.z() << "], [" << rotation.x() << "," << rotation.y() << "," << rotation.z() << "]);\n";
  20. }
  21. scadFile.close();
  22. system("openscad -o /tmp/output.3mf /tmp/output.scad");
  23. }