|
@@ -1,4 +1,5 @@
|
|
package hide.view;
|
|
package hide.view;
|
|
|
|
+import hide.view.FileTree;
|
|
import hrt.prefab.Light;
|
|
import hrt.prefab.Light;
|
|
using Lambda;
|
|
using Lambda;
|
|
|
|
|
|
@@ -23,8 +24,8 @@ typedef Section = {
|
|
@:access(hide.view.FXEditor)
|
|
@:access(hide.view.FXEditor)
|
|
class FXEditContext extends hide.prefab.EditContext {
|
|
class FXEditContext extends hide.prefab.EditContext {
|
|
var parent : FXEditor;
|
|
var parent : FXEditor;
|
|
- public function new(parent, context) {
|
|
|
|
- super(context);
|
|
|
|
|
|
+ public function new(parent) {
|
|
|
|
+ super();
|
|
this.parent = parent;
|
|
this.parent = parent;
|
|
}
|
|
}
|
|
override function onChange(p, propName) {
|
|
override function onChange(p, propName) {
|
|
@@ -58,8 +59,7 @@ private class FXSceneEditor extends hide.comp.SceneEditor {
|
|
}
|
|
}
|
|
|
|
|
|
override function duplicate(thenMove : Bool) {
|
|
override function duplicate(thenMove : Bool) {
|
|
- if(curEdit == null) return;
|
|
|
|
- var elements = curEdit.rootElements;
|
|
|
|
|
|
+ var elements = selectedPrefabs;
|
|
if(elements == null || elements.length == 0)
|
|
if(elements == null || elements.length == 0)
|
|
return;
|
|
return;
|
|
if( isDuplicating )
|
|
if( isDuplicating )
|
|
@@ -71,13 +71,16 @@ private class FXSceneEditor extends hide.comp.SceneEditor {
|
|
var undoes = [];
|
|
var undoes = [];
|
|
var newElements = [];
|
|
var newElements = [];
|
|
for(elt in elements) {
|
|
for(elt in elements) {
|
|
- var clone = elt.cloneData();
|
|
|
|
|
|
+ var clone = elt.clone(elt.parent, null);
|
|
var index = elt.parent.children.indexOf(elt) + 1;
|
|
var index = elt.parent.children.indexOf(elt) + 1;
|
|
- clone.parent = elt.parent;
|
|
|
|
elt.parent.children.remove(clone);
|
|
elt.parent.children.remove(clone);
|
|
elt.parent.children.insert(index, clone);
|
|
elt.parent.children.insert(index, clone);
|
|
|
|
+
|
|
|
|
+ clone.shared.current2d = elt.parent.findFirstLocal2d();
|
|
|
|
+ clone.shared.current3d = elt.parent.findFirstLocal3d();
|
|
|
|
+ clone.make();
|
|
|
|
+
|
|
autoName(clone);
|
|
autoName(clone);
|
|
- makeInstance(clone);
|
|
|
|
newElements.push(clone);
|
|
newElements.push(clone);
|
|
|
|
|
|
undoes.push(function(undo) {
|
|
undoes.push(function(undo) {
|
|
@@ -104,10 +107,7 @@ private class FXSceneEditor extends hide.comp.SceneEditor {
|
|
var fullRefresh = false;
|
|
var fullRefresh = false;
|
|
if(undo) {
|
|
if(undo) {
|
|
for(elt in newElements) {
|
|
for(elt in newElements) {
|
|
- if(!removeInstance(elt)) {
|
|
|
|
- fullRefresh = true;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ removeInstance(elt);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -115,7 +115,7 @@ private class FXSceneEditor extends hide.comp.SceneEditor {
|
|
|
|
|
|
if(!undo) {
|
|
if(!undo) {
|
|
for(elt in newElements)
|
|
for(elt in newElements)
|
|
- makeInstance(elt);
|
|
|
|
|
|
+ makePrefab(elt);
|
|
}
|
|
}
|
|
|
|
|
|
refresh(fullRefresh ? Full : Partial);
|
|
refresh(fullRefresh ? Full : Partial);
|
|
@@ -123,10 +123,10 @@ private class FXSceneEditor extends hide.comp.SceneEditor {
|
|
}
|
|
}
|
|
|
|
|
|
override function createDroppedElement(path:String, parent:PrefabElement):hrt.prefab.Object3D {
|
|
override function createDroppedElement(path:String, parent:PrefabElement):hrt.prefab.Object3D {
|
|
- var type = hrt.prefab.Library.getPrefabType(path);
|
|
|
|
|
|
+ var type = hrt.prefab.Prefab.getPrefabType(path);
|
|
if(type == "fx") {
|
|
if(type == "fx") {
|
|
var relative = ide.makeRelative(path);
|
|
var relative = ide.makeRelative(path);
|
|
- var ref = new hrt.prefab.fx.SubFX(parent);
|
|
|
|
|
|
+ var ref = new hrt.prefab.fx.SubFX(parent, null);
|
|
ref.source = relative;
|
|
ref.source = relative;
|
|
ref.name = new haxe.io.Path(relative).file;
|
|
ref.name = new haxe.io.Path(relative).file;
|
|
return ref;
|
|
return ref;
|
|
@@ -134,10 +134,10 @@ private class FXSceneEditor extends hide.comp.SceneEditor {
|
|
return super.createDroppedElement(path, parent);
|
|
return super.createDroppedElement(path, parent);
|
|
}
|
|
}
|
|
|
|
|
|
- override function setElementSelected( p : PrefabElement, ctx : hrt.prefab.Context, b : Bool ) {
|
|
|
|
- if( p.getParent(hrt.prefab.fx.Emitter) != null )
|
|
|
|
|
|
+ override function setElementSelected( p : PrefabElement, b : Bool ) {
|
|
|
|
+ if( p.findParent(hrt.prefab.fx.Emitter) != null )
|
|
return false;
|
|
return false;
|
|
- return super.setElementSelected(p, ctx, b);
|
|
|
|
|
|
+ return super.setElementSelected(p, b);
|
|
}
|
|
}
|
|
|
|
|
|
override function selectElements( elts, ?mode ) {
|
|
override function selectElements( elts, ?mode ) {
|
|
@@ -258,7 +258,7 @@ private class FXSceneEditor extends hide.comp.SceneEditor {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-class FXEditor extends FileView {
|
|
|
|
|
|
+class FXEditor extends hide.view.FileView {
|
|
|
|
|
|
var sceneEditor : FXSceneEditor;
|
|
var sceneEditor : FXSceneEditor;
|
|
var data : hrt.prefab.fx.BaseFX;
|
|
var data : hrt.prefab.fx.BaseFX;
|
|
@@ -302,13 +302,13 @@ class FXEditor extends FileView {
|
|
var statusText : h2d.Text;
|
|
var statusText : h2d.Text;
|
|
|
|
|
|
var scriptEditor : hide.comp.ScriptEditor;
|
|
var scriptEditor : hide.comp.ScriptEditor;
|
|
- var fxScriptParser : hrt.prefab.fx.FXScriptParser;
|
|
|
|
|
|
+ //var fxScriptParser : hrt.prefab.fx.FXScriptParser;
|
|
var cullingPreview : h3d.scene.Sphere;
|
|
var cullingPreview : h3d.scene.Sphere;
|
|
|
|
|
|
- var viewModes : Array<String>;
|
|
|
|
|
|
+ var viewModes : Array<String>;
|
|
|
|
|
|
override function getDefaultContent() {
|
|
override function getDefaultContent() {
|
|
- return haxe.io.Bytes.ofString(ide.toJSON(new hrt.prefab.fx.FX().saveData()));
|
|
|
|
|
|
+ @:privateAccess return haxe.io.Bytes.ofString(ide.toJSON(new hrt.prefab.fx.FX(null, null).serialize()));
|
|
}
|
|
}
|
|
|
|
|
|
override function canSave() {
|
|
override function canSave() {
|
|
@@ -318,7 +318,7 @@ class FXEditor extends FileView {
|
|
override function save() {
|
|
override function save() {
|
|
if( !canSave() )
|
|
if( !canSave() )
|
|
return;
|
|
return;
|
|
- var content = ide.toJSON(data.saveData());
|
|
|
|
|
|
+ @:privateAccess var content = ide.toJSON(cast(data, hrt.prefab.Prefab).serialize());
|
|
var newSign = ide.makeSignature(content);
|
|
var newSign = ide.makeSignature(content);
|
|
if(newSign != currentSign)
|
|
if(newSign != currentSign)
|
|
haxe.Timer.delay(saveBackup.bind(content), 0);
|
|
haxe.Timer.delay(saveBackup.bind(content), 0);
|
|
@@ -333,17 +333,8 @@ class FXEditor extends FileView {
|
|
xOffset = -timelineLeftMargin / xScale;
|
|
xOffset = -timelineLeftMargin / xScale;
|
|
var content = sys.io.File.getContent(getPath());
|
|
var content = sys.io.File.getContent(getPath());
|
|
var json = haxe.Json.parse(content);
|
|
var json = haxe.Json.parse(content);
|
|
- if (json.type == "fx") {
|
|
|
|
- var inf = hrt.prefab.Library.getRegistered().get("fx");
|
|
|
|
- data = Std.downcast(Type.createInstance(inf.cl, null), hrt.prefab.fx.FX);
|
|
|
|
- if ( data == null )
|
|
|
|
- throw "fx prefab override failed";
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- is2D = true;
|
|
|
|
- data = new hrt.prefab.fx.FX2D();
|
|
|
|
- }
|
|
|
|
- data.loadData(json);
|
|
|
|
|
|
+
|
|
|
|
+ data = cast(PrefabElement.createFromDynamic(json), hrt.prefab.fx.BaseFX);
|
|
currentSign = ide.makeSignature(content);
|
|
currentSign = ide.makeSignature(content);
|
|
|
|
|
|
element.html('
|
|
element.html('
|
|
@@ -389,7 +380,7 @@ class FXEditor extends FileView {
|
|
</div>');
|
|
</div>');
|
|
tools = new hide.comp.Toolbar(null,element.find(".tools-buttons"));
|
|
tools = new hide.comp.Toolbar(null,element.find(".tools-buttons"));
|
|
var tabs = new hide.comp.Tabs(null,element.find(".tabs"));
|
|
var tabs = new hide.comp.Tabs(null,element.find(".tabs"));
|
|
- sceneEditor = new FXSceneEditor(this, data);
|
|
|
|
|
|
+ sceneEditor = new FXSceneEditor(this, cast(data, hrt.prefab.Prefab));
|
|
element.find(".hide-scenetree").first().append(sceneEditor.tree.element);
|
|
element.find(".hide-scenetree").first().append(sceneEditor.tree.element);
|
|
element.find(".hide-scroll").first().append(sceneEditor.properties.element);
|
|
element.find(".hide-scroll").first().append(sceneEditor.properties.element);
|
|
element.find(".heaps-scene").first().append(sceneEditor.scene.element);
|
|
element.find(".heaps-scene").first().append(sceneEditor.scene.element);
|
|
@@ -443,11 +434,11 @@ class FXEditor extends FileView {
|
|
});
|
|
});
|
|
var fxprops = new hide.comp.PropsEditor(undo,null,element.find(".fx-props"));
|
|
var fxprops = new hide.comp.PropsEditor(undo,null,element.find(".fx-props"));
|
|
{
|
|
{
|
|
- var edit = new FXEditContext(this, sceneEditor.context);
|
|
|
|
|
|
+ var edit = new FXEditContext(this);
|
|
edit.properties = fxprops;
|
|
edit.properties = fxprops;
|
|
edit.scene = sceneEditor.scene;
|
|
edit.scene = sceneEditor.scene;
|
|
edit.cleanups = [];
|
|
edit.cleanups = [];
|
|
- data.edit(edit);
|
|
|
|
|
|
+ cast(data, hrt.prefab.Prefab).edit(edit);
|
|
}
|
|
}
|
|
|
|
|
|
if (is2D) {
|
|
if (is2D) {
|
|
@@ -463,7 +454,7 @@ class FXEditor extends FileView {
|
|
modified = false;
|
|
modified = false;
|
|
}
|
|
}
|
|
scriptEditor.onSave = onSaveScript;
|
|
scriptEditor.onSave = onSaveScript;
|
|
- fxScriptParser = new hrt.prefab.fx.FXScriptParser();
|
|
|
|
|
|
+ //fxScriptParser = new hrt.prefab.fx.FXScriptParser();
|
|
data.scriptCode = scriptEditor.code;
|
|
data.scriptCode = scriptEditor.code;
|
|
|
|
|
|
keys.register("playPause", function() { pauseButton.toggle(!pauseButton.isDown()); });
|
|
keys.register("playPause", function() { pauseButton.toggle(!pauseButton.isDown()); });
|
|
@@ -488,7 +479,6 @@ class FXEditor extends FileView {
|
|
if (tools != null)
|
|
if (tools != null)
|
|
tools.refreshToggles();
|
|
tools.refreshToggles();
|
|
}
|
|
}
|
|
-
|
|
|
|
public function onSceneReady() {
|
|
public function onSceneReady() {
|
|
light = sceneEditor.scene.s3d.find(function(o) return Std.downcast(o, h3d.scene.fwd.DirLight));
|
|
light = sceneEditor.scene.s3d.find(function(o) return Std.downcast(o, h3d.scene.fwd.DirLight));
|
|
if( light == null ) {
|
|
if( light == null ) {
|
|
@@ -521,6 +511,11 @@ class FXEditor extends FileView {
|
|
|
|
|
|
toolsDefs.push({id: "", title : "", icon : "", type : Separator});
|
|
toolsDefs.push({id: "", title : "", icon : "", type : Separator});
|
|
|
|
|
|
|
|
+ toolsDefs.push({id: "toggleSnap", title : "Snap Toggle", icon: "magnet", type : Toggle((v) -> {sceneEditor.snapToggle = v; sceneEditor.updateGrid();})});
|
|
|
|
+ toolsDefs.push({id: "snap-menu", title : "", icon: "", type : Popup((e) -> new hide.comp.SceneEditor.SnapSettingsPopup(null, e, sceneEditor))});
|
|
|
|
+
|
|
|
|
+ toolsDefs.push({id: "", title : "", icon : "", type : Separator});
|
|
|
|
+
|
|
toolsDefs.push({id: "localTransformsToggle", title : "Local transforms", icon : "compass", type : Toggle((v) -> sceneEditor.localTransform = v)});
|
|
toolsDefs.push({id: "localTransformsToggle", title : "Local transforms", icon : "compass", type : Toggle((v) -> sceneEditor.localTransform = v)});
|
|
|
|
|
|
toolsDefs.push({id: "", title : "", icon : "", type : Separator});
|
|
toolsDefs.push({id: "", title : "", icon : "", type : Separator});
|
|
@@ -569,6 +564,7 @@ class FXEditor extends FileView {
|
|
updateGrid();
|
|
updateGrid();
|
|
}, scene.engine.backgroundColor);
|
|
}, scene.engine.backgroundColor);
|
|
|
|
|
|
|
|
+
|
|
tools.addSeparator();
|
|
tools.addSeparator();
|
|
|
|
|
|
tools.addPopup(null, "View Modes", (e) -> new hide.comp.SceneEditor.ViewModePopup(null, e, Std.downcast(@:privateAccess scene.s3d.renderer, h3d.scene.pbr.Renderer), sceneEditor), null);
|
|
tools.addPopup(null, "View Modes", (e) -> new hide.comp.SceneEditor.ViewModePopup(null, e, Std.downcast(@:privateAccess scene.s3d.renderer, h3d.scene.pbr.Renderer), sceneEditor), null);
|
|
@@ -577,6 +573,7 @@ class FXEditor extends FileView {
|
|
|
|
|
|
tools.addPopup(null, "Render Props", (e) -> new hide.comp.SceneEditor.RenderPropsPopup(null, e, this, sceneEditor, true), null);
|
|
tools.addPopup(null, "Render Props", (e) -> new hide.comp.SceneEditor.RenderPropsPopup(null, e, this, sceneEditor, true), null);
|
|
|
|
|
|
|
|
+
|
|
tools.addSeparator();
|
|
tools.addSeparator();
|
|
|
|
|
|
|
|
|
|
@@ -585,6 +582,8 @@ class FXEditor extends FileView {
|
|
scene.speed = v;
|
|
scene.speed = v;
|
|
}, scene.speed);
|
|
}, scene.speed);
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
var gizmo = @:privateAccess sceneEditor.gizmo;
|
|
var gizmo = @:privateAccess sceneEditor.gizmo;
|
|
|
|
|
|
var onSetGizmoMode = function(mode: hide.view.l3d.Gizmo.EditMode) {
|
|
var onSetGizmoMode = function(mode: hide.view.l3d.Gizmo.EditMode) {
|
|
@@ -604,8 +603,128 @@ class FXEditor extends FileView {
|
|
updateGrid();
|
|
updateGrid();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // public function onSceneReady() {
|
|
|
|
+ // light = sceneEditor.scene.s3d.find(function(o) return Std.downcast(o, h3d.scene.fwd.DirLight));
|
|
|
|
+ // if( light == null ) {
|
|
|
|
+ // light = new h3d.scene.fwd.DirLight(scene.s3d);
|
|
|
|
+ // light.enableSpecular = true;
|
|
|
|
+ // } else
|
|
|
|
+ // light = null;
|
|
|
|
+
|
|
|
|
+ // var axis = new h3d.scene.Graphics(scene.s3d);
|
|
|
|
+ // axis.z = 0.001;
|
|
|
|
+ // axis.lineStyle(2,0xFF0000); axis.lineTo(1,0,0);
|
|
|
|
+ // axis.lineStyle(1,0x00FF00); axis.moveTo(0,0,0); axis.lineTo(0,1,0);
|
|
|
|
+ // axis.lineStyle(1,0x0000FF); axis.moveTo(0,0,0); axis.lineTo(0,0,1);
|
|
|
|
+ // axis.lineStyle();
|
|
|
|
+ // axis.material.mainPass.setPassName("debuggeom");
|
|
|
|
+ // axis.visible = (!is2D) ? showGrid : false;
|
|
|
|
+
|
|
|
|
+ // cullingPreview = new h3d.scene.Sphere(0xffffff, data.cullingRadius, true, scene.s3d);
|
|
|
|
+ // cullingPreview.visible = (!is2D) ? showGrid : false;
|
|
|
|
+
|
|
|
|
+ // tools.saveDisplayKey = "FXScene/tools";
|
|
|
|
+ // tools.addButton("video-camera", "Perspective camera", () -> sceneEditor.resetCamera());
|
|
|
|
+ // tools.addButton("arrows", "Gizmo translation Mode", @:privateAccess sceneEditor.gizmo.translationMode, () -> {
|
|
|
|
+ // var items = [{
|
|
|
|
+ // label : "Snap to Grid",
|
|
|
|
+ // click : function() {
|
|
|
|
+ // @:privateAccess sceneEditor.gizmo.snapToGrid = !sceneEditor.gizmo.snapToGrid;
|
|
|
|
+ // },
|
|
|
|
+ // checked: @:privateAccess sceneEditor.gizmo.snapToGrid
|
|
|
|
+ // }];
|
|
|
|
+ // var steps : Array<Float> = sceneEditor.view.config.get("sceneeditor.gridSnapSteps");
|
|
|
|
+ // for (step in steps) {
|
|
|
|
+ // items.push({
|
|
|
|
+ // label : ""+step,
|
|
|
|
+ // click : function() {
|
|
|
|
+ // @:privateAccess sceneEditor.gizmo.moveStep = step;
|
|
|
|
+ // },
|
|
|
|
+ // checked: @:privateAccess sceneEditor.gizmo.moveStep == step
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+ // new hide.comp.ContextMenu(items);
|
|
|
|
+ // });
|
|
|
|
+ // tools.addButton("undo", "Gizmo rotation Mode", @:privateAccess sceneEditor.gizmo.rotationMode, () -> {
|
|
|
|
+ // var steps : Array<Float> = sceneEditor.view.config.get("sceneeditor.rotateStepCoarses");
|
|
|
|
+ // var items = [{
|
|
|
|
+ // label : "Snap enabled",
|
|
|
|
+ // click : function() {
|
|
|
|
+ // @:privateAccess sceneEditor.gizmo.rotateSnap = !sceneEditor.gizmo.rotateSnap;
|
|
|
|
+ // },
|
|
|
|
+ // checked: @:privateAccess sceneEditor.gizmo.rotateSnap
|
|
|
|
+ // }];
|
|
|
|
+ // for (step in steps) {
|
|
|
|
+ // items.push({
|
|
|
|
+ // label : ""+step+"°",
|
|
|
|
+ // click : function() {
|
|
|
|
+ // @:privateAccess sceneEditor.gizmo.rotateStepCoarse = step;
|
|
|
|
+ // },
|
|
|
|
+ // checked: @:privateAccess sceneEditor.gizmo.rotateStepCoarse == step
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+ // new hide.comp.ContextMenu(items);
|
|
|
|
+ // });
|
|
|
|
+ // tools.addButton("compress", "Gizmo scaling Mode", @:privateAccess sceneEditor.gizmo.scalingMode);
|
|
|
|
+
|
|
|
|
+ // function renderProps() {
|
|
|
|
+ // properties.clear();
|
|
|
|
+ // var renderer = scene.s3d.renderer;
|
|
|
|
+ // var group = new Element('<div class="group" name="Renderer"></div>');
|
|
|
|
+ // renderer.editProps().appendTo(group);
|
|
|
|
+ // properties.add(group, renderer.props, function(_) {
|
|
|
|
+ // renderer.refreshProps();
|
|
|
|
+ // if( !properties.isTempChange ) renderProps();
|
|
|
|
+ // });
|
|
|
|
+ // var lprops = {
|
|
|
|
+ // power : Math.sqrt(light.color.r),
|
|
|
|
+ // enable: true
|
|
|
|
+ // };
|
|
|
|
+ // var group = new Element('<div class="group" name="Light">
|
|
|
|
+ // <dl>
|
|
|
|
+ // <dt>Power</dt><dd><input type="range" min="0" max="4" field="power"/></dd>
|
|
|
|
+ // </dl>
|
|
|
|
+ // </div>');
|
|
|
|
+ // properties.add(group, lprops, function(_) {
|
|
|
|
+ // var p = lprops.power * lprops.power;
|
|
|
|
+ // light.color.set(p, p, p);
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+ // tools.addButton("gears", "Renderer Properties", renderProps);
|
|
|
|
+
|
|
|
|
+ // tools.addToggle("th", "Show grid", function(v) {
|
|
|
|
+ // showGrid = v;
|
|
|
|
+ // axis.visible = (is2D) ? false : v;
|
|
|
|
+ // cullingPreview.visible = (is2D) ? false : v;
|
|
|
|
+ // updateGrid();
|
|
|
|
+ // }, showGrid);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // tools.addToggle("cube", "Toggle model axis", null, (v) -> { sceneEditor.showBasis = v; sceneEditor.updateBasis(); });
|
|
|
|
+
|
|
|
|
+ // tools.addToggle("image", "Toggle 3d icons visibility", null, function(v) { hide.Ide.inst.show3DIcons = v; }, true);
|
|
|
|
+ // tools.addColor("Background color", function(v) {
|
|
|
|
+ // scene.engine.backgroundColor = v;
|
|
|
|
+ // updateGrid();
|
|
|
|
+ // }, scene.engine.backgroundColor);
|
|
|
|
+ // tools.addToggle("refresh", "Auto synchronize", function(b) {
|
|
|
|
+ // autoSync = b;
|
|
|
|
+ // });
|
|
|
|
+ // tools.addToggle("compass", "Local transforms", (v) -> sceneEditor.localTransform = v, sceneEditor.localTransform);
|
|
|
|
+ // tools.addToggle("connectdevelop", "Wireframe",(b) -> { sceneEditor.setWireframe(b); });
|
|
|
|
+ // pauseButton = tools.addToggle("pause", "Pause animation", function(v) {}, false);
|
|
|
|
+ // tools.addRange("Speed", function(v) {
|
|
|
|
+ // scene.speed = v;
|
|
|
|
+ // }, scene.speed);
|
|
|
|
+
|
|
|
|
+ // statusText = new h2d.Text(hxd.res.DefaultFont.get(), scene.s2d);
|
|
|
|
+ // statusText.setPosition(5, 5);
|
|
|
|
+
|
|
|
|
+ // updateGrid();
|
|
|
|
+ // }
|
|
|
|
+
|
|
function onPrefabChange(p: PrefabElement, ?pname: String) {
|
|
function onPrefabChange(p: PrefabElement, ?pname: String) {
|
|
- if(p == data) {
|
|
|
|
|
|
+ if(p == cast(data, hrt.prefab.Prefab)) {
|
|
if (this.curveEditor != null) {
|
|
if (this.curveEditor != null) {
|
|
previewMax = data.duration == 0 ? 5000 : data.duration;
|
|
previewMax = data.duration == 0 ? 5000 : data.duration;
|
|
this.curveEditor.refreshTimeline(currentTime);
|
|
this.curveEditor.refreshTimeline(currentTime);
|
|
@@ -630,7 +749,7 @@ class FXEditor extends FileView {
|
|
|
|
|
|
while (toRemove.length > 0) {
|
|
while (toRemove.length > 0) {
|
|
var c = toRemove.pop();
|
|
var c = toRemove.pop();
|
|
- c.removeInstance(sceneEditor.context);
|
|
|
|
|
|
+ //c.removeInstance();
|
|
c.parent.children.remove(c);
|
|
c.parent.children.remove(c);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -642,7 +761,7 @@ class FXEditor extends FileView {
|
|
|
|
|
|
// We're currently supporting blending with only 2 curves
|
|
// We're currently supporting blending with only 2 curves
|
|
for (i in 0...2) {
|
|
for (i in 0...2) {
|
|
- var c = new Curve();
|
|
|
|
|
|
+ var c = new Curve(null, null);
|
|
c.parent = curve;
|
|
c.parent = curve;
|
|
c.name = '${curve.name}.${i}';
|
|
c.name = '${curve.name}.${i}';
|
|
}
|
|
}
|
|
@@ -659,7 +778,7 @@ class FXEditor extends FileView {
|
|
|
|
|
|
if(pname == "time" || pname == "loop" || pname == "animation" || pname == "blendMode" || pname == "blendFactor") {
|
|
if(pname == "time" || pname == "loop" || pname == "animation" || pname == "blendMode" || pname == "blendFactor") {
|
|
afterPan(false);
|
|
afterPan(false);
|
|
- data.refreshObjectAnims(sceneEditor.getContext(data));
|
|
|
|
|
|
+ data.refreshObjectAnims();
|
|
}
|
|
}
|
|
|
|
|
|
if (pname == "loop") {
|
|
if (pname == "loop") {
|
|
@@ -674,7 +793,7 @@ class FXEditor extends FileView {
|
|
}
|
|
}
|
|
|
|
|
|
function onRefreshScene() {
|
|
function onRefreshScene() {
|
|
- var renderProps = data.find(e -> e.to(hrt.prefab.RenderProps));
|
|
|
|
|
|
+ var renderProps = cast(data, hrt.prefab.Prefab).find(hrt.prefab.RenderProps);
|
|
if(renderProps != null)
|
|
if(renderProps != null)
|
|
renderProps.applyProps(scene.s3d.renderer);
|
|
renderProps.applyProps(scene.s3d.renderer);
|
|
updateGrid();
|
|
updateGrid();
|
|
@@ -718,7 +837,6 @@ class FXEditor extends FileView {
|
|
|
|
|
|
var minHeight = 40;
|
|
var minHeight = 40;
|
|
var curveEditorHeight = 100;
|
|
var curveEditorHeight = 100;
|
|
- var ctx = sceneEditor.getContext(data);
|
|
|
|
|
|
|
|
for (curve in curves){
|
|
for (curve in curves){
|
|
var dispKey = getPath() + "/" + curve.getAbsPath(true);
|
|
var dispKey = getPath() + "/" + curve.getAbsPath(true);
|
|
@@ -746,7 +864,7 @@ class FXEditor extends FileView {
|
|
}
|
|
}
|
|
var shader = curve.parent.to(hrt.prefab.Shader);
|
|
var shader = curve.parent.to(hrt.prefab.Shader);
|
|
if(shader != null) {
|
|
if(shader != null) {
|
|
- var sh = shader.getShaderDefinition(ctx);
|
|
|
|
|
|
+ var sh = shader.getShaderDefinition();
|
|
if(sh != null) {
|
|
if(sh != null) {
|
|
var v = sh.data.vars.find(v -> v.kind == Param && v.name == curve.name);
|
|
var v = sh.data.vars.find(v -> v.kind == Param && v.name == curve.name);
|
|
if(v != null && v.qualifiers != null) {
|
|
if(v != null && v.qualifiers != null) {
|
|
@@ -1250,7 +1368,7 @@ class FXEditor extends FileView {
|
|
var id = prefix != null ? prefix + "." + prop.name : prop.name;
|
|
var id = prefix != null ? prefix + "." + prop.name : prop.name;
|
|
if(Curve.getCurve(element, id) != null)
|
|
if(Curve.getCurve(element, id) != null)
|
|
continue;
|
|
continue;
|
|
- var curve = new Curve(element);
|
|
|
|
|
|
+ var curve = new Curve(element,null);
|
|
curve.name = id;
|
|
curve.name = id;
|
|
if(prop.def != null)
|
|
if(prop.def != null)
|
|
curve.addKey(0, prop.def, Linear);
|
|
curve.addKey(0, prop.def, Linear);
|
|
@@ -1280,6 +1398,7 @@ class FXEditor extends FileView {
|
|
var obj2dElt = Std.downcast(elt, hrt.prefab.Object2D);
|
|
var obj2dElt = Std.downcast(elt, hrt.prefab.Object2D);
|
|
var shaderElt = Std.downcast(elt, hrt.prefab.Shader);
|
|
var shaderElt = Std.downcast(elt, hrt.prefab.Shader);
|
|
var emitterElt = Std.downcast(elt, hrt.prefab.fx.Emitter);
|
|
var emitterElt = Std.downcast(elt, hrt.prefab.fx.Emitter);
|
|
|
|
+
|
|
var particle2dElt = Std.downcast(elt, hrt.prefab.l2d.Particle2D);
|
|
var particle2dElt = Std.downcast(elt, hrt.prefab.l2d.Particle2D);
|
|
var menuItems : Array<hide.comp.ContextMenu.ContextMenuItem> = [];
|
|
var menuItems : Array<hide.comp.ContextMenu.ContextMenuItem> = [];
|
|
var lightElt = Std.downcast(elt, Light);
|
|
var lightElt = Std.downcast(elt, Light);
|
|
@@ -1364,7 +1483,7 @@ class FXEditor extends FileView {
|
|
}
|
|
}
|
|
if(shaderElt != null) {
|
|
if(shaderElt != null) {
|
|
var shader = shaderElt.makeShader();
|
|
var shader = shaderElt.makeShader();
|
|
- var inEmitter = shaderElt.getParent(hrt.prefab.fx.Emitter) != null;
|
|
|
|
|
|
+ var inEmitter = shaderElt.findParent(hrt.prefab.fx.Emitter) != null;
|
|
var params = shader == null ? [] : @:privateAccess shader.shader.data.vars.filter(v -> v.kind == Param);
|
|
var params = shader == null ? [] : @:privateAccess shader.shader.data.vars.filter(v -> v.kind == Param);
|
|
for(param in params) {
|
|
for(param in params) {
|
|
if (param.qualifiers?.contains(Ignore) ?? false)
|
|
if (param.qualifiers?.contains(Ignore) ?? false)
|
|
@@ -1417,6 +1536,7 @@ class FXEditor extends FileView {
|
|
addParam(param, "Instance ");
|
|
addParam(param, "Instance ");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
if (particle2dElt != null) {
|
|
if (particle2dElt != null) {
|
|
for(param in hrt.prefab.l2d.Particle2D.emitter2dParams) {
|
|
for(param in hrt.prefab.l2d.Particle2D.emitter2dParams) {
|
|
if(!param.animate)
|
|
if(!param.animate)
|
|
@@ -1424,6 +1544,7 @@ class FXEditor extends FileView {
|
|
addParam(param, "");
|
|
addParam(param, "");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
if( lightElt != null ) {
|
|
if( lightElt != null ) {
|
|
switch lightElt.kind {
|
|
switch lightElt.kind {
|
|
case Point:
|
|
case Point:
|
|
@@ -1492,7 +1613,7 @@ class FXEditor extends FileView {
|
|
return;
|
|
return;
|
|
|
|
|
|
if (is2D) {
|
|
if (is2D) {
|
|
- grid2d = new h2d.Graphics(scene.editor.context.local2d);
|
|
|
|
|
|
+ grid2d = new h2d.Graphics(scene.s2d);
|
|
grid2d.scale(1);
|
|
grid2d.scale(1);
|
|
|
|
|
|
grid2d.lineStyle(1.0, 12632256, 1.0);
|
|
grid2d.lineStyle(1.0, 12632256, 1.0);
|
|
@@ -1536,11 +1657,9 @@ class FXEditor extends FileView {
|
|
}
|
|
}
|
|
|
|
|
|
function onUpdate2D(dt:Float) {
|
|
function onUpdate2D(dt:Float) {
|
|
- var anim : hrt.prefab.fx.FX2D.FX2DAnimation = null;
|
|
|
|
- var ctx = sceneEditor.getContext(data);
|
|
|
|
- if(ctx != null && ctx.local2d != null) {
|
|
|
|
- anim = Std.downcast(ctx.local2d, hrt.prefab.fx.FX2D.FX2DAnimation);
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ var anim = Std.downcast(sceneEditor.root2d, hrt.prefab.fx.FX2D.FX2DAnimation);
|
|
|
|
+
|
|
if(!pauseButton.isDown()) {
|
|
if(!pauseButton.isDown()) {
|
|
currentTime += scene.speed * dt;
|
|
currentTime += scene.speed * dt;
|
|
if(this.curveEditor != null) {
|
|
if(this.curveEditor != null) {
|
|
@@ -1577,7 +1696,6 @@ class FXEditor extends FileView {
|
|
@:privateAccess grid2d.setPosition(scene.s2d.children[0].x, scene.s2d.children[0].y);
|
|
@:privateAccess grid2d.setPosition(scene.s2d.children[0].x, scene.s2d.children[0].y);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
var avg_smooth = 0.0;
|
|
var avg_smooth = 0.0;
|
|
@@ -1635,11 +1753,11 @@ class FXEditor extends FileView {
|
|
}
|
|
}
|
|
|
|
|
|
function onUpdate3D(dt:Float) {
|
|
function onUpdate3D(dt:Float) {
|
|
- var ctx = sceneEditor.getContext(data);
|
|
|
|
- if(ctx == null || ctx.local3d == null)
|
|
|
|
|
|
+ var local3d = sceneEditor.root3d;
|
|
|
|
+ if(local3d == null)
|
|
return;
|
|
return;
|
|
|
|
|
|
- var allFx = ctx.local3d.findAll(o -> Std.downcast(o, hrt.prefab.fx.FX.FXAnimation));
|
|
|
|
|
|
+ var allFx = local3d.findAll(o -> Std.downcast(o, hrt.prefab.fx.FX.FXAnimation));
|
|
|
|
|
|
if(!pauseButton.isDown()) {
|
|
if(!pauseButton.isDown()) {
|
|
currentTime += scene.speed * dt;
|
|
currentTime += scene.speed * dt;
|
|
@@ -1662,7 +1780,7 @@ class FXEditor extends FileView {
|
|
|
|
|
|
var emitRateCurrent = 0.0;
|
|
var emitRateCurrent = 0.0;
|
|
|
|
|
|
- var emitters = ctx.local3d.findAll(o -> Std.downcast(o, hrt.prefab.fx.Emitter.EmitterObject));
|
|
|
|
|
|
+ var emitters = local3d.findAll(o -> Std.downcast(o, hrt.prefab.fx.Emitter.EmitterObject));
|
|
var totalParts = 0;
|
|
var totalParts = 0;
|
|
for(e in emitters) {
|
|
for(e in emitters) {
|
|
totalParts += @:privateAccess e.numInstances;
|
|
totalParts += @:privateAccess e.numInstances;
|
|
@@ -1676,7 +1794,7 @@ class FXEditor extends FileView {
|
|
emitterTime += e.tickTime;
|
|
emitterTime += e.tickTime;
|
|
}
|
|
}
|
|
|
|
|
|
- var trails = ctx.local3d.findAll(o -> Std.downcast(o, hrt.prefab.l3d.Trails.TrailObj));
|
|
|
|
|
|
+ var trails = local3d.findAll(o -> Std.downcast(o, hrt.prefab.l3d.Trails.TrailObj));
|
|
var trailCount = 0;
|
|
var trailCount = 0;
|
|
var trailTime = 0.0;
|
|
var trailTime = 0.0;
|
|
var trailTris = 0.0;
|
|
var trailTris = 0.0;
|
|
@@ -1777,7 +1895,7 @@ class FXEditor extends FileView {
|
|
}
|
|
}
|
|
|
|
|
|
static function isInstanceCurve(curve: Curve) {
|
|
static function isInstanceCurve(curve: Curve) {
|
|
- return curve.getParent(hrt.prefab.fx.Emitter) != null;
|
|
|
|
|
|
+ return curve.findParent(hrt.prefab.fx.Emitter) != null;
|
|
}
|
|
}
|
|
|
|
|
|
static var _ = FileTree.registerExtension(FXEditor, ["fx"], { icon : "sitemap", createNew : "FX" });
|
|
static var _ = FileTree.registerExtension(FXEditor, ["fx"], { icon : "sitemap", createNew : "FX" });
|
|
@@ -1798,8 +1916,8 @@ class FXEditor extends FileView {
|
|
class FX2DEditor extends FXEditor {
|
|
class FX2DEditor extends FXEditor {
|
|
|
|
|
|
override function getDefaultContent() {
|
|
override function getDefaultContent() {
|
|
- return haxe.io.Bytes.ofString(ide.toJSON(new hrt.prefab.fx.FX2D().saveData()));
|
|
|
|
|
|
+ @:privateAccess return haxe.io.Bytes.ofString(ide.toJSON(new hrt.prefab.fx.FX2D(null, null).save()));
|
|
}
|
|
}
|
|
|
|
|
|
- static var _2d = FileTree.registerExtension(FX2DEditor, ["fx2d"], { icon : "sitemap", createNew : "FX 2D" });
|
|
|
|
|
|
+ static var _2d = FileTree.registerExtension(FX2DEditor, ["fx2d__"], { icon : "sitemap", createNew : "FX 2D" });
|
|
}
|
|
}
|