Pointing at a point and remaining upright?
|
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
11-24-2006 10:50
Okay, I'm using the llRotLookAt() function to aim the X axis of my object at a point. However, this can often result in my object ending up on its side or upside down. ie, the X axis points at the target, but the rotation of the X axis could be anything, meaning the Y and Z axis could be anywhere.
What I'm looking for is a way to aim the object's X axis at a target vector, while remaining 'upright', ie; the z axis will point as close to upwards as possible (without moving the x-axis).
Hopefully that explains it enough, I can't post pictures just now but will if I need to.
_____________________
Computer (Mac Pro): 2 x Quad Core 3.2ghz Xeon 10gb DDR2 800mhz FB-DIMMS 4 x 750gb, 32mb cache hard-drives (RAID-0/striped) NVidia GeForce 8800GT (512mb)
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
11-24-2006 11:02
llSetStatus(STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);
_____________________
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
|
|
Raeyan Aldrich
Registered User
Join date: 14 Oct 2006
Posts: 44
|
11-24-2006 17:24
actually jesse im 99% sure you need to prevent rotation of X and Y... rotation around the z-axis will allow the object to spin on the horizontal plane only... 
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
11-24-2006 18:21
From: Raeyan Aldrich actually jesse im 99% sure you need to prevent rotation of X and Y... rotation around the z-axis will allow the object to spin on the horizontal plane only...  I would be 100% sure that I don't know. heehee. Haven't tried it in world. Just in case; Haravikk you can lock any combination of the 3 axis as needed.
_____________________
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
|
|
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
|
11-24-2006 19:22
rotation upright_point_at(vector target) { vector fwd = llVecNorm(target); vector left = llVecNorm(<0,0,1> % fwd); vector up = fwd % left; return llAxes2Rot(fwd, left, up); } I'm pretty sure this will do what you want.
_____________________
-Seifert Surface 2G!tGLf 2nLt9cG
|
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
11-26-2006 05:21
Thanks Seifert that works perfectly after I subtract llGetPos() from the target! Thanks Jesse as well, but I should have said that my object isn't always physical, so disabling some rotations seems to give some odd behaviour, but thanks for suggesting 
_____________________
Computer (Mac Pro): 2 x Quad Core 3.2ghz Xeon 10gb DDR2 800mhz FB-DIMMS 4 x 750gb, 32mb cache hard-drives (RAID-0/striped) NVidia GeForce 8800GT (512mb)
|
|
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
|
11-26-2006 12:46
From: Haravikk Mistral Thanks Seifert that works perfectly after I subtract llGetPos() from the target! Ah, yeah, I should have said, "target" is a direction rather than a position, so yes, target_pos - llGetPos() will give you the direction. Incidentally, if it is at all possible for the target direction to be vertically up or down then the script could behave strangely, maybe crash. This may never show up, but might be worth checking for.
_____________________
-Seifert Surface 2G!tGLf 2nLt9cG
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
11-26-2006 14:32
I don't know, I usually just take the simple approach. targetDirection = targetPosition - llGetPos(); targetDirection.z = 0.0; point_forward_axis_in_direction(targetDirection);
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
|
11-26-2006 15:55
From: Ordinal Malaprop I don't know, I usually just take the simple approach. targetDirection = targetPosition - llGetPos(); targetDirection.z = 0.0; point_forward_axis_in_direction(targetDirection);
This will only make the object point along the x-y plane, so the object's forward axis doesn't 'pitch,' right? Seifert's (I think) will let it pitch as if vertical attraction were enabled for only the rolling axis.
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
11-26-2006 16:50
You know, you're quite right, I misunderstood the question.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
11-27-2006 01:53
From: Seifert Surface Incidentally, if it is at all possible for the target direction to be vertically up or down then the script could behave strangely, maybe crash. This may never show up, but might be worth checking for. Ah, fortunately not too much extra work for this script, and since it may happen it will be worth looking out for, cheers.
_____________________
Computer (Mac Pro): 2 x Quad Core 3.2ghz Xeon 10gb DDR2 800mhz FB-DIMMS 4 x 750gb, 32mb cache hard-drives (RAID-0/striped) NVidia GeForce 8800GT (512mb)
|