updated camera package

This commit is contained in:
gnembon committed 2019-05-16 22:31:55 -03:00
1 parent 06e4197509
commit 9b31fa0252
1 file changed
+308 -285
@@ -11,301 +11,324 @@ public class CameraPathModule implements ModuleInterface
@Override @Override
public String getCode() public String getCode()
{ {
return "$ __command() ->\n" + return " __command() ->\n" +
"$ (\n" + " (\n" +
"$ print('Camera path module.');\n" + " print('Camera path module.');\n" +
"$ print('-------------------');\n" + " print('-------------------');\n" +
"$ print(' \"/camera start\" - set the starting point');\n" + " print(' \"/camera start\" - set the starting point');\n" +
"$ print('');\n" + " print('');\n" +
"$ print(' \"/camera add <N>\" - add another point <N> frames later');\n" + " print(' \"/camera add <N>\" - add another point <N> frames later');\n" +
"$ print('');\n" + " print('');\n" +
"$ print(' \"/camera select_interpolation < linear | gauss_? >\"');\n" + " print(' \"/camera select_interpolation < linear | gauss_? >\"');\n" +
"$ print(' Select interpolation between points:');\n" + " print(' Select interpolation between points:');\n" +
"$ print(' - linear: straight paths between points.');\n" + " print(' - linear: straight paths between points.');\n" +
"$ print(' - gauss_auto: automatic smooth transitions.');\n" + " print(' - gauss_auto: automatic smooth transitions.');\n" +
"$ print(' - gauss_<number>: custom fixed variance ');\n" + " print(' - gauss_<number>: custom fixed variance ');\n" +
"$ print(' (in points) for special effects.');\n" + " print(' (in points) for special effects.');\n" +
"$ print('');\n" + " print('');\n" +
"$ print(' \"/camera repeat <N> <last_delay>\" - ');\n" + " print(' \"/camera repeat <N> <last_delay>\" - ');\n" +
"$ print(' Repeat existing points configuration n-times');\n" + " print(' Repeat existing points configuration n-times');\n" +
"$ print(' using <last_delay> points to link path ends');\n" + " print(' using <last_delay> points to link path ends');\n" +
"$ print('');\n" + " print('');\n" +
"$ print(' \"/camera speed <factor> - ');\n" + " print(' \"/camera speed <factor> - ');\n" +
"$ print(' Change number of frames between points');\n" + " print(' Change number of frames between points');\n" +
"$ print(' from 25 -> 4 times faster (less points),');\n" + " print(' from 25 -> 4 times faster (less points),');\n" +
"$ print(' to 400 -> 4 times slower (more points)');\n" + " print(' to 400 -> 4 times slower (more points)');\n" +
"$ print('');\n" + " print('');\n" +
"$ print(' \"/camera play <fps>: run a path with a player');\n" + " print(' \"/camera play <fps>: run a path with a player');\n" +
"$ print(' <fps> needs to be multiples of 20, (20 tps)');\n" + " print(' <fps> needs to be multiples of 20, (20 tps)');\n" +
"$ print('');\n" + " print('');\n" +
"$ print(' \"/camera show\": shows current path for a moment');\n" + " print(' \"/camera show\": shows current path for a moment');\n" +
"$ print('');\n" + " print('');\n" +
"$ print(' \"/script in camera invoke _show_path_tick <particle> <ppt>\":');\n" + " print(' \"/script in camera invoke _show_path_tick <particle> <ppt>\":');\n" +
"$ print(' place this in a repeating commandblock');\n" + " print(' place this in a repeating commandblock');\n" +
"$ print(' to display path continuously');\n" + " print(' to display path continuously');\n" +
"$ print(' with set particle and number of particles per tick');\n" + " print(' with set particle and number of particles per tick');\n" +
"$ print(' example: \\'dust 0.9 0.1 0.1 1\\' 100 ');\n" + " print(' example: \\'dust 0.9 0.1 0.1 1\\' 100 ');\n" +
"$ ''\n" + " ''\n" +
"$ );\n" + " );\n" +
"$ start() -> \n" + " start() -> \n" +
"$(\n" + "(\n" +
"$ p = player();\n" + " p = player();\n" +
"$ global_points = l(l(l(p~'x',p~'y',p~'z',p~'pitch',p~'yaw'),0,'sharp'));\n" + " global_points = l(l(l(p~'x',p~'y',p~'z',p~'yaw',p~'pitch'),0,'sharp'));\n" +
"$ undef('global_path_precalculated');\n" + " undef('global_path_precalculated');\n" +
"$ str('Started path at %.1f %.1f %.1f', p~'x', p~'y', p~'z')\n" + " str('Started path at %.1f %.1f %.1f', p~'x', p~'y', p~'z')\n" +
"$);\n" + ");\n" +
"$\n" + "\n" +
"$ add(delay) -> \n" + " add(delay) -> \n" +
"$( \n" + "( \n" +
"$ p = player(); \n" + " p = player(); \n" +
"$ mode = 'sharp';\n" + " mode = 'sharp';\n" +
"$ 'mode is currently unused, run_path does always sharp, gauss interpolator is always smooth';\n" + " 'mode is currently unused, run_path does always sharp, gauss interpolator is always smooth';\n" +
"$ ' but this option could be used could be used at some point by more robust interpolators';\n" + " ' but this option could be used could be used at some point by more robust interpolators';\n" +
"$ vector = l(p~'x',p~'y',p~'z', p~'pitch', p~'yaw');\n" + " vector = l(p~'x',p~'y',p~'z', p~'yaw', p~'pitch');\n" +
"$ __add_path_segment(vector, delay, mode);\n" + " __add_path_segment(vector, delay, mode);\n" +
"$ str('Added point %d: %.1f %.1f %.1f', length(global_points), p~'x', p~'y', p~'z')\n" + " str('Added point %d: %.1f %.1f %.1f', length(global_points), p~'x', p~'y', p~'z')\n" +
"$);\n" + ");\n" +
"$\n" + "\n" +
"$ __add_path_segment(vector, duration, mode) -> \n" + " __add_path_segment(vector, duration, mode) -> \n" +
"$(\n" + "(\n" +
"$ undef('global_path_precalculated');\n" + " undef('global_path_precalculated');\n" +
"$ if ( (l('sharp','smooth') ~ mode) == null, exit('use smooth or sharp point')); \n" + " if ( (l('sharp','smooth') ~ mode) == null, exit('use smooth or sharp point')); \n" +
"$ if(!global_points, exit('Cannot add point to path that didn\\'t started yet!'));\n" + " if(!global_points, exit('Cannot add point to path that didn\\'t started yet!'));\n" +
"$ l(v, end_time, m) = element(global_points, -1);\n" + " l(v, end_time, m) = element(global_points, -1);\n" +
"$ put(vector,-1, __adjusted_rot(element(v, -1), element(vector, -1)));\n" + " put(vector,-2, __adjusted_rot(element(v, -2), element(vector, -2)));\n" +
"$ global_points += l(vector, end_time+duration, mode)\n" + " global_points += l(vector, end_time+duration, mode)\n" +
"$);\n" + ");\n" +
"$\n" + "\n" +
"$'adjusts current rotation so we don\\'t spin around like crazy';\n" + "'adjusts current rotation so we don\\'t spin around like crazy';\n" +
"$ __adjusted_rot(previous_rot, current_rot) -> \n" + " __adjusted_rot(previous_rot, current_rot) -> \n" +
"$(\n" + "(\n" +
"$ while( abs(previous_rot-current_rot) > 180, 1000,\n" + " while( abs(previous_rot-current_rot) > 180, 1000,\n" +
"$ current_rot += if(previous_rot < current_rot, -360, 360)\n" + " current_rot += if(previous_rot < current_rot, -360, 360)\n" +
"$ );\n" + " );\n" +
"$ current_rot\n" + " current_rot\n" +
"$);\n" + ");\n" +
"$\n" + "\n" +
"$\n" + "\n" +
"$ repeat(times, last_section_duration) -> \n" + " repeat(times, last_section_duration) -> \n" +
"$(\n" + "(\n" +
"$ undef('global_path_precalculated');\n" + " undef('global_path_precalculated');\n" +
"$ positions = map(global_points, k = element(_, 0));\n" + " positions = map(global_points, k = element(_, 0));\n" +
"$ modes = map(global_points, element(_, -1));\n" + " modes = map(global_points, element(_, -1));\n" +
"$ durations = map(global_points, element(element(global_points, _i+1), 1)-element(_, 1));\n" + " durations = map(global_points, element(element(global_points, _i+1), 1)-element(_, 1));\n" +
"$ put(durations, -1, last_section_duration);\n" + " put(durations, -1, last_section_duration);\n" +
"$ loop(times,\n" + " loop(times,\n" +
"$ loop( length(positions),\n" + " loop( length(positions),\n" +
"$ __add_path_segment(element(positions, _), element(durations, _), element(modes, _))\n" + " __add_path_segment(element(positions, _), element(durations, _), element(modes, _))\n" +
"$ )\n" + " )\n" +
"$ );\n" + " );\n" +
"$ str('Add %d points %d times', length(positions), times)\n" + " str('Add %d points %d times', length(positions), times)\n" +
"$);\n" + ");\n" +
"$\n" + "\n" +
"$ speed(percentage) ->\n" + " speed(percentage) ->\n" +
"$(\n" + "(\n" +
"$ undef('global_path_precalculated');\n" + " undef('global_path_precalculated');\n" +
"$ if (percentage < 25 || percentage > 400, \n" + " if (percentage < 25 || percentage > 400, \n" +
"$ exit('path speed can only be speed, or slowed down 4 times. Recall command for larger changes')\n" + " exit('path speed can only be speed, or slowed down 4 times. Recall command for larger changes')\n" +
"$ );\n" + " );\n" +
"$ ratio = percentage/100;\n" + " ratio = percentage/100;\n" +
"$ previous_path_length = element(element(global_points, -1),1);\n" + " previous_path_length = element(element(global_points, -1),1);\n" +
"$ for(global_points, put(_, 1, element(_, 1)*ratio ) );\n" + " for(global_points, put(_, 1, element(_, 1)*ratio ) );\n" +
"$ undef('global_path_precalculated');\n" + " undef('global_path_precalculated');\n" +
"$ str('path %d from %d to %d ticks',\n" + " str('path %s from %d to %d ticks',\n" +
"$ if(ratio<1,'shortened','extended'),\n" + " if(ratio<1,'shortened','extended'),\n" +
"$ previous_path_length,\n" + " previous_path_length,\n" +
"$ element(element(global_points, -1),1)\n" + " element(element(global_points, -1),1)\n" +
"$ )\n" + " )\n" +
"$);\n" + ");\n" +
"$\n" + "\n" +
"$ select_interpolation(method) ->\n" + " select_interpolation(method) ->\n" +
"$(\n" + "(\n" +
"$ undef('global_path_precalculated');\n" + " undef('global_path_precalculated');\n" +
"$ __prepare_path_if_needed() -> __prepare_path_if_needed_generic();\n" + " __prepare_path_if_needed() -> __prepare_path_if_needed_generic();\n" +
"$ 'each supported method needs to specify its __find_position_for_point to trace the path';\n" + " 'each supported method needs to specify its __find_position_for_point to trace the path';\n" +
"$ 'accepting segment number, and position in the segment';\n" + " 'accepting segment number, and position in the segment';\n" +
"$ 'or optionally __prepare_path_if_needed, if path is inefficient to compute point by point';\n" + " 'or optionally __prepare_path_if_needed, if path is inefficient to compute point by point';\n" +
"$ if (\n" + " if (\n" +
"$ method == 'linear',\n" + " method == 'linear',\n" +
"$ (\n" + " (\n" +
"$ __find_position_for_point(s, p) -> __find_position_for_linear(s, p)\n" + " __find_position_for_point(s, p) -> __find_position_for_linear(s, p)\n" +
"$ ),\n" + " ),\n" +
"$ method ~ '^gauss_',\n" + " method ~ '^gauss_',\n" +
"$ (\n" + " (\n" +
"$ type = method - 'gauss_';\n" + " type = method - 'gauss_';\n" +
"$ global_interpol_option = if(type=='auto',0,number(type));\n" + " global_interpol_option = if(type=='auto',0,number(type));\n" +
"$ __find_position_for_point(s, p) -> __find_position_for_gauss(s, p)\n" + " __find_position_for_point(s, p) -> __find_position_for_gauss(s, p)\n" +
"$ ),\n" + " ),\n" +
"$ method ~ '^bungee_',\n" + " method ~ '^bungee_',\n" +
"$ (\n" + " (\n" +
"$ exit('unsupported / planned');\n" + " exit('unsupported / planned');\n" +
"$ type = method - 'bungee_';\n" + " type = method - 'bungee_';\n" +
"$ global_interpol_option = if(type=='auto',80,number(type));\n" + " global_interpol_option = if(type=='auto',80,number(type));\n" +
"$ __prepare_path_if_needed() -> __prepare_path_if_needed_bungee()\n" + " __prepare_path_if_needed() -> __prepare_path_if_needed_bungee()\n" +
"$ ),\n" + " ),\n" +
"$ \n" + " \n" +
"$ exit('Choose one of the following methods: linear, gauss:auto, gauss:<deviation>')\n" + " exit('Choose one of the following methods: linear, gauss:auto, gauss:<deviation>')\n" +
"$ );\n" + " );\n" +
"$ 'Ok'\n" + " 'Ok'\n" +
"$);\n" + ");\n" +
"$\n" + "\n" +
"$ select_interpolation('linear');\n" + " select_interpolation('linear');\n" +
"$\n" + "\n" +
"$ __assert_valid_for_motion() ->\n" + " __assert_valid_for_motion() ->\n" +
"$(\n" + "(\n" +
"$ if(!global_points, exit('Path not defined yet'));\n" + " if(!global_points, exit('Path not defined yet'));\n" +
"$ if(length(global_points)<2, exit('Path not complete - add more points'));\n" + " if(length(global_points)<2, exit('Path not complete - add more points'));\n" +
"$ null \n" + " null \n" +
"$);\n" + ");\n" +
"$\n" + "\n" +
"$ __get_path_at(segment, start, index) ->\n" + " __get_path_at(segment, start, index) ->\n" +
"$(\n" + "(\n" +
"$ v = element(global_path_precalculated, start+index);\n" + " v = element(global_path_precalculated, start+index);\n" +
"$ if(v == null,\n" + " if(v == null,\n" +
"$ v = __find_position_for_point(segment, index);\n" + " v = __find_position_for_point(segment, index);\n" +
"$ put(global_path_precalculated, start+index, v)\n" + " put(global_path_precalculated, start+index, v)\n" +
" );\n" + " );\n" +
" v\n" + " v\n" +
"$);\n" + ");\n" +
"$\n" + "\n" +
"$ __invalidate_points_cache() -> global_path_precalculated = map(range(element(element(global_points, -1),1)), null);\n" + " __invalidate_points_cache() -> global_path_precalculated = map(range(element(element(global_points, -1),1)), null);\n" +
"$\n" + "\n" +
"$ show() -> \n" + " show() -> \n" +
"$(\n" + "(\n" +
"$ loop(100,\n" + " loop(100,\n" +
"$ _show_path_tick('dust 0.9 0.1 0.1 1', 100);\n" + " _show_path_tick('dust 0.9 0.1 0.1 1', 100);\n" +
"$ game_tick(50)\n" + " game_tick(50)\n" +
"$ );\n" + " );\n" +
"$ 'Done!'\n" + " 'Done!'\n" +
"$);\n" + ");\n" +
"$\n" + "\n" +
"$\n" + " __play(fps) -> \n" +
"$ play(fps) -> \n" + "(\n" +
"$(\n" + " p = player();\n" +
"$ p = player();\n" + " __assert_valid_for_motion();\n" +
"$ __assert_valid_for_motion();\n" + " __prepare_path_if_needed();\n" +
"$ __prepare_path_if_needed();\n" + " loop( length(global_points)-1,\n" +
"$ loop( length(global_points)-1,\n" + " segment = _;\n" +
"$ segment = _;\n" + " start = element(element(global_points, segment),1);\n" +
"$ start = element(element(global_points, segment),1);\n" + " end = element(element(global_points, segment+1),1);\n" +
"$ end = element(element(global_points, segment+1),1);\n" + " loop(end-start,\n" +
"$ loop(end-start,\n" + " v = __get_path_at(segment, start, _);\n" +
"$ v = __get_path_at(segment, start, _);\n" + " modify(p, 'location', v);\n" +
"$ modify(p, 'pos', slice(v,0,3));\n" + " game_tick(1000/fps)\n" +
"$ modify(p, 'pitch', element(v,3));\n" + " )\n" +
"$ modify(p, 'yaw', element(v,4));\n" + " );\n" +
"$ game_tick(1000/fps)\n" + " game_tick(1000);\n" +
"$ )\n" + " 'Done!'\n" +
"$ );\n" + ");\n" +
"$ game_tick(1000);\n" + "\n" +
"$ 'Done!'\n" + " play(fps) -> \n" +
"$);\n" + "(\n" +
"$\n" + " p = player();\n" +
"$ _show_path_tick(particle_type, total) -> (\n" + " __assert_valid_for_motion();\n" +
"$ __assert_valid_for_motion();\n" + " __prepare_path_if_needed();\n" +
"$ __prepare_path_if_needed();\n" + " if ((fps % 20 != 0) || fps < 20, exit('FPS needs to be multiples of 20') );\n" +
"$ loop(total,\n" + "\ttpt = round(fps / 20);\n" +
"$ segment = floor(rand(length(global_points)-1));\n" + " mspt = 50 / tpt; \n" +
"$ start = element(element(global_points, segment),1);\n" + " start_time = time();\n" +
"$ end = element(element(global_points, segment+1),1);\n" + " point = 0;\n" +
"$ index = floor(rand(end-start));\n" + " loop( length(global_points)-1,\n" +
"$ l(x, y, z) = slice(__get_path_at(segment, start, index), 0, 3);\n" + " segment = _;\n" +
"$ particle(particle_type, x, y, z, 1, 0, 0)\n" + " start = element(element(global_points, segment),1);\n" +
"$ );\n" + " end = element(element(global_points, segment+1),1);\n" +
"$ null\n" + " loop(end-start,\n" +
"$);\n" + " v = __get_path_at(segment, start, _);\n" +
"$\n" + " modify(p, 'location', v);\n" +
"$ __prepare_path_if_needed_generic() ->\n" + " point += 1;\n" +
"$(\n" + " if ((point % tpt == 0), game_tick());\n" +
"$ if(!global_path_precalculated, __invalidate_points_cache())\n" + " end_time = time();\n" +
" took = end_time - start_time;\n" +
" if (took < mspt, sleep(mspt-took));\n" +
" start_time = time()\n" +
" )\n" +
" );\n" +
" game_tick(1000);\n" +
" 'Done!'\n" +
");\n" +
"\n" +
" _show_path_tick(particle_type, total) -> (\n" +
" __assert_valid_for_motion();\n" +
" __prepare_path_if_needed();\n" +
" loop(total,\n" +
" segment = floor(rand(length(global_points)-1));\n" +
" start = element(element(global_points, segment),1);\n" +
" end = element(element(global_points, segment+1),1);\n" +
" index = floor(rand(end-start));\n" +
" l(x, y, z) = slice(__get_path_at(segment, start, index), 0, 3);\n" +
" particle(particle_type, x, y, z, 1, 0, 0)\n" +
" );\n" +
" null\n" +
");\n" +
"\n" +
" __prepare_path_if_needed_generic() ->\n" +
"(\n" +
" if(!global_path_precalculated, __invalidate_points_cache())\n" +
");\n" + ");\n" +
"\n" + "\n" +
"__find_position_for_linear(segment, point) ->\n" + "__find_position_for_linear(segment, point) ->\n" +
"(\n" + "(\n" +
"$ l(va, start, mode_a) = element(global_points,segment);\n" + " l(va, start, mode_a) = element(global_points,segment);\n" +
"$ l(vb, end, mode_b) = element(global_points,segment+1);\n" + " l(vb, end, mode_b) = element(global_points,segment+1);\n" +
"$ section = end-start;\n" + " section = end-start;\n" +
"$ dt = point/section;\n" + " dt = point/section;\n" +
"$ dt*vb+(1-dt)*va\n" + " dt*vb+(1-dt)*va\n" +
");\n" + ");\n" +
"\n" + "\n" +
"\n" + "\n" +
"$'(1/sqrt(2*pi*d*d))*euler^(-((x-miu)^2)/(2*d*d)) ';\n" + "'(1/sqrt(2*pi*d*d))*euler^(-((x-miu)^2)/(2*d*d)) ';\n" +
"$ 'but we will be normalizing anyways, so who cares';\n" + " 'but we will be normalizing anyways, so who cares';\n" +
"$ __norm_prob(x, miu, d) -> euler^(-((x-miu)^2)/(2*d*d));\n" + " __norm_prob(x, miu, d) -> euler^(-((x-miu)^2)/(2*d*d));\n" +
"$\n" +
"$ __find_position_for_gauss(from_index, point) -> \n" +
"$(\n" +
"$ dev = global_interpol_option;\n" +
"$ components = l();\n" +
"$ path_point = element(element(global_points, from_index),1);\n" +
"$ \n" +
"$ try(\n" +
"$ for(range(from_index+1, length(global_points)),\n" +
"$ l(v,ptime,mode) = element(global_points, _);\n" +
"$ dev = if (global_interpol_option > 0, global_interpol_option, \n" +
"$ devs = l();\n" +
"$ if (_+1 < length(global_points), devs += element(element(global_points, _+1),1)-ptime);\n" +
"$ if (_-1 >= 0, devs += ptime-element(element(global_points, _-1),1));\n" +
"$ 0.6*reduce(devs, _a+_, 0)/length(devs)\n" +
"$ );\n" +
"$ impact = __norm_prob(path_point+point, ptime, dev);\n" +
"$ if(rtotal && impact < 0.000001*rtotal, throw(null));\n" +
"$ components += l(v, impact);\n" +
"$ rtotal += impact\n" +
"$ )\n" +
"$ ,null\n" +
"$ );\n" +
"$ try(\n" +
"$ for(range(from_index, -1, -1),\n" +
"$ l(v,ptime,mode) = element(global_points, _);\n" +
"$ dev = if (global_interpol_option > 0, global_interpol_option, \n" +
"$ devs = l();\n" +
"$ if (_+1 < length(global_points), devs += element(element(global_points, _+1),1)-ptime);\n" +
"$ if (_-1 >= 0, devs += ptime-element(element(global_points, _-1),1));\n" +
"$ 0.6*reduce(devs, _a+_, 0)/length(devs)\n" +
"$ );\n" +
"$ impact = __norm_prob(path_point+point, ptime, dev);\n" +
"$ if(ltotal && impact < 0.000001*ltotal, throw(null));\n" +
"$ components += l(v, impact);\n" +
"$ ltotal += impact\n" +
"$ )\n" +
"$ ,null\n" +
"$ );\n" +
"$ total = rtotal+ltotal;\n" +
"$ reduce(components, _a+element(_,0)*(element(_,1)/total), l(0,0,0,0,0))\n" +
"$);\n" +
"\n" + "\n" +
" __find_position_for_gauss(from_index, point) -> \n" +
"(\n" +
" dev = global_interpol_option;\n" +
" components = l();\n" +
" path_point = element(element(global_points, from_index),1);\n" +
" \n" +
" try(\n" +
" for(range(from_index+1, length(global_points)),\n" +
" l(v,ptime,mode) = element(global_points, _);\n" +
" dev = if (global_interpol_option > 0, global_interpol_option, \n" +
" devs = l();\n" +
" if (_+1 < length(global_points), devs += element(element(global_points, _+1),1)-ptime);\n" +
" if (_-1 >= 0, devs += ptime-element(element(global_points, _-1),1));\n" +
" 0.6*reduce(devs, _a+_, 0)/length(devs)\n" +
" );\n" +
" impact = __norm_prob(path_point+point, ptime, dev);\n" +
" if(rtotal && impact < 0.000001*rtotal, throw(null));\n" +
" components += l(v, impact);\n" +
" rtotal += impact\n" +
" )\n" +
" ,null\n" +
" );\n" +
" try(\n" +
" for(range(from_index, -1, -1),\n" +
" l(v,ptime,mode) = element(global_points, _);\n" +
" dev = if (global_interpol_option > 0, global_interpol_option, \n" +
" devs = l();\n" +
" if (_+1 < length(global_points), devs += element(element(global_points, _+1),1)-ptime);\n" +
" if (_-1 >= 0, devs += ptime-element(element(global_points, _-1),1));\n" +
" 0.6*reduce(devs, _a+_, 0)/length(devs)\n" +
" );\n" +
" impact = __norm_prob(path_point+point, ptime, dev);\n" +
" if(ltotal && impact < 0.000001*ltotal, throw(null));\n" +
" components += l(v, impact);\n" +
" ltotal += impact\n" +
" )\n" +
" ,null\n" +
" );\n" +
" total = rtotal+ltotal;\n" +
" reduce(components, _a+element(_,0)*(element(_,1)/total), l(0,0,0,0,0))\n" +
");\n" +
" __prepare_path_if_needed_bungee(fps) ->\n" +
"(\n" +
" exit('not ready!');\n" +
" if(!global_points, exit('Cannot show path that doesn\\'t exist'));\n" +
" if(length(global_points)<2, exit('Path not complete - add more points'));\n" +
" v = element(element(global_points, 0),0);\n" +
" modify(p, 'pos', slice(v,0,3));\n" +
" modify(p, 'yaw', element(v,3));\n" +
" modify(p, 'pitch', element(v,4));\n" +
" current_target = element(element(global_points, 1),0);\n" +
" current_hook = 1;\n" +
" loop(length(global_points)-1, \n" +
" current_base = _;\n" +
" l(va, start, mode_a) = element(global_points,_);\n" +
" l(vb, end, mode_b) = element(global_points,_+1);\n" +
" section = end-start;\n" +
" loop(section,\n" +
" dt = _/section;\n" +
"\n" + "\n" +
"$ __prepare_path_if_needed_bungee(fps) ->\n" + " v = dt*vb+(1-dt)*va;\n" +
"$(\n" + " modify(p, 'pos', slice(v,0,3));\n" +
"$ exit('not ready!');\n" + " modify(p, 'yaw', element(v,3));\n" +
"$ if(!global_points, exit('Cannot show path that doesn\\'t exist'));\n" + " modify(p, 'pitch', element(v,4));\n" +
"$ if(length(global_points)<2, exit('Path not complete - add more points'));\n" + " game_tick(1000/fps)\n" +
"$ v = element(element(global_points, 0),0);\n" + " )\n" +
"$ modify(p, 'pos', slice(v,0,3));\n" + " );\n" +
"$ modify(p, 'pitch', element(v,3));\n" + " game_tick(1000);\n" +
"$ modify(p, 'yaw', element(v,4));\n" + " 'Done!'\n" +
"$ current_target = element(element(global_points, 1),0);\n" + ")\n";
"$ current_hook = 1;\n" +
"$ loop(length(global_points)-1, \n" +
"$ current_base = _;\n" +
"$ l(va, start, mode_a) = element(global_points,_);\n" +
"$ l(vb, end, mode_b) = element(global_points,_+1);\n" +
"$ section = end-start;\n" +
"$ loop(section,\n" +
"$ dt = _/section;\n" +
"\n" +
"$ v = dt*vb+(1-dt)*va;\n" +
"$ modify(p, 'pos', slice(v,0,3));\n" +
"$ modify(p, 'pitch', element(v,3));\n" +
"$ modify(p, 'yaw', element(v,4));\n" +
"$ game_tick(1000/fps)\n" +
"$ )\n" +
"$ );\n" +
"$ game_tick(1000);\n" +
"$ 'Done!'\n" +
"$)\n" +
"$";
} }
} }