libgpac
Documentation of the core library of GPAC
|
Scenegraph used for manipulating scenes. More...
Data Structures | |
struct | GF_Node |
struct | GF_ChildNodeItem |
struct | GF_ParentNode |
struct | GF_FieldInfo |
struct | GF_JSAPIURI |
struct | GF_JSAPIOPT |
struct | GF_JSAPIINFO |
union | GF_JSAPIParam |
struct | GF_CommandField |
struct | GF_Command |
union | GF_Command.__unnamed164__ |
union | GF_Command.__unnamed166__ |
union | GF_Command.__unnamed168__ |
union | GF_Command.__unnamed170__ |
union | GF_Command.__unnamed172__ |
union | GF_Command.__unnamed174__ |
union | GF_Command.__unnamed176__ |
Macros | |
#define | BASE_NODE struct _nodepriv *sgprivate; |
#define | CHILDREN struct _child_node *children; |
Typedefs | |
typedef void(* | gf_sg_node_callback) (GF_Node *n, void *traverse_state, Bool is_destroy) |
typedef void(* | gf_sg_node_init_callback) (void *udta, GF_SGNodeCbkType type, GF_Node *node, void *ctxdata) |
typedef Bool(* | gf_sg_script_action) (void *callback, GF_JSAPIActionType type, GF_Node *node, GF_JSAPIParam *param) |
typedef struct _xml_node * | GF_DOMXMLNODE |
This section documents the Scenegraph used in GPAC for all interactive scenes.
struct GF_Node |
base node type
struct GF_ChildNodeItem |
child storage This is not integrated in the base node, because of VRML/MPEG-4 USE: a node may be present at different places in the tree, hence have different "next" siblings.
Data Fields | ||
---|---|---|
struct _child_node * | next | |
GF_Node * | node |
struct GF_ParentNode |
generic parent node
struct GF_JSAPIURI |
JS API Url structure
Data Fields | ||
---|---|---|
char * | url | |
const char ** | params | |
u32 | nb_params |
struct GF_JSAPIOPT |
struct GF_JSAPIINFO |
JS API structure for script message
Data Fields | ||
---|---|---|
GF_Err | e | |
const char * | msg |
union GF_JSAPIParam |
JS API parameter type
Data Fields | ||
---|---|---|
u32 | opt | |
Fixed | val | |
GF_Point2D | pt | |
GF_Rect | rc | |
Double | time | |
GF_BBox | bbox | |
GF_Matrix | mx | |
GF_JSAPIURI | uri | |
GF_JSAPIOPT | gpac_cfg | |
GF_Node * | node | |
struct __gf_download_manager * | dnld_man | |
GF_SceneGraph * | scene | |
void * | compositor | |
GF_JSAPIINFO | info |
struct GF_CommandField |
structure used to store field info, pos and static pointers to GF_Node/MFNode in commands
Data Fields | ||
---|---|---|
u32 | fieldIndex | |
u32 | fieldType | |
void * | field_ptr | |
s32 | pos | |
GF_Node * | new_node | |
GF_ChildNodeItem * | node_list |
struct GF_Command |
structure used to store decoded BIFS command
Data Fields | ||
---|---|---|
GF_SceneGraph * | in_scene | |
u32 | tag | |
GF_Node * | node | |
GF_List * | command_fields | |
GF_List * | scripts_to_load | |
Bool | unresolved | |
char * | unres_name | |
union GF_Command | __unnamed__ | |
GF_List * | new_proto_list | |
u32 * | del_proto_list | |
union GF_Command | __unnamed__ | |
union GF_Command | __unnamed__ | |
union GF_Command | __unnamed__ | |
union GF_Command | __unnamed__ | |
union GF_Command | __unnamed__ | |
union GF_Command | __unnamed__ | |
Bool | aggregated | |
Bool | never_apply |
#define BASE_NODE struct _nodepriv *sgprivate; |
macro for defining base node (apply to all nodes)
#define CHILDREN struct _child_node *children; |
grouping nodes macro children: list of children SFNodes
node callback function
n | the target node |
traverse_state | opaque data passed during traversal |
is_destroy | set when the node is about to be destroyed |
typedef void(* gf_sg_node_init_callback) (void *udta, GF_SGNodeCbkType type, GF_Node *node, void *ctxdata) |
node callback function for scene graph
udta | user private data of scene graph, see gf_sg_set_private |
type | the type of callback |
node | the target node for the callback |
ctxdata | associated data, type depends on the callback type |
typedef Bool(* gf_sg_script_action) (void *callback, GF_JSAPIActionType type, GF_Node *node, GF_JSAPIParam *param) |
interface to various get/set options:
callback | opaque data passed to the function |
type | operand type, one of the above |
node | target node, scene root node or NULL |
param | i/o param, depending on operand type |
typedef struct _xml_node* GF_DOMXMLNODE |
XML node from DOM parser
anonymous enum |
Tags of scene graph nodes TAG definitions are static, in order to be able to mix nodes from different standard in a single scenegraph. These TAGs are only used internally (they do not match any binary encoding)
anonymous enum |
node dirty flags
enum GF_SGNodeCbkType |
anonymous enum |
enum GF_JSAPIActionType |
JS API action types
anonymous enum |
Scene command tags
scene graph command tools used for BIFS and LASeR These are used to store updates in memory without applying changes to the graph, for dumpers, encoders ... The commands can then be applied through this lib
GF_Err gf_node_list_add_child | ( | GF_ChildNodeItem ** | list, |
GF_Node * | n | ||
) |
adds a child to a given container
list | pointer to target child list |
n | node to add |
GF_Err gf_node_list_add_child_last | ( | GF_ChildNodeItem ** | list, |
GF_Node * | n, | ||
GF_ChildNodeItem ** | last_child | ||
) |
adds a child to a given container, updating last position
list | pointer to target child list |
n | node to add |
last_child | set to position of add child |
GF_Err gf_node_list_insert_child | ( | GF_ChildNodeItem ** | list, |
GF_Node * | n, | ||
u32 | pos | ||
) |
inserts a child to a given container - if pos doesn't match, append the child
list | pointer to target child list |
n | node to insert |
pos | 0-based index at which to insert |
Bool gf_node_list_del_child | ( | GF_ChildNodeItem ** | list, |
GF_Node * | n | ||
) |
removes a child to a given container
list | pointer to target child list |
n | node to remove |
s32 gf_node_list_find_child | ( | GF_ChildNodeItem * | list, |
GF_Node * | n | ||
) |
finds a child in a given container
list | target child list |
n | node to find |
GF_Node* gf_node_list_get_child | ( | GF_ChildNodeItem * | list, |
s32 | pos | ||
) |
finds a child in a given container given its index. if pos is <0, returns the last child
list | target child list |
pos | 0-based index at which to insert |
u32 gf_node_list_get_count | ( | GF_ChildNodeItem * | list | ) |
gets the number of children in a given list
list | target child list |
GF_Node* gf_node_list_del_child_idx | ( | GF_ChildNodeItem ** | list, |
u32 | pos | ||
) |
removes node at given idx
list | pointer to target child list |
pos | 0-based index at which to insert |
gets tag of node (tag is set upon creation and cannot be modified)
n | the target node |
set node ID/def If a different node with the same ID exists, returns error. You may change the node ID by recalling the function with a different ID value. You may get a node ID by calling gf_sg_get_next_available_node_id
n | the target node |
nodeID | ID to set to the node, ignored if 0. |
nodeDEFName | optional readable name (script, MPEGJ). To change the name, recall the function with a different name and the same ID |
const char* gf_node_get_name | ( | GF_Node * | n | ) |
gets def name of the node
n | the target node |
const char* gf_node_get_log_name | ( | GF_Node * | n | ) |
gets def name of the node, or the string representation of the node pointer if not set
n | the target node |
gets def ID of the node
n | the target node |
const char* gf_node_get_class_name | ( | GF_Node * | n | ) |
gets node built-in name (eg 'Appearance', ..)
n | the target node |
unsets the node ID
n | the target node |
void* gf_node_get_private | ( | GF_Node * | n | ) |
gets user private of node
n | the target node |
void gf_node_set_private | ( | GF_Node * | n, |
void * | udta | ||
) |
sets user private of node
n | the target node |
udta | user data to assign to the node |
GF_Err gf_node_set_callback_function | ( | GF_Node * | n, |
gf_sg_node_callback | NodeFunction | ||
) |
sets traversal callback function. If a node has no associated callback, the traversing of the graph won't propagate below it. It is the app responsibility to setup traversing functions as needed VRML/MPEG4: Instantiated Protos are handled internally as well as interpolators, valuators and scripts
n | the target node |
NodeFunction | the callback function |
registers a node (DEFed or not), specifying parent if any. A node must be registered whenever used by something (a parent node, a command, whatever) to prevent its destruction (think of it as a reference counting).
n | the target node |
parent_node | the parent node this node should be registered with |
unregister a node from parent (node may or not be DEF'ed). Parent may be NULL (DEF root node, commands). This MUST be called whenever a node is destroyed (removed from a parent node) If this is the last instance of the node, the node is destroyed
n | the target node |
parent_node | the parent node this node should be unregistered from |
void gf_node_unregister_children | ( | GF_Node * | node, |
GF_ChildNodeItem * | childrenlist | ||
) |
unregisters all children in the given list
node | the target parent node owning the list |
childrenlist | the list of children to unregister |
gets all parents of the node and replace the old_node by the new node in all parents
old_node | old node to replace |
new_node | new node to replace with |
updateOrderedGroup | if GF_TRUE, update the order field of parent OrderdedGroup nodes |
gets the number of node instances
n | the target node |
void gf_node_traverse | ( | GF_Node * | n, |
void * | udta | ||
) |
calls node traverse callback routine on this node
n | the target node |
udta | opaque data passed to the node traverse callback |
void gf_node_allow_cyclic_traverse | ( | GF_Node * | n | ) |
allows a node to be re-rendered - by default a node in its render callback will never be retraversed a second time. Use this function to enable a second traverse for this node while traversing it
n | the target node |
sets the cyclic traverse flag
n | the target node |
on | indicates if cyclic traverse shall be turned on or off |
void gf_node_traverse_children | ( | GF_Node * | n, |
void * | udta | ||
) |
blindly calls traverse callback on all children nodes
n | the target node |
udta | opaque data passed to the node traverse callback |
get the number of parent for this node (parent are kept regardless of DEF state)
n | the target node |
returns desired parent for this node (parent are kept regardless of DEF state)
n | the target node |
idx | 0-based parent index |
checks if a node belongs to a subtree
parent | the target parent node |
target | the target node |
sets dirty flags
n | the target node |
flags | if 0, sets the base flags on (GF_SG_NODE_DIRTY); otherwise, adds the flags to the node dirty state |
dirty_parents | if GF_TRUE, all parent subtrees for this node are marked as GF_SG_CHILD_DIRTY |
void gf_node_dirty_parents | ( | GF_Node * | n | ) |
marks all parent subtrees for this node as GF_SG_CHILD_DIRTY
n | the target node |
sets dirty flag off. It is the user responsibility to clear dirty flags
n | the target node |
flags | if 0, all flags are set off; otherwise, removes the indicated flags from the node dirty state |
reset dirty state of a node
n | the target node |
reset_children | if GF_TRUE and node was dirty, resets the state of all its children |
gets dirty flag value
n | the target node |
returns number of field for this node. For BIFS/VRML/X3D, this is the number of defined fields by the spec. For SVG/DOM, this is the number of attributes defined for the node.
n | the target node |
GF_Err gf_node_get_field | ( | GF_Node * | n, |
u32 | FieldIndex, | ||
GF_FieldInfo * | info | ||
) |
fills the field info structure for the given field
n | the target node |
FieldIndex | the 0-based index of the target field |
info | filled with field info |
GF_Err gf_node_get_field_by_name | ( | GF_Node * | n, |
char * | name, | ||
GF_FieldInfo * | field | ||
) |
gets the field by its name
n | the target node |
name | name of the target field |
field | filled with field info |
GF_SceneGraph* gf_sg_new | ( | ) |
creates a new scene graph
GF_SceneGraph* gf_sg_new_subscene | ( | GF_SceneGraph * | scene | ) |
creates a sub scene graph (typically used with Inline node): independent graph with same private stack, and user callbacks as parent. All routes triggered in this subgraph are executed in the parent graph (this means you only have to activate routes on the main graph)
scene | the parent scene graph |
void gf_sg_del | ( | GF_SceneGraph * | sg | ) |
destroys a scene graph
sg | the target scene graph |
void gf_sg_reset | ( | GF_SceneGraph * | sg | ) |
resets the graph - all nodes, routes and protos are destroyed
sg | the target scene graph |
void gf_sg_set_private | ( | GF_SceneGraph * | sg, |
void * | udta | ||
) |
sets user private data for scene graph
sg | the target scene graph |
udta | user private data to set |
void* gf_sg_get_private | ( | GF_SceneGraph * | sg | ) |
gets user private data of scene graph
sg | the target scene graph |
void gf_sg_set_scene_time_callback | ( | GF_SceneGraph * | sg, |
Double(*)(void *user_priv) | GetSceneTime | ||
) |
sets the scene time query callback (functions returns time in sec)
sg | the target scene graph |
GetSceneTime | the scene time query callback |
GF_SceneGraph* gf_sg_get_parent | ( | GF_SceneGraph * | sg | ) |
gets the parent scene graph of a graph
sg | the target scene graph |
void gf_sg_set_node_callback | ( | GF_SceneGraph * | sg, |
gf_sg_node_init_callback | NodeCallback | ||
) |
sets node callback: function called upon node creation. Application should instantiate the node rendering stack and any desired callback
sg | the target scene graph |
NodeCallback | the node callback function |
GF_Node* gf_sg_get_root_node | ( | GF_SceneGraph * | sg | ) |
gets the root node of the graph
sg | the target scene graph |
void gf_sg_set_root_node | ( | GF_SceneGraph * | sg, |
GF_Node * | node | ||
) |
sets the root node of the graph
sg | the target scene graph |
node | root node of the scene graph |
finds a registered node by ID
sg | the target scene graph |
nodeID | ID of the node to find |
GF_Node* gf_sg_find_node_by_name | ( | GF_SceneGraph * | sg, |
char * | name | ||
) |
finds a registered node by DEF name
sg | the target scene graph |
name | name of the node to find |
void gf_node_changed | ( | GF_Node * | n, |
GF_FieldInfo * | fieldChanged | ||
) |
signals node has been modified, indicating which field is modified
n | the target node |
fieldChanged | the modified field, may be NULL of global node modification |
GF_SceneGraph* gf_node_get_graph | ( | GF_Node * | n | ) |
gets the scene graph of a node
n | the target node |
sets size info for the graph - by default graphs have no size and are in meter metrics (VRML like) if any of width or height is 0, the graph has no size info
sg | the target scene graph |
width | width in pixels |
height | height in pixels |
usePixelMetrics | indicates coordinates in graph are given in pixels |
Bool gf_sg_use_pixel_metrics | ( | GF_SceneGraph * | sg | ) |
checks if pixel metrics is used
sg | the target scene graph |
gets size information of graph
sg | the target scene graph |
width | set to width of scene |
height | set to height of scene |
creates a node of the given tag. sg is the parent scenegraph of the node, eg the root one for scene nodes or the proto one for proto code (cf proto)
sg | the target scene graph |
tag | tag of node to create |
void gf_node_init | ( | GF_Node * | n | ) |
inits node (either internal stack or user-defined) - usually called once the node has been fully loaded
n | the target node |
GF_Node* gf_node_clone | ( | GF_SceneGraph * | inScene, |
GF_Node * | orig, | ||
GF_Node * | cloned_parent, | ||
char * | id_suffix, | ||
Bool | deep | ||
) |
clones a node in the given graph and register with parent cloned.
inScene | the target scene graph in which the node should be cloned |
orig | the target node to clone |
cloned_parent | the parent of the node to clone |
id_suffix | if NULL, all IDs are removed from the cloned subtree, (each node instance will become a hard copy). If empty string "", ID will be kept exactly as they where in the original subtree (this may lead to errors due to the presence of the same ID depending on the standard). Otherwise, all IDs are translated ( -> id_suffix) and binary IDs are generated on the fly |
deep | clones children as well |
gets scene time for scene this node belongs too
n | the target node |
u32 gf_sg_get_next_available_node_id | ( | GF_SceneGraph * | sg | ) |
gets next available NodeID
sg | the target scene graph |
u32 gf_sg_get_max_node_id | ( | GF_SceneGraph * | sg | ) |
gets max ID used in graph
sg | the target scene graph |
gets node ID and name
n | the target node |
ID | set to the node ID or to 0 if not defined |
void gf_sg_set_script_action | ( | GF_SceneGraph * | sg, |
gf_sg_script_action | script_act, | ||
void * | cbk | ||
) |
assigns API to scene graph - by default, sub-graphs inherits the API if set
sg | the target scene graph |
script_act | the script action callback |
cbk | opaque data to pass to the script action callback |
void gf_sg_script_load | ( | GF_Node * | script | ) |
loads script into engine - this should be called only for script in main scene, loading of scripts in protos is done internally when instanciating the proto
script | the target script node |
Bool gf_sg_has_scripting | ( | ) |
checks if scripting is supported in GPAC (built-in and run-time enabled)
GF_Command* gf_sg_command_new | ( | GF_SceneGraph * | sg, |
u32 | tag | ||
) |
creates a command - graph is only needed for SceneReplace
sg | parent scene graph of the command, only needed for SceneReplace |
tag | the command tag |
void gf_sg_command_del | ( | GF_Command * | com | ) |
destroys a command
com | the target command |
GF_Err gf_sg_command_apply | ( | GF_SceneGraph * | sg, |
GF_Command * | com, | ||
Double | time_offset | ||
) |
applies command to graph - the command content is kept unchanged for authoring purposes - THIS NEEDS TESTING AND FIXING
sg | the target scene graph where to apply the command |
com | the target command |
time_offset | time offset in seconds for time fields if desired |
applies list if command to graph - the command content is kept unchanged for authoring purposes
sg | the target scene graph where to apply the command |
comList | the list of commands |
time_offset | time offset in seconds for time fields if desired |
GF_CommandField* gf_sg_command_field_new | ( | GF_Command * | com | ) |
creates a new command field structire (some commands may target multiple fields at once) and registers it with command
com | the parent command |
GF_Err gf_sg_init_from_xml_node | ( | GF_SceneGraph * | document, |
GF_DOMXMLNODE | root_node | ||
) |
Creates a GF_SceneGraph from an XML root node. This is mostly used to allow using DOM API on an XML doc
document | an empty scene graph object |
root_node | the root node of an XML document |