Incrimental movement functions! (less intensive then physical damping)
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
09-09-2003 17:29
I commenly use these functions when doing 'effects' type 'smooth' movement (stuff for doors, drawers, etc). Using these to emulate smooth movement is alot less intensive on the sim then using physics to move. The functions: incrimentToPos(vector pos, integer incriments) { vector moveIncriments = (pos - llGetPos()) / incriments; integer i; for(i = 0; i < incriments; i++) { llSetPos(llGetPos() + moveIncriments); } }
The above func moves to pos incrimentally, defined by the amnt of incriments you pass to it. Please note, that the more incriments you have, the slower the movement will be (each incriment takes .2 seconds to complete). incrimentToRot(rotation targetRot, integer incriment) { //llSetRot()'s in incriments, specified by incriment, to targetRot vector eTargetRot = llRot2Euler(targetRot); integer i; for(i = 0; i < incriment; i++) { rotation rotTo = llGetRot(); rotation toGoTo = llEuler2Rot(eTargetRot / incriment); rotTo *= toGoTo; llSetRot(rotTo); } }
The above rotates in the same way incrimentToPos() moves. Ty to Lance LeFay for providing the framework of incrimentToRot()  Feel free to use these any way you wish. -Chris, giver of the snippets NOTE: DO NOT PASS 0 AS THE INCRIMENT!!! The script will blow up if you do!
|
Nick Fortune
National Alchemist
Join date: 30 May 2003
Posts: 74
|
09-12-2003 09:50
0.o
|
Bosozoku Kato
insurrectionist midget
Join date: 16 Jun 2003
Posts: 452
|
09-13-2003 04:09
put an if check in it for an increment of 0 then :) incrimentToPos(vector pos, integer incriments) { if (incriments != 0) { vector moveIncriments = (pos - llGetPos()) / incriments; integer i; for(i = 0; i < incriments; i++) { llSetPos(llGetPos() + moveIncriments); } } else { llWhisper(0,"Increment input = 0, aborting!"); } }
Boso
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
09-13-2003 23:09
Ah, forgot about that, right now Im learning Java, and am totally amazed by things called exceptions, and how you can try and catch them... which is why I didnt want to include something like an llSay() in there if it got 0 ('cause, I mean.... the script does it anyway, so why bother?)
|
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
|
09-17-2003 11:57
From: someone Originally posted by Bosozoku Kato put an if check in it for an increment of 0 then 
Actually, what you probably want is incrimentToPos(vector pos, integer incriments) { if (incriments <= 0) incriments = 1; vector moveIncriments = (pos - llGetPos()) / incriments; integer i; for(i = 0; i < incriments; i++) { llSetPos(llGetPos() + moveIncriments); } }
_____________________
Sarcasm meter: 0 |-----------------------*-| 10 Rating: Awww Jeeze!
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
10-21-2003 05:44
Note: for SL version 1.1, these functions are no longer needed for smooth non-physical 'damped' movement 
|
Olympia Rebus
Muse of Chaos
Join date: 22 Feb 2004
Posts: 1,831
|
Re: Incrimental movement functions! (less intensive then physical damping)
03-21-2004 19:35
Pardon my newbie ignorance, but how would this code be applied to a new script. In what context? Would you (or anyone else) be kind enough to show me how the code would appear within a sample script? Thanks. Olympia [ The functions: incrimentToPos(vector pos, integer incriments) { vector moveIncriments = (pos - llGetPos()) / incriments; integer i; for(i = 0; i < incriments; i++) { llSetPos(llGetPos() + moveIncriments); } }
|
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
|
Re: Re: Incrimental movement functions! (less intensive then physical damping)
03-22-2004 14:25
incrimentToPos(vector pos, integer incriments) { vector moveIncriments = (pos - llGetPos()) / incriments; integer i; for(i = 0; i < incriments; i++) { llSetPos(llGetPos() + moveIncriments); } }
default { state_entry() { llListen(0,"",llGetOwner(),""); }
listen(integer channel, string name, key id, string message) { list m = llParseString2List(message,["::"],[""]); if(llGetListLength(m) > 1) { incrimentToPos(llList2Vector(m,0),llList2Integer( m, 1)); } } }
or something along those lines.
_____________________
i've got nothing. 
|
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
|
03-22-2004 14:33
Note, however, that as Chris said, while this function still works, it's no longer necessary as of the release of SL 1.1 six months ago. Also, it's spelled "increment". 
|
Tracy Murray
Junior Member
Join date: 9 Nov 2003
Posts: 8
|
07-22-2004 08:27
Why are these functions no longer necessary? What in the SL 1.1 release made them obsolete? I still haven't figured out how to do decently smooth non-physical movement.
|