Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rez path from point a to point b

Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
10-23-2007 12:52
I am trying to create a rezzer that will join point A to point B with prims. I've had a look at the path maker script /15/5d/92495/1.html but this seems far to complicated for what i need and is based on the wrong shape of prim.

Basically I want a rezzer that will create a line of cylinders from itself to a another prim. I can get the positions and rotations needed but what I'm lacking is the LLRezObject parameters to get the cylinders to join the two points.

I know i need to get the distance between the two points and get the script to work out how many prims are needed but I am lost beyond that.

I don't want a free script unless anyone has one they want to share, I just need to be pointed in the right direction. Anyone tackled this sort of thing before or know where I should start?
_____________________
Tread softly upon the Earth for you walk on my face.
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
10-23-2007 14:31
If you know the two positions then you can check the distance between with llVecDist, if your distance is less than 10 use one prim, between 10 and 20 two prims etc.
With the known number of prims you can find the centres for the prims by dividing the vector distance by double the number of prims (i.e. 1 prim is 1/2 the distance, 2 prims 1/4, 3 prims 1/6, 4 prims 1/8). Multiply that by the rotation between the two points (llRotBetween) then add the vector for the first position and you get your first prim centre with llRotBetween being your prim's rotation (multiplied by a rotation if it's not the x-axis you want pointing towards the target). For the next prim along (if there is one), add the prim length to the fractioned distance, i.e. for a 20m span, 2 prims of 10m, first prim centre is 5m from the start vector, the second would then be 15m. Rinse and repeat.
_____________________
www.nandnerd.info
http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
10-23-2007 14:43
fantastic nand. Thanks for the help and not a bunch of code. Means I can actually work it out and might learn something in the process.

Genuine thanks and NOT sarcasm.

Now if I can just get my head round the maths and what order to make all these calls in I'm in business :)
_____________________
Tread softly upon the Earth for you walk on my face.
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
10-23-2007 16:05
If you wanted to get really fancy, you'd make it plot along a NURBS path :)
_____________________
Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
10-23-2007 17:33
ok I don't want to get too fancy. I'm only after straight lines. The problem I'm having is getting the llRotBetween to return a useable value. I'm converting the return of the llRotBetween to a euler so I can use that with the rez position. Trouble is I don't think the values are right.

Up to that point things are ok and I'm getting sensible returns on things but from there it goes a bit funny. Whats the best way to get a useable vector for positional work from the llRotBetween?

CODE

//Rez objects between two points

default
{
state_entry()
{
}
touch_start(integer num_detected)

{
vector posA = llGetPos(); // rezzer position
//llSay(0, "posA is " + (string)posA);

vector posB = <63.0,120.0,25.0>; //end position

float gap = llVecDist(posA, posB); //distance between points
//llSay(0, "gap is " + (string)gap);

integer prims = llCeil(gap / 10); //number of prims to fill gap
//llSay(0, "prims is " +(string)prims);

float length = gap / prims; // length for each prim
//llSay(0, "length is " + (string)length);

float center = gap / 2 / prims; //center of each prim
//llSay(0, "center is " + (string)center);

rotation rot = llRotBetween(posA, posB);
//llSay(0, "rot is " + (string)rot);

vector euler = llRot2Euler(rot);
//llSay(0, "euler is " + (string)euler);

vector rez_pos = center * euler + posA;
//llSay(0, "rez_pos is " +(string)rez_pos);

integer x = 0;
// llSay(0, "x is " + (string)x);

do

{
llRezObject("Temp Object", rez_pos, ZERO_VECTOR, rot, 42); // where to rez each prim
center = center + length;
x = x + 1;
rez_pos = center * euler + posA;
//llSay(0, "rez_pos is " +(string)rez_pos);
//llSay(0, "center is " + (string)center);
//llSay(0, "x is " + (string)x);
}
while (x < prims);

llResetScript();
}
}
_____________________
Tread softly upon the Earth for you walk on my face.
Saskia McLaglen
Registered User
Join date: 18 Jan 2007
Posts: 21
10-24-2007 03:10
Hi Django

I have made a zip-line that rezzes a line between point a (the base support) to point b (top support) rezzing the line piece by piece along the path between the points until it reaches the top. There is a relatively simple function using llRotBetween and llLookAt at

[urlhttp://rpgstats.com/wiki/index.php?title=LlLookAt[/url]

which I use to work out the path the line needs to rez along, point the base rezzer along this line and rez out line pieces until they reach the top using the rotation returned by the code above as part of the llRezObject rotation parameter.

I am not in-world right now to check if it is purely that rotation I use, or a factor of it. I can check later if thats of help to you.

It is running from the top of the tower in Discordia if you want a ride :)
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
10-24-2007 03:20
From: Django Yifu
fantastic nand. Thanks for the help and not a bunch of code. Means I can actually work it out and might learn something in the process.

I started writing out the code then deleted it seeing as you explicitly didn't want any.

From: Django Yifu

ok I don't want to get too fancy. I'm only after straight lines. The problem I'm having is getting the llRotBetween to return a useable value. I'm converting the return of the llRotBetween to a euler so I can use that with the rez position. Trouble is I don't think the values are right.

Up to that point things are ok and I'm getting sensible returns on things but from there it goes a bit funny. Whats the best way to get a useable vector for positional work from the llRotBetween?


You're working against yourself on this one. Keep the llRotBetween as a quat rotation and use that, turning into Euler only helps you read the values, it's of little to no use for the script. The line vector rez_pos = center * euler + posA; should read vector rez_pos = centre * rot + posA; (or perhaps rot * center, but you get the idea). Other than that it looks just like the code I started writing, even got the llCeil in there =D
_____________________
www.nandnerd.info
http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
10-24-2007 08:40
Thanks Saskia for pointing me to that page. I had found it and lost it again. It just so happens I am creating exactly the same object as you, a zip line. Funny how these things happen.

Nand, I tried rez_pos = center * rot + posA originally and got a type error when I compiled the code. That's why I assumed I needed to convert to a euler as I was returning a quaternian and thought that wouldn't fit into the command. I'll try it again both ways.

The trouble I have now is making the llRezObject work at further than 10m. Am I better rezzing and moving the parts for the line or having the parts self replicate along the same vector as the original until they reach the end point?

And thanks for not posting the code. I have spent so long deconstructing other peoples code I am beginning to see where the holes in my knowledge are and am trying to plug them :)

Just had a thought, maybe i could move the path rezzer along the path at each iteration of the rez command making it then always rez within 10m. Would mean a change of the way I am checking lengths and iterations but might be a bit easier.
_____________________
Tread softly upon the Earth for you walk on my face.
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
10-24-2007 11:06
You seem to have the right ideas, just run through the pros and cons of different methods.

And for the rotation of a vector:
From: LSL Wiki
When rotating a vector, the rotation must appear to the right of the vector:
vector new_vec = old_vec * x_45; // compiles
vector new_v = x_45 * old_v; // doesn't compile

Where x_45 is a rotation and old_v is a vector.
http://www.lslwiki.net/lslwiki/wakka.php?wakka=rotation

Sometimes it's not about knowing all, it's just about knowing where to look. Unfortunately there's no longer a single wiki to find all the answers at so it takes a little more searching around between different sources.
_____________________
www.nandnerd.info
http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
Saskia McLaglen
Registered User
Join date: 18 Jan 2007
Posts: 21
10-24-2007 11:19
From: Django Yifu

The trouble I have now is making the llRezObject work at further than 10m. Am I better rezzing and moving the parts for the line or having the parts self replicate along the same vector as the original until they reach the end point?


I have my line segments self-replicate and check to see if they are at the destination, if so then stop, else rez another.

Compared with your thoughts on it, I don't know that one method is better than the other, just different :)
Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
10-24-2007 12:28
thanks again guys.

With all the help I am definately on the right track, I think I will go with the self replicating objects, with adequate failsafes of course. I looked at the rez to target function in the forum but the maths is a bit beyond me and seemed more complicated than necessary for this project.

ps your zip-line is immensly fun Saskia, my only comment on that would be to use a different camera angle, I just love seeing the avi swing around on it rather than in mouselook. Having said that the slorb run I made at Beat Island is much more fun in mouselook so i get why you've used that.
_____________________
Tread softly upon the Earth for you walk on my face.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-24-2007 15:12
I personally would have probably used self replication myself, just because it is cool as heck. Try building a 4,000 meter tower in beta with it sometime. WOOT.

But this thread will give you an alternative way to rez all of the objects from one script past 10 meters:

/54/d5/76793/1.html
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
10-24-2007 19:25
Jesse. I had actually dug that post up out of the forums and it appears more has been added since I asked for some clarification. I agree self replicators are cool. I like just watching them build away. I'm also using some linking to allow setlinkprimitiveparams on the object_rez of each replicator. This helps trim the lengths of the parts in a dynbamic way.

I stilll have a load of bugs to work out but it's pretty much done and works over quite big distances...with a few errors creeping in due to link limits.


Saskia I'd be interested to know what sort of length information you pass to your line segments and what distances you've had it work over.

I now want to implement some commands to allow me to un rez everything in case of poor positioning to begin with and lock the final pieces then remove the scripts but thats icing on the cake for now.
_____________________
Tread softly upon the Earth for you walk on my face.
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
10-25-2007 00:49
From: Django Yifu
Saskia I'd be interested to know what sort of length information you pass to your line segments and what distances you've had it work over.

Personally if going down this route I'd have the first prim take up the slack and have subsequent prims of 10m each, i.e. for a length of 24.31m the first prim is 4.31m leaving two full 10m prims.

From: Django Yifu
I now want to implement some commands to allow me to un rez everything in case of poor positioning to begin with and lock the final pieces then remove the scripts but thats icing on the cake for now.

Especially important if using self-replicating prims, last thing you want is a mis-calculation and they never reach their target but continue on rezzing. A listen for owner only on a non-zero channel with commands for die/delete calling llDie() and empty/lock calling llRemoveScripts(llGetScriptName()) should suffice.
_____________________
www.nandnerd.info
http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
Saskia McLaglen
Registered User
Join date: 18 Jan 2007
Posts: 21
10-25-2007 02:25
From: Django Yifu


Saskia I'd be interested to know what sort of length information you pass to your line segments and what distances you've had it work over.

I now want to implement some commands to allow me to un rez everything in case of poor positioning to begin with and lock the final pieces then remove the scripts but thats icing on the cake for now.


As you may have noticed, I have a rather untidy amount of excess at one end ;) I don't pass any length information over to the line, 10m segments are rezzed out until they reach the top end (detected by a sensor).

I initially did this as a fun thing to have as an installation at a friends party. I have yet to get back to work on it to tidy it up. I would agree with nand on using the first part of the line to take up the slack in the line, and I use a tight filtered listen to kill it off.

I have had it rez out over about 200m, i am not sure to be honest, from about 150m high passing diagonally across most of a region. I really want to have it from my plat at 700m to the ground, but the air space is a lil crowded. I am sure I could make some space though if you fancy a rez race to the top and a slide to the ground again :)
Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
10-25-2007 05:10
Thanks every one for your amazing help. I have finally got the zip line working with accurate lengths and a self replicating line. The two end points line up and the zip line is linked (depending on lengths). The self replication is under control without additional listens as it uses link permissions. If anything goes wrong I can just deny the run time permission request and the line stops self replicating and problems can be fixed before setting it off again.

Nand I wish I had thought of scaling only the first segment to begin with, simplified the whole process and made a doddle out of the maths. When I have it installed people are welcome to come and have a play.

Here is the script I use for the self replicator

prolly not the most concise or elegent but it gets the job done

CODE

//creates self replicating cylinder between two points. Links rezzed objects using runtime perms

//by Django Yifu

// with help from Saskia McLaglen, nand Nerd and Jesse Barnett

//feel free to duplicate alter and distribute this script as you see fit just don't charge for the script alone

default
{
on_rez(integer start_param)
{
llSleep(5);
llListen(251176,"","","");
llRequestPermissions(llGetOwner(), PERMISSION_CHANGE_LINKS);
}
run_time_permissions(integer perm)

{if (perm & PERMISSION_CHANGE_LINKS)
{
llRegionSay(251177, "where");}
}

listen(integer channel, string name, key id, string message)
{

vector posB = (vector)message;

//vector size = llGetScale();
//llSay(0, "size is" + (string)size);

//float length = size.z;
///llSay(0, "length is" +(string)length);


vector pos = llGetPos();
llSay(0, "pos is" +(string)pos);

vector size = llGetScale();

float length = size.z;

float offset = length / 2 + 5;

vector rez_pos = pos + <0.0,0.0,offset> * llGetRot();
llSay(0, " rez_pos is " +(string)rez_pos);



vector posBloc = posB / llGetRot();
llSay(0, "posBloc is " + (string)posBloc);

vector rez_posloc = rez_pos / llGetRot();
llSay(0, "rez_posloc is " + (string)rez_posloc);

float distance = posBloc.z - rez_posloc.z;
llSay(0, "distance is " + (string)distance);



if (distance <= 0.0)
{


integer linknum = llGetLinkNumber();
llSay(0, "won't rez");
llRegionSay(251199,"end reached");
llSetScriptState("Zip Line Rope Self Replicator", FALSE);
}
else
{
llSay(0, "will rez");
llRezObject("Zip Line Rope", rez_pos, <0,0,0>,llGetRot(), llGetStartParameter());


}
}
object_rez(key id)
{
llGiveInventory(id, "Zip Line Rope");
integer linknum = llGetLinkNumber();
llCreateLink(id,FALSE);
llSay(0,"change size");
llSetScriptState("Zip Line Rope Self Replicator", FALSE);

}
}
_____________________
Tread softly upon the Earth for you walk on my face.
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
10-25-2007 06:16
From: Django Yifu

Nand I wish I had thought of scaling only the first segment to begin with, simplified the whole process and made a doddle out of the maths. When I have it installed people are welcome to come and have a play.


I probably would have gone down the communications route if I had done it myself but since you asked the right question a better solution popped into my head.

Sign me up for a go! (Give me a shout in-world once you've got it all set up).
_____________________
www.nandnerd.info
http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
10-26-2007 15:45
Well as promised here's the LM for the zip-line. Not as physical as Saskias perhaps but a good way of getting from A to B.
Beat Island (200, 60, 44)
_____________________
Tread softly upon the Earth for you walk on my face.
Saskia McLaglen
Registered User
Join date: 18 Jan 2007
Posts: 21
10-26-2007 16:24
YES!!! That is awesome Django :D a great little sound you have for it too! I had to go back for many goes on that :) Yeah, mine currently relies just on gravity to get you down with a fair old bit of wobbling as well ^_^
Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
10-27-2007 06:05
Glad you liked it Saskia. It's just an llApplyImpulse * by llGetMass to give it the force on a floating ring. The line is actually phantom so only there for cosmetics really :)

I may create a version that uses gravity but that only seems to work on very steep lines.
_____________________
Tread softly upon the Earth for you walk on my face.