Re: HELP: Problem with pfuPath

New Message Reply Date view Thread view Subject view Author view

Rob Jenkins (robj++at++barney.reading.sgi.com)
Mon, 1 Jul 1996 08:37:49 +0100


On Jun 30, 7:57pm, Nuno Godinho wrote:
> Subject: HELP: Problem with pfuPath
> I just can't seem to make pfuPath work correctly.
>
> WHen I load ONE path from a file to make my dolphin go around in circles
> everything works ok.
>
> If I load another path to make my duck swim I start getting problems:
> If we load the duck prior to the dolphin everything is ok. Switching
> their order... the trajectories tend to go wild (in reverse order... or
> some other strange behaviours).
>
> pfuPrintPath simply crashes my application.
>
> Is there any problem with pfuPath that I'm not aware of?
>
> thanks
> Oceanario Virtual
> =======================================================================
> List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/ <--new!
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com
>-- End of excerpt from Nuno Godinho

Michael Jones posted a good discussion and example of pfuPath a while back:

From: "Michael Jones" <mtj++at++babar>
Message-Id: <9405311811.ZM20736++at++babar.asd.sgi.com>
Date: Tue, 31 May 1994 18:11:08 -0700
In-Reply-To: "Drew Hess" <dhess++at++vision.arc.nasa.gov>
        "pfuPath routines" (May 31, 5:20pm)
References: <9405311720.ZM4168++at++airy.arc.nasa.gov>
X-Mailer: Z-Mail (3.1.0 22feb94 MediaMail)
To: "Drew Hess" <dhess++at++vision.arc.nasa.gov>, info-performer++at++sgi.sgi.com
Subject: Re: pfuPath routines
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Status: O

On May 31, 5:20pm, Drew Hess wrote:
> Subject: pfuPath routines

:I am looking for documentation or (preferably) some example code that details
:the use of the pfuPath routines in libpfu.

man pfupath is the first source. The idea is that a path is a list of
segments,
each of which is either a vector or an arc. The handy thing is that if you set
a radius of curvature, the path routines will make an arc for you that joins
the two vectors. This is how the truck is sent about the performer town demo.

:I realize that libpfu is
:unsupported and subject to change in future releases, but I am hoping that
:someone out there has made good use of these routines. I've started by
looking
:at the path.c source for libpfu, but some actual examples of its use would be
:helpful.

If you develop improvements for the path logic send it to us and we'll include
it in future releases of IRIS Performer.

Here are the path-related excerpts from the "IRIS Performer Town" demo that's
in buttonfly in the demos account. That demo uses a version of perfly that
takes names of models and their paths from the command line (via the "A"
keyword) and maintains a list of vehicles based on this information. Once the
argument list has been processed, a trip is made through the list to load each
model with a pfDCS node above it and to load its path definition as well.
Finally, each model is advanced along the path by one time step in the main
simulation loop. Here are the code fragments:

==================================================================
= handy structure definition used later in code
==================================================================

/* autopilot vehicle support */
typedef struct
{
    char modelName[PF_MAXSTRING];
    char pathName[PF_MAXSTRING];
    char vehicleName[PF_MAXSTRING];
    pfDCS *dcs;
    pfuPath *path;
    pfVec3 xyz;
    pfVec3 hpr;
} Vehicle;

#define MAX_VEHICLES 32
Vehicle vehicle[MAX_VEHICLES] = {"", "", "", NULL, NULL, {0,0,0}, {0,0,0}};
long vehicles = 0;

==================================================================
= parse vehicle definitions: remember vehicles and paths
==================================================================

    /* process command-line arguments */
    while ((opt = getopt(argc, argv, OptionStr)) != -1)
    {
        /* specify "autopilot" vehicle */
        case 'A':
            {
            if (vehicles < MAX_VEHICLES)
            {
                /* initialize vehicle defininition */
                vehicle[vehicles].modelName[0] = '\0';
                vehicle[vehicles].pathName[0] = '\0';
                sprintf(vehicle[vehicles].vehicleName, "%d", vehicles);
                vehicle[vehicles].dcs = NULL;
                vehicle[vehicles].path = NULL;

                /* parse file names from argument */
                sscanf(optarg, "%[^,],%[^,],%s",
                    vehicle[vehicles].modelName,
                    vehicle[vehicles].pathName,
                    vehicle[vehicles].vehicleName);

                /* increment vehicle count */
                vehicles++;
            }
            else
                pfNotify(PFNFY_INFO, PFNFY_PRINT,
                    "Too many autopilot vehicles");
            }
            break;

==================================================================
= pass through vehicle list: loading vehicles and paths
==================================================================

    /* load each of the autopilot vehicles */
    for (i = 0; i < vehicles; i++)
    {
        long j;

        /* has file already been loaded ? */
        for (j = 0, root = NULL; j < i && root == NULL; j++)
            if (strcmp(vehicle[i].modelName, vehicle[j].modelName) == 0)
                root = pfGetChild(vehicle[j].dcs, 0);

        /* load named file */
        if (root == NULL)
            root = LoadFile(vehicle[i].modelName, NULL);
        Loaded = 0;

        /* create new vehicle and attach model to it */
        if (root != NULL)
        {
            /* load database */
            vehicle[i].dcs = pfNewDCS();
            pfAddChild(vehicle[i].dcs, root);
            pfAddChild(scene, vehicle[i].dcs);

            /* load path */
            vehicle[i].path = pfuNewPath();
            pfuAddFile(vehicle[i].path, vehicle[i].pathName);
        }
    }

==================================================================
= advance each vehicle during each trip through the simulation
==================================================================

        /* simulate each autopilot vehicle */
        for (i = 0; i < vehicles; i++)
            if (vehicle[i].dcs != NULL && vehicle[i].path != NULL)
            {
                /* advance along path */
                pfuFollowPath(vehicle[i].path,
                    1.0/pfGetFrameRate(),
                    vehicle[i].xyz,
                    vehicle[i].hpr);

                /* update vehicle DCS */
                pfDCSRot(vehicle[i].dcs,
                    vehicle[i].hpr[PF_H],
                    vehicle[i].hpr[PF_P],
                    vehicle[i].hpr[PF_R]);
                pfDCSTrans(vehicle[i].dcs,
                    vehicle[i].xyz[PF_X],
                    vehicle[i].xyz[PF_Y],
                    vehicle[i].xyz[PF_Z]);
            }

------------------------------------

Hope this helps
Cheers
Rob

-- 
________________________________________________________________
Rob Jenkins, Software Support Group, Silicon Graphics UK Ltd.       
Forum 1, Station Road, Theale, Reading, UK, RG7 4SB. 
tel 01734 257736, fax 01734 257553, email robj++at++reading.sgi.com,

======================================================================= List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/ <--new! Submissions: info-performer++at++sgi.com Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:53:07 PDT

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