Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rezzing objects facing another object?

Luc Aubret
Oreo-eater
Join date: 14 Sep 2005
Posts: 86
11-26-2005 22:35
I'm trying to get an object (say, ObjectA) to sense another object (ObjectB), and rez an object (Object C) between them. This much was simple. However, where I'm stumped is trying to set the math so that ObjectC has its largest face (it's a flat square) facing ObjectB.

That's convoluted. For anyone who has seen, say, the Sion shield, that shield does what I'm trying to do, basically, by rezzing convex circles between an oncoming object and the av it's headed towards. I'm sorta trying to replicate that effect for different purposes.

Again, it's the rotational math that's bugging me on this, and not the pos vector. Can anyone get me started in the right direction?
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
11-27-2005 01:10
Here's something that might help:

CODE

// AXIS_* constants, represent the unit vector 1 meter along the specified axis.
vector AXIS_UP = <0,0,1>;
vector AXIS_LEFT = <0,1,0>;
vector AXIS_FWD = <1,0,0>;

// getRotToPointAxisAt()
// Gets the rotation to point the specified axis at the specified position.
// @param axis The axis to point. Easiest to just use an AXIS_* constant.
// @param target The target, in region-local coordinates, to point the axis at.
// @return The rotation necessary to point axis at target.
rotation getRotToPointAxisAt(vector axis, vector target)
{
return llGetRot() * llRotBetween(axis * llGetRot(), target - llGetPos());
}
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm
Jokey Domela
Registered User
Join date: 27 Jul 2005
Posts: 83
11-27-2005 06:18
If you're making a shield, you've probably already picked off the object coming towards you with a sensor, so you should know WHAT the object is that is coming towards you.

Have you tried llRotLookAt??

http://secondlife.com/badgeo/wakka.php?wakka=llRotLookAt
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
11-27-2005 07:39
Just a thought:

If you used a big, hollowed sphere with whatever cuts/dimples you like to make it look nice you could skip the positioning of it.
_____________________
Luc Aubret
Oreo-eater
Join date: 14 Sep 2005
Posts: 86
11-27-2005 14:45
I'm not actually making a shield, LOL. I just meant that the Sion Shield does this same thing - rezzing an object that is rotated to face the target.

llRotLookAt is great, but it acts on the object after it is rezzed and sensing already all by itself. I want the objec to be rezzed - non-physical - and already facing the sensed object.
Jokey Domela
Registered User
Join date: 27 Jul 2005
Posts: 83
11-27-2005 15:34
Is Object A allowed to face Object B?

If so, use the llRotLookAt on Object A, then you'll be able to get the params using something like llGetRot or llGetPrimitiveParams to use in your llRezObject for rezzing object C.

If you cant rotate object A, how about an inviso prim that you can just use as a reference?
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
11-27-2005 15:52
I think what Luc is looking for is the maths to calculate the rotation from the two position vectors. I shouldn't think that's too difficult, but my 3D maths is shabby at best.
_____________________
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
11-27-2005 16:27
From: AJ DaSilva
I think what Luc is looking for is the maths to calculate the rotation from the two position vectors. I shouldn't think that's too difficult, but my 3D maths is shabby at best.

Chris' code should work.

CODE
ZERO_ROTATION * llRotBetween( ( llRot2Up( ZERO_ROTATION ) ) * ZERO_ROTATION, llDetectedPos() - llGetPos() )
in the rotation value of the llRezObject call should work. I'm not in world to test atm though.
_____________________
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
11-27-2005 16:30
Good point. Just saw the llGetRot()s and skipped over it. :rolleyes:
_____________________
Luc Aubret
Oreo-eater
Join date: 14 Sep 2005
Posts: 86
11-27-2005 22:23
I'll give Chris' code a shot and report back.

Of course, my report will probably be flavoured by the fact that I am simply not that bright.

Thanks, Chris!
Luc Aubret
Oreo-eater
Join date: 14 Sep 2005
Posts: 86
11-28-2005 10:00
Okay... this is what my script-kiddie-like implementation of this script has wrought...

The plates do consistently rez at an angle to the target that seems to be based on the target's location in relation to the rezzing object's. But that rotation is not facing the target, but rather at an odd angle to the target.
Luc Aubret
Oreo-eater
Join date: 14 Sep 2005
Posts: 86
11-28-2005 22:02
Any suggestions about how I might adjust this rotation, perhaps to account for the object's natural shape? I'm not sure how to find the offset between what the computation thinks the object's natural axis are, and what the actual prim's axis are.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
11-29-2005 03:07
For figuring out the orientation for odd-looking shapes, I just rez one, orient it so it "looks right", and then read off the Euler orientation from the object tab. Then a quick translation to Radians and conversion to rotation can be most conveniently done in the script...