Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Looking for a way to determine coordinates of an object

Jexx Rayner
Registered User
Join date: 30 Jun 2006
Posts: 16
02-23-2007 23:08
Hey folks, I suspect what I am trying to learn to do is easy and I'm just missing something, so please don't thump me too hard. ;)

I have object A, a rod and object B, a slider, I want to have a script position object B at one end of object A and then slide down to the other end. I have the code working to do the sliding given known the start and end positions (testing), but I cannot figure out how to determine the two endpoints of the rod.

I tried using simple equations based on llGetPos() and llGetScale() to help me, but haven't gotten it right.

I'd appreciate if anyone can shed some light on this or point me in the right direction.

Thank you,
Jexx
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-24-2007 00:01
llGetPos will give you the centre cooridante of the object.
llGetRot will give you its rotation
llGetScale will give you its sizes

Any endpoint of a rod will be 1/2 of the Xscale size from the centre
(assuming you have made a rod with a default rotation!)

All you should need do is take into account the object rotation.

CODE

default
{
touch_start(integer total_number)
{
vector position = llGetPos();
vector scale = llGetScale() / 2;
// We are only interested in the X alignment
scale.z = 0;
scale.y = 0;
rotation rot = llGetRot();
vector delta = scale * rot;
vector endA = position + delta;
vector endB = position - delta;
llRezObject("Object",endA,ZERO_VECTOR, rot, 0);
llRezObject("Object",endB,ZERO_VECTOR, rot, 0);
}
}
Jexx Rayner
Registered User
Join date: 30 Jun 2006
Posts: 16
02-24-2007 10:47
A couple of problems but for the most part this helps alot, I can see the procedure now at least...

Problem 1: I create a basic cylinder and then stretch the ends to make a rod, but for some reason the script puts the two rezzed objects in the middle of the rod but on the top and bottom, this ascii picture describes it ( sorry for my bad ascii artwork )

O
RRRRRRRRRRRRRRRRRRRRRR
O

If I tweak the object to stabilize the X and Y axes instead and only use Z for the endpoints it works and produces the desired result


ORRRRRRRRRRRRRRRRRRRRRO

Problem 2: The object/script you put in my inventory doesn't run, it gives me a permission error popup, not a big deal though and I appreciate the example. :)


All in all I can make the script work by tweaking which axis to use but I am curious as to why the X-axis isn't the right one (for me anyway), it certainly seems to be the one I'd want to use for the endpoints.


I greatly appreciate your help regardless of the axis issue, thank you very much!

-Jexx
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-24-2007 12:00
hmmm, Well the script wporked correctly for me, no idea why it doesnt for you. Your description of your solution sounds like the alignment was rotated. When you rez a tube it will be aligned along the x axis not the Z

Again no idea why the object I dropped on you didnt work.Especially as it doesnt use permissions at all.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-25-2007 01:17
Update: The reason the object I dropped oin Jexx didnt work was becasue the inventory object was set to no copy. Having corrected that and redropped it all was ok.