Skip to content

Commit

Permalink
Tangent changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Retera committed Sep 11, 2022
1 parent a3b8932 commit ed2f593
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions craft3data/src/com/hiveworkshop/wc3/mdl/EditableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -3585,6 +3585,31 @@ public static void recalculateTangents(final EditableModel currentMDL, final Com
// copied from
// https://github.com/TaylorMouse/MaxScripts/blob/master/Warcraft%203%20Reforged/GriffonStudios/GriffonStudios_Warcraft_3_Reforged_Export.ms#L169
currentMDL.doSavePreps(); // I wanted to use VertexId on the triangle
final Vertex up = new Vertex(0, 0, 1);
if (true) {
for (final Geoset theMesh : currentMDL.getGeosets()) {
for (final GeosetVertex gv : theMesh.getVertices()) {
if (gv.getSkinBones() == null) {
gv.initV900();
}
// if (up.dotProduct(gv.getNormal()) < 0.99) {
// final Vertex tangent = gv.getNormal().crossProduct(up);
// gv.setTangent(new float[] { (float) tangent.x, (float) tangent.y, (float) tangent.z, -1 });
// } else {
// gv.setTangent(new float[] { 0, 1, 0, 1 });
// }
gv.setTangent(new float[] { 0, 0, 1, 1 });
if (gv.getBones() != null && !gv.getBones().isEmpty()) {
final int nBones = Math.min(4, gv.getBones().size());
for (int i = 0; i < nBones; i++) {
gv.getSkinBones()[i] = gv.getBones().get(i);
gv.getSkinBoneWeights()[i] = (short) (255 / nBones);
}
}
}
}
return;
}
for (final Geoset theMesh : currentMDL.getGeosets()) {
final double[][] tan1 = new double[theMesh.getVertices().size()][];
final double[][] tan2 = new double[theMesh.getVertices().size()][];
Expand Down
2 changes: 1 addition & 1 deletion matrixeater/src/com/matrixeater/src/MainPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -3390,7 +3390,7 @@ public void actionPerformed(final ActionEvent e) {
});
scriptsMenu.add(version800BakingToggle);

final JMenuItem recalculateTangents = new JMenuItem("Recalculate Tangents (requires 900 or 1000)");
final JMenuItem recalculateTangents = new JMenuItem("Recalculate Tangents (requires 900 or 1000 or 1100)");
recalculateTangents.setMnemonic(KeyEvent.VK_A);
recalculateTangents.addActionListener(new ActionListener() {
@Override
Expand Down

0 comments on commit ed2f593

Please sign in to comment.