Import brush from texture
This commit is contained in:
@@ -1 +1 @@
|
||||
{"name":"Brush","nodes":[{"id":3,"name":"Input","type":"InputNode","x":83,"y":218,"color":-11959648,"inputs":[{"id":3,"node_id":3,"name":"Lazy Radius","type":"VALUE","color":-6184543,"default_value":0.0},{"id":3,"node_id":3,"name":"Lazy Step","type":"VALUE","color":-6184543,"default_value":0.0}],"outputs":[{"id":3,"node_id":3,"name":"Position","type":"VECTOR","color":-10238109,"default_value":null}],"buttons":[]},{"id":5,"name":"Brush Output","type":"BrushOutputNode","x":311,"y":192,"color":-11959648,"inputs":[{"id":5,"node_id":5,"name":"Position","type":"VECTOR","color":-10238109,"default_value":[0,0,0]},{"id":5,"node_id":5,"name":"Radius","type":"VALUE","color":-6184543,"default_value":1.0},{"id":5,"node_id":5,"name":"UV Scale","type":"VALUE","color":-6184543,"default_value":1.0},{"id":5,"node_id":5,"name":"Angle","type":"VALUE","color":-6184543,"default_value":0.0,"max":360},{"id":5,"node_id":5,"name":"Opacity","type":"VALUE","color":-6184543,"default_value":1.0},{"id":5,"node_id":5,"name":"Hardness","type":"VALUE","color":-6184543,"default_value":1.0},{"id":5,"node_id":5,"name":"Stencil","type":"VALUE","color":-6184543,"default_value":1.0}],"outputs":[],"buttons":[{"name": "Directional","type": "BOOL","default_value": false,"output": 0}]}],"links":[{"id":0,"from_id":3,"from_socket":0,"to_id":5,"to_socket":0}]}
|
||||
{"name":"Brush","nodes":[{"id":1,"name":"Input","type":"InputNode","x":83,"y":218,"color":-11959648,"inputs":[{"id":0,"node_id":1,"name":"Lazy Radius","type":"VALUE","color":-6184543,"default_value":0.0},{"id":1,"node_id":1,"name":"Lazy Step","type":"VALUE","color":-6184543,"default_value":0.0}],"outputs":[{"id":0,"node_id":1,"name":"Position","type":"VECTOR","color":-10238109,"default_value":null}],"buttons":[]},{"id":0,"name":"Brush Output","type":"BrushOutputNode","x":311,"y":192,"color":-11959648,"inputs":[{"id":0,"node_id":0,"name":"Position","type":"VECTOR","color":-10238109,"default_value":[0,0,0]},{"id":1,"node_id":0,"name":"Radius","type":"VALUE","color":-6184543,"default_value":1.0},{"id":2,"node_id":0,"name":"UV Scale","type":"VALUE","color":-6184543,"default_value":1.0},{"id":3,"node_id":0,"name":"Angle","type":"VALUE","color":-6184543,"default_value":0.0,"max":360},{"id":4,"node_id":0,"name":"Opacity","type":"VALUE","color":-6184543,"default_value":1.0},{"id":5,"node_id":0,"name":"Hardness","type":"VALUE","color":-6184543,"default_value":1.0},{"id":6,"node_id":0,"name":"Stencil","type":"VALUE","color":-6184543,"default_value":1.0}],"outputs":[],"buttons":[{"name": "Directional","type": "BOOL","default_value": false,"output": 0}]}],"links":[{"id":0,"from_id":1,"from_socket":0,"to_id":0,"to_socket":0}]}
|
||||
@@ -1 +1 @@
|
||||
{"name":"Material","nodes":[{"id":1,"name":"RGB","type":"RGB","x":122,"y":100,"color":-5025958,"inputs":[],"outputs":[{"id":1,"node_id":1,"name":"Color","type":"RGBA","color":-3684567,"default_value":[0.8,0.8,0.8,1]}],"buttons":[{"name":"default_value","type":"RGBA","output":0}]},{"id":2,"name":"Material Output","type":"OUTPUT_MATERIAL_PBR","x":386,"y":100,"color":-5025958,"inputs":[{"id":2,"node_id":2,"name":"Base Color","type":"RGBA","color":-3684567,"default_value":[0.8,0.8,0.8,1]},{"id":2,"node_id":2,"name":"Opacity","type":"VALUE","color":-6184543,"default_value":1},{"id":2,"node_id":2,"name":"Occlusion","type":"VALUE","color":-6184543,"default_value":1},{"id":2,"node_id":2,"name":"Roughness","type":"VALUE","color":-6184543,"default_value":0.3},{"id":2,"node_id":2,"name":"Metallic","type":"VALUE","color":-6184543,"default_value":0},{"id":2,"node_id":2,"name":"Normal Map","type":"VECTOR","color":-10238109,"default_value":[0.5,0.5,1]},{"id":2,"node_id":2,"name":"Emission","type":"VALUE","color":-6184543,"default_value":0},{"id":2,"node_id":2,"name":"Height","type":"VALUE","color":-6184543,"default_value":0},{"id":2,"node_id":2,"name":"Subsurface","type":"VALUE","color":-6184543,"default_value":0}],"outputs":[],"buttons":[]}],"links":[{"id":0,"from_id":1,"from_socket":0,"to_id":2,"to_socket":0}]}
|
||||
{"name":"Material","nodes":[{"id":1,"name":"RGB","type":"RGB","x":122,"y":100,"color":-5025958,"inputs":[],"outputs":[{"id":0,"node_id":1,"name":"Color","type":"RGBA","color":-3684567,"default_value":[0.8,0.8,0.8,1]}],"buttons":[{"name":"default_value","type":"RGBA","output":0}]},{"id":0,"name":"Material Output","type":"OUTPUT_MATERIAL_PBR","x":386,"y":100,"color":-5025958,"inputs":[{"id":0,"node_id":0,"name":"Base Color","type":"RGBA","color":-3684567,"default_value":[0.8,0.8,0.8,1]},{"id":1,"node_id":0,"name":"Opacity","type":"VALUE","color":-6184543,"default_value":1},{"id":2,"node_id":0,"name":"Occlusion","type":"VALUE","color":-6184543,"default_value":1},{"id":3,"node_id":0,"name":"Roughness","type":"VALUE","color":-6184543,"default_value":0.3},{"id":4,"node_id":0,"name":"Metallic","type":"VALUE","color":-6184543,"default_value":0},{"id":5,"node_id":0,"name":"Normal Map","type":"VECTOR","color":-10238109,"default_value":[0.5,0.5,1]},{"id":6,"node_id":0,"name":"Emission","type":"VALUE","color":-6184543,"default_value":0},{"id":7,"node_id":0,"name":"Height","type":"VALUE","color":-6184543,"default_value":0},{"id":8,"node_id":0,"name":"Subsurface","type":"VALUE","color":-6184543,"default_value":0}],"outputs":[],"buttons":[]}],"links":[{"id":0,"from_id":1,"from_socket":0,"to_id":0,"to_socket":0}]}
|
||||
+47
-2
@@ -17,6 +17,7 @@ import arm.sys.Path;
|
||||
import arm.ui.UISidebar;
|
||||
import arm.ui.UIFiles;
|
||||
import arm.ui.UIBox;
|
||||
import arm.ui.UINodes;
|
||||
import arm.data.LayerSlot;
|
||||
import arm.data.BrushSlot;
|
||||
import arm.data.MaterialSlot;
|
||||
@@ -26,6 +27,7 @@ import arm.io.ImportArm;
|
||||
import arm.io.ImportBlend;
|
||||
import arm.io.ImportMesh;
|
||||
import arm.io.ExportArm;
|
||||
import arm.node.NodesBrush;
|
||||
import arm.ProjectFormat;
|
||||
import arm.Enums;
|
||||
|
||||
@@ -251,8 +253,51 @@ class Project {
|
||||
}
|
||||
|
||||
public static function importBrush() {
|
||||
UIFiles.show("arm", false, function(path: String) {
|
||||
ImportArm.runBrush(path);
|
||||
UIFiles.show("arm," + Path.textureFormats.join(","), false, function(path: String) {
|
||||
// Create brush from texture
|
||||
if (Path.isTexture(path)) {
|
||||
// Import texture
|
||||
ImportAsset.run(path);
|
||||
var assetIndex = 0;
|
||||
for (i in 0...Project.assets.length) {
|
||||
if (Project.assets[i].file == path) {
|
||||
assetIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a new brush
|
||||
Context.brush = new BrushSlot();
|
||||
Project.brushes.push(Context.brush);
|
||||
|
||||
// Create and link image node
|
||||
var n = NodesBrush.createNode("TEX_IMAGE");
|
||||
n.x = 83;
|
||||
n.y = 340;
|
||||
n.buttons[0].default_value = assetIndex;
|
||||
var links = Context.brush.canvas.links;
|
||||
links.push({
|
||||
id: Context.brush.nodes.getLinkId(links),
|
||||
from_id: n.id,
|
||||
from_socket: 0,
|
||||
to_id: 0,
|
||||
to_socket: 4
|
||||
});
|
||||
|
||||
// Parse brush
|
||||
MaterialParser.parseBrush();
|
||||
Context.parseBrushInputs();
|
||||
UINodes.inst.hwnd.redraws = 2;
|
||||
function makeBrushPreview(_) {
|
||||
RenderUtil.makeBrushPreview();
|
||||
iron.App.removeRender(makeBrushPreview);
|
||||
}
|
||||
iron.App.notifyOnRender(makeBrushPreview);
|
||||
}
|
||||
// Import from project file
|
||||
else {
|
||||
ImportArm.runBrush(path);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user