Jump to content

Loading external image via http request (?) on clicked prim face ...


Katherine Heartsong
 Share

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

Quick question I may have asked before.

I have 115+ art images for my gallery artwork, obviously uploaded as textures so I can use them on a panel surface for my art. Works great. I also have a basic, cobbled together script made that if I loaded more than one of them into the root of the panel, I could click on the face of the panel and display a random one. Cooler. I did that so you could get a surprise and a two-for-one deal at an art show in world.

So here's the ask ...

If I had all 115 images (let's say they're names art "art-1" through "art-115") as JPGs on my external web server, is there any way for me to have a poster or wall in my warehouse gallery (a prim) where a user could touch the face of that prim and load/display one of the images on my web server via an http request? I think that's the right way to phrase that question, but I'm a coding klutz so rely mostly on the one script generator online to do things.

No worried about lag, if it's not instant that's okay with me.

Link to comment
Share on other sites

So, kinda. Because of how media on a prim (MOAP) works, it's easiest to script if you can get them to touch literally anything that isn't the face the picture is on, (or ctrl-click the picture in any viewer other than firestorm, or firestorm with an obscure option tuned on)

integer link;
integer face;

string server = "www.MyAwesomeServer.com/art-";
integer counter; // the number of the picture to display.
integer counter_max = 115; // number of pictures.
default
{  touch_start()
   {   llSetLinkMedia(link,face,
       [   PRIM_MEDIA_CURRENT_URL, server+(string)(1+(counter%counter_max))+".jpg"
           PRIM_MEDIA_PERMS_CONTROL, PRIM_MEDIA_PERMS_NONE
       ]);
   }
}

or so should work as a basic test. There are some weird things with sizing the media in such a way as to not have a scroll bar visible though.

Edited by Quistess Alpha
  • Like 1
Link to comment
Share on other sites

I started typing up a response, but had a strong sense of deja vu...

I don't think HTTPRequest will be of much help much here, because the end goal is to display content from the web on a prim's face. The only way to do that which I'm aware of is to turn the prim's face into a mini web browser by way of the Prim Media functions like llSetLinkMedia.

The last time this was suggested, you seemed to have trouble getting it to work. Here's a slightly more automated demo. It cycles on its own as soon as the script is compiled. If you have Media-Auto Play enabled, it should just work, otherwise you must click on the target prim face once to initialize the mini browser. This demo uses face 0, or the top face of the default cube prim.

/*
Display images randomly from a given website directory.
Assumptions:
 1. All images have the same base URL,name, and file extension.
 2. All images are differentiated by numerical suffix.
 3. Users must have Media enabled in preferences.
 3. Users must also have Auto-play Media enabled in
    preferences - otherwise they must click the prim's
    media face once to enable it for their view.
*/

string baseURL = "http://www.6dfgs.net/Gallery/Originals/DR2_6dFGS_view";  //the static portion of the image's full url (including the first part of the file name)
string ext = ".jpg";    //extension for image file
integer img_count = 5; //number of images in directory

default
{
    state_entry()
    {
        llClearPrimMedia(0);
        llSetLinkMedia(LINK_THIS, 0, [
            PRIM_MEDIA_PERMS_CONTROL, PRIM_MEDIA_PERM_NONE, //hide control bar entirely
            PRIM_MEDIA_FIRST_CLICK_INTERACT, FALSE,         //disable first click interaction
            PRIM_MEDIA_AUTO_PLAY, TRUE,                     //auto play
            PRIM_MEDIA_AUTO_SCALE, TRUE,                    //auto scale
            PRIM_MEDIA_CURRENT_URL, baseURL+(string)1+ext   //initial url to display
        ]);
        
        llSetTimerEvent(10.0);
    }
    
    timer()
    {
        integer x = (integer)llFrand(img_count)+1;  //generate random number from (0 to img_count-1) + 1
        llSetLinkMedia(LINK_THIS, 0, [PRIM_MEDIA_CURRENT_URL, baseURL+(string)x+ext]);
    }
}

The example here uses a random website I found that had a gallery of pictures that followed a similar naming convention as your art files. The files are all named DR2_6dFGS_viewX.jpg where X is a number 1-5.

Edit: It was also pointed out in the previous thread that this is a rather expensive way to go about displaying images, as each instance is its own web browser. That's a lot of overhead for a jpg. It will work, but it would be advisable to not use a lot of them in a single area.

Edited by Fenix Eldritch
  • Like 2
Link to comment
Share on other sites

@Fenix Eldritch perfect, thanks so much!

I managed to get it to work, placing art on a 4:3 aspect ratio prim (new work coming!).

The only thing is I see black bars on the prim face above/below the image even though the ratio of image and prim it's on are the same, and these seem to be distorting the image (squishing it down vertically). I looked through the LSL PRIM library and there doesn't seem to be a way to get rid of these?

  • Like 1
Link to comment
Share on other sites

Huh, I assumed the auto scale parameter would account for that... but apparently not.

If all the images are the same size, you can probably get away with just altering the prim face's vertical scale (repeats) from the build tool texture tab until it aligns with the desired aspect ration of the prim/image.

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...