Ability to flush a GLB manifest to a stream (#143)
This commit is contained in:
Родитель
142f92c10e
Коммит
d01d109037
|
@ -20,6 +20,9 @@ namespace Microsoft
|
|||
GLBResourceWriter(std::unique_ptr<IStreamWriterCache> streamCache);
|
||||
GLBResourceWriter(std::unique_ptr<IStreamWriterCache> streamCache, std::unique_ptr<std::iostream> tempBufferStream);
|
||||
|
||||
// Write to a stream instead of a file (can be useful for draco compression)
|
||||
template <typename T>
|
||||
void FlushStream(const std::string& manifest, T* stream);
|
||||
void Flush(const std::string& manifest, const std::string& uri);
|
||||
std::string GenerateBufferUri(const std::string& bufferId) const override;
|
||||
std::ostream* GetBufferStream(const std::string& bufferId) override;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <GLTFSDK/ResourceWriter.h>
|
||||
#include <limits>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <GLTFSDK/Color.h>
|
||||
#include <GLTFSDK/ExtensionsKHR.h>
|
||||
#include <limits>
|
||||
|
||||
namespace Microsoft
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
|
||||
namespace Microsoft
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <GLTFSDK/GLBResourceWriter.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
using namespace Microsoft::glTF;
|
||||
|
||||
|
@ -42,7 +43,8 @@ GLBResourceWriter::GLBResourceWriter(std::unique_ptr<IStreamWriterCache> streamC
|
|||
{
|
||||
}
|
||||
|
||||
void GLBResourceWriter::Flush(const std::string& manifest, const std::string& uri)
|
||||
template <typename T>
|
||||
void GLBResourceWriter::FlushStream(const std::string& manifest, T* stream)
|
||||
{
|
||||
uint32_t jsonChunkLength = static_cast<uint32_t>(manifest.length());
|
||||
const uint32_t jsonPaddingLength = ::CalculatePadding(jsonChunkLength);
|
||||
|
@ -59,7 +61,6 @@ void GLBResourceWriter::Flush(const std::string& manifest, const std::string& ur
|
|||
+ sizeof(binaryChunkLength) + GLB_CHUNK_TYPE_SIZE // 8 bytes (BIN header)
|
||||
+ binaryChunkLength;
|
||||
|
||||
auto stream = m_streamWriterCache->Get(uri);
|
||||
|
||||
// Write GLB header (12 bytes)
|
||||
StreamUtils::WriteBinary(*stream, GLB_HEADER_MAGIC_STRING, GLB_HEADER_MAGIC_STRING_SIZE);
|
||||
|
@ -96,6 +97,15 @@ void GLBResourceWriter::Flush(const std::string& manifest, const std::string& ur
|
|||
}
|
||||
}
|
||||
|
||||
template void GLBResourceWriter::FlushStream<std::fstream>(const std::string& manifest, std::fstream* stream);
|
||||
template void GLBResourceWriter::FlushStream<std::stringstream>(const std::string& manifest, std::stringstream* stream);
|
||||
|
||||
void GLBResourceWriter::Flush(const std::string& manifest, const std::string& uri)
|
||||
{
|
||||
auto stream = m_streamWriterCache->Get(uri);
|
||||
this->FlushStream<std::ostream>(manifest, stream.get());
|
||||
}
|
||||
|
||||
std::string GLBResourceWriter::GenerateBufferUri(const std::string& bufferId) const
|
||||
{
|
||||
std::string bufferUri;
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include <sstream>
|
||||
|
||||
#include <limits>
|
||||
|
||||
using namespace Microsoft::glTF;
|
||||
|
||||
namespace
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <set>
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
#include <limits>
|
||||
|
||||
using namespace Microsoft::glTF;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче