2023-01-15 17:01:27 +00:00
|
|
|
#include "FileParser.h"
|
|
|
|
#include "../shape/Line.h"
|
|
|
|
|
|
|
|
FileParser::FileParser() {}
|
|
|
|
|
2023-01-15 22:34:02 +00:00
|
|
|
void FileParser::parse(juce::String extension, std::unique_ptr<juce::InputStream> stream) {
|
|
|
|
if (extension == ".obj") {
|
2023-01-20 23:41:37 +00:00
|
|
|
object = std::make_unique<WorldObject>(stream->readEntireStreamAsString().toStdString());
|
2023-01-19 20:46:41 +00:00
|
|
|
camera = std::make_unique<Camera>(1.0, 0, 0, 0.0);
|
|
|
|
camera->findZPos(*object);
|
2023-01-15 22:34:02 +00:00
|
|
|
}
|
2023-01-15 17:01:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<Shape>> FileParser::next() {
|
2023-01-15 22:34:02 +00:00
|
|
|
if (object != nullptr && camera != nullptr) {
|
|
|
|
return camera->draw(*object);
|
|
|
|
}
|
2023-01-15 17:01:27 +00:00
|
|
|
auto shapes = std::vector<std::unique_ptr<Shape>>();
|
|
|
|
shapes.push_back(std::make_unique<Line>(0.0, 0.0, 1.0, 1.0));
|
|
|
|
return shapes;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FileParser::isActive() {
|
|
|
|
return active;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FileParser::disable() {
|
|
|
|
active = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FileParser::enable() {
|
|
|
|
active = true;
|
|
|
|
}
|