s3pik Posted March 22, 2022 Share Posted March 22, 2022 (edited) Hi! I have tested with a simple door script by adding it to the top part of the phone and it works as it should. But i need the top and bottom parts to be linked to be able to use a resize script and once i link them the phone just rotates around the middle. So is there a way to have the parts joined and have the script only affect the top part so it would fold closed? https://i.gyazo.com/2e8301d4947f566d57d7dc516bcd6a01.mp4 https://i.gyazo.com/302254dbda875496ac1d44e0d3802eab.mp4 Edited March 22, 2022 by s3pik Link to comment Share on other sites More sharing options...
Emma Krokus Posted March 22, 2022 Share Posted March 22, 2022 (edited) Put the script into the child prim and see if that works for you. Or make the bottom part the root prim. Edited March 22, 2022 by Emma Krokus Link to comment Share on other sites More sharing options...
Fenix Eldritch Posted March 22, 2022 Share Posted March 22, 2022 (edited) Yes, it's entirely possible, that's what functions like llSetLinkPrimitiveParams and llSetLinkPrimitiveParamsFast are for. They allow you to modify any linked prims in the linkset. In your case, you would want to modify the local rotation of the top section of the phone. And it would be advisable to have the top part not be the root prim. Here is a very quick demonstration script: // Demo script rotation open = <0.438371, 0.0, 0.0, 0.898794>; //example open rotation rotation close = <0.999312, -0.0, -0.0, 0.037077>; //example closed rotation integer toggle = FALSE; integer top_part; //link number default { state_entry() { integer x; for(x=1;x<=llGetNumberOfPrims();x++) //scan all links in the linkset { if(llGetLinkName(x) == "top") //check if it's the top prim by looking for a name of "top" { top_part = x; //store the link number of the top part } } llSetLinkPrimitiveParamsFast(top_part,[ PRIM_ROT_LOCAL, close ]); //start in closed rotation } touch_start(integer total_number) { if(toggle = !toggle) { llSetLinkPrimitiveParamsFast(top_part,[ PRIM_ROT_LOCAL, open ]); } else { llSetLinkPrimitiveParamsFast(top_part,[ PRIM_ROT_LOCAL, close ]); } } } For your purposes, you'll need to supply the local rotations for the top part in its closed and opened orientations. You can do this by linking everything together and manually editing the top to be in the orientation you want and then adding a diagnostic command to the touch_start event of your script to report the part's current local rotation. Something like:llOwnerSay((string)llGetLinkPrimitiveParams(top_part,[ PRIM_ROT_LOCAL ])); where "top_part" is a global variable which contains the link number for the top part of the phone. Make a note of what is reported and repeat the process for the other orientation. Once you have both, plug them into the demo script above. I noticed that the phone appears to have a hinge prim, which suggests the top part of the phone doesn't have its origin in an optimal location. This isn't a huge problem, it just means you'll need to also update the top part's local position as well. The process for discovering that is identical to the above, just use PRIM_POS_LOCAL for the get and set functions respectively. You can also combine using the local rotation and local position at the same time. Edited March 22, 2022 by Fenix Eldritch 1 Link to comment Share on other sites More sharing options...
s3pik Posted March 22, 2022 Author Share Posted March 22, 2022 4 hours ago, Fenix Eldritch said: Yes, it's entirely possible, that's what functions like llSetLinkPrimitiveParams and llSetLinkPrimitiveParamsFast are for. They allow you to modify any linked prims in the linkset. In your case, you would want to modify the local rotation of the top section of the phone. And it would be advisable to have the top part not be the root prim. Here is a very quick demonstration script: // Demo script rotation open = <0.438371, 0.0, 0.0, 0.898794>; //example open rotation rotation close = <0.999312, -0.0, -0.0, 0.037077>; //example closed rotation integer toggle = FALSE; integer top_part; //link number default { state_entry() { integer x; for(x=1;x<=llGetNumberOfPrims();x++) //scan all links in the linkset { if(llGetLinkName(x) == "top") //check if it's the top prim by looking for a name of "top" { top_part = x; //store the link number of the top part } } llSetLinkPrimitiveParamsFast(top_part,[ PRIM_ROT_LOCAL, close ]); //start in closed rotation } touch_start(integer total_number) { if(toggle = !toggle) { llSetLinkPrimitiveParamsFast(top_part,[ PRIM_ROT_LOCAL, open ]); } else { llSetLinkPrimitiveParamsFast(top_part,[ PRIM_ROT_LOCAL, close ]); } } } For your purposes, you'll need to supply the local rotations for the top part in its closed and opened orientations. You can do this by linking everything together and manually editing the top to be in the orientation you want and then adding a diagnostic command to the touch_start event of your script to report the part's current local rotation. Something like:llOwnerSay((string)llGetLinkPrimitiveParams(top_part,[ PRIM_ROT_LOCAL ])); where "top_part" is a global variable which contains the link number for the top part of the phone. Make a note of what is reported and repeat the process for the other orientation. Once you have both, plug them into the demo script above. I noticed that the phone appears to have a hinge prim, which suggests the top part of the phone doesn't have its origin in an optimal location. This isn't a huge problem, it just means you'll need to also update the top part's local position as well. The process for discovering that is identical to the above, just use PRIM_POS_LOCAL for the get and set functions respectively. You can also combine using the local rotation and local position at the same time. This gave me a lot of hope, but then again im new when it comes to scripting in second life. I really do appreciate the effort you put into your reply but im afraid i simply dont have the skill to apply it. Also i feel like i should mention that both top and bottom parts consist of linked meshes, for example, the top part is 4 linked objects plus a hinge and the bottom is also 4 linked objects. Would it still be possible like that? Link to comment Share on other sites More sharing options...
Quistess Alpha Posted March 22, 2022 Share Posted March 22, 2022 19 minutes ago, s3pik said: Would it still be possible like that? There is no support in Secondlife for 'hierarchies' of linked objects. Either everything is sepparate in the same object, or you have different objects, so the second you link the top and bottom of the phone, you no longer have a 'top part' and a 'bottom part', just one phone. It's still ~possible to move multiple linked parts together as one piece, but you need to do the math yourself, and it doesn't always look the best visually. Link to comment Share on other sites More sharing options...
Mollymews Posted March 23, 2022 Share Posted March 23, 2022 (edited) On 3/23/2022 at 7:21 AM, s3pik said: i should mention that both top and bottom parts consist of linked meshes, for example, the top part is 4 linked objects plus a hinge and the bottom is also 4 linked objects when making the meshes try to make the top part as one mesh object, and the bottom part as one mesh object. When we do this then the scripting is a whole lot simpler. Bottom as the root prim, top as the linked prim, and we only need to rotate the one linked prim Edited March 23, 2022 by Mollymews lot 1 Link to comment Share on other sites More sharing options...
Emma Krokus Posted March 24, 2022 Share Posted March 24, 2022 15 hours ago, Mollymews said: when making the meshes try to make the top part as one mesh object, and the bottom part as one mesh object. When we do this then the scripting is a whole lot simpler. Bottom as the root prim, top as the linked prim, and we only need to rotate the one linked prim If the buttons are on the inside of the lid, maybe you could have them alpha out when its closed? And if the hinge is round, it wouldn't matter that it stays in place when the lid is rotated? 2 Link to comment Share on other sites More sharing options...
arton Rotaru Posted March 26, 2022 Share Posted March 26, 2022 On 3/24/2022 at 12:52 PM, Emma Krokus said: If the buttons are on the inside of the lid, maybe you could have them alpha out when its closed? And if the hinge is round, it wouldn't matter that it stays in place when the lid is rotated? If merging it all into one piece isn't an option, and the scripting task is also out of reach, this is indeed a solution. You could even have 2 sets of the top parts, one in open, one in closed state, and just toggle the alpha. Would increase the land impact indeed. Omitting everything that is barely visible when closed would help with that. Scripting all the rotations/translations is kinda annoying. To make that look good, it would have to run in a loop with tiny increments. However, it would still be the way I would do it, when merging isn't an option, though. Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now