SpeedTree
    Show / Hide Table of Contents

    Accessing metadata

    Exported .stsdk files contain all metadata set in the SpeedTree Modeler using the Tree Info Window. To access the metadata for a base tree model in the Runtime SDK, call CCore::Metadata(). An example of accessing all fields in an .stsdk file follows:

    #include "SpeedTree/Core/Core.h"
    
    void PrintTreeInfo(const char* pFilename)
    {
        // populate loading config struct so that the sdk
        // handles the file and memory operations automatically
        SpeedTree::CCore::SLoadConfig sLoadConfig;
        sLoadConfig.m_strFilename = pFilename;
        sLoadConfig.m_bGrassModel = false;
    
        // create a core/tree object to read stsdk into
        SpeedTree::CCore cModel;
    
        // call stsdk-loading function: returns true on success
        if (cModel.LoadTree(sLoadConfig))
        {
            printf("STSDK load was successful\n");
    
            SpeedTree::CMetadata cMetadata = cModel.Metadata( );
    
            printf("\nSTSDK file metadata:\n");
            printf("  up vector: %s\n", cMetadata.UpVector( ) == SpeedTree::CMetadata::UP_VECTOR_Z ? "Z" : "Y");
            printf("  meters per unit: %g\n", cMetadata.MetersPerUnit( ));
            for (int i = 0; i < static_cast<int>(cMetadata.Entries( ).Count( )); ++i)
            {
                printf("  '%s' = '%s'\n", cMetadata.Entries( )[i].Key( ).Data( ), cMetadata.Entries( )[i].Value( ).Data( ));
            }
        }
        else
            fprintf(stderr, "STSDK load was unsuccessful\n");
    }
    
    Copyright © 2023 Unity Technologies
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX.