From: Angus Dorbie (dorbie++at++sgi.com)
Date: 12/06/2000 11:02:26
Could you post your intersection code?
Cheers,Angus.
Yigang Wang wrote:
>
> Hello,
> If you like, i hope you to see the program
> /usr/share/Performer/src/pguide/libpf/C++/intersect.C. The pfGeoSet is
> a Cube-similar object, which is made by 6 QUAD faces. I change the
> representation of each face with strips , so i have 6 strips instead
> of a single strip, and length of each strip is 4. In the original case
> ( not changed by me), the parameters corresponding to PFQHIT_PRIM and
> PFQHIT_TRI changed correctly, that is, prim_index changed with
> intersection points. However, it doesn't change after my changing.
>
> Here is what i have made change to the pfGeoSet.
>
> Original,
>
> pfVec3 *verts = (pfVec3*) new(8*sizeof(pfVec3)) pfMemory;
> verts[0].set(-1.0f, -1.0f, 1.0f);
> verts[1].set( 1.0f, -1.0f, 1.0f);
> verts[2].set( 1.0f, 1.0f, 1.0f);
> verts[3].set(-1.0f, 1.0f, 1.0f);
> verts[4].set(-2.0f, -2.0f, 0.0f);
> verts[5].set( 2.0f, -2.0f, 0.0f);
> verts[6].set( 2.0f, 2.0f, 0.0f);
> verts[7].set(-2.0f, 2.0f, 0.0f);
>
> ushort *vindex = (ushort*) new(24*sizeof(ushort)) pfMemory;
> vindex[0] = 0; vindex[1] = 1; vindex[2] = 2; vindex[3] = 3; //
> front
> vindex[4] = 0; vindex[5] = 3; vindex[6] = 7; vindex[7] = 4; //
> left
> vindex[8] = 4; vindex[9] = 7; vindex[10] = 6; vindex[11] = 5; //
> back
> vindex[12] = 1; vindex[13] = 5; vindex[14] = 6; vindex[15] = 2; //
> right
> vindex[16] = 3; vindex[17] = 2; vindex[18] = 6; vindex[19] = 7; //
> top
> vindex[20] = 0; vindex[21] = 4; vindex[22] = 5; vindex[23] = 1; //
> bottom
>
> pfVec4 *colors = (pfVec4*) new(4*sizeof(pfVec4)) pfMemory;
> colors[0].set(1.0f, 0.0f, 0.0f, 0.5f);
> colors[1].set(0.0f, 1.0f, 0.0f, 0.5f);
> colors[2].set(0.0f, 0.0f, 1.0f, 0.5f);
> colors[3].set(1.0f, 1.0f, 1.0f, 0.5f);
>
> ushort *cindex = (ushort*) new(24*sizeof(ushort)) pfMemory;
> cindex[0] = 0; cindex[1] = 1; cindex[2] = 2; cindex[3] = 3;
> cindex[4] = 0; cindex[5] = 1; cindex[6] = 2; cindex[7] = 3;
> cindex[8] = 0; cindex[9] = 1; cindex[10] = 2; cindex[11] = 3;
> cindex[12] = 0; cindex[13] = 1; cindex[14] = 2; cindex[15] = 3;
> cindex[16] = 0; cindex[17] = 1; cindex[18] = 2; cindex[19] = 3;
> cindex[20] = 0; cindex[21] = 1; cindex[22] = 2; cindex[23] = 3;
>
> pfGeoSet *gset = new pfGeoSet;
> gset->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, verts, vindex);
> gset->setAttr(PFGS_COLOR4, PFGS_PER_VERTEX, colors, cindex);
> gset->setPrimType(PFGS_QUADS);
> gset->setNumPrims(6);
>
> My changes, (Note: the index order is different from QUAD case)
>
> pfVec3 *verts = (pfVec3*) new(8*sizeof(pfVec3)) pfMemory;
> verts[0].set(-1.0f, -1.0f, 1.0f)
> verts[1].set( 1.0f, -1.0f, 1.0f);
> verts[2].set( 1.0f, 1.0f, 1.0f);
> verts[3].set(-1.0f, 1.0f, 1.0f);
> verts[4].set(-2.0f, -2.0f, 0.0f);
> verts[5].set( 2.0f, -2.0f, 0.0f);
> verts[6].set( 2.0f, 2.0f, 0.0f);
> verts[7].set(-2.0f, 2.0f, 0.0f);
>
> ushort *vindex = (ushort*) new(24*sizeof(ushort)) pfMemory;
> vindex[0] = 0; vindex[1] = 1; vindex[2] = 3; vindex[3] = 2; //
> top
> vindex[4] = 0; vindex[5] = 3; vindex[6] = 4; vindex[7] = 7; //
> left
> vindex[8] = 4; vindex[9] = 7; vindex[10] = 5; vindex[11] = 6; //
> bottom
> vindex[12] = 1; vindex[13] = 5; vindex[14] = 2; vindex[15] = 6; //
> right
> vindex[16] = 3; vindex[17] = 2; vindex[18] = 7; vindex[19] = 6; //
> back
> vindex[20] = 0; vindex[21] = 4; vindex[22] = 1; vindex[23] = 5; //
> front
>
> pfVec4 *colors = (pfVec4*) new(4*sizeof(pfVec4)) pfMemory;
> colors[0].set(1.0f, 0.0f, 0.0f, 0.5f);
> colors[1].set(0.0f, 1.0f, 0.0f, 0.5f);
> colors[2].set(0.0f, 0.0f, 1.0f, 0.5f);
> colors[3].set(1.0f, 1.0f, 1.0f, 0.5f);
>
> ushort *cindex = (ushort*) new(24*sizeof(ushort)) pfMemory;
> cindex[0] = 0; cindex[1] = 1; cindex[2] = 3; cindex[3] = 2;
> cindex[4] = 0; cindex[5] = 1; cindex[6] = 3; cindex[7] = 2;
> cindex[8] = 0; cindex[9] = 1; cindex[10] = 3; cindex[11] = 2;
> cindex[12] = 0; cindex[13] = 1; cindex[14] = 3; cindex[15] = 2;
> cindex[16] = 0; cindex[17] = 1; cindex[18] = 3; cindex[19] = 2;
> cindex[20] = 0; cindex[21] = 1; cindex[22] = 3; cindex[23] = 2;
>
>
> int *length = (int *) new(6*sizeof(int)) pfMemory;
> for(uint i=0; i<6; i++)
> length[i] = 4;
>
> pfGeoSet *gset = new pfGeoSet;
>
> gset->setPrimType(PFGS_TRISTRIPS);
> gset->setPrimLengths(length);
> gset->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, verts, vindex);
> gset->setAttr(PFGS_COLOR4, PFGS_PER_VERTEX, colors, cindex);
> gset->setNumPrims(6);
>
> After the change, please get the value of PFQHIT_PRIM, it always is 0.
> In fact, in my application, it is always a constant value.
>
> Thank you for your reconsideration.
>
> Best regards
>
> Yigang
>
>
> Angus Dorbie wrote:
>
> > You say you set a strip, a strip is a single primitive with several
> > triangles. You may optionally have more than one triangle primitive
> > and
> > set the associated lengths array when you create the geoset so, to
> > narrow everything down fully if you use multiple strips you need to
> > look
> > at PFQHIT_PRIM and PFQHIT_TRI, the former telling you which tristrip
> > and
> > the latter telling you which triangle in the strip. As things stand
> > you
> > probably only have the one primitive (and a single value in lengths)
> >
> > which is obviously always 0 and so PFQHIT_TRI will be the number you
> >
> > need indicating which triangle in strip 0 you have hit.
> >
> > Cheers,Angus.
> >
> > Yigang Wang wrote:
> > >
> > > Hi, all.
> > >
> > > I am making a program to select some parts of the triangle mesh
> > with
> > > Performer. I need the returned parameters of the index of strip
> > > primitive (PFHIT_PRIM) and the index of triangle in the strip
> > > (PFHIT_TRI). But it result in an error in my program. So i check
> > the
> > > example program
> > /usr/share/Performer/src/pguide/libpf/C++/intersect.C
> > >
> > > I made a small change of the programe
> > > /usr/share/Performer/src/pguide/libpf/C++/intersect.C, there
> > appear an
> > > strange result. In the example, i change the primitive of the
> > pfGeoSet
> > > (QUADS) to strips representation ( not change the real geometry),
> > and
> > > then i get the result of intersection from the fuuctions:
> > > pfHit::query(&prim_index, PFHIT_PRIM) and
> > pfHit::mQuery(&tri_index,
> > > PFHIT_TRI), I found that the prim_index is always 0. However it
> > > changed correctly for QUADS case or POLYS case.
> > >
> > > Is it a bug or not? Do i need to set more parameters for pfHit?
> > >
> > > Thanks for your reply.
> > >
> > > Yigang
> > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > >
> > **********************************************************************
> >
> > > Yigang Wang tel: +49 (2241) 14
> > 2980
> > > http://www.viswiz.gmd.de fax: +49 (2241) 14
> > 2040
> > > email:
> > yigang.wang++at++gmd.de
> > > GMD - The German National Research Center for Information
> > Technology
> > >
> > >
> >
> > --
> > For Performer+OpenGL tutorials http://www.dorbie.com/
> >
> > "In the middle of difficulty lies opportunity."
> > --Albert Einstein
>
> --
> **********************************************************************
> Yigang Wang tel: +49 (2241) 14 2980
> http://www.viswiz.gmd.de fax: +49 (2241) 14 2040
> email: yigang.wang++at++gmd.de
> GMD - The German National Research Center for Information Technology
>
>
-- For Performer+OpenGL tutorials http://www.dorbie.com/"In the middle of difficulty lies opportunity." --Albert Einstein
This archive was generated by hypermail 2b29 : Wed Dec 06 2000 - 11:02:42 PST