how to make two sides geoset

New Message Reply Date view Thread view Subject view Author view

Li Yonglin (engp8691++at++nus.edu.sg)
Wed, 09 Jun 1999 11:21:13 -0700


Hi, performers,
        I use the code below constructing a geoset of a retangle. But I can
only make it a single side retangle, this means that I can only see the
plane when the normals at the four vertices are facing me, as I rotate
the view, The plane will lose when the normals are against me. So I need
to make the plane two sides so that I can see the back of the plane. I
must define the normals at the vertices because I have many this kind of
polygons, they must be connected smoothly. So any body knows how to do
can give me some suggestion.

Thanks.

Rgs. Yonglin

// My code for a rectangle.

    Coords = (pfVec3 *) pfMalloc(4*sizeof(pfVec3), pfGetSharedArena());
    Norms = (pfVec3 *) pfMalloc(4*sizeof(pfVec3), pfGetSharedArena());
    Cindex = (ushort *) pfMalloc(4*SIZEOF_USHORT, pfGetSharedArena());

    Coords[0].set(-100.0, 0.0, -100.0);
    Coords[1].set( 100.0, 0.0, -100.0);
    Coords[2].set( 100.0, 0.0, 100.0);
    Coords[3].set(-100.0, 0.0, 100.0);

    Norms[0].set( 0.0, -1.0, 0.0);
    Norms[1].set( 0.0, -1.0, 0.0);
    Norms[2].set( 0.0, -1.0, 0.0);
    Norms[3].set( 0.0, -1.0, 0.0);

    Cindex[0] = 0;
    Cindex[1] = 1;
    Cindex[2] = 2;
    Cindex[3] = 3;

    gset = new pfGeoSet;

    gset->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, Coords, Cindex);
    gset->setAttr(PFGS_NORMAL3, PFGS_PER_VERTEX, Norms, Cindex);
    gset->setPrimType(PFGS_QUADS);
    gset->setNumPrims(1);

    gstate = new pfGeoState;
    redMtl = new pfMaterial();
    redMtl->setColor(PFMTL_DIFFUSE, 1.0f, 0.9f, 0.6f);
    redMtl->setColorMode(PFMTL_FRONT, PFMTL_CMODE_OFF);

    gstate->setMode(PFSTATE_ENLIGHTING, PF_ON);
    gstate->setMode(PFSTATE_TRANSPARENCY, PFTR_ON);
    gstate->setAttr(PFSTATE_FRONTMTL, redMtl);
    gstate->setMode(PFSTATE_CULLFACE, PFCF_OFF);

    gset->setGState(gstate);
    geonode->addGSet (gset);


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Tue Jun 08 1999 - 18:51:20 PDT

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