Przeglądaj źródła

* Added RenderState.isApply*** methods
* TangentBinormalGenerator now generates TBN lines properly for the new 4 dimensional tangents that it generates

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8554 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

sha..rd 14 lat temu
rodzic
commit
e9a78c5b61

+ 0 - 2
engine/src/core/com/jme3/material/RenderState.java

@@ -915,7 +915,6 @@ public class RenderState implements Cloneable, Savable {
         return alphaFallOff;
     }
 
-/*
     public boolean isApplyAlphaFallOff() {
         return applyAlphaFallOff;
     }
@@ -955,7 +954,6 @@ public class RenderState implements Cloneable, Savable {
     public boolean isApplyWireFrame() {
         return applyWireFrame;
     }
-*/
 
     /**
      * Merges <code>this</code> state and <code>additionalState</code> into

+ 18 - 6
engine/src/core/com/jme3/util/TangentBinormalGenerator.java

@@ -370,8 +370,6 @@ public class TangentBinormalGenerator {
         Vector3f tangentUnit = new Vector3f();
         Vector3f binormalUnit = new Vector3f();
         
-        
-
         for (int i = 0; i < vertices.length; i++) {
             float wCoord = -1;
             
@@ -592,11 +590,22 @@ public class TangentBinormalGenerator {
         IntBuffer lineIndex = BufferUtils.createIntBuffer(vertexBuffer.capacity() / 3 * 6);
         FloatBuffer lineVertex = BufferUtils.createFloatBuffer(vertexBuffer.capacity() * 4);
         FloatBuffer lineColor = BufferUtils.createFloatBuffer(vertexBuffer.capacity() / 3 * 4 * 4);
-
+        
+        boolean hasParity = mesh.getBuffer(Type.Tangent).getNumComponents() == 4;
+        float tangentW = 1;
+        
         for (int i = 0; i < vertexBuffer.capacity() / 3; i++) {
             populateFromBuffer(origin, vertexBuffer, i);
             populateFromBuffer(normal, normalBuffer, i);
-            populateFromBuffer(tangent, tangentBuffer, i);
+            
+            if (hasParity){
+                tangent.x = tangentBuffer.get(i * 4);
+                tangent.y = tangentBuffer.get(i * 4 + 1);
+                tangent.z = tangentBuffer.get(i * 4 + 2);
+                tangentW  = tangentBuffer.get(i * 4 + 3);
+            }else{
+                populateFromBuffer(tangent, tangentBuffer, i);
+            }
 
             int index = i * 4;
 
@@ -617,13 +626,16 @@ public class TangentBinormalGenerator {
             setInBuffer(point, lineVertex, index + 1);
             setInBuffer(tangentColor, lineColor, index + 1);
 
+            // wvBinormal = cross(wvNormal, wvTangent) * -inTangent.w
+            
             if (binormalBuffer == null) {
                 normal.cross(tangent, point);
+                point.multLocal(-tangentW);
                 point.normalizeLocal();
-            }
-            else {
+            } else {
                 populateFromBuffer(point, binormalBuffer, i);
             }
+            
             point.multLocal(scale);
             point.addLocal(origin);
             setInBuffer(point, lineVertex, index + 2);