Skip to content

Commit 7da3393

Browse files
committed
per-face color-based-picker color
1 parent abf39aa commit 7da3393

File tree

5 files changed

+32
-18
lines changed

5 files changed

+32
-18
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ protected boolean processButtonClick(int x, int y, boolean left){
114114
FMTB.showDialogbox("Texture not found in Memory.", "This rather bad.", "ok", null, DialogBox.NOTHING, null);
115115
}
116116
FMTB.MODEL.getCompound().values().forEach(list -> list.forEach(poly -> {
117-
poly.burnToTexture(tex); //poly.recompile();
117+
poly.burnToTexture(tex, null); //poly.recompile();
118118
})); tex.rebind(); //TextureManager.saveTexture(FMTB.MODEL.texture);
119119
//FMTB.showDialogbox("Done!", "", "ok", null, DialogBox.NOTHING, null);
120120
}

src/net/fexcraft/app/fmt/ui/generic/Toolbar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ protected boolean processButtonClick(int x, int y, boolean left){
354354
FMTB.MODEL.setTexture(texname);
355355
TextureManager.newBlankTexture(texname);
356356
Texture tex = TextureManager.getTexture(texname, true);
357-
FMTB.MODEL.getCompound().values().forEach(elm -> elm.forEach(poly -> poly.burnToTexture(tex)));
357+
FMTB.MODEL.getCompound().values().forEach(elm -> elm.forEach(poly -> poly.burnToTexture(tex, null)));
358358
TextureManager.saveTexture(texname); tex.reload(); FMTB.MODEL.recompile();
359359
return true;
360360
}

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ public static void doTest(boolean bool, boolean mouseoff){
3535
buffer.clear(); PICKING = false; MOUSEOFF = false;
3636
for(TurboList list : FMTB.MODEL.getCompound().values()){
3737
for(PolygonWrapper wrapper : list){
38-
if(wrapper.color == id){
39-
boolean control = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL);
40-
boolean state = control ? wrapper.getList().selected : wrapper.selected;
41-
if(!Keyboard.isKeyDown(Keyboard.KEY_LMENU)) FMTB.MODEL.clearSelection();
42-
if(control){ wrapper.getList().selected = !state; }
43-
else{ wrapper.selected = !state; }
44-
FMTB.MODEL.updateFields();
38+
for(int col : wrapper.color){
39+
if(col == id){
40+
boolean control = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL);
41+
boolean state = control ? wrapper.getList().selected : wrapper.selected;
42+
if(!Keyboard.isKeyDown(Keyboard.KEY_LMENU)) FMTB.MODEL.clearSelection();
43+
if(control){ wrapper.getList().selected = !state; }
44+
else{ wrapper.selected = !state; }
45+
FMTB.MODEL.updateFields();
46+
}
4547
}
4648
}
4749
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public void render(){
6060
else{
6161
compound.values().forEach(elm -> elm.render());
6262
compound.values().forEach(elm -> elm.renderLines());
63+
//compound.values().forEach(elm -> elm.renderPicking());//uncomment for debugging the ray-/color-picker
6364
}
6465
if(scale != null){
6566
GL11.glPopMatrix();

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

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public abstract class PolygonWrapper {
2929
private TurboList turbolist;
3030
public boolean mirror, flip;
3131
public boolean selected;
32-
public Integer color;
32+
public int[] color;
3333
public String name;
3434

3535
public PolygonWrapper(GroupCompound compound){
@@ -154,21 +154,31 @@ protected void setupMRT(){
154154
turbo = newMRT().setTextured(compound.texture != null);
155155
lines = newMRT().setLines(true);
156156
sellines = newMRT().setLines(Settings.selectedColor);
157-
picker = newMRT().setTextured(false).setColor(genColor());
157+
//
158+
picker = new ModelRendererTurbo(null, 0, 0, 16, 16){
159+
@Override
160+
public RGB getColor(int i){
161+
return new RGB(genColor(this, i));
162+
}
163+
};
164+
picker.copyTo(sellines.getVertices(), sellines.getFaces());
165+
picker.setRotationPoint(sellines.rotationPointX, sellines.rotationPointY, sellines.rotationPointZ);
166+
picker.setRotationAngle(sellines.rotateAngleX, sellines.rotateAngleY, sellines.rotateAngleZ);
167+
picker.setTextured(false).setLines(false);
158168
}
159169

160170
//private static int maxcol = 16777215;
161171
private static int lastint = 0;
162172

163-
private RGB genColor(){
173+
private RGB genColor(ModelRendererTurbo turbo, int face){
164174
if(color == null){
165-
color = lastint += 16;
166-
if(color == 2048383){
167-
color = lastint += 16;
175+
color = new int[turbo.getFaces().length];
176+
for(int i = 0; i < color.length; i++){
177+
color[i] = lastint += 1;
178+
if(color[i] == 2048383){ color[i] = lastint += 1; }
168179
}
169180
}
170-
//Print.console(color + " ");
171-
RGB rgb = new RGB(); rgb.packed = color; return rgb;
181+
RGB rgb = new RGB(); rgb.packed = color[face]; return rgb;
172182
}
173183

174184
protected abstract ModelRendererTurbo newMRT();
@@ -219,13 +229,14 @@ public ModelRendererTurbo getTurboObject(int i){
219229
if(i < 0 || i > 2) i = 0; return i == 0 ? turbo : i == 1 ? lines : sellines;
220230
}
221231

222-
public boolean burnToTexture(Texture tex){
232+
public boolean burnToTexture(Texture tex, Integer face){
223233
if(this.texpos == null || this.texpos.length == 0){
224234
Print.console("Polygon '" + turbolist.id + ":" + this.name() + "' has no texture data, skipping.");
225235
return false;
226236
}
227237
BufferedImage buff = tex.getImage(); int color = 0;
228238
for(int i = 0; i < texpos.length; i++){
239+
if(face != null && i != face) continue;
229240
float[][] ends = texpos[i]; if(ends == null || ends.length == 0) continue; color = new Color(something.getColor(i).packed).darker().darker().getRGB();
230241
for(float x = ends[0][0]; x < ends[1][0]; x += 0.5f){//double accuracy!
231242
for(float y = ends[0][1]; y < ends[1][1]; y += 0.5f){//double accuracy!

0 commit comments

Comments
 (0)