X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Fmqo.cpp;h=7c6ff3c499b40695b32877abbdbbe5a19aaee045;hb=4b7b856e70fe8047f985e2598020032d0d87a672;hp=1fe8603a80144bdd2b89998cd132291a9339dd2d;hpb=2e272c8234ed76c70119a71a8371c4c48b8d7a33;p=meshio%2Fmeshio.git diff --git a/src/mqo.cpp b/src/mqo.cpp index 1fe8603..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 { @@ -64,7 +86,7 @@ public: else if(key=="Eof"){ if(materials.empty()){ // fallback - materials.push_back(Material()); + //materials.push_back(Material()); } return true; } @@ -285,7 +307,7 @@ private: material.ambient=splitter.getFloat(); } else if(key=="emi"){ - material.emmit=splitter.getFloat(); + material.emit=splitter.getFloat(); } else if(key=="spc"){ material.specular=splitter.getFloat(); @@ -404,11 +426,115 @@ bool IO::read(const char *path) return read(reader); } -bool IO::write(std::ostream &os) +#ifdef _WIN32 +bool IO::read(const wchar_t *path) { - return false; + 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) +{ + // 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