From: Haravikk Mistral
Joannah Cramer's code snippet should be all that you need. To have your offset work for all rotations you need multiply the offset by the rotation of the object.
If this is not working, then there is something else affecting your object....
Okay, so this thread is a bit old now but I resurrect it because:
a) I have been working all this time and it *still* doesn't work! (I am an idiot I guess)
b) I "kind of" solved it and the solution is even more mystifying than the original problem!
Essentially I made a test bed of simple prims with a simplified version of the script so as to test the rotation of the offset with no other junk to mess it up. I started off with the original solution I had worked out for the rotation before I even
started this thread and was going to work through all the possible solution methodically until I found the right one.
Unfortunately, (sort of), it worked on the very first go and has worked perfectly ever since.
So I had it right all along, and the wiki had it right, and all the hints I got on this thread were essentially right, but the sad thing is the script still does not work in the actual fireplace. The same script with the same variables works in the test construction, but *not* in the fireplace and the curious thing is that
there is only one difference between them. The fireplace rezzes a fire which is
multiprim object, whereas the test construction rezzes a simgle sphere. WTF?
To confirm that the rezzed object being single or multi-prim is the only difference and indeed the cause of the problem, I put a single sphere inside my fireplace and changed only the name of the object to be rezzed so it would rez the sphere instead of the fire. Bingo. Now the fireplace works every single time. However, the second I replace the single sphere with the multiprim fire object again, it stops working.
Here is the code:
// ======================================
// rez-rot test script by Jeremy Bender
// ======================================
integer _rezzed;
vector _currPos;
vector _currOffset;
vector _currPosPlusOffset;
rotation _currentRot;
vector _pos2Rez;
default
{
on_rez(integer start_param)
{
llResetScript();
}
state_entry()
{
llWhisper(59,"poke");
_rezzed = FALSE;
}
touch_start(integer total_number)
{
if (_rezzed){
llWhisper(59,"poke");
_rezzed = FALSE;
}
else{
_currentRot = llGetRot();
_rezObjRot = llEuler2Rot(<PI_BY_TWO, 0.0, 0.0>);
_currPos = llGetPos();
_currOffset = <1.0, 0.0, -1.0>;
_currPosPlusOffset = llGetPos() + _currOffset;
_pos2Rez = _currPos - ((_currPos * _currentRot) - (_currPosPlusOffset * _currentRot));
llRezObject("pink object 1", _pos2Rez, ZERO_VECTOR, ZERO_ROTATION, 42);
_rezzed = TRUE;
}
}
}
I simply cannot see how the fact that the object being rezzed has more than one prim has anything to do with this and would appreciate it if someone could show me why it does. There is only one rotation, and a couple of vectors that describe the position of the parent object, the offset, and eventually the "_pos2Rez" or position to rez the object is calculated from that. The object being rezzed has
absolutely nothing to do with any of these variables as far as I can see.
And it's not that the final rezzed fire is off-place because it's centre is not the same as the parent prim of the fire "prim-set's" centre, the whole thing is seven prims or so and all are within 0.1 of each other.
What happens is that if the prim being rezzed is a multiprim object, the formula above fails to rotate the offset of the object. Almost as if it knows that it's about to rez a multi-prim object even though the script cannot know this.
How can a script that has no knowledge of *what* it's about to rez, and only calculates a vector at which the rez is going to take place, act one way if the object eventually rezzed is a sphere and another way if it is a multiprim object?
Is the occult at work in SL?

Argh!