libgpac
Documentation of the core library of GPAC
|
Scenegraph for VRML files. More...
Data Structures | |
struct | SFString |
struct | SFColor |
struct | SFColorRGBA |
struct | SFURL |
struct | SFVec2d |
struct | SFVec3d |
struct | SFImage |
struct | SFCommandBuffer |
struct | SFScript |
struct | SFAttrRef |
struct | GenMFField |
struct | MFInt32 |
struct | MFInt |
struct | MFFloat |
struct | MFDouble |
struct | MFBool |
struct | MFColor |
struct | MFColorRGBA |
struct | MFRotation |
struct | MFTime |
struct | MFVec2f |
struct | MFVec2d |
struct | MFVec3f |
struct | MFVec3d |
struct | MFVec4f |
struct | MFURL |
struct | MFString |
struct | MFScript |
struct | MFAttrRef |
struct | GF_VRMLParent |
Macros | |
#define | MPEG4_RESERVED_NDT 200 |
#define | GF_SG_INTERNAL_PROTO (PTR_TO_U_CAST -1) |
#define | VRML_CHILDREN |
Typedefs | |
typedef u32 | SFBool |
typedef s32 | SFInt32 |
typedef s32 | SFInt |
typedef Fixed | SFFloat |
typedef Double | SFDouble |
typedef Double | SFTime |
typedef struct __vec2f | SFVec2f |
typedef struct __vec3f | SFVec3f |
typedef struct __vec4f | SFRotation |
typedef struct __vec4f | SFVec4f |
typedef struct _proto | GF_Proto |
typedef struct _protofield | GF_ProtoFieldInterface |
typedef struct _scriptfield | GF_ScriptField |
This section documents the Scenegraph for VRML files.
struct SFURL |
URL
Data Fields | ||
---|---|---|
u32 | OD_ID | |
char * | url |
struct SFImage |
struct SFCommandBuffer |
struct SFScript |
struct SFAttrRef |
struct GenMFField |
struct MFColor |
struct MFColorRGBA |
struct MFRotation |
Rotation array
Data Fields | ||
---|---|---|
u32 | count | |
SFRotation * | vals |
struct MFVec2d |
struct MFVec3d |
struct MFString |
String array
Data Fields | ||
---|---|---|
u32 | count | |
char ** | vals |
struct MFScript |
struct MFAttrRef |
struct GF_VRMLParent |
generic VRML parent node
#define MPEG4_RESERVED_NDT 200 |
reserved NDT for MPEG4 (match binary coding)
#define GF_SG_INTERNAL_PROTO (PTR_TO_U_CAST -1) |
internal prototype
#define VRML_CHILDREN |
VRML grouping nodes macro - note we have inverted the children field to be compatible with the base GF_ParentNode node All grouping nodes (with "children" field) implement the following:
addChildren: chain containing nodes to add passed as eventIn - handled internally through ROUTE void (*on_addChildren)(GF_Node *pNode): add feventIn signaler - this is handled internally by the scene_graph and SHALL NOT BE overridden since it takes care of node(s) routing
removeChildren: chain containing nodes to remove passed as eventIn - handled internally through ROUTE
void (*on_removeChildren)(GF_Node *pNode): remove eventIn signaler - this is handled internally by the scene_graph and SHALL NOT BE overridden since it takes care of node(s) routing
children: list of children SFNodes
typedef struct __vec2f SFVec2f |
2D vector (float)
typedef struct __vec3f SFVec3f |
3D vector (float)
typedef struct __vec4f SFRotation |
rotation (float)
typedef struct __vec4f SFVec4f |
4D vector (float)
typedef struct _proto GF_Proto |
proto object
typedef struct _protofield GF_ProtoFieldInterface |
proto field object
typedef struct _scriptfield GF_ScriptField |
script field object
anonymous enum |
the NDTs used in X3D not defined in MPEG4
anonymous enum |
event types of fields, as defined in the specs this should not be needed by non binary codecs
anonymous enum |
field coding mode
BIFS defines the bitstream syntax contextually, and therefore sometimes refer to fields as indexed
in the node ("all" mode) or just as a sub-set (in, out, def, dyn modes) of similar types
anonymous enum |
field types, as defined in BIFS encoding (used for scripts and proto coding)
anonymous enum |
script fields type don't have the same value as the bifs ones...
gets the event type name
EventType | the event type |
forX3D | for X3D dumping |
gets the number of field in the given mode (BIFS specific)
n | the target node |
IndexMode | the field indexing mode |
SFColorRGBA gf_sg_sfcolor_to_rgba | ( | SFColor | val | ) |
converts an SFColor to an SFColorRGBA by setting the alpha component to 1
val | the input color |
checks if a field is an SF field
FieldType | the tragte filed type |
translates MF/SF to SF type
FieldType | the tragte filed type |
inserts (+alloc) a slot in the MFField with a specified position for insertion and sets the ptr to the newly created slot
mf | pointer to the MF field |
FieldType | the MF field type |
new_ptr | set to the allocated slot (do not free) |
InsertAt | is the 0-based index for the new slot |
removes all items of the MFField
mf | pointer to the MF field |
FieldType | the MF field type |
void gf_sg_mfurl_del | ( | MFURL | url | ) |
deletes an MFUrl field
url | the MF url field to reset |
copies MFUrl field
dst | the destination MF url field to copy |
src | the source MF url field to copy |
SFRotation gf_sg_sfrotation_interpolate | ( | SFRotation | kv1, |
SFRotation | kv2, | ||
Fixed | f | ||
) |
interpolates SFRotation
kv1 | start value for interpolation |
kv2 | end value for interpolation |
f | interpolation factor |
adds a new node to the "children" field
parent | the target parent node |
new_child | the child to insert |
pos | the 0-BASED index in the list of children, -1 means end of list (append) |
GF_Err gf_node_replace_child | ( | GF_Node * | node, |
GF_ChildNodeItem ** | container, | ||
s32 | pos, | ||
GF_Node * | newNode | ||
) |
removes and replace given child by specified node. If node is NULL, only delete target node
node | the target node to replace |
container | the container list |
pos | the 0-BASED index in the list of children, -1 means end of list (append) |
newNode | the new node to use |
void gf_sg_vrml_parent_setup | ( | GF_Node * | n | ) |
setup a vrml parent
n | the target node |
void gf_sg_vrml_parent_destroy | ( | GF_Node * | n | ) |
resets all children in a vrml parent node (but does not destroy the node)
n | the target node |
checks if a given node tag is in a given NDT table
tag | the node tag |
NDTType | the NDT type |
const char* gf_sg_vrml_get_field_type_name | ( | u32 | FieldType | ) |
gets field type name
FieldType | the field type |
void* gf_sg_vrml_field_pointer_new | ( | u32 | FieldType | ) |
allocates a new field
FieldType | the field type |
void gf_sg_vrml_field_pointer_del | ( | void * | field, |
u32 | FieldType | ||
) |
deletes a field pointer (including SF an,d MF nodes)
field | the field pointer value |
FieldType | the field type |
adds at the end of an MF field
mf | pointer to the MF field |
FieldType | the MF field type |
new_ptr | set to the allocated SF field slot - do not destroy |
removes the desired item of an MF field
mf | pointer to the MF field |
FieldType | the MF field type |
RemoveFrom | the 0-based index of item to remove |
allocates an MF array
mf | pointer to the MF field |
FieldType | the MF field type |
NbItems | number of items to allocate |
gets the item in the MF array
mf | pointer to the MF field |
FieldType | the MF field type |
new_ptr | set to the SF field slot - do not destroy |
ItemPos | the 0-based index of item to remove |
void gf_sg_vrml_field_copy | ( | void * | dest, |
void * | orig, | ||
u32 | FieldType | ||
) |
copies a field content EXCEPT SF/MFNode. Pointers to field shall be used
dest | pointer to the MF field |
orig | pointer to the MF field |
FieldType | the MF field type |
void gf_sg_vrml_field_clone | ( | void * | dest, |
void * | orig, | ||
u32 | FieldType, | ||
GF_SceneGraph * | inScene | ||
) |
clones a field content EXCEPT SF/MFNode. Pointers to field shall be used
dest | pointer to the MF field |
orig | pointer to the MF field |
FieldType | the MF field type |
inScene | target scene graph for SFCommandBuffers cloning |
indicates whether 2 fields of same type EXCEPT SF/MFNode are equal
dest | pointer to the MF field |
orig | pointer to the MF field |
FieldType | the MF field type |
GF_Route* gf_sg_route_new | ( | GF_SceneGraph * | sg, |
GF_Node * | fromNode, | ||
u32 | fromField, | ||
GF_Node * | toNode, | ||
u32 | toField | ||
) |
creates a new route
sg | the target scene graph of the route |
fromNode | the source node triggering the event out |
fromField | the source field triggering the event out |
toNode | the destination node accepting the event in |
toField | the destination field accepting the event in |
void gf_sg_route_del | ( | GF_Route * | route | ) |
destroys a route
route | the target route |
GF_Err gf_sg_route_del_by_id | ( | GF_SceneGraph * | sg, |
u32 | routeID | ||
) |
destroys a route by ID
sg | the scene graph of the route |
routeID | the ID of the route to destroy |
GF_Route* gf_sg_route_find | ( | GF_SceneGraph * | sg, |
u32 | RouteID | ||
) |
locate a route by ID
sg | the scene graph of the route |
RouteID | the ID of the route |
GF_Route* gf_sg_route_find_by_name | ( | GF_SceneGraph * | sg, |
char * | name | ||
) |
locate a route by name
sg | the scene graph of the route |
name | the name of the route |
assigns a route ID
route | the target route |
ID | the ID to assign |
assign a route name
route | the target route |
name | the name to assign |
char* gf_sg_route_get_name | ( | GF_Route * | route | ) |
gets route name
route | the target route |
u32 gf_sg_get_next_available_route_id | ( | GF_SceneGraph * | sg | ) |
retuns next available RouteID
sg | the target scene graph of the route |
void gf_sg_set_max_defined_route_id | ( | GF_SceneGraph * | sg, |
u32 | ID | ||
) |
sets max defined route ID used in the scene - used to handle RouteInsert commands note that this must be called by the user to be effective,; otherwise the max route ID is computed from the routes present in scene
sg | the target scene graph of the route |
ID | the value of the max defined route ID |
void gf_sg_route_new_to_callback | ( | GF_SceneGraph * | sg, |
GF_Node * | fromNode, | ||
u32 | fromField, | ||
void * | cbk, | ||
void(*)(void *param, GF_FieldInfo *from_field) | route_callback | ||
) |
creates a new route from a node output to a given callback/function
sg | the target scene graph of the route |
fromNode | the source node emiting the event out |
fromField | the source field emiting the event out |
cbk | opaque data to pass to the callback |
route_callback | route callback function to call |
void gf_sg_activate_routes | ( | GF_SceneGraph * | sg | ) |
activates all routes currently triggered - this follows the event cascade model of VRML/MPEG4:
A route cannot be activated twice in the same simulation tick, hence this function shall be called ONCE AND ONLY ONCE per simulation tick
Note that children scene graphs register their routes with the top-level graph, so only the main scene graph needs to be activated
sg | the target scene graph of the route |
u32 gf_sg_get_next_available_proto_id | ( | GF_SceneGraph * | sg | ) |
retuns next available proto ID
sg | the target scene graph of the proto |
GF_Proto* gf_sg_proto_new | ( | GF_SceneGraph * | sg, |
u32 | ProtoID, | ||
char * | name, | ||
Bool | unregistered | ||
) |
constructs a new proto identified by ID/name in the given scene 2 protos in the same scene may not have the same ID/name
sg | the target scene graph in which the proto is created |
ProtoID | ID of the proto to create |
name | name of the proto to create |
unregistered | if GF_TRUE, the proto is not stored in the graph main proto list but in an alternate list (used for memory handling of scene graph only). Several protos with the same ID/Name can be stored unregistered |
destroys a proto - can be used even if instances of the proto are still present
proto | the target proto |
GF_SceneGraph* gf_sg_proto_get_graph | ( | GF_Proto * | proto | ) |
returns the graph associated with this proto. Such a graph cannot be used for rendering but is needed during construction of proto dictionaries in case of nested protos
proto | the target proto |
adds node code - a proto is build of several nodes, the first node is used for rendering and the others are kept private. This set of nodes is referred to as the proto "node code"
proto | the target proto |
n | the node to add to the proto code |
gets number of field in the proto interface
proto | the target proto |
GF_ProtoFieldInterface* gf_sg_proto_field_find_by_name | ( | GF_Proto * | proto, |
char * | fieldName | ||
) |
locates a field declaration by name
proto | the target proto |
fieldName | the name of the field |
GF_ProtoFieldInterface* gf_sg_proto_field_find | ( | GF_Proto * | proto, |
u32 | fieldIndex | ||
) |
locates field declaration by index
proto | the target proto |
fieldIndex | 0-based index of the field to query |
GF_ProtoFieldInterface* gf_sg_proto_field_new | ( | GF_Proto * | proto, |
u32 | fieldType, | ||
u32 | eventType, | ||
char * | fieldName | ||
) |
creates a new field declaration in the proto. of given fieldtype and eventType fieldName can be NULL, if so the name will be fieldN, N being the index of the created field
proto | the target proto |
fieldType | the data type of the field to create |
eventType | the event type of the field to create |
fieldName | the name of the field to create (may be NULL) |
GF_Err gf_sg_proto_field_set_ised | ( | GF_Proto * | proto, |
u32 | protoFieldIndex, | ||
GF_Node * | node, | ||
u32 | nodeFieldIndex | ||
) |
assigns the node field to a field of the proto (the node field IS the proto field) the node shall be a node of the proto scenegraph, and the fieldtype/eventType of both fields shall match (except SF/MFString and MF/SFURL which are allowed) due to BIFS semantics
proto | the target proto |
protoFieldIndex | the proto field index to assign |
node | the node (shall be part of the proto node code) to link to |
nodeFieldIndex | the field index of the node to link to |
GF_Err gf_sg_proto_field_get_field | ( | GF_ProtoFieldInterface * | field, |
GF_FieldInfo * | info | ||
) |
returns field info of the field - this is typically used to setup the default value of the field
field | the proto field interface to query |
info | filled with the proto field interface info |
GF_Node* gf_sg_proto_create_instance | ( | GF_SceneGraph * | sg, |
GF_Proto * | proto | ||
) |
creates the proto instance without the proto code
sg | the target scene graph of the node |
proto | the proto to instanciate |
loads code in this instance - all subprotos are automatically created, thus you must only instantiate top-level protos. VRML/BIFS doesn't allow for non top-level proto instanciation in the main graph All nodes created in this proto will be forwarded to the app for initialization
proto_inst | the proto instance to load |
GF_Proto* gf_sg_find_proto | ( | GF_SceneGraph * | sg, |
u32 | ProtoID, | ||
char * | name | ||
) |
locates a prototype definition by ID or by name. when looking by name, ID is ignored
sg | the target scene graph of the proto |
ProtoID | the ID of the proto to locate |
name | the name of the proto to locate |
GF_Err gf_sg_delete_all_protos | ( | GF_SceneGraph * | sg | ) |
deletes all protos in given scene - does NOT delete instances of protos, only the proto object is destroyed
sg | the target scene graph |
gets proto of a prototype instance node
node | the target prototype instance node |
returns the ID of a proto
proto | the target proto |
const char* gf_sg_proto_get_class_name | ( | GF_Proto * | proto | ) |
returns the name of a proto
proto | the target proto |
Bool gf_sg_proto_field_is_sftime_offset | ( | GF_Node * | node, |
GF_FieldInfo * | field | ||
) |
checks if a proto instance field is an SFTime routed to a startTime/stopTime field in the proto code (MPEG-4 specific for updates)
node | the target prototype instance node |
field | the target field info |
GF_Err gf_sg_proto_instance_set_ised | ( | GF_Node * | protoinst, |
u32 | protoFieldIndex, | ||
GF_Node * | node, | ||
u32 | nodeFieldIndex | ||
) |
sets an ISed (route between proto instance and internal proto code) field in a proto instance (not a proto) - this is needed with dynamic node creation inside a proto instance (conditionals)
protoinst | the target prototype instance node |
protoFieldIndex | field index in prototype instance node |
node | the target node |
nodeFieldIndex | field index in the target node |
returns root node (the one and only one being traversed) of this proto instance if any
node | the target prototype instance node |
void gf_sg_proto_mark_field_loaded | ( | GF_Node * | node, |
GF_FieldInfo * | info | ||
) |
indicates proto field has been parsed and its value is valid - this is needed for externProtos not specifying default values
node | the target prototype instance node |
info | the target field info |
void gf_sg_set_proto_loader | ( | GF_SceneGraph * | sg, |
GF_SceneGraph *(*)(void *SceneCallback, MFURL *lib_url) | GetExternProtoLib | ||
) |
sets proto loader callback - callback user data is the same as simulation time callback
GetExternProtoLib is a pointer to the proto lib loader - this callback shall return the LPSCENEGRAPH of the extern proto lib if found and loaded, NULL if not found and GF_SG_INTERNAL_PROTO for internal hardcoded protos (extensions of MPEG-4 scene graph used for module deveopment)
sg | the target scene graph |
GetExternProtoLib | the callback function |
gets a pointer to the MF URL field for externProto info - DO NOT TOUCH THIS FIELD
proto | the target proto field |
GF_ScriptField* gf_sg_script_field_new | ( | GF_Node * | script, |
u32 | eventType, | ||
u32 | fieldType, | ||
const char * | name | ||
) |
creates new sript field - script fields are dynamically added to the node, and thus can be accessed through the same functions as other GF_Node fields
script | the script node |
eventType | the event type of the new field |
fieldType | the data type of the new field |
name | the name of the new field |
GF_Err gf_sg_script_field_get_info | ( | GF_ScriptField * | field, |
GF_FieldInfo * | info | ||
) |
retrieves field info of a script field object, useful to get the field index
field | the script field to query |
info | filled with the field info |
void gf_sg_script_event_in | ( | GF_Node * | script, |
GF_FieldInfo * | in_field | ||
) |
activates eventIn for script node - needed for BIFS field replace
script | the target script node |
in_field | the field info of the activated event in field |
signals eventOut has been set by field index
n | the target node emitin the event |
FieldIndex | the field index emiting the event |
void gf_node_event_out_str | ( | GF_Node * | n, |
const char * | eventName | ||
) |
signals eventOut has been set by event name.
n | the target node emitin the event |
eventName | the name of the field emiting the event |
u32 gf_node_mpeg4_type_by_class_name | ( | const char * | node_name | ) |
gets MPEG-4 / VRML node tag by class name
node_name | the node name |
u32 gf_node_x3d_type_by_class_name | ( | const char * | node_name | ) |
gets X3D node tag by class name
node_name | the node name |
check if a hardcoded prototype node acts as a grouping node
n | the target prototype instance node |
tags a hardcoded proto as being a grouping node
n | the target prototype instance node |
GF_Err gf_node_set_proto_eventin_handler | ( | GF_Node * | n, |
u32 | fieldIndex, | ||
void(*)(GF_Node *pThis, struct _route *route) | event_in_cbk | ||
) |
assigns callback to an eventIn field of an hardcoded proto
n | the target prototype instance node |
fieldIndex | the target field index |
event_in_cbk | the event callback function |