44import java .util .HashSet ;
55import java .util .List ;
66import java .util .Set ;
7+
78import net .fexcraft .app .fmt .utils .Settings .Setting ;
89import net .fexcraft .app .fmt .utils .Settings .Type ;
910import net .fexcraft .app .fmt .wrappers .PolygonWrapper ;
@@ -13,11 +14,15 @@ public class Animator {
1314
1415 public static final HashSet <Animation > nani = new HashSet <>();
1516 static {
16- 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 Rotator ("rotator" , 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" , -360f ), new Setting (Type .FLOAT , "y_min" , -360f ), new Setting (Type .FLOAT , "z_min" , -360f ),
19+ new Setting (Type .FLOAT , "x_max" , 360f ), new Setting (Type .FLOAT , "y_max" , 360f ), new Setting (Type .FLOAT , "z_max" , 360f ),
20+ new Setting (Type .BOOLEAN , "loop" , true ), new Setting (Type .BOOLEAN , "opposite_on_end" , false )));
1721 nani .add (new Translator ("translator" , new Setting (Type .FLOAT , "x" , 0f ), new Setting (Type .FLOAT , "y" , 0f ), new Setting (Type .FLOAT , "z" , 0f ),
1822 new Setting (Type .FLOAT , "x_min" ,-1f ), new Setting (Type .FLOAT , "y_min" , -1f ), new Setting (Type .FLOAT , "z_min" , -1f ),
1923 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 )));
24+ new Setting (Type .BOOLEAN , "loop" , true ), new Setting (Type .BOOLEAN , "opposite_on_end" , false )));
25+ //nani.add(new Transparency("glass", new Setting(Type.RGB, "color", RGB.BLUE)));
2126 }
2227
2328 public static abstract class Animation {
@@ -32,6 +37,7 @@ public Animation(String id, Setting... settings){
3237 public abstract void pre (TurboList list );
3338 public abstract void post (TurboList list );
3439 protected abstract Animation COPY (String id , Setting [] settings );
40+ public void onSettingsUpdate (){}
3541
3642 public Animation copy (){
3743 Setting [] settings = new Setting [this .settings .size ()];
@@ -43,6 +49,10 @@ public Setting get(String id, Setting[] list){
4349 for (Setting setting : list ) if (setting .getId ().equals (id )) return setting ; return null ;
4450 }
4551
52+ public Setting get (String id , Iterable <Setting > list ){
53+ for (Setting setting : list ) if (setting .getId ().equals (id )) return setting ; return null ;
54+ }
55+
4656 }
4757
4858 public static Set <Animation > get (){
@@ -55,22 +65,53 @@ public static Animation get(String string){
5565
5666 public static class Rotator extends Animation {
5767
58- private Setting x , y , z ;
68+ private Setting x , y , z , x_max , y_max , z_max , x_min , y_min , z_min , loop , ooe ;
69+ private int xdir = 1 , ydir = 1 , zdir = 1 ; private float xpass , ypass , zpass ;
5970
6071 public Rotator (String id , Setting ... settings ){
6172 super (id , settings ); x = get ("x" , settings ); y = get ("y" , settings ); z = get ("z" , settings );
73+ x_min = get ("x_min" , settings ); y_min = get ("y_min" , settings ); z_min = get ("z_min" , settings );
74+ x_max = get ("x_max" , settings ); y_max = get ("y_max" , settings ); z_max = get ("z_max" , settings );
75+ loop = get ("loop" , settings ); ooe = get ("opposite_on_end" , settings );
6276 }
6377
6478 @ Override
6579 public void pre (TurboList list ){
66- for (PolygonWrapper wrap : list ){
67- wrap .addPosRot (false , x .getValue (), y .getValue (), z .getValue ());
80+ xpass += xdir * x .getFloatValue (); ypass += ydir * y .getFloatValue (); zpass += zdir * z .getFloatValue ();
81+ //
82+ if (xpass > x_max .getFloatValue ()){
83+ xpass = x_max .getFloatValue (); if (ooe .getBooleanValue ()) xdir = -xdir ;
84+ if (loop .getBooleanValue ()) xpass = x_min .getFloatValue ();
85+ }
86+ if (xpass < x_min .getFloatValue ()){
87+ xpass = x_min .getFloatValue (); if (ooe .getBooleanValue ()) xdir = -xdir ;
88+ if (loop .getBooleanValue ()) xpass = x_max .getFloatValue ();
89+ }
90+ //
91+ if (ypass > y_max .getFloatValue ()){
92+ ypass = y_max .getFloatValue (); if (ooe .getBooleanValue ()) ydir = -ydir ;
93+ if (loop .getBooleanValue ()) ypass = y_min .getFloatValue ();
6894 }
95+ if (ypass < y_min .getFloatValue ()){
96+ ypass = y_min .getFloatValue (); if (ooe .getBooleanValue ()) ydir = -ydir ;
97+ if (loop .getBooleanValue ()) ypass = y_max .getFloatValue ();
98+ }
99+ //
100+ if (zpass > z_max .getFloatValue ()){
101+ zpass = z_max .getFloatValue (); if (ooe .getBooleanValue ()) zdir = -zdir ;
102+ if (loop .getBooleanValue ()) zpass = z_min .getFloatValue ();
103+ }
104+ if (zpass < z_min .getFloatValue ()){
105+ zpass = z_min .getFloatValue (); if (ooe .getBooleanValue ()) zdir = -zdir ;
106+ if (loop .getBooleanValue ()) zpass = z_max .getFloatValue ();
107+ }
108+ //
109+ for (PolygonWrapper wrap : list ){ wrap .addPosRot (false , xpass , ypass , zpass ); }
69110 }
70111
71112 @ Override
72113 public void post (TurboList list ){
73- //
114+ for ( PolygonWrapper wrap : list ){ wrap . addPosRot ( false , - xpass , - ypass , - zpass ); }
74115 }
75116
76117 @ Override
@@ -82,29 +123,46 @@ protected Animation COPY(String id, Setting[] settings){
82123
83124 public static class Translator extends Animation {
84125
85- private Setting x , y , z , x_max , y_max , z_max , x_min , y_min , z_min , loop ;
126+ private Setting x , y , z , x_max , y_max , z_max , x_min , y_min , z_min , loop , ooe ;
86127 private int xdir = 1 , ydir = 1 , zdir = 1 ; private float xpass , ypass , zpass ;
87128
88129 public Translator (String id , Setting ... settings ){
89- super (id , settings );
90- x = get ("x" , settings ); y = get ("y" , settings ); z = get ("z" , settings );
130+ super (id , settings ); x = get ("x" , settings ); y = get ("y" , settings ); z = get ("z" , settings );
91131 x_min = get ("x_min" , settings ); y_min = get ("y_min" , settings ); z_min = get ("z_min" , settings );
92132 x_max = get ("x_max" , settings ); y_max = get ("y_max" , settings ); z_max = get ("z_max" , settings );
93- loop = get ("loop" , settings );
133+ loop = get ("loop" , settings ); ooe = get ( "opposite_on_end" , settings );
94134 }
95135
96136 @ Override
97137 public void pre (TurboList list ){
98138 xpass += xdir * x .getFloatValue (); ypass += ydir * y .getFloatValue (); zpass += zdir * z .getFloatValue ();
99139 //
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 ; }
140+ if (xpass > x_max .getFloatValue ()){
141+ xpass = x_max .getFloatValue (); if (ooe .getBooleanValue ()) xdir = -xdir ;
142+ if (loop .getBooleanValue ()) xpass = x_min .getFloatValue ();
143+ }
144+ if (xpass < x_min .getFloatValue ()){
145+ xpass = x_min .getFloatValue (); if (ooe .getBooleanValue ()) xdir = -xdir ;
146+ if (loop .getBooleanValue ()) xpass = x_max .getFloatValue ();
147+ }
102148 //
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 ; }
149+ if (ypass > y_max .getFloatValue ()){
150+ ypass = y_max .getFloatValue (); if (ooe .getBooleanValue ()) ydir = -ydir ;
151+ if (loop .getBooleanValue ()) ypass = y_min .getFloatValue ();
152+ }
153+ if (ypass < y_min .getFloatValue ()){
154+ ypass = y_min .getFloatValue (); if (ooe .getBooleanValue ()) ydir = -ydir ;
155+ if (loop .getBooleanValue ()) ypass = y_max .getFloatValue ();
156+ }
105157 //
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 ; }
158+ if (zpass > z_max .getFloatValue ()){
159+ zpass = z_max .getFloatValue (); if (ooe .getBooleanValue ()) zdir = -zdir ;
160+ if (loop .getBooleanValue ()) zpass = z_min .getFloatValue ();
161+ }
162+ if (zpass < z_min .getFloatValue ()){
163+ zpass = z_min .getFloatValue (); if (ooe .getBooleanValue ()) zdir = -zdir ;
164+ if (loop .getBooleanValue ()) zpass = z_max .getFloatValue ();
165+ }
108166 //
109167 for (PolygonWrapper wrap : list ){ wrap .addPosRot (true , xpass , ypass , zpass ); }
110168 }
@@ -120,5 +178,41 @@ protected Animation COPY(String id, Setting[] settings){
120178 }
121179
122180 }
181+
182+ /*public static class Transparency extends Animation {
183+
184+ private RGB color;
185+
186+ public Transparency(String id, Setting... settings){
187+ super(id, settings); this.onSettingsUpdate();
188+ }
189+
190+ @Override
191+ public void pre(TurboList list){
192+ GL11.glPushMatrix();
193+ GL11.glDepthMask(false);
194+ GL11.glEnable(GL11.GL_ALPHA_TEST);
195+ color.glColorApply();
196+ }
197+
198+ @Override
199+ public void post(TurboList list){
200+ RGB.glColorReset();
201+ GL11.glDisable(GL11.GL_ALPHA_TEST);
202+ GL11.glDepthMask(true);
203+ GL11.glPopMatrix();
204+ }
205+
206+ @Override
207+ protected Animation COPY(String id, Setting[] settings){
208+ return new Transparency(id, settings);
209+ }
210+
211+ @Override
212+ public void onSettingsUpdate(){
213+ color = get("color", settings).getValue(); color.alpha = 0.2f;
214+ }
215+
216+ }*/
123217
124218}
0 commit comments