Simulate rising or falling liquid level
|
Rick Stradale
Registered User
Join date: 2 Nov 2008
Posts: 4
|
01-04-2010 20:43
I've searched as best as I could to find the best way to approach solving this problem. I'd really appreciate any help to put me on track. I'm trying to simulate a vessel (object) containing a fluid of a certain level. The fluid may rise and fall based on the messages from another object. (Ignore that part of the problem for now.) I just want to be able to solve to first part of the problem..how to script a vessel containing a liquid and the liquid may rise or fall. Attempt #1 Try what seems easiest. If I could have a totally transparent object and colour more of it (to show filling) or less of it (to show falling level). Is it possible to partially colour an object while leaving a portion un coloured? It did not seem possible which brings me to:
Attempt # 2 Use a transparent object to represent the vessel and another object inside to represent the liquid. I tried a hollowed out cylinder (as the vessel) and put a complete cylinder (as the liquid level. That does not look right as I manually lined up both cylinders. If I pursue this thinking will it bear fruit?
I'm trying to learn LSL, but there is a large jump in level of the tutorials after the basics are covered.
I'm trying to take it all in by creating problems that I can commit to solving.
Thanks in advance for any takers Sincerely, Rick
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
01-04-2010 21:14
The easiest way is probably to animate a texture on the side of a cylinder. Take a look at http://wiki.secondlife.com/wiki/LlSetTextureAnim and see if you can figure out how to do it.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
Rick Stradale
Registered User
Join date: 2 Nov 2008
Posts: 4
|
Thanks for the response
01-04-2010 21:49
A very useful link! Although the texture seems to wrap about the entire surface so that I'm not fully getting the illusion that I'm looking for. Is there a way to get a texture to partially cover a surface? I'll have to look into sides as they apply to a cylinder. Thanks again, Rolig Rick
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
01-04-2010 22:00
You could color a texture 1/2 transparent, 1/2 blue for example, then modify the vertical scaling of the texture which would cause the blue portion to go up or down depending on which direction you were moving it.
|
Rick Stradale
Registered User
Join date: 2 Nov 2008
Posts: 4
|
01-04-2010 22:48
From: Johan Laurasia You could color a texture 1/2 transparent, 1/2 blue for example, then modify the vertical scaling of the texture which would cause the blue portion to go up or down depending on which direction you were moving it. Yup...that did it! Thanks for all the help Johan and Rolig. I can sleep now lol!
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
01-05-2010 06:31
What Johan is suggesting is actually a second way, just as good as using llSetTextureAnim. To make his method work, you'd apply the 1/2 transparent texture to your prims and then change the scaling of the texture with llSetPrimitiveParams([PRIM_TEXTURE ..... Change the texture repeats incrementally in a loop to get the effect. (See http://wiki.secondlife.com/wiki/LlSetPrimitiveParams.) Each method its advantages. Using llSetTextureAnimation will probably give you a smoother-looking effect, but you can only animate one side (or ALL_SIDES) of the prim. That's fine on a cylinder, but you can't animate the sides of a cube, for example, without also animating the top and bottom. Using llSetPrimitiveParams gives you more flexibility in that regard, but it's clunkier to script and not likely to look quite as smooth in execution unless you use a lot of steps. Still, it's nice to have more than one possible solution to any challenge.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-05-2010 09:55
I'm still partial to the 2 cylinders model, perhaps with partial transparency on the liquid too (although pouring may be harder to simulate) with a half sliced cylinder.
depending on what you're doing, it's possible to have two of them facing each other and overlapping letting the upper one move smoothly up via move to target, and then expand down to make sure the next rise doesn't separate the overlap
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
Rick Stradale
Registered User
Join date: 2 Nov 2008
Posts: 4
|
01-05-2010 19:51
From: Void Singer I'm still partial to the 2 cylinders model, perhaps with partial transparency on the liquid too (although pouring may be harder to simulate) with a half sliced cylinder.
depending on what you're doing, it's possible to have two of them facing each other and overlapping letting the upper one move smoothly up via move to target, and then expand down to make sure the next rise doesn't separate the overlap I'll explore this option more deeply as soon as time permits, because I'm still feeling out a lot of the functions and now starting to make sense of the tutorial scripts. In the meantime, I'll focus on the texture approach for the learning I can get out of it. When I have something meaningful you guys will be the first to know...
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
01-06-2010 01:21
Glad to be of help. @Rolig: Yeah, you're right that a smooth animation would be smoother, but as you said, harder to control where exactly you're going to get animation. @Void: Heh, I beat ya to the punch for a change... 
|
Dekka Raymaker
thinking very hard
Join date: 4 Feb 2007
Posts: 3,898
|
01-06-2010 08:56
I use this, not perfect but a good illusion: 
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-06-2010 12:11
From: Johan Laurasia @Void: Heh, I beat ya to the punch for a change...  =)
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
Dixie Sixpence
Registered User
Join date: 3 Sep 2009
Posts: 1
|
Simulate rising or falling liquid level
01-20-2010 11:04
you may be able to stack prims on top of each other inside the vessel and use apha script with a percentage menu allowing you to choose how full or how empty the vessel is.
with each slice you can make the color apear this would be heavy prim and scripted tho only other way would be to use a curtain script on the inside cylinder but your control for filling would be limited
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
01-20-2010 12:17
Yes, that would work too. There's almost always more than one way to approach a challenge, and it's nice to play with several to see what you like best.
Personally, I'd shy away from a solution that is going to be prim-heavy and -- unless you use LOTS of prims -- one that's going to make the simulated water level jump up or down in spurts instead of doing it smoothly. It would certainly work, though. As for the other suggestion, a curtain script, that's essentially what Void was leaning toward.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|