Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Movement that is relative to rotation

Cito Karu
Registered User
Join date: 23 Jul 2008
Posts: 229
02-23-2009 13:05
Howdy all, normally I usually have few to no problems with most scripting, but my "Kryptonite" seems to be creating movements that are relative to a rotation. I just seem to can't figure out the math to save my life. I guess skipping geometry in school was the most stupid thing I ever did.

Anyhow with that intro out of the way here is what I'm trying to do, and it's so super simple that yes I'm calling myself a dumbarse when it comes to rotations. (imo rotations are da debil )

Ok imagine a simple desk.

In this imagination desk there is a drawer.

Now I have 2 versions of this desk in attempts to get this to work.

First is a solid totally linked desk.
Second is the desk is linked, but the drawer is a seperately linked object so desk/drawer = 2 objects.


My plans is to click the drawer, it slides out with a setpos or whatnot like .5 meters then click the drawer again and it closes -.5 meters.

I can get that drawer to move no problem, but most are probably seeing the issue I'm having. If this was my desk then I would be happy just doing llSetPos on a x or y plane based on how i setup the desk in my house.

But the kicker is this is for a friend and he wants to be able to rotate it or move or whatnot and the drawer will always slide open and closed in relative to the desk.

I have tried setpos, with getrots etc but situation is I can get the rot of the desk but I cannot figure out how to pass whether I should send a positive or negative to the X plane or Y plane or BOTH based on the rotation of the desk itself.

If anyone has a sample script I could perhaps look at, or tips, or heck see me in game and I'll even think about purchasing it, cause I believe once I see it done I can figure it out with no problem.

And once again I'm banging my head on table for skipping geometry and just taking algebra's 1 and 2.

haha

Sorry for spammy post, but thank you to anyone willing to toss an old dog a few pointers.

Let me know if any further info is needed or if you would like to see the item in question in SL.
_____________________
My XstreetSL store:
http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=179545

My Blog:
http://qoaa.blogspot.com
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
02-23-2009 15:10
From: Cito Karu

My plans is to click the drawer, it slides out with a setpos or whatnot like .5 meters then click the drawer again and it closes -.5 meters.

I can get that drawer to move no problem, but most are probably seeing the issue I'm having. If this was my desk then I would be happy just doing llSetPos on a x or y plane based on how i setup the desk in my house.

But the kicker is this is for a friend and he wants to be able to rotate it or move or whatnot and the drawer will always slide open and closed in relative to the desk.

I have tried setpos, with getrots etc but situation is I can get the rot of the desk but I cannot figure out how to pass whether I should send a positive or negative to the X plane or Y plane or BOTH based on the rotation of the desk itself.


llSetPos() in a linked object will move the linked object relative to the root, What is the problem?
_____________________
From Studio Dora
Cito Karu
Registered User
Join date: 23 Jul 2008
Posts: 229
02-23-2009 16:20
Thanks Jewel Greenwood for the examples.

Dora: wasn't working like I thought it would. If desk is rotated 1 direction and even with getrot passed to the drawer object it would only move 1 direction so if the original position allowed it to move correctly when you rotated the desk the drawer no longer moved in relative to the desk

both with the 2 object desk and the 1 linked desk both worked that way, needed a math formula to take the rot and tell the drawer to either move on x plane or y plane or if the desk is not at a 90 degree angle the drawer would have to move on both x and y planes

and just wasn't happening.
_____________________
My XstreetSL store:
http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=179545

My Blog:
http://qoaa.blogspot.com
Cito Karu
Registered User
Join date: 23 Jul 2008
Posts: 229
02-23-2009 16:51
actually figured it out, well changed the build around to make it a bit easier, so nevermind. :)

thanks for tips

Sometimes writing about it or stepping back a while helps makes the problem clear up :P
_____________________
My XstreetSL store:
http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=179545

My Blog:
http://qoaa.blogspot.com
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
02-23-2009 17:57
From: Cito Karu
Sometimes writing about it or stepping back a while helps makes the problem clear up :P

I usually just bang my head against the problem until it is beaten into submission :p
_____________________
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
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-24-2009 02:19
btw that formula is:
llGetPos() + vecChange * llGetRot()

presuming the des rezzes facing south, vecChange would be <0.0, -0.5, 0.0>

a cheap way to do the change between opening and closing is

llGetPos + (vecChange *= -1) * llGetRot()
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -