34#include <libFreeWRL.h>
37#include "../vrml_parser/Structs.h"
38#include "../main/headers.h"
42static const int capabilities[] = {
47 COM_EnvironmentalSensor, 3,
50 COM_CubeMapTexturing, 3,
51 COM_EventUtilities, 1,
59 COM_EnvironmentalEffects, 4,
62 COM_PointDeviceSensor, 1,
64 COM_RigidBodyPhysics, 2,
72 COM_KeyDeviceSensor, 2,
75 COM_ParticleSystems, 3,
77 COM_VolumeRendering, 4,
78 COM_TextureProjection, 2,
80 INT_ID_UNDEFINED, INT_ID_UNDEFINED,
86static const int CADInterchangeProfile[] = {
98 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
102static const int CoreProfile[] = {
104 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
108static const int FullProfile[] = {
121 COM_Interpolation, 5,
123 COM_PointDeviceSensor, 1,
124 COM_KeyDeviceSensor, 2,
125 COM_EnvironmentalSensor, 3,
126 COM_EnvironmentalEffects, 4,
132 COM_EventUtilities, 1,
136 COM_CubeMapTexturing, 3,
139 COM_RigidBodyPhysics, 2,
142 COM_ParticleSystems, 3,
143 COM_TextureProjection, 2,
145 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
149static const int ImmersiveProfile[] = {
162 COM_Interpolation, 2,
163 COM_PointDeviceSensor, 1,
164 COM_KeyDeviceSensor, 2,
165 COM_EnvironmentalSensor, 2,
166 COM_EnvironmentalEffects, 2,
168 COM_EventUtilities, 1,
169 COM_ParticleSystems, 3,
170 COM_TextureProjection, 2,
172 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
176static const int InteractiveProfile[] = {
186 COM_Interpolation, 2,
188 COM_PointDeviceSensor, 1,
189 COM_KeyDeviceSensor, 1,
190 COM_EnvironmentalSensor, 1,
191 COM_EnvironmentalEffects, 1,
192 COM_EventUtilities, 1,
193 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
197static const int InterchangeProfile[] = {
207 COM_Interpolation, 2,
209 COM_EnvironmentalEffects, 1,
210 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
214static const int MPEG4Profile[] = {
224 COM_Interpolation, 2,
226 COM_PointDeviceSensor, 1,
227 COM_EnvironmentalSensor, 1,
229 COM_EnvironmentalEffects, 1,
230 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
245 const int *profileTable;
250 {PRO_Interchange, InterchangeProfile, 1},
251 {PRO_CADInterchange, CADInterchangeProfile, 1},
252 {PRO_MPEG4, MPEG4Profile, 1},
253 {PRO_Interactive, InteractiveProfile, 1},
254 {PRO_Full, FullProfile, 1},
255 {PRO_Immersive, ImmersiveProfile, 1},
256 {PRO_Core, CoreProfile, 1},
257 {INT_ID_UNDEFINED, (
const int*) INT_ID_UNDEFINED, INT_ID_UNDEFINED}
261void handleVersion(
const char *versionString) {
270 rt = sscanf (versionString,
"%d.%d.%d",&xa, &xb,&xc);
274 inputFileVersion[0] = xa, inputFileVersion[1] = xb; inputFileVersion[2] = xc;
279void handleMetaDataStringString(
void *ectx,
char *name,
char *content) {
280 #ifdef CAPABILITIESVERBOSE
281 printf (
"handleMetaDataStringString, :%s:, :%s:\n",val1->strptr, val2->strptr);
284 int nodetype = X3D_NODE(ectx)->_nodeType;
285 if (nodetype == NODE_Proto || nodetype == NODE_Inline) {
289 ec->__META = newVector(
struct metarecord, 10);
293 mr.name = strdup(name);
294 mr.content = strdup(content);
295 vector_pushBack(
struct metarecord, metalist, mr);
305void addUnits(
void *ec,
char *category,
char *unit,
double factor);
306void handleUnitDataStringString(
void *ec,
char *categoryname,
char *unitname,
double conversionfactor) {
307 addUnits(ec, categoryname,unitname,conversionfactor);
311void handleProfile (
int myProfile) {
315 #ifdef CAPABILITIESVERBOSE
316 printf (
"handleProfile, my profile is %s (%d)\n",stringProfileType(myProfile), myProfile);
320 while ((profTable[i].profileName != INT_ID_UNDEFINED) && (profTable[i].profileName != myProfile)) i++;
323 if (profTable[i].profileName == INT_ID_UNDEFINED) {
324 ConsoleMessage (
"Something wrong in handleProfile for profile %s\n",
325 stringProfileType(myProfile));
329 gglobal()->Mainloop.scene_profile = i;
330 myTable = (
int *)profTable[i].profileTable;
332 comp = *myTable; myTable++; lev = *myTable; myTable++;
333 while (comp != INT_ID_UNDEFINED) {
334 handleComponent(comp,lev);
335 comp = *myTable; myTable++; lev = *myTable; myTable++;
340int capabilitiesHandler_getComponentLevel(
int *table,
int comp)
342 return table[(comp*2) +1];
344int capabilitiesHandler_getProfileLevel(
int prof)
346 return profTable[prof].level;
348const int *capabilitiesHandler_getProfileComponent(
int prof)
350 return profTable[prof].profileTable;
352const int *capabilitiesHandler_getCapabilitiesTable()
356int capabilitiesHandler_getTableLength(
int* table){
358 if(table == NULL)
return 0;
359 while(table[2*len] != INT_ID_UNDEFINED)
367const int * getCapabilitiesTable(){
371void scene_addComponent(
int myComponent,
int mylevel){
376 int *scene_comps = gglobal()->Mainloop.scene_components;
377 int len = capabilitiesHandler_getTableLength(scene_comps);
378 scene_comps = realloc(scene_comps,
sizeof(
int)*2*(len+2));
379 scene_comps[len*2] = myComponent;
380 scene_comps[len*2 +1] = mylevel;
382 scene_comps[len*2] = INT_ID_UNDEFINED;
383 scene_comps[len*2 +1] = INT_ID_UNDEFINED;
384 gglobal()->Mainloop.scene_components = scene_comps;
386void scene_clearComponents(){
387 FREE_IF_NZ(gglobal()->Mainloop.scene_components);
392void handleComponent (
int myComponent,
int myLevel) {
396 #ifdef CAPABILITIESVERBOSE
397 printf (
"handleComponent: my Component is %s, level %d\n",COMPONENTS[myComponent], myLevel);
401 while ((capabilities[i] != myComponent) && (capabilities[i] != INT_ID_UNDEFINED)) {
406 if (capabilities[i] == myComponent) {
407 scene_addComponent(myComponent,myLevel);
409 #ifdef CAPABILITIESVERBOSE
410 printf (
"handleComponent, comparing requested level %d with supported level %d\n",myLevel, capabilities[i+1]);
413 if (myLevel > capabilities[i+1]) {
414 ConsoleMessage (
"Component %s support level %d, requested %d",
415 COMPONENTS[myComponent], capabilities[i+1], myLevel);
418 ConsoleMessage (
"did not find component %s in capabilities table!",COMPONENTS[myComponent]);