| Content Creation Discuss building, scripting, and other forms of content creation for SL. |
| |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| Junior Member ![]() Join Date: Nov 2009
Posts: 3
| Okay i've made this bridge that rotates when you click on the root prim. It rotates fine but it's just way too fast and i can't figure out how to slow it down. I don't want it to pause ten seconds or so - it would just be nice if it would take more time getting from frame 0 to frame 1 and back. I was told to change the llsleep(delay) to llsleep(number); but this just tells it to pause for however long i tell it to. I've tried going through my rotation scripts and such to see if i can get parts out of it but the script seems to reject it with an 'error.' Any way here's the script: float delay=0.3; string status="off"; go(){ llMessageLinked(LINK_SET,2,"p1",""); llSleep(delay); llMessageLinked(LINK_SET,2,"p0",""); } default { on_rez(integer r){llResetScript();} state_entry(){ llMessageLinked(LINK_SET,2,"p0",""); //Start is at frame 0 } touch_start(integer total_number) {if(status=="off"){ status="on"; llSetTimerEvent(delay*6); }else{ status="off"; llSetTimerEvent(0);} } timer(){go();} } Any idea if i'm missing something or need to change something? Like i said - i'd like to be able to change the ammount of time that it takes to get from point A to point B and back again. Thanks again for your help, i've been trying to work it out all day i even looked on Google for answers before asking here. |
| | |
| | #2 (permalink) |
| Animates and Scripts ![]() Join Date: Oct 2009 Location: rural northeast US
Posts: 33
My Mood: SL Join Date: Sept 2006
Business: jeaniesing's things | This script only tells the other pieces what to do with llMessageLinked... perhaps post what the other script (in the pieces) says and someone could help? |
| | |
| 1 User Agreed: |
| | #3 (permalink) | ||
| Doing stuff ![]() ![]() ![]() ![]()
Happles!
Join Date: Sep 2007 Location: Glasgow, Scotland
Posts: 2,778
My Mood: SLShopper Ads: 1 SL Join Date: 14/10/2006
Business: MagoTek Industries | Quote:
luckily for you, this is one of my areas of expertise ![]() The best way to do this. First of all, get your values for A and B. Position, rotation, and scale, if applicable. The next thing you need to do is to interpolate them. This function suffices for position and rotation: Code: calc_pos_scale()
{
positions = [];
scales = [];
posdifference = end_pos - begin_pos;
scaledifference = end_scale - begin_scale;
posincrement = posdifference / frames;
scaleincrement = scaledifference / frames;
for (i=0;i <= frames;i++)
{
positions += begin_pos + (posincrement*i);
scales += begin_scale + (scaleincrement*i);
}
}
For rotation, it's in two parts Code: calc_rot_frames()
{
rotations = [];
rotincrement = 1.0 / (float)frames;
for (i=0;i <= frames;i++)
{
rotations += slerp( begin_rot, end_rot, (rotincrement*i) );
}
}
rotation slerp( rotation a, rotation b, float f )
{
float angleBetween = llAngleBetween(a, b);
if ( angleBetween > PI )
angleBetween = angleBetween - TWO_PI;
return a*llAxisAngle2Rot(llRot2Axis(b/a)*a, angleBetween*f);
}
Once you run your data through these functions, you'll be left with 3 lists of positions, scales, and rotations. This processing will only need to be done once unless the start/end values change, so do it once and store the valuesfor reuse later. You'll simply want to run through an llSetPrimitiveParams loop with the values from each element of the list, and the 0.2 inherent delay in the function will slow things down for you. Lastly, bear in mind that this is all rather resource intensive. You're going to be sending an object update with every frame, and it can be a bit taxing on the sim. it's advised to only do in small parts as necessary, not something you should run constantly.
__________________ Wounds, both physical and mental, heal in time. bones reknit, therapy and drugs make you forget. Life goes on. But nothing cures death. Please remember this. Quote:
| ||
| | |
![]() |
| Thread Tools | |
| Display Modes | |
| |