Prim rotation around specific coordinates
|
|
Gorana Kolache
Registered User
Join date: 28 Feb 2006
Posts: 18
|
07-31-2006 03:08
Hello everyone,
today is my brain somehow broken, so i have to ask you to help me a bit.
I would like to rotate an object (willl be probably a ball prim) around <10.0, 11.0, 12.0> in circle rotation with radius of 2.0 and angle of 5° ( <0.0, 0.0, 5.0> )
Also, if it is not too complicate, i would like to make it to rotate on elipse rotation where r(min) = 2.0 and r(max) = 3.0
Please help me with that, and person who solves that problem for me will get a small surprise.
Thank you very much,
G.
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
07-31-2006 05:11
elliptical rotation: vector root; float ellipse_x; float ellipse_y; float angle = 0;
default {
on_rez( integer Parameter ) { llResetScript(); } state_entry() {
root = <10, 11, 12>; // set the center point here ellipse_x = 3.0; // r_max ellipse_y = 2.0; // r_min
llSetTimerEvent( 0.2 ); // or more depending how smooth and fast it's to be } timer() { angle += 5.0 * DEG_TO_RAD; if( angle >= TWO_PI ) angle -= TWO_PI; float x = ellipse_x * llCos(angle); float y = ellipse_y * llSin(angle); llSetPrimitiveParams( [ PRIM_POSITION, root + <x, y, 0>, PRIM_ROTATION, llEuler2Rot( <0.0, 0.0, angle> ) ] ); } }
note this version will have the prim always 'face' the center point with the same side. If you need the prim itself to rotate slower or faster while in orbit, add extra variable to store angle and alter it like angle variable in this script, then use this prim_angle for PRIM_ROTATION parameter. or something o.O;
|
|
Gorana Kolache
Registered User
Join date: 28 Feb 2006
Posts: 18
|
07-31-2006 05:41
Yay Thankies  A prez is on it's way G.
|
|
Indy Quamar
Registered User
Join date: 16 Sep 2006
Posts: 69
|
12-15-2006 11:25
is it possible to make this script work so the orbiter is going around a named prim verses orbiting a map grid cord.?
|
|
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
|
12-15-2006 12:21
Here's a quick shot at adding a named object for axis: vector root; float ellipse_x; float ellipse_y; float angle = 0;
string axis_name = "Object";
default {
on_rez( integer Parameter ) { llResetScript(); } state_entry() {
// root = <10, 11, 12>; // set the center point here root = llGetPos(); // default axis is around myself (sensor will update) ellipse_x = 3.0; // r_max ellipse_y = 2.0; // r_min
llSetTimerEvent( 0.2 ); // or more depending how smooth and fast it's to be
// non moving target llSensor(axis_name, "", ACTIVE | PASSIVE, 20.0, PI); // 20m range // moving target // llSensorRepeat(axis_name, "", 20.0, ACTIVE | PASSIVE, PI, 2.0); // 20m range } timer() { angle += 5.0 * DEG_TO_RAD; if( angle >= TWO_PI ) angle -= TWO_PI; float x = ellipse_x * llCos(angle); float y = ellipse_y * llSin(angle); llSetPrimitiveParams( [ PRIM_POSITION, root + <x, y, 0>, PRIM_ROTATION, llEuler2Rot( <0.0, 0.0, angle> ) ] ); }
sensor(integer num_detected) { root = llDetectedPos(0); }
no_sensor() { llWhisper(0, axis_name + " not found."); llSensorRemove(); }
}
My apologies if it does not compile, I'm not in world atm Oops - syntax error fixed. Seems like I forget the type every time I call llSensor.
|
|
Indy Quamar
Registered User
Join date: 16 Sep 2006
Posts: 69
|
12-15-2006 13:54
21,43 ERROR function mismatchs type or number of arguement
is the error i am getting from your script Boss. I guess i need to go to scripting school cause i dont have a clue as to what to try next
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
12-15-2006 15:27
From: Indy Quamar 21,43 ERROR function mismatchs type or number of arguement
is the error i am getting from your script Boss. I guess i need to go to scripting school cause i dont have a clue as to what to try next find the line llSensor(axis_name, "", 20.0, PI); // 20m range
and replace with llSensor( axis_name, NULL_KEY, PASSIVE | ACTIVE, 20.0, PI ); // 20m range
|
|
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
|
12-16-2006 06:56
Thanks for covering that Joannah
|
|
Indy Quamar
Registered User
Join date: 16 Sep 2006
Posts: 69
|
12-20-2006 12:20
Thank you very much! One last question...well 2....this line llSensor(axis_name, "", 20.0, ACTIVE | PASSIVE, PI, 2.0); // 20m range workes good. I got the orbit around the object, but if the object is moveing i think it should be llSensorRepeat(axis_name, "", 20.0, ACTIVE | PASSIVE, PI, 2.0); // 20m range but this is giveing me the same error as before 21,75 ERROR function mismatchs type or number of arguement
I dont see why this should happen but it is. Other question is less important but is is possible to put in a z axis as well? i have done this but it doesnt want to work. Somehow think i should have started my scripting class with something simpler LOL
|
|
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
|
12-21-2006 05:31
From: Indy Quamar Thank you very much! One last question...well 2....this line llSensor(axis_name, "", 20.0, ACTIVE | PASSIVE, PI, 2.0); // 20m range workes good. I got the orbit around the object, but if the object is moveing i think it should be llSensorRepeat(axis_name, "", 20.0, ACTIVE | PASSIVE, PI, 2.0); // 20m range but this is giveing me the same error as before 21,75 ERROR function mismatchs type or number of arguement
I dont see why this should happen but it is. Other question is less important but is is possible to put in a z axis as well? i have done this but it doesnt want to work. Somehow think i should have started my scripting class with something simpler LOL llSensorRepeat takes one additional argument than llSensor does, which is how often you want to sense for things. For example, if you wanted to scan for objects every 5 seconds, you would change llSensor(axis_name, "", 20.0, ACTIVE | PASSIVE, PI, 2.0); // 20m range
to llSensorRepeat(axis_name, "", 20.0, ACTIVE | PASSIVE, PI, 2.0, 5.0); // 20m range, 5 second repeat
|
|
Indy Quamar
Registered User
Join date: 16 Sep 2006
Posts: 69
|
12-27-2006 08:07
this is still giveing me an error message. I have a scripting friend trying to take a shot at it so if he comes up with something i will post it. I swear i hate scripting. Guess thats why i am a builder and not a scripter lol
|
|
Ryken Redgrave
Registered User
Join date: 26 Dec 2006
Posts: 13
|
12-28-2006 17:00
Thanks for this code, btw.  I've been able to get this to work, however the 'orbiting' mechanic is very chunky. The object moves a little bit in its orbit, pauses visibly, moves, pauses, etc. It's reminiscent of a second hand ticking around the clock face. Is this expected behavior? Is there a way to get the prim to move smoothly?
|