23 #define UNUSED(v) ((void) v)
35 X3DNode *X3D_getNode (
char *name) {
40 retval = malloc (
sizeof(
X3DNode));
41 retval->X3D_SFNode.type = FIELDTYPE_SFNode;
44 retval->X3D_SFNode.adr = 0;
47 ptr = _X3D_make1StringCommand(GETNODE,name);
50 if (sscanf (ptr,
"%d", &adr) != 1) {
51 printf (
"error getting %s\n",name);
54 printf (
"X3D_getNode, ptr %s\n",ptr);
55 printf (
"adr %d\n",adr);
59 printf (
"node %s does not exist\n",name);
64 retval->X3D_SFNode.adr = adr;
87 if((child->X3D_SFNode.type != FIELDTYPE_SFNode) && (child->X3D_MFNode.type != FIELDTYPE_MFNode)) {
88 printf (
"X3D_getParentNodes, expected a node, got a %s\n",FIELDTYPES[child->X3D_SFNode.type]);
92 if (child->X3D_SFNode.type == FIELDTYPE_SFNode) {
93 adr = child->X3D_SFNode.adr;
95 if (child->X3D_MFNode.n != 1) {
96 printf (
"warning - will only get event for first child = have %d nodes\n",child->X3D_MFNode.n);
99 adr = child->X3D_MFNode.p[5].adr;
102 snprintf(arg, 10,
"%d", adr);
104 ptr = _X3D_make1StringCommand(GETNODEPARENTS,arg);
109 parentToken = STRTOK_S(ptr,
" ",&next_token);
111 sscanf(parentToken,
"%d",&parentAdr);
116 *outParentArray = NULL;
126 if(parentCount && parentCount%10==0)
129 tmpReallocBuf =(
X3DNode*) realloc(tmpBuf,(
sizeof(
X3DNode)*(parentCount+10)));
134 *outParentArray = tmpBuf;
138 tmpBuf = tmpReallocBuf;
141 tmpBuf[parentCount].X3D_SFNode.type = FIELDTYPE_SFNode;
143 sscanf(parentToken,
"%d",&parentAdr);
148 *outParentArray = tmpBuf;
152 tmpBuf[parentCount].X3D_SFNode.adr = parentAdr;
157 parentToken = STRTOK_S(NULL,
" ",&next_token);
160 *outParentArray = tmpBuf;
166 int X3D_getParentNodesbyName(
char *childName,
X3DNode** outChildNode,
X3DNode** outParentArray)
168 *outChildNode = X3D_getNode(childName);
171 return X3D_getParentNodes(*outChildNode, outParentArray);
179 X3DEventIn *_X3D_getEvent(
X3DNode *node,
char *name,
int into) {
190 retval->datasize = 0;
191 retval->field = NULL;
192 retval->scripttype = 0;
194 if((node->X3D_SFNode.type != FIELDTYPE_SFNode) && (node->X3D_MFNode.type != FIELDTYPE_MFNode)) {
195 printf (
"X3D_getEvent, expected a node, got a %s\n",FIELDTYPES[node->X3D_SFNode.type]);
200 if (node->X3D_SFNode.type == FIELDTYPE_SFNode) {
201 adr = node->X3D_SFNode.adr;
203 if (node->X3D_MFNode.n != 1) {
205 printf (
"warning - will only get event for first node = have %d nodes\n",node->X3D_MFNode.n);
206 for (i=0; i<node->X3D_MFNode.n; i++) {
207 printf (
"... node %d nodetype %d\n",i,node->X3D_MFNode.p[i].adr);
211 adr = node->X3D_MFNode.p[0].adr;
221 ptr = _X3D_Browser_SendEventType(adr, name,
"eventOut");
224 ptr = _X3D_Browser_SendEventType(adr, name,
"eventIn");
227 ptr = _X3D_Browser_SendEventType(adr, name,
"");
231 ptr = _X3D_Browser_SendEventType(adr, name,
"eventIn");
247 if (sscanf(ptr,
"%d %d %d", &origPtr, &offset, &nds) != 3) {
248 printf (
"error in getEventIn\n");
254 if (origPtr != adr) {
255 printf (
"error in getEventIn, origptr and node ptr do not match\n");
261 retval->nodeptr = origPtr;
262 retval->offset = offset;
263 retval->datasize = nds;
275 retval->datatype = mapEAItypeToFieldType(*ptr);
280 if (sscanf (ptr,
"%d",&(retval->scripttype)) != 1) {
281 printf (
"No Event %s found!\n", name);
301 retval->field = strdup(name);
308 X3DEventIn *X3D_getEventIn(
X3DNode *node,
char *name) {
310 retval = _X3D_getEvent(node, name,TRUE);
316 X3DNode* X3D_getExecutionContext()
318 return X3D_getNode (SYSTEMROOTNODE);
321 void X3D_rootNodeHandling(
X3DNode *scene,
X3DNode *node,
int action)
324 X3DEventIn *addChildren = X3D_getEventIn(scene,
"addChildren");
325 X3D_setValue(addChildren, node);
326 }
else if(action ==2){
327 X3DEventIn *removeChildren = X3D_getEventIn(scene,
"removeChildren");
328 X3D_setValue(removeChildren, node);
332 X3DEventOut *X3D_getEventOut(
X3DNode *node,
char *name) {
334 retval = _X3D_getEvent(node, name,FALSE);
339 X3DFieldDef* X3D_getFieldDef(
X3DNode *node,
char *name){
341 retval = _X3D_getEvent(node, name,-1);
346 char* X3D_getFieldDefs(
int nodeAdr)
351 sprintf (myline,
"%d",nodeAdr);
354 ptr = _X3D_make1StringCommand(GETFIELDDEFS,myline);
361 void X3D_addRoute (X3DEventOut *from, X3DEventIn *to) {
366 sprintf (myline,
"%d %s %d %s",from->nodeptr,from->field,to->nodeptr,to->field);
367 ptr = _X3D_make1StringCommand(ADDROUTE,myline);
370 void X3D_deleteRoute (X3DEventOut *from, X3DEventIn *to) {
375 sprintf (myline,
"%d %s %d %s",from->nodeptr,from->field,to->nodeptr,to->field);
376 ptr = _X3D_make1StringCommand(DELETEROUTE,myline);
379 X3DNode* X3D_getValue (X3DEventOut *src) {
397 value = malloc (
sizeof(
X3DNode));
399 value->type = src->datatype;
400 sprintf(myline,
"%d %d %c %d", src->nodeptr, src->offset, mapFieldTypeToEAItype(src->datatype), src->datasize);
401 ptr = _X3D_make1StringCommand(GETVALUE, myline);
403 switch (src->datatype) {
404 case FIELDTYPE_SFVec3f:
405 sscanf(ptr,
"%f %f %f", &a, &b, &c);
407 value->X3D_SFVec3f.c[0] = a;
408 value->X3D_SFVec3f.c[1] = b;
409 value->X3D_SFVec3f.c[2] = c;
412 case FIELDTYPE_SFColor:
414 sscanf(ptr,
"%f %f %f", &a, &b, &c);
416 value->X3D_SFColor.c[0] = a;
417 value->X3D_SFColor.c[1] = b;
418 value->X3D_SFColor.c[2] = c;
422 case FIELDTYPE_SFVec2f:
424 sscanf(ptr,
"%f %f", &a, &b);
426 value->X3D_SFVec2f.c[0] = a;
427 value->X3D_SFVec2f.c[1] = b;
431 case FIELDTYPE_SFRotation:
433 sscanf(ptr,
"%f %f %f %f", &a, &b, &c, &d);
435 value->X3D_SFRotation.r[0] = a;
436 value->X3D_SFRotation.r[1] = b;
437 value->X3D_SFRotation.r[2] = c;
438 value->X3D_SFRotation.r[3] = d;
442 case FIELDTYPE_SFColorRGBA:
444 sscanf(ptr,
"%f %f %f %f", &a, &b, &c, &d);
446 value->X3D_SFColorRGBA.r[0] = a;
447 value->X3D_SFColorRGBA.r[1] = b;
448 value->X3D_SFColorRGBA.r[2] = c;
449 value->X3D_SFColorRGBA.r[3] = d;
453 case FIELDTYPE_SFBool:
455 sscanf(ptr,
"%s", tstring);
457 if (!strcmp(tstring,
"TRUE"))
458 value->X3D_SFBool.value = 1;
460 value->X3D_SFBool.value = 0;
464 case FIELDTYPE_SFFloat:
466 sscanf(ptr,
"%f", &a);
468 value->X3D_SFFloat.value = a;
472 case FIELDTYPE_SFTime:
474 sscanf(ptr,
"%lf", &db);
476 value->X3D_SFTime.value = db;
480 case FIELDTYPE_SFInt32:
482 sscanf(ptr,
"%d", &i);
484 value->X3D_SFInt32.value = i;
488 case FIELDTYPE_SFString:
490 sscanf(ptr,
"\"%s\"", tstring);
491 len = strlen(tstring);
495 value->X3D_SFString.strptr = malloc ((strlen(tstring)+1) *
sizeof(
char));
496 strncpy(value->X3D_SFString.strptr,tstring, strlen(tstring) + 1);
497 value->X3D_SFString.len = strlen(tstring);
501 case FIELDTYPE_MFString:
503 bzero(ttok,
sizeof(ttok));
505 temp = strtok(ptr,
"\r\n");
508 while (strncmp(temp,
"RE_EOT", 6) && (temp != NULL)) {
520 for(i=istart;i<strlen(temp);i++)
526 if( temp[i-1] !=
'\\' ) start = i+1;
536 for(i=start;i<strlen(temp);i++)
539 if( temp[i-1] !=
'\\' ) stop = i-1;
546 strncpy(tstring,&temp[start],len);
548 strcat(ttok, tstring);
553 }
while(start && stop);
554 temp = strtok(NULL,
"\r\n");
557 value->X3D_MFString.n = j;
558 value->X3D_MFString.p = malloc(j*
sizeof(
X3DNode));
561 temp = strtok(ttok,
"\r");
563 value->X3D_MFString.p[0].len = strlen(temp);
564 value->X3D_MFString.p[0].strptr = malloc(
sizeof(
char)*(STRLEN));
565 strncpy(value->X3D_MFString.p[0].strptr, temp, STRLEN);
567 value->X3D_MFString.p[0].type = FIELDTYPE_SFString;
570 for (i = 1; i < j; i++) {
572 temp = strtok(NULL,
"\r");
573 value->X3D_MFString.p[i].len = strlen(temp);
574 value->X3D_MFString.p[i].strptr = malloc(STRLEN);
575 strncpy(value->X3D_MFString.p[i].strptr, temp, STRLEN);
578 value->X3D_MFString.p[i].type = FIELDTYPE_SFString;
582 case FIELDTYPE_MFInt32:
584 temp = strtok(ptr,
" \r\n");
586 value->X3D_MFInt32.n = num;
587 value->X3D_MFInt32.p = malloc(num *
sizeof(
X3DNode));
589 for (i = 0; i < num; i++) {
590 temp = strtok(NULL,
" \r\n");
592 value->X3D_MFInt32.p[i].value = val;
593 value->X3D_MFInt32.p[i].type= FIELDTYPE_SFInt32;
598 case FIELDTYPE_MFBool:
600 temp = strtok(ptr,
" \r\n");
602 value->X3D_MFBool.n = num;
603 value->X3D_MFBool.p = malloc(num *
sizeof(
X3DNode));
605 for (i = 0; i < num; i++) {
606 temp = strtok(NULL,
" \r\n");
607 if (!strcmp(temp,
"TRUE")) {
608 value->X3D_MFBool.p[i].value = 1;
610 value->X3D_MFBool.p[i].value = 0;
612 value->X3D_MFBool.p[i].type= FIELDTYPE_SFBool;
617 case FIELDTYPE_MFFloat:
619 temp = strtok(ptr,
" \r\n");
621 value->X3D_MFFloat.n = num;
622 value->X3D_MFFloat.p = malloc(num *
sizeof(
X3DNode));
624 for (i = 0; i < num; i++) {
625 temp = strtok(NULL,
" \r\n");
627 value->X3D_MFFloat.p[i].value = fval;
628 value->X3D_MFFloat.p[i].type= FIELDTYPE_SFFloat;
633 case FIELDTYPE_MFVec3f:
634 temp = strtok(ptr,
" \r\n");
637 value->X3D_MFVec3f.n = num;
638 value->X3D_MFVec3f.p = malloc(num *
sizeof(
X3DNode));
640 for (i = 0; i < num; i++) {
641 for (j=0; j < 3; j++) {
642 temp = strtok(NULL,
" \r\n");
644 value->X3D_MFVec3f.p[i].c[j] = fval;
646 value->X3D_MFVec3f.p[i].type = FIELDTYPE_SFVec3f;
651 case FIELDTYPE_MFVec3d:
652 temp = strtok(ptr,
" \r\n");
655 value->X3D_MFVec3d.n = num;
656 value->X3D_MFVec3d.p = malloc(num *
sizeof(
X3DNode));
658 for (i = 0; i < num; i++) {
659 for (j=0; j < 3; j++) {
660 temp = strtok(NULL,
" \r\n");
662 value->X3D_MFVec3d.p[i].c[j] = (double) fval;
664 value->X3D_MFVec3d.p[i].type = FIELDTYPE_SFVec3d;
669 case FIELDTYPE_MFColor:
670 temp = strtok(ptr,
" \r\n");
673 value->X3D_MFColor.n = num;
674 value->X3D_MFColor.p = malloc(num *
sizeof(
X3DNode));
676 for (i = 0; i < num; i++) {
677 for (j=0; j < 3; j++) {
678 temp = strtok(NULL,
" \r\n");
680 value->X3D_MFColor.p[i].c[j] = fval;
682 value->X3D_MFColor.p[i].type = FIELDTYPE_SFColor;
687 case FIELDTYPE_MFVec2f:
688 temp = strtok(ptr,
" \r\n");
691 value->X3D_MFVec2f.n = num;
692 value->X3D_MFVec2f.p = malloc(num *
sizeof(
X3DNode));
694 for (i = 0; i < num; i++) {
695 for (j=0; j < 2; j++) {
696 temp = strtok(NULL,
" \r\n");
698 value->X3D_MFVec2f.p[i].c[j] = fval;
700 value->X3D_MFVec2f.p[i].type = FIELDTYPE_SFVec2f;
705 case FIELDTYPE_MFRotation:
706 temp = strtok(ptr,
" \r\n");
709 value->X3D_MFRotation.n = num;
710 value->X3D_MFRotation.p = malloc(num *
sizeof(
X3DNode));
712 for (i = 0; i < num; i++) {
713 for (j=0; j < 4; j++) {
714 temp = strtok(NULL,
" \r\n");
716 value->X3D_MFRotation.p[i].r[j] = fval;
718 value->X3D_MFRotation.p[i].type = FIELDTYPE_SFRotation;
723 case FIELDTYPE_MFColorRGBA:
724 temp = strtok(ptr,
" \r\n");
727 value->X3D_MFColorRGBA.n = num;
728 value->X3D_MFColorRGBA.p = malloc(num *
sizeof(
X3DNode));
730 for (i = 0; i < num; i++) {
731 for (j=0; j < 4; j++) {
732 temp = strtok(NULL,
" \r\n");
734 value->X3D_MFColorRGBA.p[i].r[j] = fval;
736 value->X3D_MFColorRGBA.p[i].type = FIELDTYPE_SFColorRGBA;
741 case FIELDTYPE_SFNode:
744 sscanf(ptr,
"%d", &adr);
746 value->X3D_SFNode.adr= adr;
750 case FIELDTYPE_MFNode:
752 retvals = _X3D_countWords(ptr);
755 value->X3D_MFNode.p = malloc (retvals/2 *
sizeof (
X3DNode));
756 value->X3D_MFNode.n = retvals;
758 for (i= 0; i< (retvals); i++) {
764 sscanf (ptr,
"%d",&mytmp);
765 value->X3D_MFNode.p[i].adr = mytmp;
775 printf(
"XXX - getValue, not implemented yet for type '%s'\n", FIELDTYPES[src->datatype]);
783 void X3D_setValue (X3DEventIn *dest,
X3DNode *node) {
795 if (dest->datatype != node->X3D_SFNode.type) {
796 printf (
"X3D_setValue mismatch: event type %s, value type %s (%d, %d)\n",
797 FIELDTYPES[(
int)dest->datatype], FIELDTYPES[node->X3D_SFNode.type],
798 dest->datatype,node->X3D_SFNode.type);
803 switch (dest->datatype) {
805 printf (
"XXX - setValue, not implemented yet for type '%s'\n",FIELDTYPES[dest->datatype]);
808 case FIELDTYPE_SFVec3d:
809 sprintf (myline,
"%c %d %d %d %f %f %f\n",
810 mapFieldTypeToEAItype(dest->datatype),
811 dest->nodeptr, dest->offset, dest->scripttype,
812 node->X3D_SFVec3d.c[0],
813 node->X3D_SFVec3d.c[1],
814 node->X3D_SFVec3d.c[2]);
815 _X3D_sendEvent (SENDEVENT,myline,__LINE__);
819 case FIELDTYPE_SFVec3f:
820 case FIELDTYPE_SFColor:
821 sprintf (myline,
"%c %d %d %d %f %f %f\n",
822 mapFieldTypeToEAItype(dest->datatype),
823 dest->nodeptr, dest->offset, dest->scripttype,
824 node->X3D_SFVec3f.c[0],
825 node->X3D_SFVec3f.c[1],
826 node->X3D_SFVec3f.c[2]);
827 _X3D_sendEvent (SENDEVENT,myline,__LINE__);
830 case FIELDTYPE_SFVec2f:
831 sprintf (myline,
"%c %d %d %d %f %f\n",
832 mapFieldTypeToEAItype(dest->datatype),
833 dest->nodeptr, dest->offset, dest->scripttype,
834 node->X3D_SFVec2f.c[0],
835 node->X3D_SFVec2f.c[1]);
836 _X3D_sendEvent (SENDEVENT,myline,__LINE__);
839 case FIELDTYPE_SFRotation:
840 case FIELDTYPE_SFColorRGBA:
841 sprintf (myline,
"%c %d %d %d %f %f %f %f\n",
842 mapFieldTypeToEAItype(dest->datatype),
843 dest->nodeptr, dest->offset, dest->scripttype,
844 node->X3D_SFRotation.r[0],
845 node->X3D_SFRotation.r[1],
846 node->X3D_SFRotation.r[2],
847 node->X3D_SFRotation.r[3]);
848 _X3D_sendEvent (SENDEVENT,myline,__LINE__);
851 case FIELDTYPE_SFBool:
852 if (node->X3D_SFBool.value) {
853 sprintf (myline,
"%c %d %d %d TRUE\n",
854 mapFieldTypeToEAItype(dest->datatype),
855 dest->nodeptr, dest->offset, dest->scripttype);
857 sprintf (myline,
"%c %d %d %d FALSE\n",
858 mapFieldTypeToEAItype(dest->datatype),
859 dest->nodeptr, dest->offset, dest->scripttype);
861 _X3D_sendEvent (SENDEVENT,myline,__LINE__);
863 case FIELDTYPE_SFInt32:
864 sprintf (myline,
"%c %d %d %d %d\n",
865 mapFieldTypeToEAItype(dest->datatype),
866 dest->nodeptr, dest->offset, dest->scripttype,
867 node->X3D_SFBool.value);
868 _X3D_sendEvent (SENDEVENT,myline,__LINE__);
871 case FIELDTYPE_SFFloat:
872 sprintf (myline,
"%c %d %d %d %f\n",
873 mapFieldTypeToEAItype(dest->datatype),
874 dest->nodeptr, dest->offset, dest->scripttype,
875 node->X3D_SFFloat.value);
876 _X3D_sendEvent (SENDEVENT,myline,__LINE__);
879 case FIELDTYPE_SFTime:
880 sprintf (myline,
"%c %d %d %d %lf\n",
881 mapFieldTypeToEAItype(dest->datatype),
882 dest->nodeptr, dest->offset, dest->scripttype,
883 node->X3D_SFTime.value);
884 _X3D_sendEvent (SENDEVENT,myline,__LINE__);
887 case FIELDTYPE_SFString:
888 sprintf (myline,
"%c %d %d %d %d:%s\n",
889 mapFieldTypeToEAItype(dest->datatype),
890 dest->nodeptr, dest->offset, dest->scripttype,
891 node->X3D_SFString.len, node->X3D_SFString.strptr);
892 _X3D_sendEvent (SENDEVENT,myline,__LINE__);
895 case FIELDTYPE_MFInt32:
896 sprintf(myline,
"%c %d %d %d [",
897 mapFieldTypeToEAItype(dest->datatype),
898 dest->nodeptr, dest->offset, dest->scripttype
901 for (i = 0; i < node->X3D_MFInt32.n; i++) {
902 sprintf(tstring,
"%d", node->X3D_MFInt32.p[i].value);
903 strcat(myline, tstring);
904 strcat(myline,
", ");
907 _X3D_sendEvent (SENDEVENT, myline,__LINE__);
911 case FIELDTYPE_MFBool:
912 sprintf(myline,
"%c %d %d %d [",
913 mapFieldTypeToEAItype(dest->datatype),
914 dest->nodeptr, dest->offset, dest->scripttype
917 for (i = 0; i < node->X3D_MFBool.n; i++) {
918 if (node->X3D_MFBool.p[i].value) {
919 strcat(myline,
"TRUE");
921 strcat(myline,
"FALSE");
923 strcat(myline,
", ");
926 _X3D_sendEvent (SENDEVENT, myline,__LINE__);
930 case FIELDTYPE_MFFloat:
931 sprintf(myline,
"%c %d %d %d [",
932 mapFieldTypeToEAItype(dest->datatype),
933 dest->nodeptr, dest->offset, dest->scripttype
936 for (i = 0; i < node->X3D_MFFloat.n; i++) {
937 sprintf(tstring,
"%f", node->X3D_MFFloat.p[i].value);
938 strcat(myline, tstring);
939 strcat(myline,
", ");
942 _X3D_sendEvent (SENDEVENT, myline,__LINE__);
946 case FIELDTYPE_MFVec3f:
947 sprintf(myline,
"%c %d %d %d [",
948 mapFieldTypeToEAItype(dest->datatype),
949 dest->nodeptr, dest->offset, dest->scripttype
952 for (i = 0; i < node->X3D_MFVec3f.n; i++) {
953 sprintf(tstring,
"%f %f %f, ", node->X3D_MFVec3f.p[i].c[0], node->X3D_MFVec3f.p[i].c[1], node->X3D_MFVec3f.p[i].c[2]);
954 strcat(myline, tstring);
957 _X3D_sendEvent(SENDEVENT, myline,__LINE__);
961 case FIELDTYPE_MFVec3d:
962 sprintf(myline,
"%c %d %d %d [",
963 mapFieldTypeToEAItype(dest->datatype),
964 dest->nodeptr, dest->offset, dest->scripttype
967 for (i = 0; i < node->X3D_MFVec3d.n; i++) {
968 sprintf(tstring,
"%lf %lf %lf, ", node->X3D_MFVec3d.p[i].c[0], node->X3D_MFVec3d.p[i].c[1], node->X3D_MFVec3d.p[i].c[2]);
969 strcat(myline, tstring);
972 _X3D_sendEvent(SENDEVENT, myline,__LINE__);
976 case FIELDTYPE_MFColor:
977 sprintf(myline,
"%c %d %d %d [",
978 mapFieldTypeToEAItype(dest->datatype),
979 dest->nodeptr, dest->offset, dest->scripttype
982 for (i = 0; i < node->X3D_MFColor.n; i++) {
983 sprintf(tstring,
"%f %f %f, ", node->X3D_MFColor.p[i].c[0], node->X3D_MFColor.p[i].c[1], node->X3D_MFColor.p[i].c[2]);
984 strcat(myline, tstring);
987 _X3D_sendEvent(SENDEVENT, myline,__LINE__);
991 case FIELDTYPE_MFVec2f:
992 sprintf(myline,
"%c %d %d %d [",
993 mapFieldTypeToEAItype(dest->datatype),
994 dest->nodeptr, dest->offset, dest->scripttype
997 for (i = 0; i < node->X3D_MFVec2f.n; i++) {
998 sprintf(tstring,
"%f %f, ", node->X3D_MFVec2f.p[i].c[0], node->X3D_MFVec2f.p[i].c[1]);
999 strcat(myline, tstring);
1001 strcat(myline,
"]");
1002 _X3D_sendEvent(SENDEVENT, myline,__LINE__);
1006 case FIELDTYPE_MFRotation:
1007 sprintf(myline,
"%c %d %d %d [",
1008 mapFieldTypeToEAItype(dest->datatype),
1009 dest->nodeptr, dest->offset, dest->scripttype
1012 for (i = 0; i < node->X3D_MFRotation.n; i++) {
1013 sprintf(tstring,
"%f %f %f %f, ", node->X3D_MFRotation.p[i].r[0], node->X3D_MFRotation.p[i].r[1], node->X3D_MFRotation.p[i].r[2], node->X3D_MFRotation.p[i].r[3]);
1014 strcat(myline, tstring);
1016 strcat(myline,
"]");
1017 _X3D_sendEvent(SENDEVENT, myline,__LINE__);
1021 case FIELDTYPE_MFColorRGBA:
1022 sprintf(myline,
"%c %d %d %d [",
1023 mapFieldTypeToEAItype(dest->datatype),
1024 dest->nodeptr, dest->offset, dest->scripttype
1027 for (i = 0; i < node->X3D_MFColorRGBA.n; i++) {
1028 sprintf(tstring,
"%f %f %f %f, ", node->X3D_MFColorRGBA.p[i].r[0], node->X3D_MFColorRGBA.p[i].r[1], node->X3D_MFColorRGBA.p[i].r[2], node->X3D_MFColorRGBA.p[i].r[3]);
1029 strcat(myline, tstring);
1031 strcat(myline,
"]");
1032 _X3D_sendEvent(SENDEVENT, myline,__LINE__);
1036 case FIELDTYPE_MFString:
1037 sprintf(myline,
"%c %d %d %d [ ",
1038 mapFieldTypeToEAItype(dest->datatype),
1039 dest->nodeptr, dest->offset, dest->scripttype
1042 for (i = 0; i < node->X3D_MFString.n; i++) {
1043 strcat(myline,
"\"");
1044 strcat(myline, node->X3D_MFString.p[i].strptr);
1045 strcat(myline,
"\" ");
1047 strcat(myline,
"]");
1053 _X3D_sendEvent(SENDEVENT, myline,__LINE__);
1057 case FIELDTYPE_MFNode:
1059 printf (
"sending in %d nodes\n",node->X3D_MFNode.n);
1062 for (count = 0; count < node->X3D_MFNode.n; count ++) {
1063 sprintf (myline,
"%d %d %s %d\n",
1067 node->X3D_MFNode.p[count].adr);
1069 _X3D_sendEvent (SENDCHILD,myline,__LINE__);
1074 case FIELDTYPE_SFNode:
1075 sprintf (myline,
"%c %d %d %d %d\n",
1076 mapFieldTypeToEAItype(dest->datatype),
1077 dest->nodeptr, dest->offset, dest->scripttype,
1078 node->X3D_SFNode.adr);
1080 _X3D_sendEvent (SENDEVENT,myline,__LINE__);
1090 void X3D_lastViewpoint(){}
1091 void X3D_firstViewpoint(){}
1092 void X3D_previousViewpoint(){}
1093 void X3D_nextViewpoint(){}
1097 char *descrip = NULL;
1099 void X3D_setDescription(
char *newDesc) {
1101 if (descrip != NULL)
1103 descrip = strdup(newDesc);
1106 char *X3D_getDescription() {
1109 if (descrip == NULL) {
1110 descrip = strdup(
"in X3D");
1115 char *X3D_getName() {
1117 ptr = strdup(_X3D_makeShortCommand(GETNAME));
1121 char *X3D_getVersion() {
1123 ptr = strdup(_X3D_makeShortCommand(GETVERSION));
1127 char *X3D_getWorldURL() {
1129 ptr = strdup(_X3D_makeShortCommand(GETURL));
1136 float X3D_getCurrentSpeed() {
1139 ptr = _X3D_makeShortCommand(GETCURSPEED);
1140 if (sscanf(ptr,
"%f",&curspeed) == 0) {
1141 printf (
"client, error - problem reading float from %s\n",ptr);
1148 float X3D_getCurrentFrameRate() {
1151 ptr = _X3D_makeShortCommand(GETFRAMERATE);
1152 if (sscanf(ptr,
"%f",&curframe) == 0) {
1153 printf (
"client, error - problem reading float from %s\n",ptr);
1159 X3DNode *X3D_createVrmlFromString(
char *str) {
1166 retval = malloc (
sizeof(
X3DNode));
1167 retval->X3D_MFNode.type = FIELDTYPE_MFNode;
1168 retval->X3D_MFNode.n = 0;
1171 printf (
"X3D_createVrmlFromString - string %s\n",str);
1174 ptr = _X3D_make2StringCommand(CREATEVS,str,
"\nEOT\n");
1177 printf (
"return pointer is %s\n",ptr);
1181 retvals = _X3D_countWords(ptr);
1184 retval->X3D_MFNode.p = malloc (retvals *
sizeof (
X3DNode));
1185 retval->X3D_MFNode.n = retvals;
1187 for (count = 0; count < retvals; count++) {
1192 sscanf (ptr,
"%d",&mytmp);
1194 retval->X3D_MFNode.p[count].adr = mytmp;
1200 printf (
"X3D_createVrmlFromString, found %d pointers, they are:\n",retval->X3D_MFNode.n);
1201 for (count=0; count<retval->X3D_MFNode.n; count++) {
1202 printf (
" %d\n",(
int) retval->X3D_MFNode.p[count].adr);
1204 printf (
"(end oflist)\n");
1208 X3DNode *X3D_createX3DFromString(
char *str) {
1215 retval = malloc (
sizeof(
X3DNode));
1216 retval->X3D_MFNode.type = FIELDTYPE_MFNode;
1217 retval->X3D_MFNode.n = 0;
1220 printf (
"X3D_createX3DFromString - string %s\n",str);
1223 ptr = _X3D_make2StringCommand(CREATEXS,str,
"\nEOT\n");
1226 printf (
"return pointer is %s\n",ptr);
1231 retvals = _X3D_countWords(ptr);
1234 retval->X3D_MFNode.p = malloc (retvals *
sizeof (
X3DNode));
1235 retval->X3D_MFNode.n = retvals;
1239 for (count = 0; count < retvals; count++) {
1244 sscanf (ptr,
"%d",&mytmp);
1246 retval->X3D_MFNode.p[count].adr = mytmp;
1252 printf (
"X3D_createVrmlFromString, found %d pointers, they are:\n",retval->X3D_MFNode.n);
1253 for (count=0; count<retval->X3D_MFNode.n; count++) {
1254 printf (
" %d\n",(
int) retval->X3D_MFNode.p[count].adr);
1256 printf (
"(end oflist)\n");