A SERVICE OF

logo

74
Chapter 5: Building a Scene Graph
Loading a VRML Scene Graph
Example 5-2 shows a portion of vrml.cxx. The example illustrates how to load a VRML
scene graph using vlDB::readFile().
Example 5-2 Loading a VRML Scene Graph
csGroup *vrml = new csGroup;
for (int i=1; i<argc; i++)
{
csContainer *v;
static char path[512];
char *lastSlash;
strcpy(path, argv[i]);
lastSlash = strrchr(path, /);
if (lastSlash != NULL)
*lastSlash = \0;
strcat(path, :.);
csGlobal::setFilePath(path);
if (vlDB::readFile(argv[i], v, viewPoints) && v != NULL)
{
printf(Read %s was ok\n, argv[i]);
vrml->addChild((csNode*)v);
}
else
printf(Read %s was bad\n, argv[i]);
}
new csWindow(vrml);