Scripting an iris door?
|
Ceera Murakami
Texture Artist / Builder
Join date: 9 Sep 2005
Posts: 7,750
|
07-21-2006 14:41
I saw someone post an idea in the forums about using a flattened torus as an iris door, by scripting a change in the hole size property. I think I am most of the way to my own solution on that for a project I am building (an 'expanding knothole door' for a naturalistic build), but I've never used llSetPrimativeParams before, and could use a bit of advice. I'll be using a simple touch event handler with two states to manage the change. I've done those before, to script alpha-mapped windows to change between two textures for open or closed curtains. Presumably I'll need something similar, but rather than executing an llSetTexture I'll need to use llSetPrimitiveParams to alter the hole size. What I need to know is the syntax, and how much I need to specify in that command. In the LSL WIKI, it looks like I might need to specify ALL of the possible parameters for the torus, even though I only want to alter the "Y Hole Size" value? Is that right? So I guess I need to fill in all the values in the below string for holeshape, cut, hollow, twist, holesize, topshear, profilecut, taper, revolutions, radiusoffset, and skew -- Even though I only want to change the value for holesize?  I think the value that I have in bold below is the only one I need to change. (Values below are from the WIKI, not from my prim.) llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.25, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]) Or is there a way to specify only the holesize, and allow the other parameters to remain unchanged? I did a manual test, changing values in the edit dialog, and it looks like a Y holesize of 0.05 is open, and 0.5 is closed. Another thought is wheather or not a cylander might be a better choice than a torus. It looks like a cylander would have fewer parameters to change, and might map a texture more cleanly than the torus did in my tests. If I can get a bit of help on this, I'll post the resulting iris door script in the Script Library, for everyone to use.
_____________________
Sorry, LL won't let me tell you where I sell my textures and where I offer my services as a sim builder. Ask me in-world.
|
Ceera Murakami
Texture Artist / Builder
Join date: 9 Sep 2005
Posts: 7,750
|
07-21-2006 15:57
Yay! My first try worked! // Iris Open Script by Cera Murakami - 7/21/2006 // Touch-sensitive iris opening door // Toggles open and closed state for a hole in a torus as an iris door // Put this script into a flattened torus.
// ----- Global Variables ------------------ integer g_OpenNow; // True (1) if iris is 'open' now
default { on_rez(integer param) { llResetScript(); } state_entry() { if (g_OpenNow == TRUE) // Prim is in open state, so calculate new 'closed' size { state WaitToClose; } else // Prim is in a closed (or undefined state), so calculate new 'open' size { g_OpenNow = FALSE; state WaitToOpen; } } } state WaitToClose // Iris is Open, and waiting to close { touch_start(integer total_number) { llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]); g_OpenNow = FALSE; state WaitToOpen; } }
state WaitToOpen // Iris is closed, and waiting to open { touch_start(integer total_number) { llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.05, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]); g_OpenNow = TRUE; state WaitToClose; } } Did I miss anything obvious, or use any completely unnecessary code? Anything I can/should improve before adding this to the Scripting Library?
_____________________
Sorry, LL won't let me tell you where I sell my textures and where I offer my services as a sim builder. Ask me in-world.
|
Shack Dougall
self become: Object new
Join date: 9 Aug 2004
Posts: 1,028
|
07-21-2006 16:16
From: Ceera Murakami Yay! My first try worked!
..code...
Did I miss anything obvious, or use any completely unnecessary code? Anything I can/should improve before adding this to the Scripting Library? Well, you could have it move gradually from open to closed using a loop. llSetPrimitiveParams() has a 0.2 second delay built in. So, it limits the speed and the smoothness with which you can have it open/close gradually. But that can be circumvented by using more than one script.
_____________________
Prim Composer for 3dsMax -- complete offline builder for prims and sculpties in 3ds Max http://liferain.com/downloads/primcomposer/
Hierarchical Prim Archive (HPA) -- HPA is is a fully-documented, platform-independent specification for storing and transferring builds between Second Life-compatible platforms and tools. https://liferain.com/projects/hpa
|
Ceera Murakami
Texture Artist / Builder
Join date: 9 Sep 2005
Posts: 7,750
|
07-25-2006 08:15
Well, I have submitted the script to the Script Library, and it's pending moderator approval.
I'll be doing some additional tests and refinments later this week. The initial script assumes the door will be a simple flat oval or circle - a torus flattened on the axis of the hole, and rotated and streached as needed to make the door shape. I found that a 2.5M x 1.5M oval worked rather pleasantly for a door, and I set that in a wall panel that had a similar oval hole in it.
For other shapes... The code has values for holeshape, cut, hollow, twist, holesize, topshear, profilecut, taper, revolutions, radiusoffset, and skew. If the prim you use for the actual door adjusts any of these parameters from the defaults, you'll need to add those changes in the appropriate fields as well. One use for this might be to make an iris-opening archway, using half a torus, and specifying parameters for "Cut". Again, I'll do some experiments and will add the modified versions to the script in the library.
I'll also play with a variation that will use five or ten stepped changes in a row, rather than a single command, to get a more smoothly 'opening' variation.
Eventually I may borrow an idea from the "Deluxe Door" script, and add code so if the script is dropped into a default prim shape, it will detect the shape used and turn the prim into a door of that shape. But for now, I'm keeping it simple.
_____________________
Sorry, LL won't let me tell you where I sell my textures and where I offer my services as a sim builder. Ask me in-world.
|
Wicc Cunningham
Registered User
Join date: 25 Jun 2004
Posts: 52
|
07-25-2006 08:33
I've tried to get a smooth gradual open and close using a loop. It worked but looked really bad. So just went with open and close. From what I've read in the wiki and forum posts on it, it's just really difficult to do with the built in delay. I currently have and iris door for sale that detects the prim it's in and creates it's opening based on the prim. Plus a bunch of other features. Custom opening, access lists, etc... I'm not sure there are any original ideas anymore in SL. I wonder sometimes if it's worth trying to create something when hundreds of others have done the same thing just slightly different. (Sorry, SL disillusion coming through there...)
|
Ceera Murakami
Texture Artist / Builder
Join date: 9 Sep 2005
Posts: 7,750
|
07-25-2006 12:16
Well, my script is just a very simple one. Honestly, if I wanted one with access lists and the like, I might well seek to pay for your version. It would save me a lot of time over developing it myself.
A lot of parallel development can and does happen in SL. In many cases, people may be completely unaware of the existance of a similar product. Or in some cases, they may be very aware of the competition, but may desire certain features that the previous product does not offer.
I wrote my script because I needed a way to open up a 'knothole' as a door for a custom, organic-looking build. So far I have made a door shaped like a branch stub (2 prims), and a window in a knothole (3 prims, counting a transparent thin panel of 'glass' that is revealed when the knothole opens).
_____________________
Sorry, LL won't let me tell you where I sell my textures and where I offer my services as a sim builder. Ask me in-world.
|
Ceera Murakami
Texture Artist / Builder
Join date: 9 Sep 2005
Posts: 7,750
|
07-25-2006 14:37
The script is in the Script Library now. Please move further discussion to the designated discussion thread for the released version.
_____________________
Sorry, LL won't let me tell you where I sell my textures and where I offer my services as a sim builder. Ask me in-world.
|