34 #include <libFreeWRL.h>
37 #include "../vrml_parser/Structs.h"
38 #include "../main/headers.h"
42 static const int capabilities[] = {
47 COM_EnvironmentalSensor, 3,
50 COM_CubeMapTexturing, 3,
51 COM_EventUtilities, 1,
59 COM_EnvironmentalEffects, 3,
62 COM_PointDeviceSensor, 1,
64 COM_RigidBodyPhysics, 2,
72 COM_KeyDeviceSensor, 2,
75 COM_ParticleSystems, 3,
77 COM_VolumeRendering, 4,
78 INT_ID_UNDEFINED, INT_ID_UNDEFINED,
84 static const int CADInterchangeProfile[] = {
95 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
99 static const int CoreProfile[] = {
101 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
105 static const int FullProfile[] = {
118 COM_Interpolation, 5,
120 COM_PointDeviceSensor, 1,
121 COM_KeyDeviceSensor, 2,
122 COM_EnvironmentalSensor, 3,
123 COM_EnvironmentalEffects, 4,
129 COM_EventUtilities, 1,
133 COM_CubeMapTexturing, 3,
136 COM_RigidBodyPhysics, 2,
139 COM_ParticleSystems, 3,
140 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
144 static const int ImmersiveProfile[] = {
157 COM_Interpolation, 2,
158 COM_PointDeviceSensor, 1,
159 COM_KeyDeviceSensor, 2,
160 COM_EnvironmentalSensor, 2,
161 COM_EnvironmentalEffects, 2,
163 COM_EventUtilities, 1,
164 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
168 static const int InteractiveProfile[] = {
178 COM_Interpolation, 2,
180 COM_PointDeviceSensor, 1,
181 COM_KeyDeviceSensor, 1,
182 COM_EnvironmentalSensor, 1,
183 COM_EnvironmentalEffects, 1,
184 COM_EventUtilities, 1,
186 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
190 static const int InterchangeProfile[] = {
200 COM_Interpolation, 2,
202 COM_EnvironmentalEffects, 1,
203 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
207 static const int MPEG4Profile[] = {
217 COM_Interpolation, 2,
219 COM_PointDeviceSensor, 1,
220 COM_EnvironmentalSensor, 1,
222 COM_EnvironmentalEffects, 1,
223 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
238 const int *profileTable;
243 {PRO_Interchange, InterchangeProfile, 1},
244 {PRO_CADInterchange, CADInterchangeProfile, 1},
245 {PRO_MPEG4, MPEG4Profile, 1},
246 {PRO_Interactive, InteractiveProfile, 1},
247 {PRO_Full, FullProfile, 1},
248 {PRO_Immersive, ImmersiveProfile, 1},
249 {PRO_Core, CoreProfile, 1},
250 {INT_ID_UNDEFINED, (
const int*) INT_ID_UNDEFINED, INT_ID_UNDEFINED}
254 void handleVersion(
const char *versionString) {
263 rt = sscanf (versionString,
"%d.%d.%d",&xa, &xb,&xc);
267 inputFileVersion[0] = xa, inputFileVersion[1] = xb; inputFileVersion[2] = xc;
273 #ifdef CAPABILITIESVERBOSE
274 printf (
"handleMetaDataStringString, :%s:, :%s:\n",val1->strptr, val2->strptr);
283 const char * unitcategories [] = {
295 const char * unitnames [] = {
302 void handleUnitDataStringString(
char *categoryname,
char *unitname,
double conversionfactor) {
306 #ifdef CAPABILITIESVERBOSE
307 printf (
"handleMetaDataStringString, :%s:, :%s:\n",val1->strptr, val2->strptr);
311 void 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++;
340 int capabilitiesHandler_getComponentLevel(
int *table,
int comp)
342 return table[(comp*2) +1];
344 int capabilitiesHandler_getProfileLevel(
int prof)
346 return profTable[prof].level;
348 const int *capabilitiesHandler_getProfileComponent(
int prof)
350 return profTable[prof].profileTable;
352 const int *capabilitiesHandler_getCapabilitiesTable()
356 int capabilitiesHandler_getTableLength(
int* table){
358 if(table == NULL)
return 0;
359 while(table[2*len] != INT_ID_UNDEFINED)
367 const int * getCapabilitiesTable(){
371 void 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;
386 void scene_clearComponents(){
387 FREE_IF_NZ(gglobal()->Mainloop.scene_components);
392 void 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]);