[info-performer] Sphere infront of The Quad

Date view Thread view Subject view Author view

From: Rajesh R (rajeshr++at++cair.res.in)
Date: 12/14/2005 03:51:09


I want to render a sphere infront a Quad. The Quad is visible. Sphere is
not to be seen

#include <Performer/pr/pfWindow.h>
#include <Performer/pr/pfGeoSet.h>
#include <Performer/pr/pfGeoState.h>
#include <Performer/pr/pfMaterial.h>
#include <Performer/pfdu.h>

int main (void)
{
    float t = 0.0f;

    void *arena = pfGetSharedArena();

    // Initialize Performer
    pfInit();
    pfInitState(NULL);

    // Initialize GL
    pfWindow *win = new pfWindow;
    win->setOriginSize(100, 100, 500, 500);
    win->setName("Iris Performer");
    win->setWinType(PFWIN_TYPE_X);
    win->open();

    // set up the window
    pfFrustum *frust = new pfFrustum;
    frust->apply();
    delete frust;

    pfAntialias(PFAA_ON);
    pfCullFace(PFCF_OFF);

    // Set up a geoset

    pfVec3 *coords = new pfVec3[4];
    coords[0].set(-1.0f, -1.0f, 0.0f );
    coords[1].set( 1.0f, -1.0f, 0.0f );
    coords[2].set( 1.0f, 1.0f, 0.0f );
    coords[3].set(-1.0f, 1.0f, 0.0f );

    /* pfVec3 *coords = new pfVec3[4];
    coords[0].set(1.0f, 0.0f, 1.0f );
    coords[1].set(1.0f, 0.0f, 1.0f );
    coords[2].set(1.0f, 0.0f, 1.0f );
    coords[3].set(1.0f, 0.0f, 1.0f );*/

    pfVec4 *colors = new pfVec4[4];
    colors[0].set(1.0f, 1.0f, 1.0f, 1.0f);
    colors[1].set(0.0f, 0.0f, 1.0f, 1.0f);
    colors[2].set(1.0f, 0.0f, 0.0f, 1.0f);
    colors[3].set(0.0f, 1.0f, 0.0f, 1.0f);

    pfGeoSet *gset = new pfGeoSet;
    gset->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, coords, NULL);
    gset->setAttr(PFGS_COLOR4, PFGS_PER_VERTEX, colors, NULL);
    gset->setPrimType(PFGS_QUADS);
    gset->setNumPrims(1);

    // Set up a geostate, backface removal turned off
    pfGeoState *gstate = new pfGeoState;
    gstate->setMode(PFSTATE_CULLFACE, PFCF_OFF);
    gset->setGState(gstate);

    pfTranslate (0.0f, 0.0f, -4.0f);

    pfGeoSet *gset2;
    pfGeoState *gstate2 = new pfGeoState();
    gset2 = pfdNewSphere(500,arena);

    pfMaterial *mat = new pfMaterial();
    mat->setAlpha(0.5);
    gstate2->makeBasic();
    gstate2->setMode(PFSTATE_ENLIGHTING, PF_ON);
    gstate2->setAttr(PFSTATE_FRONTMTL, mat);
    gstate2->setMode(PFSTATE_TEXTURE, PFTR_OFF);
    gstate2->setMode(PFSTATE_TEXENV, PFTR_OFF);
    gstate2->setMode(PFSTATE_TRANSPARENCY, PFTR_ON);
    gset2->setGState(gstate2);

    pfTranslate (0.0f,0.0f,-4.0f);

    // Simulate for twenty seconds.
    pfInitClock (0.0f);
    while (t < 2.0f)
    {
        static pfVec4 clr(0.1f, 0.0f, 0.4f, 1.0f);

        t = pfGetTime();
        pfClear(PFCL_COLOR | PFCL_DEPTH, &clr);
        //pfRotate (PF_Y, 1.0f);
        gset->draw();

        win->swapBuffers();
    }
    return 0;
}

Rajesh.R
Virtual Reality
Institute for Robotics and Virtual Reality
c/o Centre for AI and Robotics
Defence Research and Development Organization (DRDO)
Ministry of Defence
Bangalore - 1

Scientists are people of very dissimilar temperaments
doing different things in very different ways. Among
scientists are collectors, classifiers and compulsive
tidiers-up; many are detectives by temperament and many
are explorers; some are artists and others artisans.
There are poet-scientists and philosopher-scientists and
even a few mystics."


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Dec 14 2005 - 04:20:53 PST