From: Dorosky, Christopher G (christopher.g.dorosky++at++lmco.com)
Date: 07/02/2002 06:18:05
Rob, a few things.
Your primitive type is PFGS_TRIS, when you probably wanted tstrips.
I forget what the enumeration is, but its in the man page. Maybe
PFGS_TRISTRIPS.
To add texture, use PFGS_TEXCOORD2. You need to create a pfTexture, and
reference it in the geoset's pfGeoState.
PUt your multiprocessing mode to APPCULLDRAW for now, to eliminate any
confusion with this. It probably won't help, but you never know.
To repeat the texture, look at the clamp vs repeat mode on wrapping, in the
pfTexture man page.
As to why the updates aren't there, I'm not sure. Is ANYTHING being drawn at
that point, or does the mesh disappear?
You should be able to do this, so there is probably something wrong that
isn't obvious now.
Chris Dorosky
Lockheed Martin, TOPSCENE
-----Original Message-----
From: Rob Body [mailto:rdb++at++hrwallingford.co.uk]
Sent: Tuesday, July 02, 2002 3:30 AM
To: info-performer++at++sgi.com
Subject: [info-performer] Modifying a triangle mesh at run time
Hi Performers,
I have created a triangle mesh using Performer 2.5 and RedHat Linux 7.2 but
don't know how to add a texture to it or modify the vertex's at run time. I
have calculated the new height's of each vertex and modified
vtx_table[i][PF_Z] at run time but the new values aren't drawn.
Code to create the triangles
/*--------------------------------------------------------------------------
*/
DS_create_test_tris(pfScene *scene)
{
pfGroup *group;
pfGeode *geode;
pfGeoSet *gset = NULL;
pfGeoState *gstate = NULL;
void *arena = pfGetSharedArena();
int p;
int num_vtx;
int num_triangles;
int num_indices;
int *lengths;
pfVec3 *vtx_table;
ushort *index_table;
int num_col;
pfVec4 *colour;
ushort *col_index;
col_index = (ushort*) pfMalloc(sizeof(ushort) * 1, arena);
group = pfNewGroup();
geode = pfNewGeode();
gset = pfNewGSet(arena);
pfAddChild( scene, group);
pfAddChild(group, geode);
pfAddGSet(geode, gset);
num_vtx = 4; /* EXAMPLE */
/* Allocate memory for vertices in shared memory */
vtx_table = (pfVec3*) pfMalloc(sizeof(pfVec3) * num_vtx, arena);
vtx_table[0][PF_X] = 50.0;
vtx_table[0][PF_Y] = 50.0;
vtx_table[0][PF_Z] = 2.0;
vtx_table[1][PF_X] = 75.0;
vtx_table[1][PF_Y] = 50.0;
vtx_table[1][PF_Z] = 2.0;
vtx_table[2][PF_X] = 50.0;
vtx_table[2][PF_Y] = 75.0;
vtx_table[2][PF_Z] = 2.0;
vtx_table[3][PF_X] = 75.0;
vtx_table[3][PF_Y] = 75.0;
vtx_table[3][PF_Z] = 2.0;
num_triangles = 2;
num_indices = 3 * num_triangles;
index_table = (ushort*) pfMalloc(sizeof(ushort) * num_indices, arena);
/* For independent triangles */
index_table[0] = 0; /* Indexing starts at 0 */
index_table[1] = 1;
index_table[2] = 2;
index_table[3] = 2;
index_table[4] = 1;
index_table[5] = 3;
/* Set up the vertex info of the geoset */
pfGSetAttr(gset, PFGS_COORD3, PFGS_PER_VERTEX, vtx_table, index_table);
pfGSetPrimType(gset, PFGS_TRIS);
pfGSetNumPrims(gset, num_triangles); /* Number of triangles (our
primitive type) */
/* COLOUR */
/* ------ */
/* Use the same colour for all triangles */
num_col = 1;
colour = (pfVec4*) pfMalloc(sizeof(pfVec4) * num_col, arena);
colour[0][0] = 1.0;
colour[0][1] = 0.0;
colour[0][2] = 1.0;
colour[0][3] = 1.0;
/* Even though only 1 colour is used,
need a colour index table, since cannot mix indexed and non-indexed
data on a geoset */
col_index = (ushort*) pfMalloc(sizeof(ushort) * 1, arena);
col_index[0] = 0;
pfGSetAttr (gset, PFGS_COLOR4, PFGS_OVERALL, colour, col_index);
}
/*--------------------------------------------------------------------------
*/
In my loop I update the z values like this:
for (i = 0;i <= 16385;i++)
{
vtx_table[i][PF_Z] = rz[timecount][i];
}
Can anyone see what I have missed out and advise on how I add a texture to
the triangles. I would like to use one texture, repeated over the whole
triangular surface.
Thanks for any help.
Rob
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Rob Body
Simulator Manager
HR Mardyn
HR Wallingford
Howbery Park
Wallingford
Oxon
OX10 8BA
Tel +44 (0) 1491 822327
Fax +44 (0) 1491 832233
E-mail r.body++at++hrwallingford.co.uk <mailto:r.body++at++hrwallingford.co.uk>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
HR Wallingford uses Faxes and Emails for confidential and
legally privileged business communications. They do not of
themselves create legal commitments. Disclosure to parties
other than addressees requires our specific consent. We are
not liable for unauthorised disclosures nor reliance upon
them. If you have received this message in error please
advise us immediately and destroy all copies of it.
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
This archive was generated by hypermail 2b29 : Tue Jul 02 2002 - 06:18:50 PDT