Nestled links - possible?
|
|
Margot Schnyder
Generalsekretärin
Join date: 20 Feb 2007
Posts: 14
|
03-18-2007 06:51
Hi there.  I'm currently building a book shelf serie, and it's allmost done. The book shelf series concists of four indivdual parts and three of them have movable drawers and/or hatches and/or doors. Problem now is, the drawers, hatches and doors concist of more than 1 prim each (the doors must even have so many as 5 prims each), and it seems to be impossible to link them to the main body of the book shelfs without losing the link within the drawers/doors/hatches themselfes. I'll try to illustrate my linking: .------------. | Hatch and | <- They are first linked with eachoter (separatly) | Doorknob | `------------´ | | + <- This link is the last one, and the hatches are selected | first in this link. Unfortunatly this link allways terminates | the link above and the door knob no longer follows the | hatch's movement. | .--------------. | Mainbody and | <- They are first linked with eachoter (separatly) | Up2 10 prims | `--------------´ Is it not possible to nestle links? Even if i take the simplest object that should move, it's a hatch, it still has 2 prims, one for the hatch and one for the handle (knob). I have untill now "solved" this problem with letting the mainbody-part of the book shelf uppon it's own rez, rez the doors, drawers and hatches, and it works. Only problem is, they are not attached, and if i want to move the book shelf i need to make sure to select every drawer, door, hatch and the main shelf body toghether -- that would not be satisfying for customers. Now i'm thinking of perhaps making the drawers, doors and hatches act as "pets" that follows the shelf that rezzes them and allso make them monitor the presence of the shelf that rezzed them, if it moves, they move, if it's gone (deleted), they "commit suecide". Does anyone have any ideas? Could all this that i want to happen perhaps be done in a more simple and elegant way? (i hope my text makes sence and can be followed)
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
03-18-2007 08:18
Basically no its not possible to have hierarchal links. Objects in SL consist fo a single list or 'chain' if you will of prims. So each prim connects to the previous one and then next one.
|
|
Ed Gobo
ed44's alt
Join date: 20 Jun 2006
Posts: 220
|
03-18-2007 18:16
Builders Buddy has some elements that might be useful. The cabinet might rez the drawer as an object and it in turn might have a linked handle. The handle can move wrt to the drawer it is linked to and the drawer has a position given from its moment of being rezzed (could be stored in its description) by the cabinet.
|
|
Margot Schnyder
Generalsekretärin
Join date: 20 Feb 2007
Posts: 14
|
03-18-2007 18:54
Oki, thanks for the answers...  I looked at Builders Body, but to be honest i did not understand wich part of it that does what i want. :| I'll list the code here, to this point it works allmost, the dravers and the hatch are rezzed from the shelf body, and they are positioned correctly with cordinates relative to the shelf body and they open correctly nomather what the angle of the shelf body and the drawers. And for me this is enough. But if i will perhaps sell furniture in the future, it would feel a bit "unfinished" if the customer must be careful to select the shelf body, the dravers and the hatch together to avoid the drawers and hatch to get out of position, instead of just having to move the shelf body. This is the script in the shelf body: default { on_rez(integer start_param) { vector eul1 = <0,270,270>; //45 degrees around the z-axis, in Euler form eul1 *= DEG_TO_RAD; //convert to radians rotation quat1 = llEuler2Rot(eul1); //convert to quaternion llRezObject("KDS - Modular Book Shelf 1 - Piece 1 - Hatch", llGetPos() + <0.0, 0.587, 0.309>,ZERO_VECTOR, quat1, 1);
vector eul2 = <0,0,0>; //45 degrees around the z-axis, in Euler form eul2 *= DEG_TO_RAD; //convert to radians rotation quat2 = llEuler2Rot(eul2); //convert to quaternion llRezObject("KDS - Modular Book Shelf 1 - Piece 1 - Drawer", llGetPos() + <0.0, 0.317, -0.349>,ZERO_VECTOR, quat2, 1);
vector eul3 = <0,0,0>; //45 degrees around the z-axis, in Euler form eul3 *= DEG_TO_RAD; //convert to radians rotation quat3 = llEuler2Rot(eul3); //convert to quaternion llRezObject("KDS - Modular Book Shelf 1 - Piece 1 - Drawer", llGetPos() + <0.0, 0.317, -0.633>,ZERO_VECTOR, quat3, 1);
} } And this is the script in one of the drawers: integer g_Up;
default { touch_start(integer total_number) { g_Up = !g_Up; if(g_Up) { llTriggerSound("Drawer_OPEN", 1.0); vector moveVector = <0,0.5,0>; // adjust this for movement when the drawer has 0 rot llSetPos(llGetPos () + moveVector * llGetRot ()); } else { llTriggerSound("Drawer_CLOSE", 1.0); vector moveVector = <0,-0.5,0>; // adjust this for movement when the drawer has 0 rot llSetPos(llGetPos () + moveVector * llGetRot ());
} } } The only thing that i want to acomplish now is that the drawer stays in the same position relative to the shelf body (the parent) automagicly if i rotate and/or move the shelf body. Now it does not, because i cannot link them. If i move the shelf body (the parent) the drawers and the hatch stays in the position where they where rezzed.
_____________________
"Wir kennen nur ein Ziel, das die gesamte Politik unserer Partei durchdringt: alles zu tun für das Wohl des Menschen, für das Glück des Volkes, für die Interessen der Arbeiterklasse und aller Werktätigen. Das ist der Sinn des Sozialismus. Dafür arbeiten und kämpfen wir."
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
03-19-2007 04:33
The solution in that instance, or at least one solution, is to tell the drawers to delete themselves when ever the main unit is moved. It does require additional intelligence in the scripts.
|
|
Margot Schnyder
Generalsekretärin
Join date: 20 Feb 2007
Posts: 14
|
03-19-2007 05:40
Yes, i was experimenting with that a bit right now. I used the events moving_start() and moving_end() in the main shelf. moving_start() send "unique" chattmessages on separate channel to the drawers, hatches and doors instructing them to die (the drawers, hatches and doors listen on same channel for their respective unique "suecide command"  , and move_end() in the main shelf rezzed the drawers, hatches and doors at the shelfs new position. But then it striked me, what if i have two identical book shelfs? Or a neighbour has a set to and he/she has it placed closer that the 10m boundary for llWhisper()? In that case my neigbours drawers, hatches and doors would allso be deleted, and then be re-rezzed at my book shelf. This is really killing me. Then i thougt i could include llGetKey() in the chatt message the book shelf body sends to the drawers, hatches and doors, but i cannot find anyway of letting the drawers, hatches and doors know the key of the object that rezzed them.
_____________________
"Wir kennen nur ein Ziel, das die gesamte Politik unserer Partei durchdringt: alles zu tun für das Wohl des Menschen, für das Glück des Volkes, für die Interessen der Arbeiterklasse und aller Werktätigen. Das ist der Sinn des Sozialismus. Dafür arbeiten und kämpfen wir."
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
03-19-2007 06:31
From: Margot Schnyder Yes, i was experimenting with that a bit right now. I used the events moving_start() and moving_end() in the main shelf. moving_start() send "unique" chattmessages on separate channel to the drawers, hatches and doors instructing them to die (the drawers, hatches and doors listen on same channel for their respective unique "suecide command"  , and move_end() in the main shelf rezzed the drawers, hatches and doors at the shelfs new position. But then it striked me, what if i have two identical book shelfs? Or a neighbour has a set to and he/she has it placed closer that the 10m boundary for llWhisper()? In that case my neigbours drawers, hatches and doors would allso be deleted, and then be re-rezzed at my book shelf. This is really killing me. Then i thougt i could include llGetKey() in the chatt message the book shelf body sends to the drawers, hatches and doors, but i cannot find anyway of letting the drawers, hatches and doors know the key of the object that rezzed them. When you Rez objects you specify an integer as the last parameter. Use this to pass a random channel for them to listen on. RezItems() { // Channel is the global channel number being used to communicate with the rezzed items. // Idf its non zero then there is already something rezzed? if(Channel != 0) { llWhispher(Channel, DieCommand); } // Select a new unique Channel = 0 - (integer)llFrand(2147483647); vector position = llGetPos(); vector eul1 = <0,270,270>; //45 degrees around the z-axis, in Euler form eul1 *= DEG_TO_RAD; //convert to radians rotation quat1 = llEuler2Rot(eul1); //convert to quaternion llRezObject("KDS - Modular Book Shelf 1 - Piece 1 - Hatch", pos+ <0.0, 0.587, 0.309>,ZERO_VECTOR, quat1, Channel);
vector eul2 = <0,0,0>; //45 degrees around the z-axis, in Euler form eul2 *= DEG_TO_RAD; //convert to radians rotation quat2 = llEuler2Rot(eul2); //convert to quaternion llRezObject("KDS - Modular Book Shelf 1 - Piece 1 - Drawer", pos + <0.0, 0.317, -0.349>,ZERO_VECTOR, quat2, Channel);
vector eul3 = <0,0,0>; //45 degrees around the z-axis, in Euler form eul3 *= DEG_TO_RAD; //convert to radians rotation quat3 = llEuler2Rot(eul3); //convert to quaternion llRezObject("KDS - Modular Book Shelf 1 - Piece 1 - Drawer", pos + <0.0, 0.317, -0.633>,ZERO_VECTOR, quat3, Channel);
}
The drawer script will now require an on_rez event and a listen on_rez(integer number) { if(number != 0)llListen(number,"","",""); }
listen(integer channel, string name, key id, string message) { if(DieCommand == message) llDie(); }
|
|
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
|
03-19-2007 06:31
From: Margot Schnyder i cannot find anyway of letting the drawers, hatches and doors know the key of the object that rezzed them. In the the main body's object_rez handler, have it whisper the key of the object it rezzed, and in the rezzed objects' on_rez handlers, have them listen for a message with their own key, and save the ID from that message // Dresser Body: object_rez( key ID ) { // SomeChannel = the Parameter value passed to // llRezObject or llRezAtRoot llWhisper( SomeChannel, ID ); }
//Drawer, Door, etc: key MasterID;
default { on_rez( integer Param ) { llListen( Param, "", "", llGetKey() ); }
listen( integer Channel, string Name, key ID, string Message ) { MasterID = ID; state Active; } }
state Active { state_entry { llListen( llGetStartParameter(), "", MasterID, "" ); } }
|
|
Margot Schnyder
Generalsekretärin
Join date: 20 Feb 2007
Posts: 14
|
03-20-2007 07:25
I thank you all for the help! 
_____________________
"Wir kennen nur ein Ziel, das die gesamte Politik unserer Partei durchdringt: alles zu tun für das Wohl des Menschen, für das Glück des Volkes, für die Interessen der Arbeiterklasse und aller Werktätigen. Das ist der Sinn des Sozialismus. Dafür arbeiten und kämpfen wir."
|
|
Margot Schnyder
Generalsekretärin
Join date: 20 Feb 2007
Posts: 14
|
03-20-2007 08:38
Oh! How typical, i have just noticed move_start() and move_end() are not triggered by rotation... The script for using a random channel to ask the drawers, hatches and doors to commit collective suecide was however very useful.  I'm now working with a function that kills the drawers, hatches and doors if the owner touches the main body and then ressurect them (at the new position) if the owner touches it again. Now i only have to find out how i can add the mainbodys rotation to the drawers, doors and hatches rotations. Adding llGetRootRotation() to quat1 as below does not seem to work. vector eul1 = <0,270,270>; //45 degrees around the z-axis, in Euler form eul1 *= DEG_TO_RAD; //convert to radians rotation quat1 = llEuler2Rot(eul1); //convert to quaternion llSay(0, (string)llGetRootRotation()); llRezObject("KDS - Modular Book Shelf 1 - Piece 1 - Hatch", llGetPos() + <0.0, 0.587, 0.309>,ZERO_VECTOR, quat1+llGetRootRotation(), Channel);
_____________________
"Wir kennen nur ein Ziel, das die gesamte Politik unserer Partei durchdringt: alles zu tun für das Wohl des Menschen, für das Glück des Volkes, für die Interessen der Arbeiterklasse und aller Werktätigen. Das ist der Sinn des Sozialismus. Dafür arbeiten und kämpfen wir."
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
03-21-2007 02:26
Multiply the positional offset by the base rotation when you rez the object.
|