X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Fmqo.cpp;h=7c6ff3c499b40695b32877abbdbbe5a19aaee045;hb=4b7b856e70fe8047f985e2598020032d0d87a672;hp=982d47df777d78a81d958d670e68b309e0539cc2;hpb=1c78f8bbdfe52be741185762123fba2c169d738a;p=meshio%2Fmeshio.git diff --git a/src/mqo.cpp b/src/mqo.cpp index 982d47d..7c6ff3c 100644 --- a/src/mqo.cpp +++ b/src/mqo.cpp @@ -1,11 +1,33 @@ #include "mqo.h" #include #include +#include +#include #include +#include "text.h" + namespace meshio { namespace mqo { +std::wstring + Material::getName()const + { + return text::trim(text::to_WideChar(CP_OEMCP, name)); + } + +std::wstring + Material::getTexture()const + { + return text::trim(text::to_WideChar(CP_OEMCP, texture)); + } + +std::wstring + Object::getName()const + { + return text::trim(text::to_WideChar(CP_OEMCP, name)); + } + //! Tokenizer struct DELIMITER { @@ -14,6 +36,7 @@ struct DELIMITER switch(c) { case ' ': + case '\t': case '(': case ')': return true; @@ -63,7 +86,7 @@ public: else if(key=="Eof"){ if(materials.empty()){ // fallback - materials.push_back(Material()); + //materials.push_back(Material()); } return true; } @@ -138,6 +161,9 @@ private: // ToDo continue; } + else if(key=="mirror"){ + object.mirror=splitter.getInt(); + } else{ std::cout << "unknown object key: " << key << std::endl; } @@ -220,7 +246,7 @@ private: else if(key=="COL"){ for(size_t i=0; i all; + binary::readAll(path, all); + if(all.empty()){ + return false; + } + binary::MemoryReader reader(&all[0], all.size()); + return read(reader); +} + +#ifdef _WIN32 +bool IO::read(const wchar_t *path) +{ + std::vector all; + binary::readAll(path, all); + if(all.empty()){ + return false; + } + binary::MemoryReader reader(&all[0], all.size()); + return read(reader); +} +#endif + +bool IO::write(binary::IWriter &writer) { - return false; + // header + writer.printLn("Metasequoia Document"); + writer.printLn("Format Text Ver 1.0"); + writer.printLn(""); + + // scene + writer.printLn("Scene {"); + writer.printLn("\tpos 0.0000 0.0000 1500.0000"); + writer.printLn("\tlookat 0.0000 0.0000 0.0000"); + writer.printLn("\thead -0.5236"); + writer.printLn("\tpich 0.5236"); + writer.printLn("\tortho 0"); + writer.printLn("\tzoom2 5.0000"); + writer.printLn("\tamb 0.250 0.250 0.250"); + writer.printLn("}"); + + // materials + if(materials.size()>0){ + writer.printLn("Material %d {", materials.size()); + for(size_t i=0; i