RE: pfGeoSet problems

New Message Reply Date view Thread view Subject view Author view

From: Dorosky, Christopher G (christopher.g.dorosky++at++lmco.com)
Date: 01/31/2001 05:02:15


Mark,

I agree with Mario.

Change norms [1] to norms[2];
Lengths must be pfmalloced
Don't bother with texture

For now, don't bother with normals, and make the color per prim (which will
be one color, if you follow my reccommended example below).

The material helps for lighting, and can produce some color effects, but is
not necessary until you get the rest running. Keep the cullface off for now.

Make sure your group is already in the scene (or is added after the geode is
added)
scene->addChild(group); will work.

Try making your vertices center around the origin. Limit yourself to a
tristrip that folds into a square, and do something like vertices that
stretch from 5 to -5 in each direction. Make sure you can move, since if you
use x&y, it will be an invisible flat plane, unless your eyepoint can tilt.

Also, make sure this routine is called in the app. If it is called from
DBASE, you will have a whole host of problems to deal with. It would be
better to understand how to do it from APP. The gset example is a good one,
under /usr/share/Performer/pguide etc...

Christopher Dorosky
Lead Electronic Systems Engineer - Real Time Simulation
Lockheed Martin Missiles and Fire Control - Dallas
christopher.g.dorosky++at++lmco.com
972-603-2349

-----Original Message-----
From: Mark Gill [mailto:Mark.Gill++at++usm.edu]
Sent: Tuesday, January 30, 2001 9:29 AM
To: Info-Performer++at++Sgi. Com
Subject: pfGeoSet problems

greets,

Once again I bring a problem that has troubled me for a few days, but
hopefully, will be easy for the Performer community to resolve.

What I'm trying to do is read in a 1-d array of {lat / long/ elev} floats
and build a pfGeoSet of TRISTRIPS based on the file. The file has 1.44
million entries of X,Y, and Z values -- so I'm only trying to read in a
small number of them Eventually I want to build an ASD out of this, but I'm
simply trying to get a small portion of the data to display.

The problem that I have is this: The program compiles, the program runs. I
just don't see *anything*. I can read in the point and display PFGS_POINTS,
but I haven't had any luck with any other primitive. I suspect that this is
due to some problem with setting up the pfGeoSet itself. (I'm afraid I
don't have the most experience with geosets. Most of my work here is done
with imported 3d models)

I've gotten past the point to figuring this out. If there's a question
about why I did something the way I did, it's probably because I've reduced
my attempts to randomly changing values, hoping that something will work.

It's my hope that there's something in this file that just leaps out at the
many of the more experienced programmers out there

thanks in advance,

Mark.Gill++at++usm.edu

Here's the code snippet that load the geoset:

/*************************** build the vertices **********************/
static void bld_verts (pfGroup *group)

{
const int grid_size =4; // determines the size per side of the square
data set
pfGeoSet *ngli_gset = new pfGeoSet;
pfGeode *ngli_geode = new pfGeode;

pfGeoState *gst = new pfGeoState;
pfVec3 *verts;
pfVec4 *verts_color;

int lats, longs;
char ngli_file [50];
float dummy_x, dummy_y, dummy_z, end_row;
int vert_count = 0;
end_row=0.0;

        verts = (pfVec3 *) pfMalloc ((grid_size * grid_size) * sizeof
(pfVec3),
pfGetSharedArena());
        verts_color = (pfVec4 *) pfMalloc ((grid_size * grid_size)* sizeof
(pfVec4), pfGetSharedArena());

        strcpy (ngli_file, "/vizoned1/ngli/ngli_bathy_topo_");
        strcat (ngli_file, "8829");
        strcat (ngli_file, ".xyz");

        ifstream infile;

        infile.open (ngli_file);

                if (!infile)
                        {
                        printf ("couldn't open file: %s \n", ngli_file);
                        exit (1);
                        }

        printf ("reading vertices from %s \n",ngli_file);

        infile >> dummy_x >> dummy_y >> dummy_z;

        for (longs= 0; longs < grid_size; longs ++)

                {
                        for (lats= 0; lats < grid_size; lats ++)
                        {

                        verts [vert_count].set (((dummy_x+88)*1000),
((dummy_y-29)*1000),
dummy_z);
                        verts_color [vert_count].set (0.2 0.5, 1.0);

                        printf ("%f %f %f \n", dummy_x, dummy_y, dummy_z);
                        vert_count ++;
                        end_row = dummy_y;
                        infile >> dummy_x >> dummy_y >> dummy_z;
                        }

        /* because the NGLI files are not ordered row/column, read till the
Y
value changes */

                        while (end_row == dummy_y) // read to the end of
the 'row'
                                {
                        infile >> dummy_x >> dummy_y >> dummy_z;

                                }
                        }

        infile.close ();

// build a geoset of tris

pfVec3 *gsVerts;
pfVec3 norms [1];

norms [0].set (0.0, 0.0, 1.0);
norms [1].set (0.0, 0.0, 1.0);

int X,Y,gsv_count; // counting integers

gsVerts = (pfVec3 *) pfMalloc (((grid_size * grid_size)*2) * sizeof
(pfVec3), pfGetSharedArena());

int lengths [grid_size];

gsv_count = 0;

        for (X=0; X< vert_count; X++)
                {

                gsVerts [gsv_count] = verts [X];
                gsv_count++;

                gsVerts [gsv_count] = verts [X + (grid_size)];
                gsv_count++;

        }

        for (Y=0; Y<grid_size; Y++)
                lengths [Y] = (grid_size*2);

pfMaterial *gsMat = new pfMaterial;
pfTexture *tex = new pfTexture; // maybe I need these, maybe I dont?
pfTexEnv *tev = new pfTexEnv;
        pfEnable(PFEN_TEXTURE);

        gsMat->setColor (PFMTL_EMISSION, 1.0, 1.0, 1.0);

ngli_gset -> setGState (gst);
gst -> setMode (PFSTATE_ENLIGHTING, PF_ON);
gst->setMode(PFSTATE_CULLFACE, PFCF_OFF);
gst->setAttr(PFSTATE_TEXENV, tev);
gst->setAttr(PFSTATE_FRONTMTL, gsMat);
gst->setAttr(PFSTATE_BACKMTL, gsMat);

ngli_gset -> setPrimType (PFGS_TRISTRIPS);
ngli_gset -> setNumPrims (grid_size);
ngli_gset -> setPrimLengths (lengths);
ngli_gset -> setAttr (PFGS_COORD3,PFGS_PER_VERTEX, gsVerts, NULL);
ngli_gset -> setAttr (PFGS_NORMAL3,PFGS_OVERALL, norms, NULL);
ngli_gset -> setAttr (PFGS_COLOR4,PFGS_PER_VERTEX, verts_color, NULL);
ngli_geode -> addGSet (ngli_gset);
group -> addChild (ngli_geode);

}

Mark Gill Visualization Researcher
CHL Stennis Space Center
Mark.Gill++at++usm.edu
----------------------------------------------

-----------------------------------------------------------------------
 List Archives, FAQ, FTP: http://www.sgi.com/software/performer/
Open Development Project: http://oss.sgi.com/projects/performer/
             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 2b29 : Wed Jan 31 2001 - 05:02:30 PST

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