OSDN Git Service

add tstools.
[rec10/rec10-git.git] / tstools / DtsEdit / src / gpac / scenegraph_vrml.h
1 /*\r
2  *                      GPAC - Multimedia Framework C SDK\r
3  *\r
4  *                      Copyright (c) Jean Le Feuvre 2000-2005\r
5  *                                      All rights reserved\r
6  *\r
7  *  This file is part of GPAC / Scene Graph sub-project\r
8  *\r
9  *  GPAC is free software; you can redistribute it and/or modify\r
10  *  it under the terms of the GNU Lesser General Public License as published by\r
11  *  the Free Software Foundation; either version 2, or (at your option)\r
12  *  any later version.\r
13  *   \r
14  *  GPAC is distributed in the hope that it will be useful,\r
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
17  *  GNU Lesser General Public License for more details.\r
18  *   \r
19  *  You should have received a copy of the GNU Lesser General Public\r
20  *  License along with this library; see the file COPYING.  If not, write to\r
21  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. \r
22  *\r
23  */\r
24 \r
25 \r
26 #ifndef _GF_SG_VRML_H_\r
27 #define _GF_SG_VRML_H_\r
28 \r
29 #ifdef __cplusplus\r
30 extern "C" {\r
31 #endif\r
32 \r
33 #include <gpac/scenegraph.h>\r
34 #include <gpac/math.h>\r
35 \r
36 /*\r
37         All extensions for VRML/MPEG-4/X3D graph structure      \r
38 */\r
39 \r
40 /*reserved NDT for MPEG4 (match binary coding)*/\r
41 #define MPEG4_RESERVED_NDT              200\r
42 \r
43 /*the NDTs used in X3D not defined in MPEG4*/\r
44 enum\r
45 {\r
46         NDT_SFMetadataNode = MPEG4_RESERVED_NDT+1,\r
47         NDT_SFFillPropertiesNode,\r
48         NDT_SFX3DLinePropertiesNode,\r
49         NDT_SFGeoOriginNode,\r
50         NDT_SFHAnimNode,\r
51         NDT_SFHAnimDisplacerNode,\r
52         NDT_SFNurbsControlCurveNode,\r
53         NDT_SFNurbsSurfaceNode,\r
54         NDT_SFNurbsCurveNode\r
55 };\r
56 \r
57 /*\r
58         VRML / BIFS TYPES DEFINITION\r
59 */\r
60 \r
61 /*\r
62                                 event types, as defined in the specs \r
63         this should not be needed by non binary codecs\r
64 */\r
65 enum\r
66 {\r
67         GF_SG_EVENT_FIELD               =       0,\r
68         GF_SG_EVENT_EXPOSED_FIELD       =       1,\r
69         GF_SG_EVENT_IN          =       2,\r
70         GF_SG_EVENT_OUT         =       3,\r
71         GF_SG_EVENT_UNKNOWN     =       4\r
72 };\r
73 const char *gf_sg_vrml_get_event_type_name(u32 EventType, Bool forX3D);\r
74 \r
75 /*\r
76                                 field coding mode\r
77 \r
78         BIFS defines the bitstream syntax contextually, and therefore sometimes refer to fields as indexed\r
79   in the node ("all" mode) or just as a sub-set (in, out, def, dyn modes) of similar types\r
80 */\r
81 enum\r
82 {\r
83         /*all fields and events*/\r
84         GF_SG_FIELD_CODING_ALL          =       0,\r
85         /*defined fields (exposedField and Field)*/\r
86         GF_SG_FIELD_CODING_DEF          =       1,\r
87         /*input field (exposedField and eventIn)*/\r
88         GF_SG_FIELD_CODING_IN           =       2,\r
89         /*output field (exposedField and eventOut)*/\r
90         GF_SG_FIELD_CODING_OUT          =       3,\r
91         /*field that can be animated (subset of inFields) used in BIFS_Anim only*/\r
92         GF_SG_FIELD_CODING_DYN          =       4\r
93 };\r
94 \r
95 /*get the number of field in the given mode (BIFS specific)*/\r
96 u32 gf_node_get_num_fields_in_mode(GF_Node *Node, u8 IndexMode);\r
97 \r
98 /*              SF Types        */\r
99 typedef Bool SFBool;\r
100 typedef s32 SFInt32;\r
101 typedef s32 SFInt;\r
102 typedef Fixed SFFloat;\r
103 typedef Double SFDouble;\r
104 \r
105 typedef struct\r
106 {\r
107         char* buffer;\r
108 } SFString;\r
109 \r
110 typedef Double SFTime;\r
111 \r
112 typedef struct {\r
113         Fixed   red;\r
114         Fixed   green;\r
115         Fixed   blue;\r
116 } SFColor;\r
117 \r
118 typedef struct {\r
119         Fixed   red;\r
120         Fixed   green;\r
121         Fixed   blue;\r
122         Fixed   alpha;\r
123 } SFColorRGBA;\r
124 \r
125 typedef struct {\r
126         u32 OD_ID;\r
127         char *url;\r
128 } SFURL;\r
129 \r
130 typedef struct {\r
131         Double  x;\r
132         Double  y;\r
133 } SFVec2d;\r
134 \r
135 typedef struct {\r
136         Double  x;\r
137         Double  y;\r
138         Double  z;\r
139 } SFVec3d;\r
140 \r
141 /*typedef's to main math tools*/\r
142 typedef struct __vec2f SFVec2f;\r
143 typedef struct __vec3f SFVec3f;\r
144 typedef struct __vec4f SFRotation;\r
145 typedef struct __vec4f SFVec4f;\r
146 \r
147 typedef struct {\r
148         u32 width;\r
149         u32 height;\r
150         u8 numComponents;\r
151         unsigned char* pixels;\r
152 } SFImage;\r
153 typedef struct {\r
154         u32 bufferSize;\r
155         unsigned char* buffer;\r
156         /*uncompressed command list*/\r
157         GF_List *commandList;\r
158 } SFCommandBuffer;\r
159 \r
160 /*Note on SFScript: the javascript or vrml script is handled in its decompressed (textual) format\r
161 since most JS interpreter work with text*/\r
162 typedef struct {\r
163         unsigned char* script_text;\r
164 } SFScript;\r
165 \r
166 \r
167 /*              MF Types        */\r
168 \r
169 /*generic MF field: all MF fields use the same syntax except MFNode which uses GF_List. You  can thus use\r
170 this structure to safely typecast MF field pointers*/\r
171 typedef struct {\r
172         u32 count;\r
173         char *array;\r
174 } GenMFField;\r
175 \r
176 typedef struct {\r
177         u32 count;\r
178         s32* vals;\r
179 } MFInt32;\r
180 typedef struct {\r
181         u32 count;\r
182         s32* vals;\r
183 } MFInt;\r
184 typedef struct {\r
185         u32 count;\r
186         Fixed *vals;\r
187 } MFFloat;\r
188 typedef struct {\r
189         u32 count;\r
190         Double *vals;\r
191 } MFDouble;\r
192 typedef struct {\r
193         u32 count;\r
194         u32* vals;\r
195 } MFBool;\r
196 typedef struct {\r
197         u32 count;\r
198         SFColor* vals;\r
199 } MFColor;\r
200 typedef struct {\r
201         u32 count;\r
202         SFColorRGBA* vals;\r
203 } MFColorRGBA;\r
204 typedef struct {\r
205         u32 count;\r
206         SFRotation*     vals;\r
207 } MFRotation;\r
208 typedef struct {\r
209         u32 count;\r
210         Double* vals;\r
211 } MFTime;\r
212 typedef struct {\r
213         u32 count;\r
214         SFVec2f* vals;\r
215 } MFVec2f;\r
216 typedef struct {\r
217         u32 count;\r
218         SFVec2d* vals;\r
219 } MFVec2d;\r
220 typedef struct {\r
221         u32 count;\r
222         SFVec3f* vals;\r
223 } MFVec3f;\r
224 typedef struct {\r
225         u32 count;\r
226         SFVec3d* vals;\r
227 } MFVec3d;\r
228 typedef struct {\r
229         u32 count;\r
230         SFVec4f* vals;\r
231 } MFVec4f;\r
232 \r
233 typedef struct {\r
234         u32 count;\r
235         SFURL* vals;\r
236 } MFURL;\r
237 typedef struct {\r
238         u32 count;\r
239         char** vals;\r
240 } MFString;\r
241 typedef struct {\r
242         u32 count;\r
243         SFScript *vals;\r
244 } MFScript;\r
245 \r
246 \r
247 SFColorRGBA gf_sg_sfcolor_to_rgba(SFColor val);\r
248 \r
249 /*field types, as defined in BIFS encoding (used for scripts and proto coding)*/\r
250 enum\r
251 {\r
252         GF_SG_VRML_SFBOOL               =       0,\r
253         GF_SG_VRML_SFFLOAT              =       1,\r
254         GF_SG_VRML_SFTIME               =       2,\r
255         GF_SG_VRML_SFINT32              =       3,\r
256         GF_SG_VRML_SFSTRING             =       4,\r
257         GF_SG_VRML_SFVEC3F              =       5,\r
258         GF_SG_VRML_SFVEC2F              =       6,\r
259         GF_SG_VRML_SFCOLOR              =       7,\r
260         GF_SG_VRML_SFROTATION   =       8,\r
261         GF_SG_VRML_SFIMAGE              =       9,\r
262         GF_SG_VRML_SFNODE               =       10,\r
263         /*TO CHECK*/\r
264         GF_SG_VRML_SFVEC4F              =       11,\r
265 \r
266         /*used types in GPAC but not defined in the MPEG4 spec*/\r
267         GF_SG_VRML_SFURL,\r
268         GF_SG_VRML_SFSCRIPT,\r
269         GF_SG_VRML_SFCOMMANDBUFFER,\r
270         /*used types in X3D*/\r
271         GF_SG_VRML_SFDOUBLE,\r
272         GF_SG_VRML_SFCOLORRGBA,\r
273         GF_SG_VRML_SFVEC2D,\r
274         GF_SG_VRML_SFVEC3D,\r
275 \r
276         GF_SG_VRML_FIRST_MF             = 32,\r
277         GF_SG_VRML_MFBOOL               = GF_SG_VRML_FIRST_MF,\r
278         GF_SG_VRML_MFFLOAT,\r
279         GF_SG_VRML_MFTIME,\r
280         GF_SG_VRML_MFINT32,\r
281         GF_SG_VRML_MFSTRING,\r
282         GF_SG_VRML_MFVEC3F,\r
283         GF_SG_VRML_MFVEC2F,\r
284         GF_SG_VRML_MFCOLOR,\r
285         GF_SG_VRML_MFROTATION,\r
286         GF_SG_VRML_MFIMAGE,\r
287         GF_SG_VRML_MFNODE,\r
288         GF_SG_VRML_MFVEC4F,\r
289 \r
290         /*used types in GPAC but not defined in the MPEG4 spec*/\r
291         GF_SG_VRML_MFURL,\r
292         GF_SG_VRML_MFSCRIPT,\r
293 \r
294         /*used types in X3D*/\r
295         GF_SG_VRML_MFDOUBLE,\r
296         GF_SG_VRML_MFCOLORRGBA,\r
297         GF_SG_VRML_MFVEC2D,\r
298         GF_SG_VRML_MFVEC3D,\r
299 \r
300         GF_SG_VRML_UNKNOWN\r
301 };\r
302 const char *gf_sg_vrml_get_field_type_by_name(u32 FieldType);\r
303 \r
304 \r
305 /*\r
306 allocates a new field and gets it back. \r
307         NOTE:\r
308                         GF_SG_VRML_MFNODE will return a pointer to a GF_List structure (eg GF_List *)\r
309                         GF_SG_VRML_SFNODE will return NULL\r
310 */\r
311 void *gf_sg_vrml_field_pointer_new(u32 FieldType);\r
312 /*deletes a field pointer (including SF an,d MF nodes)*/\r
313 void gf_sg_vrml_field_pointer_del(void *field, u32 FieldType);\r
314 \r
315 Bool gf_sg_vrml_is_sf_field(u32 FieldType);\r
316 \r
317 /*translates MF/SF to SF type*/\r
318 u32 gf_sg_vrml_get_sf_type(u32 FieldType);\r
319 \r
320 \r
321 /*\r
322         MFField manipulation  - MFNode cannot use these, use the GF_List functions instead\r
323         or the Node_* insertion functions\r
324         FieldType shall always be given when manipulating MFFields\r
325 */\r
326 /*Insert (+alloc) a slot in the MFField with a specified position for insertion and sets the ptr\r
327 to the newly created slot\r
328 @InsertAt is the 0-based index for the new slot\r
329 */\r
330 GF_Err gf_sg_vrml_mf_insert(void *mf, u32 FieldType, void **new_ptr, u32 InsertAt);\r
331 /*adds at the end and gets the ptr*/\r
332 GF_Err gf_sg_vrml_mf_append(void *mf, u32 FieldType, void **new_ptr);\r
333 /*remove the desired item*/\r
334 GF_Err gf_sg_vrml_mf_remove(void *mf, u32 FieldType, u32 RemoveFrom);\r
335 /*alloc a fixed array*/\r
336 GF_Err gf_sg_vrml_mf_alloc(void *mf, u32 FieldType, u32 NbItems);\r
337 /*get the item in the array*/\r
338 GF_Err gf_sg_vrml_mf_get_item(void *mf, u32 FieldType, void **new_ptr, u32 ItemPos);\r
339 /*remove all items of the MFField*/\r
340 GF_Err gf_sg_vrml_mf_reset(void *mf, u32 FieldType);\r
341 \r
342 /*clones a field content EXCEPT SF/MFNode. Pointers to field shall be used\r
343 @dest, @orig: pointers to field\r
344 @FieldType: type of the field\r
345 */\r
346 void gf_sg_vrml_field_copy(void *dest, void *orig, u32 FieldType);\r
347 \r
348 /*indicates whether 2 fields of same type EXCEPT SF/MFNode are equal\r
349 @dest, @orig: pointers to field\r
350 @FieldType: type of the field\r
351 */\r
352 Bool gf_sg_vrml_field_equal(void *dest, void *orig, u32 FieldType);\r
353 \r
354 \r
355 \r
356 /*VRML grouping nodes macro - note we have inverted the children field to be \r
357 compatible with the base GF_ParentNode node\r
358 All grouping nodes (with "children" field) implement the following: \r
359 \r
360 addChildren: chain containing nodes to add passed as eventIn - handled internally through ROUTE\r
361 void (*on_addChildren)(GF_Node *pNode): add eventIn signaler - this is handled internally by the scene_graph and SHALL \r
362 NOT BE OVERRIDEN since it takes care of node(s) routing\r
363 \r
364 removeChildren: chain containing nodes to remove passed as eventIn - handled internally through ROUTE\r
365 \r
366 void (*on_removeChildren)(GF_Node *pNode): remove eventIn signaler - this is handled internally by the scene_graph and SHALL \r
367 NOT BE OVERRIDEN since it takes care of node(s) routing\r
368 \r
369 children: list of children SFNodes\r
370 */\r
371 \r
372 #define VRML_CHILDREN                                                   \\r
373         CHILDREN                                                                        \\r
374         GF_ChildNodeItem *addChildren;                                                  \\r
375         void (*on_addChildren)(GF_Node *pNode);         \\r
376         GF_ChildNodeItem *removeChildren;                                               \\r
377         void (*on_removeChildren)(GF_Node *pNode);              \\r
378 \r
379 typedef struct\r
380 {\r
381         BASE_NODE\r
382         VRML_CHILDREN\r
383 } GF_VRMLParent;\r
384 \r
385 void gf_sg_vrml_parent_setup(GF_Node *pNode);\r
386 void gf_sg_vrml_parent_destroy(GF_Node *pNode);\r
387 \r
388 \r
389 /*set proto loader - callback is the same as simulation time callback\r
390         GetExternProtoLib is a pointer to the proto lib loader - this callback shall return the LPSCENEGRAPH\r
391 of the extern proto lib if found and loaded, NULL if not found and GF_SG_INTERNAL_PROTO for internal\r
392 hardcoded protos (extensions of MPEG-4 scene graph used for module deveopment)\r
393 */\r
394 #define GF_SG_INTERNAL_PROTO    (GF_SceneGraph *) 0xFFFFFFFF\r
395 \r
396 /*GF_Route manip: routes are used to pass events between nodes. Event handling is managed by the scene graph\r
397 however only the nodes overloading the EventIn handler associated with the event will process the eventIn*/\r
398 typedef struct _route GF_Route;\r
399 \r
400 /*creates a new route:\r
401         @fromNode: @fromField: address of the eventOut field triggering the route\r
402         @toNode: @toField: address of the destination eventIn field\r
403 NOTE: routes are automatically destroyed if either the target or origin node of the route is destroyed\r
404 */\r
405 GF_Route *gf_sg_route_new(GF_SceneGraph *sg, GF_Node *fromNode, u32 fromField, GF_Node *toNode, u32 toField);\r
406 \r
407 /*delete route*/\r
408 void gf_sg_route_del(GF_Route *route);\r
409 GF_Err gf_sg_route_del_by_id(GF_SceneGraph *sg,u32 routeID);\r
410 \r
411 /*locate route by ID/name*/\r
412 GF_Route *gf_sg_route_find(GF_SceneGraph *sg, u32 RouteID);\r
413 GF_Route *gf_sg_route_find_by_name(GF_SceneGraph *sg, char *name);\r
414 /*assign route ID - fails if a route with same ID already exist*/\r
415 GF_Err gf_sg_route_set_id(GF_Route *route, u32 ID);\r
416 u32 gf_sg_route_get_id(GF_Route *route);\r
417 /*assign route name if desired*/\r
418 GF_Err gf_sg_route_set_name(GF_Route *route, char *name);\r
419 char *gf_sg_route_get_name(GF_Route *route);\r
420 \r
421 /*retuns next available RouteID - Note this doesn't track inserted routes, that's the user responsability*/\r
422 u32 gf_sg_get_next_available_route_id(GF_SceneGraph *sg);\r
423 /*set max defined route ID used in the scene - used to handle RouteInsert commands\r
424 note that this must be called by the user to be effective,; otherwise the max route ID is computed\r
425 from the routes present in scene*/\r
426 void gf_sg_set_max_defined_route_id(GF_SceneGraph *sg, u32 ID);\r
427 \r
428 \r
429 /*activates all routes currently triggered - this follows the event cascade model of VRML/MPEG4:\r
430         - routes are collected during eventOut generation\r
431         - routes are activated. If eventOuts are generated during activation the cycle goes on.\r
432 \r
433   A route cannot be activated twice in the same simulation tick, hence this function shall be called \r
434   ONCE AND ONLY ONCE per simulation tick\r
435 \r
436 Note that children scene graphs register their routes with the top-level graph, so only the main \r
437 scene graph needs to be activated*/\r
438 void gf_sg_activate_routes(GF_SceneGraph *sg);\r
439 \r
440 \r
441 /*\r
442                                 proto handling\r
443 \r
444         The lib allows you to construct prototype nodes as defined in VRML/MPEG4 by constructing \r
445         proto interfaces and instanciating them. An instanciated proto is handled as a single node for\r
446         rendering, thus an application will never handle proto instances for rendering\r
447 */\r
448 \r
449 /*opaque handler for a proto object (declaration)*/\r
450 typedef struct _proto GF_Proto;\r
451 /*opaque handler for a proto field object (declaration)*/\r
452 typedef struct _protofield GF_ProtoFieldInterface;\r
453 \r
454 \r
455 /*retuns next available NodeID*/\r
456 u32 gf_sg_get_next_available_proto_id(GF_SceneGraph *sg);\r
457 \r
458 /*proto constructor identified by ID/name in the given scene\r
459 2 protos in the same scene may not have the same ID/name\r
460 \r
461 @unregistered: used for memory handling of scene graph only, the proto is not stored\r
462 in the graph main proto list but in an alternate list. Several protos with the same ID/Name can be stored unregistered\r
463 */\r
464 GF_Proto *gf_sg_proto_new(GF_SceneGraph *inScene, u32 ProtoID, char *name, Bool unregistered);\r
465 \r
466 /*destroy proto interface - can be used even if instances of the proto are still present*/\r
467 GF_Err gf_sg_proto_del(GF_Proto *proto);\r
468 \r
469 /*used for memory handling of scene graph only. move proto from off-graph to in-graph or reverse*/\r
470 GF_Err gf_sg_proto_set_in_graph(GF_Proto *proto, GF_SceneGraph *inScene, Bool set_in);\r
471 \r
472 /*returns graph associated with this proto. Such a graph cannot be used for rendering but is needed during\r
473 construction of proto dictionaries in case of nested protos*/\r
474 GF_SceneGraph *gf_sg_proto_get_graph(GF_Proto *proto);\r
475 \r
476 /*get/set private data*/\r
477 void gf_sg_proto_set_private(GF_Proto *proto, void *ptr, void (*OnDelete)(void *ptr) );\r
478 void *gf_sg_proto_get_private(GF_Proto *proto);\r
479 \r
480 /*add node code - a proto is build of several nodes, the first node is used for rendering\r
481 and the others are kept private. This set of nodes is refered to as the proto "node code"*/\r
482 GF_Err gf_sg_proto_add_node_code(GF_Proto *proto, GF_Node *pNode);\r
483 \r
484 /*gets number of field in the proto interface*/\r
485 u32 gf_sg_proto_get_field_count(GF_Proto *proto);\r
486 /*locates field declaration by name*/\r
487 GF_ProtoFieldInterface *gf_sg_proto_field_find_by_name(GF_Proto *proto, char *fieldName);\r
488 /*locates field declaration by index (0-based)*/\r
489 GF_ProtoFieldInterface *gf_sg_proto_field_find(GF_Proto *proto, u32 fieldIndex);\r
490 \r
491 /*creates a new field declaration in the proto. of given fieldtype and eventType\r
492 fieldName can be NULL, if so the name will be fieldN, N being the index of the created field*/\r
493 GF_ProtoFieldInterface *gf_sg_proto_field_new(GF_Proto *proto, u32 fieldType, u32 eventType, char *fieldName);\r
494 \r
495 /*assign the node field to a field of the proto (the node field IS the proto field)\r
496 the node shall be a node of the proto scenegraph, and the fieldtype/eventType of both fields shall match\r
497 (except SF/MFString and MF/SFURL which are allowed) due to BIFS semantics*/\r
498 GF_Err gf_sg_proto_field_set_ised(GF_Proto *proto, u32 protoFieldIndex, GF_Node *node, u32 nodeFieldIndex);\r
499 /*set/get user private data for the proto field declaration*/\r
500 void gf_sg_proto_field_set_private(GF_ProtoFieldInterface *field, void *ptr, void (*OnDelete)(void *ptr) );\r
501 void *gf_sg_proto_field_get_private(GF_ProtoFieldInterface *field);\r
502 /*returns field info of the field - this is typically used to setup the default value of the field*/\r
503 GF_Err gf_sg_proto_field_get_field(GF_ProtoFieldInterface *field, GF_FieldInfo *info);\r
504 \r
505 /*\r
506         NOTE on proto instances:\r
507                 The proto instance is handled as an GF_Node outside the scenegraph lib, and is manipulated with the same functions \r
508                 as an GF_Node \r
509                 The proto instance may or may not be loaded. \r
510                 An unloaded instance only contains the proto instance fields \r
511                 A loaded instance contains the proto instance fields plus all the proto code (Nodes, routes) and \r
512                 will load any scripts present in it. This allows keeping the memory usage of proto very low, especially\r
513                 when nested protos (protos used as building blocks of their parent proto) are used.\r
514 */\r
515 \r
516 /*creates the proto interface without the proto code.*/\r
517 GF_Node *gf_sg_proto_create_instance(GF_SceneGraph *sg, GF_Proto *proto);\r
518 \r
519 /*lodes code in this instance - all subprotos are automatically created, thus you must only instanciate\r
520 top-level protos. VRML/BIFS doesn't allow for non top-level proto instanciation in the main graph\r
521 All nodes created in this proto will be forwarded to the app for initialization*/\r
522 GF_Err gf_sg_proto_load_code(GF_Node *proto_inst);\r
523 \r
524 /*locate a prototype definition by ID or by name. when looking by name, ID is ignored*/\r
525 GF_Proto *gf_sg_find_proto(GF_SceneGraph *sg, u32 ProtoID, char *name);\r
526 \r
527 /*deletes all protos in given scene - does NOT delete instances of protos, only the proto object is destroyed */\r
528 GF_Err gf_sg_delete_all_protos(GF_SceneGraph *scene);\r
529 \r
530 \r
531 /*tools for hardcoded proto*/\r
532 /*gets proto of this node - if the node is not a prototype instance, returns NULL*/\r
533 GF_Proto *gf_node_get_proto(GF_Node *node);\r
534 /*returns the ID of the proto*/\r
535 u32 gf_sg_proto_get_id(GF_Proto *proto);\r
536 /*returns proto name*/\r
537 const char *gf_sg_proto_get_class_name(GF_Proto *proto);\r
538 \r
539 /*Returns 1 if the given field is ISed to a startTime/stopTime field (MPEG-4 specific for updates)*/\r
540 Bool gf_sg_proto_field_is_sftime_offset(GF_Node *node, GF_FieldInfo *field);\r
541 \r
542 /*set an ISed field in a proto instance (not a proto) - this is needed with dynamic node creation inside a proto\r
543 instance (conditionals)*/\r
544 GF_Err gf_sg_proto_instance_set_ised(GF_Node *protoinst, u32 protoFieldIndex, GF_Node *node, u32 nodeFieldIndex);\r
545 \r
546 /*returns root node (the one and only one being traversed) of this proto instance if any*/\r
547 GF_Node *gf_node_get_proto_root(GF_Node *node);\r
548 \r
549 /*returns parent ProtoInstance node if this node is in a proto*/\r
550 GF_Node *gf_node_get_proto_parent(GF_Node *node);\r
551 \r
552 /*indicates proto field has been parsed and its value is valid - this is needed for externProtos not specifying default\r
553 values*/\r
554 void gf_sg_proto_mark_field_loaded(GF_Node *proto_inst, GF_FieldInfo *info);\r
555 \r
556 /*\r
557                         JavaScript tools\r
558 */\r
559 \r
560 /*script fields type don't have the same value as the bifs ones...*/\r
561 enum\r
562 {\r
563         GF_SG_SCRIPT_TYPE_FIELD = 0,\r
564         GF_SG_SCRIPT_TYPE_EVENT_IN,\r
565         GF_SG_SCRIPT_TYPE_EVENT_OUT,\r
566 };\r
567 \r
568 typedef struct _scriptfield GF_ScriptField;\r
569 /*creates new sript field - script fields are dynamically added to the node, and thus can be accessed through the\r
570 same functions as other GF_Node fields*/\r
571 GF_ScriptField *gf_sg_script_field_new(GF_Node *script, u32 eventType, u32 fieldType, const char *name);\r
572 /*retrieves field info, usefull to get the field index*/\r
573 GF_Err gf_sg_script_field_get_info(GF_ScriptField *field, GF_FieldInfo *info);\r
574 \r
575 /*activate eventIn for script node - needed for BIFS field replace*/\r
576 void gf_sg_script_event_in(GF_Node *node, GF_FieldInfo *in_field);\r
577 \r
578 \r
579 \r
580 /*set the scene proto loader function for externProto - callback is the same as the scene callback*/\r
581 void gf_sg_set_proto_loader(GF_SceneGraph *scene, GF_SceneGraph *(*GetExternProtoLib)(void *SceneCallback, MFURL *lib_url));\r
582 \r
583 /*get a pointer to the MF URL field for externProto info - DO NOT TOUCH THIS FIELD*/\r
584 MFURL *gf_sg_proto_get_extern_url(GF_Proto *proto);\r
585 \r
586 SFRotation gf_sg_sfrotation_interpolate(SFRotation kv1, SFRotation kv2, Fixed fraction);\r
587 \r
588 \r
589 \r
590 \r
591 /*adds a new node to the "children" field\r
592 position is the 0-BASED index in the list of children, -1 means end of list (append)\r
593 DOES NOT CHECK CHILD/PARENT type compatibility\r
594 */\r
595 GF_Err gf_node_insert_child(GF_Node *parent, GF_Node *new_child, s32 Position);\r
596 /*removes an existing node from the "children" field*/\r
597 GF_Err gf_node_remove_child(GF_Node *parent, GF_Node *toremove_child);\r
598 /*remove and replace given child by specified node. If node is NULL, only delete target node\r
599 position is the 0-BASED index in the list of children, -1 means end of list (append)\r
600 DOES NOT CHECK CHILD/PARENT type compatibility\r
601 */\r
602 GF_Err gf_node_replace_child(GF_Node *node, GF_ChildNodeItem **container, s32 pos, GF_Node *newNode);\r
603 \r
604 /*signals eventOut has been set. FieldIndex/eventName identify the eventOut field. Routes are automatically triggered\r
605 when the event is signaled*/\r
606 void gf_node_event_out(GF_Node *node, u32 FieldIndex);\r
607 void gf_node_event_out_str(GF_Node *node, const char *eventName);\r
608 \r
609 \r
610 /*exported for parsers*/\r
611 u32 gf_node_mpeg4_type_by_class_name(const char *node_name);\r
612 u32 gf_node_x3d_type_by_class_name(const char *node_name);\r
613 \r
614 /*exported for URL handling in compositor*/\r
615 void gf_sg_mfurl_del(MFURL url);\r
616 \r
617 #ifdef __cplusplus\r
618 }\r
619 #endif\r
620 \r
621 \r
622 \r
623 #endif /*_GF_SG_VRML_H_*/\r