|
59 | 59 | import java.util.logging.Logger; |
60 | 60 |
|
61 | 61 | /** |
62 | | - * |
| 62 | + * @deprecated This is an outdated and non-standard method. Please use @{link MikktspaceTangentGenerator} |
| 63 | + * instead. |
63 | 64 | * @author Lex (Aleksey Nikiforov) |
64 | 65 | */ |
| 66 | +@Deprecated |
65 | 67 | public class TangentBinormalGenerator { |
66 | 68 |
|
67 | 69 | private static final Logger log = Logger.getLogger(TangentBinormalGenerator.class.getName()); |
@@ -860,142 +862,21 @@ private static int parity(Vector3f n1, Vector3f n) { |
860 | 862 | } |
861 | 863 | } |
862 | 864 |
|
| 865 | + /** |
| 866 | + * @deprecated Use {@link TangentUtils#genTbnLines(com.jme3.scene.Mesh, float) } instead. |
| 867 | + */ |
| 868 | + @Deprecated |
863 | 869 | public static Mesh genTbnLines(Mesh mesh, float scale) { |
864 | | - if (mesh.getBuffer(Type.Tangent) == null) { |
865 | | - return genNormalLines(mesh, scale); |
866 | | - } else { |
867 | | - return genTangentLines(mesh, scale); |
868 | | - } |
| 870 | + return TangentUtils.genTbnLines(mesh, scale); |
869 | 871 | } |
870 | 872 |
|
| 873 | + /** |
| 874 | + * @deprecated Use {@link TangentUtils#genNormalLines(com.jme3.scene.Mesh, float) } instead. |
| 875 | + */ |
| 876 | + @Deprecated |
871 | 877 | public static Mesh genNormalLines(Mesh mesh, float scale) { |
872 | | - FloatBuffer vertexBuffer = (FloatBuffer) mesh.getBuffer(Type.Position).getData(); |
873 | | - FloatBuffer normalBuffer = (FloatBuffer) mesh.getBuffer(Type.Normal).getData(); |
874 | | - |
875 | | - ColorRGBA originColor = ColorRGBA.White; |
876 | | - ColorRGBA normalColor = ColorRGBA.Blue; |
877 | | - |
878 | | - Mesh lineMesh = new Mesh(); |
879 | | - lineMesh.setMode(Mesh.Mode.Lines); |
880 | | - |
881 | | - Vector3f origin = new Vector3f(); |
882 | | - Vector3f point = new Vector3f(); |
883 | | - |
884 | | - FloatBuffer lineVertex = BufferUtils.createFloatBuffer(vertexBuffer.limit() * 2); |
885 | | - FloatBuffer lineColor = BufferUtils.createFloatBuffer(vertexBuffer.limit() / 3 * 4 * 2); |
886 | | - |
887 | | - for (int i = 0; i < vertexBuffer.limit() / 3; i++) { |
888 | | - populateFromBuffer(origin, vertexBuffer, i); |
889 | | - populateFromBuffer(point, normalBuffer, i); |
890 | | - |
891 | | - int index = i * 2; |
892 | | - |
893 | | - setInBuffer(origin, lineVertex, index); |
894 | | - setInBuffer(originColor, lineColor, index); |
895 | | - |
896 | | - point.multLocal(scale); |
897 | | - point.addLocal(origin); |
898 | | - setInBuffer(point, lineVertex, index + 1); |
899 | | - setInBuffer(normalColor, lineColor, index + 1); |
900 | | - } |
901 | | - |
902 | | - lineMesh.setBuffer(Type.Position, 3, lineVertex); |
903 | | - lineMesh.setBuffer(Type.Color, 4, lineColor); |
904 | | - |
905 | | - lineMesh.setStatic(); |
906 | | - //lineMesh.setInterleaved(); |
907 | | - return lineMesh; |
| 878 | + return TangentUtils.genNormalLines(mesh, scale); |
908 | 879 | } |
909 | 880 |
|
910 | | - private static Mesh genTangentLines(Mesh mesh, float scale) { |
911 | | - FloatBuffer vertexBuffer = (FloatBuffer) mesh.getBuffer(Type.Position).getData(); |
912 | | - FloatBuffer normalBuffer = (FloatBuffer) mesh.getBuffer(Type.Normal).getData(); |
913 | | - FloatBuffer tangentBuffer = (FloatBuffer) mesh.getBuffer(Type.Tangent).getData(); |
914 | | - |
915 | | - FloatBuffer binormalBuffer = null; |
916 | | - if (mesh.getBuffer(Type.Binormal) != null) { |
917 | | - binormalBuffer = (FloatBuffer) mesh.getBuffer(Type.Binormal).getData(); |
918 | | - } |
919 | | - |
920 | | - ColorRGBA originColor = ColorRGBA.White; |
921 | | - ColorRGBA tangentColor = ColorRGBA.Red; |
922 | | - ColorRGBA binormalColor = ColorRGBA.Green; |
923 | | - ColorRGBA normalColor = ColorRGBA.Blue; |
924 | | - |
925 | | - Mesh lineMesh = new Mesh(); |
926 | | - lineMesh.setMode(Mesh.Mode.Lines); |
927 | | - |
928 | | - Vector3f origin = new Vector3f(); |
929 | | - Vector3f point = new Vector3f(); |
930 | | - Vector3f tangent = new Vector3f(); |
931 | | - Vector3f normal = new Vector3f(); |
932 | 881 |
|
933 | | - IntBuffer lineIndex = BufferUtils.createIntBuffer(vertexBuffer.limit() / 3 * 6); |
934 | | - FloatBuffer lineVertex = BufferUtils.createFloatBuffer(vertexBuffer.limit() * 4); |
935 | | - FloatBuffer lineColor = BufferUtils.createFloatBuffer(vertexBuffer.limit() / 3 * 4 * 4); |
936 | | - |
937 | | - boolean hasParity = mesh.getBuffer(Type.Tangent).getNumComponents() == 4; |
938 | | - float tangentW = 1; |
939 | | - |
940 | | - for (int i = 0; i < vertexBuffer.limit() / 3; i++) { |
941 | | - populateFromBuffer(origin, vertexBuffer, i); |
942 | | - populateFromBuffer(normal, normalBuffer, i); |
943 | | - |
944 | | - if (hasParity) { |
945 | | - tangent.x = tangentBuffer.get(i * 4); |
946 | | - tangent.y = tangentBuffer.get(i * 4 + 1); |
947 | | - tangent.z = tangentBuffer.get(i * 4 + 2); |
948 | | - tangentW = tangentBuffer.get(i * 4 + 3); |
949 | | - } else { |
950 | | - populateFromBuffer(tangent, tangentBuffer, i); |
951 | | - } |
952 | | - |
953 | | - int index = i * 4; |
954 | | - |
955 | | - int id = i * 6; |
956 | | - lineIndex.put(id, index); |
957 | | - lineIndex.put(id + 1, index + 1); |
958 | | - lineIndex.put(id + 2, index); |
959 | | - lineIndex.put(id + 3, index + 2); |
960 | | - lineIndex.put(id + 4, index); |
961 | | - lineIndex.put(id + 5, index + 3); |
962 | | - |
963 | | - setInBuffer(origin, lineVertex, index); |
964 | | - setInBuffer(originColor, lineColor, index); |
965 | | - |
966 | | - point.set(tangent); |
967 | | - point.multLocal(scale); |
968 | | - point.addLocal(origin); |
969 | | - setInBuffer(point, lineVertex, index + 1); |
970 | | - setInBuffer(tangentColor, lineColor, index + 1); |
971 | | - |
972 | | - // wvBinormal = cross(wvNormal, wvTangent) * -inTangent.w |
973 | | - if (binormalBuffer == null) { |
974 | | - normal.cross(tangent, point); |
975 | | - point.multLocal(-tangentW); |
976 | | - point.normalizeLocal(); |
977 | | - } else { |
978 | | - populateFromBuffer(point, binormalBuffer, i); |
979 | | - } |
980 | | - |
981 | | - point.multLocal(scale); |
982 | | - point.addLocal(origin); |
983 | | - setInBuffer(point, lineVertex, index + 2); |
984 | | - setInBuffer(binormalColor, lineColor, index + 2); |
985 | | - |
986 | | - point.set(normal); |
987 | | - point.multLocal(scale); |
988 | | - point.addLocal(origin); |
989 | | - setInBuffer(point, lineVertex, index + 3); |
990 | | - setInBuffer(normalColor, lineColor, index + 3); |
991 | | - } |
992 | | - |
993 | | - lineMesh.setBuffer(Type.Index, 1, lineIndex); |
994 | | - lineMesh.setBuffer(Type.Position, 3, lineVertex); |
995 | | - lineMesh.setBuffer(Type.Color, 4, lineColor); |
996 | | - |
997 | | - lineMesh.setStatic(); |
998 | | - //lineMesh.setInterleaved(); |
999 | | - return lineMesh; |
1000 | | - } |
1001 | 882 | } |
0 commit comments