FreeWRL / FreeX3D 4.3.0
EAI_swigMe.h
1
2/****************************************************************************
3 This file is part of the FreeWRL/FreeX3D Distribution.
4
5 Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
6
7 FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 FreeWRL/FreeX3D is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
19****************************************************************************/
20
21
22#ifndef __X3D_NODE_HEADERS__
23#define __X3D_NODE_HEADERS__
24/*EAIswigMe.h - for swigging */
25/* garbage collection - in your script call X3D_freeNode(X3DNode*) for anything that returns an X3DNode* to your script. */
26/* most of this is a copy from X3DNode.h - could be refactored to elliminate duplication
27 Except swig specifics - see bottom for SWIG-specific swig-venience function prototypes
28 (see EAI_swigExtras.c for implementation) */
29/* Node section */
30#ifdef SWIG
31typedef struct { int type; int value; } _intX3D_SFBool;
32typedef struct { int type; float value; } _intX3D_SFFloat;
33typedef struct { int type; double value; } _intX3D_SFTime;
34typedef struct { int type; int value; } _intX3D_SFInt32;
35typedef struct { int type; int adr; } _intX3D_SFNode;
36typedef struct { int type; float r[4]; } _intX3D_SFRotation;
37typedef struct { int type; float c[2]; } _intX3D_SFVec2f;
38typedef struct { int type; double c[2]; } _intX3D_SFVec2d;
39typedef struct { int type; float c[3]; } _intX3D_SFColor;
40typedef struct { int type; float c[3]; } _intX3D_SFVec3f;
41typedef struct { int type; double c[3]; } _intX3D_SFVec3d;
42typedef struct { int type; float r[4]; } _intX3D_SFColorRGBA;
43typedef struct { int type; int len; char *strptr;} _intX3D_SFString;
44typedef struct { int type; int len; char *strptr;} _intX3D_SFImage;
45
46typedef struct { int type; int n; _intX3D_SFColor *p; } _intX3D_MFColor;
47typedef struct { int type; int n; _intX3D_SFColorRGBA *p; } _intX3D_MFColorRGBA;
48typedef struct { int type; int n; _intX3D_SFFloat *p; } _intX3D_MFFloat;
49typedef struct { int type; int n; _intX3D_SFTime *p; } _intX3D_MFTime;
50typedef struct { int type; int n; _intX3D_SFRotation *p; } _intX3D_MFRotation;
51typedef struct { int type; int n; _intX3D_SFVec3d *p; } _intX3D_MFVec3d;
52typedef struct { int type; int n; _intX3D_SFVec2d *p; } _intX3D_MFVec2d;
53typedef struct { int type; int n; _intX3D_SFVec3f *p; } _intX3D_MFVec3f;
54typedef struct { int type; int n; _intX3D_SFVec2f *p; } _intX3D_MFVec2f;
55typedef struct { int type; int n; _intX3D_SFBool *p; } _intX3D_MFBool;
56typedef struct { int type; int n; _intX3D_SFInt32 *p; } _intX3D_MFInt32;
57typedef struct { int type; int n; _intX3D_SFNode *p; } _intX3D_MFNode;
58typedef struct { int type; int n; _intX3D_SFString *p; } _intX3D_MFString;
59typedef struct { int type; int n; _intX3D_SFImage *p; } _intX3D_MFImage;
60
61
62typedef union _X3DNode {
63 int type;
64 _intX3D_MFBool X3D_MFBool;
65 _intX3D_SFBool X3D_SFBool;
66 _intX3D_SFFloat X3D_SFFloat;
67 _intX3D_SFTime X3D_SFTime;
68 _intX3D_SFInt32 X3D_SFInt32;
69 _intX3D_MFColor X3D_MFColor;
70 _intX3D_MFColorRGBA X3D_MFColorRGBA;
71 _intX3D_SFString X3D_SFString;
72 _intX3D_SFNode X3D_SFNode;
73 _intX3D_SFRotation X3D_SFRotation;
74 _intX3D_SFVec2f X3D_SFVec2f;
75 _intX3D_SFVec2d X3D_SFVec2d;
76 _intX3D_SFColor X3D_SFColor;
77 _intX3D_SFColor X3D_SFVec3f;
78 _intX3D_SFVec3d X3D_SFVec3d;
79 _intX3D_SFColorRGBA X3D_SFColorRGBA;
80 _intX3D_MFFloat X3D_MFFloat;
81 _intX3D_MFTime X3D_MFTime;
82 _intX3D_MFInt32 X3D_MFInt32;
83 _intX3D_MFString X3D_MFString;
84 _intX3D_MFNode X3D_MFNode;
85 _intX3D_MFRotation X3D_MFRotation;
86 _intX3D_MFVec2f X3D_MFVec2f;
87 _intX3D_MFVec3f X3D_MFVec3f;
88 _intX3D_MFImage X3D_MFImage;
89 _intX3D_MFVec3d X3D_MFVec3d;
90} X3DNode;
91
92/* field section */
93X3DNode *X3D_newSFVec3f (float a, float b, float c);
94X3DNode *X3D_newSFColor (float a, float b, float c);
95X3DNode *X3D_newSFVec2f (float a, float b);
96X3DNode *X3D_newSFRotation (float a, float b,float c, float d);
97X3DNode *X3D_newSFColorRGBA (float a, float b,float c, float d);
98X3DNode *X3D_newSFVec3d (double a, double b,double c);
99X3DNode *X3D_newSFVec2d (double a, double b);
100X3DNode *X3D_newSFBool (int a);
101X3DNode *X3D_newSFFloat (float a);
102X3DNode *X3D_newSFTime (double a);
103X3DNode *X3D_newSFInt32 (int a);
104X3DNode *X3D_newSFString(char* string); /*()*/
105X3DNode *X3D_newSFNode(); /*not implemented yet*/
106X3DNode *X3D_newSFImage(); /*not implemented yet*/
107
108/* these prototypes dont match the .c - use X3D_newMF plus: setItem and/or appendToMF*.
109X3DNode *X3D_newMFColor();
110X3DNode *X3D_newMFFloat();
111X3DNode *X3D_newMFTime();
112X3DNode *X3D_newMFInt32();
113X3DNode *X3D_newMFString();
114X3DNode *X3D_newMFNode();
115X3DNode *X3D_newMFRotation();
116X3DNode *X3D_newMFVec2f();
117X3DNode *X3D_newMFVec3f();
118X3DNode *X3D_newMFColorRGBA();
119X3DNode *X3D_newMFBool();
120X3DNode *X3D_newMFVec3d();
121X3DNode *X3D_newMFVec2d();
122*/
123
124
125/* browser section */
126struct _intX3DEventIn {
127 int nodeptr;
128 int offset;
129 int datatype;
130 int datasize;
131 int scripttype;
132 char *field;
133};
134
135#define X3DEventIn struct _intX3DEventIn
136#define X3DEventOut struct _intX3DEventIn
137void X3D_freeEventIn(X3DEventIn* ev);
138void X3D_freeEventOut(X3DEventOut* ev);
139/* single value structures */
140
141X3DNode *X3D_getNode (char *name);
142X3DEventIn *X3D_getEventIn(X3DNode *node, char *name);
143X3DEventOut *X3D_getEventOut(X3DNode *node, char *name);
144X3DNode* X3D_getValue (X3DEventOut *src);
145void X3D_freeNode(X3DNode* node);
146
147void X3D_setValue (X3DEventIn *dest, X3DNode *node);
148void X3D_addRoute (X3DEventOut *from, X3DEventIn *to);
149void X3D_deleteRoute (X3DEventOut *from, X3DEventIn *to);
150
151/* initialize, shutdown public methods */
152void X3D_initialize(char *);
153void X3D_shutdown();
154
155/* float public methods */
156float X3D_getCurrentSpeed();
157float X3D_getCurrentFrameRate();
158
159/* null public methods */
160void X3D_firstViewpoint();
161void X3D_lastViewpoint();
162void X3D_nextViewpoint();
163void X3D_previousViewpoint();
164void X3D_setDescription(char *newDescription);
165
166/* string return val public methods */
167char *X3D_getDescription();
168char *X3D_getName();
169char *X3D_getVersion();
170char *X3D_getWorldURL();
171
172/* MFNode public methods */
173X3DNode *X3D_createVrmlFromString(char *str);
174
175void X3D_error(char *msg);
176int X3DAdvise(X3DEventOut *node, void *fn);
177
178
179/* findField.. not swig specific, but needed as helper by swig-venience functions */
180int findFieldInFIELDTYPES(char *fieldtype);
181
182/* SWIG-SPECIFIC */
183void *freewrlSwigThread(void*);
184
185
186
187/* SWIG does scalars well including char* but not C arrays which appear as opaque binary blobs.
188The following 'swig-venience' functions elliminate the need for passing C arrays by providing getters and setters*/
189
190/*the first 2 swig-venience functions should be minimally sufficient
191but require parsing code to interpret the stringFromField on the script side*/
192X3DNode* X3D_swigFieldFromString(char* fieldtype, char* values);
193char * X3D_swigStringFromField(X3DNode* field);
194
195/* the following 4 would also be sufficient (but do not confuse with any "live" field functions in the main libeai) */
196X3DNode *X3D_swigNewMF(char *fieldtype, int num );
197void X3D_swigAppendToMF(X3DNode* mfnode, X3DNode* sfitem);
198void X3D_swigSetItem(X3DNode* node, int item, X3DNode* value);
199X3DNode* X3D_swigGetItem(X3DNode* node, int item);
200
201/* the following is what you call right after a port style Advise notification, to get the field data */
202X3DNode* X3D_swigCallbackDataFetch(char *ListenerTableIndex);
203
204#endif //SWIG
205
206#endif //__X3D_NODE_HEADERS__