Talk:Hierarchics
Default Rotation etc
It's a good script but the rotation code leaves much to be desired. If the user specifies in the objects description that it should have a zero rotation, the script currently ignores it. Additionally it forces the user to use Euler notation. You need something like the following, it allows the user to supply either a quaternion on Euler. <lsl> //Creator: Strife Onizuka //http://creativecommons.org/licenses/by-sa/3.0/
rotation AngleString2Rot(string in, rotation bad){
//we test if it is an angle type we can use by: //1) parse input and see if it has a value //2) flip the sign of an element and test again. rotation r = (rotation)in; if(r)//it's a rotation (or something greater) return r;//by greater it might be <x,y,z,s,...>
vector v = (vector)in; if(v)// it's not a rotation but it is a vector return llEuler2Rot(v * DEG_TO_RAD);
//now it's either default or invalid //to determine which, we modify the input string and test agian //if it passes, we know the result should be ZERO_ROTATION integer index = llSubStringIndex(in, "<"); if(~index) { //we insert a negative sign //but we have to remove spaces or they will cause problems //we don't care about negative negative zero because //breaking the parse is an indication that it did parse. in = llGetSubString(in, 0, index) + "-" + llStringTrim(llDeleteSubString(in, 0, index), STRING_TRIM_HEAD);
if((string)((vector)in) != (string)v) return r; //r is Identity but could have negative zero's, waste not want not. //the user specified them, we should preserve them. } return bad;
}//Strife Onizuka 2009, cc-by-sa 3.0
//Less verbose rotation AngleString2Rot(string in, rotation bad){
rotation r = (rotation)in; if(r)//it's a rotation! return r;
vector v = (vector)in; if(v)// it's not a rotation but it is a vector return llEuler2Rot(v * DEG_TO_RAD);
integer index = llSubStringIndex(in, "<"); if(~index) {//"<" was found, now insert "-" in = llGetSubString(in, 0, index) + "-" + llStringTrim(llDeleteSubString(in, 0, index), STRING_TRIM_HEAD); if((string)((vector)in) != (string)v) return r; //it did parse, not an error } return bad;
}//Strife Onizuka 2009, cc-by-sa 3.0 </lsl> -- Strife (talk|contribs) 20:46, 6 May 2009 (UTC)
Wow! Thanks Strife! Nexii Malthus 23:30, 6 May 2009 (UTC)
Changes
Over the last couple hours I've made a bunch of changes. None should change how the script functions except for where I removed the CheckValidity functionality.
- Add: Ref now supports quaternions
- Fix: Ref does not support <0,0,0>
- Fix: Collision between Link_HierarchicsGet and Link_HierarchicsEdit
- Add: Re-enabled Link_HierarchicsGet
- Fix: In edit mode the (ChangedRot && ChangedPos) code is dead due to preceding logic... and inconsistent with preceding code.
- Removed: CheckValidity
I removed CheckValidity because it wasn't necessary to the core functionality and it required configuration. In addition to that, maintaining inventory integrity may or may not be a priority of the scripter. The biggest problem was that CheckValidity in it's default configuration would delete the script and if it could the entire objec, upon object rerez or change in inventory. It was my conclusion that CheckValidity should be a separate library/example script. -- Strife (talk|contribs) 23:49, 6 May 2009 (UTC)
llGetRootRotation
llGetRootRotation is going to be a problem with attachments. I'll see if I can come up with a solution. -- Strife (talk|contribs) 00:38, 7 May 2009 (UTC)
- Hmm, in my prim animations code previously, I used to send llGetRootRotation along with the individual commands, perhaps we should do the same here with the Values List as an extra unreferenced value at the end. It seems the most realistic fix to me. llMessageLinked( LINK_SET, 660333, "Rot1;Rot2;Rot3"+";RootRot", "Link1;Link2;Link3" ); Nexii Malthus 12:32, 7 May 2009 (UTC)
Broke
Before you get ahead of yourself Strife, we should try fix up the script so it works. It doesn't work anymore when I sent it through the example code. The code in Update() seems okay to me, I think it may be the initialisation routine changes you introduced. Nexii Malthus 12:29, 7 May 2009 (UTC)