Re: Fw: [info-performer] Dynamic change texture to be a animation movement

New Message Reply Date view Thread view Subject view Author view

From: Ken Schwarz (kschwarz++at++sgi.com)
Date: 10/31/2002 06:32:13


Use the pfFlux to create geometry that can be modified on the fly.
Here's a code snippet that may help:

pfNotify(PFNFY_NOTICE, PFNFY_RESOURCE, "pfPopClass::init() started [%d]
...", numObj);
primType = TRACER_AS_QUADS;
maxObj = TRACER_DEF_NUM_DATA;
numObj = 0;
// Allocate fluxes
// Four vertices (one quad) per new vertex position
fluxCoords = new pfFlux(sizeof(pfVec3) * 4 * maxObj,
PFFLUX_DEFAULT_NUM_BUFFERS);
fluxColors = new pfFlux(sizeof(pfVec4) * 4 * maxObj,
PFFLUX_DEFAULT_NUM_BUFFERS);
fluxTexCoords = new pfFlux(sizeof(pfVec2) * 4 * maxObj,
PFFLUX_DEFAULT_NUM_BUFFERS);

posData = (pfVec3*) pfMalloc(sizeof(pfVec3) * (maxObj + 1),
pfGetSharedArena());

gset = new pfGeoSet();

gset->setPrimType(PFGS_QUADS);

gset->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, fluxCoords, NULL);
gset->setAttr(PFGS_TEXCOORD2, PFGS_PER_VERTEX, fluxTexCoords, NULL);
gset->setAttr(PFGS_COLOR4, PFGS_PER_VERTEX, fluxColors, NULL);
gstate = new pfGeoState();
gstate->setMode(PFSTATE_ENLIGHTING, PF_OFF);
gstate->setMode(PFSTATE_ENTEXTURE, PF_OFF);
gstate->setMode(PFSTATE_CULLFACE, PFCF_OFF);

gset->setGState(gstate);
// Bounding box and sphere
bbox = new pfBox;
bsphere = new pfSphere;

geode = new pfGeode();
geode->addGSet(gset);

if(texName[0]) {
pfNotify(PFNFY_NOTICE, PFNFY_RESOURCE, "initTexture('%s')", texName);
this->initTexture();
}

During run-time you can modify the texture coordinates by getting a
pointer to the texture coordinate data:

// Set the texture coordinates
pfVec2 *texCoords = (pfVec2 *)fluxTexCoords->getWritableData();

for (i = 0; i < numObj; i++) {
PFSET_VEC2(texCoords[i*4 + 0], ... );
PFSET_VEC2(texCoords[i*4 + 1], ... );
PFSET_VEC2(texCoords[i*4 + 2], ... );
PFSET_VEC2(texCoords[i*4 + 3], ... );
}
fluxTexCoords->writeComplete();

Best,

Ken

³¯®a¥Í(Archer Chen) wrote:

> Hi, Performer ,
>
> Sorry re-post it again and explain the question easily :
>
> I load a OpenFlight file to my scene node and I wish to show
>
> an animation .For first method is add an animation in OpenFilgh
>
> file, but by this way , I had no idea to control the reflash rate.
>
> How can I do it??
>
> The second method , to change the texture while running to look
>
> "like" animation. By this way, I didn't know how to get the texture
>
> in FLT file and replace texture while running .
>
> Please someone direct me the derection to solve this problem.
>
> Thanks again.
>
> Regards,
>
> Archer Chen
>
> Best Regards,
> Archer Chen, Senior Specialist
> =============================================================
> Hitron Technology Inc.
>
> No. 40, Wu-Kung 5th Road, Wu-Ku, Taipei, Taiwan, R.O.C
>
> Tel: +886 2 2298-3456 ext:2620
> Fax:+886 2 2298-2508
> =============================================================
>
>
> ------------------------------------------------------------------
>
> Hi, Performers,
>
> Thanks for your patience to help me handle my problems.
>
> I got many help here for my job. Anyway , thanks.
>
> Now I got the new problem is:
>
> I wish to show an animation in my scene graph with OpenFligh file.
>
> It's a simple way to acchieve it if it include in the database .
>
> But if I did it, I couldn't control the rate of the animation.
>
> (If it could be control, can you tell me how to do??)
>
> So I plan to change the texture realtime in runtime.
>
> For example , there is a neon sigh, the colors is changing,
>
> and I wish to control the ligth colors manual ( color change, rate,
>
> on/off , etc.)
>
> Please tell me What shauld I do ???
>
> Thanks.
>
> Regards,
>
> Archer Chen
>

-- 
 ..    Ken Schwarz  Technical Consultant SGI Dallas  kschwarz++at++sgi.com .. 
..  972.628.3232 W/972.902.9639 Pager  http://reality.sgi.com/kschwarz ..
 ..   Brain:  Pinky, what rhymes with June?   Pinky:  No it doesn't.  ..


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Thu Oct 31 2002 - 06:32:29 PST

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