|
@@ -51,17 +51,8 @@ var lightmapSource = new Atomic.UIMenuItemSource();
|
|
|
lightmapSource.addItem(new Atomic.UIMenuItem("Lightmap", "Lightmap"));
|
|
lightmapSource.addItem(new Atomic.UIMenuItem("Lightmap", "Lightmap"));
|
|
|
lightmapSource.addItem(new Atomic.UIMenuItem("Lightmap Alpha", "Lightmap Alpha"));
|
|
lightmapSource.addItem(new Atomic.UIMenuItem("Lightmap Alpha", "Lightmap Alpha"));
|
|
|
|
|
|
|
|
-var _ = new Atomic.UIMenuItem("Solid");
|
|
|
|
|
-_.subSource = solidSource;
|
|
|
|
|
-techniqueSource.addItem(_);
|
|
|
|
|
-
|
|
|
|
|
-_ = new Atomic.UIMenuItem("Transparency");
|
|
|
|
|
-_.subSource = tranSource;
|
|
|
|
|
-techniqueSource.addItem(_);
|
|
|
|
|
-
|
|
|
|
|
-_ = new Atomic.UIMenuItem("Lightmap");
|
|
|
|
|
-_.subSource = lightmapSource;
|
|
|
|
|
-techniqueSource.addItem(_);
|
|
|
|
|
|
|
+var projectSource = new Atomic.UIMenuItemSource();
|
|
|
|
|
+var _ = new Atomic.UIMenuItem();
|
|
|
|
|
|
|
|
var techniqueLookup = {
|
|
var techniqueLookup = {
|
|
|
"Techniques/Diff.xml": "Diffuse",
|
|
"Techniques/Diff.xml": "Diffuse",
|
|
@@ -79,6 +70,8 @@ var techniqueLookup = {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
var techniqueReverseLookup = {};
|
|
var techniqueReverseLookup = {};
|
|
|
|
|
+var projectTechniques = {};
|
|
|
|
|
+var projectTechniquesAddress = {};
|
|
|
|
|
|
|
|
for (var key in techniqueLookup) {
|
|
for (var key in techniqueLookup) {
|
|
|
|
|
|
|
@@ -86,7 +79,6 @@ for (var key in techniqueLookup) {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
class MaterialInspector extends ScriptWidget {
|
|
class MaterialInspector extends ScriptWidget {
|
|
|
|
|
|
|
|
currentTexture: Atomic.UITextureWidget = null;
|
|
currentTexture: Atomic.UITextureWidget = null;
|
|
@@ -101,6 +93,7 @@ class MaterialInspector extends ScriptWidget {
|
|
|
this.fd.size = 11;
|
|
this.fd.size = 11;
|
|
|
|
|
|
|
|
this.subscribeToEvent(EditorEvents.RemoveCurrentAssetAssigned, (ev: EditorEvents.RemoveCurrentAssetAssignedEvent) => this.createTextureRemoveButtonCallback(this.tunit, this.textureWidget));
|
|
this.subscribeToEvent(EditorEvents.RemoveCurrentAssetAssigned, (ev: EditorEvents.RemoveCurrentAssetAssignedEvent) => this.createTextureRemoveButtonCallback(this.tunit, this.textureWidget));
|
|
|
|
|
+ this.subscribeToEvent("ResourceAdded", (ev: ToolCore.ResourceAddedEvent) => this.refreshTechniquesPopup());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
createShaderParametersSection(): Atomic.UISection {
|
|
createShaderParametersSection(): Atomic.UISection {
|
|
@@ -144,11 +137,11 @@ class MaterialInspector extends ScriptWidget {
|
|
|
field.id = params[i].name;
|
|
field.id = params[i].name;
|
|
|
field.text = params[i].valueString;
|
|
field.text = params[i].valueString;
|
|
|
|
|
|
|
|
- field.subscribeToEvent(field, "WidgetEvent", function(ev: Atomic.UIWidgetEvent) {
|
|
|
|
|
|
|
+ field.subscribeToEvent(field, "WidgetEvent", function (ev: Atomic.UIWidgetEvent) {
|
|
|
|
|
|
|
|
if (ev.type == Atomic.UI_EVENT_TYPE_CHANGED) {
|
|
if (ev.type == Atomic.UI_EVENT_TYPE_CHANGED) {
|
|
|
|
|
|
|
|
- var field = <Atomic.UIEditField> ev.target;
|
|
|
|
|
|
|
+ var field = <Atomic.UIEditField>ev.target;
|
|
|
this.material.setShaderParameter(field.id, field.text);
|
|
this.material.setShaderParameter(field.id, field.text);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -160,12 +153,8 @@ class MaterialInspector extends ScriptWidget {
|
|
|
attrsVerticalLayout.addChild(attrLayout);
|
|
attrsVerticalLayout.addChild(attrLayout);
|
|
|
|
|
|
|
|
// print(params[i].name, " : ", params[i].value, " : ", params[i].type);
|
|
// print(params[i].name, " : ", params[i].value, " : ", params[i].type);
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
return section;
|
|
return section;
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
getTextureThumbnail(texture: Atomic.Texture): Atomic.Texture {
|
|
getTextureThumbnail(texture: Atomic.Texture): Atomic.Texture {
|
|
@@ -181,7 +170,7 @@ class MaterialInspector extends ScriptWidget {
|
|
|
var thumbnail = asset.cachePath + "_thumbnail.png";
|
|
var thumbnail = asset.cachePath + "_thumbnail.png";
|
|
|
var cache = Atomic.getResourceCache();
|
|
var cache = Atomic.getResourceCache();
|
|
|
|
|
|
|
|
- var thumb = <Atomic.Texture2D> cache.getTempResource("Texture2D", thumbnail);
|
|
|
|
|
|
|
+ var thumb = <Atomic.Texture2D>cache.getTempResource("Texture2D", thumbnail);
|
|
|
|
|
|
|
|
if (thumb)
|
|
if (thumb)
|
|
|
return thumb;
|
|
return thumb;
|
|
@@ -195,17 +184,39 @@ class MaterialInspector extends ScriptWidget {
|
|
|
this.techniqueButton.text = techniqueName;
|
|
this.techniqueButton.text = techniqueName;
|
|
|
|
|
|
|
|
var cache = Atomic.getResourceCache();
|
|
var cache = Atomic.getResourceCache();
|
|
|
- var technique = <Atomic.Technique> cache.getResource("Technique", techniqueReverseLookup[techniqueName]);
|
|
|
|
|
- this.material.setTechnique(0, technique);
|
|
|
|
|
|
|
+ var technique = <Atomic.Technique>cache.getResource("Technique", techniqueReverseLookup[techniqueName]);
|
|
|
|
|
+ var resourcePath = ToolCore.toolSystem.project.getResourcePath();
|
|
|
|
|
|
|
|
|
|
+ if (technique == null) {
|
|
|
|
|
+ var techniquePath = "";
|
|
|
|
|
+
|
|
|
|
|
+ for (var i in projectTechniques) {
|
|
|
|
|
+ if (techniqueName == projectTechniques[i]) {
|
|
|
|
|
+ techniquePath = projectTechniquesAddress[i];
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ techniquePath = techniquePath.replace(resourcePath, "");
|
|
|
|
|
+ technique = <Atomic.Technique>cache.getResource("Technique", techniquePath);
|
|
|
|
|
+ }
|
|
|
|
|
+ this.material.setTechnique(0, technique);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
createTechniquePopup(): Atomic.UIWidget {
|
|
createTechniquePopup(): Atomic.UIWidget {
|
|
|
|
|
|
|
|
|
|
+ this.refreshTechniquesPopup();
|
|
|
|
|
+
|
|
|
var button = this.techniqueButton = new Atomic.UIButton();
|
|
var button = this.techniqueButton = new Atomic.UIButton();
|
|
|
var technique = this.material.getTechnique(0);
|
|
var technique = this.material.getTechnique(0);
|
|
|
|
|
+ var techniqueName = "";
|
|
|
|
|
|
|
|
- button.text = techniqueLookup[technique.name];
|
|
|
|
|
|
|
+ if (technique != null) {
|
|
|
|
|
+ techniqueName = technique.name.replace("Techniques/", "").replace(".xml", "");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ techniqueName = "UNDEFINED";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ button.text = techniqueName;
|
|
|
|
|
|
|
|
button.fontDescription = this.fd;
|
|
button.fontDescription = this.fd;
|
|
|
|
|
|
|
@@ -213,14 +224,14 @@ class MaterialInspector extends ScriptWidget {
|
|
|
lp.width = 140;
|
|
lp.width = 140;
|
|
|
button.layoutParams = lp;
|
|
button.layoutParams = lp;
|
|
|
|
|
|
|
|
- button.onClick = function() {
|
|
|
|
|
|
|
+ button.onClick = function () {
|
|
|
|
|
|
|
|
var menu = new Atomic.UIMenuWindow(button, "technique popup");
|
|
var menu = new Atomic.UIMenuWindow(button, "technique popup");
|
|
|
|
|
|
|
|
menu.fontDescription = this.fd;
|
|
menu.fontDescription = this.fd;
|
|
|
menu.show(techniqueSource);
|
|
menu.show(techniqueSource);
|
|
|
|
|
|
|
|
- button.subscribeToEvent(button, "WidgetEvent", function(ev: Atomic.UIWidgetEvent) {
|
|
|
|
|
|
|
+ button.subscribeToEvent(button, "WidgetEvent", function (ev: Atomic.UIWidgetEvent) {
|
|
|
|
|
|
|
|
if (ev.type != Atomic.UI_EVENT_TYPE_CLICK)
|
|
if (ev.type != Atomic.UI_EVENT_TYPE_CLICK)
|
|
|
return;
|
|
return;
|
|
@@ -245,7 +256,7 @@ class MaterialInspector extends ScriptWidget {
|
|
|
|
|
|
|
|
if (dragObject.object && dragObject.object.typeName == "Asset") {
|
|
if (dragObject.object && dragObject.object.typeName == "Asset") {
|
|
|
|
|
|
|
|
- var asset = <ToolCore.Asset> dragObject.object;
|
|
|
|
|
|
|
+ var asset = <ToolCore.Asset>dragObject.object;
|
|
|
|
|
|
|
|
if (asset.importerTypeName == importerTypeName) {
|
|
if (asset.importerTypeName == importerTypeName) {
|
|
|
return asset.importer;
|
|
return asset.importer;
|
|
@@ -257,7 +268,6 @@ class MaterialInspector extends ScriptWidget {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
openTextureSelectionBox(textureUnit: number, textureWidget: Atomic.UITextureWidget) {
|
|
openTextureSelectionBox(textureUnit: number, textureWidget: Atomic.UITextureWidget) {
|
|
|
|
|
|
|
|
var inspector = this;
|
|
var inspector = this;
|
|
@@ -277,8 +287,8 @@ class MaterialInspector extends ScriptWidget {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Big Texture Button(referenced texture file path in project frame)
|
|
|
|
|
- createTextureButtonCallback(textureUnit:number, textureWidget:Atomic.UITextureWidget) {
|
|
|
|
|
|
|
+ // Big Texture Button(referenced texture file path in project frame)
|
|
|
|
|
+ createTextureButtonCallback(textureUnit: number, textureWidget: Atomic.UITextureWidget) {
|
|
|
|
|
|
|
|
return () => {
|
|
return () => {
|
|
|
|
|
|
|
@@ -290,13 +300,13 @@ class MaterialInspector extends ScriptWidget {
|
|
|
this.openTextureSelectionBox(textureUnit, textureWidget);
|
|
this.openTextureSelectionBox(textureUnit, textureWidget);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return true;
|
|
|
|
|
|
|
+ return true;
|
|
|
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Small Texture Button (Opens texture selection window)
|
|
|
|
|
|
|
+ // Small Texture Button (Opens texture selection window)
|
|
|
createTextureReferenceButtonCallback(textureUnit: number, textureWidget: Atomic.UITextureWidget) {
|
|
createTextureReferenceButtonCallback(textureUnit: number, textureWidget: Atomic.UITextureWidget) {
|
|
|
|
|
|
|
|
return () => {
|
|
return () => {
|
|
@@ -310,11 +320,11 @@ class MaterialInspector extends ScriptWidget {
|
|
|
//Remove Texture Button
|
|
//Remove Texture Button
|
|
|
createTextureRemoveButtonCallback(textureUnit: number, textureWidget: Atomic.UITextureWidget) {
|
|
createTextureRemoveButtonCallback(textureUnit: number, textureWidget: Atomic.UITextureWidget) {
|
|
|
|
|
|
|
|
- var texture = this.material.getTexture(textureUnit);
|
|
|
|
|
|
|
+ var texture = this.material.getTexture(textureUnit);
|
|
|
|
|
|
|
|
- if (texture != null && textureWidget != null) {
|
|
|
|
|
- textureWidget.setTexture(null);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (texture != null && textureWidget != null) {
|
|
|
|
|
+ textureWidget.setTexture(null);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -333,7 +343,7 @@ class MaterialInspector extends ScriptWidget {
|
|
|
section.contentRoot.addChild(attrsVerticalLayout);
|
|
section.contentRoot.addChild(attrsVerticalLayout);
|
|
|
|
|
|
|
|
// TODO: Filter on technique
|
|
// TODO: Filter on technique
|
|
|
- var textureUnits = [ Atomic.TU_DIFFUSE, Atomic.TU_NORMAL, Atomic.TU_SPECULAR, Atomic.TU_EMISSIVE ];
|
|
|
|
|
|
|
+ var textureUnits = [Atomic.TU_DIFFUSE, Atomic.TU_NORMAL, Atomic.TU_SPECULAR, Atomic.TU_EMISSIVE];
|
|
|
|
|
|
|
|
for (var i in textureUnits) {
|
|
for (var i in textureUnits) {
|
|
|
|
|
|
|
@@ -389,10 +399,10 @@ class MaterialInspector extends ScriptWidget {
|
|
|
|
|
|
|
|
if (importer) {
|
|
if (importer) {
|
|
|
|
|
|
|
|
- var textureImporter = <ToolCore.TextureImporter> importer;
|
|
|
|
|
|
|
+ var textureImporter = <ToolCore.TextureImporter>importer;
|
|
|
var asset = textureImporter.asset;
|
|
var asset = textureImporter.asset;
|
|
|
|
|
|
|
|
- var texture = <Atomic.Texture2D> Atomic.cache.getResource("Texture2D", asset.path);
|
|
|
|
|
|
|
+ var texture = <Atomic.Texture2D>Atomic.cache.getResource("Texture2D", asset.path);
|
|
|
|
|
|
|
|
if (texture) {
|
|
if (texture) {
|
|
|
|
|
|
|
@@ -410,9 +420,90 @@ class MaterialInspector extends ScriptWidget {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ loadProjectTechniques(directory: string, menuItem: Atomic.UIMenuItemSource) {
|
|
|
|
|
|
|
|
|
|
+ var resourcePath = ToolCore.toolSystem.project.getResourcePath();
|
|
|
|
|
+ var TechniqueAssets = ToolCore.getAssetDatabase().getFolderAssets(directory);
|
|
|
|
|
+
|
|
|
|
|
+ for (var i = 0; i < TechniqueAssets.length; i++) {
|
|
|
|
|
+
|
|
|
|
|
+ var asset = TechniqueAssets[i];
|
|
|
|
|
+
|
|
|
|
|
+ if (TechniqueAssets[i].isFolder()) {
|
|
|
|
|
+
|
|
|
|
|
+ if (this.scanDirectoryForTechniques(asset.path)) {
|
|
|
|
|
+
|
|
|
|
|
+ var subfoldersource = new Atomic.UIMenuItemSource();
|
|
|
|
|
+ _ = new Atomic.UIMenuItem(TechniqueAssets[i].name);
|
|
|
|
|
+ _.subSource = subfoldersource;
|
|
|
|
|
+ menuItem.addItem(_);
|
|
|
|
|
+
|
|
|
|
|
+ this.loadProjectTechniques(asset.path, subfoldersource);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ projectTechniques[i] = TechniqueAssets[i].name;
|
|
|
|
|
+ projectTechniquesAddress[i] = TechniqueAssets[i].path;
|
|
|
|
|
+ menuItem.addItem(new Atomic.UIMenuItem(projectTechniques[i], projectTechniques[i]));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ scanDirectoryForTechniques(directory: string): boolean {
|
|
|
|
|
+
|
|
|
|
|
+ var techniqueAssets = ToolCore.getAssetDatabase().getFolderAssets(directory);
|
|
|
|
|
+
|
|
|
|
|
+ for (var i = 0; i < techniqueAssets.length; i++) {
|
|
|
|
|
+
|
|
|
|
|
+ var asset = techniqueAssets[i];
|
|
|
|
|
+
|
|
|
|
|
+ if (techniqueAssets[i].isFolder()) {
|
|
|
|
|
+ if (this.scanDirectoryForTechniques(asset.path)) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (techniqueAssets[i].getExtension() == ".xml") {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ refreshTechniquesPopup() {
|
|
|
|
|
+
|
|
|
|
|
+ techniqueSource.clear();
|
|
|
|
|
+
|
|
|
|
|
+ _ = new Atomic.UIMenuItem("Solid");
|
|
|
|
|
+ _.subSource = solidSource;
|
|
|
|
|
+ techniqueSource.addItem(_);
|
|
|
|
|
+
|
|
|
|
|
+ _ = new Atomic.UIMenuItem("Transparency");
|
|
|
|
|
+ _.subSource = tranSource;
|
|
|
|
|
+ techniqueSource.addItem(_);
|
|
|
|
|
+
|
|
|
|
|
+ _ = new Atomic.UIMenuItem("Lightmap");
|
|
|
|
|
+ _.subSource = lightmapSource;
|
|
|
|
|
+ techniqueSource.addItem(_);
|
|
|
|
|
+
|
|
|
|
|
+ var projectTechniquesPath = ToolCore.toolSystem.project.getResourcePath() + "Techniques";
|
|
|
|
|
+
|
|
|
|
|
+ if (Atomic.fileSystem.dirExists(projectTechniquesPath)) {
|
|
|
|
|
+
|
|
|
|
|
+ if (this.scanDirectoryForTechniques(projectTechniquesPath)) {
|
|
|
|
|
+
|
|
|
|
|
+ projectSource.clear();
|
|
|
|
|
+
|
|
|
|
|
+ _ = new Atomic.UIMenuItem("Project");
|
|
|
|
|
+ _.subSource = projectSource;
|
|
|
|
|
+ techniqueSource.addItem(_);
|
|
|
|
|
+
|
|
|
|
|
+ this.loadProjectTechniques(projectTechniquesPath, projectSource);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
inspect(asset: ToolCore.Asset, material: Atomic.Material) {
|
|
inspect(asset: ToolCore.Asset, material: Atomic.Material) {
|
|
|
|
|
+ // Add folders to resource directory
|
|
|
|
|
|
|
|
this.asset = asset;
|
|
this.asset = asset;
|
|
|
this.material = material;
|
|
this.material = material;
|
|
@@ -499,9 +590,9 @@ class MaterialInspector extends ScriptWidget {
|
|
|
button.gravity = Atomic.UI_GRAVITY_RIGHT;
|
|
button.gravity = Atomic.UI_GRAVITY_RIGHT;
|
|
|
button.text = "Save";
|
|
button.text = "Save";
|
|
|
|
|
|
|
|
- button.onClick = function() {
|
|
|
|
|
|
|
+ button.onClick = function () {
|
|
|
|
|
|
|
|
- var importer = <ToolCore.MaterialImporter> this.asset.getImporter();
|
|
|
|
|
|
|
+ var importer = <ToolCore.MaterialImporter>this.asset.getImporter();
|
|
|
importer.saveMaterial();
|
|
importer.saveMaterial();
|
|
|
|
|
|
|
|
}.bind(this);
|
|
}.bind(this);
|