Rotation and Elevation in One Command?
|
Rutherford Beresford
Registered User
Join date: 2 Sep 2007
Posts: 45
|
05-30-2009 14:47
I would like to take an object and rotate it some random amount around any or all of its three axis and, at the same time, move it up or down in some random amount all at the same time. Can this be done with one llSetPos or llSetRot command? Rotations, vectors, etc... currently are more than my little brain can wrap itself around, and I would appreciate any advice anyone has.
Thank you, Rutherford Beresford
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
05-30-2009 15:56
llSetPrimitiveParams( [PRIM_POSITION, /*// insert vector //*/, PRIM_ROTATION, /*// insert rotation //*/] ); https://wiki.secondlife.com/wiki/LlSetPrimitiveParamsbeware of SVC-93 when rotating child prims. https://jira.secondlife.com/browse/SVC-93
_____________________
| | . "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... | - 
|
Rutherford Beresford
Registered User
Join date: 2 Sep 2007
Posts: 45
|
05-30-2009 16:37
I found this in the WIKI...
vector currentPos = llGetPos(); vector rotPoint = llGetPos() + <1, 1, 1>; // in global coordinates vector newPos = rotPoint + ((currentPos - rotPoint) * x_45); llSetPos(newPos);
...and was wondering, since it mentions both rotation and position if this might be close, provided I change X_45 to the random rotation I'm looking for?
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
05-30-2009 16:58
From: Rutherford Beresford I found this in the WIKI... vector currentPos = llGetPos(); vector rotPoint = llGetPos() + <1, 1, 1>; // in global coordinates vector newPos = rotPoint + ((currentPos - rotPoint) * x_45); llSetPos(newPos); ...and was wondering, since it mentions both rotation and position if this might be close, provided I change X_45 to the random rotation I'm looking for? That snippet will move your object upward along the body diagonal of a 1m cube and then rotate it (presumably 45 degrees around the X-axis), assuming that you have provided some description of what the variable x_45 is. You can of course define x_45 any way you like. If you want some other angular movement around another axis, just redefine x_45 or replace it with something else.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
Rutherford Beresford
Registered User
Join date: 2 Sep 2007
Posts: 45
|
05-30-2009 17:55
So if I want to just "move" up or down in addition to rotating I would change
vector rotPoint = llGetPos() + <1, 1, 1>;
to
vector rotPoint = llGetPos() + <0, 0, UpDwnAmt>;
to get the job done?
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
05-30-2009 21:25
From: Rutherford Beresford So if I want to just "move" up or down in addition to rotating I would change vector rotPoint = llGetPos() + <1, 1, 1>; to vector rotPoint = llGetPos() + <0, 0, UpDwnAmt>; to get the job done? Yup. This part of the script is calculating the offset from the current position, llGetPos(). When you add vectors, you sum their individual components (x,y,z) to get the new vector, so rotpoint = <x, y, z> + <0,0,UpDwnAmt> = <x,y, z+UpDownAmt>. The offset's the easy part. Calculating the rotation around rotpoint is the rest of the game. That's where you need to define the variable x_45 that you had before.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
Rutherford Beresford
Registered User
Join date: 2 Sep 2007
Posts: 45
|
Almost there!
05-31-2009 08:52
That produced some interesting results, although not quite what I'm looking for. It moved the box up, down, left, ride, and side to side based on the values I gave it, but it didn't actually move the box just up and down and then tilt the box in the desired new position.
This code got me close to where I want to be...
vector newPos = origPos + <0, 0, z_mov>; rotation new_rot = xyz_rot * origRot; llSetRot(new_rot); llSetPos(newPos);
...but there is just the slightest bit of jerky-ness between the llSetRot and the llSetPos. Is there any way to make it look as though it was just one fluid movement from current location with adjusting rotation and then adjusting position?
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
05-31-2009 08:59
Use Void's advice (post #2) and put your new_rot and newPos into llSetPrimitiveParams ..... llSetPrimitiveParams([PRIM_POSITION, newPos,PRIM_ROTATION,new_rot]);
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|