X3DConverter::X3DConverter(const string& filename, bool binary) : RVMReader(), m_binary(binary), m_id(0) { X3DWriter* writer = binary ? (X3DWriter*)new X3DWriterFI() : (X3DWriter*)new X3DWriterXML(); writer->setProperty(Property::IntEncodingAlgorithm, (void*)Encoder::DeltazlibIntArrayEncoder); writer->setProperty(Property::FloatEncodingAlgorithm, (void*)Encoder::QuantizedzlibFloatArrayEncoder); writer->openFile(filename.data()); m_writers.push_back(writer); }
void X3DConverter::startGroup(const std::string& name, const Vector3F& translation, const int& materialId) { // Ensuring the name is compatible with the DEF attribute string x3dName = name; size_t p; while ((p = x3dName.find_first_of(' ')) != string::npos) x3dName[p] = '_'; while (x3dName[0] == '-') x3dName[0] = '_'; while ((p = x3dName.find_first_of('/')) != string::npos) { x3dName[p] = '_'; } m_materials.push_back(materialId); m_groups.push_back(name); if (m_split) { startNode(ID::Inline); MFString name; name.push_back(x3dName + ".x3d"); m_writers.back()->setMFString(ID::url, name); X3DWriter* writer = m_binary ? (X3DWriter*)new X3DWriterFI() : (X3DWriter*)new X3DWriterXML(); writer->setProperty(Property::IntEncodingAlgorithm, (void*)Encoder::DeltazlibIntArrayEncoder); writer->setProperty(Property::FloatEncodingAlgorithm, (void*)Encoder::QuantizedzlibFloatArrayEncoder); writer->openFile((x3dName + ".x3d").data()); m_writers.push_back(writer); multimap<std::string, std::string> meta; meta.insert(pair<string, string>("generator", "Plant Mock-Up Converter 0.1")); m_writers.back()->startX3DDocument(Immersive, VERSION_3_0, &meta, false); startNode(ID::Background); m_writers.back()->setSFColor(ID::skyColor, .9f, .9f, .9f); endNode(ID::Background); } startNode(ID::Transform); // Problems with encoding and unicity so changed name from DEF storage to metadata. See after translation. //m_writers.back()->setSFString(ID::DEF, x3dName); /*m_writers.back()->setSFVec3f(ID::translation, (translation[0] - m_translations.back()[0]), (translation[1] - m_translations.back()[1]), (translation[2] - m_translations.back()[2]));*/ m_translations.push_back(translation); // PDMS name as metadata. // writeMetaDataString("pdms", name); }