|
@@ -3,19 +3,12 @@ using Lambda;
|
|
import hide.view.GraphInterface;
|
|
import hide.view.GraphInterface;
|
|
import hrt.animgraph.*;
|
|
import hrt.animgraph.*;
|
|
|
|
|
|
-class PreviewSettings {
|
|
|
|
- public var modelPath: String = null;
|
|
|
|
-
|
|
|
|
- public function new() {};
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
@:access(hrt.animgraph.AnimGraph)
|
|
@:access(hrt.animgraph.AnimGraph)
|
|
@:access(hrt.animgraph.AnimGraphInstance)
|
|
@:access(hrt.animgraph.AnimGraphInstance)
|
|
@:access(hrt.animgraph.Node)
|
|
@:access(hrt.animgraph.Node)
|
|
class AnimGraphEditor extends GenericGraphEditor {
|
|
class AnimGraphEditor extends GenericGraphEditor {
|
|
|
|
|
|
var animGraph : hrt.animgraph.AnimGraph;
|
|
var animGraph : hrt.animgraph.AnimGraph;
|
|
- public var previewModel : h3d.scene.Object;
|
|
|
|
public var previewPrefab : hrt.prefab.Prefab;
|
|
public var previewPrefab : hrt.prefab.Prefab;
|
|
|
|
|
|
var parametersList : hide.Element;
|
|
var parametersList : hide.Element;
|
|
@@ -24,8 +17,6 @@ class AnimGraphEditor extends GenericGraphEditor {
|
|
var previewNode : hrt.animgraph.nodes.AnimNode = null;
|
|
var previewNode : hrt.animgraph.nodes.AnimNode = null;
|
|
var queuedPreview : hrt.animgraph.nodes.AnimNode = null;
|
|
var queuedPreview : hrt.animgraph.nodes.AnimNode = null;
|
|
|
|
|
|
- var previewSettings : PreviewSettings = new PreviewSettings();
|
|
|
|
-
|
|
|
|
override function reloadView() {
|
|
override function reloadView() {
|
|
previewNode = null;
|
|
previewNode = null;
|
|
animGraph = cast hide.Ide.inst.loadPrefab(state.path, null, true);
|
|
animGraph = cast hide.Ide.inst.loadPrefab(state.path, null, true);
|
|
@@ -51,9 +42,6 @@ class AnimGraphEditor extends GenericGraphEditor {
|
|
}
|
|
}
|
|
|
|
|
|
super.reloadView();
|
|
super.reloadView();
|
|
- loadPreviewSettings();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
var parameters = new Element("<graph-parameters></graph-parameters>").appendTo(propertiesContainer);
|
|
var parameters = new Element("<graph-parameters></graph-parameters>").appendTo(propertiesContainer);
|
|
new Element("<h1>Parameters</h1>").appendTo(parameters);
|
|
new Element("<h1>Parameters</h1>").appendTo(parameters);
|
|
@@ -88,10 +76,6 @@ class AnimGraphEditor extends GenericGraphEditor {
|
|
graphEditor.opBox(inst, true, graphEditor.currentUndoBuffer);
|
|
graphEditor.opBox(inst, true, graphEditor.currentUndoBuffer);
|
|
graphEditor.commitUndo();
|
|
graphEditor.commitUndo();
|
|
});
|
|
});
|
|
-
|
|
|
|
- if (previewSettings.modelPath == null) {
|
|
|
|
- previewSettings.modelPath = gatherAllPreviewModels(animGraph.animFolder)[0];
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
static public function gatherAllPreviewModels(basePath : String) : Array<String> {
|
|
static public function gatherAllPreviewModels(basePath : String) : Array<String> {
|
|
@@ -128,9 +112,7 @@ class AnimGraphEditor extends GenericGraphEditor {
|
|
for (path in paths) {
|
|
for (path in paths) {
|
|
var basePath = StringTools.replace(path, animGraph.animFolder + "/", "");
|
|
var basePath = StringTools.replace(path, animGraph.animFolder + "/", "");
|
|
models.push({label: basePath, click: () -> {
|
|
models.push({label: basePath, click: () -> {
|
|
- previewSettings.modelPath = path;
|
|
|
|
- savePreviewSettings();
|
|
|
|
- reloadPreviewModel();
|
|
|
|
|
|
+ scenePreview.setObjectPath(path);
|
|
}});
|
|
}});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -138,11 +120,6 @@ class AnimGraphEditor extends GenericGraphEditor {
|
|
return options;
|
|
return options;
|
|
}
|
|
}
|
|
|
|
|
|
- public function setPreviewMesh(path: String) {
|
|
|
|
-
|
|
|
|
- savePreviewSettings();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public function refreshPreview() {
|
|
public function refreshPreview() {
|
|
if (previewNode != null)
|
|
if (previewNode != null)
|
|
setPreview(previewNode);
|
|
setPreview(previewNode);
|
|
@@ -157,6 +134,7 @@ class AnimGraphEditor extends GenericGraphEditor {
|
|
|
|
|
|
// refresh animation
|
|
// refresh animation
|
|
{
|
|
{
|
|
|
|
+ var previewModel = scenePreview.prefab?.find(hrt.prefab.Model, (f) -> StringTools.startsWith(f.source, animGraph.animFolder))?.local3d;
|
|
if (previewModel == null)
|
|
if (previewModel == null)
|
|
return;
|
|
return;
|
|
|
|
|
|
@@ -304,6 +282,10 @@ class AnimGraphEditor extends GenericGraphEditor {
|
|
]);
|
|
]);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ scenePreview.onObjectLoaded = () -> {
|
|
|
|
+ setPreview(cast animGraph.nodes.find((f) -> Std.downcast(f, hrt.animgraph.nodes.Output) != null));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
function execRemoveParam(index: Int) {
|
|
function execRemoveParam(index: Int) {
|
|
@@ -359,58 +341,10 @@ class AnimGraphEditor extends GenericGraphEditor {
|
|
override function onScenePreviewReady() {
|
|
override function onScenePreviewReady() {
|
|
super.onScenePreviewReady();
|
|
super.onScenePreviewReady();
|
|
|
|
|
|
- reloadPreviewModel();
|
|
|
|
- resetPreviewCamera();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function reloadPreviewModel() {
|
|
|
|
- if (previewModel != null) {
|
|
|
|
- previewModel.remove();
|
|
|
|
- previewModel = null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (previewPrefab != null) {
|
|
|
|
- previewPrefab.dispose();
|
|
|
|
- previewPrefab.shared.root3d?.remove();
|
|
|
|
- previewPrefab.shared.root2d?.remove();
|
|
|
|
- previewPrefab = null;
|
|
|
|
|
|
+ if (scenePreview.getObjectPath() == null) {
|
|
|
|
+ scenePreview.setObjectPath(gatherAllPreviewModels(animGraph.animFolder)[0]);
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (previewSettings.modelPath == null)
|
|
|
|
- return;
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- if (StringTools.endsWith(previewSettings.modelPath, ".prefab")) {
|
|
|
|
- try {
|
|
|
|
- previewPrefab = Ide.inst.loadPrefab(previewSettings.modelPath);
|
|
|
|
- } catch (e) {
|
|
|
|
- throw 'Could not load mesh ${previewSettings.modelPath}, error : $e';
|
|
|
|
- }
|
|
|
|
- var ctx = new hide.prefab.ContextShared(null, new h3d.scene.Object(scenePreview.s3d));
|
|
|
|
- ctx.scene = scenePreview;
|
|
|
|
- previewPrefab.setSharedRec(ctx);
|
|
|
|
- previewPrefab = previewPrefab.make();
|
|
|
|
-
|
|
|
|
- previewModel = previewPrefab.find(hrt.prefab.Model, (m) -> StringTools.startsWith(m.source, animGraph.animFolder))?.local3d;
|
|
|
|
- if (previewModel == null) {
|
|
|
|
- throw "Linked prefab doesn't contain any suitable model";
|
|
|
|
- }
|
|
|
|
- } else if (StringTools.endsWith(previewSettings.modelPath, ".fbx")) {
|
|
|
|
- previewModel = scenePreview.loadModel(previewSettings.modelPath);
|
|
|
|
- scenePreview.s3d.addChild(previewModel);
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- throw "Unsupported model format";
|
|
|
|
- }
|
|
|
|
- } catch (e) {
|
|
|
|
- previewSettings.modelPath = null;
|
|
|
|
- ide.quickError("Couldn't load preview : " + e);
|
|
|
|
- savePreviewSettings();
|
|
|
|
- reloadPreviewModel(); // cleanup
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- setPreview(cast animGraph.nodes.find((f) -> Std.downcast(f, hrt.animgraph.nodes.Output) != null));
|
|
|
|
|
|
+ scenePreview.resetCamera();
|
|
}
|
|
}
|
|
|
|
|
|
override function getNodes() : Iterator<IGraphNode> {
|
|
override function getNodes() : Iterator<IGraphNode> {
|
|
@@ -542,25 +476,6 @@ class AnimGraphEditor extends GenericGraphEditor {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- function resetPreviewCamera() {
|
|
|
|
- previewFocusObject(previewModel);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function loadPreviewSettings() {
|
|
|
|
- var save = haxe.Json.parse(getDisplayState("previewSettings") ?? "{}");
|
|
|
|
- previewSettings = new PreviewSettings();
|
|
|
|
- for (f in Reflect.fields(previewSettings)) {
|
|
|
|
- var v = Reflect.field(save, f);
|
|
|
|
- if (v != null) {
|
|
|
|
- Reflect.setField(previewSettings, f, v);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function savePreviewSettings() {
|
|
|
|
- saveDisplayState("previewSettings", haxe.Json.stringify(previewSettings));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
function addParameter() {
|
|
function addParameter() {
|
|
var newParam = new hrt.animgraph.AnimGraph.Parameter();
|
|
var newParam = new hrt.animgraph.AnimGraph.Parameter();
|
|
newParam.name = "New Parameter";
|
|
newParam.name = "New Parameter";
|