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, 3,
62 COM_PointDeviceSensor, 1,
64 COM_RigidBodyPhysics, 2,
72 COM_KeyDeviceSensor, 2,
75 COM_ParticleSystems, 3,
77 COM_VolumeRendering, 4,
78 COM_ProjectiveTextureMapping, 2,
79 INT_ID_UNDEFINED, INT_ID_UNDEFINED,
85static const int CADInterchangeProfile[] = {
96 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
100static const int CoreProfile[] = {
102 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
106static const int FullProfile[] = {
119 COM_Interpolation, 5,
121 COM_PointDeviceSensor, 1,
122 COM_KeyDeviceSensor, 2,
123 COM_EnvironmentalSensor, 3,
124 COM_EnvironmentalEffects, 4,
130 COM_EventUtilities, 1,
134 COM_CubeMapTexturing, 3,
137 COM_RigidBodyPhysics, 2,
140 COM_ParticleSystems, 3,
141 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
145static const int ImmersiveProfile[] = {
158 COM_Interpolation, 2,
159 COM_PointDeviceSensor, 1,
160 COM_KeyDeviceSensor, 2,
161 COM_EnvironmentalSensor, 2,
162 COM_EnvironmentalEffects, 2,
164 COM_EventUtilities, 1,
165 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
169static const int InteractiveProfile[] = {
179 COM_Interpolation, 2,
181 COM_PointDeviceSensor, 1,
182 COM_KeyDeviceSensor, 1,
183 COM_EnvironmentalSensor, 1,
184 COM_EnvironmentalEffects, 1,
185 COM_EventUtilities, 1,
187 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
191static const int InterchangeProfile[] = {
201 COM_Interpolation, 2,
203 COM_EnvironmentalEffects, 1,
204 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
208static const int MPEG4Profile[] = {
218 COM_Interpolation, 2,
220 COM_PointDeviceSensor, 1,
221 COM_EnvironmentalSensor, 1,
223 COM_EnvironmentalEffects, 1,
224 INT_ID_UNDEFINED, INT_ID_UNDEFINED};
239 const int *profileTable;
244 {PRO_Interchange, InterchangeProfile, 1},
245 {PRO_CADInterchange, CADInterchangeProfile, 1},
246 {PRO_MPEG4, MPEG4Profile, 1},
247 {PRO_Interactive, InteractiveProfile, 1},
248 {PRO_Full, FullProfile, 1},
249 {PRO_Immersive, ImmersiveProfile, 1},
250 {PRO_Core, CoreProfile, 1},
251 {INT_ID_UNDEFINED, (
const int*) INT_ID_UNDEFINED, INT_ID_UNDEFINED}
255void handleVersion(
const char *versionString) {
264 rt = sscanf (versionString,
"%d.%d.%d",&xa, &xb,&xc);
268 inputFileVersion[0] = xa, inputFileVersion[1] = xb; inputFileVersion[2] = xc;
274 #ifdef CAPABILITIESVERBOSE
275 printf (
"handleMetaDataStringString, :%s:, :%s:\n",val1->strptr, val2->strptr);
284void addUnits(
void *ec,
char *category,
char *unit,
double factor);
285void handleUnitDataStringString(
void *ec,
char *categoryname,
char *unitname,
double conversionfactor) {
286 addUnits(ec, categoryname,unitname,conversionfactor);
290void handleProfile (
int myProfile) {
294 #ifdef CAPABILITIESVERBOSE
295 printf (
"handleProfile, my profile is %s (%d)\n",stringProfileType(myProfile), myProfile);
299 while ((profTable[i].profileName != INT_ID_UNDEFINED) && (profTable[i].profileName != myProfile)) i++;
302 if (profTable[i].profileName == INT_ID_UNDEFINED) {
303 ConsoleMessage (
"Something wrong in handleProfile for profile %s\n",
304 stringProfileType(myProfile));
308 gglobal()->Mainloop.scene_profile = i;
309 myTable = (
int *)profTable[i].profileTable;
311 comp = *myTable; myTable++; lev = *myTable; myTable++;
312 while (comp != INT_ID_UNDEFINED) {
313 handleComponent(comp,lev);
314 comp = *myTable; myTable++; lev = *myTable; myTable++;
319int capabilitiesHandler_getComponentLevel(
int *table,
int comp)
321 return table[(comp*2) +1];
323int capabilitiesHandler_getProfileLevel(
int prof)
325 return profTable[prof].level;
327const int *capabilitiesHandler_getProfileComponent(
int prof)
329 return profTable[prof].profileTable;
331const int *capabilitiesHandler_getCapabilitiesTable()
335int capabilitiesHandler_getTableLength(
int* table){
337 if(table == NULL)
return 0;
338 while(table[2*len] != INT_ID_UNDEFINED)
346const int * getCapabilitiesTable(){
350void scene_addComponent(
int myComponent,
int mylevel){
355 int *scene_comps = gglobal()->Mainloop.scene_components;
356 int len = capabilitiesHandler_getTableLength(scene_comps);
357 scene_comps = realloc(scene_comps,
sizeof(
int)*2*(len+2));
358 scene_comps[len*2] = myComponent;
359 scene_comps[len*2 +1] = mylevel;
361 scene_comps[len*2] = INT_ID_UNDEFINED;
362 scene_comps[len*2 +1] = INT_ID_UNDEFINED;
363 gglobal()->Mainloop.scene_components = scene_comps;
365void scene_clearComponents(){
366 FREE_IF_NZ(gglobal()->Mainloop.scene_components);
371void handleComponent (
int myComponent,
int myLevel) {
375 #ifdef CAPABILITIESVERBOSE
376 printf (
"handleComponent: my Component is %s, level %d\n",COMPONENTS[myComponent], myLevel);
380 while ((capabilities[i] != myComponent) && (capabilities[i] != INT_ID_UNDEFINED)) {
385 if (capabilities[i] == myComponent) {
386 scene_addComponent(myComponent,myLevel);
388 #ifdef CAPABILITIESVERBOSE
389 printf (
"handleComponent, comparing requested level %d with supported level %d\n",myLevel, capabilities[i+1]);
392 if (myLevel > capabilities[i+1]) {
393 ConsoleMessage (
"Component %s support level %d, requested %d",
394 COMPONENTS[myComponent], capabilities[i+1], myLevel);
397 ConsoleMessage (
"did not find component %s in capabilities table!",COMPONENTS[myComponent]);