@@ -14,6 +14,10 @@ public class Animator {
1414 public static final HashSet <Animation > nani = new HashSet <>();
1515 static {
1616 nani .add (new Rotator ("rotator" , new Setting (Type .FLOAT , "x" , 0f ), new Setting (Type .FLOAT , "y" , 0f ), new Setting (Type .FLOAT , "z" , 0f )));
17+ nani .add (new Translator ("translator" , new Setting (Type .FLOAT , "x" , 0f ), new Setting (Type .FLOAT , "y" , 0f ), new Setting (Type .FLOAT , "z" , 0f ),
18+ new Setting (Type .FLOAT , "x_min" ,-1f ), new Setting (Type .FLOAT , "y_min" , -1f ), new Setting (Type .FLOAT , "z_min" , -1f ),
19+ new Setting (Type .FLOAT , "x_max" , 1f ), new Setting (Type .FLOAT , "y_max" , 1f ), new Setting (Type .FLOAT , "z_max" , 1f ),
20+ new Setting (Type .BOOLEAN , "loop" , true )));
1721 }
1822
1923 public static abstract class Animation {
@@ -35,6 +39,10 @@ public Animation copy(){
3539 return this .COPY (id , settings );
3640 }
3741
42+ public Setting get (String id , Setting [] list ){
43+ for (Setting setting : list ) if (setting .getId ().equals (id )) return setting ; return null ;
44+ }
45+
3846 }
3947
4048 public static Set <Animation > get (){
@@ -50,7 +58,7 @@ public static class Rotator extends Animation {
5058 private Setting x , y , z ;
5159
5260 public Rotator (String id , Setting ... settings ){
53- super (id , settings ); x = settings [ 0 ] ; y = settings [ 1 ] ; z = settings [ 2 ] ;
61+ super (id , settings ); x = get ( "x" , settings ) ; y = get ( "y" , settings ) ; z = get ( "z" , settings ) ;
5462 }
5563
5664 @ Override
@@ -71,5 +79,46 @@ protected Animation COPY(String id, Setting[] settings){
7179 }
7280
7381 }
82+
83+ public static class Translator extends Animation {
84+
85+ private Setting x , y , z , x_max , y_max , z_max , x_min , y_min , z_min , loop ;
86+ private int xdir = 1 , ydir = 1 , zdir = 1 ; private float xpass , ypass , zpass ;
87+
88+ public Translator (String id , Setting ... settings ){
89+ super (id , settings );
90+ x = get ("x" , settings ); y = get ("y" , settings ); z = get ("z" , settings );
91+ x_min = get ("x_min" , settings ); y_min = get ("y_min" , settings ); z_min = get ("z_min" , settings );
92+ x_max = get ("x_max" , settings ); y_max = get ("y_max" , settings ); z_max = get ("z_max" , settings );
93+ loop = get ("loop" , settings );
94+ }
95+
96+ @ Override
97+ public void pre (TurboList list ){
98+ xpass += xdir * x .getFloatValue (); ypass += ydir * y .getFloatValue (); zpass += zdir * z .getFloatValue ();
99+ //
100+ if (xpass > x_max .getFloatValue ()){ xpass = x_max .getFloatValue (); if (loop .getBooleanValue ()) xdir = -xdir ; }
101+ if (xpass < x_min .getFloatValue ()){ xpass = x_min .getFloatValue (); if (loop .getBooleanValue ()) xdir = -xdir ; }
102+ //
103+ if (ypass > y_max .getFloatValue ()){ ypass = y_max .getFloatValue (); if (loop .getBooleanValue ()) ydir = -ydir ; }
104+ if (ypass < y_min .getFloatValue ()){ ypass = y_min .getFloatValue (); if (loop .getBooleanValue ()) ydir = -ydir ; }
105+ //
106+ if (zpass > z_max .getFloatValue ()){ zpass = z_max .getFloatValue (); if (loop .getBooleanValue ()) zdir = -zdir ; }
107+ if (zpass < z_min .getFloatValue ()){ zpass = z_min .getFloatValue (); if (loop .getBooleanValue ()) zdir = -zdir ; }
108+ //
109+ for (PolygonWrapper wrap : list ){ wrap .addPosRot (true , xpass , ypass , zpass ); }
110+ }
111+
112+ @ Override
113+ public void post (TurboList list ){
114+ for (PolygonWrapper wrap : list ){ wrap .addPosRot (true , -xpass , -ypass , -zpass ); }
115+ }
116+
117+ @ Override
118+ protected Animation COPY (String id , Setting [] settings ){
119+ return new Translator (id , settings );
120+ }
121+
122+ }
74123
75124}
0 commit comments