Jump to content

Switch on and off Projectors by touch?


You are about to reply to a thread that has been inactive for 120 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I am looking into projectors at the moment and the only LSL command that I can find is llSetPrimitiveParams and the flag [ PRIM_PROJECTOR ].

Unlike the flag [ PRIM_POINT_LIGHT ] the prim_projector flag does not contain a boollean for FALSE or TRUE. Does that mean that there is no way to switch on or off a projector via touch and the only way to change it is by editing the object and do it in the edit window via the features tab? This would be a serious problem IMHO, now that PBR will look more dynamic and interesting by placing more projectors. But maybe I am overlooking something?

 

Link to comment
Share on other sites

36 minutes ago, Estelle Pienaar said:

Unlike the flag [ PRIM_POINT_LIGHT ] the prim_projector flag does not contain a boollean for FALSE or TRUE.

Not so.  The Boolean operator is the second parameter in the command for PRIM_POINT_LIGHT.   When you want to turn your light on/off, just write:

llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_FULLBRIGHT, iFace, iOn, PRIM_POINT_LIGHT, iOn, vColor, fIntensity, 10.0, 0.7]);

where iOn is your toggle variable.

 

EDIT:  Ah, no, I misread your question... Nothing more to see here.... 🙃

Edited by Rolig Loon
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Just toggle PRIM_POINT_LIGHT. The projector parameters (texture, FOV, focus, ambient) are not affected by the point light call, so they remain the same if you change the light state, color, intensity or radius. 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Posted (edited)

This script will switch on and off a projector. In order for the light to act like projector, the value for PRIM_FULLBRIGHT should be FALSE (unlike with point light):

integer isLightTurnedOn;

default
{
    state_entry()
    {
        llSetPrimitiveParams([  PRIM_PROJECTOR, "TextureName", 3, 10, 0.5  ]);
    }

    touch_start(integer total_number)
    {
        isLightTurnedOn = !isLightTurnedOn;    
        vector COLOR_White  = <1.00, 1.00, 1.00>;
        
        if (isLightTurnedOn){
            llSetPrimitiveParams([
                PRIM_FULLBRIGHT, ALL_SIDES, FALSE,
                PRIM_POINT_LIGHT, TRUE, COLOR_White, 1.0, 10.0, 0.6]);

                            }
        else{
 vector COLOR_White  = <1.00, 1.00, 1.00>;
            llSetPrimitiveParams([
                PRIM_FULLBRIGHT, ALL_SIDES, FALSE,
                PRIM_POINT_LIGHT, FALSE, COLOR_White, 1.0, 10.0, 0.6]);
            }

     }
}

 

Edited by Estelle Pienaar
  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 120 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...