mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-14 22:05:59 +08:00
Merge pull request #173 from christophe-f8/master
Adding texture scale reading + asset copyright and texture names to the export
This commit is contained in:
commit
689edcbef6
18
tiny_gltf.h
18
tiny_gltf.h
@ -393,6 +393,17 @@ struct Parameter {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Return the scale of a texture if this Parameter is a normal texture map.
|
||||
/// Returned value is only valid if the parameter represent a normal texture
|
||||
/// from a material
|
||||
double TextureScale() const {
|
||||
const auto it = json_double_value.find("scale");
|
||||
if (it != std::end(json_double_value)) {
|
||||
return it->second;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// Material factor, like the roughness or metalness of a material
|
||||
/// Returned value is only valid if the parameter represent a texture from a
|
||||
/// material
|
||||
@ -4838,6 +4849,10 @@ static void SerializeGltfAsset(Asset &asset, json &o) {
|
||||
SerializeStringProperty("generator", asset.generator, o);
|
||||
}
|
||||
|
||||
if (!asset.copyright.empty()) {
|
||||
SerializeStringProperty("copyright", asset.copyright, o);
|
||||
}
|
||||
|
||||
if (!asset.version.empty()) {
|
||||
SerializeStringProperty("version", asset.version, o);
|
||||
}
|
||||
@ -5135,6 +5150,9 @@ static void SerializeGltfTexture(Texture &texture, json &o) {
|
||||
if (texture.source > -1) {
|
||||
SerializeNumberProperty("source", texture.source, o);
|
||||
}
|
||||
if (texture.name.size()) {
|
||||
SerializeStringProperty("name", texture.name, o);
|
||||
}
|
||||
if (texture.extras.Type() != NULL_TYPE) {
|
||||
SerializeValue("extras", texture.extras, o);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user