Advertisement
Guest User

Untitled

a guest
Feb 10th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 117.40 KB | None | 0 0
  1. # This patch file was generated by NetBeans IDE
  2. # Following Index: paths are relative to: D:\_Programming\Java\WorkspaceJme3\jme3
  3. # This patch can be applied using context Tools: Patch action on respective folder.
  4. # It uses platform neutral UTF-8 encoding and \n newlines.
  5. # Above lines and this line are ignored by the patching process.
  6. Index: src/core-plugins/com/jme3/material/plugins/J3MLoader.java
  7. --- src/core-plugins/com/jme3/material/plugins/J3MLoader.java Base (BASE)
  8. +++ src/core-plugins/com/jme3/material/plugins/J3MLoader.java Locally Modified (Based On LOCAL)
  9. @@ -59,27 +59,27 @@
  10. // private ErrorLogger errors;
  11. private ShaderNodeLoaderDelegate nodesLoaderDelegate;
  12. boolean isUseNodes = false;
  13. -
  14. private AssetManager assetManager;
  15. private AssetKey key;
  16. -
  17. private MaterialDef materialDef;
  18. private Material material;
  19. private TechniqueDef technique;
  20. private RenderState renderState;
  21. -
  22. private String vertLanguage;
  23. private String fragLanguage;
  24. -
  25. + private String geomLanguage;
  26. + private String tessControlLanguage;
  27. + private String tessEvaluationLanguage;
  28. private String vertName;
  29. private String fragName;
  30. -
  31. + private String geomName;
  32. + private String tessControlName;
  33. + private String tessEvaluationName;
  34. private static final String whitespacePattern = "\\p{javaWhitespace}+";
  35.  
  36. - public J3MLoader(){
  37. + public J3MLoader() {
  38. }
  39.  
  40. -
  41. // <TYPE> <LANG> : <SOURCE>
  42. private void readShaderStatement(String statement) throws IOException {
  43. String[] split = statement.split(":");
  44. @@ -97,13 +97,22 @@
  45. } else if (typeAndLang[0].equals("FragmentShader")) {
  46. fragName = split[1].trim();
  47. fragLanguage = typeAndLang[1];
  48. + } else if (typeAndLang[0].equals("GeometryShader")) {
  49. + geomName = split[1].trim();
  50. + geomLanguage = typeAndLang[1];
  51. + } else if (typeAndLang[0].equals("TessControlShader")) {
  52. + tessControlName = split[1].trim();
  53. + tessControlLanguage = typeAndLang[1];
  54. + } else if (typeAndLang[0].equals("TessEvaluationShader")) {
  55. + tessEvaluationName = split[1].trim();
  56. + tessEvaluationLanguage = typeAndLang[1];
  57. }
  58. }
  59.  
  60. // LightMode <MODE>
  61. - private void readLightMode(String statement) throws IOException{
  62. + private void readLightMode(String statement) throws IOException {
  63. String[] split = statement.split(whitespacePattern);
  64. - if (split.length != 2){
  65. + if (split.length != 2) {
  66. throw new IOException("LightMode statement syntax incorrect");
  67. }
  68. LightMode lm = LightMode.valueOf(split[1]);
  69. @@ -111,29 +120,29 @@
  70. }
  71.  
  72. // ShadowMode <MODE>
  73. - private void readShadowMode(String statement) throws IOException{
  74. + private void readShadowMode(String statement) throws IOException {
  75. String[] split = statement.split(whitespacePattern);
  76. - if (split.length != 2){
  77. + if (split.length != 2) {
  78. throw new IOException("ShadowMode statement syntax incorrect");
  79. }
  80. ShadowMode sm = ShadowMode.valueOf(split[1]);
  81. technique.setShadowMode(sm);
  82. }
  83.  
  84. - private Object readValue(VarType type, String value) throws IOException{
  85. - if (type.isTextureType()){
  86. + private Object readValue(VarType type, String value) throws IOException {
  87. + if (type.isTextureType()) {
  88. // String texturePath = readString("[\n;(//)(\\})]");
  89. String texturePath = value.trim();
  90. boolean flipY = false;
  91. boolean repeat = false;
  92. - if (texturePath.startsWith("Flip Repeat ")){
  93. + if (texturePath.startsWith("Flip Repeat ")) {
  94. texturePath = texturePath.substring(12).trim();
  95. flipY = true;
  96. repeat = true;
  97. - }else if (texturePath.startsWith("Flip ")){
  98. + } else if (texturePath.startsWith("Flip ")) {
  99. texturePath = texturePath.substring(5).trim();
  100. flipY = true;
  101. - }else if (texturePath.startsWith("Repeat ")){
  102. + } else if (texturePath.startsWith("Repeat ")) {
  103. texturePath = texturePath.substring(7).trim();
  104. repeat = true;
  105. }
  106. @@ -145,45 +154,45 @@
  107. Texture tex;
  108. try {
  109. tex = assetManager.loadTexture(texKey);
  110. - } catch (AssetNotFoundException ex){
  111. + } catch (AssetNotFoundException ex) {
  112. logger.log(Level.WARNING, "Cannot locate {0} for material {1}", new Object[]{texKey, key});
  113. tex = null;
  114. }
  115. - if (tex != null){
  116. - if (repeat){
  117. + if (tex != null) {
  118. + if (repeat) {
  119. tex.setWrap(WrapMode.Repeat);
  120. }
  121. - }else{
  122. + } else {
  123. tex = new Texture2D(PlaceholderAssets.getPlaceholderImage());
  124. - if (repeat){
  125. + if (repeat) {
  126. tex.setWrap(WrapMode.Repeat);
  127. }
  128. tex.setKey(texKey);
  129. }
  130. return tex;
  131. - }else{
  132. + } else {
  133. String[] split = value.trim().split(whitespacePattern);
  134. - switch (type){
  135. + switch (type) {
  136. case Float:
  137. - if (split.length != 1){
  138. + if (split.length != 1) {
  139. throw new IOException("Float value parameter must have 1 entry: " + value);
  140. }
  141. return Float.parseFloat(split[0]);
  142. case Vector2:
  143. - if (split.length != 2){
  144. + if (split.length != 2) {
  145. throw new IOException("Vector2 value parameter must have 2 entries: " + value);
  146. }
  147. return new Vector2f(Float.parseFloat(split[0]),
  148. Float.parseFloat(split[1]));
  149. case Vector3:
  150. - if (split.length != 3){
  151. + if (split.length != 3) {
  152. throw new IOException("Vector3 value parameter must have 3 entries: " + value);
  153. }
  154. return new Vector3f(Float.parseFloat(split[0]),
  155. Float.parseFloat(split[1]),
  156. Float.parseFloat(split[2]));
  157. case Vector4:
  158. - if (split.length != 4){
  159. + if (split.length != 4) {
  160. throw new IOException("Vector4 value parameter must have 4 entries: " + value);
  161. }
  162. return new ColorRGBA(Float.parseFloat(split[0]),
  163. @@ -191,23 +200,23 @@
  164. Float.parseFloat(split[2]),
  165. Float.parseFloat(split[3]));
  166. case Int:
  167. - if (split.length != 1){
  168. + if (split.length != 1) {
  169. throw new IOException("Int value parameter must have 1 entry: " + value);
  170. }
  171. return Integer.parseInt(split[0]);
  172. case Boolean:
  173. - if (split.length != 1){
  174. + if (split.length != 1) {
  175. throw new IOException("Boolean value parameter must have 1 entry: " + value);
  176. }
  177. return Boolean.parseBoolean(split[0]);
  178. default:
  179. - throw new UnsupportedOperationException("Unknown type: "+type);
  180. + throw new UnsupportedOperationException("Unknown type: " + type);
  181. }
  182. }
  183. }
  184.  
  185. // <TYPE> <NAME> [ "(" <FFBINDING> ")" ] [ ":" <DEFAULTVAL> ]
  186. - private void readParam(String statement) throws IOException{
  187. + private void readParam(String statement) throws IOException {
  188. String name;
  189. String defaultVal = null;
  190. FixedFuncBinding ffBinding = null;
  191. @@ -215,10 +224,10 @@
  192. String[] split = statement.split(":");
  193.  
  194. // Parse default val
  195. - if (split.length == 1){
  196. + if (split.length == 1) {
  197. // Doesn't contain default value
  198. - }else{
  199. - if (split.length != 2){
  200. + } else {
  201. + if (split.length != 2) {
  202. throw new IOException("Parameter statement syntax incorrect");
  203. }
  204. statement = split[0].trim();
  205. @@ -227,138 +236,138 @@
  206.  
  207. // Parse ffbinding
  208. int startParen = statement.indexOf("(");
  209. - if (startParen != -1){
  210. + if (startParen != -1) {
  211. // get content inside parentheses
  212. int endParen = statement.indexOf(")", startParen);
  213. - String bindingStr = statement.substring(startParen+1, endParen).trim();
  214. + String bindingStr = statement.substring(startParen + 1, endParen).trim();
  215. try {
  216. ffBinding = FixedFuncBinding.valueOf(bindingStr);
  217. - } catch (IllegalArgumentException ex){
  218. - throw new IOException("FixedFuncBinding '" +
  219. - split[1] + "' does not exist!");
  220. + } catch (IllegalArgumentException ex) {
  221. + throw new IOException("FixedFuncBinding '"
  222. + + split[1] + "' does not exist!");
  223. }
  224. statement = statement.substring(0, startParen);
  225. }
  226.  
  227. // Parse type + name
  228. split = statement.split(whitespacePattern);
  229. - if (split.length != 2){
  230. + if (split.length != 2) {
  231. throw new IOException("Parameter statement syntax incorrect");
  232. }
  233.  
  234. VarType type;
  235. - if (split[0].equals("Color")){
  236. + if (split[0].equals("Color")) {
  237. type = VarType.Vector4;
  238. - }else{
  239. + } else {
  240. type = VarType.valueOf(split[0]);
  241. }
  242.  
  243. name = split[1];
  244.  
  245. Object defaultValObj = null;
  246. - if (defaultVal != null){
  247. + if (defaultVal != null) {
  248. defaultValObj = readValue(type, defaultVal);
  249. }
  250.  
  251. materialDef.addMaterialParam(type, name, defaultValObj, ffBinding);
  252. }
  253.  
  254. - private void readValueParam(String statement) throws IOException{
  255. + private void readValueParam(String statement) throws IOException {
  256. // Use limit=1 incase filename contains colons
  257. String[] split = statement.split(":", 2);
  258. - if (split.length != 2){
  259. + if (split.length != 2) {
  260. throw new IOException("Value parameter statement syntax incorrect");
  261. }
  262. String name = split[0].trim();
  263.  
  264. // parse value
  265. MatParam p = material.getMaterialDef().getMaterialParam(name);
  266. - if (p == null){
  267. - throw new IOException("The material parameter: "+name+" is undefined.");
  268. + if (p == null) {
  269. + throw new IOException("The material parameter: " + name + " is undefined.");
  270. }
  271.  
  272. Object valueObj = readValue(p.getVarType(), split[1]);
  273. - if (p.getVarType().isTextureType()){
  274. + if (p.getVarType().isTextureType()) {
  275. material.setTextureParam(name, p.getVarType(), (Texture) valueObj);
  276. - }else{
  277. + } else {
  278. material.setParam(name, p.getVarType(), valueObj);
  279. }
  280. }
  281.  
  282. - private void readMaterialParams(List<Statement> paramsList) throws IOException{
  283. - for (Statement statement : paramsList){
  284. + private void readMaterialParams(List<Statement> paramsList) throws IOException {
  285. + for (Statement statement : paramsList) {
  286. readParam(statement.getLine());
  287. }
  288. }
  289.  
  290. - private void readExtendingMaterialParams(List<Statement> paramsList) throws IOException{
  291. - for (Statement statement : paramsList){
  292. + private void readExtendingMaterialParams(List<Statement> paramsList) throws IOException {
  293. + for (Statement statement : paramsList) {
  294. readValueParam(statement.getLine());
  295. }
  296. }
  297.  
  298. - private void readWorldParams(List<Statement> worldParams) throws IOException{
  299. - for (Statement statement : worldParams){
  300. + private void readWorldParams(List<Statement> worldParams) throws IOException {
  301. + for (Statement statement : worldParams) {
  302. technique.addWorldParam(statement.getLine());
  303. }
  304. }
  305.  
  306. - private boolean parseBoolean(String word){
  307. + private boolean parseBoolean(String word) {
  308. return word != null && word.equals("On");
  309. }
  310.  
  311. - private void readRenderStateStatement(Statement statement) throws IOException{
  312. + private void readRenderStateStatement(Statement statement) throws IOException {
  313. String[] split = statement.getLine().split(whitespacePattern);
  314. - if (split[0].equals("Wireframe")){
  315. + if (split[0].equals("Wireframe")) {
  316. renderState.setWireframe(parseBoolean(split[1]));
  317. - }else if (split[0].equals("FaceCull")){
  318. + } else if (split[0].equals("FaceCull")) {
  319. renderState.setFaceCullMode(FaceCullMode.valueOf(split[1]));
  320. - }else if (split[0].equals("DepthWrite")){
  321. + } else if (split[0].equals("DepthWrite")) {
  322. renderState.setDepthWrite(parseBoolean(split[1]));
  323. - }else if (split[0].equals("DepthTest")){
  324. + } else if (split[0].equals("DepthTest")) {
  325. renderState.setDepthTest(parseBoolean(split[1]));
  326. - }else if (split[0].equals("Blend")){
  327. + } else if (split[0].equals("Blend")) {
  328. renderState.setBlendMode(BlendMode.valueOf(split[1]));
  329. - }else if (split[0].equals("AlphaTestFalloff")){
  330. + } else if (split[0].equals("AlphaTestFalloff")) {
  331. renderState.setAlphaTest(true);
  332. renderState.setAlphaFallOff(Float.parseFloat(split[1]));
  333. - }else if (split[0].equals("PolyOffset")){
  334. + } else if (split[0].equals("PolyOffset")) {
  335. float factor = Float.parseFloat(split[1]);
  336. float units = Float.parseFloat(split[2]);
  337. renderState.setPolyOffset(factor, units);
  338. - }else if (split[0].equals("ColorWrite")){
  339. + } else if (split[0].equals("ColorWrite")) {
  340. renderState.setColorWrite(parseBoolean(split[1]));
  341. - }else if (split[0].equals("PointSprite")){
  342. + } else if (split[0].equals("PointSprite")) {
  343. renderState.setPointSprite(parseBoolean(split[1]));
  344. - }else if (split[0].equals("DepthFunc")){
  345. + } else if (split[0].equals("DepthFunc")) {
  346. renderState.setDepthFunc(RenderState.TestFunction.valueOf(split[1]));
  347. - }else if (split[0].equals("AlphaFunc")){
  348. + } else if (split[0].equals("AlphaFunc")) {
  349. renderState.setAlphaFunc(RenderState.TestFunction.valueOf(split[1]));
  350. } else {
  351. throw new MatParseException(null, split[0], statement);
  352. }
  353. }
  354.  
  355. - private void readAdditionalRenderState(List<Statement> renderStates) throws IOException{
  356. + private void readAdditionalRenderState(List<Statement> renderStates) throws IOException {
  357. renderState = material.getAdditionalRenderState();
  358. - for (Statement statement : renderStates){
  359. + for (Statement statement : renderStates) {
  360. readRenderStateStatement(statement);
  361. }
  362. renderState = null;
  363. }
  364.  
  365. - private void readRenderState(List<Statement> renderStates) throws IOException{
  366. + private void readRenderState(List<Statement> renderStates) throws IOException {
  367. renderState = new RenderState();
  368. - for (Statement statement : renderStates){
  369. + for (Statement statement : renderStates) {
  370. readRenderStateStatement(statement);
  371. }
  372. technique.setRenderState(renderState);
  373. renderState = null;
  374. }
  375.  
  376. - private void readForcedRenderState(List<Statement> renderStates) throws IOException{
  377. + private void readForcedRenderState(List<Statement> renderStates) throws IOException {
  378. renderState = new RenderState();
  379. - for (Statement statement : renderStates){
  380. + for (Statement statement : renderStates) {
  381. readRenderStateStatement(statement);
  382. }
  383. technique.setForcedRenderState(renderState);
  384. @@ -366,41 +375,44 @@
  385. }
  386.  
  387. // <DEFINENAME> [ ":" <PARAMNAME> ]
  388. - private void readDefine(String statement) throws IOException{
  389. + private void readDefine(String statement) throws IOException {
  390. String[] split = statement.split(":");
  391. - if (split.length == 1){
  392. + if (split.length == 1) {
  393. // add preset define
  394. technique.addShaderPresetDefine(split[0].trim(), VarType.Boolean, true);
  395. - }else if (split.length == 2){
  396. + } else if (split.length == 2) {
  397. technique.addShaderParamDefine(split[1].trim(), split[0].trim());
  398. - }else{
  399. + } else {
  400. throw new IOException("Define syntax incorrect");
  401. }
  402. }
  403.  
  404. - private void readDefines(List<Statement> defineList) throws IOException{
  405. - for (Statement statement : defineList){
  406. + private void readDefines(List<Statement> defineList) throws IOException {
  407. + for (Statement statement : defineList) {
  408. readDefine(statement.getLine());
  409. }
  410.  
  411. }
  412.  
  413. - private void readTechniqueStatement(Statement statement) throws IOException{
  414. + private void readTechniqueStatement(Statement statement) throws IOException {
  415. String[] split = statement.getLine().split("[ \\{]");
  416. - if (split[0].equals("VertexShader") ||
  417. - split[0].equals("FragmentShader")){
  418. + if (split[0].equals("VertexShader")
  419. + || split[0].equals("FragmentShader")
  420. + || split[0].equals("GeometryShader")
  421. + || split[0].equals("TessControlShader")
  422. + || split[0].equals("TessEvaluationShader")) {
  423. readShaderStatement(statement.getLine());
  424. - }else if (split[0].equals("LightMode")){
  425. + } else if (split[0].equals("LightMode")) {
  426. readLightMode(statement.getLine());
  427. - }else if (split[0].equals("ShadowMode")){
  428. + } else if (split[0].equals("ShadowMode")) {
  429. readShadowMode(statement.getLine());
  430. - }else if (split[0].equals("WorldParameters")){
  431. + } else if (split[0].equals("WorldParameters")) {
  432. readWorldParams(statement.getContents());
  433. - }else if (split[0].equals("RenderState")){
  434. + } else if (split[0].equals("RenderState")) {
  435. readRenderState(statement.getContents());
  436. - }else if (split[0].equals("ForcedRenderState")){
  437. + } else if (split[0].equals("ForcedRenderState")) {
  438. readForcedRenderState(statement.getContents());
  439. - }else if (split[0].equals("Defines")){
  440. + } else if (split[0].equals("Defines")) {
  441. readDefines(statement.getContents());
  442. } else if (split[0].equals("ShaderNodesDefinitions")) {
  443. initNodesLoader();
  444. @@ -422,15 +434,15 @@
  445. }
  446. }
  447.  
  448. - private void readTransparentStatement(String statement) throws IOException{
  449. + private void readTransparentStatement(String statement) throws IOException {
  450. String[] split = statement.split(whitespacePattern);
  451. - if (split.length != 2){
  452. + if (split.length != 2) {
  453. throw new IOException("Transparent statement syntax incorrect");
  454. }
  455. material.setTransparent(parseBoolean(split[1]));
  456. }
  457.  
  458. - private void readTechnique(Statement techStat) throws IOException{
  459. + private void readTechnique(Statement techStat) throws IOException {
  460. isUseNodes = false;
  461. String[] split = techStat.getLine().split(whitespacePattern);
  462. if (split.length == 1) {
  463. @@ -447,62 +459,68 @@
  464. throw new IOException("Technique statement syntax incorrect");
  465. }
  466.  
  467. - for (Statement statement : techStat.getContents()){
  468. + for (Statement statement : techStat.getContents()) {
  469. readTechniqueStatement(statement);
  470. }
  471.  
  472. - if(isUseNodes){
  473. + if (isUseNodes) {
  474. nodesLoaderDelegate.computeConditions();
  475. //used for caching later, the shader here is not a file.
  476. technique.setShaderFile(technique.hashCode() + "", technique.hashCode() + "", "GLSL100", "GLSL100");
  477. }
  478.  
  479. - if (vertName != null && fragName != null){
  480. - technique.setShaderFile(vertName, fragName, vertLanguage, fragLanguage);
  481. + if (vertName != null && fragName != null) {
  482. + technique.setShaderFile(vertName, fragName, geomName,tessControlName,tessEvaluationName, vertLanguage, fragLanguage,geomLanguage,tessControlLanguage,tessEvaluationLanguage);
  483. }
  484.  
  485. materialDef.addTechniqueDef(technique);
  486. technique = null;
  487. vertName = null;
  488. fragName = null;
  489. + geomName=null;
  490. + tessControlName=null;
  491. + tessEvaluationName=null;
  492. vertLanguage = null;
  493. fragLanguage = null;
  494. + geomLanguage=null;
  495. + tessControlLanguage=null;
  496. + tessEvaluationLanguage=null;
  497. }
  498.  
  499. - private void loadFromRoot(List<Statement> roots) throws IOException{
  500. - if (roots.size() == 2){
  501. + private void loadFromRoot(List<Statement> roots) throws IOException {
  502. + if (roots.size() == 2) {
  503. Statement exception = roots.get(0);
  504. String line = exception.getLine();
  505. - if (line.startsWith("Exception")){
  506. + if (line.startsWith("Exception")) {
  507. throw new AssetLoadException(line.substring("Exception ".length()));
  508. - }else{
  509. + } else {
  510. throw new IOException("In multiroot material, expected first statement to be 'Exception'");
  511. }
  512. - }else if (roots.size() != 1){
  513. + } else if (roots.size() != 1) {
  514. throw new IOException("Too many roots in J3M/J3MD file");
  515. }
  516.  
  517. boolean extending = false;
  518. Statement materialStat = roots.get(0);
  519. String materialName = materialStat.getLine();
  520. - if (materialName.startsWith("MaterialDef")){
  521. + if (materialName.startsWith("MaterialDef")) {
  522. materialName = materialName.substring("MaterialDef ".length()).trim();
  523. extending = false;
  524. - }else if (materialName.startsWith("Material")){
  525. + } else if (materialName.startsWith("Material")) {
  526. materialName = materialName.substring("Material ".length()).trim();
  527. extending = true;
  528. - }else{
  529. + } else {
  530. throw new IOException("Specified file is not a Material file");
  531. }
  532.  
  533. String[] split = materialName.split(":", 2);
  534.  
  535. - if (materialName.equals("")){
  536. + if (materialName.equals("")) {
  537. throw new MatParseException("Material name cannot be empty", materialStat);
  538. }
  539.  
  540. - if (split.length == 2){
  541. - if (!extending){
  542. + if (split.length == 2) {
  543. + if (!extending) {
  544. throw new MatParseException("Must use 'Material' when extending.", materialStat);
  545. }
  546.  
  547. @@ -516,35 +534,35 @@
  548. material = new Material(def);
  549. material.setKey(key);
  550. // material.setAssetName(fileName);
  551. - }else if (split.length == 1){
  552. - if (extending){
  553. + } else if (split.length == 1) {
  554. + if (extending) {
  555. throw new MatParseException("Expected ':', got '{'", materialStat);
  556. }
  557. materialDef = new MaterialDef(assetManager, materialName);
  558. // NOTE: pass file name for defs so they can be loaded later
  559. materialDef.setAssetName(key.getName());
  560. - }else{
  561. + } else {
  562. throw new MatParseException("Cannot use colon in material name/path", materialStat);
  563. }
  564.  
  565. - for (Statement statement : materialStat.getContents()){
  566. + for (Statement statement : materialStat.getContents()) {
  567. split = statement.getLine().split("[ \\{]");
  568. String statType = split[0];
  569. - if (extending){
  570. - if (statType.equals("MaterialParameters")){
  571. + if (extending) {
  572. + if (statType.equals("MaterialParameters")) {
  573. readExtendingMaterialParams(statement.getContents());
  574. - }else if (statType.equals("AdditionalRenderState")){
  575. + } else if (statType.equals("AdditionalRenderState")) {
  576. readAdditionalRenderState(statement.getContents());
  577. - }else if (statType.equals("Transparent")){
  578. + } else if (statType.equals("Transparent")) {
  579. readTransparentStatement(statement.getLine());
  580. }
  581. - }else{
  582. - if (statType.equals("Technique")){
  583. + } else {
  584. + if (statType.equals("Technique")) {
  585. readTechnique(statement);
  586. - }else if (statType.equals("MaterialParameters")){
  587. + } else if (statType.equals("MaterialParameters")) {
  588. readMaterialParams(statement.getContents());
  589. - }else{
  590. - throw new MatParseException("Expected material statement, got '"+statType+"'", statement);
  591. + } else {
  592. + throw new MatParseException("Expected material statement, got '" + statType + "'", statement);
  593. }
  594. }
  595. }
  596. @@ -558,18 +576,18 @@
  597. key = info.getKey();
  598. loadFromRoot(BlockLanguageParser.parse(in));
  599. } finally {
  600. - if (in != null){
  601. + if (in != null) {
  602. in.close();
  603. }
  604. }
  605.  
  606. - if (material != null){
  607. - if (!(info.getKey() instanceof MaterialKey)){
  608. + if (material != null) {
  609. + if (!(info.getKey() instanceof MaterialKey)) {
  610. throw new IOException("Material instances must be loaded via MaterialKey");
  611. }
  612. // material implementation
  613. return material;
  614. - }else{
  615. + } else {
  616. // material definition
  617. return materialDef;
  618. }
  619. @@ -586,9 +604,9 @@
  620. if (!isUseNodes) {
  621. isUseNodes = fragName == null && vertName == null;
  622. if (isUseNodes) {
  623. - if(nodesLoaderDelegate == null){
  624. + if (nodesLoaderDelegate == null) {
  625. nodesLoaderDelegate = new ShaderNodeLoaderDelegate();
  626. - }else{
  627. + } else {
  628. nodesLoaderDelegate.clear();
  629. }
  630. nodesLoaderDelegate.setTechniqueDef(technique);
  631. @@ -597,5 +615,4 @@
  632. }
  633. }
  634. }
  635. -
  636. }
  637. Index: src/core/com/jme3/asset/Desktop.cfg
  638. --- src/core/com/jme3/asset/Desktop.cfg Base (BASE)
  639. +++ src/core/com/jme3/asset/Desktop.cfg Locally Modified (Based On LOCAL)
  640. @@ -21,4 +21,4 @@
  641. LOADER com.jme3.scene.plugins.ogre.MaterialLoader : material
  642. LOADER com.jme3.scene.plugins.ogre.SceneLoader : scene
  643. LOADER com.jme3.scene.plugins.blender.BlenderModelLoader : blend
  644. -LOADER com.jme3.shader.plugins.GLSLLoader : vert, frag, glsl, glsllib
  645. +LOADER com.jme3.shader.plugins.GLSLLoader : vert, frag,geom, tsctrl, tseval, glsl, glsllib
  646. Index: src/core/com/jme3/asset/DesktopAssetManager.java
  647. --- src/core/com/jme3/asset/DesktopAssetManager.java Base (BASE)
  648. +++ src/core/com/jme3/asset/DesktopAssetManager.java Locally Modified (Based On LOCAL)
  649. @@ -68,47 +68,45 @@
  650.  
  651. private static final Logger logger = Logger.getLogger(AssetManager.class.getName());
  652. private ShaderGenerator shaderGenerator;
  653. -
  654. private final ImplHandler handler = new ImplHandler(this);
  655. -
  656. private CopyOnWriteArrayList<AssetEventListener> eventListeners =
  657. new CopyOnWriteArrayList<AssetEventListener>();
  658. -
  659. private List<ClassLoader> classLoaders =
  660. Collections.synchronizedList(new ArrayList<ClassLoader>());
  661.  
  662. - public DesktopAssetManager(){
  663. + public DesktopAssetManager() {
  664. this(null);
  665. }
  666.  
  667. @Deprecated
  668. - public DesktopAssetManager(boolean loadDefaults){
  669. + public DesktopAssetManager(boolean loadDefaults) {
  670. this(Thread.currentThread().getContextClassLoader().getResource("com/jme3/asset/Desktop.cfg"));
  671. }
  672.  
  673. - public DesktopAssetManager(URL configFile){
  674. - if (configFile != null){
  675. + public DesktopAssetManager(URL configFile) {
  676. + if (configFile != null) {
  677. loadConfigFile(configFile);
  678. }
  679. logger.fine("DesktopAssetManager created.");
  680. }
  681.  
  682. - private void loadConfigFile(URL configFile){
  683. + private void loadConfigFile(URL configFile) {
  684. InputStream stream = null;
  685. - try{
  686. + try {
  687. AssetConfig cfg = new AssetConfig(this);
  688. stream = configFile.openStream();
  689. cfg.loadText(stream);
  690. - }catch (IOException ex){
  691. + } catch (IOException ex) {
  692. logger.log(Level.SEVERE, "Failed to load asset config", ex);
  693. - }finally{
  694. - if (stream != null)
  695. - try{
  696. + } finally {
  697. + if (stream != null) {
  698. + try {
  699. stream.close();
  700. - }catch (IOException ex){
  701. + } catch (IOException ex) {
  702. }
  703. }
  704. }
  705. + }
  706.  
  707. public void addClassLoader(ClassLoader loader) {
  708. classLoaders.add(loader);
  709. @@ -118,7 +116,7 @@
  710. classLoaders.remove(loader);
  711. }
  712.  
  713. - public List<ClassLoader> getClassLoaders(){
  714. + public List<ClassLoader> getClassLoaders() {
  715. return Collections.unmodifiableList(classLoaders);
  716. }
  717.  
  718. @@ -134,74 +132,74 @@
  719. eventListeners.clear();
  720. }
  721.  
  722. - public void setAssetEventListener(AssetEventListener listener){
  723. + public void setAssetEventListener(AssetEventListener listener) {
  724. eventListeners.clear();
  725. eventListeners.add(listener);
  726. }
  727.  
  728. - public void registerLoader(Class<? extends AssetLoader> loader, String ... extensions){
  729. + public void registerLoader(Class<? extends AssetLoader> loader, String... extensions) {
  730. handler.addLoader(loader, extensions);
  731. - if (logger.isLoggable(Level.FINER)){
  732. + if (logger.isLoggable(Level.FINER)) {
  733. logger.log(Level.FINER, "Registered loader: {0} for extensions {1}",
  734. new Object[]{loader.getSimpleName(), Arrays.toString(extensions)});
  735. }
  736. }
  737.  
  738. - public void registerLoader(String clsName, String ... extensions){
  739. + public void registerLoader(String clsName, String... extensions) {
  740. Class<? extends AssetLoader> clazz = null;
  741. - try{
  742. + try {
  743. clazz = (Class<? extends AssetLoader>) Class.forName(clsName);
  744. - }catch (ClassNotFoundException ex){
  745. - logger.log(Level.WARNING, "Failed to find loader: "+clsName, ex);
  746. - }catch (NoClassDefFoundError ex){
  747. - logger.log(Level.WARNING, "Failed to find loader: "+clsName, ex);
  748. + } catch (ClassNotFoundException ex) {
  749. + logger.log(Level.WARNING, "Failed to find loader: " + clsName, ex);
  750. + } catch (NoClassDefFoundError ex) {
  751. + logger.log(Level.WARNING, "Failed to find loader: " + clsName, ex);
  752. }
  753. - if (clazz != null){
  754. + if (clazz != null) {
  755. registerLoader(clazz, extensions);
  756. }
  757. }
  758.  
  759. public void unregisterLoader(Class<? extends AssetLoader> loaderClass) {
  760. handler.removeLoader(loaderClass);
  761. - if (logger.isLoggable(Level.FINER)){
  762. + if (logger.isLoggable(Level.FINER)) {
  763. logger.log(Level.FINER, "Unregistered loader: {0}",
  764. loaderClass.getSimpleName());
  765. }
  766. }
  767.  
  768. - public void registerLocator(String rootPath, Class<? extends AssetLocator> locatorClass){
  769. + public void registerLocator(String rootPath, Class<? extends AssetLocator> locatorClass) {
  770. handler.addLocator(locatorClass, rootPath);
  771. - if (logger.isLoggable(Level.FINER)){
  772. + if (logger.isLoggable(Level.FINER)) {
  773. logger.log(Level.FINER, "Registered locator: {0}",
  774. locatorClass.getSimpleName());
  775. }
  776. }
  777.  
  778. - public void registerLocator(String rootPath, String clsName){
  779. + public void registerLocator(String rootPath, String clsName) {
  780. Class<? extends AssetLocator> clazz = null;
  781. - try{
  782. + try {
  783. clazz = (Class<? extends AssetLocator>) Class.forName(clsName);
  784. - }catch (ClassNotFoundException ex){
  785. - logger.log(Level.WARNING, "Failed to find locator: "+clsName, ex);
  786. - }catch (NoClassDefFoundError ex){
  787. - logger.log(Level.WARNING, "Failed to find loader: "+clsName, ex);
  788. + } catch (ClassNotFoundException ex) {
  789. + logger.log(Level.WARNING, "Failed to find locator: " + clsName, ex);
  790. + } catch (NoClassDefFoundError ex) {
  791. + logger.log(Level.WARNING, "Failed to find loader: " + clsName, ex);
  792. }
  793. - if (clazz != null){
  794. + if (clazz != null) {
  795. registerLocator(rootPath, clazz);
  796. }
  797. }
  798.  
  799. - public void unregisterLocator(String rootPath, Class<? extends AssetLocator> clazz){
  800. + public void unregisterLocator(String rootPath, Class<? extends AssetLocator> clazz) {
  801. handler.removeLocator(clazz, rootPath);
  802. - if (logger.isLoggable(Level.FINER)){
  803. + if (logger.isLoggable(Level.FINER)) {
  804. logger.log(Level.FINER, "Unregistered locator: {0}",
  805. clazz.getSimpleName());
  806. }
  807. }
  808.  
  809. - public AssetInfo locateAsset(AssetKey<?> key){
  810. + public AssetInfo locateAsset(AssetKey<?> key) {
  811. AssetInfo info = handler.tryLocate(key);
  812. - if (info == null){
  813. + if (info == null) {
  814. logger.log(Level.WARNING, "Cannot locate resource: {0}", key);
  815. }
  816. return info;
  817. @@ -240,9 +238,9 @@
  818. }
  819. }
  820.  
  821. - public void clearCache(){
  822. + public void clearCache() {
  823. handler.clearCache();
  824. - if (logger.isLoggable(Level.FINER)){
  825. + if (logger.isLoggable(Level.FINER)) {
  826. logger.log(Level.FINER, "All asset caches cleared.");
  827. }
  828. }
  829. @@ -254,11 +252,12 @@
  830. * @param key
  831. * @return the loaded asset
  832. */
  833. - public <T> T loadAsset(AssetKey<T> key){
  834. - if (key == null)
  835. + public <T> T loadAsset(AssetKey<T> key) {
  836. + if (key == null) {
  837. throw new IllegalArgumentException("key cannot be null");
  838. + }
  839.  
  840. - for (AssetEventListener listener : eventListeners){
  841. + for (AssetEventListener listener : eventListeners) {
  842. listener.assetRequested(key);
  843. }
  844.  
  845. @@ -266,17 +265,17 @@
  846. AssetProcessor proc = handler.getProcessor(key.getProcessorType());
  847.  
  848. Object obj = cache != null ? cache.getFromCache(key) : null;
  849. - if (obj == null){
  850. + if (obj == null) {
  851. // Asset not in cache, load it from file system.
  852. AssetLoader loader = handler.aquireLoader(key);
  853. AssetInfo info = handler.tryLocate(key);
  854. - if (info == null){
  855. - if (handler.getParentKey() != null){
  856. + if (info == null) {
  857. + if (handler.getParentKey() != null) {
  858. // Inform event listener that an asset has failed to load.
  859. // If the parent AssetLoader chooses not to propagate
  860. // the exception, this is the only means of finding
  861. // that something went wrong.
  862. - for (AssetEventListener listener : eventListeners){
  863. + for (AssetEventListener listener : eventListeners) {
  864. listener.assetDependencyNotFound(handler.getParentKey(), key);
  865. }
  866. }
  867. @@ -291,25 +290,25 @@
  868. } finally {
  869. handler.releaseParentKey(key);
  870. }
  871. - if (obj == null){
  872. + if (obj == null) {
  873. throw new AssetLoadException("Error occured while loading asset \"" + key + "\" using " + loader.getClass().getSimpleName());
  874. - }else{
  875. - if (logger.isLoggable(Level.FINER)){
  876. + } else {
  877. + if (logger.isLoggable(Level.FINER)) {
  878. logger.log(Level.FINER, "Loaded {0} with {1}",
  879. new Object[]{key, loader.getClass().getSimpleName()});
  880. }
  881.  
  882. - if (proc != null){
  883. + if (proc != null) {
  884. // do processing on asset before caching
  885. obj = proc.postProcess(key, obj);
  886. }
  887.  
  888. - if (cache != null){
  889. + if (cache != null) {
  890. // At this point, obj should be of type T
  891. cache.addToCache(key, (T) obj);
  892. }
  893.  
  894. - for (AssetEventListener listener : eventListeners){
  895. + for (AssetEventListener listener : eventListeners) {
  896. listener.assetLoaded(key);
  897. }
  898. }
  899. @@ -318,16 +317,16 @@
  900. // object obj is the original asset
  901. // create an instance for user
  902. T clone = (T) obj;
  903. - if (clone instanceof CloneableSmartAsset){
  904. - if (proc == null){
  905. + if (clone instanceof CloneableSmartAsset) {
  906. + if (proc == null) {
  907. throw new IllegalStateException("Asset implements "
  908. + "CloneableSmartAsset but doesn't "
  909. + "have processor to handle cloning");
  910. - }else{
  911. + } else {
  912. clone = (T) proc.createClone(obj);
  913. - if (cache != null && clone != obj){
  914. + if (cache != null && clone != obj) {
  915. cache.registerAssetClone(key, clone);
  916. - } else{
  917. + } else {
  918. throw new IllegalStateException("Asset implements "
  919. + "CloneableSmartAsset but doesn't have cache or "
  920. + "was not cloned");
  921. @@ -338,19 +337,19 @@
  922. return clone;
  923. }
  924.  
  925. - public Object loadAsset(String name){
  926. + public Object loadAsset(String name) {
  927. return loadAsset(new AssetKey(name));
  928. }
  929.  
  930. - public Texture loadTexture(TextureKey key){
  931. + public Texture loadTexture(TextureKey key) {
  932. return (Texture) loadAsset(key);
  933. }
  934.  
  935. - public Material loadMaterial(String name){
  936. + public Material loadMaterial(String name) {
  937. return (Material) loadAsset(new MaterialKey(name));
  938. }
  939.  
  940. - public Texture loadTexture(String name){
  941. + public Texture loadTexture(String name) {
  942. TextureKey key = new TextureKey(name, true);
  943. key.setGenerateMips(true);
  944. Texture tex = loadTexture(key);
  945. @@ -358,31 +357,31 @@
  946. return tex;
  947. }
  948.  
  949. - public AudioData loadAudio(AudioKey key){
  950. + public AudioData loadAudio(AudioKey key) {
  951. return (AudioData) loadAsset(key);
  952. }
  953.  
  954. - public AudioData loadAudio(String name){
  955. + public AudioData loadAudio(String name) {
  956. return loadAudio(new AudioKey(name, false));
  957. }
  958.  
  959. - public BitmapFont loadFont(String name){
  960. + public BitmapFont loadFont(String name) {
  961. return (BitmapFont) loadAsset(new AssetKey(name));
  962. }
  963.  
  964. - public Spatial loadModel(ModelKey key){
  965. + public Spatial loadModel(ModelKey key) {
  966. return (Spatial) loadAsset(key);
  967. }
  968.  
  969. - public Spatial loadModel(String name){
  970. + public Spatial loadModel(String name) {
  971. return loadModel(new ModelKey(name));
  972. }
  973.  
  974. - public FilterPostProcessor loadFilter(FilterKey key){
  975. + public FilterPostProcessor loadFilter(FilterKey key) {
  976. return (FilterPostProcessor) loadAsset(key);
  977. }
  978.  
  979. - public FilterPostProcessor loadFilter(String name){
  980. + public FilterPostProcessor loadFilter(String name) {
  981. return loadFilter(new FilterKey(name));
  982. }
  983.  
  984. @@ -392,30 +391,44 @@
  985. * @param key
  986. * @return the loaded {@link Shader}
  987. */
  988. - public Shader loadShader(ShaderKey key){
  989. + public Shader loadShader(ShaderKey key) {
  990. // cache abuse in method
  991. // that doesn't use loaders/locators
  992. AssetCache cache = handler.getCache(SimpleAssetCache.class);
  993. Shader shader = (Shader) cache.getFromCache(key);
  994. - if (shader == null){
  995. + if (shader == null) {
  996. if (key.isUsesShaderNodes()) {
  997. - if(shaderGenerator == null){
  998. + if (shaderGenerator == null) {
  999. throw new UnsupportedOperationException("ShaderGenerator was not initialized, make sure assetManager.getGenerator(caps) has been called");
  1000. }
  1001. shader = shaderGenerator.generateShader();
  1002. } else {
  1003. String vertName = key.getVertName();
  1004. String fragName = key.getFragName();
  1005. -
  1006. + String geomName = key.getGeomName();
  1007. + String tcName = key.getTcName();
  1008. + String teName = key.getTeName();
  1009. String vertSource = (String) loadAsset(new AssetKey(vertName));
  1010. String fragSource = (String) loadAsset(new AssetKey(fragName));
  1011. -
  1012. + String geomSource = geomName == null ? null : (String) loadAsset(new AssetKey(geomName));
  1013. + String tcSource = tcName == null ? null : (String) loadAsset(new AssetKey(tcName));
  1014. + String teSource = teName == null ? null : (String) loadAsset(new AssetKey(teName));
  1015. shader = new Shader();
  1016. shader.initialize();
  1017. shader.addSource(Shader.ShaderType.Vertex, vertName, vertSource, key.getDefines().getCompiled(), key.getVertexShaderLanguage());
  1018. shader.addSource(Shader.ShaderType.Fragment, fragName, fragSource, key.getDefines().getCompiled(), key.getFragmentShaderLanguage());
  1019. + if (geomName != null) {
  1020. + shader.addSource(Shader.ShaderType.Geometry, geomName, geomSource, key.getDefines().getCompiled(), key.getVertexShaderLanguage());
  1021. }
  1022. + if (tcName != null) {
  1023. + shader.addSource(Shader.ShaderType.TesselationControl, tcName, tcSource, key.getDefines().getCompiled(), key.getVertexShaderLanguage());
  1024. + }
  1025. + if (teName != null) {
  1026. + shader.addSource(Shader.ShaderType.TesselationEvaluation, teName, teSource, key.getDefines().getCompiled(), key.getVertexShaderLanguage());
  1027. + }
  1028.  
  1029. + }
  1030. +
  1031. cache.addToCache(key, shader);
  1032. }
  1033. return shader;
  1034. @@ -427,9 +440,9 @@
  1035. @Override
  1036. public ShaderGenerator getShaderGenerator(EnumSet<Caps> caps) {
  1037. if (shaderGenerator == null) {
  1038. - if(caps.contains(Caps.GLSL150)){
  1039. + if (caps.contains(Caps.GLSL150)) {
  1040. shaderGenerator = new Glsl150ShaderGenerator(this);
  1041. - }else{
  1042. + } else {
  1043. shaderGenerator = new Glsl100ShaderGenerator(this);
  1044. }
  1045. }
  1046. @@ -443,6 +456,4 @@
  1047. public void setShaderGenerator(ShaderGenerator shaderGenerator) {
  1048. this.shaderGenerator = shaderGenerator;
  1049. }
  1050. -
  1051. -
  1052. }
  1053. Index: src/core/com/jme3/material/Technique.java
  1054. --- src/core/com/jme3/material/Technique.java Base (BASE)
  1055. +++ src/core/com/jme3/material/Technique.java Locally Modified (Based On LOCAL)
  1056. @@ -207,9 +207,15 @@
  1057.  
  1058. ShaderKey key = new ShaderKey(def.getVertexShaderName(),
  1059. def.getFragmentShaderName(),
  1060. + def.getGeometryShaderName(),
  1061. + def.getTessControlShaderName(),
  1062. + def.getTessEvaluationShaderName(),
  1063. getAllDefines(),
  1064. def.getVertexShaderLanguage(),
  1065. - def.getFragmentShaderLanguage());
  1066. + def.getFragmentShaderLanguage(),
  1067. + def.getGeometryShaderLanguage(),
  1068. + def.getTessControlShaderLanguage(),
  1069. + def.getTessEvaluationShaderLanguage());
  1070.  
  1071. if (getDef().isUsingShaderNodes()) {
  1072. manager.getShaderGenerator(rendererCaps).initialize(this);
  1073. Index: src/core/com/jme3/material/TechniqueDef.java
  1074. --- src/core/com/jme3/material/TechniqueDef.java Base (BASE)
  1075. +++ src/core/com/jme3/material/TechniqueDef.java Locally Modified (Based On LOCAL)
  1076. @@ -56,15 +56,31 @@
  1077. */
  1078. public static final int SAVABLE_VERSION = 1;
  1079.  
  1080. + public void setShaderFile(String vertexShader, String fragmentShader, String vertLanguage, String fragLanguage) {
  1081. + this.vertName = vertexShader;
  1082. + this.fragName = fragmentShader;
  1083. +
  1084. + this.vertLanguage = vertLanguage;
  1085. + this.fragLanguage = fragLanguage;
  1086. +
  1087. + Caps vertCap = Caps.valueOf(vertLanguage);
  1088. + requiredCaps.add(vertCap);
  1089. + Caps fragCap = Caps.valueOf(fragLanguage);
  1090. + requiredCaps.add(fragCap);
  1091. + Caps geomCap = Caps.valueOf(geomLanguage);
  1092. + requiredCaps.add(geomCap);
  1093. + usesShaders = true;
  1094. + }
  1095. +
  1096. /**
  1097. * Describes light rendering mode.
  1098. */
  1099. public enum LightMode {
  1100. +
  1101. /**
  1102. * Disable light-based rendering
  1103. */
  1104. Disable,
  1105. -
  1106. /**
  1107. * Enable light rendering by using a single pass.
  1108. * <p>
  1109. @@ -72,55 +88,54 @@
  1110. * containing the world light list for the geometry being rendered.
  1111. */
  1112. SinglePass,
  1113. -
  1114. /**
  1115. * Enable light rendering by using multi-pass rendering.
  1116. * <p>
  1117. * The geometry will be rendered once for each light. Each time the
  1118. - * light position and light color uniforms are updated to contain
  1119. - * the values for the current light. The ambient light color uniform
  1120. - * is only set to the ambient light color on the first pass, future
  1121. - * passes have it set to black.
  1122. + * light position and light color uniforms are updated to contain the
  1123. + * values for the current light. The ambient light color uniform is only
  1124. + * set to the ambient light color on the first pass, future passes have
  1125. + * it set to black.
  1126. */
  1127. MultiPass,
  1128. -
  1129. /**
  1130. * Enable light rendering by using the
  1131. * {@link Renderer#setLighting(com.jme3.light.LightList) renderer's setLighting}
  1132. * method.
  1133. * <p>
  1134. - * The specific details of rendering the lighting is up to the
  1135. - * renderer implementation.
  1136. + * The specific details of rendering the lighting is up to the renderer
  1137. + * implementation.
  1138. */
  1139. FixedPipeline,
  1140. }
  1141.  
  1142. public enum ShadowMode {
  1143. +
  1144. Disable,
  1145. InPass,
  1146. PostPass,
  1147. }
  1148. -
  1149. private EnumSet<Caps> requiredCaps = EnumSet.noneOf(Caps.class);
  1150. private String name;
  1151. -
  1152. private String vertName;
  1153. private String fragName;
  1154. + private String geomName;
  1155. + private String tcName;
  1156. + private String teName;
  1157. private String vertLanguage;
  1158. private String fragLanguage;
  1159. -
  1160. + private String geomLanguage;
  1161. + private String tcLanguage;
  1162. + private String teLanguage;
  1163. private DefineList presetDefines;
  1164. private boolean usesShaders;
  1165. private boolean usesNodes = false;
  1166. private List<ShaderNode> shaderNodes;
  1167. private ShaderGenerationInfo shaderGenerationInfo;
  1168. -
  1169. private RenderState renderState;
  1170. private RenderState forcedRenderState;
  1171. -
  1172. - private LightMode lightMode = LightMode.Disable;
  1173. + private LightMode lightMode = LightMode.Disable;
  1174. private ShadowMode shadowMode = ShadowMode.Disable;
  1175. -
  1176. private HashMap<String, String> defineParams;
  1177. private ArrayList<UniformBinding> worldBinds;
  1178.  
  1179. @@ -132,28 +147,29 @@
  1180. * @param name The name of the technique, should be set to <code>null</code>
  1181. * for default techniques.
  1182. */
  1183. - public TechniqueDef(String name){
  1184. + public TechniqueDef(String name) {
  1185. this.name = name == null ? "Default" : name;
  1186. }
  1187.  
  1188. /**
  1189. * Serialization only. Do not use.
  1190. */
  1191. - public TechniqueDef(){
  1192. + public TechniqueDef() {
  1193. }
  1194.  
  1195. /**
  1196. - * Returns the name of this technique as specified in the J3MD file.
  1197. - * Default techniques have the name "Default".
  1198. + * Returns the name of this technique as specified in the J3MD file. Default
  1199. + * techniques have the name "Default".
  1200. *
  1201. * @return the name of this technique
  1202. */
  1203. - public String getName(){
  1204. + public String getName() {
  1205. return name;
  1206. }
  1207.  
  1208. /**
  1209. * Returns the light mode.
  1210. + *
  1211. * @return the light mode.
  1212. * @see LightMode
  1213. */
  1214. @@ -174,6 +190,7 @@
  1215.  
  1216. /**
  1217. * Returns the shadow mode.
  1218. + *
  1219. * @return the shadow mode.
  1220. */
  1221. public ShadowMode getShadowMode() {
  1222. @@ -193,6 +210,7 @@
  1223.  
  1224. /**
  1225. * Returns the render state that this technique is using
  1226. + *
  1227. * @return the render state that this technique is using
  1228. * @see #setRenderState(com.jme3.material.RenderState)
  1229. */
  1230. @@ -218,7 +236,7 @@
  1231. *
  1232. * @see #setShaderFile(java.lang.String, java.lang.String, java.lang.String)
  1233. */
  1234. - public boolean isUsingShaders(){
  1235. + public boolean isUsingShaders() {
  1236. return usesShaders;
  1237. }
  1238.  
  1239. @@ -228,13 +246,13 @@
  1240. * @return true if this technique uses Shader Nodes, false otherwise.
  1241. *
  1242. */
  1243. - public boolean isUsingShaderNodes(){
  1244. + public boolean isUsingShaderNodes() {
  1245. return usesNodes;
  1246. }
  1247.  
  1248. /**
  1249. - * Gets the {@link Caps renderer capabilities} that are required
  1250. - * by this technique.
  1251. + * Gets the {@link Caps renderer capabilities} that are required by this
  1252. + * technique.
  1253. *
  1254. * @return the required renderer capabilities
  1255. */
  1256. @@ -250,20 +268,56 @@
  1257. * @param vertLanguage The vertex shader language
  1258. * @param fragLanguage The fragment shader language
  1259. */
  1260. - public void setShaderFile(String vertexShader, String fragmentShader, String vertLanguage, String fragLanguage){
  1261. + public void setShaderFile(String vertexShader, String fragmentShader, String geomShader, String tcShader, String teShader, String vertLanguage, String fragLanguage, String geomLang, String tcLang, String teLang) {
  1262. this.vertName = vertexShader;
  1263. this.fragName = fragmentShader;
  1264. + this.geomName = geomShader;
  1265. + this.tcName = tcShader;
  1266. + this.teName = teShader;
  1267. this.vertLanguage = vertLanguage;
  1268. this.fragLanguage = fragLanguage;
  1269. -
  1270. + this.geomLanguage = geomLang;
  1271. + this.tcLanguage = tcLang;
  1272. + this.teLanguage = teLang;
  1273. Caps vertCap = Caps.valueOf(vertLanguage);
  1274. requiredCaps.add(vertCap);
  1275. Caps fragCap = Caps.valueOf(fragLanguage);
  1276. requiredCaps.add(fragCap);
  1277. + //System.out.println(geomLanguage);
  1278. + if(geomLanguage!=null){
  1279. + Caps geomCap = Caps.valueOf(geomLanguage);
  1280.  
  1281. + requiredCaps.add(geomCap);
  1282. + }
  1283. + if(tcLanguage!=null){
  1284. + Caps tcCaps = Caps.valueOf(tcLanguage);
  1285. + requiredCaps.add(tcCaps);
  1286. + }
  1287. + if(teLanguage!=null){
  1288. + Caps teCaps = Caps.valueOf(teLanguage);
  1289. + requiredCaps.add(teCaps);
  1290. + }
  1291. + if (geomName != null) {
  1292. + requiredCaps.add(Caps.GeometryShader);
  1293. + }
  1294. + if (tcName != null || teName != null) {
  1295. + requiredCaps.add(Caps.TesselationShader);
  1296. + }
  1297. usesShaders = true;
  1298. }
  1299.  
  1300. + public String getGeometryShaderName() {
  1301. + return geomName;
  1302. + }
  1303. +
  1304. + public String getTessControlShaderName() {
  1305. + return tcName;
  1306. + }
  1307. +
  1308. + public String getTessEvaluationShaderName() {
  1309. + return teName;
  1310. + }
  1311. +
  1312. /**
  1313. * Returns the define name which the given material parameter influences.
  1314. *
  1315. @@ -272,7 +326,7 @@
  1316. *
  1317. * @see #addShaderParamDefine(java.lang.String, java.lang.String)
  1318. */
  1319. - public String getShaderParamDefine(String paramName){
  1320. + public String getShaderParamDefine(String paramName) {
  1321. if (defineParams == null) {
  1322. return null;
  1323. }
  1324. @@ -282,16 +336,16 @@
  1325. /**
  1326. * Adds a define linked to a material parameter.
  1327. * <p>
  1328. - * Any time the material parameter on the parent material is altered,
  1329. - * the appropriate define on the technique will be modified as well.
  1330. - * See the method
  1331. + * Any time the material parameter on the parent material is altered, the
  1332. + * appropriate define on the technique will be modified as well. See the
  1333. + * method
  1334. * {@link DefineList#set(java.lang.String, com.jme3.shader.VarType, java.lang.Object) }
  1335. * on the exact details of how the material parameter changes the define.
  1336. *
  1337. * @param paramName The name of the material parameter to link to.
  1338. * @param defineName The name of the define parameter, e.g. USE_LIGHTING
  1339. */
  1340. - public void addShaderParamDefine(String paramName, String defineName){
  1341. + public void addShaderParamDefine(String paramName, String defineName) {
  1342. if (defineParams == null) {
  1343. defineParams = new HashMap<String, String>();
  1344. }
  1345. @@ -303,7 +357,8 @@
  1346. *
  1347. * @return the {@link DefineList} for the preset defines.
  1348. *
  1349. - * @see #addShaderPresetDefine(java.lang.String, com.jme3.shader.VarType, java.lang.Object)
  1350. + * @see #addShaderPresetDefine(java.lang.String, com.jme3.shader.VarType,
  1351. + * java.lang.Object)
  1352. */
  1353. public DefineList getShaderPresetDefines() {
  1354. return presetDefines;
  1355. @@ -312,8 +367,8 @@
  1356. /**
  1357. * Adds a preset define.
  1358. * <p>
  1359. - * Preset defines do not depend upon any parameters to be activated,
  1360. - * they are always passed to the shader as long as this technique is used.
  1361. + * Preset defines do not depend upon any parameters to be activated, they
  1362. + * are always passed to the shader as long as this technique is used.
  1363. *
  1364. * @param defineName The name of the define parameter, e.g. USE_LIGHTING
  1365. * @param type The type of the define. See
  1366. @@ -322,7 +377,7 @@
  1367. *
  1368. * @param value The value of the define
  1369. */
  1370. - public void addShaderPresetDefine(String defineName, VarType type, Object value){
  1371. + public void addShaderPresetDefine(String defineName, VarType type, Object value) {
  1372. if (presetDefines == null) {
  1373. presetDefines = new DefineList();
  1374. }
  1375. @@ -330,8 +385,8 @@
  1376. }
  1377.  
  1378. /**
  1379. - * Returns the name of the fragment shader used by the technique, or null
  1380. - * if no fragment shader is specified.
  1381. + * Returns the name of the fragment shader used by the technique, or null if
  1382. + * no fragment shader is specified.
  1383. *
  1384. * @return the name of the fragment shader to be used.
  1385. */
  1386. @@ -339,10 +394,9 @@
  1387. return fragName;
  1388. }
  1389.  
  1390. -
  1391. /**
  1392. - * Returns the name of the vertex shader used by the technique, or null
  1393. - * if no vertex shader is specified.
  1394. + * Returns the name of the vertex shader used by the technique, or null if
  1395. + * no vertex shader is specified.
  1396. *
  1397. * @return the name of the vertex shader to be used.
  1398. */
  1399. @@ -372,22 +426,34 @@
  1400. return vertLanguage;
  1401. }
  1402.  
  1403. + public String getGeometryShaderLanguage() {
  1404. + return geomLanguage;
  1405. + }
  1406. +
  1407. + public String getTessControlShaderLanguage() {
  1408. + return tcLanguage;
  1409. + }
  1410. +
  1411. + public String getTessEvaluationShaderLanguage() {
  1412. + return teLanguage;
  1413. + }
  1414. +
  1415. /**
  1416. * Adds a new world parameter by the given name.
  1417. *
  1418. * @param name The world parameter to add.
  1419. - * @return True if the world parameter name was found and added
  1420. - * to the list of world parameters, false otherwise.
  1421. + * @return True if the world parameter name was found and added to the list
  1422. + * of world parameters, false otherwise.
  1423. */
  1424. public boolean addWorldParam(String name) {
  1425. - if (worldBinds == null){
  1426. + if (worldBinds == null) {
  1427. worldBinds = new ArrayList<UniformBinding>();
  1428. }
  1429.  
  1430. try {
  1431. - worldBinds.add( UniformBinding.valueOf(name) );
  1432. + worldBinds.add(UniformBinding.valueOf(name));
  1433. return true;
  1434. - } catch (IllegalArgumentException ex){
  1435. + } catch (IllegalArgumentException ex) {
  1436. return false;
  1437. }
  1438. }
  1439. @@ -401,8 +467,8 @@
  1440. }
  1441.  
  1442. /**
  1443. - * Returns a list of world parameters that are used by this
  1444. - * technique definition.
  1445. + * Returns a list of world parameters that are used by this technique
  1446. + * definition.
  1447. *
  1448. * @return The list of world parameters
  1449. */
  1450. @@ -410,20 +476,26 @@
  1451. return worldBinds;
  1452. }
  1453.  
  1454. - public void write(JmeExporter ex) throws IOException{
  1455. + public void write(JmeExporter ex) throws IOException {
  1456. OutputCapsule oc = ex.getCapsule(this);
  1457. oc.write(name, "name", null);
  1458. oc.write(vertName, "vertName", null);
  1459. oc.write(fragName, "fragName", null);
  1460. + oc.write(geomName, "geomName", null);
  1461. + oc.write(tcName, "tcName", null);
  1462. + oc.write(teName, "teName", null);
  1463. oc.write(vertLanguage, "vertLanguage", null);
  1464. oc.write(vertLanguage, "fragLanguage", null);
  1465. + oc.write(geomLanguage, "geomLanguage", null);
  1466. + oc.write(tcLanguage, "tcLanguage", null);
  1467. + oc.write(teLanguage, "teLanguage", null);
  1468. oc.write(presetDefines, "presetDefines", null);
  1469. oc.write(lightMode, "lightMode", LightMode.Disable);
  1470. oc.write(shadowMode, "shadowMode", ShadowMode.Disable);
  1471. oc.write(renderState, "renderState", null);
  1472. oc.write(usesShaders, "usesShaders", false);
  1473. oc.write(usesNodes, "usesNodes", false);
  1474. - oc.writeSavableArrayList((ArrayList)shaderNodes,"shaderNodes", null);
  1475. + oc.writeSavableArrayList((ArrayList) shaderNodes, "shaderNodes", null);
  1476. oc.write(shaderGenerationInfo, "shaderGenerationInfo", null);
  1477.  
  1478. // TODO: Finish this when Map<String, String> export is available
  1479. @@ -432,7 +504,7 @@
  1480. // oc.write(worldBinds, "worldBinds", null);
  1481. }
  1482.  
  1483. - public void read(JmeImporter im) throws IOException{
  1484. + public void read(JmeImporter im) throws IOException {
  1485. InputCapsule ic = im.getCapsule(this);
  1486. name = ic.readString("name", null);
  1487. vertName = ic.readString("vertName", null);
  1488. Index: src/core/com/jme3/renderer/Caps.java
  1489. --- src/core/com/jme3/renderer/Caps.java Base (BASE)
  1490. +++ src/core/com/jme3/renderer/Caps.java Locally Modified (Based On LOCAL)
  1491. @@ -106,6 +106,7 @@
  1492. */
  1493. OpenGL32,
  1494.  
  1495. + OpenGL40,
  1496. /**
  1497. * Supports OpenGL ARB program.
  1498. * <p>
  1499. @@ -149,6 +150,7 @@
  1500. */
  1501. GLSL330,
  1502.  
  1503. + GLSL400,
  1504. /**
  1505. * Supports reading from textures inside the vertex shader.
  1506. */
  1507. @@ -158,6 +160,7 @@
  1508. * Supports geometry shader.
  1509. */
  1510. GeometryShader,
  1511. + TesselationShader,
  1512.  
  1513. /**
  1514. * Supports texture arrays
  1515. Index: src/core/com/jme3/scene/Mesh.java
  1516. --- src/core/com/jme3/scene/Mesh.java Base (BASE)
  1517. +++ src/core/com/jme3/scene/Mesh.java Locally Modified (Based On LOCAL)
  1518. @@ -57,15 +57,15 @@
  1519. /**
  1520. * <code>Mesh</code> is used to store rendering data.
  1521. * <p>
  1522. - * All visible elements in a scene are represented by meshes.
  1523. - * Meshes may contain three types of geometric primitives:
  1524. + * All visible elements in a scene are represented by meshes. Meshes may contain
  1525. + * three types of geometric primitives:
  1526. * <ul>
  1527. - * <li>Points - Every vertex represents a single point in space,
  1528. - * the size of each point is specified via {@link Mesh#setPointSize(float) }.
  1529. - * Points can also be used for {@link RenderState#setPointSprite(boolean) point
  1530. + * <li>Points - Every vertex represents a single point in space, the size of
  1531. + * each point is specified via {@link Mesh#setPointSize(float) }. Points can
  1532. + * also be used for {@link RenderState#setPointSprite(boolean) point
  1533. * sprite} mode.</li>
  1534. - * <li>Lines - 2 vertices represent a line segment, with the width specified
  1535. - * via {@link Mesh#setLineWidth(float) }.</li>
  1536. + * <li>Lines - 2 vertices represent a line segment, with the width specified via {@link Mesh#setLineWidth(float)
  1537. + * }.</li>
  1538. * <li>Triangles - 3 vertices represent a solid triangle primitive. </li>
  1539. * </ul>
  1540. *
  1541. @@ -74,123 +74,109 @@
  1542. public class Mesh implements Savable, Cloneable {
  1543.  
  1544. /**
  1545. - * The mode of the Mesh specifies both the type of primitive represented
  1546. - * by the mesh and how the data should be interpreted.
  1547. + * The mode of the Mesh specifies both the type of primitive represented by
  1548. + * the mesh and how the data should be interpreted.
  1549. */
  1550. public enum Mode {
  1551. +
  1552. /**
  1553. - * A primitive is a single point in space. The size of the points
  1554. - * can be specified with {@link Mesh#setPointSize(float) }.
  1555. + * A primitive is a single point in space. The size of the points can be
  1556. + * specified with {@link Mesh#setPointSize(float) }.
  1557. */
  1558. Points(true),
  1559. -
  1560. /**
  1561. - * A primitive is a line segment. Every two vertices specify
  1562. - * a single line. {@link Mesh#setLineWidth(float) } can be used
  1563. - * to set the width of the lines.
  1564. + * A primitive is a line segment. Every two vertices specify a single
  1565. + * line. {@link Mesh#setLineWidth(float) } can be used to set the width
  1566. + * of the lines.
  1567. */
  1568. Lines(true),
  1569. -
  1570. /**
  1571. - * A primitive is a line segment. The first two vertices specify
  1572. - * a single line, while subsequent vertices are combined with the
  1573. - * previous vertex to make a line. {@link Mesh#setLineWidth(float) } can
  1574. - * be used to set the width of the lines.
  1575. + * A primitive is a line segment. The first two vertices specify a
  1576. + * single line, while subsequent vertices are combined with the previous
  1577. + * vertex to make a line. {@link Mesh#setLineWidth(float) } can be used
  1578. + * to set the width of the lines.
  1579. */
  1580. LineStrip(false),
  1581. -
  1582. /**
  1583. - * Identical to {@link #LineStrip} except that at the end
  1584. - * the last vertex is connected with the first to form a line.
  1585. - * {@link Mesh#setLineWidth(float) } can be used
  1586. - * to set the width of the lines.
  1587. + * Identical to {@link #LineStrip} except that at the end the last
  1588. + * vertex is connected with the first to form a line.
  1589. + * {@link Mesh#setLineWidth(float) } can be used to set the width of the
  1590. + * lines.
  1591. */
  1592. LineLoop(false),
  1593. -
  1594. /**
  1595. - * A primitive is a triangle. Each 3 vertices specify a single
  1596. - * triangle.
  1597. + * A primitive is a triangle. Each 3 vertices specify a single triangle.
  1598. */
  1599. Triangles(true),
  1600. -
  1601. /**
  1602. - * Similar to {@link #Triangles}, the first 3 vertices
  1603. - * specify a triangle, while subsequent vertices are combined with
  1604. - * the previous two to form a triangle.
  1605. + * Similar to {@link #Triangles}, the first 3 vertices specify a
  1606. + * triangle, while subsequent vertices are combined with the previous
  1607. + * two to form a triangle.
  1608. */
  1609. TriangleStrip(false),
  1610. -
  1611. /**
  1612. - * Similar to {@link #Triangles}, the first 3 vertices
  1613. - * specify a triangle, each 2 subsequent vertices are combined
  1614. - * with the very first vertex to make a triangle.
  1615. + * Similar to {@link #Triangles}, the first 3 vertices specify a
  1616. + * triangle, each 2 subsequent vertices are combined with the very first
  1617. + * vertex to make a triangle.
  1618. */
  1619. TriangleFan(false),
  1620. -
  1621. /**
  1622. - * A combination of various triangle modes. It is best to avoid
  1623. - * using this mode as it may not be supported by all renderers.
  1624. - * The {@link Mesh#setModeStart(int[]) mode start points} and
  1625. - * {@link Mesh#setElementLengths(int[]) element lengths} must
  1626. - * be specified for this mode.
  1627. + * A combination of various triangle modes. It is best to avoid using
  1628. + * this mode as it may not be supported by all renderers. The
  1629. + * {@link Mesh#setModeStart(int[]) mode start points} and
  1630. + * {@link Mesh#setElementLengths(int[]) element lengths} must be
  1631. + * specified for this mode.
  1632. */
  1633. - Hybrid(false);
  1634. -
  1635. + Hybrid(false),
  1636. + Patches(true);
  1637. private boolean listMode = false;
  1638.  
  1639. - private Mode(boolean listMode){
  1640. + private Mode(boolean listMode) {
  1641. this.listMode = listMode;
  1642. }
  1643.  
  1644. /**
  1645. - * Returns true if the specified mode is a list mode (meaning
  1646. - * ,it specifies the indices as a linear list and not some special
  1647. - * format).
  1648. + * Returns true if the specified mode is a list mode (meaning ,it
  1649. + * specifies the indices as a linear list and not some special format).
  1650. * Will return true for the types {@link #Points}, {@link #Lines} and
  1651. * {@link #Triangles}.
  1652. *
  1653. * @return true if the mode is a list type mode
  1654. */
  1655. - public boolean isListMode(){
  1656. + public boolean isListMode() {
  1657. return listMode;
  1658. }
  1659. }
  1660. -
  1661. /**
  1662. - * The bounding volume that contains the mesh entirely.
  1663. - * By default a BoundingBox (AABB).
  1664. + * The bounding volume that contains the mesh entirely. By default a
  1665. + * BoundingBox (AABB).
  1666. */
  1667. - private BoundingVolume meshBound = new BoundingBox();
  1668. -
  1669. + private BoundingVolume meshBound = new BoundingBox();
  1670. private CollisionData collisionTree = null;
  1671. -
  1672. private SafeArrayList<VertexBuffer> buffersList = new SafeArrayList<VertexBuffer>(VertexBuffer.class);
  1673. private IntMap<VertexBuffer> buffers = new IntMap<VertexBuffer>();
  1674. private VertexBuffer[] lodLevels;
  1675. private float pointSize = 1;
  1676. private float lineWidth = 1;
  1677. -
  1678. private transient int vertexArrayID = -1;
  1679. -
  1680. + private int patchVertices = 3;
  1681. private int vertCount = -1;
  1682. private int elementCount = -1;
  1683. private int maxNumWeights = -1; // only if using skeletal animation
  1684. -
  1685. private int[] elementLengths;
  1686. private int[] modeStart;
  1687. -
  1688. private Mode mode = Mode.Triangles;
  1689.  
  1690. /**
  1691. * Creates a new mesh with no {@link VertexBuffer vertex buffers}.
  1692. */
  1693. - public Mesh(){
  1694. + public Mesh() {
  1695. }
  1696.  
  1697. /**
  1698. * Create a shallow clone of this Mesh. The {@link VertexBuffer vertex
  1699. - * buffers} are shared between this and the clone mesh, the rest
  1700. - * of the data is cloned.
  1701. + * buffers} are shared between this and the clone mesh, the rest of the data
  1702. + * is cloned.
  1703. *
  1704. * @return A shallow clone of the mesh
  1705. */
  1706. @@ -201,7 +187,7 @@
  1707. clone.meshBound = meshBound.clone();
  1708. clone.collisionTree = collisionTree != null ? collisionTree : null;
  1709. clone.buffers = buffers.clone();
  1710. - clone.buffersList = new SafeArrayList<VertexBuffer>(VertexBuffer.class,buffersList);
  1711. + clone.buffersList = new SafeArrayList<VertexBuffer>(VertexBuffer.class, buffersList);
  1712. clone.vertexArrayID = -1;
  1713. if (elementLengths != null) {
  1714. clone.elementLengths = elementLengths.clone();
  1715. @@ -216,14 +202,13 @@
  1716. }
  1717.  
  1718. /**
  1719. - * Creates a deep clone of this mesh.
  1720. - * The {@link VertexBuffer vertex buffers} and the data inside them
  1721. - * is cloned.
  1722. + * Creates a deep clone of this mesh. The
  1723. + * {@link VertexBuffer vertex buffers} and the data inside them is cloned.
  1724. *
  1725. * @return a deep clone of this mesh.
  1726. */
  1727. - public Mesh deepClone(){
  1728. - try{
  1729. + public Mesh deepClone() {
  1730. + try {
  1731. Mesh clone = (Mesh) super.clone();
  1732. clone.meshBound = meshBound != null ? meshBound.clone() : null;
  1733.  
  1734. @@ -233,7 +218,7 @@
  1735.  
  1736. clone.buffers = new IntMap<VertexBuffer>();
  1737. clone.buffersList = new SafeArrayList<VertexBuffer>(VertexBuffer.class);
  1738. - for (VertexBuffer vb : buffersList.getArray()){
  1739. + for (VertexBuffer vb : buffersList.getArray()) {
  1740. VertexBuffer bufClone = vb.clone();
  1741. clone.buffers.put(vb.getBufferType().ordinal(), bufClone);
  1742. clone.buffersList.add(bufClone);
  1743. @@ -250,23 +235,22 @@
  1744. clone.elementLengths = elementLengths != null ? elementLengths.clone() : null;
  1745. clone.modeStart = modeStart != null ? modeStart.clone() : null;
  1746. return clone;
  1747. - }catch (CloneNotSupportedException ex){
  1748. + } catch (CloneNotSupportedException ex) {
  1749. throw new AssertionError();
  1750. }
  1751. }
  1752.  
  1753. /**
  1754. - * Clone the mesh for animation use.
  1755. - * This creates a shallow clone of the mesh, sharing most
  1756. - * of the {@link VertexBuffer vertex buffer} data, however the
  1757. - * {@link Type#Position}, {@link Type#Normal}, and {@link Type#Tangent} buffers
  1758. - * are deeply cloned.
  1759. + * Clone the mesh for animation use. This creates a shallow clone of the
  1760. + * mesh, sharing most of the {@link VertexBuffer vertex buffer} data,
  1761. + * however the {@link Type#Position}, {@link Type#Normal}, and
  1762. + * {@link Type#Tangent} buffers are deeply cloned.
  1763. *
  1764. * @return A clone of the mesh for animation use.
  1765. */
  1766. - public Mesh cloneForAnim(){
  1767. + public Mesh cloneForAnim() {
  1768. Mesh clone = clone();
  1769. - if (getBuffer(Type.BindPosePosition) != null){
  1770. + if (getBuffer(Type.BindPosePosition) != null) {
  1771. VertexBuffer oldPos = getBuffer(Type.Position);
  1772.  
  1773. // NOTE: creates deep clone
  1774. @@ -274,13 +258,13 @@
  1775. clone.clearBuffer(Type.Position);
  1776. clone.setBuffer(newPos);
  1777.  
  1778. - if (getBuffer(Type.BindPoseNormal) != null){
  1779. + if (getBuffer(Type.BindPoseNormal) != null) {
  1780. VertexBuffer oldNorm = getBuffer(Type.Normal);
  1781. VertexBuffer newNorm = oldNorm.clone();
  1782. clone.clearBuffer(Type.Normal);
  1783. clone.setBuffer(newNorm);
  1784.  
  1785. - if (getBuffer(Type.BindPoseTangent) != null){
  1786. + if (getBuffer(Type.BindPoseTangent) != null) {
  1787. VertexBuffer oldTang = getBuffer(Type.Tangent);
  1788. VertexBuffer newTang = oldTang.clone();
  1789. clone.clearBuffer(Type.Tangent);
  1790. @@ -293,16 +277,15 @@
  1791.  
  1792. /**
  1793. * Generates the {@link Type#BindPosePosition}, {@link Type#BindPoseNormal},
  1794. - * and {@link Type#BindPoseTangent}
  1795. - * buffers for this mesh by duplicating them based on the position and normal
  1796. - * buffers already set on the mesh.
  1797. - * This method does nothing if the mesh has no bone weight or index
  1798. - * buffers.
  1799. + * and {@link Type#BindPoseTangent} buffers for this mesh by duplicating
  1800. + * them based on the position and normal buffers already set on the mesh.
  1801. + * This method does nothing if the mesh has no bone weight or index buffers.
  1802. *
  1803. - * @param forSoftwareAnim Should be true if the bind pose is to be generated.
  1804. + * @param forSoftwareAnim Should be true if the bind pose is to be
  1805. + * generated.
  1806. */
  1807. - public void generateBindPose(boolean forSoftwareAnim){
  1808. - if (forSoftwareAnim){
  1809. + public void generateBindPose(boolean forSoftwareAnim) {
  1810. + if (forSoftwareAnim) {
  1811. VertexBuffer pos = getBuffer(Type.Position);
  1812. if (pos == null || getBuffer(Type.BoneIndex) == null) {
  1813. // ignore, this mesh doesn't have positional data
  1814. @@ -346,12 +329,12 @@
  1815. }
  1816.  
  1817. /**
  1818. - * Prepares the mesh for software skinning by converting the bone index
  1819. - * and weight buffers to heap buffers.
  1820. + * Prepares the mesh for software skinning by converting the bone index and
  1821. + * weight buffers to heap buffers.
  1822. *
  1823. * @param forSoftwareAnim Should be true to enable the conversion.
  1824. */
  1825. - public void prepareForAnim(boolean forSoftwareAnim){
  1826. + public void prepareForAnim(boolean forSoftwareAnim) {
  1827. if (forSoftwareAnim) {
  1828. // convert indices to ubytes on the heap
  1829. VertexBuffer indices = getBuffer(Type.BoneIndex);
  1830. @@ -389,7 +372,7 @@
  1831. //if HWBoneIndex and HWBoneWieght are empty, we setup them as direct
  1832. //buffers with software anim buffers data
  1833. VertexBuffer indicesHW = getBuffer(Type.HWBoneIndex);
  1834. - if(indicesHW.getData() == null){
  1835. + if (indicesHW.getData() == null) {
  1836. VertexBuffer indices = getBuffer(Type.BoneIndex);
  1837. ByteBuffer originalIndex = (ByteBuffer) indices.getData();
  1838. ByteBuffer directIndex = BufferUtils.createByteBuffer(originalIndex.capacity());
  1839. @@ -399,7 +382,7 @@
  1840. }
  1841.  
  1842. VertexBuffer weightsHW = getBuffer(Type.HWBoneWeight);
  1843. - if(weightsHW.getData() == null){
  1844. + if (weightsHW.getData() == null) {
  1845. VertexBuffer weights = getBuffer(Type.BoneWeight);
  1846. FloatBuffer originalWeight = (FloatBuffer) weights.getData();
  1847. FloatBuffer directWeight = BufferUtils.createFloatBuffer(originalWeight.capacity());
  1848. @@ -427,7 +410,7 @@
  1849. *
  1850. * @param lodLevels The LOD levels to set
  1851. */
  1852. - public void setLodLevels(VertexBuffer[] lodLevels){
  1853. + public void setLodLevels(VertexBuffer[] lodLevels) {
  1854. this.lodLevels = lodLevels;
  1855. }
  1856.  
  1857. @@ -435,23 +418,23 @@
  1858. * @return The number of LOD levels set on this mesh, including the main
  1859. * index buffer, returns zero if there are no lod levels.
  1860. */
  1861. - public int getNumLodLevels(){
  1862. + public int getNumLodLevels() {
  1863. return lodLevels != null ? lodLevels.length : 0;
  1864. }
  1865.  
  1866. /**
  1867. * Returns the lod level at the given index.
  1868. *
  1869. - * @param lod The lod level index, this does not include
  1870. - * the main index buffer.
  1871. + * @param lod The lod level index, this does not include the main index
  1872. + * buffer.
  1873. * @return The LOD index buffer at the index
  1874. *
  1875. - * @throws IndexOutOfBoundsException If the index is outside of the
  1876. - * range [0, {@link #getNumLodLevels()}].
  1877. + * @throws IndexOutOfBoundsException If the index is outside of the range
  1878. + * [0, {@link #getNumLodLevels()}].
  1879. *
  1880. * @see #setLodLevels(com.jme3.scene.VertexBuffer[])
  1881. */
  1882. - public VertexBuffer getLodLevel(int lod){
  1883. + public VertexBuffer getLodLevel(int lod) {
  1884. return lodLevels[lod];
  1885. }
  1886.  
  1887. @@ -524,9 +507,9 @@
  1888. }
  1889.  
  1890. /**
  1891. - * Set the maximum number of weights per vertex on this mesh.
  1892. - * Only relevant if this mesh has bone index/weight buffers.
  1893. - * This value should be between 0 and 4.
  1894. + * Set the maximum number of weights per vertex on this mesh. Only relevant
  1895. + * if this mesh has bone index/weight buffers. This value should be between
  1896. + * 0 and 4.
  1897. *
  1898. * @param maxNumWeights
  1899. */
  1900. @@ -546,12 +529,13 @@
  1901. }
  1902.  
  1903. /**
  1904. - * Set the size of points for meshes of mode {@link Mode#Points}.
  1905. - * The point size is specified as on-screen pixels, the default
  1906. - * value is 1.0. The point size
  1907. - * does nothing if {@link RenderState#setPointSprite(boolean) point sprite}
  1908. - * render state is enabled, in that case, the vertex shader must specify the
  1909. - * point size by writing to <code>gl_PointSize</code>.
  1910. + * Set the size of points for meshes of mode {@link Mode#Points}. The point
  1911. + * size is specified as on-screen pixels, the default value is 1.0. The
  1912. + * point size does nothing if
  1913. + * {@link RenderState#setPointSprite(boolean) point sprite} render state is
  1914. + * enabled, in that case, the vertex shader must specify the point size by
  1915. + * writing to
  1916. + * <code>gl_PointSize</code>.
  1917. *
  1918. * @param pointSize The size of points
  1919. */
  1920. @@ -569,9 +553,9 @@
  1921. }
  1922.  
  1923. /**
  1924. - * Specify the line width for meshes of the line modes, such
  1925. - * as {@link Mode#Lines}. The line width is specified as on-screen pixels,
  1926. - * the default value is 1.0.
  1927. + * Specify the line width for meshes of the line modes, such as
  1928. + * {@link Mode#Lines}. The line width is specified as on-screen pixels, the
  1929. + * default value is 1.0.
  1930. *
  1931. * @param lineWidth The line width
  1932. */
  1933. @@ -580,34 +564,34 @@
  1934. }
  1935.  
  1936. /**
  1937. - * Indicates to the GPU that this mesh will not be modified (a hint).
  1938. - * Sets the usage mode to {@link Usage#Static}
  1939. - * for all {@link VertexBuffer vertex buffers} on this Mesh.
  1940. + * Indicates to the GPU that this mesh will not be modified (a hint). Sets
  1941. + * the usage mode to {@link Usage#Static} for all
  1942. + * {@link VertexBuffer vertex buffers} on this Mesh.
  1943. */
  1944. public void setStatic() {
  1945. - for (VertexBuffer vb : buffersList.getArray()){
  1946. + for (VertexBuffer vb : buffersList.getArray()) {
  1947. vb.setUsage(Usage.Static);
  1948. }
  1949. }
  1950.  
  1951. /**
  1952. - * Indicates to the GPU that this mesh will be modified occasionally (a hint).
  1953. - * Sets the usage mode to {@link Usage#Dynamic}
  1954. - * for all {@link VertexBuffer vertex buffers} on this Mesh.
  1955. + * Indicates to the GPU that this mesh will be modified occasionally (a
  1956. + * hint). Sets the usage mode to {@link Usage#Dynamic} for all
  1957. + * {@link VertexBuffer vertex buffers} on this Mesh.
  1958. */
  1959. public void setDynamic() {
  1960. - for (VertexBuffer vb : buffersList.getArray()){
  1961. + for (VertexBuffer vb : buffersList.getArray()) {
  1962. vb.setUsage(Usage.Dynamic);
  1963. }
  1964. }
  1965.  
  1966. /**
  1967. - * Indicates to the GPU that this mesh will be modified every frame (a hint).
  1968. - * Sets the usage mode to {@link Usage#Stream}
  1969. - * for all {@link VertexBuffer vertex buffers} on this Mesh.
  1970. + * Indicates to the GPU that this mesh will be modified every frame (a
  1971. + * hint). Sets the usage mode to {@link Usage#Stream} for all
  1972. + * {@link VertexBuffer vertex buffers} on this Mesh.
  1973. */
  1974. - public void setStreamed(){
  1975. - for (VertexBuffer vb : buffersList.getArray()){
  1976. + public void setStreamed() {
  1977. + for (VertexBuffer vb : buffersList.getArray()) {
  1978. vb.setUsage(Usage.Stream);
  1979. }
  1980. }
  1981. @@ -618,7 +602,7 @@
  1982. * to <em>avoid</em> using this method as it disables some engine features.
  1983. */
  1984. @Deprecated
  1985. - public void setInterleaved(){
  1986. + public void setInterleaved() {
  1987. ArrayList<VertexBuffer> vbs = new ArrayList<VertexBuffer>();
  1988. vbs.addAll(buffersList);
  1989.  
  1990. @@ -627,7 +611,7 @@
  1991. vbs.remove(getBuffer(Type.Index));
  1992.  
  1993. int stride = 0; // aka bytes per vertex
  1994. - for (int i = 0; i < vbs.size(); i++){
  1995. + for (int i = 0; i < vbs.size(); i++) {
  1996. VertexBuffer vb = vbs.get(i);
  1997. // if (vb.getFormat() != Format.Float){
  1998. // throw new UnsupportedOperationException("Cannot interleave vertex buffer.\n" +
  1999. @@ -645,20 +629,20 @@
  2000. buffers.put(Type.InterleavedData.ordinal(), allData);
  2001. buffersList.add(allData);
  2002.  
  2003. - for (int vert = 0; vert < getVertexCount(); vert++){
  2004. - for (int i = 0; i < vbs.size(); i++){
  2005. + for (int vert = 0; vert < getVertexCount(); vert++) {
  2006. + for (int i = 0; i < vbs.size(); i++) {
  2007. VertexBuffer vb = vbs.get(i);
  2008. - switch (vb.getFormat()){
  2009. + switch (vb.getFormat()) {
  2010. case Float:
  2011. FloatBuffer fb = (FloatBuffer) vb.getData();
  2012. - for (int comp = 0; comp < vb.components; comp++){
  2013. + for (int comp = 0; comp < vb.components; comp++) {
  2014. dataBuf.putFloat(fb.get());
  2015. }
  2016. break;
  2017. case Byte:
  2018. case UnsignedByte:
  2019. ByteBuffer bb = (ByteBuffer) vb.getData();
  2020. - for (int comp = 0; comp < vb.components; comp++){
  2021. + for (int comp = 0; comp < vb.components; comp++) {
  2022. dataBuf.put(bb.get());
  2023. }
  2024. break;
  2025. @@ -666,20 +650,20 @@
  2026. case Short:
  2027. case UnsignedShort:
  2028. ShortBuffer sb = (ShortBuffer) vb.getData();
  2029. - for (int comp = 0; comp < vb.components; comp++){
  2030. + for (int comp = 0; comp < vb.components; comp++) {
  2031. dataBuf.putShort(sb.get());
  2032. }
  2033. break;
  2034. case Int:
  2035. case UnsignedInt:
  2036. IntBuffer ib = (IntBuffer) vb.getData();
  2037. - for (int comp = 0; comp < vb.components; comp++){
  2038. + for (int comp = 0; comp < vb.components; comp++) {
  2039. dataBuf.putInt(ib.get());
  2040. }
  2041. break;
  2042. case Double:
  2043. DoubleBuffer db = (DoubleBuffer) vb.getData();
  2044. - for (int comp = 0; comp < vb.components; comp++){
  2045. + for (int comp = 0; comp < vb.components; comp++) {
  2046. dataBuf.putDouble(db.get());
  2047. }
  2048. break;
  2049. @@ -688,7 +672,7 @@
  2050. }
  2051.  
  2052. int offset = 0;
  2053. - for (VertexBuffer vb : vbs){
  2054. + for (VertexBuffer vb : vbs) {
  2055. vb.setOffset(offset);
  2056. vb.setStride(stride);
  2057.  
  2058. @@ -698,8 +682,8 @@
  2059. }
  2060. }
  2061.  
  2062. - private int computeNumElements(int bufSize){
  2063. - switch (mode){
  2064. + private int computeNumElements(int bufSize) {
  2065. + switch (mode) {
  2066. case Triangles:
  2067. return bufSize / 3;
  2068. case TriangleFan:
  2069. @@ -713,6 +697,8 @@
  2070. return bufSize;
  2071. case LineStrip:
  2072. return bufSize - 1;
  2073. + case Patches:
  2074. + return bufSize-1;
  2075. default:
  2076. throw new UnsupportedOperationException();
  2077. }
  2078. @@ -720,26 +706,27 @@
  2079.  
  2080. /**
  2081. * Update the {@link #getVertexCount() vertex} and
  2082. - * {@link #getTriangleCount() triangle} counts for this mesh
  2083. - * based on the current data. This method should be called
  2084. - * after the {@link Buffer#capacity() capacities} of the mesh's
  2085. + * {@link #getTriangleCount() triangle} counts for this mesh based on the
  2086. + * current data. This method should be called after the
  2087. + * {@link Buffer#capacity() capacities} of the mesh's
  2088. * {@link VertexBuffer vertex buffers} has been altered.
  2089. *
  2090. * @throws IllegalStateException If this mesh is in
  2091. * {@link #setInterleaved() interleaved} format.
  2092. */
  2093. - public void updateCounts(){
  2094. - if (getBuffer(Type.InterleavedData) != null)
  2095. + public void updateCounts() {
  2096. + if (getBuffer(Type.InterleavedData) != null) {
  2097. throw new IllegalStateException("Should update counts before interleave");
  2098. + }
  2099.  
  2100. VertexBuffer pb = getBuffer(Type.Position);
  2101. VertexBuffer ib = getBuffer(Type.Index);
  2102. - if (pb != null){
  2103. + if (pb != null) {
  2104. vertCount = pb.getData().limit() / pb.getNumComponents();
  2105. }
  2106. - if (ib != null){
  2107. + if (ib != null) {
  2108. elementCount = computeNumElements(ib.getData().limit());
  2109. - }else{
  2110. + } else {
  2111. elementCount = computeNumElements(vertCount);
  2112. }
  2113. }
  2114. @@ -750,167 +737,166 @@
  2115. * @param lod The lod level to look up
  2116. * @return The triangle count for that LOD level
  2117. */
  2118. - public int getTriangleCount(int lod){
  2119. - if (lodLevels != null){
  2120. - if (lod < 0)
  2121. + public int getTriangleCount(int lod) {
  2122. + if (lodLevels != null) {
  2123. + if (lod < 0) {
  2124. throw new IllegalArgumentException("LOD level cannot be < 0");
  2125. + }
  2126.  
  2127. - if (lod >= lodLevels.length)
  2128. - throw new IllegalArgumentException("LOD level "+lod+" does not exist!");
  2129. + if (lod >= lodLevels.length) {
  2130. + throw new IllegalArgumentException("LOD level " + lod + " does not exist!");
  2131. + }
  2132.  
  2133. return computeNumElements(lodLevels[lod].getData().limit());
  2134. - }else if (lod == 0){
  2135. + } else if (lod == 0) {
  2136. return elementCount;
  2137. - }else{
  2138. + } else {
  2139. throw new IllegalArgumentException("There are no LOD levels on the mesh!");
  2140. }
  2141. }
  2142.  
  2143. /**
  2144. - * Returns how many triangles or elements are on this Mesh.
  2145. - * This value is only updated when {@link #updateCounts() } is called.
  2146. - * If the mesh mode is not a triangle mode, then this returns the
  2147. - * number of elements/primitives, e.g. how many lines or how many points,
  2148. - * instead of how many triangles.
  2149. + * Returns how many triangles or elements are on this Mesh. This value is
  2150. + * only updated when {@link #updateCounts() } is called. If the mesh mode is
  2151. + * not a triangle mode, then this returns the number of elements/primitives,
  2152. + * e.g. how many lines or how many points, instead of how many triangles.
  2153. *
  2154. * @return how many triangles/elements are on this Mesh.
  2155. */
  2156. - public int getTriangleCount(){
  2157. + public int getTriangleCount() {
  2158. return elementCount;
  2159. }
  2160.  
  2161. /**
  2162. - * Returns the number of vertices on this mesh.
  2163. - * The value is computed based on the position buffer, which
  2164. - * must be set on all meshes.
  2165. + * Returns the number of vertices on this mesh. The value is computed based
  2166. + * on the position buffer, which must be set on all meshes.
  2167. *
  2168. * @return Number of vertices on the mesh
  2169. */
  2170. - public int getVertexCount(){
  2171. + public int getVertexCount() {
  2172. return vertCount;
  2173. }
  2174.  
  2175. /**
  2176. - * Gets the triangle vertex positions at the given triangle index
  2177. - * and stores them into the v1, v2, v3 arguments.
  2178. + * Gets the triangle vertex positions at the given triangle index and stores
  2179. + * them into the v1, v2, v3 arguments.
  2180. *
  2181. - * @param index The index of the triangle.
  2182. - * Should be between 0 and {@link #getTriangleCount()}.
  2183. + * @param index The index of the triangle. Should be between 0 and
  2184. + * {@link #getTriangleCount()}.
  2185. *
  2186. * @param v1 Vector to contain first vertex position
  2187. * @param v2 Vector to contain second vertex position
  2188. * @param v3 Vector to contain third vertex position
  2189. */
  2190. - public void getTriangle(int index, Vector3f v1, Vector3f v2, Vector3f v3){
  2191. + public void getTriangle(int index, Vector3f v1, Vector3f v2, Vector3f v3) {
  2192. VertexBuffer pb = getBuffer(Type.Position);
  2193. IndexBuffer ib = getIndicesAsList();
  2194. - if (pb != null && pb.getFormat() == Format.Float && pb.getNumComponents() == 3){
  2195. + if (pb != null && pb.getFormat() == Format.Float && pb.getNumComponents() == 3) {
  2196. FloatBuffer fpb = (FloatBuffer) pb.getData();
  2197.  
  2198. // aquire triangle's vertex indices
  2199. int vertIndex = index * 3;
  2200. int vert1 = ib.get(vertIndex);
  2201. - int vert2 = ib.get(vertIndex+1);
  2202. - int vert3 = ib.get(vertIndex+2);
  2203. + int vert2 = ib.get(vertIndex + 1);
  2204. + int vert3 = ib.get(vertIndex + 2);
  2205.  
  2206. BufferUtils.populateFromBuffer(v1, fpb, vert1);
  2207. BufferUtils.populateFromBuffer(v2, fpb, vert2);
  2208. BufferUtils.populateFromBuffer(v3, fpb, vert3);
  2209. - }else{
  2210. + } else {
  2211. throw new UnsupportedOperationException("Position buffer not set or "
  2212. + " has incompatible format");
  2213. }
  2214. }
  2215.  
  2216. /**
  2217. - * Gets the triangle vertex positions at the given triangle index
  2218. - * and stores them into the {@link Triangle} argument.
  2219. - * Also sets the triangle index to the <code>index</code> argument.
  2220. + * Gets the triangle vertex positions at the given triangle index and stores
  2221. + * them into the {@link Triangle} argument. Also sets the triangle index to
  2222. + * the
  2223. + * <code>index</code> argument.
  2224. *
  2225. - * @param index The index of the triangle.
  2226. - * Should be between 0 and {@link #getTriangleCount()}.
  2227. + * @param index The index of the triangle. Should be between 0 and
  2228. + * {@link #getTriangleCount()}.
  2229. *
  2230. * @param tri The triangle to store the positions in
  2231. */
  2232. - public void getTriangle(int index, Triangle tri){
  2233. + public void getTriangle(int index, Triangle tri) {
  2234. getTriangle(index, tri.get1(), tri.get2(), tri.get3());
  2235. tri.setIndex(index);
  2236. tri.setNormal(null);
  2237. }
  2238.  
  2239. /**
  2240. - * Gets the triangle vertex indices at the given triangle index
  2241. - * and stores them into the given int array.
  2242. + * Gets the triangle vertex indices at the given triangle index and stores
  2243. + * them into the given int array.
  2244. *
  2245. - * @param index The index of the triangle.
  2246. - * Should be between 0 and {@link #getTriangleCount()}.
  2247. + * @param index The index of the triangle. Should be between 0 and
  2248. + * {@link #getTriangleCount()}.
  2249. *
  2250. * @param indices Indices of the triangle's vertices
  2251. */
  2252. - public void getTriangle(int index, int[] indices){
  2253. + public void getTriangle(int index, int[] indices) {
  2254. IndexBuffer ib = getIndicesAsList();
  2255.  
  2256. // acquire triangle's vertex indices
  2257. int vertIndex = index * 3;
  2258. indices[0] = ib.get(vertIndex);
  2259. - indices[1] = ib.get(vertIndex+1);
  2260. - indices[2] = ib.get(vertIndex+2);
  2261. + indices[1] = ib.get(vertIndex + 1);
  2262. + indices[2] = ib.get(vertIndex + 2);
  2263. }
  2264.  
  2265. /**
  2266. * Returns the mesh's VAO ID. Internal use only.
  2267. */
  2268. - public int getId(){
  2269. + public int getId() {
  2270. return vertexArrayID;
  2271. }
  2272.  
  2273. /**
  2274. * Sets the mesh's VAO ID. Internal use only.
  2275. */
  2276. - public void setId(int id){
  2277. - if (vertexArrayID != -1)
  2278. + public void setId(int id) {
  2279. + if (vertexArrayID != -1) {
  2280. throw new IllegalStateException("ID has already been set.");
  2281. + }
  2282.  
  2283. vertexArrayID = id;
  2284. }
  2285.  
  2286. /**
  2287. - * Generates a collision tree for the mesh.
  2288. - * Called automatically by {@link #collideWith(com.jme3.collision.Collidable,
  2289. + * Generates a collision tree for the mesh. Called automatically by {@link #collideWith(com.jme3.collision.Collidable,
  2290. * com.jme3.math.Matrix4f,
  2291. * com.jme3.bounding.BoundingVolume,
  2292. * com.jme3.collision.CollisionResults) }.
  2293. */
  2294. - public void createCollisionData(){
  2295. + public void createCollisionData() {
  2296. BIHTree tree = new BIHTree(this);
  2297. tree.construct();
  2298. collisionTree = tree;
  2299. }
  2300.  
  2301. /**
  2302. - * Clears any previously generated collision data. Use this if
  2303. - * the mesh has changed in some way that invalidates any previously
  2304. - * generated BIHTree.
  2305. + * Clears any previously generated collision data. Use this if the mesh has
  2306. + * changed in some way that invalidates any previously generated BIHTree.
  2307. */
  2308. public void clearCollisionData() {
  2309. collisionTree = null;
  2310. }
  2311.  
  2312. /**
  2313. - * Handles collision detection, internal use only.
  2314. - * User code should only use collideWith() on scene
  2315. - * graph elements such as {@link Spatial}s.
  2316. + * Handles collision detection, internal use only. User code should only use
  2317. + * collideWith() on scene graph elements such as {@link Spatial}s.
  2318. */
  2319. public int collideWith(Collidable other,
  2320. Matrix4f worldMatrix,
  2321. BoundingVolume worldBound,
  2322. - CollisionResults results){
  2323. + CollisionResults results) {
  2324.  
  2325. if (getVertexCount() == 0) {
  2326. return 0;
  2327. }
  2328.  
  2329. - if (collisionTree == null){
  2330. + if (collisionTree == null) {
  2331. createCollisionData();
  2332. }
  2333.  
  2334. @@ -918,15 +904,16 @@
  2335. }
  2336.  
  2337. /**
  2338. - * Sets the {@link VertexBuffer} on the mesh.
  2339. - * This will update the vertex/triangle counts if needed.
  2340. + * Sets the {@link VertexBuffer} on the mesh. This will update the
  2341. + * vertex/triangle counts if needed.
  2342. *
  2343. * @param vb The buffer to set
  2344. * @throws IllegalArgumentException If the buffer type is already set
  2345. */
  2346. - public void setBuffer(VertexBuffer vb){
  2347. - if (buffers.containsKey(vb.getBufferType().ordinal()))
  2348. - throw new IllegalArgumentException("Buffer type already set: "+vb.getBufferType());
  2349. + public void setBuffer(VertexBuffer vb) {
  2350. + if (buffers.containsKey(vb.getBufferType().ordinal())) {
  2351. + throw new IllegalArgumentException("Buffer type already set: " + vb.getBufferType());
  2352. + }
  2353.  
  2354. buffers.put(vb.getBufferType().ordinal(), vb);
  2355. buffersList.add(vb);
  2356. @@ -934,23 +921,22 @@
  2357. }
  2358.  
  2359. /**
  2360. - * Unsets the {@link VertexBuffer} set on this mesh
  2361. - * with the given type. Does nothing if the vertex buffer type is not set
  2362. - * initially.
  2363. + * Unsets the {@link VertexBuffer} set on this mesh with the given type.
  2364. + * Does nothing if the vertex buffer type is not set initially.
  2365. *
  2366. * @param type The buffer type to remove
  2367. */
  2368. - public void clearBuffer(VertexBuffer.Type type){
  2369. + public void clearBuffer(VertexBuffer.Type type) {
  2370. VertexBuffer vb = buffers.remove(type.ordinal());
  2371. - if (vb != null){
  2372. + if (vb != null) {
  2373. buffersList.remove(vb);
  2374. updateCounts();
  2375. }
  2376. }
  2377.  
  2378. /**
  2379. - * Creates a {@link VertexBuffer} for the mesh or modifies
  2380. - * the existing one per the parameters given.
  2381. + * Creates a {@link VertexBuffer} for the mesh or modifies the existing one
  2382. + * per the parameters given.
  2383. *
  2384. * @param type The type of the buffer
  2385. * @param components Number of components
  2386. @@ -960,14 +946,14 @@
  2387. * @throws UnsupportedOperationException If the buffer already set is
  2388. * incompatible with the parameters given.
  2389. */
  2390. - public void setBuffer(Type type, int components, Format format, Buffer buf){
  2391. + public void setBuffer(Type type, int components, Format format, Buffer buf) {
  2392. VertexBuffer vb = buffers.get(type.ordinal());
  2393. - if (vb == null){
  2394. + if (vb == null) {
  2395. vb = new VertexBuffer(type);
  2396. vb.setupData(Usage.Dynamic, components, format, buf);
  2397. setBuffer(vb);
  2398. - }else{
  2399. - if (vb.getNumComponents() != components || vb.getFormat() != format){
  2400. + } else {
  2401. + if (vb.getNumComponents() != components || vb.getFormat() != format) {
  2402. throw new UnsupportedOperationException("The buffer already set "
  2403. + "is incompatible with the given parameters");
  2404. }
  2405. @@ -979,11 +965,11 @@
  2406. /**
  2407. * Set a floating point {@link VertexBuffer} on the mesh.
  2408. *
  2409. - * @param type The type of {@link VertexBuffer},
  2410. - * e.g. {@link Type#Position}, {@link Type#Normal}, etc.
  2411. + * @param type The type of {@link VertexBuffer}, e.g.
  2412. + * {@link Type#Position}, {@link Type#Normal}, etc.
  2413. *
  2414. - * @param components Number of components on the vertex buffer, should
  2415. - * be between 1 and 4.
  2416. + * @param components Number of components on the vertex buffer, should be
  2417. + * between 1 and 4.
  2418. *
  2419. * @param buf The floating point data to contain
  2420. */
  2421. @@ -991,7 +977,7 @@
  2422. setBuffer(type, components, Format.Float, buf);
  2423. }
  2424.  
  2425. - public void setBuffer(Type type, int components, float[] buf){
  2426. + public void setBuffer(Type type, int components, float[] buf) {
  2427. setBuffer(type, components, BufferUtils.createFloatBuffer(buf));
  2428. }
  2429.  
  2430. @@ -999,7 +985,7 @@
  2431. setBuffer(type, components, Format.UnsignedInt, buf);
  2432. }
  2433.  
  2434. - public void setBuffer(Type type, int components, int[] buf){
  2435. + public void setBuffer(Type type, int components, int[] buf) {
  2436. setBuffer(type, components, BufferUtils.createIntBuffer(buf));
  2437. }
  2438.  
  2439. @@ -1007,7 +993,7 @@
  2440. setBuffer(type, components, Format.UnsignedShort, buf);
  2441. }
  2442.  
  2443. - public void setBuffer(Type type, int components, byte[] buf){
  2444. + public void setBuffer(Type type, int components, byte[] buf) {
  2445. setBuffer(type, components, BufferUtils.createByteBuffer(buf));
  2446. }
  2447.  
  2448. @@ -1015,72 +1001,72 @@
  2449. setBuffer(type, components, Format.UnsignedByte, buf);
  2450. }
  2451.  
  2452. - public void setBuffer(Type type, int components, short[] buf){
  2453. + public void setBuffer(Type type, int components, short[] buf) {
  2454. setBuffer(type, components, BufferUtils.createShortBuffer(buf));
  2455. }
  2456.  
  2457. /**
  2458. - * Get the {@link VertexBuffer} stored on this mesh with the given
  2459. - * type.
  2460. + * Get the {@link VertexBuffer} stored on this mesh with the given type.
  2461. *
  2462. * @param type The type of VertexBuffer
  2463. * @return the VertexBuffer data, or null if not set
  2464. */
  2465. - public VertexBuffer getBuffer(Type type){
  2466. + public VertexBuffer getBuffer(Type type) {
  2467. return buffers.get(type.ordinal());
  2468. }
  2469.  
  2470. /**
  2471. - * Get the {@link VertexBuffer} data stored on this mesh in float
  2472. - * format.
  2473. + * Get the {@link VertexBuffer} data stored on this mesh in float format.
  2474. *
  2475. * @param type The type of VertexBuffer
  2476. * @return the VertexBuffer data, or null if not set
  2477. */
  2478. public FloatBuffer getFloatBuffer(Type type) {
  2479. VertexBuffer vb = getBuffer(type);
  2480. - if (vb == null)
  2481. + if (vb == null) {
  2482. return null;
  2483. + }
  2484.  
  2485. return (FloatBuffer) vb.getData();
  2486. }
  2487.  
  2488. /**
  2489. - * Get the {@link VertexBuffer} data stored on this mesh in short
  2490. - * format.
  2491. + * Get the {@link VertexBuffer} data stored on this mesh in short format.
  2492. *
  2493. * @param type The type of VertexBuffer
  2494. * @return the VertexBuffer data, or null if not set
  2495. */
  2496. public ShortBuffer getShortBuffer(Type type) {
  2497. VertexBuffer vb = getBuffer(type);
  2498. - if (vb == null)
  2499. + if (vb == null) {
  2500. return null;
  2501. + }
  2502.  
  2503. return (ShortBuffer) vb.getData();
  2504. }
  2505.  
  2506. /**
  2507. - * Acquires an index buffer that will read the vertices on the mesh
  2508. - * as a list.
  2509. + * Acquires an index buffer that will read the vertices on the mesh as a
  2510. + * list.
  2511. *
  2512. * @return A virtual or wrapped index buffer to read the data as a list
  2513. */
  2514. - public IndexBuffer getIndicesAsList(){
  2515. - if (mode == Mode.Hybrid)
  2516. + public IndexBuffer getIndicesAsList() {
  2517. + if (mode == Mode.Hybrid) {
  2518. throw new UnsupportedOperationException("Hybrid mode not supported");
  2519. + }
  2520.  
  2521. IndexBuffer ib = getIndexBuffer();
  2522. - if (ib != null){
  2523. - if (mode.isListMode()){
  2524. + if (ib != null) {
  2525. + if (mode.isListMode()) {
  2526. // already in list mode
  2527. return ib;
  2528. - }else{
  2529. + } else {
  2530. // not in list mode but it does have an index buffer
  2531. // wrap it so the data is converted to list format
  2532. return new WrappedIndexBuffer(this);
  2533. }
  2534. - }else{
  2535. + } else {
  2536. // return a virtual index buffer that will supply
  2537. // "fake" indices in list format
  2538. return new VirtualIndexBuffer(vertCount, mode);
  2539. @@ -1088,8 +1074,8 @@
  2540. }
  2541.  
  2542. /**
  2543. - * Get the index buffer for this mesh.
  2544. - * Will return <code>null</code> if no index buffer is set.
  2545. + * Get the index buffer for this mesh. Will return
  2546. + * <code>null</code> if no index buffer is set.
  2547. *
  2548. * @return The index buffer of this mesh.
  2549. *
  2550. @@ -1097,18 +1083,27 @@
  2551. */
  2552. public IndexBuffer getIndexBuffer() {
  2553. VertexBuffer vb = getBuffer(Type.Index);
  2554. - if (vb == null)
  2555. + if (vb == null) {
  2556. return null;
  2557. + }
  2558.  
  2559. return IndexBuffer.wrapIndexBuffer(vb.getData());
  2560. }
  2561.  
  2562. + public int getPatchVertices() {
  2563. + return patchVertices;
  2564. + }
  2565. +
  2566. + public void setPatchVertices(int patchVertices) {
  2567. + this.patchVertices = patchVertices;
  2568. + }
  2569. +
  2570. /**
  2571. - * Extracts the vertex attributes from the given mesh into
  2572. - * this mesh, by using this mesh's {@link #getIndexBuffer() index buffer}
  2573. - * to index into the attributes of the other mesh.
  2574. - * Note that this will also change this mesh's index buffer so that
  2575. - * the references to the vertex data match the new indices.
  2576. + * Extracts the vertex attributes from the given mesh into this mesh, by
  2577. + * using this mesh's {@link #getIndexBuffer() index buffer} to index into
  2578. + * the attributes of the other mesh. Note that this will also change this
  2579. + * mesh's index buffer so that the references to the vertex data match the
  2580. + * new indices.
  2581. *
  2582. * @param other The mesh to extract the vertex data from
  2583. */
  2584. @@ -1185,7 +1180,7 @@
  2585. //check for data before copying, some buffers are just empty shells
  2586. //for caching purpose (HW skinning buffers), and will be filled when
  2587. //needed
  2588. - if(oldVb.getData()!=null){
  2589. + if (oldVb.getData() != null) {
  2590. // Create a new vertex buffer with similar configuration, but
  2591. // with the capacity of number of unique vertices
  2592. Buffer buffer = VertexBuffer.createBuffer(oldVb.getFormat(), oldVb.getNumComponents(), newNumVerts);
  2593. @@ -1215,39 +1210,41 @@
  2594. }
  2595.  
  2596. /**
  2597. - * Scales the texture coordinate buffer on this mesh by the given
  2598. - * scale factor.
  2599. + * Scales the texture coordinate buffer on this mesh by the given scale
  2600. + * factor.
  2601. * <p>
  2602. - * Note that values above 1 will cause the
  2603. - * texture to tile, while values below 1 will cause the texture
  2604. - * to stretch.
  2605. + * Note that values above 1 will cause the texture to tile, while values
  2606. + * below 1 will cause the texture to stretch.
  2607. * </p>
  2608. *
  2609. - * @param scaleFactor The scale factor to scale by. Every texture
  2610. - * coordinate is multiplied by this vector to get the result.
  2611. + * @param scaleFactor The scale factor to scale by. Every texture coordinate
  2612. + * is multiplied by this vector to get the result.
  2613. *
  2614. - * @throws IllegalStateException If there's no texture coordinate
  2615. - * buffer on the mesh
  2616. - * @throws UnsupportedOperationException If the texture coordinate
  2617. - * buffer is not in 2D float format.
  2618. + * @throws IllegalStateException If there's no texture coordinate buffer on
  2619. + * the mesh
  2620. + * @throws UnsupportedOperationException If the texture coordinate buffer is
  2621. + * not in 2D float format.
  2622. */
  2623. - public void scaleTextureCoordinates(Vector2f scaleFactor){
  2624. + public void scaleTextureCoordinates(Vector2f scaleFactor) {
  2625. VertexBuffer tc = getBuffer(Type.TexCoord);
  2626. - if (tc == null)
  2627. + if (tc == null) {
  2628. throw new IllegalStateException("The mesh has no texture coordinates");
  2629. + }
  2630.  
  2631. - if (tc.getFormat() != VertexBuffer.Format.Float)
  2632. + if (tc.getFormat() != VertexBuffer.Format.Float) {
  2633. throw new UnsupportedOperationException("Only float texture coord format is supported");
  2634. + }
  2635.  
  2636. - if (tc.getNumComponents() != 2)
  2637. + if (tc.getNumComponents() != 2) {
  2638. throw new UnsupportedOperationException("Only 2D texture coords are supported");
  2639. + }
  2640.  
  2641. FloatBuffer fb = (FloatBuffer) tc.getData();
  2642. fb.clear();
  2643. - for (int i = 0; i < fb.limit() / 2; i++){
  2644. + for (int i = 0; i < fb.limit() / 2; i++) {
  2645. float x = fb.get();
  2646. float y = fb.get();
  2647. - fb.position(fb.position()-2);
  2648. + fb.position(fb.position() - 2);
  2649. x *= scaleFactor.getX();
  2650. y *= scaleFactor.getY();
  2651. fb.put(x).put(y);
  2652. @@ -1257,20 +1254,20 @@
  2653. }
  2654.  
  2655. /**
  2656. - * Updates the bounding volume of this mesh.
  2657. - * The method does nothing if the mesh has no {@link Type#Position} buffer.
  2658. - * It is expected that the position buffer is a float buffer with 3 components.
  2659. + * Updates the bounding volume of this mesh. The method does nothing if the
  2660. + * mesh has no {@link Type#Position} buffer. It is expected that the
  2661. + * position buffer is a float buffer with 3 components.
  2662. */
  2663. - public void updateBound(){
  2664. + public void updateBound() {
  2665. VertexBuffer posBuf = getBuffer(VertexBuffer.Type.Position);
  2666. - if (meshBound != null && posBuf != null){
  2667. - meshBound.computeFromPoints((FloatBuffer)posBuf.getData());
  2668. + if (meshBound != null && posBuf != null) {
  2669. + meshBound.computeFromPoints((FloatBuffer) posBuf.getData());
  2670. }
  2671. }
  2672.  
  2673. /**
  2674. - * Returns the {@link BoundingVolume} of this Mesh.
  2675. - * By default the bounding volume is a {@link BoundingBox}.
  2676. + * Returns the {@link BoundingVolume} of this Mesh. By default the bounding
  2677. + * volume is a {@link BoundingBox}.
  2678. *
  2679. * @return the bounding volume of this mesh
  2680. */
  2681. @@ -1279,8 +1276,8 @@
  2682. }
  2683.  
  2684. /**
  2685. - * Sets the {@link BoundingVolume} for this Mesh.
  2686. - * The bounding volume is recomputed by calling {@link #updateBound() }.
  2687. + * Sets the {@link BoundingVolume} for this Mesh. The bounding volume is
  2688. + * recomputed by calling {@link #updateBound() }.
  2689. *
  2690. * @param modelBound The model bound to set
  2691. */
  2692. @@ -1290,14 +1287,13 @@
  2693.  
  2694. /**
  2695. * Returns a map of all {@link VertexBuffer vertex buffers} on this Mesh.
  2696. - * The integer key for the map is the {@link Enum#ordinal() ordinal}
  2697. - * of the vertex buffer's {@link Type}.
  2698. - * Note that the returned map is a reference to the map used internally,
  2699. - * modifying it will cause undefined results.
  2700. + * The integer key for the map is the {@link Enum#ordinal() ordinal} of the
  2701. + * vertex buffer's {@link Type}. Note that the returned map is a reference
  2702. + * to the map used internally, modifying it will cause undefined results.
  2703. *
  2704. * @return map of vertex buffers on this mesh.
  2705. */
  2706. - public IntMap<VertexBuffer> getBuffers(){
  2707. + public IntMap<VertexBuffer> getBuffers() {
  2708. return buffers;
  2709. }
  2710.  
  2711. @@ -1310,7 +1306,7 @@
  2712. *
  2713. * @return list of vertex buffers on this mesh.
  2714. */
  2715. - public SafeArrayList<VertexBuffer> getBufferList(){
  2716. + public SafeArrayList<VertexBuffer> getBufferList() {
  2717. return buffersList;
  2718. }
  2719.  
  2720. @@ -1319,7 +1315,6 @@
  2721. return getBuffer(Type.BindPosePosition) != null && getBuffer(Type.BoneIndex) != null && getBuffer(Type.BoneWeight) != null;
  2722. }
  2723.  
  2724. -
  2725. public void write(JmeExporter ex) throws IOException {
  2726. OutputCapsule out = ex.getCapsule(this);
  2727.  
  2728. @@ -1381,12 +1376,12 @@
  2729.  
  2730. // in.readStringSavableMap("buffers", null);
  2731. buffers = (IntMap<VertexBuffer>) in.readIntSavableMap("buffers", null);
  2732. - for (Entry<VertexBuffer> entry : buffers){
  2733. + for (Entry<VertexBuffer> entry : buffers) {
  2734. buffersList.add(entry.getValue());
  2735. }
  2736.  
  2737. //creating hw animation buffers empty so that they are put in the cache
  2738. - if(isAnimated()){
  2739. + if (isAnimated()) {
  2740. VertexBuffer hwBoneIndex = new VertexBuffer(Type.HWBoneIndex);
  2741. hwBoneIndex.setUsage(Usage.CpuOnly);
  2742. setBuffer(hwBoneIndex);
  2743. @@ -1398,8 +1393,7 @@
  2744. Savable[] lodLevelsSavable = in.readSavableArray("lodLevels", null);
  2745. if (lodLevelsSavable != null) {
  2746. lodLevels = new VertexBuffer[lodLevelsSavable.length];
  2747. - System.arraycopy( lodLevelsSavable, 0, lodLevels, 0, lodLevels.length);
  2748. + System.arraycopy(lodLevelsSavable, 0, lodLevels, 0, lodLevels.length);
  2749. }
  2750. }
  2751. -
  2752. }
  2753. Index: src/core/com/jme3/shader/Shader.java
  2754. --- src/core/com/jme3/shader/Shader.java Base (BASE)
  2755. +++ src/core/com/jme3/shader/Shader.java Locally Modified (Based On LOCAL)
  2756. @@ -74,7 +74,11 @@
  2757. /**
  2758. * Control geometry assembly. (e.g compile a triangle list from input data)
  2759. */
  2760. - Geometry;
  2761. + Geometry,
  2762. +
  2763. + TesselationControl,
  2764. +
  2765. + TesselationEvaluation;
  2766. }
  2767.  
  2768. /**
  2769. Index: src/core/com/jme3/shader/ShaderKey.java
  2770. --- src/core/com/jme3/shader/ShaderKey.java Base (BASE)
  2771. +++ src/core/com/jme3/shader/ShaderKey.java Locally Modified (Based On LOCAL)
  2772. @@ -44,18 +44,30 @@
  2773. protected DefineList defines;
  2774. protected String vertLanguage;
  2775. protected String fragLanguage;
  2776. + protected String geomName;
  2777. + protected String tcName;
  2778. + protected String teName;
  2779. + protected String geomLanguage;
  2780. + protected String tcLanguage;
  2781. + protected String teLanguage;
  2782. protected int cachedHashedCode = 0;
  2783. protected boolean usesShaderNodes = false;
  2784.  
  2785. - public ShaderKey(){
  2786. + public ShaderKey() {
  2787. }
  2788.  
  2789. - public ShaderKey(String vertName, String fragName, DefineList defines, String vertLanguage, String fragLanguage){
  2790. + public ShaderKey(String vertName, String fragName, String geomName, String tcName, String teName, DefineList defines, String vertLanguage, String fragLanguage, String geomLang, String tcLang, String teLang) {
  2791. super(vertName);
  2792. this.fragName = fragName;
  2793. + this.geomName = geomName;
  2794. + this.tcName = tcName;
  2795. + this.teName = teName;
  2796. this.defines = defines;
  2797. this.vertLanguage = vertLanguage;
  2798. this.fragLanguage = fragLanguage;
  2799. + this.geomLanguage = geomLang;
  2800. + this.tcLanguage = tcLang;
  2801. + this.teLanguage = teLang;
  2802. }
  2803.  
  2804. @Override
  2805. @@ -67,14 +79,14 @@
  2806. }
  2807.  
  2808. @Override
  2809. - public String toString(){
  2810. - return "V="+name + " F=" + fragName + (defines != null ? defines : "");
  2811. + public String toString() {
  2812. + return "V=" + name + " F=" + fragName + (defines != null ? defines : "");
  2813. }
  2814.  
  2815. @Override
  2816. public boolean equals(Object obj) {
  2817. final ShaderKey other = (ShaderKey) obj;
  2818. - if (name.equals(other.name) && fragName.equals(other.fragName)){
  2819. + 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))) {
  2820. if (defines != null && other.defines != null) {
  2821. return defines.equals(other.defines);
  2822. } else if (defines != null || other.defines != null) {
  2823. @@ -102,7 +114,7 @@
  2824. return defines;
  2825. }
  2826.  
  2827. - public String getVertName(){
  2828. + public String getVertName() {
  2829. return name;
  2830. }
  2831.  
  2832. @@ -110,6 +122,18 @@
  2833. return fragName;
  2834. }
  2835.  
  2836. + public String getGeomName() {
  2837. + return geomName;
  2838. + }
  2839. +
  2840. + public String getTcName() {
  2841. + return tcName;
  2842. + }
  2843. +
  2844. + public String getTeName() {
  2845. + return teName;
  2846. + }
  2847. +
  2848. /**
  2849. * @deprecated Use {@link #getVertexShaderLanguage() } instead.
  2850. */
  2851. @@ -126,6 +150,18 @@
  2852. return fragLanguage;
  2853. }
  2854.  
  2855. + public String getGeometryShaderLanguage() {
  2856. + return geomLanguage;
  2857. + }
  2858. +
  2859. + public String getTessControlShaderLanguage() {
  2860. + return tcLanguage;
  2861. + }
  2862. +
  2863. + public String getTessEvaluationShaderLanguage() {
  2864. + return teLanguage;
  2865. + }
  2866. +
  2867. public boolean isUsesShaderNodes() {
  2868. return usesShaderNodes;
  2869. }
  2870. @@ -135,21 +171,30 @@
  2871. }
  2872.  
  2873. @Override
  2874. - public void write(JmeExporter ex) throws IOException{
  2875. + public void write(JmeExporter ex) throws IOException {
  2876. super.write(ex);
  2877. OutputCapsule oc = ex.getCapsule(this);
  2878. +
  2879. oc.write(fragName, "fragment_name", null);
  2880. + oc.write(geomName, "geometry_name", null);
  2881. + oc.write(tcName, "tess_control_name", null);
  2882. + oc.write(teName, "tess_eval_name", null);
  2883. +
  2884. oc.write(vertLanguage, "language", null);
  2885. oc.write(fragLanguage, "frag_language", null);
  2886. + oc.write(geomLanguage, "geom_language", null);
  2887. + oc.write(tcLanguage, "tc_language", null);
  2888. + oc.write(teLanguage, "te_language", null);
  2889. +
  2890. +
  2891. }
  2892.  
  2893. @Override
  2894. - public void read(JmeImporter im) throws IOException{
  2895. + public void read(JmeImporter im) throws IOException {
  2896. super.read(im);
  2897. InputCapsule ic = im.getCapsule(this);
  2898. fragName = ic.readString("fragment_name", null);
  2899. vertLanguage = ic.readString("language", null);
  2900. fragLanguage = ic.readString("frag_language", null);
  2901. }
  2902. -
  2903. }
  2904. Index: src/lwjgl/com/jme3/renderer/lwjgl/LwjglRenderer.java
  2905. --- src/lwjgl/com/jme3/renderer/lwjgl/LwjglRenderer.java Base (BASE)
  2906. +++ src/lwjgl/com/jme3/renderer/lwjgl/LwjglRenderer.java Locally Modified (Based On LOCAL)
  2907. @@ -75,6 +75,8 @@
  2908. import static org.lwjgl.opengl.GL14.*;
  2909. import static org.lwjgl.opengl.GL15.*;
  2910. import static org.lwjgl.opengl.GL20.*;
  2911. +import static org.lwjgl.opengl.GL30.*;
  2912. +import static org.lwjgl.opengl.GL40.*;
  2913. import org.lwjgl.opengl.*;
  2914. //import static org.lwjgl.opengl.ARBDrawInstanced.*;
  2915.  
  2916. @@ -153,11 +155,16 @@
  2917. caps.add(Caps.OpenGL31);
  2918. if (ctxCaps.OpenGL32) {
  2919. caps.add(Caps.OpenGL32);
  2920. + caps.add(Caps.GeometryShader);
  2921. + if(ctxCaps.OpenGL40){
  2922. + caps.add(Caps.OpenGL40);
  2923. + caps.add(Caps.TesselationShader);
  2924. }
  2925. }
  2926. }
  2927. }
  2928. }
  2929. + }
  2930.  
  2931. //workaround, always assume we support GLSL100
  2932. //some cards just don't report this correctly
  2933. @@ -203,7 +210,9 @@
  2934.  
  2935. // fall through intentional
  2936. case 400:
  2937. + caps.add(Caps.GLSL400);
  2938. case 330:
  2939. + caps.add(Caps.GLSL330);
  2940. case 150:
  2941. caps.add(Caps.GLSL150);
  2942. case 140:
  2943. @@ -947,6 +956,12 @@
  2944. return GL_FRAGMENT_SHADER;
  2945. case Vertex:
  2946. return GL_VERTEX_SHADER;
  2947. + case Geometry:
  2948. + return GL32.GL_GEOMETRY_SHADER;
  2949. + case TesselationControl:
  2950. + return GL40.GL_TESS_CONTROL_SHADER;
  2951. + case TesselationEvaluation:
  2952. + return GL40.GL_TESS_EVALUATION_SHADER;
  2953. // case Geometry:
  2954. // return ARBGeometryShader4.GL_GEOMETRY_SHADER_ARB;
  2955. default:
  2956. @@ -2341,6 +2356,8 @@
  2957. return GL_TRIANGLE_FAN;
  2958. case TriangleStrip:
  2959. return GL_TRIANGLE_STRIP;
  2960. + case Patches:
  2961. + return GL_PATCHES;
  2962. default:
  2963. throw new UnsupportedOperationException("Unrecognized mesh mode: " + mode);
  2964. }
  2965. @@ -2480,6 +2497,9 @@
  2966. glLineWidth(mesh.getLineWidth());
  2967. context.lineWidth = mesh.getLineWidth();
  2968. }
  2969. + if(mesh.getMode()==Mode.Patches){
  2970. + GL40.glPatchParameteri(GL40.GL_PATCH_VERTICES, mesh.getPatchVertices());
  2971. + }
  2972.  
  2973. statistics.onMeshDrawn(mesh, lod);
  2974. // if (GLContext.getCapabilities().GL_ARB_vertex_array_object){
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement