C4 Engine
C4 Engine API Documentation

Model::FindNode

Defined in:  C4Models.h
Finds a node having a specific name or hash value.
Prototype

Node *FindNode(const char *name) const;

Node *FindNode(uint32 hash) const;

Parameters
name The name of the node to search for.
hash The hash value of the name of the node to search for.
Description
When a model is first preprocessed, it creates a hash table of pointers to its subnodes for quick access. The FindNode function searches this table for a node having the name whose hash value is specified by the hash parameter. If the node is found, then a pointer to it is returned. Otherwise, the return value is nullptr. If more than one node has the specified hash value because they have the same name, then a pointer to one of the nodes will be returned, but which one is undefined.

If the name parameter is specified instead of the hash parameter, then the hash value of the name string is calculated automatically and passed to the version of the FindNode function that takes a hash value.

The hash value corresponding a name string can be calculated by calling the Text::Hash function at run time. A compile-time constant hash value for a name can be calculated using the StaticHash class template.

A model node must have been added to a world and preprocessed before the FindNode function can be called for it.
See Also

Node::GetNodeName

Node::SetNodeName

Text::Hash

StaticHash