GeometryBatchFactory now correctly transforms tangents buffer (it was not taking the 4th component into account)
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9108 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
e1d4d66877
commit
26665e5df0
@ -62,6 +62,29 @@ public class GeometryBatchFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void doTransformTangents(FloatBuffer inBuf, int offset, FloatBuffer outBuf, Matrix4f transform) {
|
||||||
|
Vector3f tan = new Vector3f();
|
||||||
|
float handedness = 0;
|
||||||
|
// offset is given in element units
|
||||||
|
// convert to be in component units
|
||||||
|
offset *= 4;
|
||||||
|
|
||||||
|
for (int i = 0; i < inBuf.capacity() / 4; i++) {
|
||||||
|
tan.x = inBuf.get(i * 4 + 0);
|
||||||
|
tan.y = inBuf.get(i * 4 + 1);
|
||||||
|
tan.z = inBuf.get(i * 4 + 2);
|
||||||
|
handedness = inBuf.get(i * 4 + 3);
|
||||||
|
|
||||||
|
transform.multNormal(tan, tan);
|
||||||
|
|
||||||
|
outBuf.put(offset + i * 4 + 0, tan.x);
|
||||||
|
outBuf.put(offset + i * 4 + 1, tan.y);
|
||||||
|
outBuf.put(offset + i * 4 + 2, tan.z);
|
||||||
|
outBuf.put(offset + i * 4 + 3, handedness);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merges all geometries in the collection into
|
* Merges all geometries in the collection into
|
||||||
* the output mesh. Creates a new material using the TextureAtlas.
|
* the output mesh. Creates a new material using the TextureAtlas.
|
||||||
@ -181,10 +204,14 @@ public class GeometryBatchFactory {
|
|||||||
FloatBuffer inPos = (FloatBuffer) inBuf.getDataReadOnly();
|
FloatBuffer inPos = (FloatBuffer) inBuf.getDataReadOnly();
|
||||||
FloatBuffer outPos = (FloatBuffer) outBuf.getData();
|
FloatBuffer outPos = (FloatBuffer) outBuf.getData();
|
||||||
doTransformVerts(inPos, globalVertIndex, outPos, worldMatrix);
|
doTransformVerts(inPos, globalVertIndex, outPos, worldMatrix);
|
||||||
} else if (Type.Normal.ordinal() == bufType || Type.Tangent.ordinal() == bufType) {
|
} else if (Type.Normal.ordinal() == bufType) {
|
||||||
FloatBuffer inPos = (FloatBuffer) inBuf.getDataReadOnly();
|
FloatBuffer inPos = (FloatBuffer) inBuf.getDataReadOnly();
|
||||||
FloatBuffer outPos = (FloatBuffer) outBuf.getData();
|
FloatBuffer outPos = (FloatBuffer) outBuf.getData();
|
||||||
doTransformNorms(inPos, globalVertIndex, outPos, worldMatrix);
|
doTransformNorms(inPos, globalVertIndex, outPos, worldMatrix);
|
||||||
|
}else if(Type.Tangent.ordinal() == bufType){
|
||||||
|
FloatBuffer inPos = (FloatBuffer) inBuf.getDataReadOnly();
|
||||||
|
FloatBuffer outPos = (FloatBuffer) outBuf.getData();
|
||||||
|
doTransformTangents(inPos, globalVertIndex, outPos, worldMatrix);
|
||||||
} else {
|
} else {
|
||||||
inBuf.copyElements(0, outBuf, globalVertIndex, geomVertCount);
|
inBuf.copyElements(0, outBuf, globalVertIndex, geomVertCount);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user