ai_metadata.h File Reference

API for writing and reading node metadata. More...

#include "ai_node_entry.h"
#include "ai_vector.h"
#include "ai_color.h"
#include "ai_api.h"
#include "ai_string.h"

Go to the source code of this file.

Functions

Node Metadata Retrieval

These functions allow client code to examine metadata attached to specific parameters or to a node.

Following on the example above:

const AtNodeEntry* entry = AiNodeEntryLookUp("my_simple_lambert");
char* desc;
bool success = AiMetaDataGetStr(entry, "Kd", "description", &desc)
if (success)
printf("\nDescription for parameter Kd: %s", desc);
AI_API AI_PURE const AtNodeEntry * AiNodeEntryLookUp(const AtString name)
Look up a node entry from a name string.
Definition: ai_nodeentry.cpp:43
This represents a node type in Arnold.
Parameters
entrythe AtNodeEntry of the node you want to get metadata from
paramthe name of the node parameter you want to get metadata from (or null/empty string if you are looking for metadata on the node itself)
namethe name of the metadata you want to get
[out]valueif the read succeeds, the variable pointed to by value will be overwritten with the metadata
Returns
true when the lookup is succesful
 __attribute__ ((deprecated)) bool AiMetaDataGetBool(const AtNodeEntry *nentry
 
AtMetadataStore Writing

These functions allow attaching auxiliary information to a specific metadata store.

Here is an example:

AiMetadataStoreSetStr(mds, AtString("author"), "William Shakespeare");
AiMetadataStoreSetStr(mds, AtString("bbox"), "-1 -1 -1 1 1 1");
AiMetadataStoreSetFlt(mds, AtString("temperature"), 21.0f);
Arnold String allows for fast string comparisons.
Definition: ai_string.h:46

Note that you should never pass allocated strings, as they will not be freed.

Parameters
mdsthe metadata store to operate with
namethe name of the metadata you want to attach
valuethe value of the metadata
void AiMetadataStoreSetStr (AtMetadataStore *mds, const AtString name, const char *value)
 
void AiMetadataStoreParamSetStr (AtMetadataStore *mds, const AtString param, const AtString name, const char *value)
 
AtMetadataStore Retrieval

These functions allow client code to get metadata entries within a specific metadata store.

Following on the example above:

char* author;
bool success = AiMetadataStoreGetStr(mds, "author", &author)
if (success)
printf("\nAuthor: %s", author);
Parameters
mdsthe metadata store to read from
namethe name of the metadata you want to get
[out]valueif the read succeeds, the variable pointed to by value will be overwritten with the metadata
Returns
true when the lookup is succesful
AI_API AtMetadataStoreAiMetadataStore ()
 Creates a new metadata store. More...
 
AI_API void AiMetadataStoreDestroy (AtMetadataStore *mds)
 Destroys a metadata store object. More...
 
AI_API bool AiMetadataStoreLoadFromASS (AtMetadataStore *mds, const char *file)
 Load embedded metadata from an .ass file into a metadata store. More...
 
AI_API AtMetaDataIterator * AiMetadataStoreGetIterator (const AtMetadataStore *mds)
 Creates a new metadata iterator that traverses all global metadata. More...
 
AI_API AtMetaDataIterator * AiMetadataStoreGetIteratorRecursive (const AtMetadataStore *mds, const char *param, bool recursive)
 Creates a new metadata iterator pointing at the first matching entry. More...
 
AI_API bool AiMetaDataLoadFile (const char *filename)
 Load a metadata file. More...
 

Node metadata writing

These functions allow attaching auxiliary information about specific parameters or the node itself. This information is stored within the AtNodeEntry. These methods may only be called within the node_parameters function where the parameters are declared.

Here is an example:

{
AiParameterFlt("Kd", 0.7f);
// create a lower-case synonym for parameter Kd
AiMetaDataSetStr(nentry, "Kd", "_synonym", "kd");
// describe the parameter
AiMetaDataSetStr(nentry, "Kd", "description",
"Diffuse coefficient");
// describe the node itself
AiMetaDataSetStr(nentry, NULL, "description",
"This is a simple lambert shader for illustration purposes");
}
#define node_parameters
Parameter declaration method.
Definition: ai_nodes.h:71

Note that you should never pass allocated strings, as they will not be freed.

Parameters
nentrythis is the AtNodeEntry (note that nentry is an argument to node_parameters)
paramthe name of the node parameter to which the metadata will be attached (or a null/empty string if you want to attach information to the node itself)
namethe name of the metadata you want to attach
valuethe value of the metadata
const AtString param
 
const AtString const AtString name
 
const AtString const AtString bool value { return AiMetaDataGetBool (nentry, AtString(param), AtString(name), value)
 
 __attribute__ ((visibility("default"))) void AiMetaDataSetBool(AtNodeEntry *nentry
 
void AiMetaDataSetBool (AtNodeEntry *nentry, const char *param, const char *name, bool value)
 
void AiMetaDataSetInt (AtNodeEntry *nentry, const char *param, const char *name, int value)
 
void AiMetaDataSetFlt (AtNodeEntry *nentry, const char *param, const char *name, float value)
 
void AiMetaDataSetRGB (AtNodeEntry *nentry, const char *param, const char *name, AtRGB value)
 
void AiMetaDataSetRGBA (AtNodeEntry *nentry, const char *param, const char *name, AtRGBA value)
 
void AiMetaDataSetVec (AtNodeEntry *nentry, const char *param, const char *name, AtVector value)
 
void AiMetaDataSetVec2 (AtNodeEntry *nentry, const char *param, const char *name, AtVector2 value)
 
void AiMetaDataSetStr (AtNodeEntry *nentry, const char *param, const char *name, AtString value)
 
void AiMetaDataSetStr (AtNodeEntry *nentry, const char *param, const char *name, const char *value)
 

Detailed Description

API for writing and reading node metadata.


© 2022 Autodesk, Inc. · All rights reserved · www.arnoldrenderer.com