Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Problems with resetting prim rotation

Maxim Mistwallow
Registered User
Join date: 8 Sep 2008
Posts: 10
09-29-2008 09:35
Greetings! Hopefully somebody will help me, or explain why I can't be helped. :)

I'm trying to implement resetting of positions of moving prims. Currently I have a problem with resetting working only ONCE.

I create a prim and put two scripts there. Here they are.


default
{
state_entry()
{
llTargetOmega(<0,0,1>,0.3,1.0);
}

}


And the second one.


default
{
touch_start(integer total_number)
{
state reset;
}
}

state reset
{
state_entry()
{
llSetPrimitiveParams([PRIM_ROTATION, llEuler2Rot(<0, 0, 45> * DEG_TO_RAD)]);
llOwnerSay("Position has been reset";);
state default;
}
}


When the prim starts rotation, I touch it, it immediately 'leaps' to the 45 degrees around Z axis, says "Position has been reset", and continues to rotate according to the first script. But when I touch it second, third, etc time, it only says "Position has been reset", but no longer 'leaps' to the 45 degrees.

Can this be helped ? Or have I been just another guy to discover well-known bug? :)
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
09-29-2008 09:57
This is not a bug.
"llSetPrimitiveParams([PRIM_ROTATION, llEuler2Rot(<0, 0, 45> * DEG_TO_RAD)]); "
will set your object to the wanted rotation in world.
llTargetOmega does not touch your object at all, it only tells the client (the viewer on your computer) to show your object spinning:)
_____________________
From Studio Dora
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
09-29-2008 09:57
I *think* (and I could be way wrong) what is happening is...

* First script runs, sim tells client "start rotating the object"
* You touch it, 2nd script fires, sim says "Oh, this object's rotation changed, I better tell the client"
* Sim tells client "object's rotation is now XXX". Client applies that rotation, which makes the object jump, and then keeps rotating the object like it's been told to
* You touch it again, sim saya "Hmm, this object's new rotation is the same as the old rotation, so there's no need to update the client". So nothing happens

Remember, llTargetOmega is managed by the client (in most cases), while Set Prim Params happens on the server. So from the POV of the server, subsequent touches don't change anything.

How to get around it... not sure :)

Edit: Never mind, Dora got it :)
Maxim Mistwallow
Registered User
Join date: 8 Sep 2008
Posts: 10
09-29-2008 10:12
Ffffancy... :)

But how to get aroung that issue? I really need to be able to reset those positions!
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
09-30-2008 14:58
You can stop the spinning by llTargetOmega( <0,0,1>, 0.0, 1.0 );
rhen set rotation: llSetPrimitiveParams([PRIM_ROTATION...
and finally restart the spinning using llTargetOmega()

That does work but may not look the way you want.
The two functions are not coordinated in any way. They may look coordinated if none of them are changed while the object is spinning.
_____________________
From Studio Dora
Maxim Mistwallow
Registered User
Join date: 8 Sep 2008
Posts: 10
10-01-2008 09:53
Well, I've found an acceptible solution. It looks like this:

llSetPrimitiveParams([PRIM_ROTATION, llEuler2Rot(<0, 0, 45.1> * DEG_TO_RAD)]);
llSetPrimitiveParams([PRIM_ROTATION, llEuler2Rot(<0, 0, 45> * DEG_TO_RAD)]);

It works. :)