Orbiter
|
Oberon Onmura
Registered User
Join date: 28 Dec 2006
Posts: 125
|
03-26-2007 20:24
I found this script on a terrific website. It causes an object to orbit around a point. My question is - if I apply this to, say, a fish swimming in a pond, how can I make the fish's nose always point "forward?" Right now, the body remains static as it orbits.
Always grateful for the help!
// Orbitting around a single point with cos and sin. // Made by Juntalis // Cleaned & Hacked by Strife Onizuka vector VECTOR_ORIGIN; float angle; float radius = 2; //in meters out from the start float increment = -3; // positive = counterclockwise
default { state_entry() { VECTOR_ORIGIN = llGetPos(); llSetTimerEvent(0.01); } timer() { llSetPos( <llCos(angle * DEG_TO_RAD), llSin(angle * DEG_TO_RAD), 0> * radius + VECTOR_ORIGIN ); angle += increment; } }
|
Helsing Arkin
Registered User
Join date: 25 Dec 2006
Posts: 2
|
03-26-2007 20:49
There is a free "Slow Rotation on Axis" script I use quite often in SL.
Make your fish with two prims one being a sphere containing the slow rotation script and the other your fish. link the two prims and make the sphere 100% transparent so it's not seen and poof you have a rotating fish swimming around, with his (or her) nose pointing in the direction of travel.
Hope thats what you where looking for...
Good Day.
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
03-27-2007 02:28
From: Oberon Onmura I found this script on a terrific website. It causes an object to orbit around a point. My question is - if I apply this to, say, a fish swimming in a pond, how can I make the fish's nose always point "forward?" Right now, the body remains static as it orbits.
Always grateful for the help!
// Orbitting around a single point with cos and sin. // Made by Juntalis // Cleaned & Hacked by Strife Onizuka vector VECTOR_ORIGIN; float angle; float radius = 2; //in meters out from the start float increment = -3; // positive = counterclockwise
default { state_entry() { VECTOR_ORIGIN = llGetPos(); llSetTimerEvent(0.01); } timer() { llSetPos( <llCos(angle * DEG_TO_RAD), llSin(angle * DEG_TO_RAD), 0> * radius + VECTOR_ORIGIN ); angle += increment; } } Rotate the prim as well as change its position. I'd suggest that you use llSetPrimitiveParams to do both steps in one hit.
|
Oberon Onmura
Registered User
Join date: 28 Dec 2006
Posts: 125
|
03-27-2007 06:47
From: Helsing Arkin There is a free "Slow Rotation on Axis" script I use quite often in SL.
Make your fish with two prims one being a sphere containing the slow rotation script and the other your fish. link the two prims and make the sphere 100% transparent so it's not seen and poof you have a rotating fish swimming around, with his (or her) nose pointing in the direction of travel.
Hope thats what you where looking for...
Good Day. Thanks much. I was hoping not to go this route. Actually, when I did use this method, I found that it wouldn't work if the prim I want to rotate is flexi. And who wants to see a stiff fish? 
|
Oberon Onmura
Registered User
Join date: 28 Dec 2006
Posts: 125
|
03-27-2007 06:49
From: Newgate Ludd Rotate the prim as well as change its position. I'd suggest that you use llSetPrimitiveParams to do both steps in one hit. Alas, scripting is way beyond my skill set. But to my untutored eyes this looks like the way to go. Thanks!
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
03-27-2007 07:46
From: Oberon Onmura Alas, scripting is way beyond my skill set. But to my untutored eyes this looks like the way to go. Thanks! Not tested but // Orbitting around a single point with cos and sin. // Made by Juntalis // Cleaned & Hacked by Strife Onizuka // Played with by Newgy vector VECTOR_ORIGIN; float angle; float radius = 2; //in meters out from the start float increment = -3; // positive = counterclockwise float ninety = 1.570796; // 90 degrees in radians default { state_entry() { VECTOR_ORIGIN = llGetPos(); llSetTimerEvent(0.01); } timer() { float rads = angle * DEG_TO_RAD; vector pos = <llCos(rads), llSin(rads), 0. > * radius + VECTOR_ORIGIN; // The actual heading is 90 degrees off from position. if(increment < 0) rads -= ninety; else rads += ninety; rotation rot = llEuler2Rot(< 0. , 0. , rads >); llSetPrimitiveParams( [ PRIM_POSITION , pos , PRIM_ROTATION , rot ] ); angle += increment; } }
|
Oberon Onmura
Registered User
Join date: 28 Dec 2006
Posts: 125
|
03-27-2007 09:11
From: Newgate Ludd Not tested but // Orbitting around a single point with cos and sin. // Made by Juntalis // Cleaned & Hacked by Strife Onizuka // Played with by Newgy vector VECTOR_ORIGIN; float angle; float radius = 2; //in meters out from the start float increment = -3; // positive = counterclockwise float ninety = 1.570796; // 90 degrees in radians default { state_entry() { VECTOR_ORIGIN = llGetPos(); llSetTimerEvent(0.01); } timer() { float rads = angle * DEG_TO_RAD; vector pos = <llCos(rads), llSin(rads), 0. > * radius + VECTOR_ORIGIN; // The actual heading is 90 degrees off from position. if(increment < 0) rads -= ninety; else rads += ninety; rotation rot = llEuler2Rot(< 0. , 0. , rads >); llSetPrimitiveParams( [ PRIM_POSITION , pos , PRIM_ROTATION , rot ] ); angle += increment; } }
Way beyond the call of duty! Thanks so much! I'll let you know what happens.
|
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
|
03-27-2007 12:53
If there's no good reason to move it like that, surely it's better to use llTargetOmega?
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
03-27-2007 12:59
From: AJ DaSilva If there's no good reason to move it like that, surely it's better to use llTargetOmega? Well I guess it depends on what the overall effect is going to be. For simple stuff then yes llTargetOmega is ok but personally I think llTargetOmega is a bit glitchy since about 3 updates ago when they broke it and its never looked quite right since (IMHO). Plus its only a client side visual effect so multiple users will not necessarily see the same thing which you can at least expect with 'real' rotation.
|
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
|
03-27-2007 13:01
What do you mean "glitchy"? Only problem I've noticed is slowdown when using it with huge prims that intersect lots of others on their way 'round.
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
03-27-2007 13:12
Hmm, may be its just me then, but I've noticed an awful lot of what I assume are llTargetOmega driven items suffer from periodic stuttering, they rotate smoothly for a while then suddenly restart the rotation from zero as if they had been reset.
|