I'm trying to make the doors rotate around an invisible point which is at a defined offset from the centred root prim. I found a little bit in the Wiki about this, but when I tried the suggested method, It didn't seem to work.
I will paste what I have so far in here.
The first script it the control script which goes in the root prim. It is a perfectly centred, invisible column. exactly the same height as the door.
Making the door as 2 seperate linksets, is NOT an option. I know it would make things much simpler but I am not willing to do it unless this is completely impossible, and i'm almost certain it CAN be done this way.
I will Pay 500l for some help in this matter.
--------------------------------------------------------------------------------------------------------
vector left_offset;
vector right_offset;
integer closed=TRUE;
integer locked=FALSE;
//The closed and locked variables are not used yet. Still trying to get the basic mechanics working before I bother with that.
default
{
touch_start(integer total_number)
{
left_offset= (llGetPos() + <4, 0, 0>
; //Calculate the first rotation point. 4m offset from the centre
right_offset= (llGetPos() - <4, 0, 0>
;//Calculate the first rotation point. 4m offset from the centre
llMessageLinked(LINK_SET, 1, "", NULL_KEY);
//This sends out a message to other moving parts in the door, and is irrelevant to this problem. Ignore this line
llSleep (2.0);
//A short break between the two stages of opening
llMessageLinked(LINK_SET, 2, (string)left_offset, (string)right_offset);
// Sends a triggering integer to the doors, as well as the rotation points as strings
}
}
--------------------------------------------------------------------------------------------------------
This second script, goes into the left hand door. It should be simple enough to adapt it for the right hand door. The problem, is that when executed, the door rotates on the spot, not around the point I set.
--------------------------------------------------------------------------------------------------------
string rota;
default
{
link_message(integer sender_num, integer num, string str, key id)
{
rotation x_45 = llEuler2Rot( -<0, 0, 8 * DEG_TO_RAD> );
//Calculates the amount that the door should rotate
if (num == 2) //Checks if it is the correct link message
{
rotation new_rot = x_45 * llGetLocalRot();
//Calculates the new rotation to set the door to
vector currentPos = llGetPos();
//Gets the current position of the door
rota = (string)id;//This line...
vector rotPoint = (vector)rota;
//And this one. Are just typecasting the rotation point back into a vector
vector newPos = rotPoint + ((currentPos - rotPoint) * x_45);
//Calculates the new position the door should be moved to. This line appears to be the source of the problem, bnut I'm not entirely sure.
llSetPos(newPos);
// Move the door to the appopriate position
llSetLocalRot(new_rot);
//Set the door to the appropriate rotation
}
}
}
--------------------------------------------------------------------------------------------------------
WarKirby