[info-performer] Inventor loader problem on IRIX

New Message Reply Date view Thread view Subject view Author view

From: Steve Satterfield (steve++at++nist.gov)
Date: 02/10/2003 08:37:46


I am hoping that someone can give me some help with an Inventor loader problem.

Summary:

   I am developing a new file loader on IRIX 6.5.17m with Performer 2.5. Among
   other things, the loader loads other files. As the other files are loaded,
   the objects they represent are added to a group node and given a unique
   name (ASCII string) which is stored with pfNodeName. Within the loader I
   am writing, these names are later used to find their corresponding node
   using pfLookupNode and create translated instances to the original objects.
   The idea is to save space by referring to existing objects rather then
   re-loading them.

   The loader I am writing works fine on several of the usual Performer file
   formats. But it does not work when I use a very simple Inventor file. In
   that case, the pfLookupNode fails, and the instance is not displayed.

   Does anyone have any suggestions?

A Detailed Description Follows:

   The reason I suspect the Inventor loader is the problem depends on the
   contents of the Inventor file. It seems to only occur when the Inventor
   file is very simple. For example, the following Inventor file exhibits the
   problem.

                #Inventor V2.0 ascii
                Separator {
                 Material {
                   diffuseColor [1 1 1]
                 }
                 Sphere { radius 1.25}
                }

   However, if I add a single line to the file, it works properly. For
   example, the following Inventor file works correctly when indirectly loaded
   by my loader.

                #Inventor V2.0 ascii
                Separator {
                 Material {
                   diffuseColor [1 1 1]
                 }
                 Sphere { radius 1.25}
                 Cube { }
                }

   Both Inventor files work perfectly well using ivview or perfly.

   At the end of this message is the source for a much simplified version of
   my loader. It demonstrates the problem I am having. It is a working loader
   to load a .tiv file. To use it, create a file named something like
   "demo.tiv" which contains a single line of text consisting of the name of
   an Inventor file to load.

   Then use perfly to load demo.tiv. You of course need to set
   PFLD_LIBRARY_PATH to point to libpftiv.so created from the source below.

   The correct operation for the loader is to display two instances of the
   Inventor file.

   If you specify the first Inventor file listed above in the demo.tiv file,
   the pfLookupNode fails and only one object is displayed.

   If you use the second Inventor file listed above, the loader works
   perfectly and two objects are displayed.

Thank you in advance for any help you can provide.

-Steve

/*
 * pftiv.c - contrive an example ".tiv" loader to test my problem
 * with indirect loading of Inventor files.
 *
 * Steve Satterfield <steve++at++nist.gov>
 * February 10, 2003
 *
 * The .tiv file contains the name of an Inventor file to load.
 * The loader will load it and add a second reference translated
 * a short distance.
 */

#include <Performer/pfdu.h>

#define VERSION "2/10/2003"

extern pfNode *
pfdLoadFile_tiv (char *filename)
{
    float tx=10.0, ty=0.0, tz=0.0;
    FILE *fp;
    char objfilename[80], *objname="ivobjname";

    pfGroup *group;
    pfSCS *trans_scs;
    pfNode *object;
    pfMatrix m;

    fp = fopen(filename, "r");
    group=pfNewGroup();

    /* Read file name from the input file */
    if (fscanf(fp, "%s",objfilename) == EOF) {
         pfNotify(PFNFY_NOTICE, PFNFY_PRINT,
              " pfdLoadFile_tiv: Warning file '%s' not found", objfilename);
         return((pfNode*)NULL);
    }
    if (!pfdInitConverter(objfilename)) {
         pfNotify(PFNFY_NOTICE, PFNFY_PRINT,
              " pfdLoadFile_tiv: Warning loader for '%s' not found", objfilename);
         return((pfNode*)NULL);
    }

    /* Load and add the initial object to the group */
    object = pfdLoadFile(objfilename);
    pfAddChild(group, object);

    /* Store a name for the object */
    fprintf(stderr,"Set objectname to '%s' \n",objname);
    if (pfNodeName(object, objname) == 0) {
      pfNotify(PFNFY_NOTICE, PFNFY_PRINT,
        " pfdLoadFile_tiv: Warning objectname '%s' is not unique", objname);
    }
    fprintf(stderr,"Stored object name is '%s'\n", pfGetNodeName(object));

    /* Find the object based on its stored name */
    fprintf(stderr,"Look up name '%s'\n",objname);
    object = (pfNode*) pfLookupNode(objname, pfGetNodeClassType());
    if (object == NULL) {
      pfNotify(PFNFY_NOTICE, PFNFY_PRINT,
         " pfdLoadFile_tiv: Warning objectname '%s' not found", objname);
    }
    fprintf(stderr,"Stored node name = '%s'\n", pfGetNodeName(object));

    /* Create a translated instance and add that to the group */
    fprintf(stderr,"Add instance translated by %g %g %g\n",tx,ty,tz);
    pfMakeTransMat(m, tx,ty,tz);
    trans_scs=pfNewSCS(m);

    pfAddChild(trans_scs, object);
    pfAddChild(group, trans_scs);

    fclose(fp);
    pfNotify(PFNFY_NOTICE, PFNFY_PRINT,
             " pfdLoadFile_tiv (%s): %s completed",VERSION,filename);
    return((pfNode*)group);

}

#!smake
#-------------------------------------------------------------------------#
#-- Makefile for libpftiv --#
#-------------------------------------------------------------------------#

OBJECT_STYLE=N32

PFROOT ?= $(ROOT)
include $(PFROOT)/usr/share/Performer/src/pfmakedefs

#-- base name of library
LIBRARY = libpftiv

CFILES = \
        pftiv.c

include $(PFROOT)/usr/share/Performer/src/pfmakerules


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Feb 10 2003 - 08:40:36 PST

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.