Troy Vogel
Marginal Prof. of ZOMG!
Join date: 16 Aug 2004
Posts: 478
|
01-23-2006 11:46
Hi all, I am trying to make a drum shaped object do the following: rotate left for 5 seconds pause for 5 seconds rotate right for 5 seconds I built the following script and it works with one major problem. At the point the rotation stops, the prim rotates back to its root position. integer direction = 1; integer turning = 0;
default { state_entry() { llSetTimerEvent(5.0); } timer() { if (turning == 0) { if (direction == -1) { direction = 1; } else { direction = -1; } turning = 1; } else { turning = 0; } llTargetOmega(<direction,0,0>, 1*turning, 1); } }
So what you see is: 1- nice smooth rotation to the left 2-jerky quick jump rotation to the right and stop 3- nice smooth rotation to the right 4-jerky quick jump rotation to the left and stop I am guessing there's a call I can use to make the prim stop at it's current position and pause then resume rotating in the opposite direction from the point it paused at. What am I doing wrong? Thanks in advance for your help, Troy
|
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
|
01-23-2006 11:58
I have a tail wagging script that's configurable and will work for this. I'll send you one tonight when I'm in world.
|
Masakazu Kojima
ケロ
Join date: 23 Apr 2004
Posts: 232
|
01-23-2006 13:04
llTargetOmega() on non-physical objects is a client-side effect, so the server-side rotation does not change at all. The client-side rotation could be different for every client, but as long as the client was there when it started, you can make a pretty close guess about where it's going to be: (time*speed) radians from where it started. Since you have a fixed timer, all you need, at the bare minimum, is this at the start of your timer() event handler to update the server rotation to match the ideal client rotation: llSetRot( llGetRot() * llEuler2Rot(<direction * 5.0 * 1 * turning, 0, 0> );That has a lot of magic numbers and is inflexible, so I'd do it like this (style changed for brevity): float TIMER_FREQUENCY = 5.0; float TURN_SPEED = 1.0; vector TURN_AXIS = <1, 0, 0>;
integer direction = 1; integer turning = 0;
default { state_entry() { llSetTimerEvent(TIMER_FREQUENCY); } timer() { llSetRot(llGetRot() * llEuler2Rot( TURN_AXIS * (direction * TIMER_FREQUENCY * TURN_SPEED * turning) )); if (turning = !turning) // !!!: assignment, not comparison direction = - direction; llTargetOmega(TURN_AXIS * direction, TURN_SPEED * turning, 1); } }
|
Troy Vogel
Marginal Prof. of ZOMG!
Join date: 16 Aug 2004
Posts: 478
|
01-23-2006 14:18
Interesting. I kinda guessed that the rotation was happening on my machine and not at the server. I like the brevity changes you made -- I was kind of going in that direction with getting the script compact. I am glad you made them. As for the calculation that takes place -- honestly that's what I was thinking about doing but I did not know a few of the function calls you used. And I was being lazy too a little bit.  Also, what if I said this kind of is going to be a very useless but very fun object? Such as the drum of a washing machine? So I would need to make it physical for it to truly tumble things inside it right? If it was physical how would that change the code you supplied? I am sorry if I come across as quite green. I just use SL to model my architectural designs usually. While I am a programmer in RL, I have avoided doing anything in SL so far. With this project I am kinda breaking my own rules. But that's good right? Thanks for the replies. Keep them coming, I would be interested in seeing other people's variations on this concept. UPDATE: just tried your version of the script. Works like a charm. THANKS, Troy Vogel
|