Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Adjusting Offset llGround Calls by Facing

Kage Seraph
I Dig Giant Mecha
Join date: 3 Nov 2004
Posts: 513
07-13-2006 06:37
Okay, I'll fess up to being a rotation-tarded vehiclemaker. :(

Suppose for a hoverpod that it is useful to know the ground height ahead of the vehicle. That is, it is good to know llGround for the point 3m forward on the vehicle's local x-axis. Calling llGround(<3,0,0>;) gets the ground height at an offset from the task that uses the non-local coord system. E.g., when the vehicle faces north, I'm scanning for groundheight 3m east of the vehicle. For that matter it is always scanning east of the vehicle, when the ultimate goal is to make it scan forward of the vehicle regardless of azimuth.

So how to make llGround's call locally oriented? I have a sneaking suspicion it has something to do with llGetRot & llRot2Fwd but I can't seem to make the pieces fit together properly.
_____________________
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
07-13-2006 08:48
I'm going to assume from what you're saying that your root prim faces east and has the ground sensor in it (that's the easiest way, but I think this will work for non-root prims too).

You want to do llGround(<3.0, 0.0, 0.0> * llGetRot());

That will take the 3m long scan, multiply it by the current rotation (of the root prim) and thus scan ahead based on the rotation of the root.
_____________________
Eloise's MiniMall
Visit Eloise's Minimall
New, smaller footprint, same great materials.

Check out the new blog
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
07-13-2006 09:21
The above should work nicely... alternative with similar results would be

llRot2Fwd( llGetRot() ) * 3.0 // unit vector pointing ahead of object, multiplied to get distance of 3m

note if your object is rotated around its Y axis the vector won't reach fully 3 m out with either approach. If that 3m is crucial, you could use something like

vector forward = llRot2Fwd( llGetRot() );
vector flat_forward = llVecNorm( <forward.x, forward.y, 0.0> ) * 3.0;

(you remove the altitude change, normalize the resulting vector to 1m length, then scale it so it reaches full 3 m out. Then can use it in llGround() call)
Kage Seraph
I Dig Giant Mecha
Join date: 3 Nov 2004
Posts: 513
07-13-2006 09:50
Worked like a charm! Thanks, Eloise!
_____________________
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
07-14-2006 00:04
You're welcome, nice to get a relatively easy one! Hope the rest of the hovercraft comes along nicely too.
_____________________
Eloise's MiniMall
Visit Eloise's Minimall
New, smaller footprint, same great materials.

Check out the new blog
Kage Seraph
I Dig Giant Mecha
Join date: 3 Nov 2004
Posts: 513
07-14-2006 08:20
From: Joannah Cramer
The above should work nicely... alternative with similar results would be

llRot2Fwd( llGetRot() ) * 3.0 // unit vector pointing ahead of object, multiplied to get distance of 3m

note if your object is rotated around its Y axis the vector won't reach fully 3 m out with either approach. If that 3m is crucial, you could use something like

vector forward = llRot2Fwd( llGetRot() );
vector flat_forward = llVecNorm( <forward.x, forward.y, 0.0> ) * 3.0;

(you remove the altitude change, normalize the resulting vector to 1m length, then scale it so it reaches full 3 m out. Then can use it in llGround() call)


Hey, Joannah!

In this particular application, the vehicle has a fairly high vertical attraction efficiency and low tau, so pitching around the y axis isn't much of an issue. But it is important to me to understand what's going on here, so allow me to articulate my understanding of what you've said.

So, first, you get the forward-pointing vector with llRot2Fwd( llGetRot() ), then you strip out the z-component of that ( <forward.x, forward.y, 0.0> ) to get a compass-azimuth-like vector that is flat on the x-y coordinate plane. Finally, you normalize that to get a vector length of one, then scale it up to a length of three. Excellent.

Seeing it all laid out that way, I see it makes a lot of sense. Thanks to you and Eloise both!
_____________________