29 #include <system_threads.h>
33 #include <libFreeWRL.h>
42 #include "../vrml_parser/Structs.h"
44 #include "../vrml_parser/CParseGeneral.h"
45 #include "../scenegraph/Vector.h"
46 #include "../vrml_parser/CFieldDecls.h"
47 #include "../world_script/JScript.h"
48 #include "../world_script/CScripts.h"
49 #include "../vrml_parser/CParseParser.h"
50 #include "../vrml_parser/CParseLexer.h"
51 #include "../vrml_parser/CParse.h"
53 #include "../scenegraph/Collision.h"
54 #include "../scenegraph/Component_KeyDevice.h"
55 #include "../opengl/Frustum.h"
56 #include "../opengl/OpenGL_Utils.h"
58 #if defined(INCLUDE_NON_WEB3D_FORMATS)
59 #include "../non_web3d_formats/ColladaParser.h"
60 #endif //INCLUDE_NON_WEB3D_FORMATS
62 #if defined (INCLUDE_STL_FILES)
63 #include "../input/convertSTL.h"
64 #endif //INCLUDE_STL_FILES
66 #include "../scenegraph/quaternion.h"
67 #include "../scenegraph/Viewer.h"
68 #include "../input/SensInterps.h"
69 #include "../x3d_parser/Bindable.h"
70 #include "../input/InputFunctions.h"
72 #include "../plugin/pluginUtils.h"
73 #include "../plugin/PluginSocket.h"
75 #include "../ui/common.h"
76 #include "../opengl/OpenGL_Utils.h"
77 #include "../opengl/Textures.h"
78 #include "../opengl/LoadTextures.h"
87 void embedEXTERNPROTO(
struct VRMLLexer *me,
char *myName,
char *buffer,
char *pound);
90 char *EAI_Flag =
"From the EAI bootcamp of life ";
91 char* PluginPath =
"/private/tmp";
92 int PluginLength = 12;
95 int _fw_browser_plugin = 0;
97 uintptr_t _fw_instance = 0;
118 static bool parser_do_parse_string(
const char *input,
const int len,
struct X3D_Node *ectx,
struct X3D_Node *nRn);
123 struct Vector *viewpointNodes;
125 struct Vector *backgroundNodes;
126 struct Vector *navigationNodes;
132 int frontend_gets_files;
139 int inputThreadParsing;
140 int haveParsedCParsed;
141 int frontend_res_count;
142 #if defined (INCLUDE_STL_FILES)
144 float lastSTLScaling;
148 void *ProdCon_constructor(){
149 void *v = MALLOCV(
sizeof(
struct pProdCon));
150 memset(v,0,
sizeof(
struct pProdCon));
153 void ProdCon_init(
struct tProdCon *t)
159 t->setViewpointBindInRender = NULL;
160 t->setFogBindInRender = NULL;
161 t->setBackgroundBindInRender = NULL;
162 t->setNavigationBindInRender = NULL;
164 t->savedParser = NULL;
167 t->prv = ProdCon_constructor();
171 p->viewpointNodes = newVector(
struct X3D_Node *,8);
172 t->viewpointNodes = p->viewpointNodes;
173 p->fogNodes = newVector(
struct X3D_Node *, 2);
174 p->backgroundNodes = newVector(
struct X3D_Node *, 2);
175 p->navigationNodes = newVector(
struct X3D_Node *, 2);
181 p->resource_list_to_parse = NULL;
182 p->frontend_list_to_get = NULL;
184 p->frontend_gets_files = 2;
186 p->frontend_gets_files = 0;
193 p->inputThreadParsing=FALSE;
194 p->haveParsedCParsed = FALSE;
196 p->frontend_res_count = 0;
197 #if defined (INCLUDE_STL_FILES)
199 p->lastSTLScaling = 0.1;
204 void ProdCon_clear(
struct tProdCon *t){
208 deleteVector(
struct X3D_Node *, p->viewpointNodes);
209 deleteVector(
struct X3D_Node *, p->fogNodes);
210 deleteVector(
struct X3D_Node *, p->backgroundNodes);
211 deleteVector(
struct X3D_Node *, p->navigationNodes);
232 #if defined (INCLUDE_STL_FILES)
234 float fwl_getLastSTLScaling() {
236 if (p!=NULL)
return p->lastSTLScaling;
244 int fwl_isInputThreadInitialized() {
247 return gglobal()->threads.ResourceThreadRunning;
251 int fwl_isinputThreadParsing() {
253 return(p->inputThreadParsing);
256 void dump_scene2(FILE *fp,
int level,
struct X3D_Node* node,
int recurse,
Stack *DEFedNodes) ;
258 int indexChildrenName(
struct X3D_Node *node){
261 switch(node->_nodeType){
263 index = FIELDNAMES_children;
266 index = FIELDNAMES_children;
269 index = FIELDNAMES_children;
272 index = FIELDNAMES_children;
275 index = FIELDNAMES___children;
278 index = FIELDNAMES___children;
281 index = FIELDNAMES_rootNode;
291 switch(node->_nodeType){
293 childs = offsetPointer_deref(
void*, node, offsetof(
struct X3D_Group,children));
296 childs = offsetPointer_deref(
void*, node, offsetof(
struct X3D_Transform,children));
299 childs = offsetPointer_deref(
void*, node, offsetof(
struct X3D_Switch,children));
302 childs = offsetPointer_deref(
void*, node, offsetof(
struct X3D_Billboard,children));
305 childs = offsetPointer_deref(
void*, node, offsetof(
struct X3D_Proto,__children));
308 childs = offsetPointer_deref(
void*, node, offsetof(
struct X3D_Inline,__children));
311 childs = offsetPointer_deref(
void*, node, offsetof(
struct X3D_GeoLOD,rootNode));
316 int offsetofChildren(
struct X3D_Node *node){
319 switch(node->_nodeType){
321 offs = offsetof(
struct X3D_Group,children);
334 offs = offsetof(
struct X3D_Proto,__children);
337 offs = offsetof(
struct X3D_Inline,__children);
349 static bool parser_do_parse_string(
const char *input,
const int len,
struct X3D_Node *ectx,
struct X3D_Node *nRn)
356 #if defined (INCLUDE_STL_FILES)
358 p->lastSTLScaling = 0.1;
364 inputFileType = determineFileType(input,len);
365 DEBUG_MSG(
"PARSE STRING, ft %d, fv %d.%d.%d\n",
366 inputFileType, inputFileVersion[0], inputFileVersion[1], inputFileVersion[2]);
367 kids = offsetofChildren(nRn);
369 switch (inputFileType) {
370 case IS_TYPE_XML_X3D:
373 ret = X3DParse(ectx, X3D_NODE(nRn), (
const char*)input);
378 ret = cParse(ectx, nRn, kids, (
const char*)input);
379 p->haveParsedCParsed = TRUE;
382 case IS_TYPE_VRML1: {
383 char *newData = STRDUP(
"#VRML V2.0 utf8\n\
384 Shape {appearance Appearance {material Material {diffuseColor 0.0 1.0 1.0}}\
386 string [\"This build\" \"is not made with\" \"VRML1 support\"]\
387 fontStyle FontStyle{\
388 justify [\"MIDDLE\",\"MIDDLE\"]\
399 #if defined (INCLUDE_NON_WEB3D_FORMATS)
400 case IS_TYPE_COLLADA:
401 ConsoleMessage (
"Collada not supported yet");
402 ret = ColladaParse (nRn, (
const char*)input);
404 case IS_TYPE_SKETCHUP:
405 ConsoleMessage (
"Google Sketchup format not supported yet");
408 ConsoleMessage (
"KML-KMZ format not supported yet");
410 #endif //INCLUDE_NON_WEB3D_FORMATS
412 #if defined (INCLUDE_STL_FILES)
413 case IS_TYPE_ASCII_STL: {
414 char *newData = convertAsciiSTL(input);
415 p->lastSTLScaling = getLastSTLScale();
419 ret = cParse (nRn,(
int) offsetof (
struct X3D_Group, children), newData);
423 case IS_TYPE_BINARY_STL: {
424 char *newData = convertBinarySTL(input);
425 p->lastSTLScaling = getLastSTLScale();
427 ret = cParse (nRn,(
int) offsetof (
struct X3D_Group, children), newData);
431 #endif //INCLUDE_STL_FILES
434 if (gglobal()->internalc.global_strictParsing) {
435 ConsoleMessage(
"unknown text as input");
437 inputFileType = IS_TYPE_VRML;
438 inputFileVersion[0] = 2;
439 cParse (ectx,nRn,(
int) offsetof (
struct X3D_Proto, __children), (
const char*)input);
440 p->haveParsedCParsed = TRUE; }
446 ConsoleMessage (
"Parser Unsuccessful");
453 void EAI_killBindables (
void) {
459 p->psp.comp = &complete;
460 p->psp.type = ZEROBINDABLES;
464 p->psp.zeroBind = FALSE;
467 p->psp.fieldname = NULL;
483 closeConsoleMessage();
495 killKeySensorNodeList();
520 fwlio_RxTx_control(CHANNEL_EAI, RxTx_STOP) ;
536 setMenuStatus(
"NONE");
544 children = childrenField(rootNode());
545 for (i = 0; i < children->n; i++) {
546 markForDispose(children->p[i], TRUE);
552 rootNode()->_change++;
564 void resitem_enqueue(
s_list_t* item);
632 printf(
"%s\t%s\n",( res->complete ?
"<finished>" :
"<waiting>" ), res->URLrequest);
638 resitem_enqueue(ml_new(res));
642 void dump_parser_wait_queue()
646 struct tProdCon *t = &gglobal()->ProdCon;
648 printf(
"Parser wait queue:\n");
649 ml_foreach(p->resource_list_to_parse, dump_resource_waiting((
resource_item_t*)ml_elem(__l)));
654 void post_parse_set_activeLayer();
670 int parsedOk = FALSE;
671 bool fromEAI_SAI = FALSE;
697 if (res->parsed_request != NULL)
698 if (strncmp(res->parsed_request,EAI_Flag,strlen(EAI_Flag)) == 0) {
704 pushInputResource(res);
708 if (res->parsed_request != NULL && strcmp(res->parsed_request, EAI_Flag) == 0) {
713 nRn = (
struct X3D_Node *) createNewX3DNode0(NODE_Group);
715 insert_node = X3D_NODE(res->whereToPlaceData);
716 offsetInNode = res->offsetFromWhereToPlaceData;
718 parsedOk = parser_do_parse_string((
const char *)res->URLrequest,(
const int)strlen(res->URLrequest), ectx, nRn);
729 of = res->openned_files;
747 if (res->treat_as_root || res == (
resource_item_t*) gglobal()->resources.root_res) {
758 t->savedParser = (
void *)tg->CParse.globalParser;
759 tg->CParse.globalParser = NULL;
764 if(res->whereToPlaceData){
765 nRn = X3D_NODE(res->whereToPlaceData);
766 if(nRn->_nodeType == NODE_Inline){
791 sceneProto = (
struct X3D_Proto *) createNewX3DNode(NODE_Proto);
792 sceneProto->__protoFlags = ciflag_set(sceneProto->__protoFlags,1,0);
793 sceneProto->__protoFlags = ciflag_set(sceneProto->__protoFlags,2,2);
795 nRn = X3D_NODE(sceneProto);
798 setRootNode(X3D_NODE(sceneProto));
801 deleteVector(
sizeof(
void*),rn->_parentVector);
802 freeMallocedNodeFields(rn);
803 unRegisterX3DNode(rn);
810 parsedOk = parser_do_parse_string(of->fileData, of->fileDataSize, ectx, nRn);
814 tg->CParse.globalParser = t->savedParser;
961 if(vectorSize(p->fogNodes))
962 t->setFogBindInRender = vector_get(
struct X3D_Node*, p->fogNodes,0);
963 if (vectorSize(p->backgroundNodes))
964 t->setBackgroundBindInRender = vector_get(
struct X3D_Node*, p->backgroundNodes,0);
965 if (vectorSize(p->navigationNodes))
966 t->setNavigationBindInRender = vector_get(
struct X3D_Node*, p->navigationNodes,0);
967 if (vectorSize(t->viewpointNodes) ){
969 t->setViewpointBindInRender = vector_get(
struct X3D_Node*, t->viewpointNodes,0);
970 if (res->afterPoundCharacters)
971 fwl_gotoViewpoint(res->afterPoundCharacters);
977 if (res->whereToPlaceData == NULL) {
981 insert_node = X3D_NODE(res->whereToPlaceData);
982 offsetInNode = res->offsetFromWhereToPlaceData;
992 if(X3D_NODE(nRn)->_nodeType == NODE_Group){
994 AddRemoveChildren(X3D_NODE(insert_node),
995 offsetPointer_deref(
void*, insert_node, offsetInNode),
996 (
struct X3D_Node * *)nRng->children.p,
997 nRng->children.n, 1, __FILE__,__LINE__);
1000 AddRemoveChildren(X3D_NODE(nRng),
1002 (
struct X3D_Node* *)nRng->children.p,nRng->children.n,2,__FILE__,__LINE__);
1004 res->complete = TRUE;
1007 deleteVector(
sizeof(
void*),nRnfree->_parentVector);
1008 freeMallocedNodeFields(nRnfree);
1009 FREE_IF_NZ(nRnfree);
1022 int EAI_CreateVrml(
const char *tp,
const char *inputstring,
1026 bool retval = FALSE;
1030 if (strncmp(tp,
"URL", 3) == 0) {
1032 res = resource_create_single(inputstring);
1034 res->whereToPlaceData = where;
1035 res->offsetFromWhereToPlaceData = (int) offsetof (
struct X3D_Group, children);
1042 if (strncmp(inputstring,
"#VRML V2.0", 6) == 0) {
1043 sendIn = inputstring;
1045 newString = MALLOC (
char *, strlen(inputstring) + strlen (
"#VRML V2.0 utf8\n") + 3);
1046 strcpy (newString,
"#VRML V2.0 utf8\n");
1047 strcat (newString,inputstring);
1052 res = resource_create_from_string(sendIn);
1053 res->media_type=resm_vrml;
1054 res->parsed_request = EAI_Flag;
1056 res->whereToPlaceData = where;
1057 res->offsetFromWhereToPlaceData = (int) offsetof (
struct X3D_Group, children);
1059 retval = parser_process_res_VRML_X3D(res);
1060 FREE_IF_NZ(newString);
1069 int EAI_CreateX3d(
const char *tp,
const char *inputstring,
struct X3D_Node *ectx,
struct X3D_Group *where)
1077 if (strncmp(tp,
"URL", 3) == 0) {
1079 res = resource_create_single(inputstring);
1081 res->whereToPlaceData = where;
1082 res->offsetFromWhereToPlaceData = (int) offsetof (
struct X3D_Group, children);
1092 newString = MALLOC (
char *, strlen(inputstring) + strlen (
"<X3D>\n\n</X3D>\n") + 3);
1093 strcpy(newString,
"<X3D>\n");
1094 strcat(newString,inputstring);
1095 strcat(newString,
"\n</X3D>\n");
1098 res = resource_create_from_string(sendIn);
1099 res->media_type=resm_x3d;
1100 res->parsed_request = EAI_Flag;
1102 res->whereToPlaceData = where;
1103 res->offsetFromWhereToPlaceData = (int) offsetof (
struct X3D_Group, children);
1105 return parser_process_res_VRML_X3D(res);
1126 switch (res->type) {
1132 buffer = res->URLrequest;
1144 of = res->openned_files;
1150 buffer = (
const char*)of->fileData;
1156 return script_initCode(ss, buffer);
1160 #if !defined(HAVE_PTHREAD_CANCEL)
1161 void Parser_thread_exit_handler(
int sig) {
1162 ConsoleMessage(
"Parser_thread_exit_handler: parserThread exiting");
1165 #endif //HAVE_PTHREAD_CANCEL
1185 void *getProdConQueueContentStatus() {
1192 return (p->resource_list_to_parse);
1196 void threadsafe_enqueue_item_signal(
s_list_t *item,
s_list_t** queue, pthread_mutex_t* queue_lock, pthread_cond_t *queue_nonzero)
1198 pthread_mutex_lock(queue_lock);
1200 pthread_cond_signal(queue_nonzero);
1201 ml_enqueue(queue,item);
1202 pthread_mutex_unlock(queue_lock);
1205 s_list_t* threadsafe_dequeue_item_wait(
s_list_t** queue, pthread_mutex_t *queue_lock, pthread_cond_t *queue_nonzero,
bool *waiting )
1208 pthread_mutex_lock(queue_lock);
1209 while (*queue == NULL){
1211 pthread_cond_wait(queue_nonzero, queue_lock);
1214 item = ml_dequeue(queue);
1215 pthread_mutex_unlock(queue_lock);
1218 void resitem_enqueue(
s_list_t *item){
1223 threadsafe_enqueue_item_signal(item,&p->resource_list_to_parse, &tg->threads.mutex_resource_list, &tg->threads.resource_list_condition );
1225 void resitem_enqueue_tg(
s_list_t *item,
void* tg){
1226 fwl_setCurrentHandle(tg, __FILE__, __LINE__);
1227 resitem_enqueue(item);
1228 fwl_clearCurrentHandle();
1235 return threadsafe_dequeue_item_wait(&p->resource_list_to_parse, &tg->threads.mutex_resource_list, &tg->threads.resource_list_condition, &tg->threads.ResourceThreadWaiting );
1240 void threadsafe_enqueue_item(
s_list_t *item,
s_list_t** queue, pthread_mutex_t* queue_lock)
1242 pthread_mutex_lock(queue_lock);
1243 ml_enqueue(queue,item);
1244 pthread_mutex_unlock(queue_lock);
1247 s_list_t* threadsafe_dequeue_item(
s_list_t** queue, pthread_mutex_t *queue_lock )
1250 pthread_mutex_lock(queue_lock);
1251 item = ml_dequeue(queue);
1252 pthread_mutex_unlock(queue_lock);
1256 void frontenditem_enqueue(
s_list_t *item){
1260 threadsafe_enqueue_item(item,&p->frontend_list_to_get, &tg->threads.mutex_frontend_list );
1262 void frontenditem_enqueue_tg(
s_list_t *item,
void *tg){
1263 fwl_setCurrentHandle(tg, __FILE__, __LINE__);
1264 frontenditem_enqueue(item);
1265 fwl_clearCurrentHandle();
1272 return threadsafe_dequeue_item(&p->frontend_list_to_get, &tg->threads.mutex_frontend_list );
1274 s_list_t *frontenditem_dequeue_tg(
void *tg){
1276 fwl_setCurrentHandle(tg, __FILE__, __LINE__);
1277 item = frontenditem_dequeue();
1278 fwl_clearCurrentHandle();
1281 void *fwl_frontenditem_dequeue(){
1283 s_list_t *item = frontenditem_dequeue();
1290 void fwl_resitem_enqueue(
void *res){
1291 resitem_enqueue(ml_new(res));
1294 int frontendGetsFiles(){
1295 return ((
ppProdCon)(gglobal()->ProdCon.prv))->frontend_gets_files;
1307 static bool parser_process_res(
s_list_t *item)
1310 bool remove_it = FALSE;
1318 if (!item || !item->elem)
1321 res = ml_elem(item);
1324 switch (res->status) {
1329 if(!res->actions || (res->actions & resa_identify)){
1330 resource_identify(res->parent, res);
1331 if (res->type == rest_invalid) {
1333 res->complete = TRUE;
1338 case ress_starts_good:
1339 if(!res->actions || (res->actions & resa_download)){
1342 frontenditem_enqueue(ml_new(res));
1348 if(p->frontend_gets_files){
1349 frontenditem_enqueue(ml_new(res));
1352 resource_fetch(res);
1358 case ress_downloaded:
1359 if(!res->actions || (res->actions & resa_load))
1363 if(!res->_loadFunc(res)){
1364 ERROR_MSG(
"failure when trying to load resource: %s\n", res->URLrequest);
1366 res->complete = TRUE;
1373 more_multi = (res->status == ress_failed) && (res->m_request != NULL);
1376 res->status = ress_invalid;
1377 res->type = rest_multi;
1380 resource_identify(res->parent, res);
1381 frontenditem_enqueue(ml_new(res));
1383 ConsoleMessage(
"url not found: %s\n",res->parsed_request);
1385 res->complete = TRUE;
1393 if(!res->actions || (res->actions & resa_process))
1394 switch (res->media_type) {
1396 ConsoleMessage (
"deciphering file: 404 file not found or unknown file type encountered.");
1399 res->status = ress_not_loaded;
1403 if (parser_process_res_VRML_X3D(res)) {
1404 DEBUG_MSG(
"parser successfull: %s\n", res->URLrequest);
1405 res->status = ress_parsed;
1408 ERROR_MSG(
"parser failed for resource: %s\n", res->URLrequest);
1413 if (parser_process_res_SCRIPT(res)) {
1414 DEBUG_MSG(
"parser successfull: %s\n", res->URLrequest);
1415 res->status = ress_parsed;
1418 ERROR_MSG(
"parser failed for resource: %s\n", res->URLrequest);
1423 if (parser_process_res_SHADER(res)) {
1424 DEBUG_MSG(
"parser successfull: %s\n", res->URLrequest);
1425 res->status = ress_parsed;
1428 ERROR_MSG(
"parser failed for resource: %s\n", res->URLrequest);
1434 res->complete = TRUE;
1435 process_res_texitem(res);
1438 res->complete = TRUE;
1439 if(process_res_movie(res)){
1440 res->status = ress_parsed;
1443 res->status = ress_failed;
1447 res->complete = TRUE;
1448 if(process_res_audio(res)){
1449 res->status = ress_parsed;
1452 res->status = ress_failed;
1457 printf(
"processed x3z\n");
1462 printf (
"dont know anything about resm_external at this point\n");
1466 res->complete = TRUE;
1470 case ress_not_loaded:
1472 res->complete = TRUE;
1477 res->complete = TRUE;
1481 case ress_not_parsed:
1482 res->complete = TRUE;
1490 if(res->status == ress_parsed){
1492 if(res->openned_files){
1495 FREE_IF_NZ(of->fileData);
1501 resitem_enqueue(item);
1503 dump_parser_wait_queue();
1510 static const int res_command_exit;
1512 void resitem_queue_exit(){
1513 resitem_enqueue(ml_new(&res_command_exit));
1515 void _inputParseThread(
void *globalcontext)
1519 #if !defined (HAVE_PTHREAD_CANCEL)
1520 struct sigaction actions;
1522 memset(&actions, 0,
sizeof(actions));
1523 sigemptyset(&actions.sa_mask);
1524 actions.sa_flags = 0;
1525 actions.sa_handler = Parser_thread_exit_handler;
1526 rc = sigaction(SIGUSR2,&actions,NULL);
1528 #endif //HAVE_PTHREAD_CANCEL
1532 tg->threads.PCthread = pthread_self();
1534 fwl_setCurrentHandle(tg,__FILE__,__LINE__);
1537 tg->threads.ResourceThreadRunning = TRUE;
1538 ENTER_THREAD(
"input parser");
1547 s_list_t* item = resitem_dequeue();
1548 elem = ml_elem(item);
1549 if (elem == &res_command_exit){
1555 if (tg->threads.flushing){
1559 p->inputThreadParsing = TRUE;
1561 parser_process_res(item);
1562 p->inputThreadParsing = FALSE;
1565 tg->threads.ResourceThreadRunning = FALSE;
1573 void kill_bindables (
void) {
1579 struct tProdCon *t = &gglobal()->ProdCon;
1588 for(i=0;i<vectorSize(tg->Bindable.bstacks);i++){
1590 if (vectorSize(bstack->navigation) > 0) {
1591 for (i=0; i < vectorSize(bstack->navigation);i++){
1592 tmp = vector_get(
struct X3D_Node*,bstack->navigation,i);
1593 send_bind_to(tmp, ib);
1596 if (vectorSize(bstack->background) > 0) {
1597 for (i=0; i < vectorSize(bstack->background);i++){
1598 tmp = vector_get(
struct X3D_Node*,bstack->background,i);
1599 send_bind_to(tmp, ib);
1602 if (vectorSize(bstack->viewpoint) > 0) {
1603 for (i=0; i < vectorSize(bstack->viewpoint);i++){
1604 tmp = vector_get(
struct X3D_Node*,bstack->viewpoint,i);
1605 send_bind_to(tmp, ib);
1608 if (vectorSize(bstack->fog) > 0) {
1609 for (i=0; i < vectorSize(bstack->fog);i++){
1610 tmp = vector_get(
struct X3D_Node*,bstack->fog,i);
1611 send_bind_to(tmp, ib);
1614 ((
struct Vector *)bstack->navigation)->n=0;
1615 ((
struct Vector *)bstack->background)->n=0;
1616 ((
struct Vector *)bstack->viewpoint)->n=0;
1617 ((
struct Vector *)bstack->fog)->n=0;
1620 ((
struct Vector *)t->viewpointNodes)->n=0;
1621 p->backgroundNodes->n=0;
1622 p->navigationNodes->n=0;
1660 void registerBindable (
struct X3D_Node *node) {
1669 layerId = tg->Bindable.activeLayer;
1671 switch (node->_nodeType) {
1672 case NODE_Viewpoint:
1673 X3D_VIEWPOINT(node)->set_bind = 100;
1674 X3D_VIEWPOINT(node)->isBound = 0;
1675 X3D_VIEWPOINT(node)->_layerId = layerId;
1676 vector_pushBack (
struct X3D_Node*,t->viewpointNodes, node);
1678 case NODE_OrthoViewpoint:
1679 X3D_ORTHOVIEWPOINT(node)->set_bind = 100;
1680 X3D_ORTHOVIEWPOINT(node)->isBound = 0;
1681 X3D_ORTHOVIEWPOINT(node)->_layerId = layerId;
1682 vector_pushBack (
struct X3D_Node*,t->viewpointNodes, node);
1684 case NODE_GeoViewpoint:
1685 X3D_GEOVIEWPOINT(node)->set_bind = 100;
1686 X3D_GEOVIEWPOINT(node)->isBound = 0;
1687 X3D_GEOVIEWPOINT(node)->_layerId = layerId;
1688 vector_pushBack (
struct X3D_Node*,t->viewpointNodes, node);
1690 case NODE_Background:
1691 X3D_BACKGROUND(node)->set_bind = 100;
1692 X3D_BACKGROUND(node)->isBound = 0;
1693 X3D_BACKGROUND(node)->_layerId = layerId;
1694 vector_pushBack (
struct X3D_Node*,p->backgroundNodes, node);
1696 case NODE_TextureBackground:
1697 X3D_TEXTUREBACKGROUND(node)->set_bind = 100;
1698 X3D_TEXTUREBACKGROUND(node)->isBound = 0;
1699 X3D_TEXTUREBACKGROUND(node)->_layerId = layerId;
1700 vector_pushBack (
struct X3D_Node*,p->backgroundNodes, node);
1702 case NODE_NavigationInfo:
1703 X3D_NAVIGATIONINFO(node)->set_bind = 100;
1704 X3D_NAVIGATIONINFO(node)->isBound = 0;
1705 X3D_NAVIGATIONINFO(node)->_layerId = layerId;
1706 vector_pushBack (
struct X3D_Node*,p->navigationNodes, node);
1709 X3D_FOG(node)->set_bind = 100;
1710 X3D_FOG(node)->isBound = 0;
1711 X3D_FOG(node)->_layerId = layerId;
1712 vector_pushBack (
struct X3D_Node*,p->fogNodes, node);
1724 int removeNodeFromVector(
int iaction,
struct Vector *v,
struct X3D_Node *node){
1727 int noisy, iret = FALSE;
1736 tn = vector_get(
struct X3D_Node*,v,ii);
1740 vector_set(
struct X3D_Node*,v,ii,NULL);
1741 if(noisy) printf(
"NULLing %d %p\n",ii,node);
1742 }
else if(iaction == 0){
1743 if(noisy) printf(
"REMOVing %d %p\n",ii,node);
1744 vector_remove_elem(
struct X3D_Node*,v,ii);
1751 printf(
"not found in stack node=%p stack.n=%d:\n",node,vectorSize(v));
1752 for(i=0;i<vectorSize(v);i++){
1753 printf(
" %p",vector_get(
struct X3D_Node*,v,i));
1759 void unRegisterBindable (
struct X3D_Node *node) {
1761 struct tProdCon *t = &gglobal()->ProdCon;
1765 switch (node->_nodeType) {
1766 case NODE_Viewpoint:
1767 X3D_VIEWPOINT(node)->set_bind = 100;
1768 X3D_VIEWPOINT(node)->isBound = 0;
1770 send_bind_to(node,0);
1771 removeNodeFromVector(0, t->viewpointNodes, node);
1773 case NODE_OrthoViewpoint:
1774 X3D_ORTHOVIEWPOINT(node)->set_bind = 100;
1775 X3D_ORTHOVIEWPOINT(node)->isBound = 0;
1776 send_bind_to(node,0);
1777 removeNodeFromVector(0, t->viewpointNodes, node);
1779 case NODE_GeoViewpoint:
1780 X3D_GEOVIEWPOINT(node)->set_bind = 100;
1781 X3D_GEOVIEWPOINT(node)->isBound = 0;
1782 send_bind_to(node,0);
1783 removeNodeFromVector(0, t->viewpointNodes, node);
1785 case NODE_Background:
1786 X3D_BACKGROUND(node)->set_bind = 100;
1787 X3D_BACKGROUND(node)->isBound = 0;
1788 send_bind_to(node,0);
1789 removeNodeFromVector(0, p->backgroundNodes, node);
1791 case NODE_TextureBackground:
1792 X3D_TEXTUREBACKGROUND(node)->set_bind = 100;
1793 X3D_TEXTUREBACKGROUND(node)->isBound = 0;
1794 removeNodeFromVector(0, p->backgroundNodes, node);
1796 case NODE_NavigationInfo:
1797 X3D_NAVIGATIONINFO(node)->set_bind = 100;
1798 X3D_NAVIGATIONINFO(node)->isBound = 0;
1799 send_bind_to(node,0);
1800 removeNodeFromVector(0, p->navigationNodes, node);
1803 X3D_FOG(node)->set_bind = 100;
1804 X3D_FOG(node)->isBound = 0;
1805 send_bind_to(node,0);
1806 removeNodeFromVector(0, p->fogNodes, node);