📄 scenegraph_vrml.h
字号:
void gf_sg_vrml_field_pointer_del(void *field, u32 FieldType);Bool gf_sg_vrml_is_sf_field(u32 FieldType);/*translates MF/SF to SF type*/u32 gf_sg_vrml_get_sf_type(u32 FieldType);/* MFField manipulation - MFNode cannot use these, use the GF_List functions instead or the Node_* insertion functions FieldType shall always be given when manipulating MFFields*//*Insert (+alloc) a slot in the MFField with a specified position for insertion and sets the ptrto the newly created slot@InsertAt is the 0-based index for the new slot*/GF_Err gf_sg_vrml_mf_insert(void *mf, u32 FieldType, void **new_ptr, u32 InsertAt);/*adds at the end and gets the ptr*/GF_Err gf_sg_vrml_mf_append(void *mf, u32 FieldType, void **new_ptr);/*remove the desired item*/GF_Err gf_sg_vrml_mf_remove(void *mf, u32 FieldType, u32 RemoveFrom);/*alloc a fixed array*/GF_Err gf_sg_vrml_mf_alloc(void *mf, u32 FieldType, u32 NbItems);/*get the item in the array*/GF_Err gf_sg_vrml_mf_get_item(void *mf, u32 FieldType, void **new_ptr, u32 ItemPos);/*remove all items of the MFField*/GF_Err gf_sg_vrml_mf_reset(void *mf, u32 FieldType);/*clones a field content EXCEPT SF/MFNode. Pointers to field shall be used@dest, @orig: pointers to field@FieldType: type of the field*/void gf_sg_vrml_field_copy(void *dest, void *orig, u32 FieldType);/*indicates whether 2 fields of same type EXCEPT SF/MFNode are equal@dest, @orig: pointers to field@FieldType: type of the field*/Bool gf_sg_vrml_field_equal(void *dest, void *orig, u32 FieldType);/*VRML grouping nodes macro - note we have inverted the children field to be compatible with the base GF_ParentNode nodeAll grouping nodes (with "children" field) implement the following: addChildren: chain containing nodes to add passed as eventIn - handled internally through ROUTEvoid (*on_addChildren)(GF_Node *pNode): add eventIn signaler - this is handled internally by the scene_graph and SHALL NOT BE OVERRIDEN since it takes care of node(s) routingremoveChildren: chain containing nodes to remove passed as eventIn - handled internally through ROUTEvoid (*on_removeChildren)(GF_Node *pNode): remove eventIn signaler - this is handled internally by the scene_graph and SHALL NOT BE OVERRIDEN since it takes care of node(s) routingchildren: list of children SFNodes*/#define VRML_CHILDREN \ CHILDREN \ GF_ChildNodeItem *addChildren; \ void (*on_addChildren)(GF_Node *pNode); \ GF_ChildNodeItem *removeChildren; \ void (*on_removeChildren)(GF_Node *pNode); \typedef struct{ BASE_NODE VRML_CHILDREN} GF_VRMLParent;void gf_sg_vrml_parent_setup(GF_Node *pNode);void gf_sg_vrml_parent_destroy(GF_Node *pNode);/*set proto loader - callback is the same as simulation time callback GetExternProtoLib is a pointer to the proto lib loader - this callback shall return the LPSCENEGRAPHof the extern proto lib if found and loaded, NULL if not found and GF_SG_INTERNAL_PROTO for internalhardcoded protos (extensions of MPEG-4 scene graph used for module deveopment)*/#define GF_SG_INTERNAL_PROTO (GF_SceneGraph *) 0xFFFFFFFF/*GF_Route manip: routes are used to pass events between nodes. Event handling is managed by the scene graphhowever only the nodes overloading the EventIn handler associated with the event will process the eventIn*/typedef struct _route GF_Route;/*creates a new route: @fromNode: @fromField: address of the eventOut field triggering the route @toNode: @toField: address of the destination eventIn fieldNOTE: routes are automatically destroyed if either the target or origin node of the route is destroyed*/GF_Route *gf_sg_route_new(GF_SceneGraph *sg, GF_Node *fromNode, u32 fromField, GF_Node *toNode, u32 toField);/*delete route*/void gf_sg_route_del(GF_Route *route);GF_Err gf_sg_route_del_by_id(GF_SceneGraph *sg,u32 routeID);/*locate route by ID/name*/GF_Route *gf_sg_route_find(GF_SceneGraph *sg, u32 RouteID);GF_Route *gf_sg_route_find_by_name(GF_SceneGraph *sg, char *name);/*assign route ID - fails if a route with same ID already exist*/GF_Err gf_sg_route_set_id(GF_Route *route, u32 ID);u32 gf_sg_route_get_id(GF_Route *route);/*assign route name if desired*/GF_Err gf_sg_route_set_name(GF_Route *route, char *name);char *gf_sg_route_get_name(GF_Route *route);/*retuns next available RouteID - Note this doesn't track inserted routes, that's the user responsability*/u32 gf_sg_get_next_available_route_id(GF_SceneGraph *sg);/*set max defined route ID used in the scene - used to handle RouteInsert commandsnote that this must be called by the user to be effective,; otherwise the max route ID is computedfrom the routes present in scene*/void gf_sg_set_max_defined_route_id(GF_SceneGraph *sg, u32 ID);/*activates all routes currently triggered - this follows the event cascade model of VRML/MPEG4: - routes are collected during eventOut generation - routes are activated. If eventOuts are generated during activation the cycle goes on. A route cannot be activated twice in the same simulation tick, hence this function shall be called ONCE AND ONLY ONCE per simulation tickNote that children scene graphs register their routes with the top-level graph, so only the main scene graph needs to be activated*/void gf_sg_activate_routes(GF_SceneGraph *sg);/* proto handling The lib allows you to construct prototype nodes as defined in VRML/MPEG4 by constructing proto interfaces and instanciating them. An instanciated proto is handled as a single node for rendering, thus an application will never handle proto instances for rendering*//*opaque handler for a proto object (declaration)*/typedef struct _proto GF_Proto;/*opaque handler for a proto field object (declaration)*/typedef struct _protofield GF_ProtoFieldInterface;/*retuns next available NodeID*/u32 gf_sg_get_next_available_proto_id(GF_SceneGraph *sg);/*proto constructor identified by ID/name in the given scene2 protos in the same scene may not have the same ID/name@unregistered: used for memory handling of scene graph only, the proto is not storedin the graph main proto list but in an alternate list. Several protos with the same ID/Name can be stored unregistered*/GF_Proto *gf_sg_proto_new(GF_SceneGraph *inScene, u32 ProtoID, char *name, Bool unregistered);/*destroy proto interface - can be used even if instances of the proto are still present*/GF_Err gf_sg_proto_del(GF_Proto *proto);/*used for memory handling of scene graph only. move proto from off-graph to in-graph or reverse*/GF_Err gf_sg_proto_set_in_graph(GF_Proto *proto, GF_SceneGraph *inScene, Bool set_in);/*returns graph associated with this proto. Such a graph cannot be used for rendering but is needed duringconstruction of proto dictionaries in case of nested protos*/GF_SceneGraph *gf_sg_proto_get_graph(GF_Proto *proto);/*get/set private data*/void gf_sg_proto_set_private(GF_Proto *proto, void *ptr, void (*OnDelete)(void *ptr) );void *gf_sg_proto_get_private(GF_Proto *proto);/*add node code - a proto is build of several nodes, the first node is used for renderingand the others are kept private. This set of nodes is refered to as the proto "node code"*/GF_Err gf_sg_proto_add_node_code(GF_Proto *proto, GF_Node *pNode);/*gets number of field in the proto interface*/u32 gf_sg_proto_get_field_count(GF_Proto *proto);/*locates field declaration by name*/GF_ProtoFieldInterface *gf_sg_proto_field_find_by_name(GF_Proto *proto, char *fieldName);/*locates field declaration by index (0-based)*/GF_ProtoFieldInterface *gf_sg_proto_field_find(GF_Proto *proto, u32 fieldIndex);/*creates a new field declaration in the proto. of given fieldtype and eventTypefieldName can be NULL, if so the name will be fieldN, N being the index of the created field*/GF_ProtoFieldInterface *gf_sg_proto_field_new(GF_Proto *proto, u32 fieldType, u32 eventType, char *fieldName);/*assign 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*/GF_Err gf_sg_proto_field_set_ised(GF_Proto *proto, u32 protoFieldIndex, GF_Node *node, u32 nodeFieldIndex);/*set/get user private data for the proto field declaration*/void gf_sg_proto_field_set_private(GF_ProtoFieldInterface *field, void *ptr, void (*OnDelete)(void *ptr) );void *gf_sg_proto_field_get_private(GF_ProtoFieldInterface *field);/*returns field info of the field - this is typically used to setup the default value of the field*/GF_Err gf_sg_proto_field_get_field(GF_ProtoFieldInterface *field, GF_FieldInfo *info);/*indicates that the default field value of this proto field is undefined - this is neededwhen VRML externProto doesn't indicate its default field values, in which case they will be copiedover from real proto one upon instanciation*/void gf_sg_proto_field_set_value_undefined(GF_ProtoFieldInterface *protofield);/* NOTE on proto instances: The proto instance is handled as an GF_Node outside the scenegraph lib, and is manipulated with the same functions as an GF_Node The proto instance may or may not be loaded. An unloaded instance only contains the proto instance fields A loaded instance contains the proto instance fields plus all the proto code (Nodes, routes) and will load any scripts present in it. This allows keeping the memory usage of proto very low, especially when nested protos (protos used as building blocks of their parent proto) are used.*//*creates the proto interface without the proto code.*/GF_Node *gf_sg_proto_create_instance(GF_SceneGraph *sg, GF_Proto *proto);/*lodes code in this instance - all subprotos are automatically created, thus you must only instanciatetop-level protos. VRML/BIFS doesn't allow for non top-level proto instanciation in the main graphAll nodes created in this proto will be forwarded to the app for initialization*/GF_Err gf_sg_proto_load_code(GF_Node *proto_inst);/*locate a prototype definition by ID or by name. when looking by name, ID is ignored*/GF_Proto *gf_sg_find_proto(GF_SceneGraph *sg, u32 ProtoID, char *name);/*deletes all protos in given scene - does NOT delete instances of protos, only the proto object is destroyed */GF_Err gf_sg_delete_all_protos(GF_SceneGraph *scene);/*tools for hardcoded proto*//*gets proto of this node - if the node is not a prototype instance, returns NULL*/GF_Proto *gf_node_get_proto(GF_Node *node);/*returns the ID of the proto*/u32 gf_sg_proto_get_id(GF_Proto *proto);/*returns proto name*/const char *gf_sg_proto_get_class_name(GF_Proto *proto);/*Returns 1 if the given field is ISed to a startTime/stopTime field (MPEG-4 specific for updates)*/Bool gf_sg_proto_field_is_sftime_offset(GF_Node *node, GF_FieldInfo *field);/*set an ISed field in a proto instance (not a proto) - this is needed with dynamic node creation inside a protoinstance (conditionals)*/GF_Err gf_sg_proto_instance_set_ised(GF_Node *protoinst, u32 protoFieldIndex, GF_Node *node, u32 nodeFieldIndex);/*indicates proto field has been parsed and its value is valid - this is needed for externProtos not specifying defaultvalues*/void gf_sg_proto_mark_field_loaded(GF_Node *proto_inst, GF_FieldInfo *info);/* JavaScript tools*//*script fields type don't have the same value as the bifs ones...*/enum{ GF_SG_SCRIPT_TYPE_FIELD = 0, GF_SG_SCRIPT_TYPE_EVENT_IN, GF_SG_SCRIPT_TYPE_EVENT_OUT,};typedef struct _scriptfield GF_ScriptField;/*creates new sript field - script fields are dynamically added to the node, and thus can be accessed through thesame functions as other GF_Node fields*/GF_ScriptField *gf_sg_script_field_new(GF_Node *script, u32 eventType, u32 fieldType, const char *name);/*retrieves field info, usefull to get the field index*/GF_Err gf_sg_script_field_get_info(GF_ScriptField *field, GF_FieldInfo *info);/*activate eventIn for script node - needed for BIFS field replace*/void gf_sg_script_event_in(GF_Node *node, GF_FieldInfo *in_field);/*set the scene proto loader function for externProto - callback is the same as the scene callback*/void gf_sg_set_proto_loader(GF_SceneGraph *scene, GF_SceneGraph *(*GetExternProtoLib)(void *SceneCallback, MFURL *lib_url));/*get a pointer to the MF URL field for externProto info - DO NOT TOUCH THIS FIELD*/MFURL *gf_sg_proto_get_extern_url(GF_Proto *proto);SFRotation gf_sg_sfrotation_interpolate(SFRotation kv1, SFRotation kv2, Fixed fraction);/*adds a new node to the "children" fieldposition is the 0-BASED index in the list of children, -1 means end of list (append)DOES NOT CHECK CHILD/PARENT type compatibility*/GF_Err gf_node_insert_child(GF_Node *parent, GF_Node *new_child, s32 Position);/*removes an existing node from the "children" field*/GF_Err gf_node_remove_child(GF_Node *parent, GF_Node *toremove_child);/*remove and replace given child by specified node. If node is NULL, only delete target nodeposition is the 0-BASED index in the list of children, -1 means end of list (append)DOES NOT CHECK CHILD/PARENT type compatibility*/GF_Err gf_node_replace_child(GF_Node *node, GF_ChildNodeItem **container, s32 pos, GF_Node *newNode);/*signals eventOut has been set. FieldIndex/eventName identify the eventOut field. Routes are automatically triggeredwhen the event is signaled*/void gf_node_event_out(GF_Node *node, u32 FieldIndex);void gf_node_event_out_str(GF_Node *node, const char *eventName);/*exported for parsers*/u32 gf_node_mpeg4_type_by_class_name(const char *node_name);u32 gf_node_x3d_type_by_class_name(const char *node_name);#ifdef __cplusplus}#endif#endif /*_GF_SG_VRML_H_*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -