Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This patch file was generated by NetBeans IDE
- # Following Index: paths are relative to: D:\_Programming\Java\WorkspaceJme3\jme3
- # This patch can be applied using context Tools: Patch action on respective folder.
- # It uses platform neutral UTF-8 encoding and \n newlines.
- # Above lines and this line are ignored by the patching process.
- Index: src/core-plugins/com/jme3/material/plugins/J3MLoader.java
- --- src/core-plugins/com/jme3/material/plugins/J3MLoader.java Base (BASE)
- +++ src/core-plugins/com/jme3/material/plugins/J3MLoader.java Locally Modified (Based On LOCAL)
- @@ -59,27 +59,27 @@
- // private ErrorLogger errors;
- private ShaderNodeLoaderDelegate nodesLoaderDelegate;
- boolean isUseNodes = false;
- -
- private AssetManager assetManager;
- private AssetKey key;
- -
- private MaterialDef materialDef;
- private Material material;
- private TechniqueDef technique;
- private RenderState renderState;
- -
- private String vertLanguage;
- private String fragLanguage;
- -
- + private String geomLanguage;
- + private String tessControlLanguage;
- + private String tessEvaluationLanguage;
- private String vertName;
- private String fragName;
- -
- + private String geomName;
- + private String tessControlName;
- + private String tessEvaluationName;
- private static final String whitespacePattern = "\\p{javaWhitespace}+";
- - public J3MLoader(){
- + public J3MLoader() {
- }
- -
- // <TYPE> <LANG> : <SOURCE>
- private void readShaderStatement(String statement) throws IOException {
- String[] split = statement.split(":");
- @@ -97,13 +97,22 @@
- } else if (typeAndLang[0].equals("FragmentShader")) {
- fragName = split[1].trim();
- fragLanguage = typeAndLang[1];
- + } else if (typeAndLang[0].equals("GeometryShader")) {
- + geomName = split[1].trim();
- + geomLanguage = typeAndLang[1];
- + } else if (typeAndLang[0].equals("TessControlShader")) {
- + tessControlName = split[1].trim();
- + tessControlLanguage = typeAndLang[1];
- + } else if (typeAndLang[0].equals("TessEvaluationShader")) {
- + tessEvaluationName = split[1].trim();
- + tessEvaluationLanguage = typeAndLang[1];
- }
- }
- // LightMode <MODE>
- - private void readLightMode(String statement) throws IOException{
- + private void readLightMode(String statement) throws IOException {
- String[] split = statement.split(whitespacePattern);
- - if (split.length != 2){
- + if (split.length != 2) {
- throw new IOException("LightMode statement syntax incorrect");
- }
- LightMode lm = LightMode.valueOf(split[1]);
- @@ -111,29 +120,29 @@
- }
- // ShadowMode <MODE>
- - private void readShadowMode(String statement) throws IOException{
- + private void readShadowMode(String statement) throws IOException {
- String[] split = statement.split(whitespacePattern);
- - if (split.length != 2){
- + if (split.length != 2) {
- throw new IOException("ShadowMode statement syntax incorrect");
- }
- ShadowMode sm = ShadowMode.valueOf(split[1]);
- technique.setShadowMode(sm);
- }
- - private Object readValue(VarType type, String value) throws IOException{
- - if (type.isTextureType()){
- + private Object readValue(VarType type, String value) throws IOException {
- + if (type.isTextureType()) {
- // String texturePath = readString("[\n;(//)(\\})]");
- String texturePath = value.trim();
- boolean flipY = false;
- boolean repeat = false;
- - if (texturePath.startsWith("Flip Repeat ")){
- + if (texturePath.startsWith("Flip Repeat ")) {
- texturePath = texturePath.substring(12).trim();
- flipY = true;
- repeat = true;
- - }else if (texturePath.startsWith("Flip ")){
- + } else if (texturePath.startsWith("Flip ")) {
- texturePath = texturePath.substring(5).trim();
- flipY = true;
- - }else if (texturePath.startsWith("Repeat ")){
- + } else if (texturePath.startsWith("Repeat ")) {
- texturePath = texturePath.substring(7).trim();
- repeat = true;
- }
- @@ -145,45 +154,45 @@
- Texture tex;
- try {
- tex = assetManager.loadTexture(texKey);
- - } catch (AssetNotFoundException ex){
- + } catch (AssetNotFoundException ex) {
- logger.log(Level.WARNING, "Cannot locate {0} for material {1}", new Object[]{texKey, key});
- tex = null;
- }
- - if (tex != null){
- - if (repeat){
- + if (tex != null) {
- + if (repeat) {
- tex.setWrap(WrapMode.Repeat);
- }
- - }else{
- + } else {
- tex = new Texture2D(PlaceholderAssets.getPlaceholderImage());
- - if (repeat){
- + if (repeat) {
- tex.setWrap(WrapMode.Repeat);
- }
- tex.setKey(texKey);
- }
- return tex;
- - }else{
- + } else {
- String[] split = value.trim().split(whitespacePattern);
- - switch (type){
- + switch (type) {
- case Float:
- - if (split.length != 1){
- + if (split.length != 1) {
- throw new IOException("Float value parameter must have 1 entry: " + value);
- }
- return Float.parseFloat(split[0]);
- case Vector2:
- - if (split.length != 2){
- + if (split.length != 2) {
- throw new IOException("Vector2 value parameter must have 2 entries: " + value);
- }
- return new Vector2f(Float.parseFloat(split[0]),
- Float.parseFloat(split[1]));
- case Vector3:
- - if (split.length != 3){
- + if (split.length != 3) {
- throw new IOException("Vector3 value parameter must have 3 entries: " + value);
- }
- return new Vector3f(Float.parseFloat(split[0]),
- Float.parseFloat(split[1]),
- Float.parseFloat(split[2]));
- case Vector4:
- - if (split.length != 4){
- + if (split.length != 4) {
- throw new IOException("Vector4 value parameter must have 4 entries: " + value);
- }
- return new ColorRGBA(Float.parseFloat(split[0]),
- @@ -191,23 +200,23 @@
- Float.parseFloat(split[2]),
- Float.parseFloat(split[3]));
- case Int:
- - if (split.length != 1){
- + if (split.length != 1) {
- throw new IOException("Int value parameter must have 1 entry: " + value);
- }
- return Integer.parseInt(split[0]);
- case Boolean:
- - if (split.length != 1){
- + if (split.length != 1) {
- throw new IOException("Boolean value parameter must have 1 entry: " + value);
- }
- return Boolean.parseBoolean(split[0]);
- default:
- - throw new UnsupportedOperationException("Unknown type: "+type);
- + throw new UnsupportedOperationException("Unknown type: " + type);
- }
- }
- }
- // <TYPE> <NAME> [ "(" <FFBINDING> ")" ] [ ":" <DEFAULTVAL> ]
- - private void readParam(String statement) throws IOException{
- + private void readParam(String statement) throws IOException {
- String name;
- String defaultVal = null;
- FixedFuncBinding ffBinding = null;
- @@ -215,10 +224,10 @@
- String[] split = statement.split(":");
- // Parse default val
- - if (split.length == 1){
- + if (split.length == 1) {
- // Doesn't contain default value
- - }else{
- - if (split.length != 2){
- + } else {
- + if (split.length != 2) {
- throw new IOException("Parameter statement syntax incorrect");
- }
- statement = split[0].trim();
- @@ -227,138 +236,138 @@
- // Parse ffbinding
- int startParen = statement.indexOf("(");
- - if (startParen != -1){
- + if (startParen != -1) {
- // get content inside parentheses
- int endParen = statement.indexOf(")", startParen);
- - String bindingStr = statement.substring(startParen+1, endParen).trim();
- + String bindingStr = statement.substring(startParen + 1, endParen).trim();
- try {
- ffBinding = FixedFuncBinding.valueOf(bindingStr);
- - } catch (IllegalArgumentException ex){
- - throw new IOException("FixedFuncBinding '" +
- - split[1] + "' does not exist!");
- + } catch (IllegalArgumentException ex) {
- + throw new IOException("FixedFuncBinding '"
- + + split[1] + "' does not exist!");
- }
- statement = statement.substring(0, startParen);
- }
- // Parse type + name
- split = statement.split(whitespacePattern);
- - if (split.length != 2){
- + if (split.length != 2) {
- throw new IOException("Parameter statement syntax incorrect");
- }
- VarType type;
- - if (split[0].equals("Color")){
- + if (split[0].equals("Color")) {
- type = VarType.Vector4;
- - }else{
- + } else {
- type = VarType.valueOf(split[0]);
- }
- name = split[1];
- Object defaultValObj = null;
- - if (defaultVal != null){
- + if (defaultVal != null) {
- defaultValObj = readValue(type, defaultVal);
- }
- materialDef.addMaterialParam(type, name, defaultValObj, ffBinding);
- }
- - private void readValueParam(String statement) throws IOException{
- + private void readValueParam(String statement) throws IOException {
- // Use limit=1 incase filename contains colons
- String[] split = statement.split(":", 2);
- - if (split.length != 2){
- + if (split.length != 2) {
- throw new IOException("Value parameter statement syntax incorrect");
- }
- String name = split[0].trim();
- // parse value
- MatParam p = material.getMaterialDef().getMaterialParam(name);
- - if (p == null){
- - throw new IOException("The material parameter: "+name+" is undefined.");
- + if (p == null) {
- + throw new IOException("The material parameter: " + name + " is undefined.");
- }
- Object valueObj = readValue(p.getVarType(), split[1]);
- - if (p.getVarType().isTextureType()){
- + if (p.getVarType().isTextureType()) {
- material.setTextureParam(name, p.getVarType(), (Texture) valueObj);
- - }else{
- + } else {
- material.setParam(name, p.getVarType(), valueObj);
- }
- }
- - private void readMaterialParams(List<Statement> paramsList) throws IOException{
- - for (Statement statement : paramsList){
- + private void readMaterialParams(List<Statement> paramsList) throws IOException {
- + for (Statement statement : paramsList) {
- readParam(statement.getLine());
- }
- }
- - private void readExtendingMaterialParams(List<Statement> paramsList) throws IOException{
- - for (Statement statement : paramsList){
- + private void readExtendingMaterialParams(List<Statement> paramsList) throws IOException {
- + for (Statement statement : paramsList) {
- readValueParam(statement.getLine());
- }
- }
- - private void readWorldParams(List<Statement> worldParams) throws IOException{
- - for (Statement statement : worldParams){
- + private void readWorldParams(List<Statement> worldParams) throws IOException {
- + for (Statement statement : worldParams) {
- technique.addWorldParam(statement.getLine());
- }
- }
- - private boolean parseBoolean(String word){
- + private boolean parseBoolean(String word) {
- return word != null && word.equals("On");
- }
- - private void readRenderStateStatement(Statement statement) throws IOException{
- + private void readRenderStateStatement(Statement statement) throws IOException {
- String[] split = statement.getLine().split(whitespacePattern);
- - if (split[0].equals("Wireframe")){
- + if (split[0].equals("Wireframe")) {
- renderState.setWireframe(parseBoolean(split[1]));
- - }else if (split[0].equals("FaceCull")){
- + } else if (split[0].equals("FaceCull")) {
- renderState.setFaceCullMode(FaceCullMode.valueOf(split[1]));
- - }else if (split[0].equals("DepthWrite")){
- + } else if (split[0].equals("DepthWrite")) {
- renderState.setDepthWrite(parseBoolean(split[1]));
- - }else if (split[0].equals("DepthTest")){
- + } else if (split[0].equals("DepthTest")) {
- renderState.setDepthTest(parseBoolean(split[1]));
- - }else if (split[0].equals("Blend")){
- + } else if (split[0].equals("Blend")) {
- renderState.setBlendMode(BlendMode.valueOf(split[1]));
- - }else if (split[0].equals("AlphaTestFalloff")){
- + } else if (split[0].equals("AlphaTestFalloff")) {
- renderState.setAlphaTest(true);
- renderState.setAlphaFallOff(Float.parseFloat(split[1]));
- - }else if (split[0].equals("PolyOffset")){
- + } else if (split[0].equals("PolyOffset")) {
- float factor = Float.parseFloat(split[1]);
- float units = Float.parseFloat(split[2]);
- renderState.setPolyOffset(factor, units);
- - }else if (split[0].equals("ColorWrite")){
- + } else if (split[0].equals("ColorWrite")) {
- renderState.setColorWrite(parseBoolean(split[1]));
- - }else if (split[0].equals("PointSprite")){
- + } else if (split[0].equals("PointSprite")) {
- renderState.setPointSprite(parseBoolean(split[1]));
- - }else if (split[0].equals("DepthFunc")){
- + } else if (split[0].equals("DepthFunc")) {
- renderState.setDepthFunc(RenderState.TestFunction.valueOf(split[1]));
- - }else if (split[0].equals("AlphaFunc")){
- + } else if (split[0].equals("AlphaFunc")) {
- renderState.setAlphaFunc(RenderState.TestFunction.valueOf(split[1]));
- } else {
- throw new MatParseException(null, split[0], statement);
- }
- }
- - private void readAdditionalRenderState(List<Statement> renderStates) throws IOException{
- + private void readAdditionalRenderState(List<Statement> renderStates) throws IOException {
- renderState = material.getAdditionalRenderState();
- - for (Statement statement : renderStates){
- + for (Statement statement : renderStates) {
- readRenderStateStatement(statement);
- }
- renderState = null;
- }
- - private void readRenderState(List<Statement> renderStates) throws IOException{
- + private void readRenderState(List<Statement> renderStates) throws IOException {
- renderState = new RenderState();
- - for (Statement statement : renderStates){
- + for (Statement statement : renderStates) {
- readRenderStateStatement(statement);
- }
- technique.setRenderState(renderState);
- renderState = null;
- }
- - private void readForcedRenderState(List<Statement> renderStates) throws IOException{
- + private void readForcedRenderState(List<Statement> renderStates) throws IOException {
- renderState = new RenderState();
- - for (Statement statement : renderStates){
- + for (Statement statement : renderStates) {
- readRenderStateStatement(statement);
- }
- technique.setForcedRenderState(renderState);
- @@ -366,41 +375,44 @@
- }
- // <DEFINENAME> [ ":" <PARAMNAME> ]
- - private void readDefine(String statement) throws IOException{
- + private void readDefine(String statement) throws IOException {
- String[] split = statement.split(":");
- - if (split.length == 1){
- + if (split.length == 1) {
- // add preset define
- technique.addShaderPresetDefine(split[0].trim(), VarType.Boolean, true);
- - }else if (split.length == 2){
- + } else if (split.length == 2) {
- technique.addShaderParamDefine(split[1].trim(), split[0].trim());
- - }else{
- + } else {
- throw new IOException("Define syntax incorrect");
- }
- }
- - private void readDefines(List<Statement> defineList) throws IOException{
- - for (Statement statement : defineList){
- + private void readDefines(List<Statement> defineList) throws IOException {
- + for (Statement statement : defineList) {
- readDefine(statement.getLine());
- }
- }
- - private void readTechniqueStatement(Statement statement) throws IOException{
- + private void readTechniqueStatement(Statement statement) throws IOException {
- String[] split = statement.getLine().split("[ \\{]");
- - if (split[0].equals("VertexShader") ||
- - split[0].equals("FragmentShader")){
- + if (split[0].equals("VertexShader")
- + || split[0].equals("FragmentShader")
- + || split[0].equals("GeometryShader")
- + || split[0].equals("TessControlShader")
- + || split[0].equals("TessEvaluationShader")) {
- readShaderStatement(statement.getLine());
- - }else if (split[0].equals("LightMode")){
- + } else if (split[0].equals("LightMode")) {
- readLightMode(statement.getLine());
- - }else if (split[0].equals("ShadowMode")){
- + } else if (split[0].equals("ShadowMode")) {
- readShadowMode(statement.getLine());
- - }else if (split[0].equals("WorldParameters")){
- + } else if (split[0].equals("WorldParameters")) {
- readWorldParams(statement.getContents());
- - }else if (split[0].equals("RenderState")){
- + } else if (split[0].equals("RenderState")) {
- readRenderState(statement.getContents());
- - }else if (split[0].equals("ForcedRenderState")){
- + } else if (split[0].equals("ForcedRenderState")) {
- readForcedRenderState(statement.getContents());
- - }else if (split[0].equals("Defines")){
- + } else if (split[0].equals("Defines")) {
- readDefines(statement.getContents());
- } else if (split[0].equals("ShaderNodesDefinitions")) {
- initNodesLoader();
- @@ -422,15 +434,15 @@
- }
- }
- - private void readTransparentStatement(String statement) throws IOException{
- + private void readTransparentStatement(String statement) throws IOException {
- String[] split = statement.split(whitespacePattern);
- - if (split.length != 2){
- + if (split.length != 2) {
- throw new IOException("Transparent statement syntax incorrect");
- }
- material.setTransparent(parseBoolean(split[1]));
- }
- - private void readTechnique(Statement techStat) throws IOException{
- + private void readTechnique(Statement techStat) throws IOException {
- isUseNodes = false;
- String[] split = techStat.getLine().split(whitespacePattern);
- if (split.length == 1) {
- @@ -447,62 +459,68 @@
- throw new IOException("Technique statement syntax incorrect");
- }
- - for (Statement statement : techStat.getContents()){
- + for (Statement statement : techStat.getContents()) {
- readTechniqueStatement(statement);
- }
- - if(isUseNodes){
- + if (isUseNodes) {
- nodesLoaderDelegate.computeConditions();
- //used for caching later, the shader here is not a file.
- technique.setShaderFile(technique.hashCode() + "", technique.hashCode() + "", "GLSL100", "GLSL100");
- }
- - if (vertName != null && fragName != null){
- - technique.setShaderFile(vertName, fragName, vertLanguage, fragLanguage);
- + if (vertName != null && fragName != null) {
- + technique.setShaderFile(vertName, fragName, geomName,tessControlName,tessEvaluationName, vertLanguage, fragLanguage,geomLanguage,tessControlLanguage,tessEvaluationLanguage);
- }
- materialDef.addTechniqueDef(technique);
- technique = null;
- vertName = null;
- fragName = null;
- + geomName=null;
- + tessControlName=null;
- + tessEvaluationName=null;
- vertLanguage = null;
- fragLanguage = null;
- + geomLanguage=null;
- + tessControlLanguage=null;
- + tessEvaluationLanguage=null;
- }
- - private void loadFromRoot(List<Statement> roots) throws IOException{
- - if (roots.size() == 2){
- + private void loadFromRoot(List<Statement> roots) throws IOException {
- + if (roots.size() == 2) {
- Statement exception = roots.get(0);
- String line = exception.getLine();
- - if (line.startsWith("Exception")){
- + if (line.startsWith("Exception")) {
- throw new AssetLoadException(line.substring("Exception ".length()));
- - }else{
- + } else {
- throw new IOException("In multiroot material, expected first statement to be 'Exception'");
- }
- - }else if (roots.size() != 1){
- + } else if (roots.size() != 1) {
- throw new IOException("Too many roots in J3M/J3MD file");
- }
- boolean extending = false;
- Statement materialStat = roots.get(0);
- String materialName = materialStat.getLine();
- - if (materialName.startsWith("MaterialDef")){
- + if (materialName.startsWith("MaterialDef")) {
- materialName = materialName.substring("MaterialDef ".length()).trim();
- extending = false;
- - }else if (materialName.startsWith("Material")){
- + } else if (materialName.startsWith("Material")) {
- materialName = materialName.substring("Material ".length()).trim();
- extending = true;
- - }else{
- + } else {
- throw new IOException("Specified file is not a Material file");
- }
- String[] split = materialName.split(":", 2);
- - if (materialName.equals("")){
- + if (materialName.equals("")) {
- throw new MatParseException("Material name cannot be empty", materialStat);
- }
- - if (split.length == 2){
- - if (!extending){
- + if (split.length == 2) {
- + if (!extending) {
- throw new MatParseException("Must use 'Material' when extending.", materialStat);
- }
- @@ -516,35 +534,35 @@
- material = new Material(def);
- material.setKey(key);
- // material.setAssetName(fileName);
- - }else if (split.length == 1){
- - if (extending){
- + } else if (split.length == 1) {
- + if (extending) {
- throw new MatParseException("Expected ':', got '{'", materialStat);
- }
- materialDef = new MaterialDef(assetManager, materialName);
- // NOTE: pass file name for defs so they can be loaded later
- materialDef.setAssetName(key.getName());
- - }else{
- + } else {
- throw new MatParseException("Cannot use colon in material name/path", materialStat);
- }
- - for (Statement statement : materialStat.getContents()){
- + for (Statement statement : materialStat.getContents()) {
- split = statement.getLine().split("[ \\{]");
- String statType = split[0];
- - if (extending){
- - if (statType.equals("MaterialParameters")){
- + if (extending) {
- + if (statType.equals("MaterialParameters")) {
- readExtendingMaterialParams(statement.getContents());
- - }else if (statType.equals("AdditionalRenderState")){
- + } else if (statType.equals("AdditionalRenderState")) {
- readAdditionalRenderState(statement.getContents());
- - }else if (statType.equals("Transparent")){
- + } else if (statType.equals("Transparent")) {
- readTransparentStatement(statement.getLine());
- }
- - }else{
- - if (statType.equals("Technique")){
- + } else {
- + if (statType.equals("Technique")) {
- readTechnique(statement);
- - }else if (statType.equals("MaterialParameters")){
- + } else if (statType.equals("MaterialParameters")) {
- readMaterialParams(statement.getContents());
- - }else{
- - throw new MatParseException("Expected material statement, got '"+statType+"'", statement);
- + } else {
- + throw new MatParseException("Expected material statement, got '" + statType + "'", statement);
- }
- }
- }
- @@ -558,18 +576,18 @@
- key = info.getKey();
- loadFromRoot(BlockLanguageParser.parse(in));
- } finally {
- - if (in != null){
- + if (in != null) {
- in.close();
- }
- }
- - if (material != null){
- - if (!(info.getKey() instanceof MaterialKey)){
- + if (material != null) {
- + if (!(info.getKey() instanceof MaterialKey)) {
- throw new IOException("Material instances must be loaded via MaterialKey");
- }
- // material implementation
- return material;
- - }else{
- + } else {
- // material definition
- return materialDef;
- }
- @@ -586,9 +604,9 @@
- if (!isUseNodes) {
- isUseNodes = fragName == null && vertName == null;
- if (isUseNodes) {
- - if(nodesLoaderDelegate == null){
- + if (nodesLoaderDelegate == null) {
- nodesLoaderDelegate = new ShaderNodeLoaderDelegate();
- - }else{
- + } else {
- nodesLoaderDelegate.clear();
- }
- nodesLoaderDelegate.setTechniqueDef(technique);
- @@ -597,5 +615,4 @@
- }
- }
- }
- -
- }
- Index: src/core/com/jme3/asset/Desktop.cfg
- --- src/core/com/jme3/asset/Desktop.cfg Base (BASE)
- +++ src/core/com/jme3/asset/Desktop.cfg Locally Modified (Based On LOCAL)
- @@ -21,4 +21,4 @@
- LOADER com.jme3.scene.plugins.ogre.MaterialLoader : material
- LOADER com.jme3.scene.plugins.ogre.SceneLoader : scene
- LOADER com.jme3.scene.plugins.blender.BlenderModelLoader : blend
- -LOADER com.jme3.shader.plugins.GLSLLoader : vert, frag, glsl, glsllib
- +LOADER com.jme3.shader.plugins.GLSLLoader : vert, frag,geom, tsctrl, tseval, glsl, glsllib
- Index: src/core/com/jme3/asset/DesktopAssetManager.java
- --- src/core/com/jme3/asset/DesktopAssetManager.java Base (BASE)
- +++ src/core/com/jme3/asset/DesktopAssetManager.java Locally Modified (Based On LOCAL)
- @@ -68,47 +68,45 @@
- private static final Logger logger = Logger.getLogger(AssetManager.class.getName());
- private ShaderGenerator shaderGenerator;
- -
- private final ImplHandler handler = new ImplHandler(this);
- -
- private CopyOnWriteArrayList<AssetEventListener> eventListeners =
- new CopyOnWriteArrayList<AssetEventListener>();
- -
- private List<ClassLoader> classLoaders =
- Collections.synchronizedList(new ArrayList<ClassLoader>());
- - public DesktopAssetManager(){
- + public DesktopAssetManager() {
- this(null);
- }
- @Deprecated
- - public DesktopAssetManager(boolean loadDefaults){
- + public DesktopAssetManager(boolean loadDefaults) {
- this(Thread.currentThread().getContextClassLoader().getResource("com/jme3/asset/Desktop.cfg"));
- }
- - public DesktopAssetManager(URL configFile){
- - if (configFile != null){
- + public DesktopAssetManager(URL configFile) {
- + if (configFile != null) {
- loadConfigFile(configFile);
- }
- logger.fine("DesktopAssetManager created.");
- }
- - private void loadConfigFile(URL configFile){
- + private void loadConfigFile(URL configFile) {
- InputStream stream = null;
- - try{
- + try {
- AssetConfig cfg = new AssetConfig(this);
- stream = configFile.openStream();
- cfg.loadText(stream);
- - }catch (IOException ex){
- + } catch (IOException ex) {
- logger.log(Level.SEVERE, "Failed to load asset config", ex);
- - }finally{
- - if (stream != null)
- - try{
- + } finally {
- + if (stream != null) {
- + try {
- stream.close();
- - }catch (IOException ex){
- + } catch (IOException ex) {
- }
- }
- }
- + }
- public void addClassLoader(ClassLoader loader) {
- classLoaders.add(loader);
- @@ -118,7 +116,7 @@
- classLoaders.remove(loader);
- }
- - public List<ClassLoader> getClassLoaders(){
- + public List<ClassLoader> getClassLoaders() {
- return Collections.unmodifiableList(classLoaders);
- }
- @@ -134,74 +132,74 @@
- eventListeners.clear();
- }
- - public void setAssetEventListener(AssetEventListener listener){
- + public void setAssetEventListener(AssetEventListener listener) {
- eventListeners.clear();
- eventListeners.add(listener);
- }
- - public void registerLoader(Class<? extends AssetLoader> loader, String ... extensions){
- + public void registerLoader(Class<? extends AssetLoader> loader, String... extensions) {
- handler.addLoader(loader, extensions);
- - if (logger.isLoggable(Level.FINER)){
- + if (logger.isLoggable(Level.FINER)) {
- logger.log(Level.FINER, "Registered loader: {0} for extensions {1}",
- new Object[]{loader.getSimpleName(), Arrays.toString(extensions)});
- }
- }
- - public void registerLoader(String clsName, String ... extensions){
- + public void registerLoader(String clsName, String... extensions) {
- Class<? extends AssetLoader> clazz = null;
- - try{
- + try {
- clazz = (Class<? extends AssetLoader>) Class.forName(clsName);
- - }catch (ClassNotFoundException ex){
- - logger.log(Level.WARNING, "Failed to find loader: "+clsName, ex);
- - }catch (NoClassDefFoundError ex){
- - logger.log(Level.WARNING, "Failed to find loader: "+clsName, ex);
- + } catch (ClassNotFoundException ex) {
- + logger.log(Level.WARNING, "Failed to find loader: " + clsName, ex);
- + } catch (NoClassDefFoundError ex) {
- + logger.log(Level.WARNING, "Failed to find loader: " + clsName, ex);
- }
- - if (clazz != null){
- + if (clazz != null) {
- registerLoader(clazz, extensions);
- }
- }
- public void unregisterLoader(Class<? extends AssetLoader> loaderClass) {
- handler.removeLoader(loaderClass);
- - if (logger.isLoggable(Level.FINER)){
- + if (logger.isLoggable(Level.FINER)) {
- logger.log(Level.FINER, "Unregistered loader: {0}",
- loaderClass.getSimpleName());
- }
- }
- - public void registerLocator(String rootPath, Class<? extends AssetLocator> locatorClass){
- + public void registerLocator(String rootPath, Class<? extends AssetLocator> locatorClass) {
- handler.addLocator(locatorClass, rootPath);
- - if (logger.isLoggable(Level.FINER)){
- + if (logger.isLoggable(Level.FINER)) {
- logger.log(Level.FINER, "Registered locator: {0}",
- locatorClass.getSimpleName());
- }
- }
- - public void registerLocator(String rootPath, String clsName){
- + public void registerLocator(String rootPath, String clsName) {
- Class<? extends AssetLocator> clazz = null;
- - try{
- + try {
- clazz = (Class<? extends AssetLocator>) Class.forName(clsName);
- - }catch (ClassNotFoundException ex){
- - logger.log(Level.WARNING, "Failed to find locator: "+clsName, ex);
- - }catch (NoClassDefFoundError ex){
- - logger.log(Level.WARNING, "Failed to find loader: "+clsName, ex);
- + } catch (ClassNotFoundException ex) {
- + logger.log(Level.WARNING, "Failed to find locator: " + clsName, ex);
- + } catch (NoClassDefFoundError ex) {
- + logger.log(Level.WARNING, "Failed to find loader: " + clsName, ex);
- }
- - if (clazz != null){
- + if (clazz != null) {
- registerLocator(rootPath, clazz);
- }
- }
- - public void unregisterLocator(String rootPath, Class<? extends AssetLocator> clazz){
- + public void unregisterLocator(String rootPath, Class<? extends AssetLocator> clazz) {
- handler.removeLocator(clazz, rootPath);
- - if (logger.isLoggable(Level.FINER)){
- + if (logger.isLoggable(Level.FINER)) {
- logger.log(Level.FINER, "Unregistered locator: {0}",
- clazz.getSimpleName());
- }
- }
- - public AssetInfo locateAsset(AssetKey<?> key){
- + public AssetInfo locateAsset(AssetKey<?> key) {
- AssetInfo info = handler.tryLocate(key);
- - if (info == null){
- + if (info == null) {
- logger.log(Level.WARNING, "Cannot locate resource: {0}", key);
- }
- return info;
- @@ -240,9 +238,9 @@
- }
- }
- - public void clearCache(){
- + public void clearCache() {
- handler.clearCache();
- - if (logger.isLoggable(Level.FINER)){
- + if (logger.isLoggable(Level.FINER)) {
- logger.log(Level.FINER, "All asset caches cleared.");
- }
- }
- @@ -254,11 +252,12 @@
- * @param key
- * @return the loaded asset
- */
- - public <T> T loadAsset(AssetKey<T> key){
- - if (key == null)
- + public <T> T loadAsset(AssetKey<T> key) {
- + if (key == null) {
- throw new IllegalArgumentException("key cannot be null");
- + }
- - for (AssetEventListener listener : eventListeners){
- + for (AssetEventListener listener : eventListeners) {
- listener.assetRequested(key);
- }
- @@ -266,17 +265,17 @@
- AssetProcessor proc = handler.getProcessor(key.getProcessorType());
- Object obj = cache != null ? cache.getFromCache(key) : null;
- - if (obj == null){
- + if (obj == null) {
- // Asset not in cache, load it from file system.
- AssetLoader loader = handler.aquireLoader(key);
- AssetInfo info = handler.tryLocate(key);
- - if (info == null){
- - if (handler.getParentKey() != null){
- + if (info == null) {
- + if (handler.getParentKey() != null) {
- // Inform event listener that an asset has failed to load.
- // If the parent AssetLoader chooses not to propagate
- // the exception, this is the only means of finding
- // that something went wrong.
- - for (AssetEventListener listener : eventListeners){
- + for (AssetEventListener listener : eventListeners) {
- listener.assetDependencyNotFound(handler.getParentKey(), key);
- }
- }
- @@ -291,25 +290,25 @@
- } finally {
- handler.releaseParentKey(key);
- }
- - if (obj == null){
- + if (obj == null) {
- throw new AssetLoadException("Error occured while loading asset \"" + key + "\" using " + loader.getClass().getSimpleName());
- - }else{
- - if (logger.isLoggable(Level.FINER)){
- + } else {
- + if (logger.isLoggable(Level.FINER)) {
- logger.log(Level.FINER, "Loaded {0} with {1}",
- new Object[]{key, loader.getClass().getSimpleName()});
- }
- - if (proc != null){
- + if (proc != null) {
- // do processing on asset before caching
- obj = proc.postProcess(key, obj);
- }
- - if (cache != null){
- + if (cache != null) {
- // At this point, obj should be of type T
- cache.addToCache(key, (T) obj);
- }
- - for (AssetEventListener listener : eventListeners){
- + for (AssetEventListener listener : eventListeners) {
- listener.assetLoaded(key);
- }
- }
- @@ -318,16 +317,16 @@
- // object obj is the original asset
- // create an instance for user
- T clone = (T) obj;
- - if (clone instanceof CloneableSmartAsset){
- - if (proc == null){
- + if (clone instanceof CloneableSmartAsset) {
- + if (proc == null) {
- throw new IllegalStateException("Asset implements "
- + "CloneableSmartAsset but doesn't "
- + "have processor to handle cloning");
- - }else{
- + } else {
- clone = (T) proc.createClone(obj);
- - if (cache != null && clone != obj){
- + if (cache != null && clone != obj) {
- cache.registerAssetClone(key, clone);
- - } else{
- + } else {
- throw new IllegalStateException("Asset implements "
- + "CloneableSmartAsset but doesn't have cache or "
- + "was not cloned");
- @@ -338,19 +337,19 @@
- return clone;
- }
- - public Object loadAsset(String name){
- + public Object loadAsset(String name) {
- return loadAsset(new AssetKey(name));
- }
- - public Texture loadTexture(TextureKey key){
- + public Texture loadTexture(TextureKey key) {
- return (Texture) loadAsset(key);
- }
- - public Material loadMaterial(String name){
- + public Material loadMaterial(String name) {
- return (Material) loadAsset(new MaterialKey(name));
- }
- - public Texture loadTexture(String name){
- + public Texture loadTexture(String name) {
- TextureKey key = new TextureKey(name, true);
- key.setGenerateMips(true);
- Texture tex = loadTexture(key);
- @@ -358,31 +357,31 @@
- return tex;
- }
- - public AudioData loadAudio(AudioKey key){
- + public AudioData loadAudio(AudioKey key) {
- return (AudioData) loadAsset(key);
- }
- - public AudioData loadAudio(String name){
- + public AudioData loadAudio(String name) {
- return loadAudio(new AudioKey(name, false));
- }
- - public BitmapFont loadFont(String name){
- + public BitmapFont loadFont(String name) {
- return (BitmapFont) loadAsset(new AssetKey(name));
- }
- - public Spatial loadModel(ModelKey key){
- + public Spatial loadModel(ModelKey key) {
- return (Spatial) loadAsset(key);
- }
- - public Spatial loadModel(String name){
- + public Spatial loadModel(String name) {
- return loadModel(new ModelKey(name));
- }
- - public FilterPostProcessor loadFilter(FilterKey key){
- + public FilterPostProcessor loadFilter(FilterKey key) {
- return (FilterPostProcessor) loadAsset(key);
- }
- - public FilterPostProcessor loadFilter(String name){
- + public FilterPostProcessor loadFilter(String name) {
- return loadFilter(new FilterKey(name));
- }
- @@ -392,30 +391,44 @@
- * @param key
- * @return the loaded {@link Shader}
- */
- - public Shader loadShader(ShaderKey key){
- + public Shader loadShader(ShaderKey key) {
- // cache abuse in method
- // that doesn't use loaders/locators
- AssetCache cache = handler.getCache(SimpleAssetCache.class);
- Shader shader = (Shader) cache.getFromCache(key);
- - if (shader == null){
- + if (shader == null) {
- if (key.isUsesShaderNodes()) {
- - if(shaderGenerator == null){
- + if (shaderGenerator == null) {
- throw new UnsupportedOperationException("ShaderGenerator was not initialized, make sure assetManager.getGenerator(caps) has been called");
- }
- shader = shaderGenerator.generateShader();
- } else {
- String vertName = key.getVertName();
- String fragName = key.getFragName();
- -
- + String geomName = key.getGeomName();
- + String tcName = key.getTcName();
- + String teName = key.getTeName();
- String vertSource = (String) loadAsset(new AssetKey(vertName));
- String fragSource = (String) loadAsset(new AssetKey(fragName));
- -
- + String geomSource = geomName == null ? null : (String) loadAsset(new AssetKey(geomName));
- + String tcSource = tcName == null ? null : (String) loadAsset(new AssetKey(tcName));
- + String teSource = teName == null ? null : (String) loadAsset(new AssetKey(teName));
- shader = new Shader();
- shader.initialize();
- shader.addSource(Shader.ShaderType.Vertex, vertName, vertSource, key.getDefines().getCompiled(), key.getVertexShaderLanguage());
- shader.addSource(Shader.ShaderType.Fragment, fragName, fragSource, key.getDefines().getCompiled(), key.getFragmentShaderLanguage());
- + if (geomName != null) {
- + shader.addSource(Shader.ShaderType.Geometry, geomName, geomSource, key.getDefines().getCompiled(), key.getVertexShaderLanguage());
- }
- + if (tcName != null) {
- + shader.addSource(Shader.ShaderType.TesselationControl, tcName, tcSource, key.getDefines().getCompiled(), key.getVertexShaderLanguage());
- + }
- + if (teName != null) {
- + shader.addSource(Shader.ShaderType.TesselationEvaluation, teName, teSource, key.getDefines().getCompiled(), key.getVertexShaderLanguage());
- + }
- + }
- +
- cache.addToCache(key, shader);
- }
- return shader;
- @@ -427,9 +440,9 @@
- @Override
- public ShaderGenerator getShaderGenerator(EnumSet<Caps> caps) {
- if (shaderGenerator == null) {
- - if(caps.contains(Caps.GLSL150)){
- + if (caps.contains(Caps.GLSL150)) {
- shaderGenerator = new Glsl150ShaderGenerator(this);
- - }else{
- + } else {
- shaderGenerator = new Glsl100ShaderGenerator(this);
- }
- }
- @@ -443,6 +456,4 @@
- public void setShaderGenerator(ShaderGenerator shaderGenerator) {
- this.shaderGenerator = shaderGenerator;
- }
- -
- -
- }
- Index: src/core/com/jme3/material/Technique.java
- --- src/core/com/jme3/material/Technique.java Base (BASE)
- +++ src/core/com/jme3/material/Technique.java Locally Modified (Based On LOCAL)
- @@ -207,9 +207,15 @@
- ShaderKey key = new ShaderKey(def.getVertexShaderName(),
- def.getFragmentShaderName(),
- + def.getGeometryShaderName(),
- + def.getTessControlShaderName(),
- + def.getTessEvaluationShaderName(),
- getAllDefines(),
- def.getVertexShaderLanguage(),
- - def.getFragmentShaderLanguage());
- + def.getFragmentShaderLanguage(),
- + def.getGeometryShaderLanguage(),
- + def.getTessControlShaderLanguage(),
- + def.getTessEvaluationShaderLanguage());
- if (getDef().isUsingShaderNodes()) {
- manager.getShaderGenerator(rendererCaps).initialize(this);
- Index: src/core/com/jme3/material/TechniqueDef.java
- --- src/core/com/jme3/material/TechniqueDef.java Base (BASE)
- +++ src/core/com/jme3/material/TechniqueDef.java Locally Modified (Based On LOCAL)
- @@ -56,15 +56,31 @@
- */
- public static final int SAVABLE_VERSION = 1;
- + public void setShaderFile(String vertexShader, String fragmentShader, String vertLanguage, String fragLanguage) {
- + this.vertName = vertexShader;
- + this.fragName = fragmentShader;
- +
- + this.vertLanguage = vertLanguage;
- + this.fragLanguage = fragLanguage;
- +
- + Caps vertCap = Caps.valueOf(vertLanguage);
- + requiredCaps.add(vertCap);
- + Caps fragCap = Caps.valueOf(fragLanguage);
- + requiredCaps.add(fragCap);
- + Caps geomCap = Caps.valueOf(geomLanguage);
- + requiredCaps.add(geomCap);
- + usesShaders = true;
- + }
- +
- /**
- * Describes light rendering mode.
- */
- public enum LightMode {
- +
- /**
- * Disable light-based rendering
- */
- Disable,
- -
- /**
- * Enable light rendering by using a single pass.
- * <p>
- @@ -72,55 +88,54 @@
- * containing the world light list for the geometry being rendered.
- */
- SinglePass,
- -
- /**
- * Enable light rendering by using multi-pass rendering.
- * <p>
- * The geometry will be rendered once for each light. Each time the
- - * light position and light color uniforms are updated to contain
- - * the values for the current light. The ambient light color uniform
- - * is only set to the ambient light color on the first pass, future
- - * passes have it set to black.
- + * light position and light color uniforms are updated to contain the
- + * values for the current light. The ambient light color uniform is only
- + * set to the ambient light color on the first pass, future passes have
- + * it set to black.
- */
- MultiPass,
- -
- /**
- * Enable light rendering by using the
- * {@link Renderer#setLighting(com.jme3.light.LightList) renderer's setLighting}
- * method.
- * <p>
- - * The specific details of rendering the lighting is up to the
- - * renderer implementation.
- + * The specific details of rendering the lighting is up to the renderer
- + * implementation.
- */
- FixedPipeline,
- }
- public enum ShadowMode {
- +
- Disable,
- InPass,
- PostPass,
- }
- -
- private EnumSet<Caps> requiredCaps = EnumSet.noneOf(Caps.class);
- private String name;
- -
- private String vertName;
- private String fragName;
- + private String geomName;
- + private String tcName;
- + private String teName;
- private String vertLanguage;
- private String fragLanguage;
- -
- + private String geomLanguage;
- + private String tcLanguage;
- + private String teLanguage;
- private DefineList presetDefines;
- private boolean usesShaders;
- private boolean usesNodes = false;
- private List<ShaderNode> shaderNodes;
- private ShaderGenerationInfo shaderGenerationInfo;
- -
- private RenderState renderState;
- private RenderState forcedRenderState;
- -
- - private LightMode lightMode = LightMode.Disable;
- + private LightMode lightMode = LightMode.Disable;
- private ShadowMode shadowMode = ShadowMode.Disable;
- -
- private HashMap<String, String> defineParams;
- private ArrayList<UniformBinding> worldBinds;
- @@ -132,28 +147,29 @@
- * @param name The name of the technique, should be set to <code>null</code>
- * for default techniques.
- */
- - public TechniqueDef(String name){
- + public TechniqueDef(String name) {
- this.name = name == null ? "Default" : name;
- }
- /**
- * Serialization only. Do not use.
- */
- - public TechniqueDef(){
- + public TechniqueDef() {
- }
- /**
- - * Returns the name of this technique as specified in the J3MD file.
- - * Default techniques have the name "Default".
- + * Returns the name of this technique as specified in the J3MD file. Default
- + * techniques have the name "Default".
- *
- * @return the name of this technique
- */
- - public String getName(){
- + public String getName() {
- return name;
- }
- /**
- * Returns the light mode.
- + *
- * @return the light mode.
- * @see LightMode
- */
- @@ -174,6 +190,7 @@
- /**
- * Returns the shadow mode.
- + *
- * @return the shadow mode.
- */
- public ShadowMode getShadowMode() {
- @@ -193,6 +210,7 @@
- /**
- * Returns the render state that this technique is using
- + *
- * @return the render state that this technique is using
- * @see #setRenderState(com.jme3.material.RenderState)
- */
- @@ -218,7 +236,7 @@
- *
- * @see #setShaderFile(java.lang.String, java.lang.String, java.lang.String)
- */
- - public boolean isUsingShaders(){
- + public boolean isUsingShaders() {
- return usesShaders;
- }
- @@ -228,13 +246,13 @@
- * @return true if this technique uses Shader Nodes, false otherwise.
- *
- */
- - public boolean isUsingShaderNodes(){
- + public boolean isUsingShaderNodes() {
- return usesNodes;
- }
- /**
- - * Gets the {@link Caps renderer capabilities} that are required
- - * by this technique.
- + * Gets the {@link Caps renderer capabilities} that are required by this
- + * technique.
- *
- * @return the required renderer capabilities
- */
- @@ -250,20 +268,56 @@
- * @param vertLanguage The vertex shader language
- * @param fragLanguage The fragment shader language
- */
- - public void setShaderFile(String vertexShader, String fragmentShader, String vertLanguage, String fragLanguage){
- + public void setShaderFile(String vertexShader, String fragmentShader, String geomShader, String tcShader, String teShader, String vertLanguage, String fragLanguage, String geomLang, String tcLang, String teLang) {
- this.vertName = vertexShader;
- this.fragName = fragmentShader;
- + this.geomName = geomShader;
- + this.tcName = tcShader;
- + this.teName = teShader;
- this.vertLanguage = vertLanguage;
- this.fragLanguage = fragLanguage;
- -
- + this.geomLanguage = geomLang;
- + this.tcLanguage = tcLang;
- + this.teLanguage = teLang;
- Caps vertCap = Caps.valueOf(vertLanguage);
- requiredCaps.add(vertCap);
- Caps fragCap = Caps.valueOf(fragLanguage);
- requiredCaps.add(fragCap);
- + //System.out.println(geomLanguage);
- + if(geomLanguage!=null){
- + Caps geomCap = Caps.valueOf(geomLanguage);
- + requiredCaps.add(geomCap);
- + }
- + if(tcLanguage!=null){
- + Caps tcCaps = Caps.valueOf(tcLanguage);
- + requiredCaps.add(tcCaps);
- + }
- + if(teLanguage!=null){
- + Caps teCaps = Caps.valueOf(teLanguage);
- + requiredCaps.add(teCaps);
- + }
- + if (geomName != null) {
- + requiredCaps.add(Caps.GeometryShader);
- + }
- + if (tcName != null || teName != null) {
- + requiredCaps.add(Caps.TesselationShader);
- + }
- usesShaders = true;
- }
- + public String getGeometryShaderName() {
- + return geomName;
- + }
- +
- + public String getTessControlShaderName() {
- + return tcName;
- + }
- +
- + public String getTessEvaluationShaderName() {
- + return teName;
- + }
- +
- /**
- * Returns the define name which the given material parameter influences.
- *
- @@ -272,7 +326,7 @@
- *
- * @see #addShaderParamDefine(java.lang.String, java.lang.String)
- */
- - public String getShaderParamDefine(String paramName){
- + public String getShaderParamDefine(String paramName) {
- if (defineParams == null) {
- return null;
- }
- @@ -282,16 +336,16 @@
- /**
- * Adds a define linked to a material parameter.
- * <p>
- - * Any time the material parameter on the parent material is altered,
- - * the appropriate define on the technique will be modified as well.
- - * See the method
- + * Any time the material parameter on the parent material is altered, the
- + * appropriate define on the technique will be modified as well. See the
- + * method
- * {@link DefineList#set(java.lang.String, com.jme3.shader.VarType, java.lang.Object) }
- * on the exact details of how the material parameter changes the define.
- *
- * @param paramName The name of the material parameter to link to.
- * @param defineName The name of the define parameter, e.g. USE_LIGHTING
- */
- - public void addShaderParamDefine(String paramName, String defineName){
- + public void addShaderParamDefine(String paramName, String defineName) {
- if (defineParams == null) {
- defineParams = new HashMap<String, String>();
- }
- @@ -303,7 +357,8 @@
- *
- * @return the {@link DefineList} for the preset defines.
- *
- - * @see #addShaderPresetDefine(java.lang.String, com.jme3.shader.VarType, java.lang.Object)
- + * @see #addShaderPresetDefine(java.lang.String, com.jme3.shader.VarType,
- + * java.lang.Object)
- */
- public DefineList getShaderPresetDefines() {
- return presetDefines;
- @@ -312,8 +367,8 @@
- /**
- * Adds a preset define.
- * <p>
- - * Preset defines do not depend upon any parameters to be activated,
- - * they are always passed to the shader as long as this technique is used.
- + * Preset defines do not depend upon any parameters to be activated, they
- + * are always passed to the shader as long as this technique is used.
- *
- * @param defineName The name of the define parameter, e.g. USE_LIGHTING
- * @param type The type of the define. See
- @@ -322,7 +377,7 @@
- *
- * @param value The value of the define
- */
- - public void addShaderPresetDefine(String defineName, VarType type, Object value){
- + public void addShaderPresetDefine(String defineName, VarType type, Object value) {
- if (presetDefines == null) {
- presetDefines = new DefineList();
- }
- @@ -330,8 +385,8 @@
- }
- /**
- - * Returns the name of the fragment shader used by the technique, or null
- - * if no fragment shader is specified.
- + * Returns the name of the fragment shader used by the technique, or null if
- + * no fragment shader is specified.
- *
- * @return the name of the fragment shader to be used.
- */
- @@ -339,10 +394,9 @@
- return fragName;
- }
- -
- /**
- - * Returns the name of the vertex shader used by the technique, or null
- - * if no vertex shader is specified.
- + * Returns the name of the vertex shader used by the technique, or null if
- + * no vertex shader is specified.
- *
- * @return the name of the vertex shader to be used.
- */
- @@ -372,22 +426,34 @@
- return vertLanguage;
- }
- + public String getGeometryShaderLanguage() {
- + return geomLanguage;
- + }
- +
- + public String getTessControlShaderLanguage() {
- + return tcLanguage;
- + }
- +
- + public String getTessEvaluationShaderLanguage() {
- + return teLanguage;
- + }
- +
- /**
- * Adds a new world parameter by the given name.
- *
- * @param name The world parameter to add.
- - * @return True if the world parameter name was found and added
- - * to the list of world parameters, false otherwise.
- + * @return True if the world parameter name was found and added to the list
- + * of world parameters, false otherwise.
- */
- public boolean addWorldParam(String name) {
- - if (worldBinds == null){
- + if (worldBinds == null) {
- worldBinds = new ArrayList<UniformBinding>();
- }
- try {
- - worldBinds.add( UniformBinding.valueOf(name) );
- + worldBinds.add(UniformBinding.valueOf(name));
- return true;
- - } catch (IllegalArgumentException ex){
- + } catch (IllegalArgumentException ex) {
- return false;
- }
- }
- @@ -401,8 +467,8 @@
- }
- /**
- - * Returns a list of world parameters that are used by this
- - * technique definition.
- + * Returns a list of world parameters that are used by this technique
- + * definition.
- *
- * @return The list of world parameters
- */
- @@ -410,20 +476,26 @@
- return worldBinds;
- }
- - public void write(JmeExporter ex) throws IOException{
- + public void write(JmeExporter ex) throws IOException {
- OutputCapsule oc = ex.getCapsule(this);
- oc.write(name, "name", null);
- oc.write(vertName, "vertName", null);
- oc.write(fragName, "fragName", null);
- + oc.write(geomName, "geomName", null);
- + oc.write(tcName, "tcName", null);
- + oc.write(teName, "teName", null);
- oc.write(vertLanguage, "vertLanguage", null);
- oc.write(vertLanguage, "fragLanguage", null);
- + oc.write(geomLanguage, "geomLanguage", null);
- + oc.write(tcLanguage, "tcLanguage", null);
- + oc.write(teLanguage, "teLanguage", null);
- oc.write(presetDefines, "presetDefines", null);
- oc.write(lightMode, "lightMode", LightMode.Disable);
- oc.write(shadowMode, "shadowMode", ShadowMode.Disable);
- oc.write(renderState, "renderState", null);
- oc.write(usesShaders, "usesShaders", false);
- oc.write(usesNodes, "usesNodes", false);
- - oc.writeSavableArrayList((ArrayList)shaderNodes,"shaderNodes", null);
- + oc.writeSavableArrayList((ArrayList) shaderNodes, "shaderNodes", null);
- oc.write(shaderGenerationInfo, "shaderGenerationInfo", null);
- // TODO: Finish this when Map<String, String> export is available
- @@ -432,7 +504,7 @@
- // oc.write(worldBinds, "worldBinds", null);
- }
- - public void read(JmeImporter im) throws IOException{
- + public void read(JmeImporter im) throws IOException {
- InputCapsule ic = im.getCapsule(this);
- name = ic.readString("name", null);
- vertName = ic.readString("vertName", null);
- Index: src/core/com/jme3/renderer/Caps.java
- --- src/core/com/jme3/renderer/Caps.java Base (BASE)
- +++ src/core/com/jme3/renderer/Caps.java Locally Modified (Based On LOCAL)
- @@ -106,6 +106,7 @@
- */
- OpenGL32,
- + OpenGL40,
- /**
- * Supports OpenGL ARB program.
- * <p>
- @@ -149,6 +150,7 @@
- */
- GLSL330,
- + GLSL400,
- /**
- * Supports reading from textures inside the vertex shader.
- */
- @@ -158,6 +160,7 @@
- * Supports geometry shader.
- */
- GeometryShader,
- + TesselationShader,
- /**
- * Supports texture arrays
- Index: src/core/com/jme3/scene/Mesh.java
- --- src/core/com/jme3/scene/Mesh.java Base (BASE)
- +++ src/core/com/jme3/scene/Mesh.java Locally Modified (Based On LOCAL)
- @@ -57,15 +57,15 @@
- /**
- * <code>Mesh</code> is used to store rendering data.
- * <p>
- - * All visible elements in a scene are represented by meshes.
- - * Meshes may contain three types of geometric primitives:
- + * All visible elements in a scene are represented by meshes. Meshes may contain
- + * three types of geometric primitives:
- * <ul>
- - * <li>Points - Every vertex represents a single point in space,
- - * the size of each point is specified via {@link Mesh#setPointSize(float) }.
- - * Points can also be used for {@link RenderState#setPointSprite(boolean) point
- + * <li>Points - Every vertex represents a single point in space, the size of
- + * each point is specified via {@link Mesh#setPointSize(float) }. Points can
- + * also be used for {@link RenderState#setPointSprite(boolean) point
- * sprite} mode.</li>
- - * <li>Lines - 2 vertices represent a line segment, with the width specified
- - * via {@link Mesh#setLineWidth(float) }.</li>
- + * <li>Lines - 2 vertices represent a line segment, with the width specified via {@link Mesh#setLineWidth(float)
- + * }.</li>
- * <li>Triangles - 3 vertices represent a solid triangle primitive. </li>
- * </ul>
- *
- @@ -74,123 +74,109 @@
- public class Mesh implements Savable, Cloneable {
- /**
- - * The mode of the Mesh specifies both the type of primitive represented
- - * by the mesh and how the data should be interpreted.
- + * The mode of the Mesh specifies both the type of primitive represented by
- + * the mesh and how the data should be interpreted.
- */
- public enum Mode {
- +
- /**
- - * A primitive is a single point in space. The size of the points
- - * can be specified with {@link Mesh#setPointSize(float) }.
- + * A primitive is a single point in space. The size of the points can be
- + * specified with {@link Mesh#setPointSize(float) }.
- */
- Points(true),
- -
- /**
- - * A primitive is a line segment. Every two vertices specify
- - * a single line. {@link Mesh#setLineWidth(float) } can be used
- - * to set the width of the lines.
- + * A primitive is a line segment. Every two vertices specify a single
- + * line. {@link Mesh#setLineWidth(float) } can be used to set the width
- + * of the lines.
- */
- Lines(true),
- -
- /**
- - * A primitive is a line segment. The first two vertices specify
- - * a single line, while subsequent vertices are combined with the
- - * previous vertex to make a line. {@link Mesh#setLineWidth(float) } can
- - * be used to set the width of the lines.
- + * A primitive is a line segment. The first two vertices specify a
- + * single line, while subsequent vertices are combined with the previous
- + * vertex to make a line. {@link Mesh#setLineWidth(float) } can be used
- + * to set the width of the lines.
- */
- LineStrip(false),
- -
- /**
- - * Identical to {@link #LineStrip} except that at the end
- - * the last vertex is connected with the first to form a line.
- - * {@link Mesh#setLineWidth(float) } can be used
- - * to set the width of the lines.
- + * Identical to {@link #LineStrip} except that at the end the last
- + * vertex is connected with the first to form a line.
- + * {@link Mesh#setLineWidth(float) } can be used to set the width of the
- + * lines.
- */
- LineLoop(false),
- -
- /**
- - * A primitive is a triangle. Each 3 vertices specify a single
- - * triangle.
- + * A primitive is a triangle. Each 3 vertices specify a single triangle.
- */
- Triangles(true),
- -
- /**
- - * Similar to {@link #Triangles}, the first 3 vertices
- - * specify a triangle, while subsequent vertices are combined with
- - * the previous two to form a triangle.
- + * Similar to {@link #Triangles}, the first 3 vertices specify a
- + * triangle, while subsequent vertices are combined with the previous
- + * two to form a triangle.
- */
- TriangleStrip(false),
- -
- /**
- - * Similar to {@link #Triangles}, the first 3 vertices
- - * specify a triangle, each 2 subsequent vertices are combined
- - * with the very first vertex to make a triangle.
- + * Similar to {@link #Triangles}, the first 3 vertices specify a
- + * triangle, each 2 subsequent vertices are combined with the very first
- + * vertex to make a triangle.
- */
- TriangleFan(false),
- -
- /**
- - * A combination of various triangle modes. It is best to avoid
- - * using this mode as it may not be supported by all renderers.
- - * The {@link Mesh#setModeStart(int[]) mode start points} and
- - * {@link Mesh#setElementLengths(int[]) element lengths} must
- - * be specified for this mode.
- + * A combination of various triangle modes. It is best to avoid using
- + * this mode as it may not be supported by all renderers. The
- + * {@link Mesh#setModeStart(int[]) mode start points} and
- + * {@link Mesh#setElementLengths(int[]) element lengths} must be
- + * specified for this mode.
- */
- - Hybrid(false);
- -
- + Hybrid(false),
- + Patches(true);
- private boolean listMode = false;
- - private Mode(boolean listMode){
- + private Mode(boolean listMode) {
- this.listMode = listMode;
- }
- /**
- - * Returns true if the specified mode is a list mode (meaning
- - * ,it specifies the indices as a linear list and not some special
- - * format).
- + * Returns true if the specified mode is a list mode (meaning ,it
- + * specifies the indices as a linear list and not some special format).
- * Will return true for the types {@link #Points}, {@link #Lines} and
- * {@link #Triangles}.
- *
- * @return true if the mode is a list type mode
- */
- - public boolean isListMode(){
- + public boolean isListMode() {
- return listMode;
- }
- }
- -
- /**
- - * The bounding volume that contains the mesh entirely.
- - * By default a BoundingBox (AABB).
- + * The bounding volume that contains the mesh entirely. By default a
- + * BoundingBox (AABB).
- */
- - private BoundingVolume meshBound = new BoundingBox();
- -
- + private BoundingVolume meshBound = new BoundingBox();
- private CollisionData collisionTree = null;
- -
- private SafeArrayList<VertexBuffer> buffersList = new SafeArrayList<VertexBuffer>(VertexBuffer.class);
- private IntMap<VertexBuffer> buffers = new IntMap<VertexBuffer>();
- private VertexBuffer[] lodLevels;
- private float pointSize = 1;
- private float lineWidth = 1;
- -
- private transient int vertexArrayID = -1;
- -
- + private int patchVertices = 3;
- private int vertCount = -1;
- private int elementCount = -1;
- private int maxNumWeights = -1; // only if using skeletal animation
- -
- private int[] elementLengths;
- private int[] modeStart;
- -
- private Mode mode = Mode.Triangles;
- /**
- * Creates a new mesh with no {@link VertexBuffer vertex buffers}.
- */
- - public Mesh(){
- + public Mesh() {
- }
- /**
- * Create a shallow clone of this Mesh. The {@link VertexBuffer vertex
- - * buffers} are shared between this and the clone mesh, the rest
- - * of the data is cloned.
- + * buffers} are shared between this and the clone mesh, the rest of the data
- + * is cloned.
- *
- * @return A shallow clone of the mesh
- */
- @@ -201,7 +187,7 @@
- clone.meshBound = meshBound.clone();
- clone.collisionTree = collisionTree != null ? collisionTree : null;
- clone.buffers = buffers.clone();
- - clone.buffersList = new SafeArrayList<VertexBuffer>(VertexBuffer.class,buffersList);
- + clone.buffersList = new SafeArrayList<VertexBuffer>(VertexBuffer.class, buffersList);
- clone.vertexArrayID = -1;
- if (elementLengths != null) {
- clone.elementLengths = elementLengths.clone();
- @@ -216,14 +202,13 @@
- }
- /**
- - * Creates a deep clone of this mesh.
- - * The {@link VertexBuffer vertex buffers} and the data inside them
- - * is cloned.
- + * Creates a deep clone of this mesh. The
- + * {@link VertexBuffer vertex buffers} and the data inside them is cloned.
- *
- * @return a deep clone of this mesh.
- */
- - public Mesh deepClone(){
- - try{
- + public Mesh deepClone() {
- + try {
- Mesh clone = (Mesh) super.clone();
- clone.meshBound = meshBound != null ? meshBound.clone() : null;
- @@ -233,7 +218,7 @@
- clone.buffers = new IntMap<VertexBuffer>();
- clone.buffersList = new SafeArrayList<VertexBuffer>(VertexBuffer.class);
- - for (VertexBuffer vb : buffersList.getArray()){
- + for (VertexBuffer vb : buffersList.getArray()) {
- VertexBuffer bufClone = vb.clone();
- clone.buffers.put(vb.getBufferType().ordinal(), bufClone);
- clone.buffersList.add(bufClone);
- @@ -250,23 +235,22 @@
- clone.elementLengths = elementLengths != null ? elementLengths.clone() : null;
- clone.modeStart = modeStart != null ? modeStart.clone() : null;
- return clone;
- - }catch (CloneNotSupportedException ex){
- + } catch (CloneNotSupportedException ex) {
- throw new AssertionError();
- }
- }
- /**
- - * Clone the mesh for animation use.
- - * This creates a shallow clone of the mesh, sharing most
- - * of the {@link VertexBuffer vertex buffer} data, however the
- - * {@link Type#Position}, {@link Type#Normal}, and {@link Type#Tangent} buffers
- - * are deeply cloned.
- + * Clone the mesh for animation use. This creates a shallow clone of the
- + * mesh, sharing most of the {@link VertexBuffer vertex buffer} data,
- + * however the {@link Type#Position}, {@link Type#Normal}, and
- + * {@link Type#Tangent} buffers are deeply cloned.
- *
- * @return A clone of the mesh for animation use.
- */
- - public Mesh cloneForAnim(){
- + public Mesh cloneForAnim() {
- Mesh clone = clone();
- - if (getBuffer(Type.BindPosePosition) != null){
- + if (getBuffer(Type.BindPosePosition) != null) {
- VertexBuffer oldPos = getBuffer(Type.Position);
- // NOTE: creates deep clone
- @@ -274,13 +258,13 @@
- clone.clearBuffer(Type.Position);
- clone.setBuffer(newPos);
- - if (getBuffer(Type.BindPoseNormal) != null){
- + if (getBuffer(Type.BindPoseNormal) != null) {
- VertexBuffer oldNorm = getBuffer(Type.Normal);
- VertexBuffer newNorm = oldNorm.clone();
- clone.clearBuffer(Type.Normal);
- clone.setBuffer(newNorm);
- - if (getBuffer(Type.BindPoseTangent) != null){
- + if (getBuffer(Type.BindPoseTangent) != null) {
- VertexBuffer oldTang = getBuffer(Type.Tangent);
- VertexBuffer newTang = oldTang.clone();
- clone.clearBuffer(Type.Tangent);
- @@ -293,16 +277,15 @@
- /**
- * Generates the {@link Type#BindPosePosition}, {@link Type#BindPoseNormal},
- - * and {@link Type#BindPoseTangent}
- - * buffers for this mesh by duplicating them based on the position and normal
- - * buffers already set on the mesh.
- - * This method does nothing if the mesh has no bone weight or index
- - * buffers.
- + * and {@link Type#BindPoseTangent} buffers for this mesh by duplicating
- + * them based on the position and normal buffers already set on the mesh.
- + * This method does nothing if the mesh has no bone weight or index buffers.
- *
- - * @param forSoftwareAnim Should be true if the bind pose is to be generated.
- + * @param forSoftwareAnim Should be true if the bind pose is to be
- + * generated.
- */
- - public void generateBindPose(boolean forSoftwareAnim){
- - if (forSoftwareAnim){
- + public void generateBindPose(boolean forSoftwareAnim) {
- + if (forSoftwareAnim) {
- VertexBuffer pos = getBuffer(Type.Position);
- if (pos == null || getBuffer(Type.BoneIndex) == null) {
- // ignore, this mesh doesn't have positional data
- @@ -346,12 +329,12 @@
- }
- /**
- - * Prepares the mesh for software skinning by converting the bone index
- - * and weight buffers to heap buffers.
- + * Prepares the mesh for software skinning by converting the bone index and
- + * weight buffers to heap buffers.
- *
- * @param forSoftwareAnim Should be true to enable the conversion.
- */
- - public void prepareForAnim(boolean forSoftwareAnim){
- + public void prepareForAnim(boolean forSoftwareAnim) {
- if (forSoftwareAnim) {
- // convert indices to ubytes on the heap
- VertexBuffer indices = getBuffer(Type.BoneIndex);
- @@ -389,7 +372,7 @@
- //if HWBoneIndex and HWBoneWieght are empty, we setup them as direct
- //buffers with software anim buffers data
- VertexBuffer indicesHW = getBuffer(Type.HWBoneIndex);
- - if(indicesHW.getData() == null){
- + if (indicesHW.getData() == null) {
- VertexBuffer indices = getBuffer(Type.BoneIndex);
- ByteBuffer originalIndex = (ByteBuffer) indices.getData();
- ByteBuffer directIndex = BufferUtils.createByteBuffer(originalIndex.capacity());
- @@ -399,7 +382,7 @@
- }
- VertexBuffer weightsHW = getBuffer(Type.HWBoneWeight);
- - if(weightsHW.getData() == null){
- + if (weightsHW.getData() == null) {
- VertexBuffer weights = getBuffer(Type.BoneWeight);
- FloatBuffer originalWeight = (FloatBuffer) weights.getData();
- FloatBuffer directWeight = BufferUtils.createFloatBuffer(originalWeight.capacity());
- @@ -427,7 +410,7 @@
- *
- * @param lodLevels The LOD levels to set
- */
- - public void setLodLevels(VertexBuffer[] lodLevels){
- + public void setLodLevels(VertexBuffer[] lodLevels) {
- this.lodLevels = lodLevels;
- }
- @@ -435,23 +418,23 @@
- * @return The number of LOD levels set on this mesh, including the main
- * index buffer, returns zero if there are no lod levels.
- */
- - public int getNumLodLevels(){
- + public int getNumLodLevels() {
- return lodLevels != null ? lodLevels.length : 0;
- }
- /**
- * Returns the lod level at the given index.
- *
- - * @param lod The lod level index, this does not include
- - * the main index buffer.
- + * @param lod The lod level index, this does not include the main index
- + * buffer.
- * @return The LOD index buffer at the index
- *
- - * @throws IndexOutOfBoundsException If the index is outside of the
- - * range [0, {@link #getNumLodLevels()}].
- + * @throws IndexOutOfBoundsException If the index is outside of the range
- + * [0, {@link #getNumLodLevels()}].
- *
- * @see #setLodLevels(com.jme3.scene.VertexBuffer[])
- */
- - public VertexBuffer getLodLevel(int lod){
- + public VertexBuffer getLodLevel(int lod) {
- return lodLevels[lod];
- }
- @@ -524,9 +507,9 @@
- }
- /**
- - * Set the maximum number of weights per vertex on this mesh.
- - * Only relevant if this mesh has bone index/weight buffers.
- - * This value should be between 0 and 4.
- + * Set the maximum number of weights per vertex on this mesh. Only relevant
- + * if this mesh has bone index/weight buffers. This value should be between
- + * 0 and 4.
- *
- * @param maxNumWeights
- */
- @@ -546,12 +529,13 @@
- }
- /**
- - * Set the size of points for meshes of mode {@link Mode#Points}.
- - * The point size is specified as on-screen pixels, the default
- - * value is 1.0. The point size
- - * does nothing if {@link RenderState#setPointSprite(boolean) point sprite}
- - * render state is enabled, in that case, the vertex shader must specify the
- - * point size by writing to <code>gl_PointSize</code>.
- + * Set the size of points for meshes of mode {@link Mode#Points}. The point
- + * size is specified as on-screen pixels, the default value is 1.0. The
- + * point size does nothing if
- + * {@link RenderState#setPointSprite(boolean) point sprite} render state is
- + * enabled, in that case, the vertex shader must specify the point size by
- + * writing to
- + * <code>gl_PointSize</code>.
- *
- * @param pointSize The size of points
- */
- @@ -569,9 +553,9 @@
- }
- /**
- - * Specify the line width for meshes of the line modes, such
- - * as {@link Mode#Lines}. The line width is specified as on-screen pixels,
- - * the default value is 1.0.
- + * Specify the line width for meshes of the line modes, such as
- + * {@link Mode#Lines}. The line width is specified as on-screen pixels, the
- + * default value is 1.0.
- *
- * @param lineWidth The line width
- */
- @@ -580,34 +564,34 @@
- }
- /**
- - * Indicates to the GPU that this mesh will not be modified (a hint).
- - * Sets the usage mode to {@link Usage#Static}
- - * for all {@link VertexBuffer vertex buffers} on this Mesh.
- + * Indicates to the GPU that this mesh will not be modified (a hint). Sets
- + * the usage mode to {@link Usage#Static} for all
- + * {@link VertexBuffer vertex buffers} on this Mesh.
- */
- public void setStatic() {
- - for (VertexBuffer vb : buffersList.getArray()){
- + for (VertexBuffer vb : buffersList.getArray()) {
- vb.setUsage(Usage.Static);
- }
- }
- /**
- - * Indicates to the GPU that this mesh will be modified occasionally (a hint).
- - * Sets the usage mode to {@link Usage#Dynamic}
- - * for all {@link VertexBuffer vertex buffers} on this Mesh.
- + * Indicates to the GPU that this mesh will be modified occasionally (a
- + * hint). Sets the usage mode to {@link Usage#Dynamic} for all
- + * {@link VertexBuffer vertex buffers} on this Mesh.
- */
- public void setDynamic() {
- - for (VertexBuffer vb : buffersList.getArray()){
- + for (VertexBuffer vb : buffersList.getArray()) {
- vb.setUsage(Usage.Dynamic);
- }
- }
- /**
- - * Indicates to the GPU that this mesh will be modified every frame (a hint).
- - * Sets the usage mode to {@link Usage#Stream}
- - * for all {@link VertexBuffer vertex buffers} on this Mesh.
- + * Indicates to the GPU that this mesh will be modified every frame (a
- + * hint). Sets the usage mode to {@link Usage#Stream} for all
- + * {@link VertexBuffer vertex buffers} on this Mesh.
- */
- - public void setStreamed(){
- - for (VertexBuffer vb : buffersList.getArray()){
- + public void setStreamed() {
- + for (VertexBuffer vb : buffersList.getArray()) {
- vb.setUsage(Usage.Stream);
- }
- }
- @@ -618,7 +602,7 @@
- * to <em>avoid</em> using this method as it disables some engine features.
- */
- @Deprecated
- - public void setInterleaved(){
- + public void setInterleaved() {
- ArrayList<VertexBuffer> vbs = new ArrayList<VertexBuffer>();
- vbs.addAll(buffersList);
- @@ -627,7 +611,7 @@
- vbs.remove(getBuffer(Type.Index));
- int stride = 0; // aka bytes per vertex
- - for (int i = 0; i < vbs.size(); i++){
- + for (int i = 0; i < vbs.size(); i++) {
- VertexBuffer vb = vbs.get(i);
- // if (vb.getFormat() != Format.Float){
- // throw new UnsupportedOperationException("Cannot interleave vertex buffer.\n" +
- @@ -645,20 +629,20 @@
- buffers.put(Type.InterleavedData.ordinal(), allData);
- buffersList.add(allData);
- - for (int vert = 0; vert < getVertexCount(); vert++){
- - for (int i = 0; i < vbs.size(); i++){
- + for (int vert = 0; vert < getVertexCount(); vert++) {
- + for (int i = 0; i < vbs.size(); i++) {
- VertexBuffer vb = vbs.get(i);
- - switch (vb.getFormat()){
- + switch (vb.getFormat()) {
- case Float:
- FloatBuffer fb = (FloatBuffer) vb.getData();
- - for (int comp = 0; comp < vb.components; comp++){
- + for (int comp = 0; comp < vb.components; comp++) {
- dataBuf.putFloat(fb.get());
- }
- break;
- case Byte:
- case UnsignedByte:
- ByteBuffer bb = (ByteBuffer) vb.getData();
- - for (int comp = 0; comp < vb.components; comp++){
- + for (int comp = 0; comp < vb.components; comp++) {
- dataBuf.put(bb.get());
- }
- break;
- @@ -666,20 +650,20 @@
- case Short:
- case UnsignedShort:
- ShortBuffer sb = (ShortBuffer) vb.getData();
- - for (int comp = 0; comp < vb.components; comp++){
- + for (int comp = 0; comp < vb.components; comp++) {
- dataBuf.putShort(sb.get());
- }
- break;
- case Int:
- case UnsignedInt:
- IntBuffer ib = (IntBuffer) vb.getData();
- - for (int comp = 0; comp < vb.components; comp++){
- + for (int comp = 0; comp < vb.components; comp++) {
- dataBuf.putInt(ib.get());
- }
- break;
- case Double:
- DoubleBuffer db = (DoubleBuffer) vb.getData();
- - for (int comp = 0; comp < vb.components; comp++){
- + for (int comp = 0; comp < vb.components; comp++) {
- dataBuf.putDouble(db.get());
- }
- break;
- @@ -688,7 +672,7 @@
- }
- int offset = 0;
- - for (VertexBuffer vb : vbs){
- + for (VertexBuffer vb : vbs) {
- vb.setOffset(offset);
- vb.setStride(stride);
- @@ -698,8 +682,8 @@
- }
- }
- - private int computeNumElements(int bufSize){
- - switch (mode){
- + private int computeNumElements(int bufSize) {
- + switch (mode) {
- case Triangles:
- return bufSize / 3;
- case TriangleFan:
- @@ -713,6 +697,8 @@
- return bufSize;
- case LineStrip:
- return bufSize - 1;
- + case Patches:
- + return bufSize-1;
- default:
- throw new UnsupportedOperationException();
- }
- @@ -720,26 +706,27 @@
- /**
- * Update the {@link #getVertexCount() vertex} and
- - * {@link #getTriangleCount() triangle} counts for this mesh
- - * based on the current data. This method should be called
- - * after the {@link Buffer#capacity() capacities} of the mesh's
- + * {@link #getTriangleCount() triangle} counts for this mesh based on the
- + * current data. This method should be called after the
- + * {@link Buffer#capacity() capacities} of the mesh's
- * {@link VertexBuffer vertex buffers} has been altered.
- *
- * @throws IllegalStateException If this mesh is in
- * {@link #setInterleaved() interleaved} format.
- */
- - public void updateCounts(){
- - if (getBuffer(Type.InterleavedData) != null)
- + public void updateCounts() {
- + if (getBuffer(Type.InterleavedData) != null) {
- throw new IllegalStateException("Should update counts before interleave");
- + }
- VertexBuffer pb = getBuffer(Type.Position);
- VertexBuffer ib = getBuffer(Type.Index);
- - if (pb != null){
- + if (pb != null) {
- vertCount = pb.getData().limit() / pb.getNumComponents();
- }
- - if (ib != null){
- + if (ib != null) {
- elementCount = computeNumElements(ib.getData().limit());
- - }else{
- + } else {
- elementCount = computeNumElements(vertCount);
- }
- }
- @@ -750,167 +737,166 @@
- * @param lod The lod level to look up
- * @return The triangle count for that LOD level
- */
- - public int getTriangleCount(int lod){
- - if (lodLevels != null){
- - if (lod < 0)
- + public int getTriangleCount(int lod) {
- + if (lodLevels != null) {
- + if (lod < 0) {
- throw new IllegalArgumentException("LOD level cannot be < 0");
- + }
- - if (lod >= lodLevels.length)
- - throw new IllegalArgumentException("LOD level "+lod+" does not exist!");
- + if (lod >= lodLevels.length) {
- + throw new IllegalArgumentException("LOD level " + lod + " does not exist!");
- + }
- return computeNumElements(lodLevels[lod].getData().limit());
- - }else if (lod == 0){
- + } else if (lod == 0) {
- return elementCount;
- - }else{
- + } else {
- throw new IllegalArgumentException("There are no LOD levels on the mesh!");
- }
- }
- /**
- - * Returns how many triangles or elements are on this Mesh.
- - * This value is only updated when {@link #updateCounts() } is called.
- - * If the mesh mode is not a triangle mode, then this returns the
- - * number of elements/primitives, e.g. how many lines or how many points,
- - * instead of how many triangles.
- + * Returns how many triangles or elements are on this Mesh. This value is
- + * only updated when {@link #updateCounts() } is called. If the mesh mode is
- + * not a triangle mode, then this returns the number of elements/primitives,
- + * e.g. how many lines or how many points, instead of how many triangles.
- *
- * @return how many triangles/elements are on this Mesh.
- */
- - public int getTriangleCount(){
- + public int getTriangleCount() {
- return elementCount;
- }
- /**
- - * Returns the number of vertices on this mesh.
- - * The value is computed based on the position buffer, which
- - * must be set on all meshes.
- + * Returns the number of vertices on this mesh. The value is computed based
- + * on the position buffer, which must be set on all meshes.
- *
- * @return Number of vertices on the mesh
- */
- - public int getVertexCount(){
- + public int getVertexCount() {
- return vertCount;
- }
- /**
- - * Gets the triangle vertex positions at the given triangle index
- - * and stores them into the v1, v2, v3 arguments.
- + * Gets the triangle vertex positions at the given triangle index and stores
- + * them into the v1, v2, v3 arguments.
- *
- - * @param index The index of the triangle.
- - * Should be between 0 and {@link #getTriangleCount()}.
- + * @param index The index of the triangle. Should be between 0 and
- + * {@link #getTriangleCount()}.
- *
- * @param v1 Vector to contain first vertex position
- * @param v2 Vector to contain second vertex position
- * @param v3 Vector to contain third vertex position
- */
- - public void getTriangle(int index, Vector3f v1, Vector3f v2, Vector3f v3){
- + public void getTriangle(int index, Vector3f v1, Vector3f v2, Vector3f v3) {
- VertexBuffer pb = getBuffer(Type.Position);
- IndexBuffer ib = getIndicesAsList();
- - if (pb != null && pb.getFormat() == Format.Float && pb.getNumComponents() == 3){
- + if (pb != null && pb.getFormat() == Format.Float && pb.getNumComponents() == 3) {
- FloatBuffer fpb = (FloatBuffer) pb.getData();
- // aquire triangle's vertex indices
- int vertIndex = index * 3;
- int vert1 = ib.get(vertIndex);
- - int vert2 = ib.get(vertIndex+1);
- - int vert3 = ib.get(vertIndex+2);
- + int vert2 = ib.get(vertIndex + 1);
- + int vert3 = ib.get(vertIndex + 2);
- BufferUtils.populateFromBuffer(v1, fpb, vert1);
- BufferUtils.populateFromBuffer(v2, fpb, vert2);
- BufferUtils.populateFromBuffer(v3, fpb, vert3);
- - }else{
- + } else {
- throw new UnsupportedOperationException("Position buffer not set or "
- + " has incompatible format");
- }
- }
- /**
- - * Gets the triangle vertex positions at the given triangle index
- - * and stores them into the {@link Triangle} argument.
- - * Also sets the triangle index to the <code>index</code> argument.
- + * Gets the triangle vertex positions at the given triangle index and stores
- + * them into the {@link Triangle} argument. Also sets the triangle index to
- + * the
- + * <code>index</code> argument.
- *
- - * @param index The index of the triangle.
- - * Should be between 0 and {@link #getTriangleCount()}.
- + * @param index The index of the triangle. Should be between 0 and
- + * {@link #getTriangleCount()}.
- *
- * @param tri The triangle to store the positions in
- */
- - public void getTriangle(int index, Triangle tri){
- + public void getTriangle(int index, Triangle tri) {
- getTriangle(index, tri.get1(), tri.get2(), tri.get3());
- tri.setIndex(index);
- tri.setNormal(null);
- }
- /**
- - * Gets the triangle vertex indices at the given triangle index
- - * and stores them into the given int array.
- + * Gets the triangle vertex indices at the given triangle index and stores
- + * them into the given int array.
- *
- - * @param index The index of the triangle.
- - * Should be between 0 and {@link #getTriangleCount()}.
- + * @param index The index of the triangle. Should be between 0 and
- + * {@link #getTriangleCount()}.
- *
- * @param indices Indices of the triangle's vertices
- */
- - public void getTriangle(int index, int[] indices){
- + public void getTriangle(int index, int[] indices) {
- IndexBuffer ib = getIndicesAsList();
- // acquire triangle's vertex indices
- int vertIndex = index * 3;
- indices[0] = ib.get(vertIndex);
- - indices[1] = ib.get(vertIndex+1);
- - indices[2] = ib.get(vertIndex+2);
- + indices[1] = ib.get(vertIndex + 1);
- + indices[2] = ib.get(vertIndex + 2);
- }
- /**
- * Returns the mesh's VAO ID. Internal use only.
- */
- - public int getId(){
- + public int getId() {
- return vertexArrayID;
- }
- /**
- * Sets the mesh's VAO ID. Internal use only.
- */
- - public void setId(int id){
- - if (vertexArrayID != -1)
- + public void setId(int id) {
- + if (vertexArrayID != -1) {
- throw new IllegalStateException("ID has already been set.");
- + }
- vertexArrayID = id;
- }
- /**
- - * Generates a collision tree for the mesh.
- - * Called automatically by {@link #collideWith(com.jme3.collision.Collidable,
- + * Generates a collision tree for the mesh. Called automatically by {@link #collideWith(com.jme3.collision.Collidable,
- * com.jme3.math.Matrix4f,
- * com.jme3.bounding.BoundingVolume,
- * com.jme3.collision.CollisionResults) }.
- */
- - public void createCollisionData(){
- + public void createCollisionData() {
- BIHTree tree = new BIHTree(this);
- tree.construct();
- collisionTree = tree;
- }
- /**
- - * Clears any previously generated collision data. Use this if
- - * the mesh has changed in some way that invalidates any previously
- - * generated BIHTree.
- + * Clears any previously generated collision data. Use this if the mesh has
- + * changed in some way that invalidates any previously generated BIHTree.
- */
- public void clearCollisionData() {
- collisionTree = null;
- }
- /**
- - * Handles collision detection, internal use only.
- - * User code should only use collideWith() on scene
- - * graph elements such as {@link Spatial}s.
- + * Handles collision detection, internal use only. User code should only use
- + * collideWith() on scene graph elements such as {@link Spatial}s.
- */
- public int collideWith(Collidable other,
- Matrix4f worldMatrix,
- BoundingVolume worldBound,
- - CollisionResults results){
- + CollisionResults results) {
- if (getVertexCount() == 0) {
- return 0;
- }
- - if (collisionTree == null){
- + if (collisionTree == null) {
- createCollisionData();
- }
- @@ -918,15 +904,16 @@
- }
- /**
- - * Sets the {@link VertexBuffer} on the mesh.
- - * This will update the vertex/triangle counts if needed.
- + * Sets the {@link VertexBuffer} on the mesh. This will update the
- + * vertex/triangle counts if needed.
- *
- * @param vb The buffer to set
- * @throws IllegalArgumentException If the buffer type is already set
- */
- - public void setBuffer(VertexBuffer vb){
- - if (buffers.containsKey(vb.getBufferType().ordinal()))
- - throw new IllegalArgumentException("Buffer type already set: "+vb.getBufferType());
- + public void setBuffer(VertexBuffer vb) {
- + if (buffers.containsKey(vb.getBufferType().ordinal())) {
- + throw new IllegalArgumentException("Buffer type already set: " + vb.getBufferType());
- + }
- buffers.put(vb.getBufferType().ordinal(), vb);
- buffersList.add(vb);
- @@ -934,23 +921,22 @@
- }
- /**
- - * Unsets the {@link VertexBuffer} set on this mesh
- - * with the given type. Does nothing if the vertex buffer type is not set
- - * initially.
- + * Unsets the {@link VertexBuffer} set on this mesh with the given type.
- + * Does nothing if the vertex buffer type is not set initially.
- *
- * @param type The buffer type to remove
- */
- - public void clearBuffer(VertexBuffer.Type type){
- + public void clearBuffer(VertexBuffer.Type type) {
- VertexBuffer vb = buffers.remove(type.ordinal());
- - if (vb != null){
- + if (vb != null) {
- buffersList.remove(vb);
- updateCounts();
- }
- }
- /**
- - * Creates a {@link VertexBuffer} for the mesh or modifies
- - * the existing one per the parameters given.
- + * Creates a {@link VertexBuffer} for the mesh or modifies the existing one
- + * per the parameters given.
- *
- * @param type The type of the buffer
- * @param components Number of components
- @@ -960,14 +946,14 @@
- * @throws UnsupportedOperationException If the buffer already set is
- * incompatible with the parameters given.
- */
- - public void setBuffer(Type type, int components, Format format, Buffer buf){
- + public void setBuffer(Type type, int components, Format format, Buffer buf) {
- VertexBuffer vb = buffers.get(type.ordinal());
- - if (vb == null){
- + if (vb == null) {
- vb = new VertexBuffer(type);
- vb.setupData(Usage.Dynamic, components, format, buf);
- setBuffer(vb);
- - }else{
- - if (vb.getNumComponents() != components || vb.getFormat() != format){
- + } else {
- + if (vb.getNumComponents() != components || vb.getFormat() != format) {
- throw new UnsupportedOperationException("The buffer already set "
- + "is incompatible with the given parameters");
- }
- @@ -979,11 +965,11 @@
- /**
- * Set a floating point {@link VertexBuffer} on the mesh.
- *
- - * @param type The type of {@link VertexBuffer},
- - * e.g. {@link Type#Position}, {@link Type#Normal}, etc.
- + * @param type The type of {@link VertexBuffer}, e.g.
- + * {@link Type#Position}, {@link Type#Normal}, etc.
- *
- - * @param components Number of components on the vertex buffer, should
- - * be between 1 and 4.
- + * @param components Number of components on the vertex buffer, should be
- + * between 1 and 4.
- *
- * @param buf The floating point data to contain
- */
- @@ -991,7 +977,7 @@
- setBuffer(type, components, Format.Float, buf);
- }
- - public void setBuffer(Type type, int components, float[] buf){
- + public void setBuffer(Type type, int components, float[] buf) {
- setBuffer(type, components, BufferUtils.createFloatBuffer(buf));
- }
- @@ -999,7 +985,7 @@
- setBuffer(type, components, Format.UnsignedInt, buf);
- }
- - public void setBuffer(Type type, int components, int[] buf){
- + public void setBuffer(Type type, int components, int[] buf) {
- setBuffer(type, components, BufferUtils.createIntBuffer(buf));
- }
- @@ -1007,7 +993,7 @@
- setBuffer(type, components, Format.UnsignedShort, buf);
- }
- - public void setBuffer(Type type, int components, byte[] buf){
- + public void setBuffer(Type type, int components, byte[] buf) {
- setBuffer(type, components, BufferUtils.createByteBuffer(buf));
- }
- @@ -1015,72 +1001,72 @@
- setBuffer(type, components, Format.UnsignedByte, buf);
- }
- - public void setBuffer(Type type, int components, short[] buf){
- + public void setBuffer(Type type, int components, short[] buf) {
- setBuffer(type, components, BufferUtils.createShortBuffer(buf));
- }
- /**
- - * Get the {@link VertexBuffer} stored on this mesh with the given
- - * type.
- + * Get the {@link VertexBuffer} stored on this mesh with the given type.
- *
- * @param type The type of VertexBuffer
- * @return the VertexBuffer data, or null if not set
- */
- - public VertexBuffer getBuffer(Type type){
- + public VertexBuffer getBuffer(Type type) {
- return buffers.get(type.ordinal());
- }
- /**
- - * Get the {@link VertexBuffer} data stored on this mesh in float
- - * format.
- + * Get the {@link VertexBuffer} data stored on this mesh in float format.
- *
- * @param type The type of VertexBuffer
- * @return the VertexBuffer data, or null if not set
- */
- public FloatBuffer getFloatBuffer(Type type) {
- VertexBuffer vb = getBuffer(type);
- - if (vb == null)
- + if (vb == null) {
- return null;
- + }
- return (FloatBuffer) vb.getData();
- }
- /**
- - * Get the {@link VertexBuffer} data stored on this mesh in short
- - * format.
- + * Get the {@link VertexBuffer} data stored on this mesh in short format.
- *
- * @param type The type of VertexBuffer
- * @return the VertexBuffer data, or null if not set
- */
- public ShortBuffer getShortBuffer(Type type) {
- VertexBuffer vb = getBuffer(type);
- - if (vb == null)
- + if (vb == null) {
- return null;
- + }
- return (ShortBuffer) vb.getData();
- }
- /**
- - * Acquires an index buffer that will read the vertices on the mesh
- - * as a list.
- + * Acquires an index buffer that will read the vertices on the mesh as a
- + * list.
- *
- * @return A virtual or wrapped index buffer to read the data as a list
- */
- - public IndexBuffer getIndicesAsList(){
- - if (mode == Mode.Hybrid)
- + public IndexBuffer getIndicesAsList() {
- + if (mode == Mode.Hybrid) {
- throw new UnsupportedOperationException("Hybrid mode not supported");
- + }
- IndexBuffer ib = getIndexBuffer();
- - if (ib != null){
- - if (mode.isListMode()){
- + if (ib != null) {
- + if (mode.isListMode()) {
- // already in list mode
- return ib;
- - }else{
- + } else {
- // not in list mode but it does have an index buffer
- // wrap it so the data is converted to list format
- return new WrappedIndexBuffer(this);
- }
- - }else{
- + } else {
- // return a virtual index buffer that will supply
- // "fake" indices in list format
- return new VirtualIndexBuffer(vertCount, mode);
- @@ -1088,8 +1074,8 @@
- }
- /**
- - * Get the index buffer for this mesh.
- - * Will return <code>null</code> if no index buffer is set.
- + * Get the index buffer for this mesh. Will return
- + * <code>null</code> if no index buffer is set.
- *
- * @return The index buffer of this mesh.
- *
- @@ -1097,18 +1083,27 @@
- */
- public IndexBuffer getIndexBuffer() {
- VertexBuffer vb = getBuffer(Type.Index);
- - if (vb == null)
- + if (vb == null) {
- return null;
- + }
- return IndexBuffer.wrapIndexBuffer(vb.getData());
- }
- + public int getPatchVertices() {
- + return patchVertices;
- + }
- +
- + public void setPatchVertices(int patchVertices) {
- + this.patchVertices = patchVertices;
- + }
- +
- /**
- - * Extracts the vertex attributes from the given mesh into
- - * this mesh, by using this mesh's {@link #getIndexBuffer() index buffer}
- - * to index into the attributes of the other mesh.
- - * Note that this will also change this mesh's index buffer so that
- - * the references to the vertex data match the new indices.
- + * Extracts the vertex attributes from the given mesh into this mesh, by
- + * using this mesh's {@link #getIndexBuffer() index buffer} to index into
- + * the attributes of the other mesh. Note that this will also change this
- + * mesh's index buffer so that the references to the vertex data match the
- + * new indices.
- *
- * @param other The mesh to extract the vertex data from
- */
- @@ -1185,7 +1180,7 @@
- //check for data before copying, some buffers are just empty shells
- //for caching purpose (HW skinning buffers), and will be filled when
- //needed
- - if(oldVb.getData()!=null){
- + if (oldVb.getData() != null) {
- // Create a new vertex buffer with similar configuration, but
- // with the capacity of number of unique vertices
- Buffer buffer = VertexBuffer.createBuffer(oldVb.getFormat(), oldVb.getNumComponents(), newNumVerts);
- @@ -1215,39 +1210,41 @@
- }
- /**
- - * Scales the texture coordinate buffer on this mesh by the given
- - * scale factor.
- + * Scales the texture coordinate buffer on this mesh by the given scale
- + * factor.
- * <p>
- - * Note that values above 1 will cause the
- - * texture to tile, while values below 1 will cause the texture
- - * to stretch.
- + * Note that values above 1 will cause the texture to tile, while values
- + * below 1 will cause the texture to stretch.
- * </p>
- *
- - * @param scaleFactor The scale factor to scale by. Every texture
- - * coordinate is multiplied by this vector to get the result.
- + * @param scaleFactor The scale factor to scale by. Every texture coordinate
- + * is multiplied by this vector to get the result.
- *
- - * @throws IllegalStateException If there's no texture coordinate
- - * buffer on the mesh
- - * @throws UnsupportedOperationException If the texture coordinate
- - * buffer is not in 2D float format.
- + * @throws IllegalStateException If there's no texture coordinate buffer on
- + * the mesh
- + * @throws UnsupportedOperationException If the texture coordinate buffer is
- + * not in 2D float format.
- */
- - public void scaleTextureCoordinates(Vector2f scaleFactor){
- + public void scaleTextureCoordinates(Vector2f scaleFactor) {
- VertexBuffer tc = getBuffer(Type.TexCoord);
- - if (tc == null)
- + if (tc == null) {
- throw new IllegalStateException("The mesh has no texture coordinates");
- + }
- - if (tc.getFormat() != VertexBuffer.Format.Float)
- + if (tc.getFormat() != VertexBuffer.Format.Float) {
- throw new UnsupportedOperationException("Only float texture coord format is supported");
- + }
- - if (tc.getNumComponents() != 2)
- + if (tc.getNumComponents() != 2) {
- throw new UnsupportedOperationException("Only 2D texture coords are supported");
- + }
- FloatBuffer fb = (FloatBuffer) tc.getData();
- fb.clear();
- - for (int i = 0; i < fb.limit() / 2; i++){
- + for (int i = 0; i < fb.limit() / 2; i++) {
- float x = fb.get();
- float y = fb.get();
- - fb.position(fb.position()-2);
- + fb.position(fb.position() - 2);
- x *= scaleFactor.getX();
- y *= scaleFactor.getY();
- fb.put(x).put(y);
- @@ -1257,20 +1254,20 @@
- }
- /**
- - * Updates the bounding volume of this mesh.
- - * The method does nothing if the mesh has no {@link Type#Position} buffer.
- - * It is expected that the position buffer is a float buffer with 3 components.
- + * Updates the bounding volume of this mesh. The method does nothing if the
- + * mesh has no {@link Type#Position} buffer. It is expected that the
- + * position buffer is a float buffer with 3 components.
- */
- - public void updateBound(){
- + public void updateBound() {
- VertexBuffer posBuf = getBuffer(VertexBuffer.Type.Position);
- - if (meshBound != null && posBuf != null){
- - meshBound.computeFromPoints((FloatBuffer)posBuf.getData());
- + if (meshBound != null && posBuf != null) {
- + meshBound.computeFromPoints((FloatBuffer) posBuf.getData());
- }
- }
- /**
- - * Returns the {@link BoundingVolume} of this Mesh.
- - * By default the bounding volume is a {@link BoundingBox}.
- + * Returns the {@link BoundingVolume} of this Mesh. By default the bounding
- + * volume is a {@link BoundingBox}.
- *
- * @return the bounding volume of this mesh
- */
- @@ -1279,8 +1276,8 @@
- }
- /**
- - * Sets the {@link BoundingVolume} for this Mesh.
- - * The bounding volume is recomputed by calling {@link #updateBound() }.
- + * Sets the {@link BoundingVolume} for this Mesh. The bounding volume is
- + * recomputed by calling {@link #updateBound() }.
- *
- * @param modelBound The model bound to set
- */
- @@ -1290,14 +1287,13 @@
- /**
- * Returns a map of all {@link VertexBuffer vertex buffers} on this Mesh.
- - * The integer key for the map is the {@link Enum#ordinal() ordinal}
- - * of the vertex buffer's {@link Type}.
- - * Note that the returned map is a reference to the map used internally,
- - * modifying it will cause undefined results.
- + * The integer key for the map is the {@link Enum#ordinal() ordinal} of the
- + * vertex buffer's {@link Type}. Note that the returned map is a reference
- + * to the map used internally, modifying it will cause undefined results.
- *
- * @return map of vertex buffers on this mesh.
- */
- - public IntMap<VertexBuffer> getBuffers(){
- + public IntMap<VertexBuffer> getBuffers() {
- return buffers;
- }
- @@ -1310,7 +1306,7 @@
- *
- * @return list of vertex buffers on this mesh.
- */
- - public SafeArrayList<VertexBuffer> getBufferList(){
- + public SafeArrayList<VertexBuffer> getBufferList() {
- return buffersList;
- }
- @@ -1319,7 +1315,6 @@
- return getBuffer(Type.BindPosePosition) != null && getBuffer(Type.BoneIndex) != null && getBuffer(Type.BoneWeight) != null;
- }
- -
- public void write(JmeExporter ex) throws IOException {
- OutputCapsule out = ex.getCapsule(this);
- @@ -1381,12 +1376,12 @@
- // in.readStringSavableMap("buffers", null);
- buffers = (IntMap<VertexBuffer>) in.readIntSavableMap("buffers", null);
- - for (Entry<VertexBuffer> entry : buffers){
- + for (Entry<VertexBuffer> entry : buffers) {
- buffersList.add(entry.getValue());
- }
- //creating hw animation buffers empty so that they are put in the cache
- - if(isAnimated()){
- + if (isAnimated()) {
- VertexBuffer hwBoneIndex = new VertexBuffer(Type.HWBoneIndex);
- hwBoneIndex.setUsage(Usage.CpuOnly);
- setBuffer(hwBoneIndex);
- @@ -1398,8 +1393,7 @@
- Savable[] lodLevelsSavable = in.readSavableArray("lodLevels", null);
- if (lodLevelsSavable != null) {
- lodLevels = new VertexBuffer[lodLevelsSavable.length];
- - System.arraycopy( lodLevelsSavable, 0, lodLevels, 0, lodLevels.length);
- + System.arraycopy(lodLevelsSavable, 0, lodLevels, 0, lodLevels.length);
- }
- }
- -
- }
- Index: src/core/com/jme3/shader/Shader.java
- --- src/core/com/jme3/shader/Shader.java Base (BASE)
- +++ src/core/com/jme3/shader/Shader.java Locally Modified (Based On LOCAL)
- @@ -74,7 +74,11 @@
- /**
- * Control geometry assembly. (e.g compile a triangle list from input data)
- */
- - Geometry;
- + Geometry,
- +
- + TesselationControl,
- +
- + TesselationEvaluation;
- }
- /**
- Index: src/core/com/jme3/shader/ShaderKey.java
- --- src/core/com/jme3/shader/ShaderKey.java Base (BASE)
- +++ src/core/com/jme3/shader/ShaderKey.java Locally Modified (Based On LOCAL)
- @@ -44,18 +44,30 @@
- protected DefineList defines;
- protected String vertLanguage;
- protected String fragLanguage;
- + protected String geomName;
- + protected String tcName;
- + protected String teName;
- + protected String geomLanguage;
- + protected String tcLanguage;
- + protected String teLanguage;
- protected int cachedHashedCode = 0;
- protected boolean usesShaderNodes = false;
- - public ShaderKey(){
- + public ShaderKey() {
- }
- - public ShaderKey(String vertName, String fragName, DefineList defines, String vertLanguage, String fragLanguage){
- + public ShaderKey(String vertName, String fragName, String geomName, String tcName, String teName, DefineList defines, String vertLanguage, String fragLanguage, String geomLang, String tcLang, String teLang) {
- super(vertName);
- this.fragName = fragName;
- + this.geomName = geomName;
- + this.tcName = tcName;
- + this.teName = teName;
- this.defines = defines;
- this.vertLanguage = vertLanguage;
- this.fragLanguage = fragLanguage;
- + this.geomLanguage = geomLang;
- + this.tcLanguage = tcLang;
- + this.teLanguage = teLang;
- }
- @Override
- @@ -67,14 +79,14 @@
- }
- @Override
- - public String toString(){
- - return "V="+name + " F=" + fragName + (defines != null ? defines : "");
- + public String toString() {
- + return "V=" + name + " F=" + fragName + (defines != null ? defines : "");
- }
- @Override
- public boolean equals(Object obj) {
- final ShaderKey other = (ShaderKey) obj;
- - if (name.equals(other.name) && fragName.equals(other.fragName)){
- + if (name.equals(other.name) && fragName.equals(other.fragName) && (geomName == null ? other.geomName == null : geomName.equals(other.geomName)) && (tcName == null ? other.tcName == null : tcName.equals(other.tcName)) && (teName == null ? other.teName == null : teName.equals(other.teName))) {
- if (defines != null && other.defines != null) {
- return defines.equals(other.defines);
- } else if (defines != null || other.defines != null) {
- @@ -102,7 +114,7 @@
- return defines;
- }
- - public String getVertName(){
- + public String getVertName() {
- return name;
- }
- @@ -110,6 +122,18 @@
- return fragName;
- }
- + public String getGeomName() {
- + return geomName;
- + }
- +
- + public String getTcName() {
- + return tcName;
- + }
- +
- + public String getTeName() {
- + return teName;
- + }
- +
- /**
- * @deprecated Use {@link #getVertexShaderLanguage() } instead.
- */
- @@ -126,6 +150,18 @@
- return fragLanguage;
- }
- + public String getGeometryShaderLanguage() {
- + return geomLanguage;
- + }
- +
- + public String getTessControlShaderLanguage() {
- + return tcLanguage;
- + }
- +
- + public String getTessEvaluationShaderLanguage() {
- + return teLanguage;
- + }
- +
- public boolean isUsesShaderNodes() {
- return usesShaderNodes;
- }
- @@ -135,21 +171,30 @@
- }
- @Override
- - public void write(JmeExporter ex) throws IOException{
- + public void write(JmeExporter ex) throws IOException {
- super.write(ex);
- OutputCapsule oc = ex.getCapsule(this);
- +
- oc.write(fragName, "fragment_name", null);
- + oc.write(geomName, "geometry_name", null);
- + oc.write(tcName, "tess_control_name", null);
- + oc.write(teName, "tess_eval_name", null);
- +
- oc.write(vertLanguage, "language", null);
- oc.write(fragLanguage, "frag_language", null);
- + oc.write(geomLanguage, "geom_language", null);
- + oc.write(tcLanguage, "tc_language", null);
- + oc.write(teLanguage, "te_language", null);
- +
- +
- }
- @Override
- - public void read(JmeImporter im) throws IOException{
- + public void read(JmeImporter im) throws IOException {
- super.read(im);
- InputCapsule ic = im.getCapsule(this);
- fragName = ic.readString("fragment_name", null);
- vertLanguage = ic.readString("language", null);
- fragLanguage = ic.readString("frag_language", null);
- }
- -
- }
- Index: src/lwjgl/com/jme3/renderer/lwjgl/LwjglRenderer.java
- --- src/lwjgl/com/jme3/renderer/lwjgl/LwjglRenderer.java Base (BASE)
- +++ src/lwjgl/com/jme3/renderer/lwjgl/LwjglRenderer.java Locally Modified (Based On LOCAL)
- @@ -75,6 +75,8 @@
- import static org.lwjgl.opengl.GL14.*;
- import static org.lwjgl.opengl.GL15.*;
- import static org.lwjgl.opengl.GL20.*;
- +import static org.lwjgl.opengl.GL30.*;
- +import static org.lwjgl.opengl.GL40.*;
- import org.lwjgl.opengl.*;
- //import static org.lwjgl.opengl.ARBDrawInstanced.*;
- @@ -153,11 +155,16 @@
- caps.add(Caps.OpenGL31);
- if (ctxCaps.OpenGL32) {
- caps.add(Caps.OpenGL32);
- + caps.add(Caps.GeometryShader);
- + if(ctxCaps.OpenGL40){
- + caps.add(Caps.OpenGL40);
- + caps.add(Caps.TesselationShader);
- }
- }
- }
- }
- }
- + }
- //workaround, always assume we support GLSL100
- //some cards just don't report this correctly
- @@ -203,7 +210,9 @@
- // fall through intentional
- case 400:
- + caps.add(Caps.GLSL400);
- case 330:
- + caps.add(Caps.GLSL330);
- case 150:
- caps.add(Caps.GLSL150);
- case 140:
- @@ -947,6 +956,12 @@
- return GL_FRAGMENT_SHADER;
- case Vertex:
- return GL_VERTEX_SHADER;
- + case Geometry:
- + return GL32.GL_GEOMETRY_SHADER;
- + case TesselationControl:
- + return GL40.GL_TESS_CONTROL_SHADER;
- + case TesselationEvaluation:
- + return GL40.GL_TESS_EVALUATION_SHADER;
- // case Geometry:
- // return ARBGeometryShader4.GL_GEOMETRY_SHADER_ARB;
- default:
- @@ -2341,6 +2356,8 @@
- return GL_TRIANGLE_FAN;
- case TriangleStrip:
- return GL_TRIANGLE_STRIP;
- + case Patches:
- + return GL_PATCHES;
- default:
- throw new UnsupportedOperationException("Unrecognized mesh mode: " + mode);
- }
- @@ -2480,6 +2497,9 @@
- glLineWidth(mesh.getLineWidth());
- context.lineWidth = mesh.getLineWidth();
- }
- + if(mesh.getMode()==Mode.Patches){
- + GL40.glPatchParameteri(GL40.GL_PATCH_VERTICES, mesh.getPatchVertices());
- + }
- statistics.onMeshDrawn(mesh, lod);
- // if (GLContext.getCapabilities().GL_ARB_vertex_array_object){
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement