Jump to content

To switch the visibility of 2 sets of prims


Kaluura Boa
 Share

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

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

Recommended Posts

To switch the visibility of 2 sets of prims using llSetLinkPrimitiveParamsFast() and PRIM_LINK_TARGET for maximum speed. For example: Folded vs. extended wings. Easily extensible for more than 2 sets.

Only caveat: All the prims are assumed to have only one color each because llSLPPF() doesn't allow you to set only transparency without also setting the color. (Vote for Jira SCR-4!)

 

integer FirstOne;
list ShowFirstSet;
list HideFirstSet;

integer SecondOne;
list ShowSecondSet;
list HideSecondSet;

integer theSWITCH;

uuSetPrims(integer switch)
{
	theSWITCH = switch; // Don't forget this!
	if (switch)
	{
		// Show second set and hide first set.
		llSetLinkPrimitiveParamsFast(SecondOne, ShowSecondSet 
					+ [PRIM_LINK_TARGET, FirstOne] + HideFirstSet);
	}
	else
	{
		// Show first set and hide second set.
		llSetLinkPrimitiveParamsFast(FirstOne, ShowFirstSet 
					+ [PRIM_LINK_TARGET, SecondOne] + HideSecondSet);
	}
}

default
{
	on_rez(integer param) { llResetScript(); }
	
	state_entry()
	{
		integer i = llGetNumberOfPrims();
		for (; i > 0; --i) // Checking all the prims, including the root.
		{
			string name = llGetLinkName(i);
			if (name == "first") // Name of the prims in the first set
			{
				if (ShowFirstSet != []) // Params list for first set not empty
				{
					// We need PRIM_LINK_TARGET...
					ShowFirstSet += [PRIM_LINK_TARGET, i];
					HideFirstSet += [PRIM_LINK_TARGET, i];
				}
				else
				{
					// ...otherwise not. 
					FirstOne = i; // Store that link number.
				}
				// Primitive params are needed in all cases.
				vector color = llList2Vector(llGetLinkPrimitiveParams(i, [PRIM_COLOR, 0]), 0);
				ShowFirstSet += [PRIM_COLOR, ALL_SIDES, color, 1.0];
				HideFirstSet += [PRIM_COLOR, ALL_SIDES, color, 0.0];
			}
			else if (name == "second") // Name of the prims in the second set
			{
				if (ShowSecondSet != []) // Params list for second set not empty
				{
					// We need PRIM_LINK_TARGET...
					ShowSecondSet += [PRIM_LINK_TARGET, i];
					HideSecondSet += [PRIM_LINK_TARGET, i];
				}
				else
				{
					// ...otherwise not.
					SecondOne = i; // Store that link number.
				}
				// Primitive params are needed in all cases.
				vector color = llList2Vector(llGetLinkPrimitiveParams(i, [PRIM_COLOR, 0]), 0);
				ShowSecondSet += [PRIM_COLOR, ALL_SIDES, color, 1.0];
				HideSecondSet += [PRIM_COLOR, ALL_SIDES, color, 0.0];
			}
		}
		uuSetPrims(FALSE); // Set and use the switch.
	}
	
	touch_end(integer num)
	{
		if (llDetectedKey(0) != llGetOwner()) { return; } // Owner only!
		//
		uuSetPrims(!theSWITCH); // Invert and use the switch.
	}
}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4584 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...