Drop the Gltf:: namespace prefix. (#77)
This commit is contained in:
parent
3f796dd90f
commit
a984f7bf37
|
@ -1319,22 +1319,22 @@ static void ReadAnimations(RawModel &raw, FbxScene *pScene)
|
|||
static std::string GetInferredFileName(const std::string &fbxFileName, const std::string &directory, const std::vector<std::string> &directoryFileList)
|
||||
{
|
||||
// Get the file name with file extension.
|
||||
const std::string fileName = Gltf::StringUtils::GetFileNameString(Gltf::StringUtils::GetCleanPathString(fbxFileName));
|
||||
const std::string fileName = StringUtils::GetFileNameString(StringUtils::GetCleanPathString(fbxFileName));
|
||||
|
||||
// Try to find a match with extension.
|
||||
for (const auto &file : directoryFileList) {
|
||||
if (Gltf::StringUtils::CompareNoCase(fileName, file) == 0) {
|
||||
if (StringUtils::CompareNoCase(fileName, file) == 0) {
|
||||
return std::string(directory) + file;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the file name without file extension.
|
||||
const std::string fileBase = Gltf::StringUtils::GetFileBaseString(fileName);
|
||||
const std::string fileBase = StringUtils::GetFileBaseString(fileName);
|
||||
|
||||
// Try to find a match without file extension.
|
||||
for (const auto &file : directoryFileList) {
|
||||
// If the two extension-less base names match.
|
||||
if (Gltf::StringUtils::CompareNoCase(fileBase, Gltf::StringUtils::GetFileBaseString(file)) == 0) {
|
||||
if (StringUtils::CompareNoCase(fileBase, StringUtils::GetFileBaseString(file)) == 0) {
|
||||
// Return the name with extension of the file in the directory.
|
||||
return std::string(directory) + file;
|
||||
}
|
||||
|
@ -1357,10 +1357,10 @@ FindFbxTextures(
|
|||
FbxScene *pScene, const char *fbxFileName, const char *extensions, std::map<const FbxTexture *, FbxString> &textureLocations)
|
||||
{
|
||||
// Get the folder the FBX file is in.
|
||||
const std::string folder = Gltf::StringUtils::GetFolderString(fbxFileName);
|
||||
const std::string folder = StringUtils::GetFolderString(fbxFileName);
|
||||
|
||||
// Check if there is a filename.fbm folder to which embedded textures were extracted.
|
||||
const std::string fbmFolderName = folder + Gltf::StringUtils::GetFileBaseString(fbxFileName) + ".fbm/";
|
||||
const std::string fbmFolderName = folder + StringUtils::GetFileBaseString(fbxFileName) + ".fbm/";
|
||||
|
||||
// Search either in the folder with embedded textures or in the same folder as the FBX file.
|
||||
const std::string searchFolder = FileUtils::FolderExists(fbmFolderName) ? fbmFolderName : folder;
|
||||
|
|
|
@ -448,7 +448,6 @@ ModelData *Raw2Gltf(
|
|||
};
|
||||
|
||||
int width = -1, height = -1;
|
||||
std::string mergedName = tag;
|
||||
std::string mergedFilename = tag;
|
||||
std::vector<TexInfo> texes { };
|
||||
for (const int rawTexIx : rawTexIndices) {
|
||||
|
@ -456,31 +455,32 @@ ModelData *Raw2Gltf(
|
|||
if (rawTexIx >= 0) {
|
||||
const RawTexture &rawTex = raw.GetTexture(rawTexIx);
|
||||
const std::string &fileLoc = rawTex.fileLocation;
|
||||
const std::string &fileLocBase = Gltf::StringUtils::GetFileBaseString(Gltf::StringUtils::GetFileNameString(fileLoc));
|
||||
const std::string &name = StringUtils::GetFileBaseString(StringUtils::GetFileNameString(fileLoc));
|
||||
if (!fileLoc.empty()) {
|
||||
info.pixels = stbi_load(fileLoc.c_str(), &info.width, &info.height, &info.channels, 0);
|
||||
if (!info.pixels) {
|
||||
fmt::printf("Warning: merge texture [%d](%s) could not be loaded.\n",
|
||||
rawTexIx,
|
||||
Gltf::StringUtils::GetFileBaseString(Gltf::StringUtils::GetFileNameString(fileLoc)));
|
||||
name);
|
||||
} else {
|
||||
if (width < 0) {
|
||||
width = info.width;
|
||||
height = info.height;
|
||||
} else if (width != info.width || height != info.height) {
|
||||
fmt::printf("Warning: texture %s (%d, %d) can't be merged with previous texture(s) of dimension (%d, %d)\n",
|
||||
Gltf::StringUtils::GetFileBaseString(Gltf::StringUtils::GetFileNameString(fileLoc)),
|
||||
name,
|
||||
info.width, info.height, width, height);
|
||||
// this is bad enough that we abort the whole merge
|
||||
return nullptr;
|
||||
}
|
||||
mergedName += "_" + rawTex.fileName;
|
||||
mergedFilename += "_" + fileLocBase;
|
||||
mergedFilename += "_" + name;
|
||||
}
|
||||
}
|
||||
}
|
||||
texes.push_back(info);
|
||||
}
|
||||
// at the moment, the best choice of filename is also the best choice of name
|
||||
const std::string mergedName = mergedFilename;
|
||||
|
||||
if (width < 0) {
|
||||
// no textures to merge; bail
|
||||
|
@ -579,14 +579,14 @@ ModelData *Raw2Gltf(
|
|||
}
|
||||
|
||||
const RawTexture &rawTexture = raw.GetTexture(rawTexIndex);
|
||||
const std::string textureName = Gltf::StringUtils::GetFileBaseString(rawTexture.name);
|
||||
const std::string relativeFilename = Gltf::StringUtils::GetFileNameString(rawTexture.fileLocation);
|
||||
const std::string textureName = StringUtils::GetFileBaseString(rawTexture.name);
|
||||
const std::string relativeFilename = StringUtils::GetFileNameString(rawTexture.fileLocation);
|
||||
|
||||
ImageData *image = nullptr;
|
||||
if (options.outputBinary) {
|
||||
auto bufferView = gltf->AddBufferViewForFile(buffer, rawTexture.fileLocation);
|
||||
if (bufferView) {
|
||||
std::string suffix = Gltf::StringUtils::GetFileSuffixString(rawTexture.fileLocation);
|
||||
std::string suffix = StringUtils::GetFileSuffixString(rawTexture.fileLocation);
|
||||
image = new ImageData(relativeFilename, *bufferView, suffixToMimeType(suffix));
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ int RawModel::AddTexture(const std::string &name, const std::string &fileName, c
|
|||
return -1;
|
||||
}
|
||||
for (size_t i = 0; i < textures.size(); i++) {
|
||||
if (Gltf::StringUtils::CompareNoCase(textures[i].name, name) == 0 && textures[i].usage == usage) {
|
||||
if (StringUtils::CompareNoCase(textures[i].name, name) == 0 && textures[i].usage == usage) {
|
||||
return (int) i;
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ int RawModel::AddMaterial(
|
|||
int RawModel::AddSurface(const RawSurface &surface)
|
||||
{
|
||||
for (size_t i = 0; i < surfaces.size(); i++) {
|
||||
if (Gltf::StringUtils::CompareNoCase(surfaces[i].name, surface.name) == 0) {
|
||||
if (StringUtils::CompareNoCase(surfaces[i].name, surface.name) == 0) {
|
||||
return (int) i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@ Copyright (c) 2016-2017 Oculus VR, LLC.
|
|||
|
||||
if (options.count("output") == 0) {
|
||||
// if -o is not given, default to the basename of the .fbx
|
||||
outputPath = "./" + Gltf::StringUtils::GetFileBaseString(inputPath);
|
||||
outputPath = "./" + StringUtils::GetFileBaseString(inputPath);
|
||||
}
|
||||
std::string outputFolder; // the output folder in .gltf mode, not used for .glb
|
||||
std::string modelPath; // the path of the actual .glb or .gltf file
|
||||
|
@ -208,7 +208,7 @@ Copyright (c) 2016-2017 Oculus VR, LLC.
|
|||
} else {
|
||||
// in gltf mode, we create a folder and write into that
|
||||
outputFolder = outputPath + "_out/";
|
||||
modelPath = outputFolder + Gltf::StringUtils::GetFileNameString(outputPath) + ".gltf";
|
||||
modelPath = outputFolder + StringUtils::GetFileNameString(outputPath) + ".gltf";
|
||||
}
|
||||
if (!FileUtils::CreatePath(modelPath.c_str())) {
|
||||
fmt::fprintf(stderr, "ERROR: Failed to create folder: %s'\n", outputFolder.c_str());
|
||||
|
|
|
@ -41,14 +41,14 @@ namespace FileUtils {
|
|||
|
||||
std::string GetCurrentFolder()
|
||||
{
|
||||
char cwd[Gltf::StringUtils::MAX_PATH_LENGTH];
|
||||
char cwd[StringUtils::MAX_PATH_LENGTH];
|
||||
if (!_getcwd(cwd, sizeof(cwd))) {
|
||||
return std::string();
|
||||
}
|
||||
cwd[sizeof(cwd) - 1] = '\0';
|
||||
Gltf::StringUtils::GetCleanPath(cwd, cwd, Gltf::StringUtils::PATH_UNIX);
|
||||
StringUtils::GetCleanPath(cwd, cwd, StringUtils::PATH_UNIX);
|
||||
const size_t length = strlen(cwd);
|
||||
if (cwd[length - 1] != '/' && length < Gltf::StringUtils::MAX_PATH_LENGTH - 1) {
|
||||
if (cwd[length - 1] != '/' && length < StringUtils::MAX_PATH_LENGTH - 1) {
|
||||
cwd[length + 0] = '/';
|
||||
cwd[length + 1] = '\0';
|
||||
}
|
||||
|
@ -155,12 +155,12 @@ namespace FileUtils {
|
|||
bool CreatePath(const char *path)
|
||||
{
|
||||
#if defined( __unix__ ) || defined( __APPLE__ )
|
||||
Gltf::StringUtils::PathSeparator separator = Gltf::StringUtils::PATH_UNIX;
|
||||
StringUtils::PathSeparator separator = StringUtils::PATH_UNIX;
|
||||
#else
|
||||
Gltf::StringUtils::PathSeparator separator = Gltf::StringUtils::PATH_WIN;
|
||||
StringUtils::PathSeparator separator = StringUtils::PATH_WIN;
|
||||
#endif
|
||||
std::string folder = Gltf::StringUtils::GetFolderString(path);
|
||||
std::string clean = Gltf::StringUtils::GetCleanPathString(folder, separator);
|
||||
std::string folder = StringUtils::GetFolderString(path);
|
||||
std::string clean = StringUtils::GetCleanPathString(folder, separator);
|
||||
std::string build = clean;
|
||||
for (int i = 0; i < clean.length(); i ++) {
|
||||
if (clean[i] == separator && i > 0) {
|
||||
|
|
|
@ -9,13 +9,11 @@
|
|||
|
||||
#include "String_Utils.h"
|
||||
|
||||
namespace Gltf {
|
||||
namespace StringUtils {
|
||||
namespace StringUtils {
|
||||
|
||||
PathSeparator operator!(const PathSeparator &s)
|
||||
{
|
||||
return (s == PATH_WIN) ? PATH_UNIX : PATH_WIN;
|
||||
}
|
||||
|
||||
}
|
||||
}// namespace Gltf
|
||||
}
|
||||
|
|
|
@ -20,9 +20,7 @@
|
|||
#define strcasecmp _stricmp
|
||||
#endif
|
||||
|
||||
namespace Gltf // TODO replace
|
||||
{
|
||||
namespace StringUtils {
|
||||
namespace StringUtils {
|
||||
|
||||
static const unsigned int MAX_PATH_LENGTH = 1024;
|
||||
|
||||
|
@ -88,8 +86,6 @@ namespace Gltf // TODO replace
|
|||
return strncasecmp(s1.c_str(), s2.c_str(), MAX_PATH_LENGTH);
|
||||
}
|
||||
|
||||
} // StringUtils
|
||||
|
||||
}// namespace Gltf
|
||||
} // StringUtils
|
||||
#endif // _STRING_UTILS_H__
|
||||
|
||||
|
|
Loading…
Reference in New Issue