Dynamic web textures

The last few days I was struggling with the osSetDynamicTextureURL function of OpenSim. According to http://opensimulator.org/wiki/OsSetDynamicTextureURL the official usage is:

string URLTexture=osSetDynamicTextureURL(dynamicID, 
contentType ,srcURL  , "", refreshRate );

Although not explicitly stated, this suggests that the function returns some texture UUID. It doesn’t, you can’t use it to apply to the side of a prim with llSetTexture.  When looking in the log file, I see:

Returning 439411 bytes of image data for request 
7b654e9c-d76d-4630-8d8b-b1faea805df6

This 7b654e9c-… value is the same as returned by OsSetDynamicTextureURL. So it is a “request UUID” (whatever that is), instead of a texture ID?

Since I really want to have the UUID of the (temporary) texture, I use llGetTexture to get it after loading it. Unfortunately, this turned out to be not fail safe: loading the texture from the web takes some (asynchroneous) processing, so sometimes the texture UUID hasn’t changed yet right after calling the OsSetDynamicTextureURL function. I used the following (not so elegant) trick:

oldtexture = llGetTexture(0);
osSetDynamicTextureURL(dynamicID, contentType,
srcURL , "", refreshRate );
while( (texture = llGetTexture(0)) == oldtexture) 
     llSleep(1.0);

This seems to work quite reliably. Now you can preload various web textures and switch between them must faster than calling OsSetDynamicTextureURL each time.

Leave a comment