Skip to content

Commit 3fa3b96

Browse files
committed
Improved Animations, Shift Input & Cubic Markers
1 parent 9251fd1 commit 3fa3b96

File tree

10 files changed

+153
-37
lines changed

10 files changed

+153
-37
lines changed

src/net/fexcraft/app/fmt/ui/editor/ModelGroupEditor.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public void run(){
116116
protected boolean processButtonClick(int x, int y, boolean left){
117117
if(FMTB.MODEL.getSelected().isEmpty()) return true;
118118
if(!left){
119-
FMTB.showDialogbox(this.getText(), "test", null, DialogBox.NOTHING, null);
119+
FMTB.showDialogbox(this.getText(), "ok", null, DialogBox.NOTHING, null);
120120
this.setText("", true);
121121
return true;
122122
}
@@ -129,16 +129,16 @@ public void updateTextField(){
129129
if(anim == null){
130130
FMTB.showDialogbox("Animation not found!", "ok", null, DialogBox.NOTHING, null);
131131
return;
132-
} anim.copy();
132+
} final Animation ani = anim.copy();
133133
ArrayList<TurboList> lists = FMTB.MODEL.getDirectlySelectedGroups();
134134
AfterTask task = new AfterTask(){
135135
@Override
136136
public void run(){
137137
for(TurboList list : lists){
138-
list.animations.add(anim.copy());
138+
list.animations.add(ani);
139139
} FMTB.MODEL.updateFields();
140140
}
141-
}; task.settings = anim.settings;
141+
}; task.settings = ani.settings;
142142
UserInterface.SETTINGSBOX.show("Animator Settings", task);
143143
}
144144
}.setText("null", true).setRowCol(9, 0));
@@ -207,11 +207,10 @@ public void addSubElements(){
207207
@Override
208208
protected boolean processButtonClick(int x, int y, boolean left){
209209
if(left){
210-
Animation anim = list.animations.get(j); this.deselect();
211-
FMTB.MODEL.updateFields(); if(anim == null) return true;
210+
Animation anim = list.animations.get(j); this.deselect(); if(anim == null) return true;
212211
AfterTask task = new AfterTask(){
213-
@Override public void run(){ FMTB.MODEL.updateFields(); }
214-
}; task.settings = anim.settings; UserInterface.SETTINGSBOX.reset();
212+
@Override public void run(){ anim.onSettingsUpdate(); FMTB.MODEL.updateFields(); }
213+
}; task.settings = anim.settings; FMTB.MODEL.updateFields();
215214
UserInterface.SETTINGSBOX.show("[" + anim.id + "] Settings", task);
216215
}
217216
else{

src/net/fexcraft/app/fmt/ui/general/SettingsBox.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ public void show(Object... objects){
146146

147147
@Override
148148
public void reset(){
149-
this.visible = false; this.elements.removeIf(pre -> !pre.id.equals("confirm"));
150-
this.Confirm.setVisible(false); this.Cancel.setVisible(false); this.settings.clear();
149+
this.visible = false; this.elements.removeIf(pre -> !(pre.id.equals("confirm") || pre.id.equals("cancel")));
150+
this.Confirm.setVisible(false); this.Cancel.setVisible(false); this.settings.clear(); this.updateFields();
151151
}
152152

153153
}

src/net/fexcraft/app/fmt/utils/Animator.java

Lines changed: 110 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.HashSet;
55
import java.util.List;
66
import java.util.Set;
7+
78
import net.fexcraft.app.fmt.utils.Settings.Setting;
89
import net.fexcraft.app.fmt.utils.Settings.Type;
910
import 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
}

src/net/fexcraft/app/fmt/utils/GGR.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,17 @@ private void acceptInputKeyboard(){
114114
}
115115

116116
private String getKeyName(int i){
117-
return GGR.isShiftDown() ? Keyboard.getKeyName(i) : Keyboard.getKeyName(i).toLowerCase();
117+
return GGR.isShiftDown() ? i < 12 ? getSpecialChar(i) : Keyboard.getKeyName(i) : Keyboard.getKeyName(i).toLowerCase();
118+
}
119+
120+
private String getSpecialChar(int i){
121+
switch(i){
122+
case 2: return "!"; case 3: return "@";
123+
case 4: return "#"; case 5: return "$";
124+
case 6: return "%"; case 7: return "^";
125+
case 8: return "&"; case 9: return "*";
126+
case 10: return "("; case 11: return ")";
127+
} return Keyboard.getKeyName(i);
118128
}
119129

120130
private boolean clickedL, clickedR, panning;
@@ -213,7 +223,11 @@ else if(panning){
213223
}
214224

215225
public static boolean isShiftDown(){
216-
return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
226+
return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_FUNCTION);
227+
}
228+
229+
public static boolean iControlDown(){
230+
return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
217231
}
218232

219233
}

src/net/fexcraft/app/fmt/utils/HelperCollector.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ public static final GroupCompound load(File file, ExImPorter exim, Map<String, S
3737
if(exim.isInternal()){
3838
GroupCompound compound = ((InternalPorter)exim).importModel(file, settings);
3939
if(!compound.name.startsWith("import/")){ compound.name = "import/" + compound.name; }
40-
LOADED.add(compound); return compound;
40+
LOADED.add(compound); compound.deselectAll(); return compound;
4141
}
4242
else{
4343
try{
4444
Invocable inv = (Invocable)((ExternalPorter)exim).eval();
4545
String result = (String)inv.invokeFunction("importModel", file);
4646
GroupCompound compound = SaveLoad.getModel(file, JsonUtil.getObjectFromString(result), false);
4747
if(!compound.name.startsWith("import/")){ compound.name = "import/" + compound.name; }
48-
LOADED.add(compound); return compound;
48+
LOADED.add(compound); compound.deselectAll(); return compound;
4949
}
5050
catch(FileNotFoundException | ScriptException | NoSuchMethodException e){
5151
e.printStackTrace(); return null;
@@ -81,7 +81,7 @@ public static GroupCompound loadFMTB(File file){
8181
FMTB.showDialogbox("Errors occured\nwhile parsing save file", "ok", null, DialogBox.NOTHING, null);
8282
}
8383
if(compound != null){ LOADED.add(compound); }
84-
return compound;
84+
compound.deselectAll(); return compound;
8585
}
8686

8787
public static GroupCompound loadFrame(File file){
@@ -126,7 +126,7 @@ public static GroupCompound loadFrame(File file){
126126
FMTB.showDialogbox("Errors occured\nwhile creating frame.", "ok", null, DialogBox.NOTHING, null);
127127
}
128128
if(compound != null){ LOADED.add(compound); }
129-
return compound;
129+
compound.deselectAll(); return compound;
130130
}
131131

132132
}

src/net/fexcraft/app/fmt/utils/SaveLoad.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ public static GroupCompound getModel(File from, JsonObject obj, boolean ggr){
344344
for(JsonElement elm : arr){
345345
JsonObject animjsn = elm.getAsJsonObject();
346346
Animation anim = Animator.get(animjsn.get("id").getAsString());
347+
if(anim == null) continue; anim = anim.copy();
347348
JsonArray settin = animjsn.get("settings").getAsJsonArray();
348349
for(JsonElement elm0 : settin){
349350
JsonObject sett = elm0.getAsJsonObject();

src/net/fexcraft/app/fmt/utils/Settings.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.google.gson.JsonPrimitive;
1010

1111
import net.fexcraft.app.fmt.FMTB;
12+
import net.fexcraft.app.fmt.wrappers.GroupCompound;
1213
import net.fexcraft.app.fmt.wrappers.PolygonWrapper;
1314
import net.fexcraft.app.fmt.wrappers.TurboList;
1415
import net.fexcraft.lib.common.json.JsonUtil;
@@ -92,6 +93,11 @@ public static boolean toggleAnimations(){
9293
if(!bool){
9394
for(TurboList list : FMTB.MODEL.getCompound().values())
9495
for(PolygonWrapper wrapper : list) wrapper.resetPosRot();
96+
for(GroupCompound compound : HelperCollector.LOADED){
97+
for(TurboList list : compound.getCompound().values()){
98+
for(PolygonWrapper wrapper : list) wrapper.resetPosRot();
99+
}
100+
}
95101
}
96102
return bool;
97103
}
@@ -349,7 +355,7 @@ public float getFloatValue(){
349355
}
350356

351357
public Setting copy(){
352-
return new Setting(type, id, value);
358+
return new Setting(type.name(), id, save());
353359
}
354360

355361
}

src/net/fexcraft/app/fmt/wrappers/GroupCompound.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,4 +627,8 @@ public PolygonWrapper getLastSelected(){
627627
public int tx(TurboList list){ return list == null || list.getGroupTexture() == null ? textureSizeX : list.textureX; }
628628
public int ty(TurboList list){ return list == null || list.getGroupTexture() == null ? textureSizeY : list.textureY; }
629629

630+
public void deselectAll(){
631+
for(TurboList list : compound.values()){ list.selected = false; for(PolygonWrapper wrapper : list) wrapper.selected = false; }
632+
}
633+
630634
}

src/net/fexcraft/app/fmt/wrappers/PolygonWrapper.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
public abstract class PolygonWrapper {
1818

19-
protected static final ModelRendererTurbo rotmarker = new ModelRendererTurbo(null, 0, 0, 16, 16).addSphere(0, 0, 0, 0.5f, 8, 8, 0, 0).setTextured(false).setColor(Settings.getSelectedColor());
19+
protected static final ModelRendererTurbo rotmarker = new ModelRendererTurbo(null, 0, 0, 16, 16).addBox(-.25f, -.25f, -.25f, .5f, .5f, .5f).setTextured(false).setColor(Settings.getSelectedColor());
2020
private static final ModelRendererTurbo something = new ModelRendererTurbo(null, 0, 0, 16, 16).setTextured(false);
2121
//
2222
public Vec3f pos = new Vec3f(), off = new Vec3f(), rot = new Vec3f();
@@ -49,10 +49,8 @@ public void renderLines(boolean rotXb, boolean rotYb, boolean rotZb){
4949
//if(Settings.lines()) (selected ? sellines : lines).render();
5050
GL11.glDisable(GL11.GL_TEXTURE_2D);
5151
if((selected || turbolist.selected) && Settings.polygonMarker()){
52-
if(Settings.cullface()) GL11.glDisable(GL11.GL_CULL_FACE);
5352
rotmarker.setRotationPoint(lines.rotationPointX, lines.rotationPointY, lines.rotationPointZ);
5453
rotmarker.render();
55-
if(Settings.cullface()) GL11.glEnable(GL11.GL_CULL_FACE);
5654
}
5755
if(Settings.lines()){
5856
if(selected || turbolist.selected){

0 commit comments

Comments
 (0)