[info-performer] spotlights

Date view Thread view Subject view Author view

From: Rob Body (r.body++at++hrwallingford.co.uk)
Date: 12/08/2004 09:42:19


Hi everyone,

I am trying to model spotlights in Performer 3.1.1 in either Linux or
Windows. When I make a spotlight in Creator it can be seen illuminating the
scene correctly. When I then run Performer the spotlight is not visible at
all. This used to work correctly on my ONYX RE2 but now doesn't.

I have also tried hard coding a spotlight in a fixed position. This sort of
works as my sea surface is illuminated but the terrain near it is not, even
though the terrain is divided into smallish polygons, some of which are
completely covered by the spot light.

My code for adding the spotlight into Performer is this :

        scene = pfNewScene();
        arena = pfGetSharedArena();

        /* Turn on lighting globally. Disable two-sided lighting. */
        lmodel = pfNewLModel(arena);

        // the following determines how much light reflects back off object
when it is dark
        pfLModelAmbient(lmodel, 0.02f, 0.02f, 0.02f);
        
        pfLModelTwoSide(lmodel, PF_OFF);
        gstate = pfNewGState(arena);
        pfGStateMode(gstate, PFSTATE_ENLIGHTING, PF_ON);
        pfGStateAttr(gstate, PFSTATE_LIGHTMODEL, lmodel);
        pfSceneGState(scene, gstate);

        /* Load the database. create a hierarchy under node "model" */
        terrain_model = pfdLoadFile(databasefilename);
           pfAddChild(scene, terrain_model);

            // try to add a white flood light at a fixed position, shining
down on the sea for testing

        spotlightDCS = pfNewDCS();
        spotlight = pfNewLSource();

        pfSpotLSourceDir(spotlight, 0, 0, -1);
        pfLSourceColor(spotlight, PFLT_DIFFUSE, 1.0f, 1.0f, 1.0f);
        pfLSourceColor(spotlight, PFLT_SPECULAR, 1.0f, 1.0f, 1.0f);
        pfLSourceColor(spotlight, PFLT_AMBIENT, 1.0f, 1.0f, 1.0f);
        pfLSourceVal(spotlight, PFLS_INTENSITY, 1.0f);
        pfLSourcePos(spotlight, 660.126f, 750.43f, 27.5f, 1.0f); /* Make
light local */
        pfSpotLightCone(spotlight, 1.0f, 1.0f);

        pfAddChild(scene, spotlightDCS);
        pfAddChild(spotlightDCS, spotlight);

Do I need to do anything else at run time in order for the lighting to work
properly? I have looked at pfLightOn(lightsource) but I don't think that I
need to include this. Am I correct in this?

Any pointers would be appreciated.

Thanks

Rob Body
Simulator Manager
_______________________________________________________
HR Wallingford Ltd
Howbery Park, Wallingford
Oxon. OX10 8BA
Telephone: +44 (0) 1491 822327 Direct (Switchboard 835381)
Fax: +44 (0) 1491 832233
E-mail: r.body++at++hrwallingford.co.uk
Internet: http://www.hrwallingford.co.uk
 

**********************************************************************
HR Wallingford uses Faxes and Emails for confidential and
legally privileged business communications. They do not of
themselves create legal commitments. Disclosure to parties
other than addressees requires our specific consent. We are
not liable for unauthorised disclosures nor reliance upon them.
If you have received this message in error please advise us
immediately and destroy all copies of it.
**********************************************************************


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Dec 08 2004 - 09:46:19 PST