Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Wing troubles

Screwtape Foulsbane
Registered User
Join date: 30 Dec 2007
Posts: 134
01-20-2008 08:38
I'm having troubles with my pig again. I'm tryng to make his wings flap. As long as the rotation is 0,0,0 I'm good. However when the parent rotation changes the wings go nuts and rotate in strange ways.

Thanks in advance for your assistance.

S

rotation xyz;
vector xyz_angles;
vector angles_in_radians;

default
{
link_message(integer sender_num, integer num, string str, key id)
{
if (str == "flap";)
{
xyz_angles = <0,45.0,0>; // Angles as in build menu
angles_in_radians = xyz_angles*DEG_TO_RAD; // Change to Radians
xyz = llEuler2Rot(angles_in_radians); // Change to a Rotation
llSetPrimitiveParams([PRIM_POSITION,llGetLocalPos() + <0.05,0,-0.117>,PRIM_ROTATION,llGetLocalRot()*xyz]);
}
else if (str == "unflap";)
{
xyz_angles = <0,-45.0,0>; // Angles as in build menu
angles_in_radians = xyz_angles*DEG_TO_RAD; // Change to Radians
xyz = llEuler2Rot(angles_in_radians); // Change to a Rotation
llSetPrimitiveParams([PRIM_POSITION,llGetLocalPos() + <-0.05,0,0.117>,PRIM_ROTATION,llGetLocalRot()*xyz]);
}
}

}
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
01-20-2008 08:56
Positions and rotations on child prims when using llSetPrimitiveParams unfortunately does not work as one would think, and indeed only works at <0,0,0> to do what you want.

Would be much better served using llSetLocalRot() and llSetPos() for what you're trying to do
Screwtape Foulsbane
Registered User
Join date: 30 Dec 2007
Posts: 134
01-20-2008 09:08
I've tried that but they don't move smoothly. First they rotate then position. Looks like I'll have tu use a hinge (sigh).

S
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
01-20-2008 09:11
I believe this phenomena is discussed here:



...with possible workarounds.
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
01-20-2008 09:21
If I understand the intent, with enough torturing of relative rotations, and staying mindful of the bass-ackwards implementation of rotations in child prims (http://jira.secondlife.com/browse/SVC-93), I think one could get llSetPrimitiveParams to work. But possibly simplifying it slightly: one could arrange for the flapping prim's axis of rotation to be at the edge--so as to behave like a "hinge"--by changing it to a sphere and half-dimpling it, then changing it back... then one might not need to change the position, only the rotation.
_____________________
Archived for Your Protection
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
01-20-2008 10:51
From: Screwtape Foulsbane
I've tried that but they don't move smoothly. First they rotate then position. Looks like I'll have tu use a hinge (sigh).

S


Yep... the interpolation applied by the client is different for rotations vs. translations. So you see one of the happen faster than the other, which makes the prim jump around, even if you got your math right.

I filed a bug on this a long time ago, but nothing's been done about it AFAIK.

http://jira.secondlife.com/browse/VWR-332

Qie, the cut solutions don't really work with flexi prims, which is what I use in my wings. You can't do the .375/.875 cut because the cut ends up on the wrong axis w.r.t. the flex movement, and I don't remember what happened when I tried the dimple trick, but it didn't work either. I think the flex origin stayed at the original uncut prim's edge, or something like that.
Ollj Oh
Registered User
Join date: 28 Aug 2007
Posts: 522
01-20-2008 10:56
you find the solution for rotating a prim relative to another prims rotation in the lsl wikis.

quaternion rotations can be multiplied or divided by another quaternion rotation to result in a rotation relative to another rotation, or to get the rotation difference. (do not add or substract quaternions)

for linked and root prims there is usually another llFunction that does that automatically.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-20-2008 11:23
From: Ziggy Puff
Qie, the cut solutions don't really work with flexi prims, which is what I use in my wings. You can't do the .375/.875 cut because the cut ends up on the wrong axis w.r.t. the flex movement, and I don't remember what happened when I tried the dimple trick, but it didn't work either. I think the flex origin stayed at the original uncut prim's edge, or something like that.

I remember what happens.... the cuts disappear, they're completely ingored (apparently to prevent recalculating the flexi base or prevent them from having floating apparent bases).... this completely destroyed my wings project which relied on the simpler behavior of rotating a cut prim.

SVC-93 does have the corrected rotation math though, all hail Lex Neva for that work-around
From: Lex Neva on Jira
If you must set a child prim to a world-relative rotation "rot" using PRIM_ROTATION (or llSetRot()), use this:

llSetPrimtiiveParams([PRIM_ROTATION, (rot / llGetRootRotation) / llGetRootRotation);

If you must set a child prim to a local rotation "rot" using PRIM_ROTATION, use this:

llSetPrimitiveParams([PRIM_ROTATION, rot/llGetRootRotation]);
_____________________
|
| . "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...
| -
Screwtape Foulsbane
Registered User
Join date: 30 Dec 2007
Posts: 134
01-20-2008 14:35
The wings arn't flexi so I ended up cutting them.

Thanks for the help.
S