Projected Texture Spot Lights

New Message Reply Date view Thread view Subject view Author view

Gordon Tomlinson (gordon++at++apollo13.demon.co.uk)
Tue, 24 Jun 1997 14:40:41 GMT


Hi Rick

Thanks for your example, which works fine and so does my code
but ONLY IN SINGLE THREAD mode if you try it in a Multithreaded mode
than it fails to work like a project light, it seems to revert to a local light source ???

the function is set as a call back on VGDS_POSTLOAD which is set after vgDefineSys but before vgConfigSys

so one question is how can we get this to work in a multithreaded app ???

2) also when the Projected Textures spotlight works in Single Threaded mode, there is back lighting effect ( along the -y )
 that is not wanted is there a work around or fix to this effect.

Many thanks in Advance for

Gordon.

Heres the function and function call I am using

 vgAddFunc(vgGetObjDS(vgFindObj("helicopterObj")), VGDS_POSTLOAD, InitProjectedTorch, NULL);

void InitProjectedTorchCB(vgCommon *handle, void *data)
{
pfNode *node = NULL;
pfDCS *dtorchDCS = NULL;
pfFrustum *shadFrust = NULL;
pfTexture *tex = NULL;

    printf("\n\n Project callback PID = %d \n\n\n", (int) getpid());
    if((node = (pfNode *)vgGetDSPfObj((vgDataSet *)handle))== NULL){
                vgNotify(VG_FATAL, VG_APP, "****InitProjectedTorchProjected: failed to get a handle to the dataset's performer node");
                return;
                }

        if(!dtorchDCS) {
                dtorchDCS = (pfDCS*) pfFindNode( node ,"dTORCH",pfGetDCSClassType());
           if( !dtorchDCS ){
                   vgNotify(VG_FATAL, VG_APP, "****InitProjectedTorchProjected: failed on Find dtorchDCS part(dTORCH)\a");
                                return ;
                  }
                }
   vgNotify(VG_DEBUG, VG_APP, "****InitProjectedTorchProjected: Found dTORCH DCS node\n");
                 
         
        if((shadFrust = pfNewFrust( pfGetSharedArena()))== NULL){
                vgNotify(VG_FATAL, VG_APP, "****InitProjectedTorchProjected: failed on to create shadFrust\a");
                return;
                }

        pfMakeSimpleFrust( shadFrust, 21.0f);
        pfFrustNearFar( shadFrust, 0.01f, 100.0f);
        vgNotify(VG_DEBUG, VG_APP, "****InitProjectedTorchProjected: Created shadFrust \n");
         
        if( (projLight = pfNewLSource())== NULL ){
                vgNotify(VG_FATAL, VG_APP, "****InitProjectedTorchProjected: failed on to create light source for spot\a");
                return;
                }
        vgNotify(VG_DEBUG, VG_APP, "****InitProjectedTorchProjected: Created lightsource for spot \n");
         
                 
        if((tex = pfNewTex( pfGetSharedArena())) == NULL ){
                vgNotify(VG_FATAL, VG_APP, "****InitProjectedTorchProjected: failed on to create Texture for spot\a");
                return;
                }
    vgNotify(VG_DEBUG, VG_APP, "****InitProjectedTorchProjected: Created Texture for spot \n");

         
         
        if(pfLoadTexFile( tex, "/usr/working/Hasbro/Code/spotlight.inta" ))
                vgNotify(VG_DEBUG, VG_APP, "****InitProjectedTorchProjected: spotlight.inta loaded OK");
        else
                vgNotify(VG_DEBUG, VG_APP, "****InitProjectedTorchProjected: Failed to Load spotlight.inta");
         
        pfTexRepeat( tex, PFTEX_WRAP, PFTEX_CLAMP);
           
        pfLSourceMode( projLight, PFLS_PROJTEX_ENABLE, PF_ON);
        pfLSourceAttr( projLight, PFLS_PROJ_FRUST,shadFrust);

        pfLSourceAttr( projLight, PFLS_PROJ_TEX, tex );
        pfLSourceColor(projLight, PFLT_AMBIENT, 0.01f, 0.01f, 0.01f );
        pfLSourceColor(projLight, PFLT_DIFFUSE, 1.0f, 1.0f, 1.0f);
        pfLSourceVal( projLight, PFLS_INTENSITY, 1.0f);
        pfLSourcePos( projLight, 0.0f, 0.0f, 0.0f, 1.0f);
  
        pfAddChild( dtorchDCS,projLight );

        pfLSourceOn(projLight );
         
        if( pfIsLSourceOn(projLight ) == PF_ON )
                vgNotify(VG_DEBUG, VG_APP, "****InitProjectedTorchProjected: projLight report ON");
         else
                vgNotify(VG_DEBUG, VG_APP, "****InitProjectedTorchProjected: projLight report OFF");
                         
    vgNotify(VG_DEBUG, VG_APP, "****InitProjectedTorchProjected: Setup Spot light completed adding to dtorchDCS DCS \n");

}

Gordon Tomlinson

***************************************************************
Email: gordon++at++apollo13.demon.co.uk
WWW: http://www.apollo13.demon.co.uk
***************************************************************
The Truth is out there ...........
Smoke me a Kipper I'll be back for Breakfast .....
***************************************************************
===================================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:55:30 PDT

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