Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Preventing rotation of Prim in linkset

Oliviero Ranimo
Registered User
Join date: 19 Jan 2009
Posts: 13
04-16-2009 07:19
Hi guys, another question for the scripting gurus out there.

So far what I've got, is a linkset of 3 objects, which when complete I hope will form a fish object. So far I've managed to get a ?fin tail? to wag using the tail wag script here on the forums. To achieve this I'm using an axle as the root prim with another linked to this to form the tail. That works fine.

Now I've come to add a body to the fish and find that this is also rotating on the axle when linked together. So what I need to know is this. Is there anyway of keeping the three objects linked yet preventing the body of the fish from rotating along with the fin tail?

So what I'm after is a stationary body with the fin wagging from side to side.

Here's the wag script I'm using in the axle for the tail.

//user variables, set manually
float MaxRot=60; //in degrees
float swingtime=1.0; //seconds for a swing from centre to MaxRot
integer swing = FALSE; //Swing state
vector RotAxis;
float RotRate;

//runtime variable
rotation gBaseRot=ZERO_ROTATION;

do_swing() {

//Swing up
llTargetOmega(RotAxis,RotRate,1);
llSleep(-0.2+swingtime);
llSetLocalRot(gBaseRot*llAxisAngle2Rot(RotAxis,MaxRot*DEG_TO_RAD));

//swing to other side
llTargetOmega(RotAxis,-1*RotRate,1);
llSleep(-0.2+(swingtime*2));
llSetLocalRot(gBaseRot*llAxisAngle2Rot(RotAxis,-1*MaxRot*DEG_TO_RAD));

//And back to centre
llTargetOmega(RotAxis,RotRate,1);
llSleep(-0.2+swingtime);
llSetLocalRot(gBaseRot);
}

default {
state_entry() {


}

touch_start(integer count) {

state wag;

}
}

state wag {

state_entry() {


gBaseRot=llGetLocalRot();
RotAxis=llRot2Fwd(llGetLocalRot()); // maybe.
RotRate=(MaxRot*DEG_TO_RAD)/swingtime;
swing = TRUE;
llSetTimerEvent((swingtime * 4) - 0.6);
do_swing();

}

timer() {

if(swing == TRUE) {
do_swing();
}

else {

//stop rotation
llSetTimerEvent(0.0);
llTargetOmega(RotAxis,0,0);
llSetRot(gBaseRot);
state default;
}
}

touch_start(integer count) {
swing = FALSE;
}

}
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
04-16-2009 08:41
You can not do it like that.
You can make one child prim not an object swing.
So get rid of the axle prim and shape your tail in a way it will have it's axis where you want it.
For that it is a good start to cut the prim (if it is a box) in half. That way it will have it's center on one side:)
_____________________
From Studio Dora
Oliviero Ranimo
Registered User
Join date: 19 Jan 2009
Posts: 13
04-16-2009 08:59
Thanks for that, that is where I started out. I was hoping it'd be easier for lining up the textures this way but never mind.

Cheers anyway.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
04-16-2009 13:59
if you start with a sphere, dimple to .49 and .51, then convert to box, and half cut it (.125 and .625, or .375 and .875) you'll have a paper thin shape that rotates on one side and only need to double the repeats number for one dimension on the texture and a .5 offset giving you a max size of 5 * 10m and rotation on the max long side (like a door)

you can also cause it to rotate from the corner by using a dimple of 0 and .02 or .98 and 1, and then double both texture repeats and ofeset both directions by .5, giving you a max of 5m^2
_____________________
|
| . "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...
| -