Re: 3DTexture examples ?

New Message Reply Date view Thread view Subject view Author view

Matsumura Makoto (matumura++at++matsumura.nsg.sgi.com)
Tue, 5 Nov 1996 14:34:50 +0900


On Nov 4, 1:57am, login IRIX wrote:
> Subject: 3DTexture examples ?
> hello Everybody
>
> is there anybody who could tell me where I could find an sample code of
> 3Dtexture with Performer?
>

I attached the part of code.
This is a part of volume renderer.Not for VizSim, eg. Cloude etc...
So, rotating texture matrix etc...

Hope this help.

void init_texture()
{
// I use PixelTransfer & so on : following 2 lines seems incorrect...
        voltex->setFormat( PFTEX_IMAGE_FORMAT,GL_COLOR_INDEX);
        voltex->setImage(voldata, 4, W, H, D);
        voltex->setFormat( PFTEX_SUBLOAD_FORMAT,PF_ON);
        voltex->setRepeat(PFTEX_WRAP_S,PFTEX_CLAMP);
        voltex->setRepeat(PFTEX_WRAP_T,PFTEX_CLAMP);
        voltex->setRepeat(PFTEX_WRAP_R,PFTEX_CLAMP);
        voltex->setFilter(PFTEX_MINFILTER,PFTEX_TRILINEAR);
        voltex->setFilter(PFTEX_MAGFILTER,PFTEX_TRILINEAR);

        voltev->setMode( PFTE_MODULATE );

        /** Texture Generation **/
        volgen->setMode(PF_S , PFTG_OBJECT_LINEAR );
        volgen->setMode(PF_T , PFTG_OBJECT_LINEAR );
        volgen->setMode(PF_R , PFTG_OBJECT_LINEAR );
        volgen->setMode(PF_Q , PFTG_OBJECT_LINEAR );

        /** Texture Generation Plane **/
        volgen->setPlane(PF_S , 1.0, 0.f, 0.f, 0.0 );
        volgen->setPlane(PF_T , 0.f, 0.f, 1.0, 0.0 );
        volgen->setPlane(PF_R , 0.f, 1.0, 0.f, 0.0 );
        volgen->setPlane(PF_Q , 0.f, 0.f, 0.f, 1.f );

}

void init_slices()
{
    int i;

  /** create geostate **/

        gstate->setAttr(PFSTATE_TEXTURE, voltex);
        gstate->setAttr(PFSTATE_TEXENV, voltev);
        gstate->setMode(PFSTATE_ENTEXTURE,1);

        gstate->setAttr(PFSTATE_TEXGEN, volgen);
        gstate->setMode(PFSTATE_ENTEXGEN,1);

        gstate->setMode(PFSTATE_TRANSPARENCY,PFTR_ON);
  /** create geoset **/
    // Set up geosets

        {
        double dx;
        dx = 1.0/numslices;
        for(i=0;i<numslices; i++){
                coords[4*i+0].set(-0.5f, -0.5f, i*dx - 0.5);
                coords[4*i+1].set( 0.5f, -0.5f, i*dx - 0.5);
                coords[4*i+2].set( 0.5f, 0.5f, i*dx - 0.5 );
                coords[4*i+3].set(-0.5f, 0.5f, i*dx - 0.5 );
        }
        }
  
        for(i=0;i<numslices; i++){
                vertexlist[4*i+0] = 4*i+0;
                vertexlist[4*i+1] = 4*i+1;
                vertexlist[4*i+2] = 4*i+2;
                vertexlist[4*i+3] = 4*i+3;
        }

        {
        double dx;
        dx = 1.0/numslices;
        for(i=0;i<numslices; i++){

                color[4*i+0].set( 1.f, 1.f , 1.f, 1.0f);
                color[4*i+1].set( 1.f, 1.f , 1.f, 1.0f);
                color[4*i+2].set( 1.f, 1.f , 1.f, 1.0f);
                color[4*i+3].set( 1.f, 1.f , 1.f, 1.0f);

        }
        }
   
        for(i=0;i<numslices; i++){
                colorlist[4*i+0] = 4*i+0;
                colorlist[4*i+1] = 4*i+1;
                colorlist[4*i+2] = 4*i+2;
                colorlist[4*i+3] = 4*i+3;
        }
   
        gset->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, coords, vertexlist);
        gset->setAttr(PFGS_COLOR4, PFGS_PER_VERTEX, color, colorlist);
        gset->setPrimType(PFGS_QUADS);
        gset->setNumPrims(numslices);

        gset->setGState(gstate);
        // set up scene graph
        geode->addGSet(gset);

  /** DCS **/
        dcs->addChild(geode);

        root->addChild(dcs); // first child is base

#ifdef MODEL_MOVE
        ViewState->sceneGroup->addChild(root);
#endif
        ViewState->scene->addChild(root);

}
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


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:53:53 PDT

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