Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
01-01-2010 10:59
I'm trying to make variation on the theme of tables that generate chairs when you touch them; this is to be a carpet that rezzes temp on rez cushions where you touch it, all of them facing towards the center. My cushions are flattened toruses, for the time being. I'm almost there with integer param; rotation r; default { state_entry() { param = ((integer)("0x"+llGetSubString((string)llGetKey(),-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF; r = llEuler2Rot(<0.00, 90.00, 180.00>*DEG_TO_RAD); }
touch_start(integer total_number) { vector spot = llDetectedTouchPos(0); spot.z+=0.125; vector pos = llGetPos(); pos.z+=0.25; llRezAtRoot("cushion",spot,ZERO_VECTOR, r*llRotBetween( < 1.0, 0.0, 0.0 >, llVecNorm(pos-spot)),param); } }
However, if I touch the carpet too close to the carpet's positive x axis in sim terms (that is, due East, or nearly due East, of the carpet's center) the cushions rez at an angle rather than flat. Can anyone advise me? ETA -- wow! the bug with vector brackets<> seems to be fixed.
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-01-2010 11:32
From: Innula Zenovka ETA -- wow! the bug with vector brackets<> seems to be fixed. for numbers... if it's a character it still has issues.... your addition of the height before determining the rot is part of the issue... the thickness of the rug would be the other.... the relative z planes need to match. insert the rugs .z component into the the touch position, then calculate the rotation, and THEN add the height. cushion = llDetectedTouchPos( 0 ); rug = llGetPos(); cushion.z = rug.z llRezAtRoot("cushion", cushion + < 0.0, 0.0, 0.125 >, ZERO_VECTOR, r * llRotBetween( < 1.0, 0.0, 0.0 >, llVecNorm( rug - cushion ) ), param );
alternatively you could add half the rugs thickness to to the rug.z to get the needed equality between the 2 z components for a non tilted rez rotation. note that all of this is based on the asumption that the rug is lying on a flat region plane ETA: this is what it would look like if you needed it to rez as you expect when the rug itself is turned on anything more than just the z axis... integer gIntParam; rotation gRotCorrection; vector gPosOffset = < 0.0, 0.0, 0.125 >;
default{ state_entry(){ gIntParam = ((integer)("0x" + llGetSubString( (string)llGetKey(), -8, -1 )) & 0x3FFFFFFF) ^ 0xBFFFFFFF; gRotCorrection = llEuler2Rot( < 0.00, 90.00, 180.00 > * DEG_TO_RAD ); }
touch_start( integer vIntNull ){ vector vPosRug = llGetPos(); vector vSizRug = llGetScale() * 0.5; vector vPosCushion = llDetectedTouchPos( 0 ) - (< 0.0, 0.0, vSizRug.z > * llGetRot() ); llRezAtRoot( "cushion", vPosCushion + ((gPosOffset + < 0.0, 0.0, vSizRug.z >) * llGetRot()), ZERO_VECTOR, (gRotCorrection * llGetRot()) * llRotBetween( < 1.0, 0.0, 0.0 > * llGetRot(), llVecNorm( vPosRug - vPosCushion ) ), gIntParam ); } }
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
01-01-2010 12:32
Thank you so much, yet again, Void. Both methods do exactly what I need.
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
01-01-2010 23:51
Yeah... Void's like that... 
|