Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sliding & shrinking door on angle

Chaz Longstaff
Registered User
Join date: 11 Oct 2006
Posts: 685
04-05-2008 07:01
This is a door that gives the appearance of both (a) sliding off to one side, and (b) shrinking from its full size of 3 metres down to half a metre.

Works like a charm if placed at some multiple of a 90 degree angle (0, 90, 180, 270, 360)

However, when placed at a 45 or other degree angle, and opened, it leaps over to the side, though off a bit from where it should be, and leaps out in front a fair bit.

Help! Is there some kind of magic rot thing I should be multipying by to take any angle of placement into account? particularly in the crucial part of "PRIM_POSITION, (BasePos + OpenVector)" in the doorOpen() function?

Many thanks, Chaz.

____________________________

BasePos = llGetPos(); //defined at default state entry


//constants
vector SIZE_CLOSED = <2.958, 0.050, 3.29>;
vector SIZE_OPENED = <.5, 0.050, 3.29>;
float DoorMoveDistance = 1.2;

//adjust direction for x / y axis

if (DoorDirection == "-1";)
DoorDir = -1;
else DoorDir = 1;
DoorDirLR = DoorMoveDistance * DoorDir;
if (DoorAxis == "";) {
DoorAxis = "x";
}
if (DoorAxis == "x";) {
OpenVector = <DoorDirLR, 0, 0>;

}
else if (DoorAxis == "y";) {
OpenVector = <0, DoorDirLR, 0>;
}


//the actual functions

doorClose() {
llSetPrimitiveParams([PRIM_SIZE, SIZE_CLOSED,
PRIM_POSITION, BasePos]);
}

doorOpen() {
llSetPrimitiveParams(
[ PRIM_SIZE, SIZE_OPENED,
PRIM_POSITION, (BasePos + OpenVector)]);
}
Chaz Longstaff
Registered User
Join date: 11 Oct 2006
Posts: 685
04-05-2008 07:26
Figured it out through trial and error. Sorry for bothering everybody. I just always panic in advance thinking of rotations.

For those searching in the future, here's the corrected door open part. Turned out to be dead simple once I got my BOMDAS rule right for the brackets ;}


doorOpen() {
llSetPrimitiveParams(
[ PRIM_SIZE, SIZE_OPENED,
PRIM_POSITION, BasePos + (OpenVector * llGetRot() )]);
}