Skip to content

Commit

Permalink
+ Mesh Editor.
Browse files Browse the repository at this point in the history
#2 ExportAs ok
Improving TreeNode.
Game works again.
TextDialog in feature processing

Signed-off-by: Manuel Daniel Dahmen <[email protected]>
  • Loading branch information
manuelddahmen committed Jan 17, 2024
1 parent 09282b9 commit bf5bd8a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
22 changes: 9 additions & 13 deletions src/main/java/one/empty3/feature/CustomProcessFileRGB.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import one.empty3.feature.app.replace.javax.imageio.ImageIO;
import one.empty3.io.ProcessFile;
import one.empty3.library.StructureMatrix;
import one.empty3.library1.shader.Vec;
import one.empty3.library1.tree.ListInstructions;

Expand All @@ -46,6 +47,7 @@ public class CustomProcessFileRGB extends ProcessFile {

public CustomProcessFileRGB() {
textDialog = TextDialog.getInstance();
textDialog.setVisible(true);
}

@Override
Expand All @@ -66,6 +68,7 @@ public boolean process(File in, File out) {
try {
HashMap<String, String> currentVecs = new HashMap<>();
HashMap<String, Double> currentVars = new HashMap<>();
HashMap<String, StructureMatrix<Double>> currentVecsComputed = new HashMap<>();

for (int i = 0; i < pix.getColumns(); i++) {
for (int j = 0; j < pix.getLines(); j++) {
Expand All @@ -82,6 +85,7 @@ public boolean process(File in, File out) {

listInstructions.setCurrentParamsValues(currentVars);
listInstructions.setCurrentParamsValuesVec(currentVecs);
listInstructions.setCurrentParamsValuesVecComputed(currentVecsComputed);
listInstructions.addInstructions(textDialog.getText());
currentVars.put("r", r);
currentVars.put("g", g);
Expand All @@ -93,19 +97,11 @@ public boolean process(File in, File out) {

System.out.println(listInstructions.evaluate("(r,g,b"));

currentVars = listInstructions.getCurrentParamsValues();

if (currentVars.get("r") != null && currentVars.get("g") != null && currentVars.get("b") != null) {
r = currentVars.get("r");
g = currentVars.get("g");
b = currentVars.get("b");
} else {
r = 0.0;
g = 0.0;
b = 0.0;
System.err.println("Error in sources");
return false;
}
currentVecsComputed = listInstructions.getCurrentParamsValuesVecComputed();

r = currentVecsComputed.getOrDefault("r", (new StructureMatrix<Double>(0, Double.class).setElem(r))).getElem();
g = currentVecsComputed.getOrDefault("g", (new StructureMatrix<Double>(0, Double.class).setElem(g))).getElem();
b = currentVecsComputed.getOrDefault("b", (new StructureMatrix<Double>(0, Double.class).setElem(b))).getElem();
pixOut.setValues(i, j, r, g, b);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/one/empty3/feature/TextDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public TextDialog() {


public static TextDialog getInstance() {
if (instance == null)
return new TextDialog();
return instance;
}

Expand Down
29 changes: 18 additions & 11 deletions src/main/java/one/empty3/library1/tree/ListInstructions.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ public class ListInstructions {
HashMap<String, String> currentParamsValuesVec = new HashMap<>();
HashMap<String, StructureMatrix<Double>> currentParamsValuesVecComputed = new HashMap<>();

public void setCurrentParamsValues(HashMap<String, Double> currentVars) {
this.currentParamsValues = currentVars;
}

public void setCurrentParamsValuesVec(HashMap<String, String> currentVecs) {
this.currentParamsValuesVec = currentVecs;
}

public String evaluate(String s) {
return "";
}
Expand Down Expand Up @@ -157,9 +149,12 @@ public List<String> runInstructions() {

assignations.toArray(instructions);

currentParamsValues = new HashMap<>();
currentParamsValuesVec = new HashMap<>();
currentParamsValuesVecComputed = new HashMap<>();
if (currentParamsValues == null)
currentParamsValues = new HashMap<>();
if (currentParamsValuesVec == null)
currentParamsValuesVec = new HashMap<>();
if (currentParamsValuesVecComputed == null)
currentParamsValuesVecComputed = new HashMap<>();
int i = 0;
for (Instruction instruction : instructions) {
String key = (String) instruction.getLeftHand();
Expand Down Expand Up @@ -220,4 +215,16 @@ public HashMap<String, String> getCurrentParamsValuesVec() {
public HashMap<String, StructureMatrix<Double>> getCurrentParamsValuesVecComputed() {
return currentParamsValuesVecComputed;
}

public void setCurrentParamsValues(HashMap<String, Double> currentVars) {
this.currentParamsValues = currentVars;
}

public void setCurrentParamsValuesVec(HashMap<String, String> currentVecs) {
this.currentParamsValuesVec = currentVecs;
}

public void setCurrentParamsValuesVecComputed(HashMap<String, StructureMatrix<Double>> currentVecsComputed) {
this.currentParamsValuesVecComputed = currentVecsComputed;
}
}

0 comments on commit bf5bd8a

Please sign in to comment.