From: Mark Gill (Mark.Gill++at++usm.edu)
Date: 01/30/2001 07:29:20
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,
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
----------------------------------------------
This archive was generated by hypermail 2b29 : Tue Jan 30 2001 - 07:30:04 PST