When I'm making something with Mesh Studio I have this approach (with appropriate resolution tweaks along the way):
- Make and texture the source linkset that's exactly how the final mesh will look.
- Shift copy it, remove any faces that I can afford to lose for the next LOD level down.
- Shift copy #2 and start to remove more faces and even whole prims.
- Shift copy #3 and really go crazy on removing prims and faces while keeping the same overall shape and, of course, the same number of texture and tint combinations (for those who don't know, a texture+tint combo defines a face in the resulting mesh).
Mostly this isn't a problem -- the lowest LOD should only really be visible from such a distance as to make textures a bit of a moot point. Thing is I've noticed, with recent Firestorms (for example), that a mesh object can sometimes get "stuck" at the lowest LOD when it first comes into view after being obscured by another large object. That in itself is a bit of a bother but it's made all the more worse if textures appear to get swapped.
So, with all that in mind, I got to thinking that I should be able to script something to help with this. While I wouldn't really be able to script my way out of the problem, I might be able to make a tool that lets me compare each of the linksets and ensure that the texture+tint combinations are all first encountered in the same order.
And then I realised that this script that I wrote later on last year more or less did the trick. The only problem with it was that the output didn't quite lend itself to easily scanning over the results and visually comparing them. So I made a few tweaks and the result is this:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////////////////////////////////////////////// | |
// 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 ) ); | |
} | |
} | |
} | |
} |
First off I've made use of modern viewers' ability to hyperlink text, like this:
[http://www.google.com/ Visit Google]
Which, in local, results in:
Visit Google
Using this I've made the UUID of the texture just be the UUID while still being a hyperlink so you can view the texture online.
Secondly, I've stored the results and then try and output them in a single llOwnerSay. I say "try"... if the output will end up being too low so as to blow the 1024 limit, I then fall back to doing it line-by-line (I'm almost tempted, at this point, to do the whole thing via llHTTPResponse).
Finally, just for kicks, the colour data is now shown as RGB and it also links to a site that shows the colour.
The result of all of this is that, whereas the output of the old version of the script looked like this:
The new version looks like this:
When comparing two objects to check that the lists are the same I'm finding the latter a lot easier to quickly scan over.
No comments:
Post a Comment