📄 scenegraph.h
字号:
void gf_sg_reset(GF_SceneGraph *sg);/*set/get user private data*/void gf_sg_set_private(GF_SceneGraph *sg, void *user_priv);void *gf_sg_get_private(GF_SceneGraph *sg);/*set the scene timer (fct returns time in sec)*/void gf_sg_set_scene_time_callback(GF_SceneGraph *scene, Double (*GetSceneTime)(void *user_priv) );enum{ /*function called upon node creation. ctxdata is not used*/ GF_SG_CALLBACK_INIT = 0, /*function called upon node modification. You typically will set some of the dirty flags here. ctxdata is the fieldInfo pointer of the modified field*/ GF_SG_CALLBACK_MODIFIED, /*function called when the a "set dirty" propagates to root node of the graph ctxdata is not used*/ GF_SG_CALLBACK_GRAPH_DIRTY,};/*set node callback: function called upon node creation. Application should instanciate the node rendering stack and any desired callback*/void gf_sg_set_node_callback(GF_SceneGraph *sg, void (*NodeCallback)(void *user_priv, u32 type, GF_Node *node, void *ctxdata) );/*get/set the root node of the graph*/GF_Node *gf_sg_get_root_node(GF_SceneGraph *sg);void gf_sg_set_root_node(GF_SceneGraph *sg, GF_Node *node);/*finds a registered node by ID*/GF_Node *gf_sg_find_node(GF_SceneGraph *sg, u32 nodeID);/*finds a registered node by DEF name*/GF_Node *gf_sg_find_node_by_name(GF_SceneGraph *sg, char *name);/*used to signal modification of a node, indicating which field is modified - exposed for BIFS codec, should not be needed by other apps*/void gf_node_changed(GF_Node *node, GF_FieldInfo *fieldChanged);/*returns the graph this node belongs to*/GF_SceneGraph *gf_node_get_graph(GF_Node *node);/*Set 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*/void gf_sg_set_scene_size_info(GF_SceneGraph *sg, u32 width, u32 Height, Bool usePixelMetrics);/*returns 1 if pixelMetrics*/Bool gf_sg_use_pixel_metrics(GF_SceneGraph *sg);/*returns 0 if no size info, otherwise 1 and set width/height*/Bool gf_sg_get_scene_size_info(GF_SceneGraph *sg, u32 *width, u32 *Height);/*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)Note: - NODE IS NOT REGISTERED (no instances) AND CANNOT BE DESTROYED UNTIL REGISTERED - this doesn't perform application setup for the node, this must be done by the caller*/GF_Node *gf_node_new(GF_SceneGraph *sg, u32 tag);/*clones a node in the given graph and register with parent cloned. The cloning respects DEF/USE nodes*/GF_Node *gf_node_clone(GF_SceneGraph *inScene, GF_Node *orig, GF_Node *cloned_parent);/*inits node (either internal stack or user-defined) - usually called once the node has been fully loaded*/void gf_node_init(GF_Node *node);/*gets scene time for scene this node belongs too, 0 if timeline not specified*/Double gf_node_get_scene_time(GF_Node *node);/*retuns next available NodeID*/u32 gf_sg_get_next_available_node_id(GF_SceneGraph *sg);/*retuns max ID used in graph*/u32 gf_sg_get_max_node_id(GF_SceneGraph *sg);const char *gf_node_get_name_and_id(GF_Node*node, u32 *id);enum{ GF_SG_FOCUS_AUTO = 1, GF_SG_FOCUS_NEXT, GF_SG_FOCUS_PREV, GF_SG_FOCUS_NORTH, GF_SG_FOCUS_NORTH_EAST, GF_SG_FOCUS_EAST, GF_SG_FOCUS_SOUTH_EAST, GF_SG_FOCUS_SOUTH, GF_SG_FOCUS_SOUTH_WEST, GF_SG_FOCUS_WEST, GF_SG_FOCUS_NORTH_WEST};typedef struct{ const char *url; const char **params; u32 nb_params;} GF_JSAPIURI;typedef struct{ const char *section; const char *key; const char *key_val;} GF_JSAPIOPT; /*for script message option*/typedef struct{ GF_Err e; const char *msg;} GF_JSAPIINFO;typedef union{ 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_JSAPIINFO info;} GF_JSAPIParam;enum{ /*!push message from script engine.*/ GF_JSAPI_OP_MESSAGE, /*!get scene URI.*/ GF_JSAPI_OP_GET_SCENE_URI, /*!get current user agent scale.*/ GF_JSAPI_OP_GET_SCALE, /*!set current user agent scale.*/ GF_JSAPI_OP_SET_SCALE, /*!get current user agent rotation.*/ GF_JSAPI_OP_GET_ROTATION, /*!set current user agent rotation.*/ GF_JSAPI_OP_SET_ROTATION, /*!get current user agent translation.*/ GF_JSAPI_OP_GET_TRANSLATE, /*!set current user agent translation.*/ GF_JSAPI_OP_SET_TRANSLATE, /*!get node time.*/ GF_JSAPI_OP_GET_TIME, /*!set node time.*/ GF_JSAPI_OP_SET_TIME, /*!get current viewport.*/ GF_JSAPI_OP_GET_VIEWPORT, /*!get object bounding box in object local coord system.*/ GF_JSAPI_OP_GET_LOCAL_BBOX, /*!get object bounding box in world (screen) coord system.*/ GF_JSAPI_OP_GET_SCREEN_BBOX, /*!get transform matrix at object.*/ GF_JSAPI_OP_GET_TRANSFORM, /*!move focus according to opt value.*/ GF_JSAPI_OP_MOVE_FOCUS, /*!set focus to given node.*/ GF_JSAPI_OP_GET_FOCUS, /*!set focus to given node.*/ GF_JSAPI_OP_SET_FOCUS, /*!get target scene URL*/ GF_JSAPI_OP_GET_URL, /*!replace target scene URL*/ GF_JSAPI_OP_LOAD_URL, /*!get option by section and key*/ GF_JSAPI_OP_GET_OPT, /*!get option by section and key*/ GF_JSAPI_OP_SET_OPT, /*!retrieve download manager*/ GF_JSAPI_OP_GET_DOWNLOAD_MANAGER,};/*interface to various get/set options: type: operand type, one of the above node: target node, scene root node or NULL param: i/o param, depending on operand type*/typedef Bool (*gf_sg_script_action)(void *callback, u32 type, GF_Node *node, GF_JSAPIParam *param);/*assign API to scene graph - by default, sub-graphs inherits the API if set*/void gf_sg_set_script_action(GF_SceneGraph *scene, gf_sg_script_action script_act, void *cbk);/*load script into engine - this should be called only for script in main scene, loading of scriptsin protos is done internally when instanciating the proto*/void gf_sg_script_load(GF_Node *script);/*returns true if current lib has javascript support*/Bool gf_sg_has_scripting();/* 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*//* Currently defined possible modifications*/enum{ /*BIFS commands*/ GF_SG_SCENE_REPLACE = 0, GF_SG_NODE_REPLACE, GF_SG_FIELD_REPLACE, GF_SG_INDEXED_REPLACE, GF_SG_ROUTE_REPLACE, GF_SG_NODE_DELETE, GF_SG_INDEXED_DELETE, GF_SG_ROUTE_DELETE, GF_SG_NODE_INSERT, GF_SG_INDEXED_INSERT, GF_SG_ROUTE_INSERT, /*extended updates (BIFS-only)*/ GF_SG_PROTO_INSERT, GF_SG_PROTO_DELETE, GF_SG_PROTO_DELETE_ALL, GF_SG_MULTIPLE_REPLACE, GF_SG_MULTIPLE_INDEXED_REPLACE, GF_SG_GLOBAL_QUANTIZER, /*same as NodeDelete, and also updates OrderedGroup.order when deleting a child*/ GF_SG_NODE_DELETE_EX, GF_SG_LAST_BIFS_COMMAND, /*LASER commands*/ GF_SG_LSR_NEW_SCENE, GF_SG_LSR_REFRESH_SCENE, GF_SG_LSR_ADD, GF_SG_LSR_CLEAN, GF_SG_LSR_REPLACE, GF_SG_LSR_DELETE, GF_SG_LSR_INSERT, GF_SG_LSR_RESTORE, GF_SG_LSR_SAVE, GF_SG_LSR_SEND_EVENT, GF_SG_LSR_ACTIVATE, GF_SG_LSR_DEACTIVATE, GF_SG_UNDEFINED};/* single command wrapper NOTE: In order to maintain node registry, the nodes replaced/inserted MUST be registered with their parents even when the command is never applied. Registering shall be performed with gf_node_register (see below). If you fail to do so, a node may be destroyed when destroying a command while still used in another command or in the graph - this will just crash.*//*structure used to store field info, pos and static pointers to GF_Node/MFNode in commands*/typedef struct{ u32 fieldIndex; /*field type*/ u32 fieldType; /*field pointer for multiple replace/multiple indexed replace - if multiple indexed replace, must be the SF field being changed*/ void *field_ptr; /*replace/insert/delete pos - -1 is append except in multiple indexed replace*/ s32 pos; /*Whenever field pointer is of type GF_Node, store the node here and set the far pointer to this address.*/ GF_Node *new_node; /*Whenever field pointer is of type MFNode, store the node list here and set the far pointer to this address.*/ GF_ChildNodeItem *node_list;} GF_CommandField;typedef struct{ GF_SceneGraph *in_scene; u32 tag; /*node the command applies to - may be NULL*/ GF_Node *node; /*list of GF_CommandField for all field commands replace/ index insert / index replace / index delete / MultipleReplace / MultipleIndexedreplace the content is destroyed when deleting the command*/ GF_List *command_fields; /*may be NULL, and may be present with any command inserting a node*/ GF_List *scripts_to_load; /*for authoring purposes - must be cleaned by user*/ Bool unresolved; char *unres_name; /*scene replace command: root node is stored in com->node protos are stored in com->new_proto_list routes are stored as RouteInsert in the same frame BIFS only */ Bool use_names; /*route insert, replace and delete (BIFS only) fromNodeID is also used to identify operandElementId in LASeR Add/Replace */ u32 RouteID; char *def_name; u32 fromNodeID, fromFieldIndex; u32 toNodeID, toFieldIndex; /*proto list to insert - BIFS only*/ GF_List *new_proto_list; /*proto ID list to delete - BIFS only*/ u32 *del_proto_list; u32 del_proto_list_size;} GF_Command;/*creates command - graph only needed for SceneReplace*/GF_Command *gf_sg_command_new(GF_SceneGraph *in_scene, u32 tag);/*deletes command*/void gf_sg_command_del(GF_Command *com);/*apply command to graph - the command content is kept unchanged for authoring purposes - THIS NEEDS TESTING AND FIXING@time_offset: offset for time fields if desired*/GF_Err gf_sg_command_apply(GF_SceneGraph *inScene, GF_Command *com, Double time_offset);/*apply list if command to graph - the command content is kept unchanged for authoring purposes@time_offset: offset for time fields if desired*/GF_Err gf_sg_command_apply_list(GF_SceneGraph *graph, GF_List *comList, Double time_offset);/*returns new commandFieldInfo structure and registers it with command*/GF_CommandField *gf_sg_command_field_new(GF_Command *com);/*clones the command in another graph - needed for uncompressed conditional in protos*/GF_Command *gf_sg_command_clone(GF_Command *com, GF_SceneGraph *inGraph);#ifdef __cplusplus}#endif#endif /*_GF_SCENEGRAPH_H_*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -