Help with code for picking

New Message Reply Date view Thread view Subject view Author view

From: Hugh Fisher (Hugh.Fisher++at++act.cmis.CSIRO.AU)
Date: 05/03/2000 23:24:25


 OK, I'm stuck.

 Platform is an O2 running IRIX 6.5 with Performer 2.2,
 N32 libs.

 I have a molecular model which I'm displaying as a Performer
 scene graph. About 400 spheres, 1200 line segments showing
 molecular bonds. Now I want to add code that will pick an
 atom by clicking on with the mouse.

 After studying the Getting Started and Programmers Guide
 sections, this is the code I came up with: (using C++)

 Each sphere:

    pfGeode * geom;
    ...
    geom->setTravMask(PFTRAV_ISECT, PFIS_PICK_MASK,
                      PFTRAV_SELF|PFTRAV_DESCEND, PF_OR);

 and after building the entire model:

    pfNodePickSetup(Scene);

 My understanding is that pfNodePickSetup will set the
 pick mask bit on every node anyway, so the first step is
 redundant, but later on I want to only make certain atoms
 pickable.

 And when the mouse is clicked I do this:

    float cx, cy;
    int nHits;
    pfHit ** hits;

    pfuCalcNormalizedChanXY(&cx, &cy, Chan, x, y);
    hits = NULL;
    nHits = Chan->pick(PFPK_M_ALL | PFTRAV_IS_GEODE,
                                  cx, cy, 0.0, &hits);
    printf("Hits = %d\n", nHits);

 When I click outside the bounding sphere for the entire model,
 I get zero hits. Once inside the entire model sphere, the
 number starts slowly rising. When I click on actual atoms, it
 prints out something like "Hits = 32" and then core dumps
 with a segment violation. dbx shows it crashing in a deeply
 nested nb_sect call.

 Setting up a pfSegSet object and calling Scene->isect directly
 gave the same outcome.

 Have I declared the hits array correctly? Should it be an array?

 I'm doing the hit testing from the APP process. Does it have
 to be done in DRAW or something?

 Have I done something so stupid that I can't see it?

 Thanks in advance.

        Hugh Fisher
        ACSYS/CSIRO Virtual Environments Lab


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed May 03 2000 - 23:24:51 PDT

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