facebookincubator / FBX2glTF

A command-line tool for the conversion of 3D model assets on the FBX file format to the glTF file format.
Other
2.1k stars 332 forks source link

Added support for exporting user properties assigned to materials #141

Closed gwihlidal closed 5 years ago

gwihlidal commented 6 years ago

This PR adds support for exporting user properties assigned to materials, previously ignored and missing from the glTF "extras" section.

Now an example materials section in the glTF looks like this (note: halcyonUrl):

"materials": [
    {
        "name": "Cream_Marble",
        "alphaMode": "OPAQUE",
        "extras": {
            "fromFBX": {
                "shadingModel": "<unknown>",
                "isTruePBR": false,
                "userProperties": {
                    "halcyonUrl": {
                        "type": "eFbxString",
                        "value": "Phoenix/Materials/Cream_Marble"
                    }
                }
            }
        },
        "pbrMetallicRoughness": {
            "baseColorFactor": [
                0.0274509824812412,
                0.023529414087534,
                0.0196078438311815,
                1.0
            ],
            "metallicFactor": 0.200000002980232,
            "roughnessFactor": 0.800000011920929
        }
    }
],
facebook-github-bot commented 6 years ago

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

facebook-github-bot commented 6 years ago

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

zellski commented 5 years ago

This is most elegant, nicely done. At first I wasn't crazy about the idea of generating JSON so early in the process -- typically that'd go in the Raw->FBX stage -- but for something as generic as user properties, it's the right move. Thanks!

zellski commented 5 years ago

Oops, I mixed up who did what. So this uses @EscapeZero's existing code and extends it to materials, which is good. I'm less crazy about the needless duplication of the switch statement that translates types to type names. It'd be nice to abstract that out. I may push 0.9.6 out like this, though, and have a go at tidying things up later.