06-09-2008 06:56
I've been using these two scripts for a long while now with my organic builds to mirror the different sides. I last used these scripts about 3 weeks ago. upon trying to use them today, it doesn't work; it will do the correct cut/rotation/twist/etc. manipulation, but the position calculation is all wrong, sometimes shifiting it's position as much as a factor of 10 from where it needs to be, and it always seems to be a random amount /direction that it's off by. Here's the scripts. perhaps there are now depreciated functions that are being used? the script is old, from at least 2005


Mirror script (goes in the "mirror";)
CODE

//================================================== ==========================
// Prim Mirroring Script Set
// Written by Jeffrey Gomez
//
// Permissions Granted to Edit, Copy, Transfer, and Sell this script
// to any user, so long as this comment set remains intact, and is
// granted WITHOUT ANY WARRANTY. USE AT OWN RISK. And enjoy. =]
//
//
// Original Date of Creation: March 8th, 2005
//
// Any unauthorized or illegal usage of this script, as dictated by
// International Laws of Copyright or Linden Labs voids any license to use
// this script. Creator of this script is not responsible for said use.
//
// So please, don't come after me. =)
//
//
// Forum Thread URL(s):
// http://forums.secondlife.com/showthread.php?t=38165
//
//
// Script Purpose and Usage:
// This script is used to mirror prims. That's about it!
//
// To use this script set place the Prim Mirror Code in a second prim.
// That's it! Now when you want to mirror something (relative to this second
// prim), merely drop the appropriate Mirror Code into the item (primitive)
// that you wish to mirror. The script will do the work for you.
//
// You may rotate the mirror prim around to get different angles, or scale it
// to get different sizes of mirroring. Note scaling appears odd for this -
// that's a factor of how prims work, so don't blame me!
//
// Script Limitations:
// - The Script, in present form, will only work on OBJECTS YOU'VE CREATED
// - Certain rotations *may* appear bugged. I've not yet rooted out why.
// Send any instances of this behavior to me in prim form, please.
// - This Script DOES NOT support Prim Torturing in ANY form.
//================================================== ==========================

list params = [];
list params2 = [];
default
{
state_entry()
{
llListen(19000,"","","");
llListen(18999,"","","");
}

listen(integer chan, string name, key id, string msg)
{
vector my_size = llGetScale();
if(chan == 19000)
params = llParseString2List(msg,[":"],[]);
else if(chan == 18999)
{
if(msg != "done")
params2 = llParseString2List(msg,[":"],[]);
string mirror = llList2String(params,0);
vector pos = ((vector)llList2String(params,1) - llGetPos()) / llGetRot();
//pos = <pos.x, pos.y, pos.z>;
rotation rot = (rotation)llList2String(params,2) / llGetRot();
vector size = (vector)llList2String(params,3);
//size *= rot;
//size = <size.x * my_size.x,size.y * my_size.y,size.z * my_size.z>; size /= rot;
integer type = (integer)llList2String(params,4);
if(type < 3)
{
integer holeshape = (integer)llList2String(params,5);
vector cut = (vector)llList2String(params,6);
float hollow = (float)llList2String(params,7);
vector twist = (vector)llList2String(params,8);
vector topsize = (vector)llList2String(params,9);
vector topshear = (vector)llList2String(params,10);

vector rot2 = llRot2Euler(rot);
//if(type == 0)
cut = <1 - cut.y, 1 - cut.x, 0>;
topshear = <topshear.y,topshear.x,0>;
topsize = <topsize.y,topsize.x,0>;
twist *= -1;
size = <size.y,size.x,size.z>;
if(mirror == "X")
{
pos.x *= -1;
rot2.y *= -1;
rot2.z *= -1;
rot = <0.00000, 0.00000, 0.70711, 0.70711> * llEuler2Rot(rot2);
}
else if(mirror == "Y")
{
pos.y *= -1;
rot2.x *= -1;
rot2.z *= -1;
rot = <0.00000, 0.00000, -0.70711, 0.70711> * llEuler2Rot(rot2);
}
else if(mirror == "Z")
{
pos.z *= -1;
rot2.x *= -1;
rot2.y *= -1;
rot = <-0.70711, -0.70711, -0.00000, 0.00000> * llEuler2Rot(rot2);
}
if(type == 2 || type == 1)
{
topshear = <topshear.y,-1 * topshear.x,0>;
topsize = <topsize.y,topsize.x,0>;
rot2 = llRot2Euler(rot);
rot2.z += PI_BY_TWO;
rot = llEuler2Rot(rot2);
size = <size.y,size.x,size.z>;
}
pos = llGetPos() + (pos * llGetRot());
rot = rot * llGetRot();
params = [pos,rot,size,type,holeshape,cut,hollow,twist,topsize,topshear];
}
else if(type == 3)
{
integer holeshape = (integer)llList2String(params,5);
vector cut = (vector)llList2String(params,6);
float hollow = (float)llList2String(params,7);
vector twist = (vector)llList2String(params,8);
vector dimple = (vector)llList2String(params,9);

vector rot2 = llRot2Euler(rot);
cut = <1 - cut.y, 1 - cut.x, 0>;
//dimple = <1 - dimple.y,1 - dimple.x,0>;
twist = <twist.y,twist.x,0>;
if(mirror == "X")
{
pos.x *= -1;
rot2.z *= -1;
rot2.y *= -1;
rot = <-0.00000, -1.00000, -0.00000, 0.00000> * llEuler2Rot(rot2);
}
else if(mirror == "Y")
{
pos.y *= -1;
rot2.x *= -1;
rot2.z *= -1;
rot = <1.00000, -0.00000, -0.00000, 0.00000> * llEuler2Rot(rot2);
}
else if(mirror == "Z")
{
pos.z *= -1;
rot2.x *= -1;
rot2.y *= -1;
rot = llEuler2Rot(rot2);
}
pos = llGetPos() + (pos * llGetRot());
rot = rot * llGetRot();
params = [pos,rot,size,type,holeshape,cut,hollow,twist,dimple];
}
else if(type > 3)
{
integer holeshape = (integer)llList2String(params,5);
vector cut = (vector)llList2String(params,6);
float hollow = (float)llList2String(params,7);
vector twist = (vector)llList2String(params,8);
vector holesize = (vector)llList2String(params,9);
vector topshear = (vector)llList2String(params,10);
vector advancedcut = (vector)llList2String(params2,0);
vector taper = (vector)llList2String(params2,1);
float revolutions = (float)llList2String(params2,2);
float radiusoffset = (float)llList2String(params2,3);
float skew = (float)llList2String(params2,4);

cut = <1 - cut.y, 1 - cut.x, 0>;
twist = <twist.y,twist.x,0>;
topshear = <topshear.x * -1,topshear.y * -1,0>;
taper *= -1;
radiusoffset *= -1;
skew *= -1;
if(mirror == "X")
{
vector rot2 = llRot2Euler(rot);
rot2.y *= -1;
rot2.y += PI;
rot = llEuler2Rot(rot2);
pos.x *= -1;
}
else if(mirror == "Y")
{
pos.y *= -1;
vector rot2 = llRot2Euler(rot);
rot2.x *= -1;
rot2.x += PI;
rot2.y *= -1;
rot = llEuler2Rot(rot2);
}
else if(mirror == "Z")
{
pos.z *= -1;
vector rot2 = llRot2Euler(rot);
rot2.x *= -1;
rot2 += <PI,PI,PI>;
rot = llEuler2Rot(rot2);
}
pos = llGetPos() + (pos * llGetRot());
rot = rot * llGetRot();
params = [pos,rot,size,type,holeshape,cut,hollow,twist,holesize,topshear];
params2 = [advancedcut,taper,revolutions,radiusoffset,skew];
}
llSay(19003,(string)llGetPos());
llSay(19001,llDumpList2String(params,":"));
if(params2 != []) llSay(19002,llDumpList2String(params2,":"));
else llSay(19002,"done");
params = [];
params2 = [];
}
}
}



Mirroring script (goes in the prim being mirrored)

CODE

//================================================== ==========================
// Prim Mirroring Script Set
// Written by Jeffrey Gomez
//
// Permissions Granted to Edit, Copy, Transfer, and Sell this script
// to any user, so long as this comment set remains intact, and is
// granted WITHOUT ANY WARRANTY. USE AT OWN RISK. And enjoy. =]
//
// For Instructions on Usage, Limitations, etc, see PrimPorter Mirror Code
//================================================== ==========================

// This just parses our data into llSetPrimitiveParams. Not much to see here.
integer use_set = 0;
integer SETONE = 1;
integer SETTWO = 2;
integer SETTHREE = 3;
vector pos;
rotation rot;
vector size;
integer type;
integer holeshape;
vector cut;
float hollow;
vector twist;
vector topsize;
vector topshear;
vector dimple;
vector advancedcut;
vector taper;
float revolutions;
float radiusoffset;
float skew;
vector holesize;

default
{
state_entry()
{
llListen(19001,"","","");
llListen(19002,"","","");
llListen(19003,"","","");
if(llGetCreator() != llGetOwner())
llRemoveInventory(llGetScriptName());
list params =llGetPrimitiveParams([PRIM_POSITION,PRIM_ROTATION,PRIM_SIZE,PRIM_TYPE]);
string para = llDumpList2String(params,":");
if(llGetListLength(params) < 11)
{
llSay(19000,"Y" + ":" + para);
llSleep(0.5);
llSay(18999,"done");
}
else
{
para = llDumpList2String(llList2List(params,0,9),":");
llSay(19000,"Y" + ":" + para);
llSleep(0.5);
para = llDumpList2String(llList2List(params,10,llGetListLength(params) - 1),":");
llSay(18999,para);
}
}
listen(integer chan, string name, key id, string msg)
{
if(chan == 19003)
llSetPos((vector)msg);
else
{
list params = llParseString2List(msg,[":"],[]);
if(chan == 19001)
{
pos = (vector)llList2String(params,0);
rot = (rotation)llList2String(params,1);
size = (vector)llList2String(params,2);
type = (integer)llList2String(params,3);
if(type < 3)
{
use_set = SETONE;
holeshape = (integer)llList2String(params,4);
cut = (vector)llList2String(params,5);
hollow = (float)llList2String(params,6);
twist = (vector)llList2String(params,7);
topsize = (vector)llList2String(params,8);
topshear = (vector)llList2String(params,9);
}
else if(type == 3)
{
use_set = SETTWO;
holeshape = (integer)llList2String(params,4);
cut = (vector)llList2String(params,5);
hollow = (float)llList2String(params,6);
twist = (vector)llList2String(params,7);
dimple = (vector)llList2String(params,8);
}
else if(type > 3)
{
use_set = SETTHREE;
holeshape = (integer)llList2String(params,4);
cut = (vector)llList2String(params,5);
hollow = (float)llList2String(params,6);
twist = (vector)llList2String(params,7);
holesize = (vector)llList2String(params,8);
topshear = (vector)llList2String(params,9);

}
}
else if(chan == 19002)
{
if(msg != "done")
{
advancedcut = (vector)llList2String(params,0);
taper = (vector)llList2String(params,1);
revolutions = (float)llList2String(params,2);
radiusoffset = (float)llList2String(params,3);
skew = (float)llList2String(params,4);
}
if(use_set == 1)
llSetPrimitiveParams([PRIM_POSITION,pos,PRIM_ROTATION,rot,PRIM_SIZE,size ,PRIM_TYPE,type,holeshape,cut,hollow,twist,topsize ,topshear]);
else if(use_set == 2)
llSetPrimitiveParams([PRIM_POSITION,pos,PRIM_ROTATION,rot,PRIM_SIZE,size ,PRIM_TYPE,type,holeshape,cut,hollow,twist,dimple]);
else if(use_set == 3)
llSetPrimitiveParams([PRIM_POSITION,pos,PRIM_ROTATION,rot,PRIM_SIZE,size ,PRIM_TYPE,type,holeshape,cut,hollow,twist,holesize,topshear,advancedcut,taper,revolutions,radiusoffset,skew]);
llRemoveInventory(llGetScriptName());
}
}
}
}
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.