[info-performer] pfLightSource Problems

New Message Reply Date view Thread view Subject view Author view

From: Chee Tzuon (CheeTzuon++at++stts.com.sg)
Date: 03/13/2003 17:24:35


Hi all,

I have been experimenting with pfLightSource to do project texture to simulate headlights of a car. From many performer threads, i was able to create this effect by creating a pfLightSource and attach it to a DCS for easy position setting, but there are still some problems to it. (the effect is simulated in a night time lighting environment)

1) like in one of the threads "Projective Light quirks" 16/10/2002, there is a similar light lobe 180 behind the intended direction.

2) there seems to be some light leaking on the sides

3) once the headlight is turned on the it will affect my envirnoment lightings, i.e. the surrounding will become brighter

I understand that the third problem is due to the addition effect of Performer light settings, but is there any way to override that?
Any suggestions to help in solving them?? Below is the code for the effect, some parts are extracted from Performer/src/pguide/libpf/c++/projective.cxx
Did i miss out setting anything??

Chan->setTravMode(PFTRAV_MULTIPASS, PFMPASS_EMISSIVE_PASS | PFMPASS_BLACK_PASS);
spotFrust = new pfFrustum;
spotFrust->makeSimple(60.0f);
spotFrust->setNearFar(1.0f, 100.0f);

/*******************create headlight texture***************/

long i, j;
unsigned short *image;
unsigned short val;
  
image = (unsigned short *)pfMalloc(sizeof(unsigned short) * imagesize * imagesize, pfGetSharedArena());

    for (i = 0; i < SPOT_SIZE / 2; i++)
    {
        for (j = 0; j < SPOT_SIZE / 2; j++)
        {
                val=0;
                if ((i * i + j * j) <= size * size)
                        val = (unsigned short)(1.0f*65535.0f);
                image[(SPOT_SIZE / 2 - i) * SPOT_SIZE + (SPOT_SIZE / 2 - j)] =
                image[(SPOT_SIZE / 2 - i) * SPOT_SIZE + (SPOT_SIZE / 2 + j)] =
                image[(SPOT_SIZE / 2 + i) * SPOT_SIZE + (SPOT_SIZE / 2 + j)] =
                image[(SPOT_SIZE / 2 + i) * SPOT_SIZE + (SPOT_SIZE / 2 - j)] = val;
        }
    }
spotTex=new pfTexture();
spotTex->setImage((uint*) image, 2, SPOT_SIZE, SPOT_SIZE, 0);
spotTex->setFormat(PFTEX_INTERNAL_FORMAT, PFTEX_IA_8);
spotTex->setRepeat(PFTEX_WRAP, PFTEX_CLAMP);

/**********Create and configure projected texture light source********/
 
spot = new pfLightSource;
spot->setPos(0.0, 0.0, 0.0, 0.0);
spot->setAmbient(0.0, 0.0, 0.0);
spot->setColor(PFLT_AMBIENT, 0.0, 0.0, 0.0);
spot->setColor(PFLT_DIFFUSE, 1.0, 1.0, 1.0);
spot->setColor(PFLT_SPECULAR, 1.0, 1.0, 1.0);

spot->setAttr(PFLS_PROJ_TEX, spotTex);
spot->setAttr(PFLS_PROJ_FRUST, spotFrust);
spot->setMode(PFLS_PROJTEX_ENABLE, 1);
spot->setSpotDir(0.0, 0.0, 1.0);

spot->setSpotCone(1,0.5);
spotDCS->addChild(spot);


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Thu Mar 13 2003 - 17:24:21 PST

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