- fix Color and Texture2D values in j3m creation using regex
- load and apply created j3m material to model when created git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7191 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
23e17164da
commit
93308146ea
@ -479,7 +479,7 @@ public class MaterialProperties {
|
|||||||
additionalRenderStates.put("FaceCull", new MaterialProperty("FaceCullMode", "FaceCull", mat.getAdditionalRenderState().getFaceCullMode().name()));
|
additionalRenderStates.put("FaceCull", new MaterialProperty("FaceCullMode", "FaceCull", mat.getAdditionalRenderState().getFaceCullMode().name()));
|
||||||
additionalRenderStates.put("Blend", new MaterialProperty("BlendMode", "Blend", mat.getAdditionalRenderState().getBlendMode().name()));
|
additionalRenderStates.put("Blend", new MaterialProperty("BlendMode", "Blend", mat.getAdditionalRenderState().getBlendMode().name()));
|
||||||
additionalRenderStates.put("AlphaTestFalloff", new MaterialProperty("Float", "AlphaTestFalloff", mat.getAdditionalRenderState().getAlphaFallOff() + ""));
|
additionalRenderStates.put("AlphaTestFalloff", new MaterialProperty("Float", "AlphaTestFalloff", mat.getAdditionalRenderState().getAlphaFallOff() + ""));
|
||||||
additionalRenderStates.put("PolyOffset", new MaterialProperty("Float,Float", "PolyOffset", mat.getAdditionalRenderState().getPolyOffsetUnits() + ", " + mat.getAdditionalRenderState().getPolyOffsetFactor()));
|
additionalRenderStates.put("PolyOffset", new MaterialProperty("Float,Float", "PolyOffset", mat.getAdditionalRenderState().getPolyOffsetUnits() + " " + mat.getAdditionalRenderState().getPolyOffsetFactor()));
|
||||||
parseMatDef();
|
parseMatDef();
|
||||||
setAsText(getUpdatedContent());
|
setAsText(getUpdatedContent());
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
package com.jme3.gde.materials;
|
package com.jme3.gde.materials;
|
||||||
|
|
||||||
import com.jme3.material.MatParam;
|
import com.jme3.material.MatParam;
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.texture.Texture2D;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -28,9 +30,17 @@ public class MaterialProperty {
|
|||||||
public MaterialProperty(MatParam param) {
|
public MaterialProperty(MatParam param) {
|
||||||
this.type = param.getVarType().name();
|
this.type = param.getVarType().name();
|
||||||
this.name = param.getName();
|
this.name = param.getName();
|
||||||
// param.getVarType().
|
Object obj = param.getValue();
|
||||||
|
this.value = obj.toString();
|
||||||
//TODO: change to correct string
|
//TODO: change to correct string
|
||||||
this.value = param.getValue().toString();
|
if(obj instanceof ColorRGBA){
|
||||||
|
value = value.replaceAll("Color\\[([^\\]]*)\\]", "$1");
|
||||||
|
value = value.replaceAll(",", "");
|
||||||
|
}
|
||||||
|
else if(obj instanceof Texture2D)
|
||||||
|
{
|
||||||
|
value = value.replaceAll("Texture2D\\[name=([^,]*)\\,([^\\]]*)]", "$1");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,7 +107,6 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
|
|||||||
FileObject currentFile = obj.getPrimaryFile();
|
FileObject currentFile = obj.getPrimaryFile();
|
||||||
FileObject currentFolder = currentFile.getParent();
|
FileObject currentFolder = currentFile.getParent();
|
||||||
try {
|
try {
|
||||||
Material old = material.clone();
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
FileObject newFile = currentFolder.getFileObject(currentFile.getName() + "_" + i, "j3m");
|
FileObject newFile = currentFolder.getFileObject(currentFile.getName() + "_" + i, "j3m");
|
||||||
while (newFile != null) {
|
while (newFile != null) {
|
||||||
@ -118,14 +117,18 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
|
|||||||
MaterialProperties properties = new MaterialProperties(newFile, pm);
|
MaterialProperties properties = new MaterialProperties(newFile, pm);
|
||||||
material.setAssetName(pm.getRelativeAssetPath(newFile.getPath()));
|
material.setAssetName(pm.getRelativeAssetPath(newFile.getPath()));
|
||||||
properties.setAsMaterial(material);
|
properties.setAsMaterial(material);
|
||||||
notifyListeners(old, material);
|
|
||||||
currentFolder.refresh();
|
currentFolder.refresh();
|
||||||
|
applyMaterial(material.getAssetName());
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
}else{
|
||||||
|
applyMaterial(text);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyMaterial(final String text) {
|
||||||
try {
|
try {
|
||||||
Material old = material;
|
Material old = material;
|
||||||
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user