Skip to content

Instantly share code, notes, and snippets.

@antonyfairport
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antonyfairport/d31fd1090308c90049b3 to your computer and use it in GitHub Desktop.
Save antonyfairport/d31fd1090308c90049b3 to your computer and use it in GitHub Desktop.
Little tool to help find textures and tints that would result in a material face in the likes of Mesh Studio.
//////////////////////////////////////////////////////////////////////
// Z&A Unique Texture Lister
// By Antony Fairport
//
// Z&A List Unique Textures - Find the first instance of the use of
// a texture and tint combination in a linkset. Handy little tool to
// help hunt down any material face confusion when using something like
// Mesh Studio.
//
// Revision history:
// ------------------------------------------------------------
//
// 2015-02-09
// Changed the way the output is formatted, making the lines not so
// long Also changed the colour output so that it links to rgb to so
// I can quickly check what a colour looks like.
//
// 2014-08-19
// Initial revision.
//////////////////////////////////////////////////////////////////////
// Create a link to quickly view a texture.
string LinkifyTexture( key kUUID )
{
return "[http://secondlife.com/app/image/" + ( (string) kUUID ) + "/2 " + ( (string) kUUID ) + "]";
}
//////////////////////////////////////////////////////////////////////
// Show a colour vector with a link that lets you see it.
string LinkifyColour( vector vColour )
{
string sRed = (string) ( (integer) ( 255 * vColour.x ) );
string sGreen = (string) ( (integer) ( 255 * vColour.y ) );
string sBlue = (string) ( (integer) ( 255 * vColour.z ) );
return "[http://rgb.to/" + sRed + "," + sGreen + "," + sBlue + " " + sRed + "," + sGreen + "," + sBlue + "]";
}
//////////////////////////////////////////////////////////////////////
// Default state.
default
{
//////////////////////////////////////////////////////////////////
// React to a touch.
touch_start( integer _ )
{
llOwnerSay( "Starting scanning for textures/tints." );
// Holds the texture list.
list lTextures;
// Holds the "faces" that have been found.
list lFaces;
// Find out how big the linkset is.
integer iMaxPrim = llGetNumberOfPrims();
integer iPrim = 1;
// Not a linkset at all?
if ( iMaxPrim == 1 )
{
// We'll just work with this object then.
iPrim = iMaxPrim = LINK_THIS;
}
// For every prim...
for ( ; iPrim <= iMaxPrim; iPrim++ )
{
// For every face on the prim...
integer iMaxFace = llGetLinkNumberOfSides( iPrim );
integer iFace;
for ( iFace = 0; iFace < iMaxFace; iFace++ )
{
// Get the texture details.
list lTexture = llGetLinkPrimitiveParams( iPrim, [ PRIM_TEXTURE, iFace ] );
list lColour = llGetLinkPrimitiveParams( iPrim, [ PRIM_COLOR, iFace ] );
key kTexture = llList2Key( lTexture, 0 );
vector vTint = llList2Vector( lColour, 0 );
float nAlpha = llList2Float( lColour, 1 );
// If the texture is visible...
if ( nAlpha > 0.0 )
{
// Not seen this texture yet?
if ( llListFindList( lTextures, [ ( (string) kTexture ) + ( (string) vTint ) ] ) == -1 )
{
lFaces += LinkifyTexture( kTexture ) + " " +
LinkifyColour( vTint ) + " " +
"L" + ( (string) iPrim ) + " " +
"F" + ( (string) iFace );
// Add it to the list of seen textures.
lTextures += ( (string) kTexture ) + ( (string) vTint );
}
}
}
}
// Make the result.
string sResult = llDumpList2String( lFaces, "\n" );
// If it's short enough...
if ( llStringLength( sResult ) < 1024 )
{
llOwnerSay( "\n" + sResult );
}
else
{
// Oh well. Do it the hard way.
integer iMax = llGetListLength( lFaces );
integer i;
for ( i = 0; i < iMax; i++ )
{
llOwnerSay( llList2String( lFaces, i ) );
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment