Polygons in Performer 2.0

New Message Reply Date view Thread view Subject view Author view

Daniela Rainer (zrgr0390++at++awssg7.rus.uni-stuttgart.de)
Tue, 16 Jan 1996 14:36:21 +0000


Hi,

thanks to all who answered my question, but I have still the same problem:

If I define a polygon

        3 2
        ---------
| |
| |
| |
        ---------
        0 1

        ........

          static pfVec3 coordArray[4] = {
                                        {0.0f, 0.0f, 0.0f},
                                          {1.0f, 0.0f, 0.0f},
                                        {1.0f, 0.0f, 0.5f},
                                        {0.0f, 0.0f, 0.5f}
                                        };

          static pfVec4 colorArray[4] = {
                                        {1.0f, 0.0f, 0.0f, 1.0f},
                                          {1.0f, 0.0f, 0.0f, 1.0f},
                                        {1.0f, 0.5f, 0.0f, 1.0f},
                                        {0.0f, 0.5f, 0.0f, 1.0f}
                                        };

        static int primLenghthsArray[1] = {4};

          static pfVec3 normalArray[4]={{0.0f, -1.0f, 0.0f},
                                        {0.0f, -1.0f, 0.0f},
                                        {0.0f, -1.0f, 0.0f},
                                        {0.0f, -1.0f, 0.0f}};

        .......

          pfGSetAttr(geoset, PFGS_COORD3, PFGS_PER_VERTEX, coordArray, NULL);

          pfGSetAttr(geoset, PFGS_COLOR4, PFGS_PER_VERTEX, colorArray,NULL);

          pfGSetAttr(geoset, PFGS_NORMAL3, PFGS_PER_VERTEX, normalArray, NULL);

          pfGSetPrimType(geoset,PFGS_POLYS);

          pfGSetNumPrims(geoset, 1);

          pfGSetPrimLengths(geoset, primLenghthsArray);

        .......

        pfCullFace(PFCF_OFF);

        ......

Performer draws the correct polygon in wireframe mode but in filled mode
it draws the triangles 0-1-2 and 1-2-3.
And if pfCullFace is on, I don't see the second triangle because the normal is
wrong.

Regards,

Daniela

-- 
Daniela Rainer
rainer++at++rus.uni-stuttgart.de

/********************************************************************************/ /* */ /* Problem with polygons */ /* */ /********************************************************************************/

#define PF_CPLUSPLUS_API 0

#include <Performer/pf.h> #include <Performer/pr.h> #include <Performer/pfutil.h> #include <Performer/pfdu.h>

main() { pfScene *scene; pfLightSource *sun; pfPipe *pipe; pfPipeWindow *pwin; pfChannel *chan; pfGeoSet *geoset; pfGeode *geode; pfEarthSky *esky; pfCoord view; static pfVec3 coordArray[4] = { {0.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.5f}, {0.0f, 0.0f, 0.5f} }; static pfVec4 colorArray[4] = { {1.0f, 0.0f, 0.0f, 1.0f}, {1.0f, 0.0f, 0.0f, 1.0f}, {1.0f, 0.5f, 0.0f, 1.0f}, {0.0f, 0.5f, 0.0f,1.0f} }; static int primLenghthsArray[1]={4}; static pfVec3 normalArray[4]={{0.0f, -1.0f, 0.0f}, {0.0f, -1.0f, 0.0f}, {0.0f, -1.0f, 0.0f}, {0.0f, -1.0f, 0.0f}}; /***/ pfInit(); /***/

pfMultiprocess(PFMP_APPCULLDRAW); pfConfig(); /** init the scenegraph **/ scene = pfNewScene(); sun = pfNewLSource(); pfLSourceColor(sun, PFLT_AMBIENT, 1.0f,1.0f,0.8f); pfLSourceAmbient(sun, 1.0f, 1.0f, 1.0f); pfLSourcePos(sun, 0.0f, 0.0f, 1.0f,0.0f); pfLSourceOn(sun); pfAddChild(scene, sun);

esky = pfNewESky(); pfESkyColor(esky, PFES_CLEAR, 0.1, 0.1, 0.1, 1.0);

/** geometry **/

geode = pfNewGeode(); geoset = pfNewGSet(NULL); pfGSetAttr(geoset, PFGS_COORD3, PFGS_PER_VERTEX, coordArray, NULL); pfGSetAttr(geoset, PFGS_COLOR4, PFGS_PER_VERTEX, colorArray, NULL); pfGSetAttr(geoset, PFGS_NORMAL3, PFGS_PER_VERTEX, normalArray, NULL); pfGSetPrimType(geoset,PFGS_POLYS); pfGSetNumPrims(geoset, 1); pfGSetPrimLengths(geoset, primLenghthsArray); pfAddGSet(geode, geoset); /* pfPrint(geode,PFTRAV_SELF|PFTRAV_DESCEND,PFPRINT_VB_DEBUG,NULL);*/

pfAddChild(scene, geode);

/** init the pipe and the pipewindow */ pipe = pfGetPipe(0); pwin = pfNewPWin(pipe); pfPWinName(pwin, "Polygon Test"); pfPWinOriginSize(pwin, 0, 0, 500, 500); pfOpenPWin(pwin); pfCullFace(PFCF_OFF);

/** init the channel **/ chan = pfNewChan(pipe); pfChanScene(chan,scene); pfSetVec3(view.xyz, 0.0f, -5.0f, 0.0f); pfSetVec3(view.hpr, 0.0f, 0.0f, 0.0f); pfChanView(chan, view.xyz, view.hpr); pfChanESky(chan, esky);

pfChanNearFar(chan, 1.0f, 100.0f); /***/

while (1) { pfSync(); pfFrame(); } }


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:52:15 PDT

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