@ -62,14 +62,15 @@ public class GeometryBatchFactory {
}
}
}
}
private static void doTransformTangents ( FloatBuffer inBuf , int offset , FloatBuffer outBuf , Matrix4f transform ) {
private static void doTransformTangents ( FloatBuffer inBuf , int offset , int components , FloatBuffer outBuf , Matrix4f transform ) {
Vector3f tan = new Vector3f ( ) ;
Vector3f tan = new Vector3f ( ) ;
float handedness = 0 ;
float handedness ;
// offset is given in element units
// offset is given in element units
// convert to be in component units
// convert to be in component units
offset * = 4 ;
offset * = components ;
for ( int i = 0 ; i < inBuf . capacity ( ) / 4 ; i + + ) {
for ( int i = 0 ; i < inBuf . capacity ( ) / components ; i + + ) {
tan . x = inBuf . get ( i * 4 + 0 ) ;
tan . x = inBuf . get ( i * 4 + 0 ) ;
tan . y = inBuf . get ( i * 4 + 1 ) ;
tan . y = inBuf . get ( i * 4 + 1 ) ;
tan . z = inBuf . get ( i * 4 + 2 ) ;
tan . z = inBuf . get ( i * 4 + 2 ) ;
@ -81,7 +82,6 @@ public class GeometryBatchFactory {
outBuf . put ( offset + i * 4 + 1 , tan . y ) ;
outBuf . put ( offset + i * 4 + 1 , tan . y ) ;
outBuf . put ( offset + i * 4 + 2 , tan . z ) ;
outBuf . put ( offset + i * 4 + 2 , tan . z ) ;
outBuf . put ( offset + i * 4 + 3 , handedness ) ;
outBuf . put ( offset + i * 4 + 3 , handedness ) ;
}
}
}
}
@ -211,7 +211,8 @@ public class GeometryBatchFactory {
} else if ( Type . Tangent . ordinal ( ) = = bufType ) {
} else if ( Type . Tangent . ordinal ( ) = = bufType ) {
FloatBuffer inPos = ( FloatBuffer ) inBuf . getDataReadOnly ( ) ;
FloatBuffer inPos = ( FloatBuffer ) inBuf . getDataReadOnly ( ) ;
FloatBuffer outPos = ( FloatBuffer ) outBuf . getData ( ) ;
FloatBuffer outPos = ( FloatBuffer ) outBuf . getData ( ) ;
doTransformTangents ( inPos , globalVertIndex , outPos , worldMatrix ) ;
int components = inBuf . getNumComponents ( ) ;
doTransformTangents ( inPos , globalVertIndex , components , outPos , worldMatrix ) ;
} else {
} else {
inBuf . copyElements ( 0 , outBuf , globalVertIndex , geomVertCount ) ;
inBuf . copyElements ( 0 , outBuf , globalVertIndex , geomVertCount ) ;
}
}