Problem targeting particles for a shower
|
|
Klaire Larnia
Learner, be gentle....
Join date: 2 Jun 2008
Posts: 41
|
05-31-2009 05:45
Hi. I got a particle shower script which I am using ot make water, but I have a problem with it. I am trying to target the particles at a poseball. But when I do the particles go badly wrong and strange. The target is a ball called "Poser" which is not linked the main test object. The particles seem to bend back on themselves rather than stretch the arc they are flowing on to reach the target. Can anyone tell me if there is a way to correct this. If you can imagine I have water at two places. One above the av, one around foot height. I want the water jets to hit the av as if they are being showered from above and below. My idea is to have two invisable targers which the water aims at and then a poseball in the middle with a shower anim in it. The lower target will be around ankel height. I tried to upload a picutre to show you but it fails Anyhow here is the code, if anyone can help I would appreicate it. // Mask Flags - set to TRUE to enable integer glow = TRUE; // Make the particles glow integer bounce = FALSE; // Make particles bounce on Z plan of object integer interpColor = TRUE; // Go from start to end color integer interpSize = TRUE; // Go from start to end size integer wind = FALSE; // Particles effected by wind integer followSource = TRUE; // Particles follow the source integer followVel = TRUE; // Particles turn to velocity direction
// Choose a pattern from the following: // PSYS_SRC_PATTERN_EXPLODE // PSYS_SRC_PATTERN_DROP // PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY // PSYS_SRC_PATTERN_ANGLE_CONE // PSYS_SRC_PATTERN_ANGLE integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE;
// Select a target for particles to go towards key target = "Poser";
// Particle paramaters float age = 1.5; // Life of each particle float maxSpeed = 1; // Max speed each particle is spit out at float minSpeed = 1; // Min speed each particle is spit out at string texture; // Texture used for particles, default used if blank float startAlpha = 0.0; // Start alpha (transparency) value float endAlpha = 0.3; // End alpha (transparency) value vector startColor = <1,1,1>; // Start color of particles <R,G,B> vector endColor = <1,1,1>; // End color of particles <R,G,B> (if interpColor == TRUE) vector startSize = <.05,0.05,.05>; // Start size of particles vector endSize = <.05,3,.05>; // End size of particles (if interpSize == TRUE) vector push = <0,0,-5>; // Force pushed on particles
// System paramaters float rate = .01; // How fast (rate) to emit particles float radius = 0.0; // Radius to emit particles for BURST pattern integer count = 50; // How many particles to emit per BURST float outerAngle = 0.0; // Outer angle for all ANGLE patterns float innerAngle = 0.3; // Inner angle for all ANGLE patterns vector omega = <0,0,0>; // Rotation of ANGLE patterns around the source float life = 0; // Life in seconds for the system to make particles
// Script variables integer flags;
MakeParticles() { flags = 0; if (target == "owner") target = llGetOwner(); if (target == "self") target = llGetKey(); if (glow) flags = flags | PSYS_PART_EMISSIVE_MASK; if (bounce) flags = flags | PSYS_PART_BOUNCE_MASK; if (interpColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK; if (interpSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK; if (wind) flags = flags | PSYS_PART_WIND_MASK; if (followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK; if (followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK; if (target != "") flags = flags | PSYS_PART_TARGET_POS_MASK;
llParticleSystem([ PSYS_PART_MAX_AGE,age, PSYS_PART_FLAGS,flags, PSYS_PART_START_COLOR, startColor, PSYS_PART_END_COLOR, endColor, PSYS_PART_START_SCALE,startSize, PSYS_PART_END_SCALE,endSize, PSYS_SRC_PATTERN, pattern, PSYS_SRC_BURST_RATE,rate, PSYS_SRC_ACCEL, push, PSYS_SRC_BURST_PART_COUNT,count, PSYS_SRC_BURST_RADIUS,radius, PSYS_SRC_BURST_SPEED_MIN,minSpeed, PSYS_SRC_BURST_SPEED_MAX,maxSpeed, PSYS_SRC_TARGET_KEY,target, PSYS_SRC_INNERANGLE,innerAngle, PSYS_SRC_OUTERANGLE,outerAngle, PSYS_SRC_OMEGA, omega, PSYS_SRC_MAX_AGE, life, PSYS_SRC_TEXTURE, texture, PSYS_PART_START_ALPHA, startAlpha, PSYS_PART_END_ALPHA, endAlpha ]); }
default { state_entry() { llListen( 1, "", "", "showeroff" ); //Set up listener //llSay(0, "Mens Stud Earring Bling On"); MakeParticles(); //Start making particles }
touch_start( integer num ) //Turn particles off when touched { state off; //Switch to the off state } listen( integer chan, string name, key id, string msg ) //Turn particles off when told to { state off; //Switch to the off state } }
state off { state_entry() { llListen( 1, "", "", "showeron" ); //Set up listener //llSay(0, "Mens Stud Earring Bling Off"); llParticleSystem([]); //Stop making particles } touch_start( integer num ) //Turn particles back on when touched { state default; } listen( integer chan, string name, key id, string msg ) //Turn particles on when told to { state default; } }
_____________________
Klaire xXx =^.^= xXx
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
05-31-2009 09:50
The variable "target" is expecting a key and you are giving it a string = "Poser." If you use Poser's UUID instead, it ought to work. BTW, you don't actually need to use a state change to switch particles on and off. You could simplify your script by changing the listen handler to llListen (1, "", NULL_KEY, ""  ; and then let your listen event switch particles on and off depending on the message it gets. First, define a global integer variable ON=FALSE. Then write ... listen (integer channel, string name, key id, string message){ if(message == "showeron"){ ON = TRUE; MakeParticles();} else if (message == "showeroff"){ ON = FALSE; llParticleSystem([]);} } touch_start(integer num){ if (ON){ llParticleSystem([]); } else { MakeParticles();} ON = !ON; }
Barring silly typing errors, that ought to work.
_____________________
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
|
05-31-2009 10:15
"Poser" isn't a valid key, nor is it picked up in the if section (which looks for "owner" and "self"  so it's defaulting to NULL_KEY which IIRC is the same as targeting itself... either leave target blank, or use a valid prim key (that can only be found after that prim is rezed.) ETA: sry phone call interrupted, what Rolig said too =)
_____________________
| | . "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... | - 
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
05-31-2009 10:26
Incidentally, it's mildly clumsy, but you can do a quick workaround to get the Poser object's UUID and insert it into your particle-generating object. All you have to do is write a short script like this ... default { touch_start(integer num) { llSay(-1234,(string)llGetKey()); } }
and drop it into Poser. Then in your main script you add a second listen handler to listen on channel -1234 and you add the following snippet to your listen event .... if (channel == -1234) { target = (key)message; }
Once your poser object has been rezzed, you only have to click it one time to tell your main script what Poser's UUID is.
_____________________
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 
|
|
Klaire Larnia
Learner, be gentle....
Join date: 2 Jun 2008
Posts: 41
|
05-31-2009 10:35
Okay so I made a dumb mistake with using a name and not a key. Silly girl... Thanks for that and also the quick code to get it Rolig Okay. Another question. the particles target right now, but now the particles arc in the reverse direction. particles flow down and then up to the target (as if fliped 180 degrees). Rotating the emitter and the target do nothing. Any ideas or is that a quirk of Sl? Thank you again and sorry to be a total pain in the..... 
_____________________
Klaire xXx =^.^= xXx
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
05-31-2009 10:45
Silly mistakes are part of the fun, a little element of randomness to remind us not to start feeling too cocky. Particles are emitted along the +Z axis of the emiting object. Try turning your object around and see if that does the trick.
_____________________
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 
|
|
Klaire Larnia
Learner, be gentle....
Join date: 2 Jun 2008
Posts: 41
|
05-31-2009 11:01
From: Rolig Loon Silly mistakes are part of the fun, a little element of randomness to remind us not to start feeling too cocky.  . Makes me feel like a pillock at times for not understanding what I am playing with  I am trying to work out my errors now. But sometimes I lack a full concept grasp to know where to look for an error... Thanks
_____________________
Klaire xXx =^.^= xXx
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
05-31-2009 11:20
change vector push = <0,0,-5>; // Force pushed on particles
to vector push = <0,0,0>; // Force pushed on particles
alternately you could set that as a relative offset, and set target as ""
_____________________
| | . "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... | - 
|
|
Klaire Larnia
Learner, be gentle....
Join date: 2 Jun 2008
Posts: 41
|
05-31-2009 11:32
Thanks Void. Okay last of my dumb questions for today (and I bet you are both gald)...
I notce that un-targeted the particles flow in a cone shape - which for a shower is ideal. Targeted they just stream to a point - which makes sense as you are telling them to head for a specific point.
Now my guess is that if you want to maintain the cone shape you cannot target them in this fashion and would need to manually adjust the angle at which they are emitted and arc.
Am I right on this point?
_____________________
Klaire xXx =^.^= xXx
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
05-31-2009 11:54
That seems logical, but I'd have to go in world to test and be sure. The best way to figure out how particles work is to spend an afternoon some time at the Particle Laboratory. If you play with every one of the demos until you understand how the variables function independently, it will be time well spent. Also, pick up a copy of each of the control and filter scripts and the sample particle scripts in the sandbox area. If you mix and match them, and take them apart to see how they tick, you'll be MUCH wiser for 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 
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
05-31-2009 13:09
From: Klaire Larnia Thanks Void. Okay last of my dumb questions for today (and I bet you are both gald)...
I notce that un-targeted the particles flow in a cone shape - which for a shower is ideal. Targeted they just stream to a point - which makes sense as you are telling them to head for a specific point.
Now my guess is that if you want to maintain the cone shape you cannot target them in this fashion and would need to manually adjust the angle at which they are emitted and arc.
Am I right on this point? basically, although if the cone is shaped/sized right for your needs, you just rotate the emitter to face in the direction you want. if you throw in a low acceleration in the direction of emission, (<0.0, 0.0, 0.1> * llGetRot()) it'll normalize the cone to a spread stream (I think) similar to.... the emitter being at the point of a pencil, and the aceleration taking place at the point where it's unsharpened sending it all towards the eraser as a stream (but not to a point at the center of the eraser)
_____________________
| | . "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... | - 
|