SHARE
TWEET

Untitled

a guest Jul 20th, 2019 117 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. integer carChannel = -5436462;
  2. integer carListener;
  3.  
  4.  
  5. integer LINK_GRIP = 9;
  6. integer walker_channel = -4357986;
  7. float time_since_walker = 10;
  8.  
  9.  
  10. // Modulates amplitude using sine wave where the X axis is time
  11. // Used for pendulums, things that go back and forth..
  12. // References...
  13. // https://en.wikipedia.org/wiki/Damped_sine_wave
  14. // http://www.sengpielaudio.com/calculator-timedelayphase.htm
  15. // http://mriquestions.com/angular-frequency-omega.html
  16. // https://en.wikipedia.org/wiki/Exponential_decay
  17. // ----------------------------------------------
  18. //
  19. // Constants - Don't change
  20. float eulersNumber = 2.718;
  21. // Constants - Programmable
  22. float decay = 0.0;                  // Decay - for damping/amplifying
  23. //float timer_freq = 0.25;            // How often the timer event is called
  24. float frequency = 0.2;              // The frequency of the sine wave.      
  25. float startingPhaseAngle = 180;         // The initial phase offset. // 180 to start at 0 amplitude
  26. float startingAmplitude = 0.4;      // The  amplitude at Phase = 0
  27. // Variables - Non Programmable
  28. float current_phase = 0.0;
  29. float phaseAngle;               // The Phase angle at time = 0 - Either 'startingPhaseAngle' or another number if clicked.
  30. float lastTime = 0.0;
  31. float time = 0.0;               // How many simulated seconds have passed. Not real-time
  32. float modulationTime = 0.0;
  33. float offsetTime = 0.0;            // Offset from llGetTime() needed to get the real 'time'
  34. float angularFreq;              // the Angular Frequency of the sine wave
  35. float targetAmplitude = 0.4;
  36. float amplitude;                // The current calculated amplitude at this point in time
  37. float modulationModeChangeTime = 0.0; // Time after llResetTime that modulationMode will change to next modulationMode...
  38.  
  39. integer modulationMode = 0;
  40. integer MODE_MODULATING = 0;
  41. integer MODE_DAMPING = 1;
  42. float damp_time;
  43.  
  44. // Used for z rotation smoothing to prevent 'jerkiness'
  45. float zrot_smoothing_current_radians;
  46. float zrot_smoothing_target_radians;
  47. float zrot_smoothing_increment_radians = 0.2; // Supply degrees here. Converted to radians in state_entry.
  48. float zrot_smoothing_error_radians = 4;
  49.  
  50. // --------------------------------------------------
  51. // Above: Modulation Parameters.
  52. // Below: Movement Parameters.
  53. // --------------------------------------------------
  54. vector posStart     = <135.65067, 118.03327, 3710.18604>;
  55. vector posEnd       = <135.65466, 120.00000, 3710.18604>;
  56. float  speedStart   = 0.0;
  57. float  speedCruise  = 0.4;
  58. float  speedEnd     = 0.0;
  59. float  acceleration = 0.4;
  60.  
  61. float timeAccStart;
  62. float timeAccEnd;
  63. float distanceAccStart;
  64. float distanceAccEnd;
  65. float distance_travelled;
  66. float distance_cruising;
  67. float time_cruising;
  68. float total_time;
  69.  
  70. float grip_angle_modifier;
  71.  
  72. float RAD_33_DEG;
  73. float RAD_90_DEG;
  74. float RAD_180_DEG;
  75. float RAD_360_DEG;
  76.  
  77. integer movementMode = 0;
  78. integer MODE_TRANSLATION = 0;
  79. integer MODE_ROTATION = 1;
  80. integer MODE_STOPPED = 2;
  81. // --------------------------------------------------
  82. // Modulation Functions
  83.  
  84. // re-targets to the given amplitude
  85. target_amplitude(float target)
  86. {
  87.     if (target == targetAmplitude) return;
  88.  
  89.     decay = 0.3;
  90.    
  91.     if (target > targetAmplitude)
  92.     {
  93.         decay = -0.3;
  94.     }
  95.  
  96.     modulationTime                 = 0.0;
  97.     phaseAngle                     =  current_phase + startingPhaseAngle;
  98.     startingPhaseAngle             = phaseAngle;
  99.  
  100.    //amplitude                     = startingAmplitude * (llPow(eulersNumber, 0-(decay * modulationTime))) * (llCos((angularFreq * modulationTime) + phaseAngle) + llSin((angularFreq * modulationTime) + phaseAngle));
  101.  
  102.     modulationModeChangeTime     = (llLog(target/startingAmplitude)/llLog(eulersNumber)) / -(decay);
  103.     targetAmplitude             = target;
  104.     modulationMode                 = MODE_DAMPING;
  105. }
  106.  
  107. // ----------------------------------------------------
  108. // Movement Functions
  109. vector move_distance(float distance)
  110. {
  111.     vector norm = llVecNorm((posEnd - posStart));
  112.     return posStart + (norm * distance);
  113. }
  114.  
  115. // ----------------------------------------------------
  116. // Rotation Functions
  117.  
  118. vector axis;
  119. integer negative;
  120.  
  121. vector spin_round_axis(float speedMS,  float time, float swingAngle,integer negative, integer actually_do)
  122. {
  123.  
  124.     float radius = llVecDist(posEnd, axis);
  125.     float circumference = (2*PI)*radius;
  126.     float distance_covered = speedMS * time;
  127.     float revolutions = distance_covered / circumference;
  128.     rotation modifier = llEuler2Rot(<0,0, zrot_smoothing_target_radians>);
  129.     rotation main_rotation = llEuler2Rot(<(swingAngle*DEG_TO_RAD),0,0>) * modifier;
  130.     main_rotation = main_rotation * (llEuler2Rot(<0,0,(negative) * (( RAD_360_DEG * revolutions) - RAD_180_DEG)> ) );
  131.  
  132.     vector         angle_step = <swingAngle, 0, (negative) * (360 * revolutions)>;
  133.     rotation     rotation_step = llEuler2Rot(angle_step*DEG_TO_RAD);
  134.     vector       current_offset = posEnd - axis;
  135.     vector         new_offset = current_offset*rotation_step;
  136.     vector         new_position = axis + new_offset;
  137.     // rotation     new_rot = starting_rotation*rotation_step;
  138.     rotation grip_rot = llEuler2Rot(<(swingAngle*-1) - 90, 0 , 90> * DEG_TO_RAD);
  139.     vector new_pos = <new_position.x, new_position.y, posEnd.z>;
  140.     if (actually_do)
  141.     {
  142.         llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_ROTATION, main_rotation,PRIM_POSITION, new_pos]);
  143.         llSetLinkPrimitiveParamsFast(LINK_GRIP, [PRIM_ROT_LOCAL, grip_rot]);
  144.     }
  145.     return new_pos;
  146.    
  147. }
  148.  
  149. float get_time_to_spin(vector axis, float speedMS, float angleDegrees)
  150. {
  151.     float radius = llVecDist(posEnd, axis);
  152.     float circumference = (2*PI)*radius;
  153.     float revolutions_to_cover = angleDegrees / 360;
  154.     float distance_to_cover = revolutions_to_cover * circumference;
  155.     if (angleDegrees < 0) negative = -1;
  156.     else negative = 1;
  157.     return distance_to_cover / speedMS;
  158. }
  159.  
  160. // The Step Parameters is a strided list of sorts.
  161. //
  162. //          +-----------------------+-----------------------+------------------+
  163. // Type     | Movement Instructions | Rotation Instructions | Stop Instruction |
  164. //          +-----------------------+-----------------------+------------------+
  165. // List     | "M"                   | "R"                   |"S"               |
  166. // Items    | target_amplitude      | <axis>                |station_num       |
  167. //          | <endPos>              | angleDegrees          |                  |
  168. //          | cruise_speed          |                       |                  |
  169. //          | end_speed             |                       |                  |
  170. //          +-----------------------+-----------------------+------------------+
  171. // total    |                      5|                      3|3                 |
  172. //          +-----------------------+-----------------------+------------------+
  173. // 0.2 SpeedCruise for open doors
  174. list step_parameters = [
  175. "M",0.05,<168.19083, 84.28532, 3723.62354>,0.6,0.8, // Town Platform Exit
  176. "M",0.06,<166.94867, 85.78530, 3723.24854>,0.8, 0.9, // Ramp Midway
  177. "M",0.07,<165.58499, 87.31174, 3722.27954>,1.0, 1.1,// Ramp exit
  178. "M",0.1,<157.17195, 98.16995, 3715.39746>,1.3, 1.3, // Slope End
  179. "M",0.12,<155.88412, 99.68120, 3714.31323>,1.3, 1.3, // Lower Ramp Midway
  180. "M",0.12,<154.80302, 101.10777, 3714.05908>,1.3, 1.3, // Lower Ramp Exit
  181. "M",0.07,<149.26172, 107.48204, 3714.10522>,1.3, 1.3, // School Approach Slowdown
  182. "M",0.05,<145.51732, 111.78938, 3714.06177>,1.3, 0.4, // School Approach End
  183. "R",<144.50839, 111.09032, 3714.04321>,180, // School Platform Pivot
  184. "M",0.05,<144.76619, 108.84672, 3714.03052>, 0.4, 0.0, // School Platform Middle
  185. "S", 2 , // Stop in middle of school platform
  186. "M",0.05,<147.41536, 105.85649, 3714.06714>,0.2, 0.3, // School Platform End
  187. "M",0.06,<152.87383, 99.49060, 3714.07178>,1.2, 1.2, // Lower Ramp Entry
  188. "M",0.06,<154.05394, 97.92750, 3714.39868>,1.3, 1.2, // Lower Ramp Midway
  189. "M",0.06,<155.23566, 96.47243, 3715.33350>,1.3, 1.4, // Lower Ramp Exit
  190. "M",0.07,<163.87987, 85.29440, 3722.43115>,1.5, 1.4, // Slope End
  191. "M",0.06,<165.12253, 83.91364, 3723.42822>,1.3, 1.3, // Upper Ramp Midway
  192. "M",0.06,<166.92793, 82.09026, 3723.63330>,1.3, 1.3, // Upper Ramp End
  193. "M",0.04,<175.75577, 73.66718, 3723.64478>,1.0, 0.4, // Town Approach End
  194. "R",<176.72151, 74.37282, 3723.61060>,180, // Town Approach Pivot
  195. "M", 0.05, <176.46262, 76.49358, 3723.63818>, 0.4, 0.4, // Town Platform Start
  196. "M", 0.05, <173.86670, 78.95359, 3723.59595>, 0.4, 0.0, // Town Platform Middle
  197. "S", 1, // Stop in middle of platform.
  198. "M", 0.05, <169.99072, 82.60885, 3723.64185>, 0.4, 0.6 // Town Platform End
  199. ];
  200.  
  201.  
  202.  
  203. // list step_parameters = ["M", 0.6,  <136.83017, 120.30188, 3710.65869>, 0.2, 0.1,
  204. //                         "R", <136.93367, 120.30188, 3710.65869>, -180,
  205. //                         "M", 0.2, <137.03252, 119.26787, 3710.65869>, 0.04, 0.04,
  206. //                         "R", <136.92574, 119.26363, 3710.65869>, -180];
  207.  
  208.  
  209. // list step_parameters = [
  210. //     "M", 0.05, <144.49481, 111.36368, 3713.60986>, 0.2, 0.3,
  211. //     "R", <145.04198, 110.81207, 3713.61426>, -90,
  212. //     "M", 0.15, <147.55910, 109.49693, 3713.61011>, 0.4, 0.4,
  213. //     "M", 0.2, <148.23454, 108.94102, 3713.91260>, 0.8, 0.8,
  214. //     "M", 0.18, <170.01117, 87.65887, 3724.28296>, 1.5, 1.3,
  215. //     "M", 0.1, <175.27179, 82.58306, 3724.40015>, 0.8, 0.4,
  216. //     "R", <174.53149, 81.93745, 3724.41821>, -180,
  217. //     "M", 0.05, <169.26244, 85.79064, 3724.41797>, 0.2,0.3,
  218. //     "M", 0.15, <168.29089, 86.72087, 3724.08374>, 0.8, 0.8,
  219. //     "M", 0.18, <147.21301, 107.65935, 3713.92896>, 1.5, 1.3,
  220. //     "M", 0.18, <146.57162, 108.16093, 3713.61646>, 0.8, 0.4,
  221. //     "M", 0.15, <145.48149, 109.05575, 3713.61646>, 0.4, 0.4,
  222. //     "R", <144.92361, 108.51511, 3713.61426>, 90,
  223. //     "M", 0.1, <137.67944, 102.29155, 3713.61621>, 0.6, 0.6,
  224. //     "R", <137.11125, 102.88134, 3713.61426>, -180
  225. // ];
  226.  
  227. // list step_parameters = ["M",0.4,<135.83046, 120.00022, 3710.18286>,0.5,0.08,
  228. //                         "R",<135.93230, 120.00022, 3710.18286>,-180,
  229. //                         "M",0.4,<136.02982, 118.03920, 3710.18286>,0.5,0.08,
  230. //                         "R",<135.92519, 118.03920, 3710.18286>,-180];
  231. integer list_pos = 0;
  232.  
  233. next_step()
  234. {
  235.     if (movementMode == MODE_TRANSLATION)
  236.     {
  237.         list_pos += 5;
  238.     }
  239.     else if (movementMode == MODE_ROTATION)
  240.     {
  241.         list_pos += 3;
  242.     }
  243.     else if (movementMode == MODE_STOPPED)
  244.     {
  245.         list_pos += 2;
  246.     }
  247.     integer steps_length = llGetListLength(step_parameters);
  248.     if (list_pos >= steps_length)
  249.     {
  250.         list_pos = 0;
  251.     }
  252.     string mode = llList2String(step_parameters, list_pos);
  253.     if (mode == "M")
  254.     {
  255.         movementMode = MODE_TRANSLATION;
  256.         posStart = llGetPos();
  257.         target_amplitude(llList2Float(step_parameters, list_pos + 1));
  258.         posEnd = llList2Vector(step_parameters, list_pos + 2);
  259.         speedStart = speedEnd;
  260.         speedCruise = llList2Float(step_parameters, list_pos + 3);
  261.         if (speedCruise == 0.2)
  262.         {
  263.             llMessageLinked(LINK_SET, 0, "open", NULL_KEY);
  264.         }
  265.         else
  266.         {
  267.             llMessageLinked(LINK_SET, 0, "close", NULL_KEY);
  268.            
  269.         }
  270.         speedEnd = llList2Float(step_parameters, list_pos + 4);
  271.  
  272.         // Refer to
  273.         // https://www.dummies.com/education/science/physics/how-to-calculate-time-and-distance-from-acceleration-and-velocity/
  274.         //         Formula
  275.         // (End Speed - Start Speed)/1;
  276.         // Start Speed End Speed
  277.         // 20          30      (-10)/1 = -10s
  278.         // 20          10      (10)/1 = 10s
  279.         // The number may be negative but it's okay to just get the absolute value.
  280.         timeAccStart = llFabs((speedCruise - speedStart)/acceleration);
  281.         timeAccEnd   = llFabs((speedEnd - speedCruise)/acceleration);
  282.         distanceAccStart = llFabs(((speedStart) * timeAccStart) + 0.5 * (acceleration * llPow(timeAccStart, 2)));
  283.         distanceAccEnd = llFabs(((speedCruise) * timeAccEnd) - 0.5 * (acceleration * llPow(timeAccEnd, 2)));
  284.         distance_travelled = llVecDist(posStart, posEnd);
  285.         distance_cruising  = distance_travelled - distanceAccStart - distanceAccEnd;
  286.         time_cruising = distance_cruising / speedCruise;
  287.         total_time = time_cruising + timeAccStart + timeAccEnd;
  288.         // float angle_bearing(float ax, float ay, float bx, float by)
  289.         zrot_smoothing_target_radians = angle_bearing( posStart.x, posStart.y ,posEnd.x, posEnd.y) * DEG_TO_RAD;
  290.         vector current_rot = llRot2Euler(llGetRot());
  291.         zrot_smoothing_current_radians = current_rot.z;
  292.         angle_grip();
  293.         llSetTimerEvent(1.0 / llGetRegionFPS()); // Occasionally we update the timer to avoid queuing up events
  294.         return;    
  295.     }
  296.     else if (mode == "R")
  297.     {
  298.         llMessageLinked(LINK_SET, 0, "close", NULL_KEY);
  299.         movementMode = MODE_ROTATION;
  300.         axis = llList2Vector(step_parameters, list_pos + 1);
  301.         total_time = llFabs(get_time_to_spin(axis, speedEnd, llList2Float(step_parameters, list_pos + 2)));
  302.         llSetTimerEvent(1.0 / llGetRegionFPS()); // Occasionally we update the timer to avoid queuing up events
  303.  
  304.     } if (mode == "S")
  305.     {
  306.         // Stopped.
  307.         llRegionSay(-89993, "Cable Car Used Memory; " + (string)llGetUsedMemory());
  308.         movementMode = MODE_STOPPED;
  309.         llMessageLinked(LINK_SET, 0, "open", NULL_KEY);
  310.         target_amplitude(0.02); // Stop swingin
  311.         carListener = llListen(carChannel, "", NULL_KEY, "depart");
  312.         llRegionSay(carChannel, "arrived");
  313.         llSetTimerEvent((1.0 / llGetRegionFPS()) * 2); // Run a looser timer when stopped - There is not much motion. Let the server catch it's breath.
  314.     }
  315.    
  316. }
  317.  
  318. integer is_right_turn(float current, float target)
  319. {
  320.  
  321.     while (target < current)
  322.     {
  323.         target += RAD_360_DEG;
  324.     }
  325.     // Target is always greater than current.
  326.     // Turning left is the distance from 0 to current + target to 360
  327.     float turning_left = current + (RAD_360_DEG - target);
  328.     // Turning right is simply target - current as target is always bigger than current
  329.     float turning_right = target - current;
  330.     if (turning_left < turning_right) return TRUE;
  331.     return FALSE;
  332. }
  333.  
  334. vector calculate_pos_from_time(float g_time){
  335.     vector pos;
  336.     if (g_time <= timeAccStart)
  337.     {
  338.         // Before cruise speed.
  339.        
  340.         float distance = ((speedStart) * g_time) + 0.5 * (acceleration * llPow(g_time, 2));
  341.         pos = move_distance(distance);
  342.     }
  343.     else
  344.     {
  345.         if (g_time > timeAccStart && g_time < (timeAccStart + time_cruising))
  346.         {
  347.            
  348.             float distance = distanceAccStart + (speedCruise * (g_time - timeAccStart));
  349.             pos = move_distance(distance);
  350.         }
  351.         else
  352.         {
  353.            
  354.             float distance = distanceAccStart + distance_cruising + ((speedCruise) *(g_time - timeAccStart - time_cruising) + 0.5 * ((acceleration*-1) * llPow(g_time - timeAccStart - time_cruising, 2)));
  355.             pos = move_distance(distance);
  356.         }
  357.     }
  358.     return pos;
  359. }
  360.  
  361.  
  362. angle_grip()
  363. {
  364.     vector g_start = llGetPos();
  365.     vector end_horizontal = <posEnd.x, posEnd.y, g_start.z>;
  366.     float  x = llVecDist(g_start, end_horizontal);
  367.     float  y = posEnd.z - g_start.z;
  368.     // float angle = llAtan2(y, x) * RAD_TO_DEG;
  369.     grip_angle_modifier = llAtan2(y, x);
  370.     //llSetText("Grip Angle;\n" + (string) angle, <1,1,1>, 1.0);
  371.  
  372. }
  373.  
  374. float angle_bearing(float ax, float ay, float bx, float by)
  375. {
  376.     float theta = llAtan2(bx - ax, ay - by);
  377.     if (theta < 0.0)
  378.     {
  379.         theta += (TWO_PI);
  380.  
  381.     }
  382.     return RAD_TO_DEG * theta;
  383. }
  384.  
  385. default
  386. {
  387.     state_entry()
  388.     {
  389.         RAD_33_DEG = 33 * DEG_TO_RAD;
  390.         RAD_90_DEG = 90 * DEG_TO_RAD;
  391.         RAD_180_DEG = 180 * DEG_TO_RAD;
  392.         RAD_360_DEG = 360 * DEG_TO_RAD;
  393.         zrot_smoothing_increment_radians = zrot_smoothing_increment_radians * DEG_TO_RAD;
  394.         zrot_smoothing_error_radians = zrot_smoothing_error_radians * DEG_TO_RAD;
  395.         list_pos = 200;
  396.         next_step();
  397.         // Modulation Initialisation
  398.         angularFreq =  frequency * (2*PI);
  399.         startingPhaseAngle = startingPhaseAngle * DEG_TO_RAD; // TESTING
  400.         phaseAngle = startingPhaseAngle;
  401.         llListen(-206, "", NULL_KEY, "");
  402.         // Movement initialisation
  403.         llSetStatus(STATUS_SANDBOX, TRUE);
  404.  
  405.         timeAccStart = (speedCruise - speedStart)/acceleration;
  406.         timeAccEnd   = (speedEnd - speedCruise)/-(acceleration);
  407.  
  408.         distanceAccStart = ((speedStart) * timeAccStart) + 0.5 * (acceleration * llPow(timeAccStart, 2));
  409.         distanceAccEnd = distanceAccStart; // TODO
  410.         distance_travelled = llVecDist(posStart, posEnd);
  411.         distance_cruising  = distance_travelled - distanceAccStart - distanceAccEnd;
  412.         time_cruising = distance_cruising / speedCruise;
  413.         total_time = time_cruising + timeAccStart + timeAccEnd;
  414.         llResetTime();
  415.         llSetTimerEvent(1.0 / llGetRegionFPS());
  416.     }
  417.  
  418.    
  419.     timer()
  420.     {
  421.         llSetTimerEvent(1/llGetRegionFPS());
  422.         time = llGetTime();// + time_offset;
  423.         modulationTime += time - lastTime;
  424.         time_since_walker += modulationTime;
  425.         lastTime = time;
  426.        
  427.  
  428.         current_phase = (RAD_360_DEG * frequency * modulationTime);
  429.         if (current_phase > RAD_360_DEG)
  430.         {
  431.             current_phase -= RAD_360_DEG; // Prevent overflow
  432.         }
  433.         current_phase = current_phase; // TESTING
  434.         // --------------------------------------------------------------------------
  435.         // modulation handling
  436.         if (modulationMode == MODE_DAMPING && modulationTime > modulationModeChangeTime)
  437.         {
  438.             // llResetTime();
  439.             phaseAngle =  current_phase + startingPhaseAngle;
  440.             startingPhaseAngle = phaseAngle;
  441.  
  442.             decay = 0.0;
  443.             // //time_offset = time - modulationModeChangeTime;
  444.             // time = 0.0 ; // time_offset;
  445.             startingAmplitude = targetAmplitude;
  446.             modulationTime = 0.0;
  447.             modulationMode = MODE_MODULATING;
  448.         }
  449.  
  450.         if (movementMode != MODE_STOPPED && time > total_time)
  451.         {
  452.             //offsetTime = (time - total_time);
  453.             llResetTime();
  454.             next_step();
  455.             time = llGetTime() ;
  456.             lastTime = 0.0;
  457.         }
  458.  
  459.         amplitude = startingAmplitude * (llPow(eulersNumber, 0-(decay * modulationTime))) * (llCos((angularFreq * modulationTime) + phaseAngle) + llSin((angularFreq * modulationTime) + phaseAngle));
  460.  
  461.         if (movementMode == MODE_ROTATION)
  462.         {
  463.             //spin_round_axis(float speedMS,  float time, float swingAngle)
  464.             spin_round_axis(speedEnd, time, amplitude * 33, negative,TRUE);
  465.             if (time_since_walker > 1.0) {
  466.                 llWhisper(walker_channel, (string)spin_round_axis(speedEnd, (time + 2.0), amplitude * 33, negative,FALSE));
  467.             }
  468.             return;
  469.         }
  470.         if (llFabs(zrot_smoothing_current_radians - zrot_smoothing_target_radians) > zrot_smoothing_error_radians && movementMode != MODE_STOPPED)
  471.         {
  472.             //integer angle_direction(float rad_angle_a, float rad_angle_b)
  473.             if (is_right_turn(zrot_smoothing_current_radians, zrot_smoothing_target_radians))
  474.             {
  475.                 zrot_smoothing_current_radians += zrot_smoothing_increment_radians;
  476.             } else
  477.             {
  478.                 zrot_smoothing_current_radians -= zrot_smoothing_increment_radians;
  479.             }
  480.         }
  481.         vector rot_main = <(amplitude * RAD_33_DEG), 0,0>;
  482.         vector rot_grip = <((amplitude * RAD_33_DEG)*-1) - RAD_90_DEG ,0 ,RAD_90_DEG>;
  483.         rot_grip = < rot_grip.x + grip_angle_modifier, rot_grip.y, rot_grip.z>;
  484.         // llSetText((string)(amplitude*33) + "deg\n" + (string)((amplitude*33)*-1), <1,1,1>, TRUE);
  485.         rotation modifier = llEuler2Rot(<0,0, zrot_smoothing_current_radians>);
  486.         rotation r_main = llEuler2Rot(rot_main) * modifier;
  487.         rotation r_grip = llEuler2Rot(rot_grip);
  488.         if (movementMode == MODE_TRANSLATION)
  489.         {
  490.            
  491.  
  492.             // -------------------------------------------------------------------------
  493.             // position handling
  494.            
  495.             vector pos = calculate_pos_from_time(time);
  496.             if (speedCruise != 0.2 && time_since_walker > 2.0) {
  497.                 // TODO - Restore this so people can board
  498.                 llWhisper(walker_channel, (string)calculate_pos_from_time(time + 2));
  499.                 time_since_walker = 0.0;
  500.             }
  501.  
  502.             // finally, set the params.
  503.             llSetLinkPrimitiveParamsFast(LINK_THIS,[ PRIM_ROTATION, r_main, PRIM_POSITION, pos]);
  504.             llSetLinkPrimitiveParamsFast(LINK_GRIP, [PRIM_ROT_LOCAL, r_grip]);
  505.             return;
  506.         }
  507.         // beyond: movementMode == MODE_STOPPED - The cable car has been stopped.
  508.         llSetLinkPrimitiveParamsFast(LINK_THIS,[ PRIM_ROTATION, r_main]);
  509.         llSetLinkPrimitiveParamsFast(LINK_GRIP, [PRIM_ROT_LOCAL, r_grip]);
  510.         // Aight cool. So now the car needs to
  511.  
  512.     }
  513.  
  514.     listen(integer channel, string name, key id, string message)
  515.     {
  516.         if (llGetOwnerKey(id) != llGetOwner()) return; // noise on channel
  517.         // It's the depart command.
  518.         llWhisper(walker_channel, "COMMIT");
  519.         next_step();
  520.     }
  521. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top