|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
08-27-2008 21:12
I have a problem with props in MLP. Here's all the relevant code. There was an issue about rez coords and what SL thinks is the center of the object. I compensated for that by doing everything relative: MLP rezzes the prop at zero. If you move it X meters, it saves that change as the new offset. Change it again, and it adjusts by the difference between where it rezzed it and where it is now. Seems to work fine. However, if I rotate the mlp object (and STOP, which causes the ref pos to be updated), and click the pose again, the object is rezzed in a slightly different position, but ONLY if it's a complicated object. This problem happens even if the MLP object is simple 1-prim. It only seems to happen for z-axis rotations. (I tried one of the other axes and it was OK -- don't remember which one and i'll test more.) Can anyone see a flaw in rezzing that would make the relative position change as the MLP object rotates? Thanks! vector RefPos; rotation RefRot;
getRefPos() { //reference position RefPos = llGetPos(); RefRot = llGetRot(); integer z = (integer)llGetObjectDesc(); RefPos.z += (float)z/100.0; }
rez_prop(string pose) { llSay(ChatChan, "DIE"); integer ix = llListFindList(Poses, [pose]); if (ix == -1) { Pose == ""; llSetTimerEvent(0.0); return; } string prop = llList2String(Props, ix); string data = llList2String(Positions, ix); list ldata = llParseString2List(data, ["/"], []); vector pos = (vector)llList2String(ldata, 0); vector erot = (vector)llList2String(ldata, 1);
pos = pos * RefRot + RefPos; rotation rot = llEuler2Rot(erot*DEG_TO_RAD) * RefRot; // llSay(0, "rezzing '" + prop + "' at " + (string) pos); llRezObject(prop, pos, <0.,0.,0.>, rot, ChatChan); llSetTimerEvent(60.0); Pose = pose; }
The only hypothesis I can come up with is that the axis of rotation for the rezzed object isn't the same as the position for llRezObject().
|
|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
08-27-2008 21:33
From: Lear Cale I have a problem with props in MLP. Here's all the relevant code. There was an issue about rez coords and what SL thinks is the center of the object. I compensated for that by doing everything relative: MLP rezzes the prop at zero. If you move it X meters, it saves that change as the new offset. Change it again, and it adjusts by the difference between where it rezzed it and where it is now. Seems to work fine. However, if I rotate the mlp object (and STOP, which causes the ref pos to be updated), and click the pose again, the object is rezzed in a slightly different position, but ONLY if it's a complicated object. This problem happens even if the MLP object is simple 1-prim. It only seems to happen for z-axis rotations. (I tried one of the other axes and it was OK -- don't remember which one and i'll test more.) Can anyone see a flaw in rezzing that would make the relative position change as the MLP object rotates? Thanks! vector RefPos; rotation RefRot;
getRefPos() { //reference position RefPos = llGetPos(); RefRot = llGetRot(); integer z = (integer)llGetObjectDesc(); RefPos.z += (float)z/100.0; }
rez_prop(string pose) { llSay(ChatChan, "DIE"); integer ix = llListFindList(Poses, [pose]); if (ix == -1) { Pose == ""; llSetTimerEvent(0.0); return; } string prop = llList2String(Props, ix); string data = llList2String(Positions, ix); list ldata = llParseString2List(data, ["/"], []); vector pos = (vector)llList2String(ldata, 0); vector erot = (vector)llList2String(ldata, 1);
pos = pos * RefRot + RefPos; rotation rot = llEuler2Rot(erot*DEG_TO_RAD) * RefRot; llSay(0, "rezzing '" + prop + "' at " + (string) (pos - RefPos)); // debug only
llRezObject(prop, pos, <0.,0.,0.>, rot, ChatChan); llSetTimerEvent(60.0); Pose = pose; }
The only hypothesis I can come up with is that the axis of rotation for the rezzed object isn't the same as the position for llRezObject().
|
|
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
|
08-27-2008 22:22
try llRezAtRoot() instead of llRezObject()
regs, /esc
_____________________
http://slurl.com/secondlife/Together
|
|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
08-28-2008 11:19
Yup, that solved the problem, thanks!
Evidently I was right: with llRezObject, the origin for position is not the origin for rotation (which, IMHO, was a bug). I imagine they dealt with the bug by providing a new function that uses the same origin for both purposes.
|