Merge pull request #1378 from dhritzkiv/feature/gltf-version

glTF version
pull/1382/head
Kim Kulling 2017-08-10 20:50:15 +02:00 committed by GitHub
commit 0629faf9b1
8 changed files with 14 additions and 13 deletions

View File

@ -1074,7 +1074,7 @@ namespace glTF2
std::string version; //!< Specifies the target rendering API (default: "1.0.3") std::string version; //!< Specifies the target rendering API (default: "1.0.3")
} profile; //!< Specifies the target rendering API and version, e.g., WebGL 1.0.3. (default: {}) } profile; //!< Specifies the target rendering API and version, e.g., WebGL 1.0.3. (default: {})
int version; //!< The glTF format version float version; //!< The glTF format version
void Read(Document& doc); void Read(Document& doc);

View File

@ -1229,7 +1229,7 @@ inline void Scene::Read(Value& obj, Asset& r)
inline void AssetMetadata::Read(Document& doc) inline void AssetMetadata::Read(Document& doc)
{ {
// read the version, etc. // read the version, etc.
int statedVersion = 0; float statedVersion = 0;
if (Value* obj = FindObject(doc, "asset")) { if (Value* obj = FindObject(doc, "asset")) {
ReadMember(*obj, "copyright", copyright); ReadMember(*obj, "copyright", copyright);
ReadMember(*obj, "generator", generator); ReadMember(*obj, "generator", generator);
@ -1244,14 +1244,15 @@ inline void AssetMetadata::Read(Document& doc)
} }
version = std::max(statedVersion, version); version = std::max(statedVersion, version);
if (version == 0) { if (version == 0) {
// if missing version, we'll assume version 1... // if missing version, we'll assume version 1.0...
version = 1; version = 1;
} }
if (version != 1) { if (version != 1) {
char msg[128]; char msg[128];
ai_snprintf(msg, 128, "GLTF: Unsupported glTF version: %d", version); ai_snprintf(msg, 128, "GLTF: Unsupported glTF version: %.1f", version);
throw DeadlyImportError(msg); throw DeadlyImportError(msg);
} }
} }

View File

@ -600,7 +600,7 @@ namespace glTF2 {
asset.SetObject(); asset.SetObject();
{ {
char versionChar[10]; char versionChar[10];
ai_snprintf(versionChar, sizeof(versionChar), "%d", mAsset.asset.version); ai_snprintf(versionChar, sizeof(versionChar), "%.1f", mAsset.asset.version);
asset.AddMember("version", Value(versionChar, mAl).Move(), mAl); asset.AddMember("version", Value(versionChar, mAl).Move(), mAl);
asset.AddMember("generator", Value(mAsset.asset.generator, mAl).Move(), mAl); asset.AddMember("generator", Value(mAsset.asset.generator, mAl).Move(), mAl);

View File

@ -466,8 +466,8 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref<Mesh>& meshRef, Ref<Buf
float vertWeight = aib->mWeights[idx_weights].mWeight; float vertWeight = aib->mWeights[idx_weights].mWeight;
// A vertex can only have at most four joint weights. Ignore all others. // A vertex can only have at most four joint weights. Ignore all others.
if (jointsPerVertex[vertexId] > 3) { if (jointsPerVertex[vertexId] > 3) {
continue; continue;
} }
vertexJointData[vertexId][jointsPerVertex[vertexId]] = jointNamesIndex; vertexJointData[vertexId][jointsPerVertex[vertexId]] = jointNamesIndex;

View File

@ -1058,7 +1058,7 @@ namespace glTF
std::string version; //!< Specifies the target rendering API (default: "1.0.3") std::string version; //!< Specifies the target rendering API (default: "1.0.3")
} profile; //!< Specifies the target rendering API and version, e.g., WebGL 1.0.3. (default: {}) } profile; //!< Specifies the target rendering API and version, e.g., WebGL 1.0.3. (default: {})
int version; //!< The glTF format version (should be 1) float version; //!< The glTF format version (should be 1.0)
void Read(Document& doc); void Read(Document& doc);

View File

@ -1228,7 +1228,7 @@ inline void Scene::Read(Value& obj, Asset& r)
inline void AssetMetadata::Read(Document& doc) inline void AssetMetadata::Read(Document& doc)
{ {
// read the version, etc. // read the version, etc.
int statedVersion = 0; float statedVersion = 0;
if (Value* obj = FindObject(doc, "asset")) { if (Value* obj = FindObject(doc, "asset")) {
ReadMember(*obj, "copyright", copyright); ReadMember(*obj, "copyright", copyright);
ReadMember(*obj, "generator", generator); ReadMember(*obj, "generator", generator);
@ -1250,7 +1250,7 @@ inline void AssetMetadata::Read(Document& doc)
if (version != 1) { if (version != 1) {
char msg[128]; char msg[128];
ai_snprintf(msg, 128, "GLTF: Unsupported glTF version: %d", version); ai_snprintf(msg, 128, "GLTF: Unsupported glTF version: %.0f", version);
throw DeadlyImportError(msg); throw DeadlyImportError(msg);
} }
} }

View File

@ -608,7 +608,7 @@ namespace glTF {
asset.SetObject(); asset.SetObject();
{ {
char versionChar[10]; char versionChar[10];
ai_snprintf(versionChar, sizeof(versionChar), "%d", mAsset.asset.version); ai_snprintf(versionChar, sizeof(versionChar), "%.0f", mAsset.asset.version);
asset.AddMember("version", Value(versionChar, mAl).Move(), mAl); asset.AddMember("version", Value(versionChar, mAl).Move(), mAl);
asset.AddMember("generator", Value(mAsset.asset.generator, mAl).Move(), mAl); asset.AddMember("generator", Value(mAsset.asset.generator, mAl).Move(), mAl);

View File

@ -469,8 +469,8 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref<Mesh>& meshRef, Ref<Buf
float vertWeight = aib->mWeights[idx_weights].mWeight; float vertWeight = aib->mWeights[idx_weights].mWeight;
// A vertex can only have at most four joint weights. Ignore all others. // A vertex can only have at most four joint weights. Ignore all others.
if (jointsPerVertex[vertexId] > 3) { if (jointsPerVertex[vertexId] > 3) {
continue; continue;
} }
vertexJointData[vertexId][jointsPerVertex[vertexId]] = jointNamesIndex; vertexJointData[vertexId][jointsPerVertex[vertexId]] = jointNamesIndex;