Documentation

SpeedTree Runtime SDK

Version: 10

SpeedTree Runtime SDK

Version: 10

Accessing metadata

Learn how to access per-tree metadata exported from the SpeedTree Modeler.
Read time 1 minuteLast updated 2 hours ago

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");}