diff --git a/317.iml b/317.iml index 8d8ffd9..d04ccda 100644 --- a/317.iml +++ b/317.iml @@ -1,6 +1,6 @@ - + diff --git a/pom.xml b/pom.xml index aa78816..bbe0ce6 100644 --- a/pom.xml +++ b/pom.xml @@ -7,5 +7,17 @@ runescape 317 1.0-SNAPSHOT - + + + + org.apache.maven.plugins + maven-compiler-plugin + + 7 + 7 + + + + + \ No newline at end of file diff --git a/src/main/java/BitmapFont.java b/src/main/java/BitmapFont.java index 174c857..332e722 100644 --- a/src/main/java/BitmapFont.java +++ b/src/main/java/BitmapFont.java @@ -19,10 +19,10 @@ public class BitmapFont extends Draw2D { public BitmapFont(boolean flag, String s, FileArchive archive) { Buffer buffer = new Buffer(archive.method571(s + ".dat", null)); Buffer buffer_1 = new Buffer(archive.method571("index.dat", null)); - buffer_1.anInt1406 = buffer.method410() + 4; + buffer_1.position = buffer.method410() + 4; int k = buffer_1.method408(); if (k > 0) { - buffer_1.anInt1406 += 3 * (k - 1); + buffer_1.position += 3 * (k - 1); } for (int l = 0; l < 256; l++) { anIntArray1494[l] = buffer_1.method408(); @@ -198,7 +198,7 @@ public class BitmapFont extends Draw2D { } } if (aBoolean1499) { - Draw2D.method339(k + (int) ((double) anInt1497 * 0.69999999999999996D), 0x800000, i - l, l); + Draw2D.drawLineX(l, k + (int) ((double) anInt1497 * 0.69999999999999996D), i - l, 0x800000); } } @@ -294,38 +294,38 @@ public class BitmapFont extends Draw2D { } public void method392(byte[] abyte0, int i, int j, int k, int l, int i1) { - int j1 = i + j * Draw2D.anInt1379; - int k1 = Draw2D.anInt1379 - k; + int j1 = i + j * Draw2D.width; + int k1 = Draw2D.width - k; int l1 = 0; int i2 = 0; - if (j < Draw2D.anInt1381) { - int j2 = Draw2D.anInt1381 - j; + if (j < Draw2D.top) { + int j2 = Draw2D.top - j; l -= j2; - j = Draw2D.anInt1381; + j = Draw2D.top; i2 += j2 * k; - j1 += j2 * Draw2D.anInt1379; + j1 += j2 * Draw2D.width; } - if (j + l >= Draw2D.anInt1382) { - l -= ((j + l) - Draw2D.anInt1382) + 1; + if (j + l >= Draw2D.bottom) { + l -= ((j + l) - Draw2D.bottom) + 1; } - if (i < Draw2D.anInt1383) { - int k2 = Draw2D.anInt1383 - i; + if (i < Draw2D.left) { + int k2 = Draw2D.left - i; k -= k2; - i = Draw2D.anInt1383; + i = Draw2D.left; i2 += k2; j1 += k2; l1 += k2; k1 += k2; } - if (i + k >= Draw2D.anInt1384) { - int l2 = ((i + k) - Draw2D.anInt1384) + 1; + if (i + k >= Draw2D.right) { + int l2 = ((i + k) - Draw2D.right) + 1; k -= l2; l1 += l2; k1 += l2; } if (k <= 0 || l <= 0) { } else { - method393(Draw2D.anIntArray1378, abyte0, i1, i2, j1, k, l, k1, l1); + method393(Draw2D.pixels, abyte0, i1, i2, j1, k, l, k1, l1); } } @@ -368,31 +368,31 @@ public class BitmapFont extends Draw2D { } public void method394(int i, int j, byte[] abyte0, int k, int l, int i1, int j1) { - int k1 = j + l * Draw2D.anInt1379; - int l1 = Draw2D.anInt1379 - k; + int k1 = j + l * Draw2D.width; + int l1 = Draw2D.width - k; int i2 = 0; int j2 = 0; - if (l < Draw2D.anInt1381) { - int k2 = Draw2D.anInt1381 - l; + if (l < Draw2D.top) { + int k2 = Draw2D.top - l; i1 -= k2; - l = Draw2D.anInt1381; + l = Draw2D.top; j2 += k2 * k; - k1 += k2 * Draw2D.anInt1379; + k1 += k2 * Draw2D.width; } - if (l + i1 >= Draw2D.anInt1382) { - i1 -= ((l + i1) - Draw2D.anInt1382) + 1; + if (l + i1 >= Draw2D.bottom) { + i1 -= ((l + i1) - Draw2D.bottom) + 1; } - if (j < Draw2D.anInt1383) { - int l2 = Draw2D.anInt1383 - j; + if (j < Draw2D.left) { + int l2 = Draw2D.left - j; k -= l2; - j = Draw2D.anInt1383; + j = Draw2D.left; j2 += l2; k1 += l2; i2 += l2; l1 += l2; } - if (j + k >= Draw2D.anInt1384) { - int i3 = ((j + k) - Draw2D.anInt1384) + 1; + if (j + k >= Draw2D.right) { + int i3 = ((j + k) - Draw2D.right) + 1; k -= i3; i2 += i3; l1 += i3; @@ -400,7 +400,7 @@ public class BitmapFont extends Draw2D { if (k <= 0 || i1 <= 0) { return; } - method395(abyte0, i1, k1, Draw2D.anIntArray1378, j2, k, i2, l1, j1, i); + method395(abyte0, i1, k1, Draw2D.pixels, j2, k, i2, l1, j1, i); } public void method395(byte[] abyte0, int i, int j, int[] ai, int l, int i1, int j1, int k1, int l1, int i2) { diff --git a/src/main/java/Buffer.java b/src/main/java/Buffer.java index 4cf0ce4..5d79084 100644 --- a/src/main/java/Buffer.java +++ b/src/main/java/Buffer.java @@ -31,7 +31,7 @@ public class Buffer extends DoublyLinkedListNode { } public byte[] aByteArray1405; - public int anInt1406; + public int position; public int anInt1407; public ISAACCipher aISAACCipher_1410; @@ -40,7 +40,7 @@ public class Buffer extends DoublyLinkedListNode { public Buffer(byte[] abyte0) { aByteArray1405 = abyte0; - anInt1406 = 0; + position = 0; } public static Buffer method396(int i) { @@ -57,12 +57,12 @@ public class Buffer extends DoublyLinkedListNode { class30_sub2_sub2_2 = (Buffer) A_LIST___1416.method251(); } if (class30_sub2_sub2_2 != null) { - class30_sub2_sub2_2.anInt1406 = 0; + class30_sub2_sub2_2.position = 0; return class30_sub2_sub2_2; } } Buffer buffer_1 = new Buffer(); - buffer_1.anInt1406 = 0; + buffer_1.position = 0; if (i == 0) { buffer_1.aByteArray1405 = new byte[100]; } else if (i == 1) { @@ -74,86 +74,86 @@ public class Buffer extends DoublyLinkedListNode { } public void method397(int i) { - aByteArray1405[anInt1406++] = (byte) (i + aISAACCipher_1410.method246()); + aByteArray1405[position++] = (byte) (i + aISAACCipher_1410.method246()); } public void method398(int i) { - aByteArray1405[anInt1406++] = (byte) i; + aByteArray1405[position++] = (byte) i; } public void method399(int i) { - aByteArray1405[anInt1406++] = (byte) (i >> 8); - aByteArray1405[anInt1406++] = (byte) i; + aByteArray1405[position++] = (byte) (i >> 8); + aByteArray1405[position++] = (byte) i; } public void method400(int i) { - aByteArray1405[anInt1406++] = (byte) i; - aByteArray1405[anInt1406++] = (byte) (i >> 8); + aByteArray1405[position++] = (byte) i; + aByteArray1405[position++] = (byte) (i >> 8); } public void method401(int i) { - aByteArray1405[anInt1406++] = (byte) (i >> 16); - aByteArray1405[anInt1406++] = (byte) (i >> 8); - aByteArray1405[anInt1406++] = (byte) i; + aByteArray1405[position++] = (byte) (i >> 16); + aByteArray1405[position++] = (byte) (i >> 8); + aByteArray1405[position++] = (byte) i; } public void method402(int i) { - aByteArray1405[anInt1406++] = (byte) (i >> 24); - aByteArray1405[anInt1406++] = (byte) (i >> 16); - aByteArray1405[anInt1406++] = (byte) (i >> 8); - aByteArray1405[anInt1406++] = (byte) i; + aByteArray1405[position++] = (byte) (i >> 24); + aByteArray1405[position++] = (byte) (i >> 16); + aByteArray1405[position++] = (byte) (i >> 8); + aByteArray1405[position++] = (byte) i; } public void method403(int j) { - aByteArray1405[anInt1406++] = (byte) j; - aByteArray1405[anInt1406++] = (byte) (j >> 8); - aByteArray1405[anInt1406++] = (byte) (j >> 16); - aByteArray1405[anInt1406++] = (byte) (j >> 24); + aByteArray1405[position++] = (byte) j; + aByteArray1405[position++] = (byte) (j >> 8); + aByteArray1405[position++] = (byte) (j >> 16); + aByteArray1405[position++] = (byte) (j >> 24); } public void method404(long l) { - aByteArray1405[anInt1406++] = (byte) (int) (l >> 56); - aByteArray1405[anInt1406++] = (byte) (int) (l >> 48); - aByteArray1405[anInt1406++] = (byte) (int) (l >> 40); - aByteArray1405[anInt1406++] = (byte) (int) (l >> 32); - aByteArray1405[anInt1406++] = (byte) (int) (l >> 24); - aByteArray1405[anInt1406++] = (byte) (int) (l >> 16); - aByteArray1405[anInt1406++] = (byte) (int) (l >> 8); - aByteArray1405[anInt1406++] = (byte) (int) l; + aByteArray1405[position++] = (byte) (int) (l >> 56); + aByteArray1405[position++] = (byte) (int) (l >> 48); + aByteArray1405[position++] = (byte) (int) (l >> 40); + aByteArray1405[position++] = (byte) (int) (l >> 32); + aByteArray1405[position++] = (byte) (int) (l >> 24); + aByteArray1405[position++] = (byte) (int) (l >> 16); + aByteArray1405[position++] = (byte) (int) (l >> 8); + aByteArray1405[position++] = (byte) (int) l; } public void method405(String s) { - s.getBytes(0, s.length(), aByteArray1405, anInt1406); - anInt1406 += s.length(); - aByteArray1405[anInt1406++] = 10; + s.getBytes(0, s.length(), aByteArray1405, position); + position += s.length(); + aByteArray1405[position++] = 10; } public void method406(byte[] abyte0, int i, int j) { for (int k = j; k < j + i; k++) { - aByteArray1405[anInt1406++] = abyte0[k]; + aByteArray1405[position++] = abyte0[k]; } } public void method407(int i) { - aByteArray1405[anInt1406 - i - 1] = (byte) i; + aByteArray1405[position - i - 1] = (byte) i; } public int method408() { - return aByteArray1405[anInt1406++] & 0xff; + return aByteArray1405[position++] & 0xff; } public byte method409() { - return aByteArray1405[anInt1406++]; + return aByteArray1405[position++]; } public int method410() { - anInt1406 += 2; - return ((aByteArray1405[anInt1406 - 2] & 0xff) << 8) + (aByteArray1405[anInt1406 - 1] & 0xff); + position += 2; + return ((aByteArray1405[position - 2] & 0xff) << 8) + (aByteArray1405[position - 1] & 0xff); } public int method411() { - anInt1406 += 2; - int i = ((aByteArray1405[anInt1406 - 2] & 0xff) << 8) + (aByteArray1405[anInt1406 - 1] & 0xff); + position += 2; + int i = ((aByteArray1405[position - 2] & 0xff) << 8) + (aByteArray1405[position - 1] & 0xff); if (i > 32767) { i -= 0x10000; } @@ -161,13 +161,13 @@ public class Buffer extends DoublyLinkedListNode { } public int method412() { - anInt1406 += 3; - return ((aByteArray1405[anInt1406 - 3] & 0xff) << 16) + ((aByteArray1405[anInt1406 - 2] & 0xff) << 8) + (aByteArray1405[anInt1406 - 1] & 0xff); + position += 3; + return ((aByteArray1405[position - 3] & 0xff) << 16) + ((aByteArray1405[position - 2] & 0xff) << 8) + (aByteArray1405[position - 1] & 0xff); } public int method413() { - anInt1406 += 4; - return ((aByteArray1405[anInt1406 - 4] & 0xff) << 24) + ((aByteArray1405[anInt1406 - 3] & 0xff) << 16) + ((aByteArray1405[anInt1406 - 2] & 0xff) << 8) + (aByteArray1405[anInt1406 - 1] & 0xff); + position += 4; + return ((aByteArray1405[position - 4] & 0xff) << 24) + ((aByteArray1405[position - 3] & 0xff) << 16) + ((aByteArray1405[position - 2] & 0xff) << 8) + (aByteArray1405[position - 1] & 0xff); } public long method414() { @@ -177,18 +177,18 @@ public class Buffer extends DoublyLinkedListNode { } public String method415() { - int i = anInt1406; - while (aByteArray1405[anInt1406++] != 10) { + int i = position; + while (aByteArray1405[position++] != 10) { } - return new String(aByteArray1405, i, anInt1406 - i - 1); + return new String(aByteArray1405, i, position - i - 1); } public byte[] method416() { - int i = anInt1406; - while (aByteArray1405[anInt1406++] != 10) { + int i = position; + while (aByteArray1405[position++] != 10) { } - byte[] abyte0 = new byte[anInt1406 - i - 1]; - for (int j = i; j < anInt1406 - 1; j++) { + byte[] abyte0 = new byte[position - i - 1]; + for (int j = i; j < position - 1; j++) { abyte0[j - i] = aByteArray1405[j]; } return abyte0; @@ -196,12 +196,12 @@ public class Buffer extends DoublyLinkedListNode { public void method417(int i, int j, byte[] abyte0) { for (int l = j; l < j + i; l++) { - abyte0[l] = aByteArray1405[anInt1406++]; + abyte0[l] = aByteArray1405[position++]; } } public void method418() { - anInt1407 = anInt1406 * 8; + anInt1407 = position * 8; } public int method419(int i) { @@ -222,11 +222,11 @@ public class Buffer extends DoublyLinkedListNode { } public void method420() { - anInt1406 = (anInt1407 + 7) / 8; + position = (anInt1407 + 7) / 8; } public int method421() { - int i = aByteArray1405[anInt1406] & 0xff; + int i = aByteArray1405[position] & 0xff; if (i < 128) { return method408() - 64; } else { @@ -235,7 +235,7 @@ public class Buffer extends DoublyLinkedListNode { } public int method422() { - int i = aByteArray1405[anInt1406] & 0xff; + int i = aByteArray1405[position] & 0xff; if (i < 128) { return method408(); } else { @@ -244,79 +244,79 @@ public class Buffer extends DoublyLinkedListNode { } public void method423(BigInteger biginteger, BigInteger biginteger1) { - int i = anInt1406; - anInt1406 = 0; + int i = position; + position = 0; byte[] abyte0 = new byte[i]; method417(i, 0, abyte0); BigInteger biginteger2 = new BigInteger(abyte0); BigInteger biginteger3 = biginteger2.modPow(biginteger, biginteger1); byte[] abyte1 = biginteger3.toByteArray(); - anInt1406 = 0; + position = 0; method398(abyte1.length); method406(abyte1, abyte1.length, 0); } public void method424(int i) { - aByteArray1405[anInt1406++] = (byte) (-i); + aByteArray1405[position++] = (byte) (-i); } public void method425(int j) { - aByteArray1405[anInt1406++] = (byte) (128 - j); + aByteArray1405[position++] = (byte) (128 - j); } public int method426() { - return aByteArray1405[anInt1406++] - 128 & 0xff; + return aByteArray1405[position++] - 128 & 0xff; } public int method427() { - return -aByteArray1405[anInt1406++] & 0xff; + return -aByteArray1405[position++] & 0xff; } public int method428() { - return 128 - aByteArray1405[anInt1406++] & 0xff; + return 128 - aByteArray1405[position++] & 0xff; } public byte method429() { - return (byte) (-aByteArray1405[anInt1406++]); + return (byte) (-aByteArray1405[position++]); } public byte method430() { - return (byte) (128 - aByteArray1405[anInt1406++]); + return (byte) (128 - aByteArray1405[position++]); } public void method431(int i) { - aByteArray1405[anInt1406++] = (byte) i; - aByteArray1405[anInt1406++] = (byte) (i >> 8); + aByteArray1405[position++] = (byte) i; + aByteArray1405[position++] = (byte) (i >> 8); } public void method432(int j) { - aByteArray1405[anInt1406++] = (byte) (j >> 8); - aByteArray1405[anInt1406++] = (byte) (j + 128); + aByteArray1405[position++] = (byte) (j >> 8); + aByteArray1405[position++] = (byte) (j + 128); } public void method433(int j) { - aByteArray1405[anInt1406++] = (byte) (j + 128); - aByteArray1405[anInt1406++] = (byte) (j >> 8); + aByteArray1405[position++] = (byte) (j + 128); + aByteArray1405[position++] = (byte) (j >> 8); } public int method434() { - anInt1406 += 2; - return ((aByteArray1405[anInt1406 - 1] & 0xff) << 8) + (aByteArray1405[anInt1406 - 2] & 0xff); + position += 2; + return ((aByteArray1405[position - 1] & 0xff) << 8) + (aByteArray1405[position - 2] & 0xff); } public int method435() { - anInt1406 += 2; - return ((aByteArray1405[anInt1406 - 2] & 0xff) << 8) + (aByteArray1405[anInt1406 - 1] - 128 & 0xff); + position += 2; + return ((aByteArray1405[position - 2] & 0xff) << 8) + (aByteArray1405[position - 1] - 128 & 0xff); } public int method436() { - anInt1406 += 2; - return ((aByteArray1405[anInt1406 - 1] & 0xff) << 8) + (aByteArray1405[anInt1406 - 2] - 128 & 0xff); + position += 2; + return ((aByteArray1405[position - 1] & 0xff) << 8) + (aByteArray1405[position - 2] - 128 & 0xff); } public int method437() { - anInt1406 += 2; - int j = ((aByteArray1405[anInt1406 - 1] & 0xff) << 8) + (aByteArray1405[anInt1406 - 2] & 0xff); + position += 2; + int j = ((aByteArray1405[position - 1] & 0xff) << 8) + (aByteArray1405[position - 2] & 0xff); if (j > 32767) { j -= 0x10000; } @@ -324,8 +324,8 @@ public class Buffer extends DoublyLinkedListNode { } public int method438() { - anInt1406 += 2; - int j = ((aByteArray1405[anInt1406 - 1] & 0xff) << 8) + (aByteArray1405[anInt1406 - 2] - 128 & 0xff); + position += 2; + int j = ((aByteArray1405[position - 1] & 0xff) << 8) + (aByteArray1405[position - 2] - 128 & 0xff); if (j > 32767) { j -= 0x10000; } @@ -333,24 +333,24 @@ public class Buffer extends DoublyLinkedListNode { } public int method439() { - anInt1406 += 4; - return ((aByteArray1405[anInt1406 - 2] & 0xff) << 24) + ((aByteArray1405[anInt1406 - 1] & 0xff) << 16) + ((aByteArray1405[anInt1406 - 4] & 0xff) << 8) + (aByteArray1405[anInt1406 - 3] & 0xff); + position += 4; + return ((aByteArray1405[position - 2] & 0xff) << 24) + ((aByteArray1405[position - 1] & 0xff) << 16) + ((aByteArray1405[position - 4] & 0xff) << 8) + (aByteArray1405[position - 3] & 0xff); } public int method440() { - anInt1406 += 4; - return ((aByteArray1405[anInt1406 - 3] & 0xff) << 24) + ((aByteArray1405[anInt1406 - 4] & 0xff) << 16) + ((aByteArray1405[anInt1406 - 1] & 0xff) << 8) + (aByteArray1405[anInt1406 - 2] & 0xff); + position += 4; + return ((aByteArray1405[position - 3] & 0xff) << 24) + ((aByteArray1405[position - 4] & 0xff) << 16) + ((aByteArray1405[position - 1] & 0xff) << 8) + (aByteArray1405[position - 2] & 0xff); } public void method441(int i, byte[] abyte0, int j) { for (int k = (i + j) - 1; k >= i; k--) { - aByteArray1405[anInt1406++] = (byte) (abyte0[k] + 128); + aByteArray1405[position++] = (byte) (abyte0[k] + 128); } } public void method442(int i, int j, byte[] abyte0) { for (int k = (j + i) - 1; k >= j; k--) { - abyte0[k] = aByteArray1405[anInt1406++]; + abyte0[k] = aByteArray1405[position++]; } } diff --git a/src/main/java/Component.java b/src/main/java/Component.java index c3878ae..4e9a913 100644 --- a/src/main/java/Component.java +++ b/src/main/java/Component.java @@ -78,7 +78,7 @@ public class Component { int i = -1; int j = buffer.method410(); aComponentArray210 = new Component[j]; - while (buffer.anInt1406 < buffer.aByteArray1405.length) { + while (buffer.position < buffer.aByteArray1405.length) { int k = buffer.method410(); if (k == 65535) { i = buffer.method410(); @@ -314,7 +314,7 @@ public class Component { return model; } if (i == 1) { - model = Model.method462(j); + model = Model.tryGet(j); } if (i == 2) { model = NPCType.method159(j).method160(); @@ -344,20 +344,20 @@ public class Component { if (model == null) { return null; } - if (k == -1 && j == -1 && model.anIntArray1640 == null) { + if (k == -1 && j == -1 && model.faceColor == null) { return model; } - Model model_1 = new Model(true, SeqTransform.method532(k) & SeqTransform.method532(j), false, model); + Model model_1 = new Model(true, SeqFrame.isNull(k) & SeqFrame.isNull(j), false, model); if (k != -1 || j != -1) { - model_1.method469(); + model_1.createLabelReferences(); } if (k != -1) { - model_1.method470(k); + model_1.applySequenceFrame(k); } if (j != -1) { - model_1.method470(j); + model_1.applySequenceFrame(j); } - model_1.method479(64, 768, -50, -10, -50, true); + model_1.calculateNormals(64, 768, -50, -10, -50, true); return model_1; } diff --git a/src/main/java/Draw2D.java b/src/main/java/Draw2D.java index 9698945..a857446 100644 --- a/src/main/java/Draw2D.java +++ b/src/main/java/Draw2D.java @@ -1,224 +1,245 @@ -// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) +import java.util.Arrays; public class Draw2D extends DoublyLinkedListNode { - public static int[] anIntArray1378; - public static int anInt1379; - public static int anInt1380; - public static int anInt1381; - public static int anInt1382; - public static int anInt1383; - public static int anInt1384; - public static int anInt1385; - public static int anInt1386; - public static int anInt1387; + public static int[] pixels; + public static int width; + public static int height; + public static int top; + public static int bottom; + public static int left; + public static int right; + public static int boundX; + public static int centerX; + public static int centerY; public Draw2D() { } - public static void method331(int i, int j, int[] ai) { - anIntArray1378 = ai; - anInt1379 = j; - anInt1380 = i; - method333(i, 0, j, 0); + public static void bind(int[] pixels, int width, int height) { + Draw2D.pixels = pixels; + Draw2D.width = width; + Draw2D.height = height; + setBounds(height, 0, width, 0); } - public static void method332() { - anInt1383 = 0; - anInt1381 = 0; - anInt1384 = anInt1379; - anInt1382 = anInt1380; - anInt1385 = anInt1384 - 1; - anInt1386 = anInt1384 / 2; + public static void resetBounds() { + left = 0; + top = 0; + right = width; + bottom = height; + boundX = right - 1; + centerX = right / 2; } - public static void method333(int i, int j, int k, int l) { - if (j < 0) { - j = 0; + public static void setBounds(int bottom, int left, int right, int top) { + if (left < 0) { + left = 0; } - if (l < 0) { - l = 0; + if (top < 0) { + top = 0; } - if (k > anInt1379) { - k = anInt1379; + if (right > width) { + right = width; } - if (i > anInt1380) { - i = anInt1380; + if (bottom > height) { + bottom = height; } - anInt1383 = j; - anInt1381 = l; - anInt1384 = k; - anInt1382 = i; - anInt1385 = anInt1384 - 1; - anInt1386 = anInt1384 / 2; - anInt1387 = anInt1382 / 2; + Draw2D.left = left; + Draw2D.top = top; + Draw2D.right = right; + Draw2D.bottom = bottom; + boundX = Draw2D.right - 1; + centerX = Draw2D.right / 2; + centerY = Draw2D.bottom / 2; } - public static void method334() { - int i = anInt1379 * anInt1380; - for (int j = 0; j < i; j++) { - anIntArray1378[j] = 0; - } + public static void clear() { + Arrays.fill(pixels, 0); } - public static void method335(int i, int j, int k, int l, int i1, int k1) { - if (k1 < anInt1383) { - k -= anInt1383 - k1; - k1 = anInt1383; + public static void fillRect(int x, int y, int width, int height, int rgb, int alpha) { + if (x < left) { + width -= left - x; + x = left; } - if (j < anInt1381) { - l -= anInt1381 - j; - j = anInt1381; + + if (y < top) { + height -= top - y; + y = top; } - if (k1 + k > anInt1384) { - k = anInt1384 - k1; + + if (x + width > right) { + width = right - x; } - if (j + l > anInt1382) { - l = anInt1382 - j; + + if (y + height > bottom) { + height = bottom - y; } - int l1 = 256 - i1; - int i2 = (i >> 16 & 0xff) * i1; - int j2 = (i >> 8 & 0xff) * i1; - int k2 = (i & 0xff) * i1; - int k3 = anInt1379 - k; - int l3 = k1 + j * anInt1379; - for (int i4 = 0; i4 < l; i4++) { - for (int j4 = -k; j4 < 0; j4++) { - int l2 = (anIntArray1378[l3] >> 16 & 0xff) * l1; - int i3 = (anIntArray1378[l3] >> 8 & 0xff) * l1; - int j3 = (anIntArray1378[l3] & 0xff) * l1; - int k4 = ((i2 + l2 >> 8) << 16) + ((j2 + i3 >> 8) << 8) + (k2 + j3 >> 8); - anIntArray1378[l3++] = k4; + + int invAlpha = 256 - alpha; + int r0 = (rgb >> 16 & 0xff) * alpha; + int g0 = (rgb >> 8 & 0xff) * alpha; + int b0 = (rgb & 0xff) * alpha; + + int step = Draw2D.width - width; + int offset = x + y * Draw2D.width; + + for (int i = 0; i < height; i++) { + for (int j = -width; j < 0; j++) { + int r1 = (pixels[offset] >> 16 & 0xff) * invAlpha; + int g1 = (pixels[offset] >> 8 & 0xff) * invAlpha; + int b1 = (pixels[offset] & 0xff) * invAlpha; + pixels[offset++] = (((r0 + r1) >> 8) << 16) + (((g0 + g1) >> 8) << 8) + ((b0 + b1) >> 8); } - l3 += k3; + offset += step; } } - public static void method336(int i, int j, int k, int l, int i1) { - if (k < anInt1383) { - i1 -= anInt1383 - k; - k = anInt1383; + public static void fillRect(int x, int y, int width, int height, int rgb) { + if (x < left) { + width -= left - x; + x = left; } - if (j < anInt1381) { - i -= anInt1381 - j; - j = anInt1381; + + if (y < top) { + height -= top - y; + y = top; } - if (k + i1 > anInt1384) { - i1 = anInt1384 - k; + + if (x + width > right) { + width = right - x; } - if (j + i > anInt1382) { - i = anInt1382 - j; + + if (y + height > bottom) { + height = bottom - y; } - int k1 = anInt1379 - i1; - int l1 = k + j * anInt1379; - for (int i2 = -i; i2 < 0; i2++) { - for (int j2 = -i1; j2 < 0; j2++) { - anIntArray1378[l1++] = l; + + int step = Draw2D.width - width; + int offset = x + y * Draw2D.width; + + for (int i = -height; i < 0; i++) { + for (int j = -width; j < 0; j++) { + pixels[offset++] = rgb; } - l1 += k1; + offset += step; } } - public static void method337(int i, int j, int k, int l, int i1) { - method339(i1, l, j, i); - method339((i1 + k) - 1, l, j, i); - method341(i1, l, k, i); - method341(i1, l, k, (i + j) - 1); + public static void drawRect(int x, int y, int width, int height, int rgb) { + drawLineX(x, y, width, rgb); + drawLineX(x, (y + height) - 1, width, rgb); + drawLineY(y, rgb, height, x); + drawLineY(y, rgb, height, (x + width) - 1); } - public static void method338(int i, int j, int k, int l, int i1, int j1) { - method340(l, i1, i, k, j1); - method340(l, i1, (i + j) - 1, k, j1); - if (j >= 3) { - method342(l, j1, k, i + 1, j - 2); - method342(l, (j1 + i1) - 1, k, i + 1, j - 2); + public static void drawRect(int x, int y, int width, int height, int rgb, int alpha) { + drawLineX(x, y, width, rgb, alpha); + drawLineX(x, (y + height) - 1, width, rgb, alpha); + if (height >= 3) { + drawLineY(rgb, x, alpha, y + 1, height - 2); + drawLineY(rgb, (x + width) - 1, alpha, y + 1, height - 2); } } - public static void method339(int i, int j, int k, int l) { - if (i < anInt1381 || i >= anInt1382) { + public static void drawLineX(int x, int y, int length, int rgb) { + if (y < top || y >= bottom) { return; } - if (l < anInt1383) { - k -= anInt1383 - l; - l = anInt1383; + + if (x < left) { + length -= left - x; + x = left; } - if (l + k > anInt1384) { - k = anInt1384 - l; + + if (x + length > right) { + length = right - x; } - int i1 = l + i * anInt1379; - for (int j1 = 0; j1 < k; j1++) { - anIntArray1378[i1 + j1] = j; + + int offset = x + y * width; + + for (int i = 0; i < length; i++) { + pixels[offset + i] = rgb; } } - public static void method340(int i, int j, int k, int l, int i1) { - if (k < anInt1381 || k >= anInt1382) { + public static void drawLineX(int x, int y, int length, int rgb, int alpha) { + if (y < top || y >= bottom) { return; } - if (i1 < anInt1383) { - j -= anInt1383 - i1; - i1 = anInt1383; + + if (x < left) { + length -= left - x; + x = left; } - if (i1 + j > anInt1384) { - j = anInt1384 - i1; + + if (x + length > right) { + length = right - x; } - int j1 = 256 - l; - int k1 = (i >> 16 & 0xff) * l; - int l1 = (i >> 8 & 0xff) * l; - int i2 = (i & 0xff) * l; - int i3 = i1 + k * anInt1379; - for (int j3 = 0; j3 < j; j3++) { - int j2 = (anIntArray1378[i3] >> 16 & 0xff) * j1; - int k2 = (anIntArray1378[i3] >> 8 & 0xff) * j1; - int l2 = (anIntArray1378[i3] & 0xff) * j1; - int k3 = ((k1 + j2 >> 8) << 16) + ((l1 + k2 >> 8) << 8) + (i2 + l2 >> 8); - anIntArray1378[i3++] = k3; + + int invAlpha = 256 - alpha; + int r0 = (rgb >> 16 & 0xff) * alpha; + int g0 = (rgb >> 8 & 0xff) * alpha; + int b0 = (rgb & 0xff) * alpha; + + int offset = x + y * width; + + for (int i = 0; i < length; i++) { + int r1 = (pixels[offset] >> 16 & 0xff) * invAlpha; + int g1 = (pixels[offset] >> 8 & 0xff) * invAlpha; + int b1 = (pixels[offset] & 0xff) * invAlpha; + pixels[offset++] = ((r0 + r1 >> 8) << 16) + ((g0 + g1 >> 8) << 8) + (b0 + b1 >> 8); } } - public static void method341(int i, int j, int k, int l) { - if (l < anInt1383 || l >= anInt1384) { + public static void drawLineY(int y, int rgb, int length, int x) { + if (x < left || x >= right) { return; } - if (i < anInt1381) { - k -= anInt1381 - i; - i = anInt1381; + + if (y < top) { + length -= top - y; + y = top; } - if (i + k > anInt1382) { - k = anInt1382 - i; + + if (y + length > bottom) { + length = bottom - y; } - int j1 = l + i * anInt1379; - for (int k1 = 0; k1 < k; k1++) { - anIntArray1378[j1 + k1 * anInt1379] = j; + + int offset = x + y * width; + + for (int i = 0; i < length; i++) { + pixels[offset + i * width] = rgb; } } - public static void method342(int i, int j, int k, int l, int i1) { - if (j < anInt1383 || j >= anInt1384) { + public static void drawLineY(int rgb, int x, int alpha, int y, int length) { + if (x < left || x >= right) { return; } - if (l < anInt1381) { - i1 -= anInt1381 - l; - l = anInt1381; + + if (y < top) { + length -= top - y; + y = top; } - if (l + i1 > anInt1382) { - i1 = anInt1382 - l; + + if (y + length > bottom) { + length = bottom - y; } - int j1 = 256 - k; - int k1 = (i >> 16 & 0xff) * k; - int l1 = (i >> 8 & 0xff) * k; - int i2 = (i & 0xff) * k; - int i3 = j + l * anInt1379; - for (int j3 = 0; j3 < i1; j3++) { - int j2 = (anIntArray1378[i3] >> 16 & 0xff) * j1; - int k2 = (anIntArray1378[i3] >> 8 & 0xff) * j1; - int l2 = (anIntArray1378[i3] & 0xff) * j1; - int k3 = ((k1 + j2 >> 8) << 16) + ((l1 + k2 >> 8) << 8) + (i2 + l2 >> 8); - anIntArray1378[i3] = k3; - i3 += anInt1379; + + int invAlpha = 256 - alpha; + int r0 = (rgb >> 16 & 0xff) * alpha; + int g0 = (rgb >> 8 & 0xff) * alpha; + int b0 = (rgb & 0xff) * alpha; + + int offset = x + y * width; + + for (int i = 0; i < length; i++) { + int r1 = (pixels[offset] >> 16 & 0xff) * invAlpha; + int g1 = (pixels[offset] >> 8 & 0xff) * invAlpha; + int b1 = (pixels[offset] & 0xff) * invAlpha; + pixels[offset] = ((r0 + r1 >> 8) << 16) + ((g0 + g1 >> 8) << 8) + (b0 + b1 >> 8); + offset += width; } } diff --git a/src/main/java/Draw3D.java b/src/main/java/Draw3D.java index aeb992a..c557371 100644 --- a/src/main/java/Draw3D.java +++ b/src/main/java/Draw3D.java @@ -2,68 +2,79 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) -public class Draw3D extends Draw2D { +public class Draw3D { + public static final int[] reciprical16 = new int[2048]; public static boolean aBoolean1461 = true; - public static boolean aBoolean1462; - public static boolean aBoolean1463; - public static boolean aBoolean1464 = true; - public static int anInt1465; - public static int anInt1466; - public static int anInt1467; - public static int[] anIntArray1468 = new int[512]; - public static final int[] anIntArray1469 = new int[2048]; - public static int[] anIntArray1470 = new int[2048]; - public static int[] anIntArray1471 = new int[2048]; + public static boolean clipX; + public static boolean opaque; + public static boolean jagged = true; + public static int alpha; + public static int centerX; + public static int centerY; + public static int[] recipreical15 = new int[512]; + public static int[] sin = new int[2048]; + public static int[] cos = new int[2048]; public static int[] anIntArray1472; public static int anInt1473; public static Image8[] aImageArray1474 = new Image8[50]; - public static boolean[] aBooleanArray1475 = new boolean[50]; + public static boolean[] textureTranslucent = new boolean[50]; public static int[] anIntArray1476 = new int[50]; public static int anInt1477; public static int[][] anIntArrayArray1478; public static int[][] anIntArrayArray1479 = new int[50][]; public static int[] anIntArray1480 = new int[50]; public static int anInt1481; - public static int[] anIntArray1482 = new int[0x10000]; + /** + * A lookup table for HSL->RGB. A one dimensional representation of a 128x512 image. The structure of the HSL + * colors is as follows: + *

+ * (hue << 10) | (saturation << 7) | lightness + *

+ * Interpolation of colors is possible since the lightness component is the least significant, allowing any + * difference values to be the difference in lightness between two colors. + * + * @see #drawGouraudScanline(int[], int, int, int, int, int) + */ + public static int[] palette = new int[0x10000]; public static int[][] anIntArrayArray1483 = new int[50][]; static { for (int i = 1; i < 512; i++) { - anIntArray1468[i] = 32768 / i; + recipreical15[i] = 32768 / i; } for (int j = 1; j < 2048; j++) { - anIntArray1469[j] = 0x10000 / j; + reciprical16[j] = 0x10000 / j; } for (int k = 0; k < 2048; k++) { - anIntArray1470[k] = (int) (65536D * Math.sin((double) k * 0.0030679614999999999D)); - anIntArray1471[k] = (int) (65536D * Math.cos((double) k * 0.0030679614999999999D)); + sin[k] = (int) (65536D * Math.sin((double) k * 0.0030679614999999999D)); + cos[k] = (int) (65536D * Math.cos((double) k * 0.0030679614999999999D)); } } public static void method363() { - anIntArray1468 = null; - anIntArray1468 = null; - anIntArray1470 = null; - anIntArray1471 = null; + recipreical15 = null; + recipreical15 = null; + sin = null; + cos = null; anIntArray1472 = null; aImageArray1474 = null; - aBooleanArray1475 = null; + textureTranslucent = null; anIntArray1476 = null; anIntArrayArray1478 = null; anIntArrayArray1479 = null; anIntArray1480 = null; - anIntArray1482 = null; + palette = null; anIntArrayArray1483 = null; } public static void method364() { - anIntArray1472 = new int[Draw2D.anInt1380]; - for (int j = 0; j < Draw2D.anInt1380; j++) { - anIntArray1472[j] = Draw2D.anInt1379 * j; + anIntArray1472 = new int[Draw2D.height]; + for (int j = 0; j < Draw2D.height; j++) { + anIntArray1472[j] = Draw2D.width * j; } - anInt1466 = Draw2D.anInt1379 / 2; - anInt1467 = Draw2D.anInt1380 / 2; + centerX = Draw2D.width / 2; + centerY = Draw2D.height / 2; } public static void method365(int j, int k) { @@ -71,8 +82,8 @@ public class Draw3D extends Draw2D { for (int l = 0; l < k; l++) { anIntArray1472[l] = j * l; } - anInt1466 = j / 2; - anInt1467 = k / 2; + centerX = j / 2; + centerY = k / 2; } public static void method366() { @@ -142,7 +153,7 @@ public class Draw3D extends Draw2D { anIntArrayArray1479[i] = null; } - public static int[] method371(int i) { + public static int[] getTexels(int i) { anIntArray1480[i] = anInt1481++; if (anIntArrayArray1479[i] != null) { return anIntArrayArray1479[i]; @@ -167,11 +178,11 @@ public class Draw3D extends Draw2D { Image8 image = aImageArray1474[i]; int[] ai1 = anIntArrayArray1483[i]; if (aBoolean1461) { - aBooleanArray1475[i] = false; + textureTranslucent[i] = false; for (int i1 = 0; i1 < 4096; i1++) { int i2 = ai[i1] = ai1[image.aByteArray1450[i1]] & 0xf8f8ff; if (i2 == 0) { - aBooleanArray1475[i] = true; + textureTranslucent[i] = true; } ai[4096 + i1] = i2 - (i2 >>> 3) & 0xf8f8ff; ai[8192 + i1] = i2 - (i2 >>> 2) & 0xf8f8ff; @@ -189,12 +200,12 @@ public class Draw3D extends Draw2D { ai[k1] = ai1[image.aByteArray1450[k1]]; } } - aBooleanArray1475[i] = false; + textureTranslucent[i] = false; for (int l1 = 0; l1 < 16384; l1++) { ai[l1] &= 0xf8f8ff; int k2 = ai[l1]; if (k2 == 0) { - aBooleanArray1475[i] = true; + textureTranslucent[i] = true; } ai[16384 + l1] = k2 - (k2 >>> 3) & 0xf8f8ff; ai[32768 + l1] = k2 - (k2 >>> 2) & 0xf8f8ff; @@ -267,7 +278,7 @@ public class Draw3D extends Draw2D { if (k2 == 0) { k2 = 1; } - anIntArray1482[j++] = k2; + palette[j++] = k2; } } for (int l = 0; l < 50; l++) { @@ -300,499 +311,549 @@ public class Draw3D extends Draw2D { return (j << 16) + (k << 8) + l; } - public static void method374(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2) { - int j2 = 0; - int k2 = 0; - if (j != i) { - j2 = (i1 - l << 16) / (j - i); - k2 = (l1 - k1 << 15) / (j - i); + /** + * Fills a gouraud triangle using {@link #palette} colors. + * + * @param yA the Y for corner A. + * @param yB the Y for corner B. + * @param yC the Y for corner C. + * @param xA the X for corner A. + * @param xB the X for corner B. + * @param xC the X for corner C. + * @param colorA the color for corner A. + * @param colorB the color for corner B. + * @param colorC the color for corner C. + */ + public static void fillGouraudTriangle(int yA, int yB, int yC, int xA, int xB, int xC, int colorA, int colorB, int colorC) { + int xStepAB = 0; + int xStepBC = 0; + int xStepAC = 0; + + int colorStepAB = 0; + int colorStepBC = 0; + int colorStepAC = 0; + + if (yB != yA) { + xStepAB = (xB - xA << 16) / (yB - yA); + colorStepAB = (colorB - colorA << 15) / (yB - yA); } - int l2 = 0; - int i3 = 0; - if (k != j) { - l2 = (j1 - i1 << 16) / (k - j); - i3 = (i2 - l1 << 15) / (k - j); + + if (yC != yB) { + xStepBC = (xC - xB << 16) / (yC - yB); + colorStepBC = (colorC - colorB << 15) / (yC - yB); } - int j3 = 0; - int k3 = 0; - if (k != i) { - j3 = (l - j1 << 16) / (i - k); - k3 = (k1 - i2 << 15) / (i - k); + + if (yC != yA) { + xStepAC = (xA - xC << 16) / (yA - yC); + colorStepAC = (colorA - colorC << 15) / (yA - yC); } - if (i <= j && i <= k) { - if (i >= Draw2D.anInt1382) { + + if (yA <= yB && yA <= yC) { + if (yA >= Draw2D.bottom) { return; } - if (j > Draw2D.anInt1382) { - j = Draw2D.anInt1382; + if (yB > Draw2D.bottom) { + yB = Draw2D.bottom; } - if (k > Draw2D.anInt1382) { - k = Draw2D.anInt1382; + if (yC > Draw2D.bottom) { + yC = Draw2D.bottom; } - if (j < k) { - j1 = l <<= 16; - i2 = k1 <<= 15; - if (i < 0) { - j1 -= j3 * i; - l -= j2 * i; - i2 -= k3 * i; - k1 -= k2 * i; - i = 0; + if (yB < yC) { + xC = xA <<= 16; + colorC = colorA <<= 15; + if (yA < 0) { + xC -= xStepAC * yA; + xA -= xStepAB * yA; + colorC -= colorStepAC * yA; + colorA -= colorStepAB * yA; + yA = 0; } - i1 <<= 16; - l1 <<= 15; - if (j < 0) { - i1 -= l2 * j; - l1 -= i3 * j; - j = 0; + xB <<= 16; + colorB <<= 15; + if (yB < 0) { + xB -= xStepBC * yB; + colorB -= colorStepBC * yB; + yB = 0; } - if (i != j && j3 < j2 || i == j && j3 > l2) { - k -= j; - j -= i; - for (i = anIntArray1472[i]; --j >= 0; i += Draw2D.anInt1379) { - method375(Draw2D.anIntArray1378, i, j1 >> 16, l >> 16, i2 >> 7, k1 >> 7); - j1 += j3; - l += j2; - i2 += k3; - k1 += k2; + if (yA != yB && xStepAC < xStepAB || yA == yB && xStepAC > xStepBC) { + yC -= yB; + yB -= yA; + for (yA = anIntArray1472[yA]; --yB >= 0; yA += Draw2D.width) { + drawGouraudScanline(Draw2D.pixels, yA, xC >> 16, xA >> 16, colorC >> 7, colorA >> 7); + xC += xStepAC; + xA += xStepAB; + colorC += colorStepAC; + colorA += colorStepAB; } - while (--k >= 0) { - method375(Draw2D.anIntArray1378, i, j1 >> 16, i1 >> 16, i2 >> 7, l1 >> 7); - j1 += j3; - i1 += l2; - i2 += k3; - l1 += i3; - i += Draw2D.anInt1379; + while (--yC >= 0) { + drawGouraudScanline(Draw2D.pixels, yA, xC >> 16, xB >> 16, colorC >> 7, colorB >> 7); + xC += xStepAC; + xB += xStepBC; + colorC += colorStepAC; + colorB += colorStepBC; + yA += Draw2D.width; } return; } - k -= j; - j -= i; - for (i = anIntArray1472[i]; --j >= 0; i += Draw2D.anInt1379) { - method375(Draw2D.anIntArray1378, i, l >> 16, j1 >> 16, k1 >> 7, i2 >> 7); - j1 += j3; - l += j2; - i2 += k3; - k1 += k2; + yC -= yB; + yB -= yA; + for (yA = anIntArray1472[yA]; --yB >= 0; yA += Draw2D.width) { + drawGouraudScanline(Draw2D.pixels, yA, xA >> 16, xC >> 16, colorA >> 7, colorC >> 7); + xC += xStepAC; + xA += xStepAB; + colorC += colorStepAC; + colorA += colorStepAB; } - while (--k >= 0) { - method375(Draw2D.anIntArray1378, i, i1 >> 16, j1 >> 16, l1 >> 7, i2 >> 7); - j1 += j3; - i1 += l2; - i2 += k3; - l1 += i3; - i += Draw2D.anInt1379; + while (--yC >= 0) { + drawGouraudScanline(Draw2D.pixels, yA, xB >> 16, xC >> 16, colorB >> 7, colorC >> 7); + xC += xStepAC; + xB += xStepBC; + colorC += colorStepAC; + colorB += colorStepBC; + yA += Draw2D.width; } return; } - i1 = l <<= 16; - l1 = k1 <<= 15; - if (i < 0) { - i1 -= j3 * i; - l -= j2 * i; - l1 -= k3 * i; - k1 -= k2 * i; - i = 0; + xB = xA <<= 16; + colorB = colorA <<= 15; + if (yA < 0) { + xB -= xStepAC * yA; + xA -= xStepAB * yA; + colorB -= colorStepAC * yA; + colorA -= colorStepAB * yA; + yA = 0; } - j1 <<= 16; - i2 <<= 15; - if (k < 0) { - j1 -= l2 * k; - i2 -= i3 * k; - k = 0; + xC <<= 16; + colorC <<= 15; + if (yC < 0) { + xC -= xStepBC * yC; + colorC -= colorStepBC * yC; + yC = 0; } - if (i != k && j3 < j2 || i == k && l2 > j2) { - j -= k; - k -= i; - for (i = anIntArray1472[i]; --k >= 0; i += Draw2D.anInt1379) { - method375(Draw2D.anIntArray1378, i, i1 >> 16, l >> 16, l1 >> 7, k1 >> 7); - i1 += j3; - l += j2; - l1 += k3; - k1 += k2; + if (yA != yC && xStepAC < xStepAB || yA == yC && xStepBC > xStepAB) { + yB -= yC; + yC -= yA; + for (yA = anIntArray1472[yA]; --yC >= 0; yA += Draw2D.width) { + drawGouraudScanline(Draw2D.pixels, yA, xB >> 16, xA >> 16, colorB >> 7, colorA >> 7); + xB += xStepAC; + xA += xStepAB; + colorB += colorStepAC; + colorA += colorStepAB; } - while (--j >= 0) { - method375(Draw2D.anIntArray1378, i, j1 >> 16, l >> 16, i2 >> 7, k1 >> 7); - j1 += l2; - l += j2; - i2 += i3; - k1 += k2; - i += Draw2D.anInt1379; + while (--yB >= 0) { + drawGouraudScanline(Draw2D.pixels, yA, xC >> 16, xA >> 16, colorC >> 7, colorA >> 7); + xC += xStepBC; + xA += xStepAB; + colorC += colorStepBC; + colorA += colorStepAB; + yA += Draw2D.width; } return; } - j -= k; - k -= i; - for (i = anIntArray1472[i]; --k >= 0; i += Draw2D.anInt1379) { - method375(Draw2D.anIntArray1378, i, l >> 16, i1 >> 16, k1 >> 7, l1 >> 7); - i1 += j3; - l += j2; - l1 += k3; - k1 += k2; + yB -= yC; + yC -= yA; + for (yA = anIntArray1472[yA]; --yC >= 0; yA += Draw2D.width) { + drawGouraudScanline(Draw2D.pixels, yA, xA >> 16, xB >> 16, colorA >> 7, colorB >> 7); + xB += xStepAC; + xA += xStepAB; + colorB += colorStepAC; + colorA += colorStepAB; } - while (--j >= 0) { - method375(Draw2D.anIntArray1378, i, l >> 16, j1 >> 16, k1 >> 7, i2 >> 7); - j1 += l2; - l += j2; - i2 += i3; - k1 += k2; - i += Draw2D.anInt1379; + while (--yB >= 0) { + drawGouraudScanline(Draw2D.pixels, yA, xA >> 16, xC >> 16, colorA >> 7, colorC >> 7); + xC += xStepBC; + xA += xStepAB; + colorC += colorStepBC; + colorA += colorStepAB; + yA += Draw2D.width; } return; } - if (j <= k) { - if (j >= Draw2D.anInt1382) { + if (yB <= yC) { + if (yB >= Draw2D.bottom) { return; } - if (k > Draw2D.anInt1382) { - k = Draw2D.anInt1382; + if (yC > Draw2D.bottom) { + yC = Draw2D.bottom; } - if (i > Draw2D.anInt1382) { - i = Draw2D.anInt1382; + if (yA > Draw2D.bottom) { + yA = Draw2D.bottom; } - if (k < i) { - l = i1 <<= 16; - k1 = l1 <<= 15; - if (j < 0) { - l -= j2 * j; - i1 -= l2 * j; - k1 -= k2 * j; - l1 -= i3 * j; - j = 0; + if (yC < yA) { + xA = xB <<= 16; + colorA = colorB <<= 15; + if (yB < 0) { + xA -= xStepAB * yB; + xB -= xStepBC * yB; + colorA -= colorStepAB * yB; + colorB -= colorStepBC * yB; + yB = 0; } - j1 <<= 16; - i2 <<= 15; - if (k < 0) { - j1 -= j3 * k; - i2 -= k3 * k; - k = 0; + xC <<= 16; + colorC <<= 15; + if (yC < 0) { + xC -= xStepAC * yC; + colorC -= colorStepAC * yC; + yC = 0; } - if (j != k && j2 < l2 || j == k && j2 > j3) { - i -= k; - k -= j; - for (j = anIntArray1472[j]; --k >= 0; j += Draw2D.anInt1379) { - method375(Draw2D.anIntArray1378, j, l >> 16, i1 >> 16, k1 >> 7, l1 >> 7); - l += j2; - i1 += l2; - k1 += k2; - l1 += i3; + if (yB != yC && xStepAB < xStepBC || yB == yC && xStepAB > xStepAC) { + yA -= yC; + yC -= yB; + for (yB = anIntArray1472[yB]; --yC >= 0; yB += Draw2D.width) { + drawGouraudScanline(Draw2D.pixels, yB, xA >> 16, xB >> 16, colorA >> 7, colorB >> 7); + xA += xStepAB; + xB += xStepBC; + colorA += colorStepAB; + colorB += colorStepBC; } - while (--i >= 0) { - method375(Draw2D.anIntArray1378, j, l >> 16, j1 >> 16, k1 >> 7, i2 >> 7); - l += j2; - j1 += j3; - k1 += k2; - i2 += k3; - j += Draw2D.anInt1379; + while (--yA >= 0) { + drawGouraudScanline(Draw2D.pixels, yB, xA >> 16, xC >> 16, colorA >> 7, colorC >> 7); + xA += xStepAB; + xC += xStepAC; + colorA += colorStepAB; + colorC += colorStepAC; + yB += Draw2D.width; } return; } - i -= k; - k -= j; - for (j = anIntArray1472[j]; --k >= 0; j += Draw2D.anInt1379) { - method375(Draw2D.anIntArray1378, j, i1 >> 16, l >> 16, l1 >> 7, k1 >> 7); - l += j2; - i1 += l2; - k1 += k2; - l1 += i3; + yA -= yC; + yC -= yB; + for (yB = anIntArray1472[yB]; --yC >= 0; yB += Draw2D.width) { + drawGouraudScanline(Draw2D.pixels, yB, xB >> 16, xA >> 16, colorB >> 7, colorA >> 7); + xA += xStepAB; + xB += xStepBC; + colorA += colorStepAB; + colorB += colorStepBC; } - while (--i >= 0) { - method375(Draw2D.anIntArray1378, j, j1 >> 16, l >> 16, i2 >> 7, k1 >> 7); - l += j2; - j1 += j3; - k1 += k2; - i2 += k3; - j += Draw2D.anInt1379; + while (--yA >= 0) { + drawGouraudScanline(Draw2D.pixels, yB, xC >> 16, xA >> 16, colorC >> 7, colorA >> 7); + xA += xStepAB; + xC += xStepAC; + colorA += colorStepAB; + colorC += colorStepAC; + yB += Draw2D.width; } return; } - j1 = i1 <<= 16; - i2 = l1 <<= 15; - if (j < 0) { - j1 -= j2 * j; - i1 -= l2 * j; - i2 -= k2 * j; - l1 -= i3 * j; - j = 0; + xC = xB <<= 16; + colorC = colorB <<= 15; + if (yB < 0) { + xC -= xStepAB * yB; + xB -= xStepBC * yB; + colorC -= colorStepAB * yB; + colorB -= colorStepBC * yB; + yB = 0; } - l <<= 16; - k1 <<= 15; - if (i < 0) { - l -= j3 * i; - k1 -= k3 * i; - i = 0; + xA <<= 16; + colorA <<= 15; + if (yA < 0) { + xA -= xStepAC * yA; + colorA -= colorStepAC * yA; + yA = 0; } - if (j2 < l2) { - k -= i; - i -= j; - for (j = anIntArray1472[j]; --i >= 0; j += Draw2D.anInt1379) { - method375(Draw2D.anIntArray1378, j, j1 >> 16, i1 >> 16, i2 >> 7, l1 >> 7); - j1 += j2; - i1 += l2; - i2 += k2; - l1 += i3; + if (xStepAB < xStepBC) { + yC -= yA; + yA -= yB; + for (yB = anIntArray1472[yB]; --yA >= 0; yB += Draw2D.width) { + drawGouraudScanline(Draw2D.pixels, yB, xC >> 16, xB >> 16, colorC >> 7, colorB >> 7); + xC += xStepAB; + xB += xStepBC; + colorC += colorStepAB; + colorB += colorStepBC; } - while (--k >= 0) { - method375(Draw2D.anIntArray1378, j, l >> 16, i1 >> 16, k1 >> 7, l1 >> 7); - l += j3; - i1 += l2; - k1 += k3; - l1 += i3; - j += Draw2D.anInt1379; + while (--yC >= 0) { + drawGouraudScanline(Draw2D.pixels, yB, xA >> 16, xB >> 16, colorA >> 7, colorB >> 7); + xA += xStepAC; + xB += xStepBC; + colorA += colorStepAC; + colorB += colorStepBC; + yB += Draw2D.width; } return; } - k -= i; - i -= j; - for (j = anIntArray1472[j]; --i >= 0; j += Draw2D.anInt1379) { - method375(Draw2D.anIntArray1378, j, i1 >> 16, j1 >> 16, l1 >> 7, i2 >> 7); - j1 += j2; - i1 += l2; - i2 += k2; - l1 += i3; + yC -= yA; + yA -= yB; + for (yB = anIntArray1472[yB]; --yA >= 0; yB += Draw2D.width) { + drawGouraudScanline(Draw2D.pixels, yB, xB >> 16, xC >> 16, colorB >> 7, colorC >> 7); + xC += xStepAB; + xB += xStepBC; + colorC += colorStepAB; + colorB += colorStepBC; } - while (--k >= 0) { - method375(Draw2D.anIntArray1378, j, i1 >> 16, l >> 16, l1 >> 7, k1 >> 7); - l += j3; - i1 += l2; - k1 += k3; - l1 += i3; - j += Draw2D.anInt1379; + while (--yC >= 0) { + drawGouraudScanline(Draw2D.pixels, yB, xB >> 16, xA >> 16, colorB >> 7, colorA >> 7); + xA += xStepAC; + xB += xStepBC; + colorA += colorStepAC; + colorB += colorStepBC; + yB += Draw2D.width; } return; } - if (k >= Draw2D.anInt1382) { + if (yC >= Draw2D.bottom) { return; } - if (i > Draw2D.anInt1382) { - i = Draw2D.anInt1382; + if (yA > Draw2D.bottom) { + yA = Draw2D.bottom; } - if (j > Draw2D.anInt1382) { - j = Draw2D.anInt1382; + if (yB > Draw2D.bottom) { + yB = Draw2D.bottom; } - if (i < j) { - i1 = j1 <<= 16; - l1 = i2 <<= 15; - if (k < 0) { - i1 -= l2 * k; - j1 -= j3 * k; - l1 -= i3 * k; - i2 -= k3 * k; - k = 0; + if (yA < yB) { + xB = xC <<= 16; + colorB = colorC <<= 15; + if (yC < 0) { + xB -= xStepBC * yC; + xC -= xStepAC * yC; + colorB -= colorStepBC * yC; + colorC -= colorStepAC * yC; + yC = 0; } - l <<= 16; - k1 <<= 15; - if (i < 0) { - l -= j2 * i; - k1 -= k2 * i; - i = 0; + xA <<= 16; + colorA <<= 15; + if (yA < 0) { + xA -= xStepAB * yA; + colorA -= colorStepAB * yA; + yA = 0; } - if (l2 < j3) { - j -= i; - i -= k; - for (k = anIntArray1472[k]; --i >= 0; k += Draw2D.anInt1379) { - method375(Draw2D.anIntArray1378, k, i1 >> 16, j1 >> 16, l1 >> 7, i2 >> 7); - i1 += l2; - j1 += j3; - l1 += i3; - i2 += k3; + if (xStepBC < xStepAC) { + yB -= yA; + yA -= yC; + for (yC = anIntArray1472[yC]; --yA >= 0; yC += Draw2D.width) { + drawGouraudScanline(Draw2D.pixels, yC, xB >> 16, xC >> 16, colorB >> 7, colorC >> 7); + xB += xStepBC; + xC += xStepAC; + colorB += colorStepBC; + colorC += colorStepAC; } - while (--j >= 0) { - method375(Draw2D.anIntArray1378, k, i1 >> 16, l >> 16, l1 >> 7, k1 >> 7); - i1 += l2; - l += j2; - l1 += i3; - k1 += k2; - k += Draw2D.anInt1379; + while (--yB >= 0) { + drawGouraudScanline(Draw2D.pixels, yC, xB >> 16, xA >> 16, colorB >> 7, colorA >> 7); + xB += xStepBC; + xA += xStepAB; + colorB += colorStepBC; + colorA += colorStepAB; + yC += Draw2D.width; } return; } - j -= i; - i -= k; - for (k = anIntArray1472[k]; --i >= 0; k += Draw2D.anInt1379) { - method375(Draw2D.anIntArray1378, k, j1 >> 16, i1 >> 16, i2 >> 7, l1 >> 7); - i1 += l2; - j1 += j3; - l1 += i3; - i2 += k3; + yB -= yA; + yA -= yC; + for (yC = anIntArray1472[yC]; --yA >= 0; yC += Draw2D.width) { + drawGouraudScanline(Draw2D.pixels, yC, xC >> 16, xB >> 16, colorC >> 7, colorB >> 7); + xB += xStepBC; + xC += xStepAC; + colorB += colorStepBC; + colorC += colorStepAC; } - while (--j >= 0) { - method375(Draw2D.anIntArray1378, k, l >> 16, i1 >> 16, k1 >> 7, l1 >> 7); - i1 += l2; - l += j2; - l1 += i3; - k1 += k2; - k += Draw2D.anInt1379; + while (--yB >= 0) { + drawGouraudScanline(Draw2D.pixels, yC, xA >> 16, xB >> 16, colorA >> 7, colorB >> 7); + xB += xStepBC; + xA += xStepAB; + colorB += colorStepBC; + colorA += colorStepAB; + yC += Draw2D.width; } return; } - l = j1 <<= 16; - k1 = i2 <<= 15; - if (k < 0) { - l -= l2 * k; - j1 -= j3 * k; - k1 -= i3 * k; - i2 -= k3 * k; - k = 0; + xA = xC <<= 16; + colorA = colorC <<= 15; + if (yC < 0) { + xA -= xStepBC * yC; + xC -= xStepAC * yC; + colorA -= colorStepBC * yC; + colorC -= colorStepAC * yC; + yC = 0; } - i1 <<= 16; - l1 <<= 15; - if (j < 0) { - i1 -= j2 * j; - l1 -= k2 * j; - j = 0; + xB <<= 16; + colorB <<= 15; + if (yB < 0) { + xB -= xStepAB * yB; + colorB -= colorStepAB * yB; + yB = 0; } - if (l2 < j3) { - i -= j; - j -= k; - for (k = anIntArray1472[k]; --j >= 0; k += Draw2D.anInt1379) { - method375(Draw2D.anIntArray1378, k, l >> 16, j1 >> 16, k1 >> 7, i2 >> 7); - l += l2; - j1 += j3; - k1 += i3; - i2 += k3; + if (xStepBC < xStepAC) { + yA -= yB; + yB -= yC; + for (yC = anIntArray1472[yC]; --yB >= 0; yC += Draw2D.width) { + drawGouraudScanline(Draw2D.pixels, yC, xA >> 16, xC >> 16, colorA >> 7, colorC >> 7); + xA += xStepBC; + xC += xStepAC; + colorA += colorStepBC; + colorC += colorStepAC; } - while (--i >= 0) { - method375(Draw2D.anIntArray1378, k, i1 >> 16, j1 >> 16, l1 >> 7, i2 >> 7); - i1 += j2; - j1 += j3; - l1 += k2; - i2 += k3; - k += Draw2D.anInt1379; + while (--yA >= 0) { + drawGouraudScanline(Draw2D.pixels, yC, xB >> 16, xC >> 16, colorB >> 7, colorC >> 7); + xB += xStepAB; + xC += xStepAC; + colorB += colorStepAB; + colorC += colorStepAC; + yC += Draw2D.width; } return; } - i -= j; - j -= k; - for (k = anIntArray1472[k]; --j >= 0; k += Draw2D.anInt1379) { - method375(Draw2D.anIntArray1378, k, j1 >> 16, l >> 16, i2 >> 7, k1 >> 7); - l += l2; - j1 += j3; - k1 += i3; - i2 += k3; + yA -= yB; + yB -= yC; + for (yC = anIntArray1472[yC]; --yB >= 0; yC += Draw2D.width) { + drawGouraudScanline(Draw2D.pixels, yC, xC >> 16, xA >> 16, colorC >> 7, colorA >> 7); + xA += xStepBC; + xC += xStepAC; + colorA += colorStepBC; + colorC += colorStepAC; } - while (--i >= 0) { - method375(Draw2D.anIntArray1378, k, j1 >> 16, i1 >> 16, i2 >> 7, l1 >> 7); - i1 += j2; - j1 += j3; - l1 += k2; - i2 += k3; - k += Draw2D.anInt1379; + while (--yA >= 0) { + drawGouraudScanline(Draw2D.pixels, yC, xC >> 16, xB >> 16, colorC >> 7, colorB >> 7); + xB += xStepAB; + xC += xStepAC; + colorB += colorStepAB; + colorC += colorStepAC; + yC += Draw2D.width; } } - public static void method375(int[] ai, int i, int l, int i1, int j1, int k1) { - int j; - int k; - if (aBoolean1464) { - int l1; - if (aBoolean1462) { - if (i1 - l > 3) { - l1 = (k1 - j1) / (i1 - l); + /** + * Draws a gouraud scanline using {@link #palette} colors. + * + * @param dst the destination. + * @param dstOff the destination offset. + * @param leftX the left x. + * @param rightX the right x. + * @param leftColor the left color. + * @param rightColor the right color. + * @see #fillGouraudTriangle(int, int, int, int, int, int, int, int, int) e + */ + public static void drawGouraudScanline(int[] dst, int dstOff, int leftX, int rightX, int leftColor, int rightColor) { + int color; + int length; + + if (jagged) { + int colorStep; + + if (clipX) { + if (rightX - leftX > 3) { + colorStep = (rightColor - leftColor) / (rightX - leftX); } else { - l1 = 0; + colorStep = 0; } - if (i1 > Draw2D.anInt1385) { - i1 = Draw2D.anInt1385; + + if (rightX > Draw2D.boundX) { + rightX = Draw2D.boundX; } - if (l < 0) { - j1 -= l * l1; - l = 0; + + if (leftX < 0) { + leftColor -= leftX * colorStep; + leftX = 0; } - if (l >= i1) { + + if (leftX >= rightX) { return; } - i += l; - k = i1 - l >> 2; - l1 <<= 2; + + dstOff += leftX; + length = rightX - leftX >> 2; + colorStep <<= 2; } else { - if (l >= i1) { + if (leftX >= rightX) { return; } - i += l; - k = i1 - l >> 2; - if (k > 0) { - l1 = (k1 - j1) * anIntArray1468[k] >> 15; + + dstOff += leftX; + length = rightX - leftX >> 2; + + if (length > 0) { + colorStep = (rightColor - leftColor) * recipreical15[length] >> 15; } else { - l1 = 0; + colorStep = 0; } } - if (anInt1465 == 0) { - while (--k >= 0) { - j = anIntArray1482[j1 >> 8]; - j1 += l1; - ai[i++] = j; - ai[i++] = j; - ai[i++] = j; - ai[i++] = j; + + if (Draw3D.alpha == 0) { + while (--length >= 0) { + color = palette[leftColor >> 8]; + leftColor += colorStep; + dst[dstOff++] = color; + dst[dstOff++] = color; + dst[dstOff++] = color; + dst[dstOff++] = color; } - k = i1 - l & 3; - if (k > 0) { - j = anIntArray1482[j1 >> 8]; + + length = rightX - leftX & 3; + + if (length > 0) { + color = palette[leftColor >> 8]; do { - ai[i++] = j; - } while (--k > 0); + dst[dstOff++] = color; + } while (--length > 0); return; } } else { - int j2 = anInt1465; - int l2 = 256 - anInt1465; - while (--k >= 0) { - j = anIntArray1482[j1 >> 8]; - j1 += l1; - j = ((j & 0xff00ff) * l2 >> 8 & 0xff00ff) + ((j & 0xff00) * l2 >> 8 & 0xff00); - ai[i++] = j + ((ai[i] & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j2 >> 8 & 0xff00); - ai[i++] = j + ((ai[i] & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j2 >> 8 & 0xff00); - ai[i++] = j + ((ai[i] & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j2 >> 8 & 0xff00); - ai[i++] = j + ((ai[i] & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j2 >> 8 & 0xff00); + int alpha = Draw3D.alpha; + int invAlpha = 256 - Draw3D.alpha; + + while (--length >= 0) { + color = palette[leftColor >> 8]; + leftColor += colorStep; + color = ((color & 0xff00ff) * invAlpha >> 8 & 0xff00ff) + ((color & 0xff00) * invAlpha >> 8 & 0xff00); + dst[dstOff++] = color + ((dst[dstOff] & 0xff00ff) * alpha >> 8 & 0xff00ff) + ((dst[dstOff] & 0xff00) * alpha >> 8 & 0xff00); + dst[dstOff++] = color + ((dst[dstOff] & 0xff00ff) * alpha >> 8 & 0xff00ff) + ((dst[dstOff] & 0xff00) * alpha >> 8 & 0xff00); + dst[dstOff++] = color + ((dst[dstOff] & 0xff00ff) * alpha >> 8 & 0xff00ff) + ((dst[dstOff] & 0xff00) * alpha >> 8 & 0xff00); + dst[dstOff++] = color + ((dst[dstOff] & 0xff00ff) * alpha >> 8 & 0xff00ff) + ((dst[dstOff] & 0xff00) * alpha >> 8 & 0xff00); } - k = i1 - l & 3; - if (k > 0) { - j = anIntArray1482[j1 >> 8]; - j = ((j & 0xff00ff) * l2 >> 8 & 0xff00ff) + ((j & 0xff00) * l2 >> 8 & 0xff00); + + length = rightX - leftX & 3; + + if (length > 0) { + color = palette[leftColor >> 8]; + color = ((color & 0xff00ff) * invAlpha >> 8 & 0xff00ff) + ((color & 0xff00) * invAlpha >> 8 & 0xff00); do { - ai[i++] = j + ((ai[i] & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j2 >> 8 & 0xff00); - } while (--k > 0); + dst[dstOff++] = color + ((dst[dstOff] & 0xff00ff) * alpha >> 8 & 0xff00ff) + ((dst[dstOff] & 0xff00) * alpha >> 8 & 0xff00); + } while (--length > 0); } } return; } - if (l >= i1) { + + if (leftX >= rightX) { return; } - int i2 = (k1 - j1) / (i1 - l); - if (aBoolean1462) { - if (i1 > Draw2D.anInt1385) { - i1 = Draw2D.anInt1385; + + int colorStep = (rightColor - leftColor) / (rightX - leftX); + + if (clipX) { + if (rightX > Draw2D.boundX) { + rightX = Draw2D.boundX; } - if (l < 0) { - j1 -= l * i2; - l = 0; + if (leftX < 0) { + leftColor -= leftX * colorStep; + leftX = 0; } - if (l >= i1) { + if (leftX >= rightX) { return; } } - i += l; - k = i1 - l; - if (anInt1465 == 0) { + + dstOff += leftX; + length = rightX - leftX; + + if (Draw3D.alpha == 0) { do { - ai[i++] = anIntArray1482[j1 >> 8]; - j1 += i2; - } while (--k > 0); + dst[dstOff++] = palette[leftColor >> 8]; + leftColor += colorStep; + } while (--length > 0); return; } - int k2 = anInt1465; - int i3 = 256 - anInt1465; + + int alpha = Draw3D.alpha; + int invAlpha = 256 - Draw3D.alpha; + do { - j = anIntArray1482[j1 >> 8]; - j1 += i2; - j = ((j & 0xff00ff) * i3 >> 8 & 0xff00ff) + ((j & 0xff00) * i3 >> 8 & 0xff00); - ai[i++] = j + ((ai[i] & 0xff00ff) * k2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * k2 >> 8 & 0xff00); - } while (--k > 0); + color = palette[leftColor >> 8]; + leftColor += colorStep; + color = ((color & 0xff00ff) * invAlpha >> 8 & 0xff00ff) + ((color & 0xff00) * invAlpha >> 8 & 0xff00); + dst[dstOff++] = color + ((dst[dstOff] & 0xff00ff) * alpha >> 8 & 0xff00ff) + ((dst[dstOff] & 0xff00) * alpha >> 8 & 0xff00); + } while (--length > 0); } - public static void method376(int i, int j, int k, int l, int i1, int j1, int k1) { + public static void fillTriangle(int i, int j, int k, int l, int i1, int j1, int k1) { int l1 = 0; if (j != i) { l1 = (i1 - l << 16) / (j - i); @@ -806,14 +867,14 @@ public class Draw3D extends Draw2D { j2 = (l - j1 << 16) / (i - k); } if (i <= j && i <= k) { - if (i >= Draw2D.anInt1382) { + if (i >= Draw2D.bottom) { return; } - if (j > Draw2D.anInt1382) { - j = Draw2D.anInt1382; + if (j > Draw2D.bottom) { + j = Draw2D.bottom; } - if (k > Draw2D.anInt1382) { - k = Draw2D.anInt1382; + if (k > Draw2D.bottom) { + k = Draw2D.bottom; } if (j < k) { j1 = l <<= 16; @@ -830,31 +891,31 @@ public class Draw3D extends Draw2D { if (i != j && j2 < l1 || i == j && j2 > i2) { k -= j; j -= i; - for (i = anIntArray1472[i]; --j >= 0; i += Draw2D.anInt1379) { - method377(Draw2D.anIntArray1378, i, k1, j1 >> 16, l >> 16); + for (i = anIntArray1472[i]; --j >= 0; i += Draw2D.width) { + method377(Draw2D.pixels, i, k1, j1 >> 16, l >> 16); j1 += j2; l += l1; } while (--k >= 0) { - method377(Draw2D.anIntArray1378, i, k1, j1 >> 16, i1 >> 16); + method377(Draw2D.pixels, i, k1, j1 >> 16, i1 >> 16); j1 += j2; i1 += i2; - i += Draw2D.anInt1379; + i += Draw2D.width; } return; } k -= j; j -= i; - for (i = anIntArray1472[i]; --j >= 0; i += Draw2D.anInt1379) { - method377(Draw2D.anIntArray1378, i, k1, l >> 16, j1 >> 16); + for (i = anIntArray1472[i]; --j >= 0; i += Draw2D.width) { + method377(Draw2D.pixels, i, k1, l >> 16, j1 >> 16); j1 += j2; l += l1; } while (--k >= 0) { - method377(Draw2D.anIntArray1378, i, k1, i1 >> 16, j1 >> 16); + method377(Draw2D.pixels, i, k1, i1 >> 16, j1 >> 16); j1 += j2; i1 += i2; - i += Draw2D.anInt1379; + i += Draw2D.width; } return; } @@ -872,43 +933,43 @@ public class Draw3D extends Draw2D { if (i != k && j2 < l1 || i == k && i2 > l1) { j -= k; k -= i; - for (i = anIntArray1472[i]; --k >= 0; i += Draw2D.anInt1379) { - method377(Draw2D.anIntArray1378, i, k1, i1 >> 16, l >> 16); + for (i = anIntArray1472[i]; --k >= 0; i += Draw2D.width) { + method377(Draw2D.pixels, i, k1, i1 >> 16, l >> 16); i1 += j2; l += l1; } while (--j >= 0) { - method377(Draw2D.anIntArray1378, i, k1, j1 >> 16, l >> 16); + method377(Draw2D.pixels, i, k1, j1 >> 16, l >> 16); j1 += i2; l += l1; - i += Draw2D.anInt1379; + i += Draw2D.width; } return; } j -= k; k -= i; - for (i = anIntArray1472[i]; --k >= 0; i += Draw2D.anInt1379) { - method377(Draw2D.anIntArray1378, i, k1, l >> 16, i1 >> 16); + for (i = anIntArray1472[i]; --k >= 0; i += Draw2D.width) { + method377(Draw2D.pixels, i, k1, l >> 16, i1 >> 16); i1 += j2; l += l1; } while (--j >= 0) { - method377(Draw2D.anIntArray1378, i, k1, l >> 16, j1 >> 16); + method377(Draw2D.pixels, i, k1, l >> 16, j1 >> 16); j1 += i2; l += l1; - i += Draw2D.anInt1379; + i += Draw2D.width; } return; } if (j <= k) { - if (j >= Draw2D.anInt1382) { + if (j >= Draw2D.bottom) { return; } - if (k > Draw2D.anInt1382) { - k = Draw2D.anInt1382; + if (k > Draw2D.bottom) { + k = Draw2D.bottom; } - if (i > Draw2D.anInt1382) { - i = Draw2D.anInt1382; + if (i > Draw2D.bottom) { + i = Draw2D.bottom; } if (k < i) { l = i1 <<= 16; @@ -925,31 +986,31 @@ public class Draw3D extends Draw2D { if (j != k && l1 < i2 || j == k && l1 > j2) { i -= k; k -= j; - for (j = anIntArray1472[j]; --k >= 0; j += Draw2D.anInt1379) { - method377(Draw2D.anIntArray1378, j, k1, l >> 16, i1 >> 16); + for (j = anIntArray1472[j]; --k >= 0; j += Draw2D.width) { + method377(Draw2D.pixels, j, k1, l >> 16, i1 >> 16); l += l1; i1 += i2; } while (--i >= 0) { - method377(Draw2D.anIntArray1378, j, k1, l >> 16, j1 >> 16); + method377(Draw2D.pixels, j, k1, l >> 16, j1 >> 16); l += l1; j1 += j2; - j += Draw2D.anInt1379; + j += Draw2D.width; } return; } i -= k; k -= j; - for (j = anIntArray1472[j]; --k >= 0; j += Draw2D.anInt1379) { - method377(Draw2D.anIntArray1378, j, k1, i1 >> 16, l >> 16); + for (j = anIntArray1472[j]; --k >= 0; j += Draw2D.width) { + method377(Draw2D.pixels, j, k1, i1 >> 16, l >> 16); l += l1; i1 += i2; } while (--i >= 0) { - method377(Draw2D.anIntArray1378, j, k1, j1 >> 16, l >> 16); + method377(Draw2D.pixels, j, k1, j1 >> 16, l >> 16); l += l1; j1 += j2; - j += Draw2D.anInt1379; + j += Draw2D.width; } return; } @@ -967,42 +1028,42 @@ public class Draw3D extends Draw2D { if (l1 < i2) { k -= i; i -= j; - for (j = anIntArray1472[j]; --i >= 0; j += Draw2D.anInt1379) { - method377(Draw2D.anIntArray1378, j, k1, j1 >> 16, i1 >> 16); + for (j = anIntArray1472[j]; --i >= 0; j += Draw2D.width) { + method377(Draw2D.pixels, j, k1, j1 >> 16, i1 >> 16); j1 += l1; i1 += i2; } while (--k >= 0) { - method377(Draw2D.anIntArray1378, j, k1, l >> 16, i1 >> 16); + method377(Draw2D.pixels, j, k1, l >> 16, i1 >> 16); l += j2; i1 += i2; - j += Draw2D.anInt1379; + j += Draw2D.width; } return; } k -= i; i -= j; - for (j = anIntArray1472[j]; --i >= 0; j += Draw2D.anInt1379) { - method377(Draw2D.anIntArray1378, j, k1, i1 >> 16, j1 >> 16); + for (j = anIntArray1472[j]; --i >= 0; j += Draw2D.width) { + method377(Draw2D.pixels, j, k1, i1 >> 16, j1 >> 16); j1 += l1; i1 += i2; } while (--k >= 0) { - method377(Draw2D.anIntArray1378, j, k1, i1 >> 16, l >> 16); + method377(Draw2D.pixels, j, k1, i1 >> 16, l >> 16); l += j2; i1 += i2; - j += Draw2D.anInt1379; + j += Draw2D.width; } return; } - if (k >= Draw2D.anInt1382) { + if (k >= Draw2D.bottom) { return; } - if (i > Draw2D.anInt1382) { - i = Draw2D.anInt1382; + if (i > Draw2D.bottom) { + i = Draw2D.bottom; } - if (j > Draw2D.anInt1382) { - j = Draw2D.anInt1382; + if (j > Draw2D.bottom) { + j = Draw2D.bottom; } if (i < j) { i1 = j1 <<= 16; @@ -1019,31 +1080,31 @@ public class Draw3D extends Draw2D { if (i2 < j2) { j -= i; i -= k; - for (k = anIntArray1472[k]; --i >= 0; k += Draw2D.anInt1379) { - method377(Draw2D.anIntArray1378, k, k1, i1 >> 16, j1 >> 16); + for (k = anIntArray1472[k]; --i >= 0; k += Draw2D.width) { + method377(Draw2D.pixels, k, k1, i1 >> 16, j1 >> 16); i1 += i2; j1 += j2; } while (--j >= 0) { - method377(Draw2D.anIntArray1378, k, k1, i1 >> 16, l >> 16); + method377(Draw2D.pixels, k, k1, i1 >> 16, l >> 16); i1 += i2; l += l1; - k += Draw2D.anInt1379; + k += Draw2D.width; } return; } j -= i; i -= k; - for (k = anIntArray1472[k]; --i >= 0; k += Draw2D.anInt1379) { - method377(Draw2D.anIntArray1378, k, k1, j1 >> 16, i1 >> 16); + for (k = anIntArray1472[k]; --i >= 0; k += Draw2D.width) { + method377(Draw2D.pixels, k, k1, j1 >> 16, i1 >> 16); i1 += i2; j1 += j2; } while (--j >= 0) { - method377(Draw2D.anIntArray1378, k, k1, l >> 16, i1 >> 16); + method377(Draw2D.pixels, k, k1, l >> 16, i1 >> 16); i1 += i2; l += l1; - k += Draw2D.anInt1379; + k += Draw2D.width; } return; } @@ -1061,586 +1122,604 @@ public class Draw3D extends Draw2D { if (i2 < j2) { i -= j; j -= k; - for (k = anIntArray1472[k]; --j >= 0; k += Draw2D.anInt1379) { - method377(Draw2D.anIntArray1378, k, k1, l >> 16, j1 >> 16); + for (k = anIntArray1472[k]; --j >= 0; k += Draw2D.width) { + method377(Draw2D.pixels, k, k1, l >> 16, j1 >> 16); l += i2; j1 += j2; } while (--i >= 0) { - method377(Draw2D.anIntArray1378, k, k1, i1 >> 16, j1 >> 16); + method377(Draw2D.pixels, k, k1, i1 >> 16, j1 >> 16); i1 += l1; j1 += j2; - k += Draw2D.anInt1379; + k += Draw2D.width; } return; } i -= j; j -= k; - for (k = anIntArray1472[k]; --j >= 0; k += Draw2D.anInt1379) { - method377(Draw2D.anIntArray1378, k, k1, j1 >> 16, l >> 16); + for (k = anIntArray1472[k]; --j >= 0; k += Draw2D.width) { + method377(Draw2D.pixels, k, k1, j1 >> 16, l >> 16); l += i2; j1 += j2; } while (--i >= 0) { - method377(Draw2D.anIntArray1378, k, k1, j1 >> 16, i1 >> 16); + method377(Draw2D.pixels, k, k1, j1 >> 16, i1 >> 16); i1 += l1; j1 += j2; - k += Draw2D.anInt1379; + k += Draw2D.width; } } - public static void method377(int[] ai, int i, int j, int l, int i1) { - if (aBoolean1462) { - if (i1 > Draw2D.anInt1385) { - i1 = Draw2D.anInt1385; + public static void method377(int[] dst, int dstOff, int rgb, int leftX, int rightX) { + if (clipX) { + if (rightX > Draw2D.boundX) { + rightX = Draw2D.boundX; } - if (l < 0) { - l = 0; + if (leftX < 0) { + leftX = 0; } } - if (l >= i1) { + + if (leftX >= rightX) { return; } - i += l; - int k = i1 - l >> 2; - if (anInt1465 == 0) { - while (--k >= 0) { - ai[i++] = j; - ai[i++] = j; - ai[i++] = j; - ai[i++] = j; + + dstOff += leftX; + int length = rightX - leftX >> 2; + + if (Draw3D.alpha == 0) { + while (--length >= 0) { + dst[dstOff++] = rgb; + dst[dstOff++] = rgb; + dst[dstOff++] = rgb; + dst[dstOff++] = rgb; } - for (k = i1 - l & 3; --k >= 0; ) { - ai[i++] = j; + for (length = rightX - leftX & 3; --length >= 0; ) { + dst[dstOff++] = rgb; } return; } - int j1 = anInt1465; - int k1 = 256 - anInt1465; - j = ((j & 0xff00ff) * k1 >> 8 & 0xff00ff) + ((j & 0xff00) * k1 >> 8 & 0xff00); - while (--k >= 0) { - ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00); - ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00); - ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00); - ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00); + + int alpha = Draw3D.alpha; + int invAlpha = 256 - Draw3D.alpha; + + rgb = ((rgb & 0xff00ff) * invAlpha >> 8 & 0xff00ff) + ((rgb & 0xff00) * invAlpha >> 8 & 0xff00); + + while (--length >= 0) { + dst[dstOff++] = rgb + ((dst[dstOff] & 0xff00ff) * alpha >> 8 & 0xff00ff) + ((dst[dstOff] & 0xff00) * alpha >> 8 & 0xff00); + dst[dstOff++] = rgb + ((dst[dstOff] & 0xff00ff) * alpha >> 8 & 0xff00ff) + ((dst[dstOff] & 0xff00) * alpha >> 8 & 0xff00); + dst[dstOff++] = rgb + ((dst[dstOff] & 0xff00ff) * alpha >> 8 & 0xff00ff) + ((dst[dstOff] & 0xff00) * alpha >> 8 & 0xff00); + dst[dstOff++] = rgb + ((dst[dstOff] & 0xff00ff) * alpha >> 8 & 0xff00ff) + ((dst[dstOff] & 0xff00) * alpha >> 8 & 0xff00); } - for (k = i1 - l & 3; --k >= 0; ) { - ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00); + + for (length = rightX - leftX & 3; --length >= 0; ) { + dst[dstOff++] = rgb + ((dst[dstOff] & 0xff00ff) * alpha >> 8 & 0xff00ff) + ((dst[dstOff] & 0xff00) * alpha >> 8 & 0xff00); } } - public static void method378(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2, int j2, int k2, int l2, int i3, int j3, int k3, int l3, int i4, int j4, int k4) { - int[] ai = method371(k4); - aBoolean1463 = !aBooleanArray1475[k4]; - k2 = j2 - k2; - j3 = i3 - j3; - i4 = l3 - i4; - l2 -= j2; - k3 -= i3; - j4 -= l3; - int l4 = l2 * i3 - k3 * j2 << 14; - int i5 = k3 * l3 - j4 * i3 << 8; - int j5 = j4 * j2 - l2 * l3 << 5; - int k5 = k2 * i3 - j3 * j2 << 14; - int l5 = j3 * l3 - i4 * i3 << 8; - int i6 = i4 * j2 - k2 * l3 << 5; - int j6 = j3 * l2 - k2 * k3 << 14; - int k6 = i4 * k3 - j3 * j4 << 8; - int l6 = k2 * j4 - i4 * l2 << 5; - int i7 = 0; - int j7 = 0; - if (j != i) { - i7 = (i1 - l << 16) / (j - i); - j7 = (l1 - k1 << 16) / (j - i); + public static void fillTexturedTriangle(int yA, int yB, int yC, int xA, int xB, int xC, int lightnessA, int lightnessB, int lightnessC, int viewXA, int viewXB, int viewXC, int viewYA, int viewYB, int viewYC, int viewZA, int viewZB, int viewZC, int textureId) { + int[] texels = getTexels(textureId); + opaque = !textureTranslucent[textureId]; + + viewXB = viewXA - viewXB; + viewYB = viewYA - viewYB; + viewZB = viewZA - viewZB; + + viewXC -= viewXA; + viewYC -= viewYA; + viewZC -= viewZA; + + int l4 = viewXC * viewYA - viewYC * viewXA << 14; + int i5 = viewYC * viewZA - viewZC * viewYA << 8; + int j5 = viewZC * viewXA - viewXC * viewZA << 5; + + int k5 = viewXB * viewYA - viewYB * viewXA << 14; + int l5 = viewYB * viewZA - viewZB * viewYA << 8; + int i6 = viewZB * viewXA - viewXB * viewZA << 5; + + int j6 = viewYB * viewXC - viewXB * viewYC << 14; + int k6 = viewZB * viewYC - viewYB * viewZC << 8; + int l6 = viewXB * viewZC - viewZB * viewXC << 5; + + int xStepAB = 0; + int xStepBC = 0; + int xStepAC = 0; + + int lightnessStepAB = 0; + int lightnessStepBC = 0; + int lightnessStepAC = 0; + + if (yB != yA) { + xStepAB = (xB - xA << 16) / (yB - yA); + lightnessStepAB = (lightnessB - lightnessA << 16) / (yB - yA); } - int k7 = 0; - int l7 = 0; - if (k != j) { - k7 = (j1 - i1 << 16) / (k - j); - l7 = (i2 - l1 << 16) / (k - j); + + if (yC != yB) { + xStepBC = (xC - xB << 16) / (yC - yB); + lightnessStepBC = (lightnessC - lightnessB << 16) / (yC - yB); } - int i8 = 0; - int j8 = 0; - if (k != i) { - i8 = (l - j1 << 16) / (i - k); - j8 = (k1 - i2 << 16) / (i - k); + + if (yC != yA) { + xStepAC = (xA - xC << 16) / (yA - yC); + lightnessStepAC = (lightnessA - lightnessC << 16) / (yA - yC); } - if (i <= j && i <= k) { - if (i >= Draw2D.anInt1382) { + + if (yA <= yB && yA <= yC) { + if (yA >= Draw2D.bottom) { return; } - if (j > Draw2D.anInt1382) { - j = Draw2D.anInt1382; + if (yB > Draw2D.bottom) { + yB = Draw2D.bottom; } - if (k > Draw2D.anInt1382) { - k = Draw2D.anInt1382; + if (yC > Draw2D.bottom) { + yC = Draw2D.bottom; } - if (j < k) { - j1 = l <<= 16; - i2 = k1 <<= 16; - if (i < 0) { - j1 -= i8 * i; - l -= i7 * i; - i2 -= j8 * i; - k1 -= j7 * i; - i = 0; + if (yB < yC) { + xC = xA <<= 16; + lightnessC = lightnessA <<= 16; + if (yA < 0) { + xC -= xStepAC * yA; + xA -= xStepAB * yA; + lightnessC -= lightnessStepAC * yA; + lightnessA -= lightnessStepAB * yA; + yA = 0; } - i1 <<= 16; - l1 <<= 16; - if (j < 0) { - i1 -= k7 * j; - l1 -= l7 * j; - j = 0; + xB <<= 16; + lightnessB <<= 16; + if (yB < 0) { + xB -= xStepBC * yB; + lightnessB -= lightnessStepBC * yB; + yB = 0; } - int k8 = i - anInt1467; + int k8 = yA - centerY; l4 += j5 * k8; k5 += i6 * k8; j6 += l6 * k8; - if (i != j && i8 < i7 || i == j && i8 > k7) { - k -= j; - j -= i; - i = anIntArray1472[i]; - while (--j >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, i, j1 >> 16, l >> 16, i2 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6); - j1 += i8; - l += i7; - i2 += j8; - k1 += j7; - i += Draw2D.anInt1379; + if (yA != yB && xStepAC < xStepAB || yA == yB && xStepAC > xStepBC) { + yC -= yB; + yB -= yA; + yA = anIntArray1472[yA]; + while (--yB >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yA, xC >> 16, xA >> 16, lightnessC >> 8, lightnessA >> 8, l4, k5, j6, i5, l5, k6); + xC += xStepAC; + xA += xStepAB; + lightnessC += lightnessStepAC; + lightnessA += lightnessStepAB; + yA += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } - while (--k >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, i, j1 >> 16, i1 >> 16, i2 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6); - j1 += i8; - i1 += k7; - i2 += j8; - l1 += l7; - i += Draw2D.anInt1379; + while (--yC >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yA, xC >> 16, xB >> 16, lightnessC >> 8, lightnessB >> 8, l4, k5, j6, i5, l5, k6); + xC += xStepAC; + xB += xStepBC; + lightnessC += lightnessStepAC; + lightnessB += lightnessStepBC; + yA += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } return; } - k -= j; - j -= i; - i = anIntArray1472[i]; - while (--j >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, i, l >> 16, j1 >> 16, k1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6); - j1 += i8; - l += i7; - i2 += j8; - k1 += j7; - i += Draw2D.anInt1379; + yC -= yB; + yB -= yA; + yA = anIntArray1472[yA]; + while (--yB >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yA, xA >> 16, xC >> 16, lightnessA >> 8, lightnessC >> 8, l4, k5, j6, i5, l5, k6); + xC += xStepAC; + xA += xStepAB; + lightnessC += lightnessStepAC; + lightnessA += lightnessStepAB; + yA += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } - while (--k >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, i, i1 >> 16, j1 >> 16, l1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6); - j1 += i8; - i1 += k7; - i2 += j8; - l1 += l7; - i += Draw2D.anInt1379; + while (--yC >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yA, xB >> 16, xC >> 16, lightnessB >> 8, lightnessC >> 8, l4, k5, j6, i5, l5, k6); + xC += xStepAC; + xB += xStepBC; + lightnessC += lightnessStepAC; + lightnessB += lightnessStepBC; + yA += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } return; } - i1 = l <<= 16; - l1 = k1 <<= 16; - if (i < 0) { - i1 -= i8 * i; - l -= i7 * i; - l1 -= j8 * i; - k1 -= j7 * i; - i = 0; + xB = xA <<= 16; + lightnessB = lightnessA <<= 16; + if (yA < 0) { + xB -= xStepAC * yA; + xA -= xStepAB * yA; + lightnessB -= lightnessStepAC * yA; + lightnessA -= lightnessStepAB * yA; + yA = 0; } - j1 <<= 16; - i2 <<= 16; - if (k < 0) { - j1 -= k7 * k; - i2 -= l7 * k; - k = 0; + xC <<= 16; + lightnessC <<= 16; + if (yC < 0) { + xC -= xStepBC * yC; + lightnessC -= lightnessStepBC * yC; + yC = 0; } - int l8 = i - anInt1467; + int l8 = yA - centerY; l4 += j5 * l8; k5 += i6 * l8; j6 += l6 * l8; - if (i != k && i8 < i7 || i == k && k7 > i7) { - j -= k; - k -= i; - i = anIntArray1472[i]; - while (--k >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, i, i1 >> 16, l >> 16, l1 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6); - i1 += i8; - l += i7; - l1 += j8; - k1 += j7; - i += Draw2D.anInt1379; + if (yA != yC && xStepAC < xStepAB || yA == yC && xStepBC > xStepAB) { + yB -= yC; + yC -= yA; + yA = anIntArray1472[yA]; + while (--yC >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yA, xB >> 16, xA >> 16, lightnessB >> 8, lightnessA >> 8, l4, k5, j6, i5, l5, k6); + xB += xStepAC; + xA += xStepAB; + lightnessB += lightnessStepAC; + lightnessA += lightnessStepAB; + yA += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } - while (--j >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, i, j1 >> 16, l >> 16, i2 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6); - j1 += k7; - l += i7; - i2 += l7; - k1 += j7; - i += Draw2D.anInt1379; + while (--yB >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yA, xC >> 16, xA >> 16, lightnessC >> 8, lightnessA >> 8, l4, k5, j6, i5, l5, k6); + xC += xStepBC; + xA += xStepAB; + lightnessC += lightnessStepBC; + lightnessA += lightnessStepAB; + yA += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } return; } - j -= k; - k -= i; - i = anIntArray1472[i]; - while (--k >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, i, l >> 16, i1 >> 16, k1 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6); - i1 += i8; - l += i7; - l1 += j8; - k1 += j7; - i += Draw2D.anInt1379; + yB -= yC; + yC -= yA; + yA = anIntArray1472[yA]; + while (--yC >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yA, xA >> 16, xB >> 16, lightnessA >> 8, lightnessB >> 8, l4, k5, j6, i5, l5, k6); + xB += xStepAC; + xA += xStepAB; + lightnessB += lightnessStepAC; + lightnessA += lightnessStepAB; + yA += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } - while (--j >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, i, l >> 16, j1 >> 16, k1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6); - j1 += k7; - l += i7; - i2 += l7; - k1 += j7; - i += Draw2D.anInt1379; + while (--yB >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yA, xA >> 16, xC >> 16, lightnessA >> 8, lightnessC >> 8, l4, k5, j6, i5, l5, k6); + xC += xStepBC; + xA += xStepAB; + lightnessC += lightnessStepBC; + lightnessA += lightnessStepAB; + yA += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } return; } - if (j <= k) { - if (j >= Draw2D.anInt1382) { + if (yB <= yC) { + if (yB >= Draw2D.bottom) { return; } - if (k > Draw2D.anInt1382) { - k = Draw2D.anInt1382; + if (yC > Draw2D.bottom) { + yC = Draw2D.bottom; } - if (i > Draw2D.anInt1382) { - i = Draw2D.anInt1382; + if (yA > Draw2D.bottom) { + yA = Draw2D.bottom; } - if (k < i) { - l = i1 <<= 16; - k1 = l1 <<= 16; - if (j < 0) { - l -= i7 * j; - i1 -= k7 * j; - k1 -= j7 * j; - l1 -= l7 * j; - j = 0; + if (yC < yA) { + xA = xB <<= 16; + lightnessA = lightnessB <<= 16; + if (yB < 0) { + xA -= xStepAB * yB; + xB -= xStepBC * yB; + lightnessA -= lightnessStepAB * yB; + lightnessB -= lightnessStepBC * yB; + yB = 0; } - j1 <<= 16; - i2 <<= 16; - if (k < 0) { - j1 -= i8 * k; - i2 -= j8 * k; - k = 0; + xC <<= 16; + lightnessC <<= 16; + if (yC < 0) { + xC -= xStepAC * yC; + lightnessC -= lightnessStepAC * yC; + yC = 0; } - int i9 = j - anInt1467; + int i9 = yB - centerY; l4 += j5 * i9; k5 += i6 * i9; j6 += l6 * i9; - if (j != k && i7 < k7 || j == k && i7 > i8) { - i -= k; - k -= j; - j = anIntArray1472[j]; - while (--k >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, j, l >> 16, i1 >> 16, k1 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6); - l += i7; - i1 += k7; - k1 += j7; - l1 += l7; - j += Draw2D.anInt1379; + if (yB != yC && xStepAB < xStepBC || yB == yC && xStepAB > xStepAC) { + yA -= yC; + yC -= yB; + yB = anIntArray1472[yB]; + while (--yC >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yB, xA >> 16, xB >> 16, lightnessA >> 8, lightnessB >> 8, l4, k5, j6, i5, l5, k6); + xA += xStepAB; + xB += xStepBC; + lightnessA += lightnessStepAB; + lightnessB += lightnessStepBC; + yB += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } - while (--i >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, j, l >> 16, j1 >> 16, k1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6); - l += i7; - j1 += i8; - k1 += j7; - i2 += j8; - j += Draw2D.anInt1379; + while (--yA >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yB, xA >> 16, xC >> 16, lightnessA >> 8, lightnessC >> 8, l4, k5, j6, i5, l5, k6); + xA += xStepAB; + xC += xStepAC; + lightnessA += lightnessStepAB; + lightnessC += lightnessStepAC; + yB += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } return; } - i -= k; - k -= j; - j = anIntArray1472[j]; - while (--k >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, j, i1 >> 16, l >> 16, l1 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6); - l += i7; - i1 += k7; - k1 += j7; - l1 += l7; - j += Draw2D.anInt1379; + yA -= yC; + yC -= yB; + yB = anIntArray1472[yB]; + while (--yC >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yB, xB >> 16, xA >> 16, lightnessB >> 8, lightnessA >> 8, l4, k5, j6, i5, l5, k6); + xA += xStepAB; + xB += xStepBC; + lightnessA += lightnessStepAB; + lightnessB += lightnessStepBC; + yB += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } - while (--i >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, j, j1 >> 16, l >> 16, i2 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6); - l += i7; - j1 += i8; - k1 += j7; - i2 += j8; - j += Draw2D.anInt1379; + while (--yA >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yB, xC >> 16, xA >> 16, lightnessC >> 8, lightnessA >> 8, l4, k5, j6, i5, l5, k6); + xA += xStepAB; + xC += xStepAC; + lightnessA += lightnessStepAB; + lightnessC += lightnessStepAC; + yB += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } return; } - j1 = i1 <<= 16; - i2 = l1 <<= 16; - if (j < 0) { - j1 -= i7 * j; - i1 -= k7 * j; - i2 -= j7 * j; - l1 -= l7 * j; - j = 0; + xC = xB <<= 16; + lightnessC = lightnessB <<= 16; + if (yB < 0) { + xC -= xStepAB * yB; + xB -= xStepBC * yB; + lightnessC -= lightnessStepAB * yB; + lightnessB -= lightnessStepBC * yB; + yB = 0; } - l <<= 16; - k1 <<= 16; - if (i < 0) { - l -= i8 * i; - k1 -= j8 * i; - i = 0; + xA <<= 16; + lightnessA <<= 16; + if (yA < 0) { + xA -= xStepAC * yA; + lightnessA -= lightnessStepAC * yA; + yA = 0; } - int j9 = j - anInt1467; + int j9 = yB - centerY; l4 += j5 * j9; k5 += i6 * j9; j6 += l6 * j9; - if (i7 < k7) { - k -= i; - i -= j; - j = anIntArray1472[j]; - while (--i >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, j, j1 >> 16, i1 >> 16, i2 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6); - j1 += i7; - i1 += k7; - i2 += j7; - l1 += l7; - j += Draw2D.anInt1379; + if (xStepAB < xStepBC) { + yC -= yA; + yA -= yB; + yB = anIntArray1472[yB]; + while (--yA >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yB, xC >> 16, xB >> 16, lightnessC >> 8, lightnessB >> 8, l4, k5, j6, i5, l5, k6); + xC += xStepAB; + xB += xStepBC; + lightnessC += lightnessStepAB; + lightnessB += lightnessStepBC; + yB += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } - while (--k >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, j, l >> 16, i1 >> 16, k1 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6); - l += i8; - i1 += k7; - k1 += j8; - l1 += l7; - j += Draw2D.anInt1379; + while (--yC >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yB, xA >> 16, xB >> 16, lightnessA >> 8, lightnessB >> 8, l4, k5, j6, i5, l5, k6); + xA += xStepAC; + xB += xStepBC; + lightnessA += lightnessStepAC; + lightnessB += lightnessStepBC; + yB += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } return; } - k -= i; - i -= j; - j = anIntArray1472[j]; - while (--i >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, j, i1 >> 16, j1 >> 16, l1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6); - j1 += i7; - i1 += k7; - i2 += j7; - l1 += l7; - j += Draw2D.anInt1379; + yC -= yA; + yA -= yB; + yB = anIntArray1472[yB]; + while (--yA >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yB, xB >> 16, xC >> 16, lightnessB >> 8, lightnessC >> 8, l4, k5, j6, i5, l5, k6); + xC += xStepAB; + xB += xStepBC; + lightnessC += lightnessStepAB; + lightnessB += lightnessStepBC; + yB += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } - while (--k >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, j, i1 >> 16, l >> 16, l1 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6); - l += i8; - i1 += k7; - k1 += j8; - l1 += l7; - j += Draw2D.anInt1379; + while (--yC >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yB, xB >> 16, xA >> 16, lightnessB >> 8, lightnessA >> 8, l4, k5, j6, i5, l5, k6); + xA += xStepAC; + xB += xStepBC; + lightnessA += lightnessStepAC; + lightnessB += lightnessStepBC; + yB += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } return; } - if (k >= Draw2D.anInt1382) { + if (yC >= Draw2D.bottom) { return; } - if (i > Draw2D.anInt1382) { - i = Draw2D.anInt1382; + if (yA > Draw2D.bottom) { + yA = Draw2D.bottom; } - if (j > Draw2D.anInt1382) { - j = Draw2D.anInt1382; + if (yB > Draw2D.bottom) { + yB = Draw2D.bottom; } - if (i < j) { - i1 = j1 <<= 16; - l1 = i2 <<= 16; - if (k < 0) { - i1 -= k7 * k; - j1 -= i8 * k; - l1 -= l7 * k; - i2 -= j8 * k; - k = 0; + if (yA < yB) { + xB = xC <<= 16; + lightnessB = lightnessC <<= 16; + if (yC < 0) { + xB -= xStepBC * yC; + xC -= xStepAC * yC; + lightnessB -= lightnessStepBC * yC; + lightnessC -= lightnessStepAC * yC; + yC = 0; } - l <<= 16; - k1 <<= 16; - if (i < 0) { - l -= i7 * i; - k1 -= j7 * i; - i = 0; + xA <<= 16; + lightnessA <<= 16; + if (yA < 0) { + xA -= xStepAB * yA; + lightnessA -= lightnessStepAB * yA; + yA = 0; } - int k9 = k - anInt1467; + int k9 = yC - centerY; l4 += j5 * k9; k5 += i6 * k9; j6 += l6 * k9; - if (k7 < i8) { - j -= i; - i -= k; - k = anIntArray1472[k]; - while (--i >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, k, i1 >> 16, j1 >> 16, l1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6); - i1 += k7; - j1 += i8; - l1 += l7; - i2 += j8; - k += Draw2D.anInt1379; + if (xStepBC < xStepAC) { + yB -= yA; + yA -= yC; + yC = anIntArray1472[yC]; + while (--yA >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yC, xB >> 16, xC >> 16, lightnessB >> 8, lightnessC >> 8, l4, k5, j6, i5, l5, k6); + xB += xStepBC; + xC += xStepAC; + lightnessB += lightnessStepBC; + lightnessC += lightnessStepAC; + yC += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } - while (--j >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, k, i1 >> 16, l >> 16, l1 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6); - i1 += k7; - l += i7; - l1 += l7; - k1 += j7; - k += Draw2D.anInt1379; + while (--yB >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yC, xB >> 16, xA >> 16, lightnessB >> 8, lightnessA >> 8, l4, k5, j6, i5, l5, k6); + xB += xStepBC; + xA += xStepAB; + lightnessB += lightnessStepBC; + lightnessA += lightnessStepAB; + yC += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } return; } - j -= i; - i -= k; - k = anIntArray1472[k]; - while (--i >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, k, j1 >> 16, i1 >> 16, i2 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6); - i1 += k7; - j1 += i8; - l1 += l7; - i2 += j8; - k += Draw2D.anInt1379; + yB -= yA; + yA -= yC; + yC = anIntArray1472[yC]; + while (--yA >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yC, xC >> 16, xB >> 16, lightnessC >> 8, lightnessB >> 8, l4, k5, j6, i5, l5, k6); + xB += xStepBC; + xC += xStepAC; + lightnessB += lightnessStepBC; + lightnessC += lightnessStepAC; + yC += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } - while (--j >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, k, l >> 16, i1 >> 16, k1 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6); - i1 += k7; - l += i7; - l1 += l7; - k1 += j7; - k += Draw2D.anInt1379; + while (--yB >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yC, xA >> 16, xB >> 16, lightnessA >> 8, lightnessB >> 8, l4, k5, j6, i5, l5, k6); + xB += xStepBC; + xA += xStepAB; + lightnessB += lightnessStepBC; + lightnessA += lightnessStepAB; + yC += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } return; } - l = j1 <<= 16; - k1 = i2 <<= 16; - if (k < 0) { - l -= k7 * k; - j1 -= i8 * k; - k1 -= l7 * k; - i2 -= j8 * k; - k = 0; + xA = xC <<= 16; + lightnessA = lightnessC <<= 16; + if (yC < 0) { + xA -= xStepBC * yC; + xC -= xStepAC * yC; + lightnessA -= lightnessStepBC * yC; + lightnessC -= lightnessStepAC * yC; + yC = 0; } - i1 <<= 16; - l1 <<= 16; - if (j < 0) { - i1 -= i7 * j; - l1 -= j7 * j; - j = 0; + xB <<= 16; + lightnessB <<= 16; + if (yB < 0) { + xB -= xStepAB * yB; + lightnessB -= lightnessStepAB * yB; + yB = 0; } - int l9 = k - anInt1467; + int l9 = yC - centerY; l4 += j5 * l9; k5 += i6 * l9; j6 += l6 * l9; - if (k7 < i8) { - i -= j; - j -= k; - k = anIntArray1472[k]; - while (--j >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, k, l >> 16, j1 >> 16, k1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6); - l += k7; - j1 += i8; - k1 += l7; - i2 += j8; - k += Draw2D.anInt1379; + if (xStepBC < xStepAC) { + yA -= yB; + yB -= yC; + yC = anIntArray1472[yC]; + while (--yB >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yC, xA >> 16, xC >> 16, lightnessA >> 8, lightnessC >> 8, l4, k5, j6, i5, l5, k6); + xA += xStepBC; + xC += xStepAC; + lightnessA += lightnessStepBC; + lightnessC += lightnessStepAC; + yC += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } - while (--i >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, k, i1 >> 16, j1 >> 16, l1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6); - i1 += i7; - j1 += i8; - l1 += j7; - i2 += j8; - k += Draw2D.anInt1379; + while (--yA >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yC, xB >> 16, xC >> 16, lightnessB >> 8, lightnessC >> 8, l4, k5, j6, i5, l5, k6); + xB += xStepAB; + xC += xStepAC; + lightnessB += lightnessStepAB; + lightnessC += lightnessStepAC; + yC += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } return; } - i -= j; - j -= k; - k = anIntArray1472[k]; - while (--j >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, k, j1 >> 16, l >> 16, i2 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6); - l += k7; - j1 += i8; - k1 += l7; - i2 += j8; - k += Draw2D.anInt1379; + yA -= yB; + yB -= yC; + yC = anIntArray1472[yC]; + while (--yB >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yC, xC >> 16, xA >> 16, lightnessC >> 8, lightnessA >> 8, l4, k5, j6, i5, l5, k6); + xA += xStepBC; + xC += xStepAC; + lightnessA += lightnessStepBC; + lightnessC += lightnessStepAC; + yC += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; } - while (--i >= 0) { - method379(Draw2D.anIntArray1378, ai, 0, 0, k, j1 >> 16, i1 >> 16, i2 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6); - i1 += i7; - j1 += i8; - l1 += j7; - i2 += j8; - k += Draw2D.anInt1379; + while (--yA >= 0) { + method379(Draw2D.pixels, texels, 0, 0, yC, xC >> 16, xB >> 16, lightnessC >> 8, lightnessB >> 8, l4, k5, j6, i5, l5, k6); + xB += xStepAB; + xC += xStepAC; + lightnessB += lightnessStepAB; + lightnessC += lightnessStepAC; + yC += Draw2D.width; l4 += j5; k5 += i6; j6 += l6; @@ -1653,10 +1732,10 @@ public class Draw3D extends Draw2D { } int j3; int k3; - if (aBoolean1462) { + if (clipX) { j3 = (k1 - j1) / (i1 - l); - if (i1 > Draw2D.anInt1385) { - i1 = Draw2D.anInt1385; + if (i1 > Draw2D.boundX) { + i1 = Draw2D.boundX; } if (l < 0) { j1 -= l * j3; @@ -1670,7 +1749,7 @@ public class Draw3D extends Draw2D { } else { if (i1 - l > 7) { k3 = i1 - l >> 3; - j3 = (k1 - j1) * anIntArray1468[k3] >> 6; + j3 = (k1 - j1) * recipreical15[k3] >> 6; } else { k3 = 0; j3 = 0; @@ -1681,7 +1760,7 @@ public class Draw3D extends Draw2D { if (aBoolean1461) { int i4 = 0; int k4 = 0; - int k6 = l - anInt1466; + int k6 = l - centerX; l1 += (k2 >> 3) * k6; i2 += (l2 >> 3) * k6; j2 += (i3 >> 3) * k6; @@ -1712,7 +1791,7 @@ public class Draw3D extends Draw2D { int k7 = k4 - j >> 3; i += (j1 & 0x600000) >> 3; int i8 = j1 >> 23; - if (aBoolean1463) { + if (opaque) { while (k3-- > 0) { ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8; i += i7; @@ -1846,7 +1925,7 @@ public class Draw3D extends Draw2D { } int j4 = 0; int l4 = 0; - int l6 = l - anInt1466; + int l6 = l - centerX; l1 += (k2 >> 3) * l6; i2 += (l2 >> 3) * l6; j2 += (i3 >> 3) * l6; @@ -1877,7 +1956,7 @@ public class Draw3D extends Draw2D { int l7 = l4 - j >> 3; i += j1 & 0x600000; int j8 = j1 >> 23; - if (aBoolean1463) { + if (opaque) { while (k3-- > 0) { ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8; i += j7; diff --git a/src/main/java/DrawArea.java b/src/main/java/DrawArea.java index b789949..21cd7e5 100644 --- a/src/main/java/DrawArea.java +++ b/src/main/java/DrawArea.java @@ -30,7 +30,7 @@ public class DrawArea implements ImageProducer, ImageObserver { } public void method237() { - Draw2D.method331(anInt317, anInt316, anIntArray315); + Draw2D.bind(anIntArray315, anInt316, anInt317); } public void method238(int i, Graphics g, int k) { diff --git a/src/main/java/Entity.java b/src/main/java/Entity.java index f7dfb17..b4cdd96 100644 --- a/src/main/java/Entity.java +++ b/src/main/java/Entity.java @@ -4,17 +4,17 @@ public class Entity extends DoublyLinkedListNode { - public VertexNormal[] aNormalArray1425; - public int anInt1426 = 1000; + public VertexNormal[] vertexNormal; + public int minY = 1000; public Entity() { } - public void method443(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2) { + public void draw(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2) { Model model = method444(); if (model != null) { - anInt1426 = model.anInt1426; - model.method443(i, j, k, l, i1, j1, k1, l1, i2); + minY = model.minY; + model.draw(i, j, k, l, i1, j1, k1, l1, i2); } } diff --git a/src/main/java/FileArchive.java b/src/main/java/FileArchive.java index fa7dafe..d8ba3a4 100644 --- a/src/main/java/FileArchive.java +++ b/src/main/java/FileArchive.java @@ -35,7 +35,7 @@ public class FileArchive { anIntArray729 = new int[anInt727]; anIntArray730 = new int[anInt727]; anIntArray731 = new int[anInt727]; - int k = buffer.anInt1406 + anInt727 * 10; + int k = buffer.position + anInt727 * 10; for (int l = 0; l < anInt727; l++) { anIntArray728[l] = buffer.method413(); anIntArray729[l] = buffer.method412(); diff --git a/src/main/java/Game.java b/src/main/java/Game.java index fb7cdb2..e90160a 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -569,8 +569,8 @@ public class Game extends GameShell { method13(60, "Connecting to update server"); aOnDemand_1068 = new OnDemand(); aOnDemand_1068.method551(archive_6, this); - SeqTransform.method528(aOnDemand_1068.method557()); - Model.method459(aOnDemand_1068.method555(0), aOnDemand_1068); + SeqFrame.init(aOnDemand_1068.method557()); + Model.init(aOnDemand_1068.method555(0), aOnDemand_1068); if (!aBoolean960) { anInt1227 = 0; try { @@ -876,7 +876,7 @@ public class Game extends GameShell { for (int i8 = 0; i8 < 9; i8++) { int k8 = 128 + i8 * 32 + 15; int l8 = 600 + k8 * 3; - int i9 = Draw3D.anIntArray1470[k8]; + int i9 = Draw3D.sin[k8]; ai[i8] = l8 * i9 >> 16; } SceneGraph.method310(500, 800, 512, 334, ai); @@ -1034,8 +1034,8 @@ public class Game extends GameShell { PlayerEntity.aCache_1704 = null; Draw3D.method363(); SceneGraph.method273(); - Model.method458(); - SeqTransform.method530(); + Model.clear(); + SeqFrame.clear(); System.gc(); } @@ -1098,10 +1098,10 @@ public class Game extends GameShell { byte byte1 = 20; aFont_1272.method381(0xffffff, "RuneScape is loading - please wait...", c1 / 2 - 26 - byte1, c / 2); int j = c1 / 2 - 18 - byte1; - Draw2D.method337(c / 2 - 152, 304, 34, 0x8c1111, j); - Draw2D.method337(c / 2 - 151, 302, 32, 0, j + 1); - Draw2D.method336(30, j + 2, c / 2 - 150, 0x8c1111, i * 3); - Draw2D.method336(30, j + 2, (c / 2 - 150) + i * 3, 0, 300 - i * 3); + Draw2D.drawRect(c / 2 - 152, j, 304, 34, 0x8c1111); + Draw2D.drawRect(c / 2 - 151, j + 1, 302, 32, 0); + Draw2D.fillRect(c / 2 - 150, j + 2, i * 3, 30, 0x8c1111); + Draw2D.fillRect((c / 2 - 150) + i * 3, j + 2, 300 - i * 3, 30, 0); aFont_1272.method381(0xffffff, s, (c1 / 2 + 5) - byte1, c / 2); aArea_1109.method238(171, super.aGraphics12, 202); if (aBoolean1255) { @@ -1321,7 +1321,7 @@ public class Game extends GameShell { } else { BitmapFont font = aFont_1271; int j = 0; - Draw2D.method333(77, 0, 463, 0); + Draw2D.setBounds(77, 0, 463, 0); for (int k = 0; k < 100; k++) { if (aStringArray944[k] != null) { int l = anIntArray942[k]; @@ -1405,7 +1405,7 @@ public class Game extends GameShell { } } } - Draw2D.method332(); + Draw2D.resetBounds(); anInt1211 = j * 14 + 7; if (anInt1211 < 78) { anInt1211 = 78; @@ -1419,7 +1419,7 @@ public class Game extends GameShell { } font.method385(0, s + ":", 90, 4); font.method385(255, aString887 + "*", 90, 6 + font.method383(s + ": ")); - Draw2D.method339(77, 0, 479, 0); + Draw2D.drawLineX(0, 77, 479, 0); } if (aBoolean885 && anInt948 == 2) { method40(); @@ -1684,7 +1684,7 @@ public class Game extends GameShell { for (int i1 = 0; i1 < j; i1++) { int l1 = aOnDemand_1068.method559(i1); if ((l1 & 0x79) == 0) { - Model.method461(i1); + Model.unload(i1); } } } @@ -2083,21 +2083,21 @@ public class Game extends GameShell { public void method30(int j, int k, int l, int i1, int j1) { aImage_1024.method361(i1, l); aImage_1025.method361(i1, (l + j) - 16); - Draw2D.method336(j - 32, l + 16, i1, anInt1002, 16); + Draw2D.fillRect(i1, l + 16, 16, j - 32, anInt1002); int k1 = ((j - 32) * j) / j1; if (k1 < 8) { k1 = 8; } int l1 = ((j - 32 - k1) * k) / (j1 - j); - Draw2D.method336(k1, l + 16 + l1, i1, anInt1063, 16); - Draw2D.method341(l + 16 + l1, anInt902, k1, i1); - Draw2D.method341(l + 16 + l1, anInt902, k1, i1 + 1); - Draw2D.method339(l + 16 + l1, anInt902, 16, i1); - Draw2D.method339(l + 17 + l1, anInt902, 16, i1); - Draw2D.method341(l + 16 + l1, anInt927, k1, i1 + 15); - Draw2D.method341(l + 17 + l1, anInt927, k1 - 1, i1 + 14); - Draw2D.method339(l + 15 + l1 + k1, anInt927, 16, i1); - Draw2D.method339(l + 14 + l1 + k1, anInt927, 15, i1 + 1); + Draw2D.fillRect(i1, l + 16 + l1, 16, k1, anInt1063); + Draw2D.drawLineY(l + 16 + l1, anInt902, k1, i1); + Draw2D.drawLineY(l + 16 + l1, anInt902, k1, i1 + 1); + Draw2D.drawLineX(i1, l + 16 + l1, 16, anInt902); + Draw2D.drawLineX(i1, l + 17 + l1, 16, anInt902); + Draw2D.drawLineY(l + 16 + l1, anInt927, k1, i1 + 15); + Draw2D.drawLineY(l + 17 + l1, anInt927, k1 - 1, i1 + 14); + Draw2D.drawLineX(i1, l + 15 + l1 + k1, 16, anInt927); + Draw2D.drawLineX(i1 + 1, l + 14 + l1 + k1, 15, anInt927); } public void method31(Buffer buffer, int i) { @@ -2113,8 +2113,8 @@ public class Game extends GameShell { aNpcArray835[l] = null; } } - if (buffer.anInt1406 != i) { - Signlink.reporterror(aString1173 + " size mismatch in getnpcpos - pos:" + buffer.anInt1406 + " psize:" + i); + if (buffer.position != i) { + Signlink.reporterror(aString1173 + " size mismatch in getnpcpos - pos:" + buffer.position + " psize:" + i); throw new RuntimeException("eek"); } for (int i1 = 0; i1 < anInt836; i1++) { @@ -2351,8 +2351,8 @@ public class Game extends GameShell { if (i1 > 30) { i1 = 30; } - Draw2D.method336(5, anInt964 - 3, anInt963 - 15, 65280, i1); - Draw2D.method336(5, anInt964 - 3, (anInt963 - 15) + i1, 0xff0000, 30 - i1); + Draw2D.fillRect(anInt963 - 15, anInt964 - 3, i1, 5, 65280); + Draw2D.fillRect((anInt963 - 15) + i1, anInt964 - 3, 30 - i1, 5, 0xff0000); } } for (int j1 = 0; j1 < 4; j1++) { @@ -2458,10 +2458,10 @@ public class Game extends GameShell { if (anIntArray981[k] == 4) { int i4 = aFont_1272.method384(s); int k4 = ((150 - anIntArray982[k]) * (i4 + 100)) / 150; - Draw2D.method333(334, anInt963 - 50, anInt963 + 50, 0); + Draw2D.setBounds(334, anInt963 - 50, anInt963 + 50, 0); aFont_1272.method385(0, s, anInt964 + 1, (anInt963 + 50) - k4); aFont_1272.method385(i3, s, anInt964, (anInt963 + 50) - k4); - Draw2D.method332(); + Draw2D.resetBounds(); } if (anIntArray981[k] == 5) { int j4 = 150 - anIntArray982[k]; @@ -2471,10 +2471,10 @@ public class Game extends GameShell { } else if (j4 > 125) { l4 = j4 - 125; } - Draw2D.method333(anInt964 + 5, 0, 512, anInt964 - aFont_1272.anInt1497 - 1); + Draw2D.setBounds(anInt964 + 5, 0, 512, anInt964 - aFont_1272.anInt1497 - 1); aFont_1272.method381(0, s, anInt964 + 1 + l4, anInt963); aFont_1272.method381(i3, s, anInt964 + l4, anInt963); - Draw2D.method332(); + Draw2D.resetBounds(); } } else { aFont_1272.method381(0, s, anInt964 + 1, anInt963); @@ -2693,9 +2693,9 @@ public class Game extends GameShell { int k = anInt951; int l = anInt952; int i1 = 0x5d5447; - Draw2D.method336(l, j, i, i1, k); - Draw2D.method336(16, j + 1, i + 1, 0, k - 2); - Draw2D.method337(i + 1, k - 2, l - 19, 0, j + 18); + Draw2D.fillRect(i, j, k, l, i1); + Draw2D.fillRect(i + 1, j + 1, k - 2, 16, 0); + Draw2D.drawRect(i + 1, j + 18, k - 2, l - 19, 0); aFont_1272.method385(i1, "Choose Option", j + 14, i + 3); int j1 = super.anInt20; int k1 = super.anInt21; @@ -3366,7 +3366,7 @@ public class Game extends GameShell { return; } if (request.anInt1419 == 0) { - Model.method460(request.aByteArray1420, request.anInt1421); + Model.load(request.aByteArray1420, request.anInt1421); if ((aOnDemand_1068.method559(request.anInt1421) & 0x62) != 0) { aBoolean1153 = true; if (anInt1276 != -1) { @@ -3375,7 +3375,7 @@ public class Game extends GameShell { } } if (request.anInt1419 == 1 && request.aByteArray1420 != null) { - SeqTransform.method529(request.aByteArray1420); + SeqFrame.readAnimation(request.aByteArray1420); } if (request.anInt1419 == 2 && request.anInt1421 == anInt1227 && request.aByteArray1420 != null) { method21(aBoolean1228, request.aByteArray1420); @@ -3514,10 +3514,10 @@ public class Game extends GameShell { if (super.anInt26 != 0 || aMouseRecorder_879.anInt810 >= 40) { aBuffer_1192.method397(45); aBuffer_1192.method398(0); - int j2 = aBuffer_1192.anInt1406; + int j2 = aBuffer_1192.position; int j3 = 0; for (int j4 = 0; j4 < aMouseRecorder_879.anInt810; j4++) { - if (j2 - aBuffer_1192.anInt1406 >= 240) { + if (j2 - aBuffer_1192.position >= 240) { break; } j3++; @@ -3562,7 +3562,7 @@ public class Game extends GameShell { } } } - aBuffer_1192.method407(aBuffer_1192.anInt1406 - j2); + aBuffer_1192.method407(aBuffer_1192.position - j2); if (j3 >= aMouseRecorder_879.anInt810) { aMouseRecorder_879.anInt810 = 0; } else { @@ -3762,9 +3762,9 @@ public class Game extends GameShell { aBuffer_1192.method397(0); } try { - if (aConnection_1168 != null && aBuffer_1192.anInt1406 > 0) { - aConnection_1168.method271(aBuffer_1192.anInt1406, aBuffer_1192.aByteArray1405, 0); - aBuffer_1192.anInt1406 = 0; + if (aConnection_1168 != null && aBuffer_1192.position > 0) { + aConnection_1168.method271(aBuffer_1192.position, aBuffer_1192.aByteArray1405, 0); + aBuffer_1192.position = 0; anInt1010 = 0; } } catch (IOException _ex) { @@ -3798,23 +3798,23 @@ public class Game extends GameShell { aArea_1124 = null; aArea_1125 = null; aArea_1110 = new DrawArea(128, 265, method11()); - Draw2D.method334(); + Draw2D.clear(); aArea_1111 = new DrawArea(128, 265, method11()); - Draw2D.method334(); + Draw2D.clear(); aArea_1107 = new DrawArea(509, 171, method11()); - Draw2D.method334(); + Draw2D.clear(); aArea_1108 = new DrawArea(360, 132, method11()); - Draw2D.method334(); + Draw2D.clear(); aArea_1109 = new DrawArea(360, 200, method11()); - Draw2D.method334(); + Draw2D.clear(); aArea_1112 = new DrawArea(202, 238, method11()); - Draw2D.method334(); + Draw2D.clear(); aArea_1113 = new DrawArea(203, 238, method11()); - Draw2D.method334(); + Draw2D.clear(); aArea_1114 = new DrawArea(74, 94, method11()); - Draw2D.method334(); + Draw2D.clear(); aArea_1115 = new DrawArea(75, 94, method11()); - Draw2D.method334(); + Draw2D.clear(); if (aArchive_1053 != null) { method56(); method51(); @@ -3918,7 +3918,7 @@ public class Game extends GameShell { byte[] abyte1 = new byte[6]; datainputstream.readFully(abyte1, 0, 6); Buffer buffer = new Buffer(abyte1); - buffer.anInt1406 = 3; + buffer.position = 3; int i2 = buffer.method412() + 6; int j2 = 6; abyte0 = new byte[i2]; @@ -4829,8 +4829,8 @@ public class Game extends GameShell { anInt1133++; } int j = -1; - for (int k = 0; k < Model.anInt1687; k++) { - int l = Model.anIntArray1688[k]; + for (int k = 0; k < Model.pickedCount; k++) { + int l = Model.pickedBitsets[k]; int i1 = l & 0x7f; int j1 = l >> 7 & 0x7f; int k1 = l >> 29 & 3; @@ -5053,10 +5053,10 @@ public class Game extends GameShell { if (anInt1064 == 3 && aString1212.length() > 0) { aBuffer_1192.method397(126); aBuffer_1192.method398(0); - int k = aBuffer_1192.anInt1406; + int k = aBuffer_1192.position; aBuffer_1192.method404(aLong953); Huffman.method526(aString1212, aBuffer_1192); - aBuffer_1192.method407(aBuffer_1192.anInt1406 - k); + aBuffer_1192.method407(aBuffer_1192.position - k); aString1212 = Huffman.method527(aString1212); aString1212 = Censor.method497(aString1212, 0); method77(aString1212, 6, Base37.method587(Base37.method584(aLong953))); @@ -5219,13 +5219,13 @@ public class Game extends GameShell { } aBuffer_1192.method397(4); aBuffer_1192.method398(0); - int j3 = aBuffer_1192.anInt1406; + int j3 = aBuffer_1192.position; aBuffer_1192.method425(i3); aBuffer_1192.method425(j2); - aBuffer_834.anInt1406 = 0; + aBuffer_834.position = 0; Huffman.method526(aString887, aBuffer_834); - aBuffer_1192.method441(0, aBuffer_834.aByteArray1405, aBuffer_834.anInt1406); - aBuffer_1192.method407(aBuffer_1192.anInt1406 - j3); + aBuffer_1192.method441(0, aBuffer_834.aByteArray1405, aBuffer_834.position); + aBuffer_1192.method407(aBuffer_1192.position - j3); aString887 = Huffman.method527(aString887); aString887 = Censor.method497(aString887, 0); aPlayer_1126.aString1506 = aString887; @@ -5455,15 +5455,15 @@ public class Game extends GameShell { Model model = new Model(i2, aclass30_sub2_sub4_sub6); for (int l2 = 0; l2 < 5; l2++) { if (anIntArray990[l2] != 0) { - model.method476(anIntArrayArray1003[l2][0], anIntArrayArray1003[l2][anIntArray990[l2]]); + model.replaceColor(anIntArrayArray1003[l2][0], anIntArrayArray1003[l2][anIntArray990[l2]]); if (l2 == 1) { - model.method476(anIntArray1204[0], anIntArray1204[anIntArray990[l2]]); + model.replaceColor(anIntArray1204[0], anIntArray1204[anIntArray990[l2]]); } } } - model.method469(); - model.method470(SeqType.aTypeArray351[aPlayer_1126.anInt1511].anIntArray353[0]); - model.method479(64, 850, -30, -50, -30, true); + model.createLabelReferences(); + model.applySequenceFrame(SeqType.aTypeArray351[aPlayer_1126.anInt1511].anIntArray353[0]); + model.calculateNormals(64, 850, -30, -50, -30, true); component.anInt233 = 5; component.anInt234 = 0; Component.method208(0, 5, model); @@ -5767,11 +5767,11 @@ public class Game extends GameShell { aArea_1115 = null; aArea_1166 = new DrawArea(479, 96, method11()); aArea_1164 = new DrawArea(172, 156, method11()); - Draw2D.method334(); + Draw2D.clear(); aImage_1197.method361(0, 0); aArea_1163 = new DrawArea(190, 261, method11()); aArea_1165 = new DrawArea(512, 334, method11()); - Draw2D.method334(); + Draw2D.clear(); aArea_1123 = new DrawArea(496, 50, method11()); aArea_1124 = new DrawArea(269, 37, method11()); aArea_1125 = new DrawArea(249, 45, method11()); @@ -5793,8 +5793,8 @@ public class Game extends GameShell { int l = k * k + j * j; if (l > 4225 && l < 90000) { int i1 = anInt1185 + anInt1209 & 0x7ff; - int j1 = Model.anIntArray1689[i1]; - int k1 = Model.anIntArray1690[i1]; + int j1 = Model.sin[i1]; + int k1 = Model.cos[i1]; j1 = (j1 * 256) / (anInt1170 + 256); k1 = (k1 * 256) / (anInt1170 + 256); int l1 = j * j1 + k * k1 >> 16; @@ -5892,7 +5892,7 @@ public class Game extends GameShell { aConnection_1168 = new Connection(this, method19(43594 + anInt958)); long l = Base37.method583(s); int i = (int) (l >> 16 & 31L); - aBuffer_1192.anInt1406 = 0; + aBuffer_1192.position = 0; aBuffer_1192.method398(14); aBuffer_1192.method398(i); aConnection_1168.method271(2, aBuffer_1192.aByteArray1405, 0); @@ -5903,14 +5903,14 @@ public class Game extends GameShell { int i1 = k; if (k == 0) { aConnection_1168.method270(aBuffer_1083.aByteArray1405, 0, 8); - aBuffer_1083.anInt1406 = 0; + aBuffer_1083.position = 0; aLong1215 = aBuffer_1083.method414(); int[] ai = new int[4]; ai[0] = (int) (Math.random() * 99999999D); ai[1] = (int) (Math.random() * 99999999D); ai[2] = (int) (aLong1215 >> 32); ai[3] = (int) aLong1215; - aBuffer_1192.anInt1406 = 0; + aBuffer_1192.position = 0; aBuffer_1192.method398(10); aBuffer_1192.method402(ai[0]); aBuffer_1192.method402(ai[1]); @@ -5920,26 +5920,26 @@ public class Game extends GameShell { aBuffer_1192.method405(s); aBuffer_1192.method405(s1); aBuffer_1192.method423(aBigInteger1032, aBigInteger856); - aBuffer_847.anInt1406 = 0; + aBuffer_847.position = 0; if (flag) { aBuffer_847.method398(18); } else { aBuffer_847.method398(16); } - aBuffer_847.method398(aBuffer_1192.anInt1406 + 36 + 1 + 1 + 2); + aBuffer_847.method398(aBuffer_1192.position + 36 + 1 + 1 + 2); aBuffer_847.method398(255); aBuffer_847.method399(317); aBuffer_847.method398(aBoolean960 ? 1 : 0); for (int l1 = 0; l1 < 9; l1++) { aBuffer_847.method402(anIntArray1090[l1]); } - aBuffer_847.method406(aBuffer_1192.aByteArray1405, aBuffer_1192.anInt1406, 0); + aBuffer_847.method406(aBuffer_1192.aByteArray1405, aBuffer_1192.position, 0); aBuffer_1192.aISAACCipher_1410 = new ISAACCipher(ai); for (int j2 = 0; j2 < 4; j2++) { ai[j2] += 50; } aISAACCipher_1000 = new ISAACCipher(ai); - aConnection_1168.method271(aBuffer_847.anInt1406, aBuffer_847.aByteArray1405, 0); + aConnection_1168.method271(aBuffer_847.position, aBuffer_847.aByteArray1405, 0); k = aConnection_1168.method268(); } if (k == 1) { @@ -5959,8 +5959,8 @@ public class Game extends GameShell { super.aBoolean17 = true; aBoolean954 = true; aBoolean1157 = true; - aBuffer_1192.anInt1406 = 0; - aBuffer_1083.anInt1406 = 0; + aBuffer_1192.position = 0; + aBuffer_1083.position = 0; anInt1008 = -1; anInt841 = -1; anInt842 = -1; @@ -6099,8 +6099,8 @@ public class Game extends GameShell { } if (k == 15) { aBoolean1157 = true; - aBuffer_1192.anInt1406 = 0; - aBuffer_1083.anInt1406 = 0; + aBuffer_1192.position = 0; + aBuffer_1083.position = 0; anInt1008 = -1; anInt841 = -1; anInt842 = -1; @@ -6658,10 +6658,10 @@ public class Game extends GameShell { } } else { Buffer buffer = SoundTrack.method241(anIntArray1241[i], anIntArray1207[i]); - if (System.currentTimeMillis() + (long) (buffer.anInt1406 / 22) > aLong1172 + (long) (anInt1257 / 22)) { - anInt1257 = buffer.anInt1406; + if (System.currentTimeMillis() + (long) (buffer.position / 22) > aLong1172 + (long) (anInt1257 / 22)) { + anInt1257 = buffer.position; aLong1172 = System.currentTimeMillis(); - if (method59(buffer.aByteArray1405, buffer.anInt1406)) { + if (method59(buffer.aByteArray1405, buffer.position)) { anInt874 = anIntArray1207[i]; anInt1289 = anIntArray1241[i]; } else { @@ -6743,8 +6743,8 @@ public class Game extends GameShell { i -= 73; j -= 75; int k = anInt1185 + anInt1209 & 0x7ff; - int i1 = Draw3D.anIntArray1470[k]; - int j1 = Draw3D.anIntArray1471[k]; + int i1 = Draw3D.sin[k]; + int j1 = Draw3D.cos[k]; i1 = i1 * (anInt1170 + 256) >> 8; j1 = j1 * (anInt1170 + 256) >> 8; int k1 = j * i1 + i * j1 >> 11; @@ -7432,11 +7432,11 @@ public class Game extends GameShell { if (component.aBoolean266 && anInt1026 != component.anInt250 && anInt1048 != component.anInt250 && anInt1039 != component.anInt250) { return; } - int i1 = Draw2D.anInt1383; - int j1 = Draw2D.anInt1381; - int k1 = Draw2D.anInt1384; - int l1 = Draw2D.anInt1382; - Draw2D.method333(l + component.anInt267, k, k + component.anInt220, l); + int i1 = Draw2D.left; + int j1 = Draw2D.top; + int k1 = Draw2D.right; + int l1 = Draw2D.bottom; + Draw2D.setBounds(l + component.anInt267, k, k + component.anInt220, l); int i2 = component.anIntArray240.length; for (int j2 = 0; j2 < i2; j2++) { int k2 = component.anIntArray241[j2] + k; @@ -7473,7 +7473,7 @@ public class Game extends GameShell { int k6 = 0; int j7 = 0; int j9 = component_1.anIntArray253[i3] - 1; - if (k5 > Draw2D.anInt1383 - 32 && k5 < Draw2D.anInt1384 && j6 > Draw2D.anInt1381 - 32 && j6 < Draw2D.anInt1382 || anInt1086 != 0 && anInt1085 == i3) { + if (k5 > Draw2D.left - 32 && k5 < Draw2D.right && j6 > Draw2D.top - 32 && j6 < Draw2D.bottom || anInt1086 != 0 && anInt1085 == i3) { int l9 = 0; if (anInt1282 == 1 && anInt1283 == i3 && anInt1284 == component_1.anInt250) { l9 = 0xffffff; @@ -7494,8 +7494,8 @@ public class Game extends GameShell { j7 = 0; } class30_sub2_sub1_sub1_2.method350(k5 + k6, j6 + j7, 128); - if (j6 + j7 < Draw2D.anInt1381 && component.anInt224 > 0) { - int i10 = (anInt945 * (Draw2D.anInt1381 - j6 - j7)) / 3; + if (j6 + j7 < Draw2D.top && component.anInt224 > 0) { + int i10 = (anInt945 * (Draw2D.top - j6 - j7)) / 3; if (i10 > anInt945 * 10) { i10 = anInt945 * 10; } @@ -7505,8 +7505,8 @@ public class Game extends GameShell { component.anInt224 -= i10; anInt1088 += i10; } - if (j6 + j7 + 32 > Draw2D.anInt1382 && component.anInt224 < component.anInt261 - component.anInt267) { - int j10 = (anInt945 * ((j6 + j7 + 32) - Draw2D.anInt1382)) / 3; + if (j6 + j7 + 32 > Draw2D.bottom && component.anInt224 < component.anInt261 - component.anInt267) { + int j10 = (anInt945 * ((j6 + j7 + 32) - Draw2D.bottom)) / 3; if (j10 > anInt945 * 10) { j10 = anInt945 * 10; } @@ -7556,14 +7556,14 @@ public class Game extends GameShell { } if (component_1.aByte254 == 0) { if (component_1.aBoolean227) { - Draw2D.method336(component_1.anInt267, l2, k2, j3, component_1.anInt220); + Draw2D.fillRect(k2, l2, component_1.anInt220, component_1.anInt267, j3); } else { - Draw2D.method337(k2, component_1.anInt220, component_1.anInt267, j3, l2); + Draw2D.drawRect(k2, l2, component_1.anInt220, component_1.anInt267, j3); } } else if (component_1.aBoolean227) { - Draw2D.method335(j3, l2, component_1.anInt220, component_1.anInt267, 256 - (component_1.aByte254 & 0xff), k2); + Draw2D.fillRect(k2, l2, component_1.anInt220, component_1.anInt267, j3, 256 - (component_1.aByte254 & 0xff)); } else { - Draw2D.method338(l2, component_1.anInt267, 256 - (component_1.aByte254 & 0xff), j3, component_1.anInt220, k2); + Draw2D.drawRect(k2, l2, component_1.anInt220, component_1.anInt267, j3, 256 - (component_1.aByte254 & 0xff)); } } else if (component_1.anInt262 == 4) { BitmapFont font = component_1.aFont_243; @@ -7591,7 +7591,7 @@ public class Game extends GameShell { s = "Please wait..."; i4 = component_1.anInt232; } - if (Draw2D.anInt1379 == 479) { + if (Draw2D.width == 479) { if (i4 == 0xffff00) { i4 = 255; } @@ -7663,12 +7663,12 @@ public class Game extends GameShell { image.method348(k2, l2); } } else if (component_1.anInt262 == 6) { - int k3 = Draw3D.anInt1466; - int j4 = Draw3D.anInt1467; - Draw3D.anInt1466 = k2 + component_1.anInt220 / 2; - Draw3D.anInt1467 = l2 + component_1.anInt267 / 2; - int i5 = Draw3D.anIntArray1470[component_1.anInt270] * component_1.anInt269 >> 16; - int l5 = Draw3D.anIntArray1471[component_1.anInt270] * component_1.anInt269 >> 16; + int k3 = Draw3D.centerX; + int j4 = Draw3D.centerY; + Draw3D.centerX = k2 + component_1.anInt220 / 2; + Draw3D.centerY = l2 + component_1.anInt267 / 2; + int i5 = Draw3D.sin[component_1.anInt270] * component_1.anInt269 >> 16; + int l5 = Draw3D.cos[component_1.anInt270] * component_1.anInt269 >> 16; boolean flag2 = method131(component_1); int i7; if (flag2) { @@ -7684,10 +7684,10 @@ public class Game extends GameShell { model = component_1.method209(type.anIntArray354[component_1.anInt246], type.anIntArray353[component_1.anInt246], flag2); } if (model != null) { - model.method482(0, component_1.anInt271, 0, component_1.anInt270, 0, i5, l5); + model.drawSimple(0, component_1.anInt271, 0, component_1.anInt270, 0, i5, l5); } - Draw3D.anInt1466 = k3; - Draw3D.anInt1467 = j4; + Draw3D.centerX = k3; + Draw3D.centerY = j4; } else if (component_1.anInt262 == 7) { BitmapFont class30_sub2_sub1_sub4_1 = component_1.aFont_243; int k4 = 0; @@ -7713,7 +7713,7 @@ public class Game extends GameShell { } } } - Draw2D.method333(l1, i1, k1, j1); + Draw2D.setBounds(l1, i1, k1, j1); } public void method106(Image8 image) { @@ -7816,7 +7816,7 @@ public class Game extends GameShell { int i1 = buffer.method434(); int j2 = buffer.method408(); int j3 = buffer.method427(); - int k3 = buffer.anInt1406; + int k3 = buffer.position; if (player.aString1703 != null && player.aBoolean1710) { long l3 = Base37.method583(player.aString1703); boolean flag = false; @@ -7831,9 +7831,9 @@ public class Game extends GameShell { } if (!flag && anInt1251 == 0) { try { - aBuffer_834.anInt1406 = 0; + aBuffer_834.position = 0; buffer.method442(j3, 0, aBuffer_834.aByteArray1405); - aBuffer_834.anInt1406 = 0; + aBuffer_834.position = 0; String s = Huffman.method525(j3, aBuffer_834); s = Censor.method497(s, 0); player.aString1506 = s; @@ -7852,7 +7852,7 @@ public class Game extends GameShell { } } } - buffer.anInt1406 = k3 + j3; + buffer.position = k3 + j3; } if ((i & 1) != 0) { player.anInt1502 = buffer.method434(); @@ -8544,7 +8544,7 @@ public class Game extends GameShell { aArea_1164.method237(); if (anInt1021 == 2) { byte[] abyte0 = aImage_1197.aByteArray1450; - int[] ai = Draw2D.anIntArray1378; + int[] ai = Draw2D.pixels; int k2 = abyte0.length; for (int i5 = 0; i5 < k2; i5++) { if (abyte0[i5] == 0) { @@ -8644,7 +8644,7 @@ public class Game extends GameShell { int l4 = (anInt1262 * 4 + 2) - aPlayer_1126.anInt1551 / 32; method141(aImage_870, j2, l4); } - Draw2D.method336(3, 78, 97, 0xffffff, 3); + Draw2D.fillRect(97, 78, 3, 3, 0xffffff); aArea_1165.method237(); } @@ -8662,10 +8662,10 @@ public class Game extends GameShell { i -= anInt858; i1 -= anInt859; l -= anInt860; - int j1 = Model.anIntArray1689[anInt861]; - int k1 = Model.anIntArray1690[anInt861]; - int l1 = Model.anIntArray1689[anInt862]; - int i2 = Model.anIntArray1690[anInt862]; + int j1 = Model.sin[anInt861]; + int k1 = Model.cos[anInt861]; + int l1 = Model.sin[anInt862]; + int i2 = Model.cos[anInt862]; int j2 = l * l1 + i * i2 >> 16; l = l * i2 - i * l1 >> 16; i = j2; @@ -8673,8 +8673,8 @@ public class Game extends GameShell { l = i1 * j1 + l * k1 >> 16; i1 = j2; if (l >= 50) { - anInt963 = Draw3D.anInt1466 + (i << 9) / l; - anInt964 = Draw3D.anInt1467 + (i1 << 9) / l; + anInt963 = Draw3D.centerX + (i << 9) / l; + anInt964 = Draw3D.centerY + (i1 << 9) / l; } else { anInt963 = -1; anInt964 = -1; @@ -9471,8 +9471,8 @@ public class Game extends GameShell { if (l > 6400) { return; } - int i1 = Model.anIntArray1689[k]; - int j1 = Model.anIntArray1690[k]; + int i1 = Model.sin[k]; + int j1 = Model.cos[k]; i1 = (i1 * 256) / (anInt1170 + 256); j1 = (j1 * 256) / (anInt1170 + 256); int k1 = j * i1 + i * j1 >> 16; @@ -9559,8 +9559,8 @@ public class Game extends GameShell { aPlayerArray890[l] = null; } } - if (buffer.anInt1406 != i) { - Signlink.reporterror("Error packet size mismatch in getplayer pos:" + buffer.anInt1406 + " psize:" + i); + if (buffer.position != i) { + Signlink.reporterror("Error packet size mismatch in getplayer pos:" + buffer.position + " psize:" + i); throw new RuntimeException("eek"); } for (int i1 = 0; i1 < anInt891; i1++) { @@ -9578,15 +9578,15 @@ public class Game extends GameShell { int k2 = 0; int l2 = j; if (l1 != 0) { - int i3 = Model.anIntArray1689[l1]; - int k3 = Model.anIntArray1690[l1]; + int i3 = Model.sin[l1]; + int k3 = Model.cos[l1]; int i4 = k2 * k3 - l2 * i3 >> 16; l2 = k2 * i3 + l2 * k3 >> 16; k2 = i4; } if (i2 != 0) { - int j3 = Model.anIntArray1689[i2]; - int l3 = Model.anIntArray1690[i2]; + int j3 = Model.sin[i2]; + int l3 = Model.cos[i2]; int j4 = l2 * j3 + j2 * l3 >> 16; l2 = l2 * l3 - j2 * j3 >> 16; j2 = j4; @@ -9628,7 +9628,7 @@ public class Game extends GameShell { if (anInt1007 == -2) { if (i > 1) { aConnection_1168.method270(aBuffer_1083.aByteArray1405, 0, 2); - aBuffer_1083.anInt1406 = 0; + aBuffer_1083.position = 0; anInt1007 = aBuffer_1083.method410(); i -= 2; } else { @@ -9638,7 +9638,7 @@ public class Game extends GameShell { if (i < anInt1007) { return false; } - aBuffer_1083.anInt1406 = 0; + aBuffer_1083.position = 0; aConnection_1168.method270(aBuffer_1083.aByteArray1405, 0, anInt1007); anInt1009 = 0; anInt843 = anInt842; @@ -10039,7 +10039,7 @@ public class Game extends GameShell { if (anInt1008 == 60) { anInt1269 = aBuffer_1083.method408(); anInt1268 = aBuffer_1083.method427(); - while (aBuffer_1083.anInt1406 < anInt1007) { + while (aBuffer_1083.position < anInt1007) { int k3 = aBuffer_1083.method408(); method137(aBuffer_1083, k3); } @@ -10639,7 +10639,7 @@ public class Game extends GameShell { aBoolean1153 = true; int i9 = aBuffer_1083.method410(); Component component_2 = Component.aComponentArray210[i9]; - while (aBuffer_1083.anInt1406 < anInt1007) { + while (aBuffer_1083.position < anInt1007) { int j20 = aBuffer_1083.method422(); int i23 = aBuffer_1083.method410(); int l25 = aBuffer_1083.method408(); @@ -10754,12 +10754,12 @@ public class Game extends GameShell { } } int k2 = Draw3D.anInt1481; - Model.aBoolean1684 = true; - Model.anInt1687 = 0; - Model.anInt1685 = super.anInt20 - 4; - Model.anInt1686 = super.anInt21 - 4; - Draw2D.method334(); - aGraph_946.method313(anInt858, anInt860, anInt862, anInt859, j, anInt861, false); + Model.checkHover = true; + Model.pickedCount = 0; + Model.mouseX = super.anInt20 - 4; + Model.mouseY = super.anInt21 - 4; + Draw2D.clear(); + aGraph_946.method313(anInt858, anInt860, anInt862, anInt859, j, anInt861); aGraph_946.method288(); method34(); method61(); diff --git a/src/main/java/Huffman.java b/src/main/java/Huffman.java index eafd987..13aeabc 100644 --- a/src/main/java/Huffman.java +++ b/src/main/java/Huffman.java @@ -89,10 +89,10 @@ public class Huffman { } public static String method527(String s) { - A_BUFFER___632.anInt1406 = 0; + A_BUFFER___632.position = 0; method526(s, A_BUFFER___632); - int j = A_BUFFER___632.anInt1406; - A_BUFFER___632.anInt1406 = 0; + int j = A_BUFFER___632.position; + A_BUFFER___632.position = 0; return method525(j, A_BUFFER___632); } diff --git a/src/main/java/IDKType.java b/src/main/java/IDKType.java index 97bbf1e..2ed7fb6 100644 --- a/src/main/java/IDKType.java +++ b/src/main/java/IDKType.java @@ -64,7 +64,7 @@ public class IDKType { } boolean flag = true; for (int i : anIntArray658) { - if (!Model.method463(i)) { + if (!Model.validate(i)) { flag = false; } } @@ -77,7 +77,7 @@ public class IDKType { } Model[] aclass30_sub2_sub4_sub6 = new Model[anIntArray658.length]; for (int i = 0; i < anIntArray658.length; i++) { - aclass30_sub2_sub4_sub6[i] = Model.method462(anIntArray658[i]); + aclass30_sub2_sub4_sub6[i] = Model.tryGet(anIntArray658[i]); } Model model; if (aclass30_sub2_sub4_sub6.length == 1) { @@ -89,7 +89,7 @@ public class IDKType { if (anIntArray659[j] == 0) { break; } - model.method476(anIntArray659[j], anIntArray660[j]); + model.replaceColor(anIntArray659[j], anIntArray660[j]); } return model; } @@ -97,7 +97,7 @@ public class IDKType { public boolean method539() { boolean flag1 = true; for (int i = 0; i < 5; i++) { - if (anIntArray661[i] != -1 && !Model.method463(anIntArray661[i])) { + if (anIntArray661[i] != -1 && !Model.validate(anIntArray661[i])) { flag1 = false; } } @@ -109,7 +109,7 @@ public class IDKType { int j = 0; for (int k = 0; k < 5; k++) { if (anIntArray661[k] != -1) { - aclass30_sub2_sub4_sub6[j++] = Model.method462(anIntArray661[k]); + aclass30_sub2_sub4_sub6[j++] = Model.tryGet(anIntArray661[k]); } } Model model = new Model(j, aclass30_sub2_sub4_sub6); @@ -117,7 +117,7 @@ public class IDKType { if (anIntArray659[l] == 0) { break; } - model.method476(anIntArray659[l], anIntArray660[l]); + model.replaceColor(anIntArray659[l], anIntArray660[l]); } return model; } diff --git a/src/main/java/Image24.java b/src/main/java/Image24.java index caea618..38a0658 100644 --- a/src/main/java/Image24.java +++ b/src/main/java/Image24.java @@ -45,7 +45,7 @@ public class Image24 extends Draw2D { public Image24(FileArchive archive, String s, int i) { Buffer buffer = new Buffer(archive.method571(s + ".dat", null)); Buffer buffer_1 = new Buffer(archive.method571("index.dat", null)); - buffer_1.anInt1406 = buffer.method410(); + buffer_1.position = buffer.method410(); anInt1444 = buffer_1.method410(); anInt1445 = buffer_1.method410(); int j = buffer_1.method408(); @@ -57,9 +57,9 @@ public class Image24 extends Draw2D { } } for (int l = 0; l < i; l++) { - buffer_1.anInt1406 += 2; - buffer.anInt1406 += buffer_1.method410() * buffer_1.method410(); - buffer_1.anInt1406++; + buffer_1.position += 2; + buffer.position += buffer_1.method410() * buffer_1.method410(); + buffer_1.position++; } anInt1442 = buffer_1.method408(); anInt1443 = buffer_1.method408(); @@ -84,7 +84,7 @@ public class Image24 extends Draw2D { } public void method343() { - Draw2D.method331(anInt1441, anInt1440, anIntArray1439); + Draw2D.bind(anIntArray1439, anInt1440, anInt1441); } public void method344(int i, int j, int k) { @@ -134,40 +134,40 @@ public class Image24 extends Draw2D { public void method346(int i, int j) { i += anInt1442; j += anInt1443; - int l = i + j * Draw2D.anInt1379; + int l = i + j * Draw2D.width; int i1 = 0; int j1 = anInt1441; int k1 = anInt1440; - int l1 = Draw2D.anInt1379 - k1; + int l1 = Draw2D.width - k1; int i2 = 0; - if (j < Draw2D.anInt1381) { - int j2 = Draw2D.anInt1381 - j; + if (j < Draw2D.top) { + int j2 = Draw2D.top - j; j1 -= j2; - j = Draw2D.anInt1381; + j = Draw2D.top; i1 += j2 * k1; - l += j2 * Draw2D.anInt1379; + l += j2 * Draw2D.width; } - if (j + j1 > Draw2D.anInt1382) { - j1 -= (j + j1) - Draw2D.anInt1382; + if (j + j1 > Draw2D.bottom) { + j1 -= (j + j1) - Draw2D.bottom; } - if (i < Draw2D.anInt1383) { - int k2 = Draw2D.anInt1383 - i; + if (i < Draw2D.left) { + int k2 = Draw2D.left - i; k1 -= k2; - i = Draw2D.anInt1383; + i = Draw2D.left; i1 += k2; l += k2; i2 += k2; l1 += k2; } - if (i + k1 > Draw2D.anInt1384) { - int l2 = (i + k1) - Draw2D.anInt1384; + if (i + k1 > Draw2D.right) { + int l2 = (i + k1) - Draw2D.right; k1 -= l2; i2 += l2; l1 += l2; } if (k1 <= 0 || j1 <= 0) { } else { - method347(l, k1, j1, i2, i1, l1, anIntArray1439, Draw2D.anIntArray1378); + method347(l, k1, j1, i2, i1, l1, anIntArray1439, Draw2D.pixels); } } @@ -192,40 +192,40 @@ public class Image24 extends Draw2D { public void method348(int i, int k) { i += anInt1442; k += anInt1443; - int l = i + k * Draw2D.anInt1379; + int l = i + k * Draw2D.width; int i1 = 0; int j1 = anInt1441; int k1 = anInt1440; - int l1 = Draw2D.anInt1379 - k1; + int l1 = Draw2D.width - k1; int i2 = 0; - if (k < Draw2D.anInt1381) { - int j2 = Draw2D.anInt1381 - k; + if (k < Draw2D.top) { + int j2 = Draw2D.top - k; j1 -= j2; - k = Draw2D.anInt1381; + k = Draw2D.top; i1 += j2 * k1; - l += j2 * Draw2D.anInt1379; + l += j2 * Draw2D.width; } - if (k + j1 > Draw2D.anInt1382) { - j1 -= (k + j1) - Draw2D.anInt1382; + if (k + j1 > Draw2D.bottom) { + j1 -= (k + j1) - Draw2D.bottom; } - if (i < Draw2D.anInt1383) { - int k2 = Draw2D.anInt1383 - i; + if (i < Draw2D.left) { + int k2 = Draw2D.left - i; k1 -= k2; - i = Draw2D.anInt1383; + i = Draw2D.left; i1 += k2; l += k2; i2 += k2; l1 += k2; } - if (i + k1 > Draw2D.anInt1384) { - int l2 = (i + k1) - Draw2D.anInt1384; + if (i + k1 > Draw2D.right) { + int l2 = (i + k1) - Draw2D.right; k1 -= l2; i2 += l2; l1 += l2; } if (k1 <= 0 || j1 <= 0) { } else { - method349(Draw2D.anIntArray1378, anIntArray1439, i1, l, k1, j1, l1, i2); + method349(Draw2D.pixels, anIntArray1439, i1, l, k1, j1, l1, i2); } } @@ -276,40 +276,40 @@ public class Image24 extends Draw2D { public void method350(int i, int j, int k) { i += anInt1442; j += anInt1443; - int i1 = i + j * Draw2D.anInt1379; + int i1 = i + j * Draw2D.width; int j1 = 0; int k1 = anInt1441; int l1 = anInt1440; - int i2 = Draw2D.anInt1379 - l1; + int i2 = Draw2D.width - l1; int j2 = 0; - if (j < Draw2D.anInt1381) { - int k2 = Draw2D.anInt1381 - j; + if (j < Draw2D.top) { + int k2 = Draw2D.top - j; k1 -= k2; - j = Draw2D.anInt1381; + j = Draw2D.top; j1 += k2 * l1; - i1 += k2 * Draw2D.anInt1379; + i1 += k2 * Draw2D.width; } - if (j + k1 > Draw2D.anInt1382) { - k1 -= (j + k1) - Draw2D.anInt1382; + if (j + k1 > Draw2D.bottom) { + k1 -= (j + k1) - Draw2D.bottom; } - if (i < Draw2D.anInt1383) { - int l2 = Draw2D.anInt1383 - i; + if (i < Draw2D.left) { + int l2 = Draw2D.left - i; l1 -= l2; - i = Draw2D.anInt1383; + i = Draw2D.left; j1 += l2; i1 += l2; j2 += l2; i2 += l2; } - if (i + l1 > Draw2D.anInt1384) { - int i3 = (i + l1) - Draw2D.anInt1384; + if (i + l1 > Draw2D.right) { + int i3 = (i + l1) - Draw2D.right; l1 -= i3; j2 += i3; i2 += i3; } if (l1 <= 0 || k1 <= 0) { } else { - method351(j1, l1, Draw2D.anIntArray1378, anIntArray1439, j2, k1, i2, k, i1); + method351(j1, l1, Draw2D.pixels, anIntArray1439, j2, k1, i2, k, i1); } } @@ -340,20 +340,20 @@ public class Image24 extends Draw2D { i3 = i3 * k >> 8; int j3 = (i2 << 16) + (k2 * l2 + j2 * i3); int k3 = (i1 << 16) + (k2 * i3 - j2 * l2); - int l3 = k1 + j1 * Draw2D.anInt1379; + int l3 = k1 + j1 * Draw2D.width; for (j1 = 0; j1 < i; j1++) { int i4 = ai1[j1]; int j4 = l3 + i4; int k4 = j3 + i3 * i4; int l4 = k3 - l2 * i4; for (k1 = -ai[j1]; k1 < 0; k1++) { - Draw2D.anIntArray1378[j4++] = anIntArray1439[(k4 >> 16) + (l4 >> 16) * anInt1440]; + Draw2D.pixels[j4++] = anIntArray1439[(k4 >> 16) + (l4 >> 16) * anInt1440]; k4 += i3; l4 -= l2; } j3 += l2; k3 += i3; - l3 += Draw2D.anInt1379; + l3 += Draw2D.width; } } catch (Exception ignored) { } @@ -369,7 +369,7 @@ public class Image24 extends Draw2D { l2 = l2 * j1 >> 8; int i3 = (l << 16) + (j2 * k2 + i2 * l2); int j3 = (j << 16) + (j2 * l2 - i2 * k2); - int k3 = l1 + i * Draw2D.anInt1379; + int k3 = l1 + i * Draw2D.width; for (i = 0; i < k1; i++) { int l3 = k3; int i4 = i3; @@ -377,7 +377,7 @@ public class Image24 extends Draw2D { for (l1 = -k; l1 < 0; l1++) { int k4 = anIntArray1439[(i4 >> 16) + (j4 >> 16) * anInt1440]; if (k4 != 0) { - Draw2D.anIntArray1378[l3++] = k4; + Draw2D.pixels[l3++] = k4; } else { l3++; } @@ -386,7 +386,7 @@ public class Image24 extends Draw2D { } i3 += k2; j3 += l2; - k3 += Draw2D.anInt1379; + k3 += Draw2D.width; } } catch (Exception ignored) { } @@ -395,40 +395,40 @@ public class Image24 extends Draw2D { public void method354(Image8 image, int i, int j) { j += anInt1442; i += anInt1443; - int k = j + i * Draw2D.anInt1379; + int k = j + i * Draw2D.width; int l = 0; int i1 = anInt1441; int j1 = anInt1440; - int k1 = Draw2D.anInt1379 - j1; + int k1 = Draw2D.width - j1; int l1 = 0; - if (i < Draw2D.anInt1381) { - int i2 = Draw2D.anInt1381 - i; + if (i < Draw2D.top) { + int i2 = Draw2D.top - i; i1 -= i2; - i = Draw2D.anInt1381; + i = Draw2D.top; l += i2 * j1; - k += i2 * Draw2D.anInt1379; + k += i2 * Draw2D.width; } - if (i + i1 > Draw2D.anInt1382) { - i1 -= (i + i1) - Draw2D.anInt1382; + if (i + i1 > Draw2D.bottom) { + i1 -= (i + i1) - Draw2D.bottom; } - if (j < Draw2D.anInt1383) { - int j2 = Draw2D.anInt1383 - j; + if (j < Draw2D.left) { + int j2 = Draw2D.left - j; j1 -= j2; - j = Draw2D.anInt1383; + j = Draw2D.left; l += j2; k += j2; l1 += j2; k1 += j2; } - if (j + j1 > Draw2D.anInt1384) { - int k2 = (j + j1) - Draw2D.anInt1384; + if (j + j1 > Draw2D.right) { + int k2 = (j + j1) - Draw2D.right; j1 -= k2; l1 += k2; k1 += k2; } if (j1 <= 0 || i1 <= 0) { } else { - method355(anIntArray1439, j1, image.aByteArray1450, i1, Draw2D.anIntArray1378, k1, k, l1, l); + method355(anIntArray1439, j1, image.aByteArray1450, i1, Draw2D.pixels, k1, k, l1, l); } } diff --git a/src/main/java/Image8.java b/src/main/java/Image8.java index cd9043a..f63ff26 100644 --- a/src/main/java/Image8.java +++ b/src/main/java/Image8.java @@ -16,7 +16,7 @@ public class Image8 extends Draw2D { public Image8(FileArchive archive, String s, int i) { Buffer buffer = new Buffer(archive.method571(s + ".dat", null)); Buffer buffer_1 = new Buffer(archive.method571("index.dat", null)); - buffer_1.anInt1406 = buffer.method410(); + buffer_1.position = buffer.method410(); anInt1456 = buffer_1.method410(); anInt1457 = buffer_1.method410(); int j = buffer_1.method408(); @@ -25,9 +25,9 @@ public class Image8 extends Draw2D { anIntArray1451[k + 1] = buffer_1.method412(); } for (int l = 0; l < i; l++) { - buffer_1.anInt1406 += 2; - buffer.anInt1406 += buffer_1.method410() * buffer_1.method410(); - buffer_1.anInt1406++; + buffer_1.position += 2; + buffer.position += buffer_1.method410() * buffer_1.method410(); + buffer_1.position++; } anInt1454 = buffer_1.method408(); anInt1455 = buffer_1.method408(); @@ -140,39 +140,39 @@ public class Image8 extends Draw2D { public void method361(int i, int k) { i += anInt1454; k += anInt1455; - int l = i + k * Draw2D.anInt1379; + int l = i + k * Draw2D.width; int i1 = 0; int j1 = anInt1453; int k1 = anInt1452; - int l1 = Draw2D.anInt1379 - k1; + int l1 = Draw2D.width - k1; int i2 = 0; - if (k < Draw2D.anInt1381) { - int j2 = Draw2D.anInt1381 - k; + if (k < Draw2D.top) { + int j2 = Draw2D.top - k; j1 -= j2; - k = Draw2D.anInt1381; + k = Draw2D.top; i1 += j2 * k1; - l += j2 * Draw2D.anInt1379; + l += j2 * Draw2D.width; } - if (k + j1 > Draw2D.anInt1382) { - j1 -= (k + j1) - Draw2D.anInt1382; + if (k + j1 > Draw2D.bottom) { + j1 -= (k + j1) - Draw2D.bottom; } - if (i < Draw2D.anInt1383) { - int k2 = Draw2D.anInt1383 - i; + if (i < Draw2D.left) { + int k2 = Draw2D.left - i; k1 -= k2; - i = Draw2D.anInt1383; + i = Draw2D.left; i1 += k2; l += k2; i2 += k2; l1 += k2; } - if (i + k1 > Draw2D.anInt1384) { - int l2 = (i + k1) - Draw2D.anInt1384; + if (i + k1 > Draw2D.right) { + int l2 = (i + k1) - Draw2D.right; k1 -= l2; i2 += l2; l1 += l2; } if (k1 > 0 && j1 > 0) { - method362(j1, Draw2D.anIntArray1378, aByteArray1450, l1, l, k1, i1, anIntArray1451, i2); + method362(j1, Draw2D.pixels, aByteArray1450, l1, l, k1, i1, anIntArray1451, i2); } } diff --git a/src/main/java/LocType.java b/src/main/java/LocType.java index a74d5ff..a2561d5 100644 --- a/src/main/java/LocType.java +++ b/src/main/java/LocType.java @@ -64,7 +64,7 @@ public class LocType { } anInt771 = (anInt771 + 1) % 20; LocType type = aTypeArray782[anInt771]; - aBuffer_753.anInt1406 = anIntArray755[i]; + aBuffer_753.position = anIntArray755[i]; type.anInt754 = i; type.method573(); type.method582(aBuffer_753); @@ -153,13 +153,13 @@ public class LocType { } boolean flag1 = true; for (int j : anIntArray773) { - flag1 &= Model.method463(j & 0xffff); + flag1 &= Model.validate(j & 0xffff); } return flag1; } for (int j = 0; j < anIntArray776.length; j++) { if (anIntArray776[j] == i) { - return Model.method463(anIntArray773[j] & 0xffff); + return Model.validate(anIntArray773[j] & 0xffff); } } return true; @@ -175,15 +175,15 @@ public class LocType { } if (aBoolean762) { int l1 = (k + l + i1 + j1) / 4; - for (int i2 = 0; i2 < model.anInt1626; i2++) { - int j2 = model.anIntArray1627[i2]; - int k2 = model.anIntArray1629[i2]; + for (int i2 = 0; i2 < model.vertexCount; i2++) { + int j2 = model.vertexX[i2]; + int k2 = model.vertexZ[i2]; int l2 = k + ((l - k) * (j2 + 64)) / 128; int i3 = j1 + ((i1 - j1) * (j2 + 64)) / 128; int j3 = l2 + ((i3 - l2) * (k2 + 64)) / 128; - model.anIntArray1628[i2] += j3 - l1; + model.vertexY[i2] += j3 - l1; } - model.method467(); + model.calculateBoundsY(); } return model; } @@ -194,7 +194,7 @@ public class LocType { } boolean flag1 = true; for (int j : anIntArray773) { - flag1 &= Model.method463(j & 0xffff); + flag1 &= Model.validate(j & 0xffff); } return flag1; } @@ -242,12 +242,12 @@ public class LocType { } model = (Model) aCache_785.method222(l2); if (model == null) { - model = Model.method462(l2 & 0xffff); + model = Model.tryGet(l2 & 0xffff); if (model == null) { return null; } if (flag1) { - model.method477(); + model.rotateY180(); } aCache_785.method223(model, l2); } @@ -282,12 +282,12 @@ public class LocType { } model = (Model) aCache_785.method222(j2); if (model == null) { - model = Model.method462(j2 & 0xffff); + model = Model.tryGet(j2 & 0xffff); if (model == null) { return null; } if (flag3) { - model.method477(); + model.rotateY180(); } aCache_785.method223(model, j2); } @@ -296,30 +296,30 @@ public class LocType { flag = anInt748 != 128 || anInt772 != 128 || anInt740 != 128; boolean flag2; flag2 = anInt738 != 0 || anInt745 != 0 || anInt783 != 0; - Model model_3 = new Model(anIntArray784 == null, SeqTransform.method532(k), l == 0 && k == -1 && !flag && !flag2, model); + Model model_3 = new Model(anIntArray784 == null, SeqFrame.isNull(k), l == 0 && k == -1 && !flag && !flag2, model); if (k != -1) { - model_3.method469(); - model_3.method470(k); - model_3.anIntArrayArray1658 = null; - model_3.anIntArrayArray1657 = null; + model_3.createLabelReferences(); + model_3.applySequenceFrame(k); + model_3.labelFaces = null; + model_3.labelVertices = null; } while (l-- > 0) { - model_3.method473(); + model_3.rotateY90(); } if (anIntArray784 != null) { for (int k2 = 0; k2 < anIntArray784.length; k2++) { - model_3.method476(anIntArray784[k2], anIntArray747[k2]); + model_3.replaceColor(anIntArray784[k2], anIntArray747[k2]); } } if (flag) { - model_3.method478(anInt748, anInt740, anInt772); + model_3.scale(anInt748, anInt740, anInt772); } if (flag2) { - model_3.method475(anInt738, anInt745, anInt783); + model_3.translate(anInt738, anInt745, anInt783); } - model_3.method479(64 + aByte737, 768 + aByte742 * 5, -50, -10, -50, !aBoolean769); + model_3.calculateNormals(64 + aByte737, 768 + aByte742 * 5, -50, -10, -50, !aBoolean769); if (anInt760 == 1) { - model_3.anInt1654 = model_3.anInt1426; + model_3.anInt1654 = model_3.minY; } aCache_780.method223(model_3, l1); return model_3; @@ -346,7 +346,7 @@ public class LocType { anIntArray776[k1] = buffer.method408(); } } else { - buffer.anInt1406 += k * 3; + buffer.position += k * 3; } } } else if (j == 2) { @@ -363,7 +363,7 @@ public class LocType { anIntArray773[l1] = buffer.method410(); } } else { - buffer.anInt1406 += l * 2; + buffer.position += l * 2; } } } else if (j == 14) { diff --git a/src/main/java/Model.java b/src/main/java/Model.java index 21f0c6a..d054788 100644 --- a/src/main/java/Model.java +++ b/src/main/java/Model.java @@ -4,621 +4,821 @@ public class Model extends Entity { - public static int anInt1620; - public static final Model A_MODEL___1621 = new Model(); - public static int[] anIntArray1622 = new int[2000]; - public static int[] anIntArray1623 = new int[2000]; - public static int[] anIntArray1624 = new int[2000]; - public static int[] anIntArray1625 = new int[2000]; - public static ModelHeader[] aHeaderArray1661; - public static OnDemand aClass42_1662; - public static boolean[] aBooleanArray1663 = new boolean[4096]; - public static boolean[] aBooleanArray1664 = new boolean[4096]; - public static int[] anIntArray1665 = new int[4096]; - public static int[] anIntArray1666 = new int[4096]; - public static int[] anIntArray1667 = new int[4096]; - public static int[] anIntArray1668 = new int[4096]; - public static int[] anIntArray1669 = new int[4096]; - public static int[] anIntArray1670 = new int[4096]; - public static int[] anIntArray1671 = new int[1500]; - public static int[][] anIntArrayArray1672 = new int[1500][512]; - public static int[] anIntArray1673 = new int[12]; - public static int[][] anIntArrayArray1674 = new int[12][2000]; - public static int[] anIntArray1675 = new int[2000]; - public static int[] anIntArray1676 = new int[2000]; - public static int[] anIntArray1677 = new int[12]; - public static final int[] anIntArray1678 = new int[10]; - public static final int[] anIntArray1679 = new int[10]; - public static final int[] anIntArray1680 = new int[10]; - public static int anInt1681; - public static int anInt1682; - public static int anInt1683; - public static boolean aBoolean1684; - public static int anInt1685; - public static int anInt1686; - public static int anInt1687; - public static final int[] anIntArray1688 = new int[1000]; - public static int[] anIntArray1689 = Draw3D.anIntArray1470; - public static int[] anIntArray1690 = Draw3D.anIntArray1471; - public static int[] anIntArray1691 = Draw3D.anIntArray1482; - public static int[] anIntArray1692 = Draw3D.anIntArray1469; + public static final Model EMPTY = new Model(); - public int anInt1626; - public int[] anIntArray1627; - public int[] anIntArray1628; - public int[] anIntArray1629; - public int anInt1630; - public int[] anIntArray1631; - public int[] anIntArray1632; - public int[] anIntArray1633; - public int[] anIntArray1634; - public int[] anIntArray1635; - public int[] anIntArray1636; - public int[] anIntArray1637; - public int[] anIntArray1638; - public int[] anIntArray1639; - public int[] anIntArray1640; - public int anInt1641; - public int anInt1642; - public int[] anIntArray1643; - public int[] anIntArray1644; - public int[] anIntArray1645; - public int anInt1646; - public int anInt1647; - public int anInt1648; - public int anInt1649; - public int anInt1650; - public int anInt1651; - public int anInt1652; - public int anInt1653; + public static final int[] clippedX = new int[10]; + public static final int[] clippedY = new int[10]; + public static final int[] clippedColor = new int[10]; + public static final int[] pickedBitsets = new int[1000]; + + public static int counter; + + public static int[] tmpVertexX = new int[2000]; + public static int[] tmpVertexY = new int[2000]; + public static int[] tmpVertexZ = new int[2000]; + public static int[] tmpFaceAlpha = new int[2000]; + + public static ModelHeader[] headers; + public static OnDemand ondemand; + + public static boolean[] faceClippedX = new boolean[4096]; + public static boolean[] faceNearClipped = new boolean[4096]; + + public static int[] vertexScreenX = new int[4096]; + public static int[] vertexScreenY = new int[4096]; + public static int[] vertexScreenZ = new int[4096]; + public static int[] vertexViewSpaceX = new int[4096]; + public static int[] vertexViewSpaceY = new int[4096]; + public static int[] vertexViewSpaceZ = new int[4096]; + + public static int[] tmpDepthFaceCount = new int[1500]; + public static int[][] tmpDepthFaces = new int[1500][512]; + public static int[] tmpPriorityFaceCount = new int[12]; + public static int[][] tmpPriorityFaces = new int[12][2000]; + public static int[] tmpPriority10FaceDepth = new int[2000]; + public static int[] tmpPriority11FaceDepth = new int[2000]; + public static int[] tmpPriorityDepthSum = new int[12]; + + public static int baseX; + public static int baseY; + public static int baseZ; + public static boolean checkHover; + public static int mouseX; + public static int mouseY; + public static int pickedCount; + public static int[] sin = Draw3D.sin; + public static int[] cos = Draw3D.cos; + public static int[] palette = Draw3D.palette; + public static int[] reciprical16 = Draw3D.reciprical16; + + public int vertexCount; + public int[] vertexX; + public int[] vertexY; + public int[] vertexZ; + public int faceCount; + public int[] faceVertexA; + public int[] faceVertexB; + public int[] faceVertexC; + public int[] faceColorA; + public int[] faceColorB; + public int[] faceColorC; + public int[] faceInfo; + public int[] facePriority; + public int[] faceAlpha; + public int[] faceColor; + public int priority; + public int texturedFaceCount; + public int[] texturedVertexA; + public int[] texturedVertexB; + public int[] texturedVertexC; + public int minX; + public int maxX; + public int maxY; + public int minZ; + public int maxZ; + /** + * The radius of this model on the XZ plane. + * + * @see #calculateBoundsAABB() + */ + public int radius; + public int minDepth; + public int maxDepth; + + /** + * minDepth = (int) Math.sqrt((radius * radius) + (super.minY * super.minY)); + * maxDepth = minDepth + (int) Math.sqrt((radius * radius) + (maxY * maxY)); + */ public int anInt1654; - public int[] anIntArray1655; - public int[] anIntArray1656; - public int[][] anIntArrayArray1657; - public int[][] anIntArrayArray1658; - public boolean aBoolean1659 = false; - public VertexNormal[] aNormalArray1660; + /** + * The label the vertex belongs to. + */ + public int[] vertexLabel; + /** + * The label the face belongs to. + */ + public int[] faceLabel; + /** + * A lookup table for label->vertex. + */ + public int[][] labelVertices; + /** + * A lookup table for label->face. + */ + public int[][] labelFaces; + /** + * When set to true, this model will be picked based on its projected screen bounds. + * + * @see #draw(int, int, int, int, int, int, int, int, int) + */ + public boolean pickBounds = false; + /** + * A storage for the original vertex normals to give {@link SceneGraph#method308(Model, Model, int, int, int, boolean)} + * a reference. + */ + public VertexNormal[] vertexNormalOriginal; + + /** + * Constructs an empty model. + */ public Model() { } - public Model(int i) { - anInt1620++; - ModelHeader header = aHeaderArray1661[i]; - anInt1626 = header.anInt369; - anInt1630 = header.anInt370; - anInt1642 = header.anInt371; - anIntArray1627 = new int[anInt1626]; - anIntArray1628 = new int[anInt1626]; - anIntArray1629 = new int[anInt1626]; - anIntArray1631 = new int[anInt1630]; - anIntArray1632 = new int[anInt1630]; - anIntArray1633 = new int[anInt1630]; - anIntArray1643 = new int[anInt1642]; - anIntArray1644 = new int[anInt1642]; - anIntArray1645 = new int[anInt1642]; - if (header.anInt376 >= 0) { - anIntArray1655 = new int[anInt1626]; + /** + * Constructs a new model and loads it from its header. + * + * Note: This constructor only works if the model has already been loaded. {@link #load(byte[], int)} must + * have already been called for the given id. + * + * @param id the model id. + */ + public Model(int id) { + counter++; + + ModelHeader header = headers[id]; + vertexCount = header.vertexCount; + faceCount = header.faceCount; + texturedFaceCount = header.texturedFaceCount; + vertexX = new int[vertexCount]; + vertexY = new int[vertexCount]; + vertexZ = new int[vertexCount]; + faceVertexA = new int[faceCount]; + faceVertexB = new int[faceCount]; + faceVertexC = new int[faceCount]; + texturedVertexA = new int[texturedFaceCount]; + texturedVertexB = new int[texturedFaceCount]; + texturedVertexC = new int[texturedFaceCount]; + + if (header.obPoint5Position >= 0) { + vertexLabel = new int[vertexCount]; } - if (header.anInt380 >= 0) { - anIntArray1637 = new int[anInt1630]; + + if (header.obFace2Position >= 0) { + faceInfo = new int[faceCount]; } - if (header.anInt381 >= 0) { - anIntArray1638 = new int[anInt1630]; + + if (header.obFace3Position >= 0) { + facePriority = new int[faceCount]; } else { - anInt1641 = -header.anInt381 - 1; + priority = -header.obFace3Position - 1; } - if (header.anInt382 >= 0) { - anIntArray1639 = new int[anInt1630]; + + if (header.obFace4Position >= 0) { + faceAlpha = new int[faceCount]; } - if (header.anInt383 >= 0) { - anIntArray1656 = new int[anInt1630]; + + if (header.obFace5Position >= 0) { + faceLabel = new int[faceCount]; } - anIntArray1640 = new int[anInt1630]; - Buffer buffer = new Buffer(header.aByteArray368); - buffer.anInt1406 = header.anInt372; - Buffer buffer_1 = new Buffer(header.aByteArray368); - buffer_1.anInt1406 = header.anInt373; - Buffer class30_sub2_sub2_2 = new Buffer(header.aByteArray368); - class30_sub2_sub2_2.anInt1406 = header.anInt374; - Buffer buffer_3 = new Buffer(header.aByteArray368); - buffer_3.anInt1406 = header.anInt375; - Buffer buffer_4 = new Buffer(header.aByteArray368); - buffer_4.anInt1406 = header.anInt376; - int k = 0; - int l = 0; - int i1 = 0; - for (int j1 = 0; j1 < anInt1626; j1++) { - int k1 = buffer.method408(); - int i2 = 0; - if ((k1 & 1) != 0) { - i2 = buffer_1.method421(); + + faceColor = new int[faceCount]; + + Buffer buf0 = new Buffer(header.data); + buf0.position = header.obPoint1Position; + + Buffer buf1 = new Buffer(header.data); + buf1.position = header.obPoint2Position; + + Buffer buf2 = new Buffer(header.data); + buf2.position = header.obPoint3Position; + + Buffer buf3 = new Buffer(header.data); + buf3.position = header.obPoint4Position; + + Buffer buf4 = new Buffer(header.data); + buf4.position = header.obPoint5Position; + + int x = 0; + int y = 0; + int z = 0; + + for (int v = 0; v < vertexCount; v++) { + int flags = buf0.method408(); + + int dx = 0; + int dy = 0; + int dz = 0; + + if ((flags & 1) != 0) { + dx = buf1.method421(); } - int k2 = 0; - if ((k1 & 2) != 0) { - k2 = class30_sub2_sub2_2.method421(); + + if ((flags & 2) != 0) { + dy = buf2.method421(); } - int i3 = 0; - if ((k1 & 4) != 0) { - i3 = buffer_3.method421(); + + if ((flags & 4) != 0) { + dz = buf3.method421(); } - anIntArray1627[j1] = k + i2; - anIntArray1628[j1] = l + k2; - anIntArray1629[j1] = i1 + i3; - k = anIntArray1627[j1]; - l = anIntArray1628[j1]; - i1 = anIntArray1629[j1]; - if (anIntArray1655 != null) { - anIntArray1655[j1] = buffer_4.method408(); + + vertexX[v] = x + dx; + vertexY[v] = y + dy; + vertexZ[v] = z + dz; + + x = vertexX[v]; + y = vertexY[v]; + z = vertexZ[v]; + + if (vertexLabel != null) { + vertexLabel[v] = buf4.method408(); } } - buffer.anInt1406 = header.anInt379; - buffer_1.anInt1406 = header.anInt380; - class30_sub2_sub2_2.anInt1406 = header.anInt381; - buffer_3.anInt1406 = header.anInt382; - buffer_4.anInt1406 = header.anInt383; - for (int l1 = 0; l1 < anInt1630; l1++) { - anIntArray1640[l1] = buffer.method410(); - if (anIntArray1637 != null) { - anIntArray1637[l1] = buffer_1.method408(); + + buf0.position = header.obFace1Position; + buf1.position = header.obFace2Position; + buf2.position = header.obFace3Position; + buf3.position = header.obFace4Position; + buf4.position = header.obFace5Position; + + for (int face = 0; face < faceCount; face++) { + faceColor[face] = buf0.method410(); + + if (faceInfo != null) { + faceInfo[face] = buf1.method408(); } - if (anIntArray1638 != null) { - anIntArray1638[l1] = class30_sub2_sub2_2.method408(); + + if (facePriority != null) { + facePriority[face] = buf2.method408(); } - if (anIntArray1639 != null) { - anIntArray1639[l1] = buffer_3.method408(); + + if (faceAlpha != null) { + faceAlpha[face] = buf3.method408(); } - if (anIntArray1656 != null) { - anIntArray1656[l1] = buffer_4.method408(); + + if (faceLabel != null) { + faceLabel[face] = buf4.method408(); } } - buffer.anInt1406 = header.anInt377; - buffer_1.anInt1406 = header.anInt378; - int j2 = 0; - int l2 = 0; - int j3 = 0; - int k3 = 0; - for (int l3 = 0; l3 < anInt1630; l3++) { - int i4 = buffer_1.method408(); - if (i4 == 1) { - j2 = buffer.method421() + k3; - k3 = j2; - l2 = buffer.method421() + k3; - k3 = l2; - j3 = buffer.method421() + k3; - k3 = j3; - anIntArray1631[l3] = j2; - anIntArray1632[l3] = l2; - anIntArray1633[l3] = j3; + + buf0.position = header.obVertex1Position; + buf1.position = header.obVertex2Position; + + int a = 0; + int b = 0; + int c = 0; + int last = 0; + + for (int face = 0; face < faceCount; face++) { + int orientation = buf1.method408(); + + // fancy shmansy compression type stuff. + // vertex indices stored as deltas, with some faces + // sharing indices. + + // new a, b, c + if (orientation == 1) { + a = buf0.method421() + last; + last = a; + b = buf0.method421() + last; + last = b; + c = buf0.method421() + last; + last = c; + faceVertexA[face] = a; + faceVertexB[face] = b; + faceVertexC[face] = c; } - if (i4 == 2) { - l2 = j3; - j3 = buffer.method421() + k3; - k3 = j3; - anIntArray1631[l3] = j2; - anIntArray1632[l3] = l2; - anIntArray1633[l3] = j3; + + // reuse a, c, new b + if (orientation == 2) { + b = c; + c = buf0.method421() + last; + last = c; + faceVertexA[face] = a; + faceVertexB[face] = b; + faceVertexC[face] = c; } - if (i4 == 3) { - j2 = j3; - j3 = buffer.method421() + k3; - k3 = j3; - anIntArray1631[l3] = j2; - anIntArray1632[l3] = l2; - anIntArray1633[l3] = j3; + + // reuse c, b, new a + if (orientation == 3) { + a = c; + c = buf0.method421() + last; + last = c; + faceVertexA[face] = a; + faceVertexB[face] = b; + faceVertexC[face] = c; } - if (i4 == 4) { - int k4 = j2; - j2 = l2; - l2 = k4; - j3 = buffer.method421() + k3; - k3 = j3; - anIntArray1631[l3] = j2; - anIntArray1632[l3] = l2; - anIntArray1633[l3] = j3; + + // reuse b, a, new c + if (orientation == 4) { + int a_ = a; + a = b; + b = a_; + c = buf0.method421() + last; + last = c; + faceVertexA[face] = a; + faceVertexB[face] = b; + faceVertexC[face] = c; } } - buffer.anInt1406 = header.anInt384; - for (int j4 = 0; j4 < anInt1642; j4++) { - anIntArray1643[j4] = buffer.method410(); - anIntArray1644[j4] = buffer.method410(); - anIntArray1645[j4] = buffer.method410(); + + buf0.position = header.obAxisPosition; + + for (int face = 0; face < texturedFaceCount; face++) { + texturedVertexA[face] = buf0.method410(); + texturedVertexB[face] = buf0.method410(); + texturedVertexC[face] = buf0.method410(); } } - public Model(int i, Model[] aclass30_sub2_sub4_sub6) { - anInt1620++; - boolean flag = false; - boolean flag1 = false; - boolean flag2 = false; - boolean flag3 = false; - anInt1626 = 0; - anInt1630 = 0; - anInt1642 = 0; - anInt1641 = -1; - for (int k = 0; k < i; k++) { - Model model = aclass30_sub2_sub4_sub6[k]; - if (model != null) { - anInt1626 += model.anInt1626; - anInt1630 += model.anInt1630; - anInt1642 += model.anInt1642; - flag |= model.anIntArray1637 != null; - if (model.anIntArray1638 != null) { - flag1 = true; - } else { - if (anInt1641 == -1) { - anInt1641 = model.anInt1641; - } - if (anInt1641 != model.anInt1641) { - flag1 = true; - } - } - flag2 |= model.anIntArray1639 != null; - flag3 |= model.anIntArray1656 != null; + /** + * Constructs a new model by merging the provided models. This constructor is used to combine models before + * {@link SeqFrame}'s have been applied. Using this constructor implies all models merged are compatible with any + * animations played on them. + * + * @param count the model count. + * @param models the models to merge. + */ + public Model(int count, Model[] models) { + counter++; + + boolean copyInfo = false; + boolean copyPriority = false; + boolean copyAlpha = false; + boolean copyLabels = false; + + vertexCount = 0; + faceCount = 0; + texturedFaceCount = 0; + priority = -1; + + for (int i = 0; i < count; i++) { + Model model = models[i]; + + if (model == null) { + continue; } - } - anIntArray1627 = new int[anInt1626]; - anIntArray1628 = new int[anInt1626]; - anIntArray1629 = new int[anInt1626]; - anIntArray1655 = new int[anInt1626]; - anIntArray1631 = new int[anInt1630]; - anIntArray1632 = new int[anInt1630]; - anIntArray1633 = new int[anInt1630]; - anIntArray1643 = new int[anInt1642]; - anIntArray1644 = new int[anInt1642]; - anIntArray1645 = new int[anInt1642]; - if (flag) { - anIntArray1637 = new int[anInt1630]; - } - if (flag1) { - anIntArray1638 = new int[anInt1630]; - } - if (flag2) { - anIntArray1639 = new int[anInt1630]; - } - if (flag3) { - anIntArray1656 = new int[anInt1630]; - } - anIntArray1640 = new int[anInt1630]; - anInt1626 = 0; - anInt1630 = 0; - anInt1642 = 0; - int l = 0; - for (int i1 = 0; i1 < i; i1++) { - Model model_1 = aclass30_sub2_sub4_sub6[i1]; - if (model_1 != null) { - for (int j1 = 0; j1 < model_1.anInt1630; j1++) { - if (flag) { - if (model_1.anIntArray1637 == null) { - anIntArray1637[anInt1630] = 0; - } else { - int k1 = model_1.anIntArray1637[j1]; - if ((k1 & 2) == 2) { - k1 += l << 2; - } - anIntArray1637[anInt1630] = k1; - } - } - if (flag1) { - if (model_1.anIntArray1638 == null) { - anIntArray1638[anInt1630] = model_1.anInt1641; - } else { - anIntArray1638[anInt1630] = model_1.anIntArray1638[j1]; - } - } - if (flag2) { - if (model_1.anIntArray1639 == null) { - anIntArray1639[anInt1630] = 0; - } else { - anIntArray1639[anInt1630] = model_1.anIntArray1639[j1]; - } - } - if (flag3 && model_1.anIntArray1656 != null) { - anIntArray1656[anInt1630] = model_1.anIntArray1656[j1]; - } - anIntArray1640[anInt1630] = model_1.anIntArray1640[j1]; - anIntArray1631[anInt1630] = method465(model_1, model_1.anIntArray1631[j1]); - anIntArray1632[anInt1630] = method465(model_1, model_1.anIntArray1632[j1]); - anIntArray1633[anInt1630] = method465(model_1, model_1.anIntArray1633[j1]); - anInt1630++; + + vertexCount += model.vertexCount; + faceCount += model.faceCount; + texturedFaceCount += model.texturedFaceCount; + + copyInfo |= model.faceInfo != null; + + if (model.facePriority != null) { + copyPriority = true; + } else { + if (priority == -1) { + priority = model.priority; } - for (int l1 = 0; l1 < model_1.anInt1642; l1++) { - anIntArray1643[anInt1642] = method465(model_1, model_1.anIntArray1643[l1]); - anIntArray1644[anInt1642] = method465(model_1, model_1.anIntArray1644[l1]); - anIntArray1645[anInt1642] = method465(model_1, model_1.anIntArray1645[l1]); - anInt1642++; + if (priority != model.priority) { + copyPriority = true; } - l += model_1.anInt1642; } + + copyAlpha |= model.faceAlpha != null; + copyLabels |= model.faceLabel != null; + } + + vertexX = new int[vertexCount]; + vertexY = new int[vertexCount]; + vertexZ = new int[vertexCount]; + vertexLabel = new int[vertexCount]; + faceVertexA = new int[faceCount]; + faceVertexB = new int[faceCount]; + faceVertexC = new int[faceCount]; + texturedVertexA = new int[texturedFaceCount]; + texturedVertexB = new int[texturedFaceCount]; + texturedVertexC = new int[texturedFaceCount]; + + if (copyInfo) { + faceInfo = new int[faceCount]; + } + + if (copyPriority) { + facePriority = new int[faceCount]; + } + + if (copyAlpha) { + faceAlpha = new int[faceCount]; + } + + if (copyLabels) { + faceLabel = new int[faceCount]; + } + + faceColor = new int[faceCount]; + vertexCount = 0; + faceCount = 0; + texturedFaceCount = 0; + + int tfaceCount = 0; + + for (int i = 0; i < count; i++) { + Model model = models[i]; + + if (model == null) { + continue; + } + + for (int face = 0; face < model.faceCount; face++) { + if (copyInfo) { + if (model.faceInfo == null) { + faceInfo[faceCount] = 0; + } else { + int info = model.faceInfo[face]; + + if ((info & 2) == 2) { + info += tfaceCount << 2; + } + + faceInfo[faceCount] = info; + } + } + + if (copyPriority) { + if (model.facePriority == null) { + facePriority[faceCount] = model.priority; + } else { + facePriority[faceCount] = model.facePriority[face]; + } + } + + if (copyAlpha) { + if (model.faceAlpha == null) { + faceAlpha[faceCount] = 0; + } else { + faceAlpha[faceCount] = model.faceAlpha[face]; + } + } + + if (copyLabels && (model.faceLabel != null)) { + faceLabel[faceCount] = model.faceLabel[face]; + } + + faceColor[faceCount] = model.faceColor[face]; + faceVertexA[faceCount] = addVertex(model, model.faceVertexA[face]); + faceVertexB[faceCount] = addVertex(model, model.faceVertexB[face]); + faceVertexC[faceCount] = addVertex(model, model.faceVertexC[face]); + faceCount++; + } + + for (int tface = 0; tface < model.texturedFaceCount; tface++) { + texturedVertexA[texturedFaceCount] = addVertex(model, model.texturedVertexA[tface]); + texturedVertexB[texturedFaceCount] = addVertex(model, model.texturedVertexB[tface]); + texturedVertexC[texturedFaceCount] = addVertex(model, model.texturedVertexC[tface]); + texturedFaceCount++; + } + + tfaceCount += model.texturedFaceCount; } } - public Model(int i, int dummy, Model[] aclass30_sub2_sub4_sub6) { - anInt1620++; - boolean flag1 = false; - boolean flag2 = false; - boolean flag3 = false; - boolean flag4 = false; - anInt1626 = 0; - anInt1630 = 0; - anInt1642 = 0; - anInt1641 = -1; - for (int k = 0; k < i; k++) { - Model model = aclass30_sub2_sub4_sub6[k]; - if (model != null) { - anInt1626 += model.anInt1626; - anInt1630 += model.anInt1630; - anInt1642 += model.anInt1642; - flag1 |= model.anIntArray1637 != null; - if (model.anIntArray1638 != null) { - flag2 = true; - } else { - if (anInt1641 == -1) { - anInt1641 = model.anInt1641; - } - if (anInt1641 != model.anInt1641) { - flag2 = true; - } - } - flag3 |= model.anIntArray1639 != null; - flag4 |= model.anIntArray1640 != null; + /** + * Constructs a new model by combining models. This constructor is commonly used to combine models which have already + * had a {@link SeqFrame} applied, and does not copy label information. + * + * @param count the model count. + * @param dummy dummy. + * @param models the models. + */ + public Model(int count, int dummy, Model[] models) { + counter++; + + boolean copyInfo = false; + boolean copyPriority = false; + boolean copyAlpha = false; + boolean copyColor = false; + + vertexCount = 0; + faceCount = 0; + texturedFaceCount = 0; + priority = -1; + + for (int i = 0; i < count; i++) { + Model model = models[i]; + + if (model == null) { + continue; } - } - anIntArray1627 = new int[anInt1626]; - anIntArray1628 = new int[anInt1626]; - anIntArray1629 = new int[anInt1626]; - anIntArray1631 = new int[anInt1630]; - anIntArray1632 = new int[anInt1630]; - anIntArray1633 = new int[anInt1630]; - anIntArray1634 = new int[anInt1630]; - anIntArray1635 = new int[anInt1630]; - anIntArray1636 = new int[anInt1630]; - anIntArray1643 = new int[anInt1642]; - anIntArray1644 = new int[anInt1642]; - anIntArray1645 = new int[anInt1642]; - if (flag1) { - anIntArray1637 = new int[anInt1630]; - } - if (flag2) { - anIntArray1638 = new int[anInt1630]; - } - if (flag3) { - anIntArray1639 = new int[anInt1630]; - } - if (flag4) { - anIntArray1640 = new int[anInt1630]; - } - anInt1626 = 0; - anInt1630 = 0; - anInt1642 = 0; - int i1 = 0; - for (int j1 = 0; j1 < i; j1++) { - Model model_1 = aclass30_sub2_sub4_sub6[j1]; - if (model_1 != null) { - int k1 = anInt1626; - for (int l1 = 0; l1 < model_1.anInt1626; l1++) { - anIntArray1627[anInt1626] = model_1.anIntArray1627[l1]; - anIntArray1628[anInt1626] = model_1.anIntArray1628[l1]; - anIntArray1629[anInt1626] = model_1.anIntArray1629[l1]; - anInt1626++; + + vertexCount += model.vertexCount; + faceCount += model.faceCount; + texturedFaceCount += model.texturedFaceCount; + copyInfo |= model.faceInfo != null; + + if (model.facePriority != null) { + copyPriority = true; + } else { + if (priority == -1) { + priority = model.priority; } - for (int i2 = 0; i2 < model_1.anInt1630; i2++) { - anIntArray1631[anInt1630] = model_1.anIntArray1631[i2] + k1; - anIntArray1632[anInt1630] = model_1.anIntArray1632[i2] + k1; - anIntArray1633[anInt1630] = model_1.anIntArray1633[i2] + k1; - anIntArray1634[anInt1630] = model_1.anIntArray1634[i2]; - anIntArray1635[anInt1630] = model_1.anIntArray1635[i2]; - anIntArray1636[anInt1630] = model_1.anIntArray1636[i2]; - if (flag1) { - if (model_1.anIntArray1637 == null) { - anIntArray1637[anInt1630] = 0; - } else { - int j2 = model_1.anIntArray1637[i2]; - if ((j2 & 2) == 2) { - j2 += i1 << 2; - } - anIntArray1637[anInt1630] = j2; - } - } - if (flag2) { - if (model_1.anIntArray1638 == null) { - anIntArray1638[anInt1630] = model_1.anInt1641; - } else { - anIntArray1638[anInt1630] = model_1.anIntArray1638[i2]; - } - } - if (flag3) { - if (model_1.anIntArray1639 == null) { - anIntArray1639[anInt1630] = 0; - } else { - anIntArray1639[anInt1630] = model_1.anIntArray1639[i2]; - } - } - if (flag4 && model_1.anIntArray1640 != null) { - anIntArray1640[anInt1630] = model_1.anIntArray1640[i2]; - } - anInt1630++; + if (priority != model.priority) { + copyPriority = true; } - for (int k2 = 0; k2 < model_1.anInt1642; k2++) { - anIntArray1643[anInt1642] = model_1.anIntArray1643[k2] + k1; - anIntArray1644[anInt1642] = model_1.anIntArray1644[k2] + k1; - anIntArray1645[anInt1642] = model_1.anIntArray1645[k2] + k1; - anInt1642++; - } - i1 += model_1.anInt1642; } + + copyAlpha |= model.faceAlpha != null; + copyColor |= model.faceColor != null; } - method466(); + + vertexX = new int[vertexCount]; + vertexY = new int[vertexCount]; + vertexZ = new int[vertexCount]; + faceVertexA = new int[faceCount]; + faceVertexB = new int[faceCount]; + faceVertexC = new int[faceCount]; + faceColorA = new int[faceCount]; + faceColorB = new int[faceCount]; + faceColorC = new int[faceCount]; + texturedVertexA = new int[texturedFaceCount]; + texturedVertexB = new int[texturedFaceCount]; + texturedVertexC = new int[texturedFaceCount]; + + if (copyInfo) { + faceInfo = new int[faceCount]; + } + + if (copyPriority) { + facePriority = new int[faceCount]; + } + + if (copyAlpha) { + faceAlpha = new int[faceCount]; + } + + if (copyColor) { + faceColor = new int[faceCount]; + } + + vertexCount = 0; + faceCount = 0; + texturedFaceCount = 0; + + int tfaceCount = 0; + for (int i = 0; i < count; i++) { + Model model = models[i]; + + if (model == null) { + continue; + } + + int vertexCount = this.vertexCount; + + for (int v = 0; v < model.vertexCount; v++) { + vertexX[this.vertexCount] = model.vertexX[v]; + vertexY[this.vertexCount] = model.vertexY[v]; + vertexZ[this.vertexCount] = model.vertexZ[v]; + this.vertexCount++; + } + + for (int f = 0; f < model.faceCount; f++) { + faceVertexA[faceCount] = model.faceVertexA[f] + vertexCount; + faceVertexB[faceCount] = model.faceVertexB[f] + vertexCount; + faceVertexC[faceCount] = model.faceVertexC[f] + vertexCount; + + faceColorA[faceCount] = model.faceColorA[f]; + faceColorB[faceCount] = model.faceColorB[f]; + faceColorC[faceCount] = model.faceColorC[f]; + + if (copyInfo) { + if (model.faceInfo == null) { + faceInfo[faceCount] = 0; + } else { + int info = model.faceInfo[f]; + + if ((info & 2) == 2) { + info += tfaceCount << 2; + } + + faceInfo[faceCount] = info; + } + } + + if (copyPriority) { + if (model.facePriority == null) { + facePriority[faceCount] = model.priority; + } else { + facePriority[faceCount] = model.facePriority[f]; + } + } + + if (copyAlpha) { + if (model.faceAlpha == null) { + faceAlpha[faceCount] = 0; + } else { + faceAlpha[faceCount] = model.faceAlpha[f]; + } + } + + if (copyColor && (model.faceColor != null)) { + faceColor[faceCount] = model.faceColor[f]; + } + faceCount++; + } + + for (int f = 0; f < model.texturedFaceCount; f++) { + texturedVertexA[texturedFaceCount] = model.texturedVertexA[f] + vertexCount; + texturedVertexB[texturedFaceCount] = model.texturedVertexB[f] + vertexCount; + texturedVertexC[texturedFaceCount] = model.texturedVertexC[f] + vertexCount; + texturedFaceCount++; + } + + tfaceCount += model.texturedFaceCount; + } + calculateBoundsCylinder(); } - public Model(boolean flag, boolean flag1, boolean flag2, Model model) { - anInt1620++; - anInt1626 = model.anInt1626; - anInt1630 = model.anInt1630; - anInt1642 = model.anInt1642; - if (flag2) { - anIntArray1627 = model.anIntArray1627; - anIntArray1628 = model.anIntArray1628; - anIntArray1629 = model.anIntArray1629; + /** + * Constructs a new model that can either share or clone the provided models attributes. This constructor is used to + * save memory by avoiding allocations, and is meant to be used with models prior to having a {@link SeqFrame} applied. + * + * @param shareColors true to reference the provided model's colors. + * @param shareAlpha true to reference the provided model's face alpha. + * @param shareVertices true to reference the provided model's vertices. + * @param model the model to share or clone. + */ + public Model(boolean shareColors, boolean shareAlpha, boolean shareVertices, Model model) { + counter++; + vertexCount = model.vertexCount; + faceCount = model.faceCount; + texturedFaceCount = model.texturedFaceCount; + + if (shareVertices) { + vertexX = model.vertexX; + vertexY = model.vertexY; + vertexZ = model.vertexZ; } else { - anIntArray1627 = new int[anInt1626]; - anIntArray1628 = new int[anInt1626]; - anIntArray1629 = new int[anInt1626]; - for (int j = 0; j < anInt1626; j++) { - anIntArray1627[j] = model.anIntArray1627[j]; - anIntArray1628[j] = model.anIntArray1628[j]; - anIntArray1629[j] = model.anIntArray1629[j]; + vertexX = new int[vertexCount]; + vertexY = new int[vertexCount]; + vertexZ = new int[vertexCount]; + + for (int j = 0; j < vertexCount; j++) { + vertexX[j] = model.vertexX[j]; + vertexY[j] = model.vertexY[j]; + vertexZ[j] = model.vertexZ[j]; } } - if (flag) { - anIntArray1640 = model.anIntArray1640; + + if (shareColors) { + faceColor = model.faceColor; } else { - anIntArray1640 = new int[anInt1630]; - for (int k = 0; k < anInt1630; k++) { - anIntArray1640[k] = model.anIntArray1640[k]; + faceColor = new int[faceCount]; + + for (int k = 0; k < faceCount; k++) { + faceColor[k] = model.faceColor[k]; } } - if (flag1) { - anIntArray1639 = model.anIntArray1639; + + if (shareAlpha) { + faceAlpha = model.faceAlpha; } else { - anIntArray1639 = new int[anInt1630]; - if (model.anIntArray1639 == null) { - for (int l = 0; l < anInt1630; l++) { - anIntArray1639[l] = 0; + faceAlpha = new int[faceCount]; + if (model.faceAlpha == null) { + for (int l = 0; l < faceCount; l++) { + faceAlpha[l] = 0; } } else { - for (int i1 = 0; i1 < anInt1630; i1++) { - anIntArray1639[i1] = model.anIntArray1639[i1]; + for (int i1 = 0; i1 < faceCount; i1++) { + faceAlpha[i1] = model.faceAlpha[i1]; } } } - anIntArray1655 = model.anIntArray1655; - anIntArray1656 = model.anIntArray1656; - anIntArray1637 = model.anIntArray1637; - anIntArray1631 = model.anIntArray1631; - anIntArray1632 = model.anIntArray1632; - anIntArray1633 = model.anIntArray1633; - anIntArray1638 = model.anIntArray1638; - anInt1641 = model.anInt1641; - anIntArray1643 = model.anIntArray1643; - anIntArray1644 = model.anIntArray1644; - anIntArray1645 = model.anIntArray1645; + + vertexLabel = model.vertexLabel; + faceLabel = model.faceLabel; + faceInfo = model.faceInfo; + faceVertexA = model.faceVertexA; + faceVertexB = model.faceVertexB; + faceVertexC = model.faceVertexC; + facePriority = model.facePriority; + priority = model.priority; + texturedVertexA = model.texturedVertexA; + texturedVertexB = model.texturedVertexB; + texturedVertexC = model.texturedVertexC; } - public Model(boolean flag, boolean flag1, Model model) { - anInt1620++; - anInt1626 = model.anInt1626; - anInt1630 = model.anInt1630; - anInt1642 = model.anInt1642; - if (flag) { - anIntArray1628 = new int[anInt1626]; - for (int j = 0; j < anInt1626; j++) { - anIntArray1628[j] = model.anIntArray1628[j]; + /** + * Constructs a new model with the options to copy either vertex Y positions and faces. + *

+ * This constructor is specifically used by Locs which adjust to terrain. + * + * @param copyVertexY true to copy model.vertexY. + * @param copyFaces true to copy all face data from model. + * @param model the model to copy. + * @see LocType#method578(int, int, int, int, int, int, int) + */ + public Model(boolean copyVertexY, boolean copyFaces, Model model) { + counter++; + vertexCount = model.vertexCount; + faceCount = model.faceCount; + texturedFaceCount = model.texturedFaceCount; + + if (copyVertexY) { + vertexY = new int[vertexCount]; + for (int v = 0; v < vertexCount; v++) { + vertexY[v] = model.vertexY[v]; } } else { - anIntArray1628 = model.anIntArray1628; + vertexY = model.vertexY; } - if (flag1) { - anIntArray1634 = new int[anInt1630]; - anIntArray1635 = new int[anInt1630]; - anIntArray1636 = new int[anInt1630]; - for (int k = 0; k < anInt1630; k++) { - anIntArray1634[k] = model.anIntArray1634[k]; - anIntArray1635[k] = model.anIntArray1635[k]; - anIntArray1636[k] = model.anIntArray1636[k]; + + if (copyFaces) { + faceColorA = new int[faceCount]; + faceColorB = new int[faceCount]; + faceColorC = new int[faceCount]; + + for (int k = 0; k < faceCount; k++) { + faceColorA[k] = model.faceColorA[k]; + faceColorB[k] = model.faceColorB[k]; + faceColorC[k] = model.faceColorC[k]; } - anIntArray1637 = new int[anInt1630]; - if (model.anIntArray1637 == null) { - for (int l = 0; l < anInt1630; l++) { - anIntArray1637[l] = 0; + + faceInfo = new int[faceCount]; + + if (model.faceInfo == null) { + for (int l = 0; l < faceCount; l++) { + faceInfo[l] = 0; } } else { - for (int i1 = 0; i1 < anInt1630; i1++) { - anIntArray1637[i1] = model.anIntArray1637[i1]; + for (int face = 0; face < faceCount; face++) { + faceInfo[face] = model.faceInfo[face]; } } - super.aNormalArray1425 = new VertexNormal[anInt1626]; - for (int j1 = 0; j1 < anInt1626; j1++) { - VertexNormal normal = super.aNormalArray1425[j1] = new VertexNormal(); - VertexNormal normal_1 = model.aNormalArray1425[j1]; - normal.anInt602 = normal_1.anInt602; - normal.anInt603 = normal_1.anInt603; - normal.anInt604 = normal_1.anInt604; - normal.anInt605 = normal_1.anInt605; + + super.vertexNormal = new VertexNormal[vertexCount]; + for (int v = 0; v < vertexCount; v++) { + VertexNormal duplicate = super.vertexNormal[v] = new VertexNormal(); + VertexNormal original = model.vertexNormal[v]; + duplicate.x = original.x; + duplicate.y = original.y; + duplicate.z = original.z; + duplicate.w = original.w; } - aNormalArray1660 = model.aNormalArray1660; + vertexNormalOriginal = model.vertexNormalOriginal; } else { - anIntArray1634 = model.anIntArray1634; - anIntArray1635 = model.anIntArray1635; - anIntArray1636 = model.anIntArray1636; - anIntArray1637 = model.anIntArray1637; + faceColorA = model.faceColorA; + faceColorB = model.faceColorB; + faceColorC = model.faceColorC; + faceInfo = model.faceInfo; } - anIntArray1627 = model.anIntArray1627; - anIntArray1629 = model.anIntArray1629; - anIntArray1640 = model.anIntArray1640; - anIntArray1639 = model.anIntArray1639; - anIntArray1638 = model.anIntArray1638; - anInt1641 = model.anInt1641; - anIntArray1631 = model.anIntArray1631; - anIntArray1632 = model.anIntArray1632; - anIntArray1633 = model.anIntArray1633; - anIntArray1643 = model.anIntArray1643; - anIntArray1644 = model.anIntArray1644; - anIntArray1645 = model.anIntArray1645; - super.anInt1426 = model.anInt1426; - anInt1651 = model.anInt1651; - anInt1650 = model.anInt1650; - anInt1653 = model.anInt1653; - anInt1652 = model.anInt1652; - anInt1646 = model.anInt1646; - anInt1648 = model.anInt1648; - anInt1649 = model.anInt1649; - anInt1647 = model.anInt1647; + + vertexX = model.vertexX; + vertexZ = model.vertexZ; + faceColor = model.faceColor; + faceAlpha = model.faceAlpha; + facePriority = model.facePriority; + priority = model.priority; + faceVertexA = model.faceVertexA; + faceVertexB = model.faceVertexB; + faceVertexC = model.faceVertexC; + texturedVertexA = model.texturedVertexA; + texturedVertexB = model.texturedVertexB; + texturedVertexC = model.texturedVertexC; + super.minY = model.minY; + maxY = model.maxY; + radius = model.radius; + minDepth = model.minDepth; + maxDepth = model.maxDepth; + minX = model.minX; + maxZ = model.maxZ; + minZ = model.minZ; + maxX = model.maxX; } - public static void method458() { - aHeaderArray1661 = null; - aBooleanArray1663 = null; - aBooleanArray1664 = null; - anIntArray1665 = null; - anIntArray1666 = null; - anIntArray1667 = null; - anIntArray1668 = null; - anIntArray1669 = null; - anIntArray1670 = null; - anIntArray1671 = null; - anIntArrayArray1672 = null; - anIntArray1673 = null; - anIntArrayArray1674 = null; - anIntArray1675 = null; - anIntArray1676 = null; - anIntArray1677 = null; - anIntArray1689 = null; - anIntArray1690 = null; - anIntArray1691 = null; - anIntArray1692 = null; + public static void clear() { + headers = null; + faceClippedX = null; + faceNearClipped = null; + vertexScreenX = null; + vertexScreenY = null; + vertexScreenZ = null; + vertexViewSpaceX = null; + vertexViewSpaceY = null; + vertexViewSpaceZ = null; + tmpDepthFaceCount = null; + tmpDepthFaces = null; + tmpPriorityFaceCount = null; + tmpPriorityFaces = null; + tmpPriority10FaceDepth = null; + tmpPriority11FaceDepth = null; + tmpPriorityDepthSum = null; + sin = null; + cos = null; + palette = null; + reciprical16 = null; } - public static void method459(int i, OnDemand class42) { - aHeaderArray1661 = new ModelHeader[i]; - aClass42_1662 = class42; + public static void init(int count, OnDemand ondemand) { + headers = new ModelHeader[count]; + Model.ondemand = ondemand; } - public static void method460(byte[] abyte0, int j) { - if (abyte0 == null) { - ModelHeader header = aHeaderArray1661[j] = new ModelHeader(); - header.anInt369 = 0; - header.anInt370 = 0; - header.anInt371 = 0; + public static void load(byte[] src, int id) { + if (src == null) { + ModelHeader header = headers[id] = new ModelHeader(); + header.vertexCount = 0; + header.faceCount = 0; + header.texturedFaceCount = 0; return; } - Buffer buffer = new Buffer(abyte0); - buffer.anInt1406 = abyte0.length - 18; - ModelHeader header_1 = aHeaderArray1661[j] = new ModelHeader(); - header_1.aByteArray368 = abyte0; - header_1.anInt369 = buffer.method410(); - header_1.anInt370 = buffer.method410(); - header_1.anInt371 = buffer.method408(); + Buffer buffer = new Buffer(src); + buffer.position = src.length - 18; + ModelHeader header = headers[id] = new ModelHeader(); + header.data = src; + header.vertexCount = buffer.method410(); + header.faceCount = buffer.method410(); + header.texturedFaceCount = buffer.method408(); int k = buffer.method408(); int l = buffer.method408(); int i1 = buffer.method408(); @@ -629,1191 +829,1605 @@ public class Model extends Entity { //noinspection unused int j2 = buffer.method410(); int k2 = buffer.method410(); - int l2 = 0; - header_1.anInt372 = l2; - l2 += header_1.anInt369; - header_1.anInt378 = l2; - l2 += header_1.anInt370; - header_1.anInt381 = l2; + int offset = 0; + header.obPoint1Position = offset; + offset += header.vertexCount; + header.obVertex2Position = offset; + offset += header.faceCount; + header.obFace3Position = offset; if (l == 255) { - l2 += header_1.anInt370; + offset += header.faceCount; } else { - header_1.anInt381 = -l - 1; + header.obFace3Position = -l - 1; } - header_1.anInt383 = l2; + header.obFace5Position = offset; if (j1 == 1) { - l2 += header_1.anInt370; + offset += header.faceCount; } else { - header_1.anInt383 = -1; + header.obFace5Position = -1; } - header_1.anInt380 = l2; + header.obFace2Position = offset; if (k == 1) { - l2 += header_1.anInt370; + offset += header.faceCount; } else { - header_1.anInt380 = -1; + header.obFace2Position = -1; } - header_1.anInt376 = l2; + header.obPoint5Position = offset; if (k1 == 1) { - l2 += header_1.anInt369; + offset += header.vertexCount; } else { - header_1.anInt376 = -1; + header.obPoint5Position = -1; } - header_1.anInt382 = l2; + header.obFace4Position = offset; if (i1 == 1) { - l2 += header_1.anInt370; + offset += header.faceCount; } else { - header_1.anInt382 = -1; + header.obFace4Position = -1; } - header_1.anInt377 = l2; - l2 += k2; - header_1.anInt379 = l2; - l2 += header_1.anInt370 * 2; - header_1.anInt384 = l2; - l2 += header_1.anInt371 * 6; - header_1.anInt373 = l2; - l2 += l1; - header_1.anInt374 = l2; - l2 += i2; - header_1.anInt375 = l2; + header.obVertex1Position = offset; + offset += k2; + header.obFace1Position = offset; + offset += header.faceCount * 2; + header.obAxisPosition = offset; + offset += header.texturedFaceCount * 6; + header.obPoint2Position = offset; + offset += l1; + header.obPoint3Position = offset; + offset += i2; + header.obPoint4Position = offset; } - public static void method461(int j) { - aHeaderArray1661[j] = null; + public static void unload(int id) { + headers[id] = null; } - public static Model method462(int j) { - if (aHeaderArray1661 == null) { + /** + * Tries to get the model. Sends a request to the ondemand service to load the model if it isn't loaded. + * + * @param id the model id. + * @return the model, or null if not loaded. + */ + public static Model tryGet(int id) { + if (headers == null) { return null; } - ModelHeader header = aHeaderArray1661[j]; + + ModelHeader header = headers[id]; + if (header != null) { - return new Model(j); + return new Model(id); } else { - aClass42_1662.method548(j); + ondemand.method548(id); return null; } } - public static boolean method463(int i) { - if (aHeaderArray1661 == null) { + /** + * Validates the provided model id. If the model is not loaded then a request is sent to the ondemand service. + * + * @param id the model id. + * @return true if the model is loaded. + */ + public static boolean validate(int id) { + if (headers == null) { return false; } - ModelHeader header = aHeaderArray1661[i]; + + ModelHeader header = headers[id]; + if (header != null) { return true; } else { - aClass42_1662.method548(i); + ondemand.method548(id); return false; } } - public static int method481(int i, int j, int k) { - if ((k & 2) == 2) { - if (j < 0) { - j = 0; - } else if (j > 127) { - j = 127; + /** + * Utility function. Multiplies the input HSL lightness component by the provided scalar. + * + * @param hsl the color value. + * @param scalar the scalar. [0...127] + * @param faceInfo Provided face info to determine the type of color to return. Textured triangles (type 2) only have + * a lightness component. + * @return the color. + * @see #palette + */ + public static int mulColorLightness(int hsl, int scalar, int faceInfo) { + if ((faceInfo & 2) == 2) { + if (scalar < 0) { + scalar = 0; + } else if (scalar > 127) { + scalar = 127; } - j = 127 - j; - return j; + scalar = 127 - scalar; + return scalar; } - j = j * (i & 0x7f) >> 7; - if (j < 2) { - j = 2; - } else if (j > 126) { - j = 126; + scalar = (scalar * (hsl & 0x7f)) >> 7; + if (scalar < 2) { + scalar = 2; + } else if (scalar > 126) { + scalar = 126; } - return (i & 0xff80) + j; + return (hsl & 0xff80) + scalar; } - public void method464(Model model, boolean flag) { - anInt1626 = model.anInt1626; - anInt1630 = model.anInt1630; - anInt1642 = model.anInt1642; - if (anIntArray1622.length < anInt1626) { - anIntArray1622 = new int[anInt1626 + 100]; - anIntArray1623 = new int[anInt1626 + 100]; - anIntArray1624 = new int[anInt1626 + 100]; + /** + * Sets this model to the provided model using a vertex pool. + *

+ * Face alpha may be optionally copied in case an applied {@link SeqFrame} modifies the alpha of the model. + * + * @param model the model. + * @param shareAlpha whether to copy or share a reference to face alphas. + */ + public void set(Model model, boolean shareAlpha) { + vertexCount = model.vertexCount; + faceCount = model.faceCount; + texturedFaceCount = model.texturedFaceCount; + + if (tmpVertexX.length < vertexCount) { + tmpVertexX = new int[vertexCount + 100]; + tmpVertexY = new int[vertexCount + 100]; + tmpVertexZ = new int[vertexCount + 100]; } - anIntArray1627 = anIntArray1622; - anIntArray1628 = anIntArray1623; - anIntArray1629 = anIntArray1624; - for (int k = 0; k < anInt1626; k++) { - anIntArray1627[k] = model.anIntArray1627[k]; - anIntArray1628[k] = model.anIntArray1628[k]; - anIntArray1629[k] = model.anIntArray1629[k]; + + vertexX = tmpVertexX; + vertexY = tmpVertexY; + vertexZ = tmpVertexZ; + + for (int k = 0; k < vertexCount; k++) { + vertexX[k] = model.vertexX[k]; + vertexY[k] = model.vertexY[k]; + vertexZ[k] = model.vertexZ[k]; } - if (flag) { - anIntArray1639 = model.anIntArray1639; + + if (shareAlpha) { + faceAlpha = model.faceAlpha; } else { - if (anIntArray1625.length < anInt1630) { - anIntArray1625 = new int[anInt1630 + 100]; + if (tmpFaceAlpha.length < faceCount) { + tmpFaceAlpha = new int[faceCount + 100]; } - anIntArray1639 = anIntArray1625; - if (model.anIntArray1639 == null) { - for (int l = 0; l < anInt1630; l++) { - anIntArray1639[l] = 0; + faceAlpha = tmpFaceAlpha; + if (model.faceAlpha == null) { + for (int face = 0; face < faceCount; face++) { + faceAlpha[face] = 0; } } else { - for (int i1 = 0; i1 < anInt1630; i1++) { - anIntArray1639[i1] = model.anIntArray1639[i1]; + for (int face = 0; face < faceCount; face++) { + faceAlpha[face] = model.faceAlpha[face]; } } } - anIntArray1637 = model.anIntArray1637; - anIntArray1640 = model.anIntArray1640; - anIntArray1638 = model.anIntArray1638; - anInt1641 = model.anInt1641; - anIntArrayArray1658 = model.anIntArrayArray1658; - anIntArrayArray1657 = model.anIntArrayArray1657; - anIntArray1631 = model.anIntArray1631; - anIntArray1632 = model.anIntArray1632; - anIntArray1633 = model.anIntArray1633; - anIntArray1634 = model.anIntArray1634; - anIntArray1635 = model.anIntArray1635; - anIntArray1636 = model.anIntArray1636; - anIntArray1643 = model.anIntArray1643; - anIntArray1644 = model.anIntArray1644; - anIntArray1645 = model.anIntArray1645; + + faceInfo = model.faceInfo; + faceColor = model.faceColor; + facePriority = model.facePriority; + priority = model.priority; + labelFaces = model.labelFaces; + labelVertices = model.labelVertices; + faceVertexA = model.faceVertexA; + faceVertexB = model.faceVertexB; + faceVertexC = model.faceVertexC; + faceColorA = model.faceColorA; + faceColorB = model.faceColorB; + faceColorC = model.faceColorC; + texturedVertexA = model.texturedVertexA; + texturedVertexB = model.texturedVertexB; + texturedVertexC = model.texturedVertexC; } - public int method465(Model model, int i) { - int j = -1; - int k = model.anIntArray1627[i]; - int l = model.anIntArray1628[i]; - int i1 = model.anIntArray1629[i]; - for (int j1 = 0; j1 < anInt1626; j1++) { - if (k != anIntArray1627[j1] || l != anIntArray1628[j1] || i1 != anIntArray1629[j1]) { + /** + * Adds vertexId from src to this. Reuses vertex if one already exists at the + * same location. + * + * @param src the source model. + * @param vertexId the vertex id to add from the src. + * @return the vertex id of the added vertex. + */ + public int addVertex(Model src, int vertexId) { + int x = src.vertexX[vertexId]; + int y = src.vertexY[vertexId]; + int z = src.vertexZ[vertexId]; + + int identical = -1; + for (int v = 0; v < vertexCount; v++) { + if ((x == vertexX[v]) && (y == vertexY[v]) && (z == vertexZ[v])) { + identical = v; + break; + } + } + + // append new one if no matches were found + if (identical == -1) { + vertexX[vertexCount] = x; + vertexY[vertexCount] = y; + vertexZ[vertexCount] = z; + if (src.vertexLabel != null) { + vertexLabel[vertexCount] = src.vertexLabel[vertexId]; + } + identical = vertexCount++; + } + + return identical; + } + + /** + * Calculates {@link #minY}, {@link #maxY}, {@link #radius}, {@link #minDepth} and {@link #maxDepth}. + */ + public void calculateBoundsCylinder() { + super.minY = 0; + radius = 0; + maxY = 0; + for (int i = 0; i < vertexCount; i++) { + int x = vertexX[i]; + int y = vertexY[i]; + int z = vertexZ[i]; + if (-y > super.minY) { + super.minY = -y; + } + if (y > maxY) { + maxY = y; + } + int radiusSqr = (x * x) + (z * z); + if (radiusSqr > radius) { + radius = radiusSqr; + } + } + radius = (int) (Math.sqrt(radius) + 0.99); + minDepth = (int) (Math.sqrt((radius * radius) + (super.minY * super.minY)) + 0.99); + maxDepth = minDepth + (int) (Math.sqrt((radius * radius) + (maxY * maxY)) + 0.99); + } + + /** + * Calculates {@link #minY}, {@link #maxY}, {@link #minDepth} and {@link #maxDepth}. + */ + public void calculateBoundsY() { + super.minY = 0; + maxY = 0; + for (int i = 0; i < vertexCount; i++) { + int y = vertexY[i]; + if (-y > super.minY) { + super.minY = -y; + } + if (y > maxY) { + maxY = y; + } + } + minDepth = (int) (Math.sqrt((radius * radius) + (super.minY * super.minY)) + 0.99); + maxDepth = minDepth + (int) (Math.sqrt((radius * radius) + (maxY * maxY)) + 0.99); + } + + /** + * Calculates this models axis-aligned bounding box (AABB) and stores it. + */ + public void calculateBoundsAABB() { + super.minY = 0; + radius = 0; + maxY = 0; + minX = 999999; + maxX = -999999; + maxZ = -99999; + minZ = 99999; + for (int j = 0; j < vertexCount; j++) { + int x = vertexX[j]; + int y = vertexY[j]; + int z = vertexZ[j]; + if (x < minX) { + minX = x; + } + if (x > maxX) { + maxX = x; + } + if (z < minZ) { + minZ = z; + } + if (z > maxZ) { + maxZ = z; + } + if (-y > super.minY) { + super.minY = -y; + } + if (y > maxY) { + maxY = y; + } + int radiusSqr = (x * x) + (z * z); + if (radiusSqr > radius) { + radius = radiusSqr; + } + } + radius = (int) Math.sqrt(radius); + minDepth = (int) Math.sqrt((radius * radius) + (super.minY * super.minY)); + maxDepth = minDepth + (int) Math.sqrt((radius * radius) + (maxY * maxY)); + } + + /** + * Builds {@link #labelVertices} and {@link #labelFaces} using {@link #vertexLabel} and {@link #faceLabel}. + *

+ * This method is destructive, meaning it sets {@link #vertexLabel} and {@link #faceLabel} to null + * after being called. + *

+ * This method is required for applying animations to a model and should only be called once on a single instance + * of a {@link Model}. + * + * @see #applySequenceFrame(int) + * @see #applySequenceFrames(int, int, int[]) + * @see #applyTransform(int, int[], int, int, int) + */ + public void createLabelReferences() { + if (vertexLabel != null) { + int[] labelVertexCount = new int[256]; + + int count = 0; + for (int v = 0; v < vertexCount; v++) { + int label = vertexLabel[v]; + labelVertexCount[label]++; + if (label > count) { + count = label; + } + } + + labelVertices = new int[count + 1][]; + + for (int label = 0; label <= count; label++) { + labelVertices[label] = new int[labelVertexCount[label]]; + labelVertexCount[label] = 0; + } + + for (int v = 0; v < vertexCount; v++) { + int label = vertexLabel[v]; + labelVertices[label][labelVertexCount[label]++] = v; + } + + vertexLabel = null; + } + + if (faceLabel != null) { + int[] labelFaceCount = new int[256]; + + int count = 0; + for (int f = 0; f < faceCount; f++) { + int label = faceLabel[f]; + labelFaceCount[label]++; + if (label > count) { + count = label; + } + } + + labelFaces = new int[count + 1][]; + for (int label = 0; label <= count; label++) { + labelFaces[label] = new int[labelFaceCount[label]]; + labelFaceCount[label] = 0; + } + + for (int face = 0; face < faceCount; face++) { + int label = faceLabel[face]; + labelFaces[label][labelFaceCount[label]++] = face; + } + + faceLabel = null; + } + } + + /** + * Applies a {@link SeqFrame} of the specified id. + * + * @param frameId the frame id. + */ + public void applySequenceFrame(int frameId) { + if (labelVertices == null) { + return; + } + if (frameId == -1) { + return; + } + SeqFrame frame = SeqFrame.get(frameId); + if (frame == null) { + return; + } + SeqSkeleton skeleton = frame.skeleton; + baseX = 0; + baseY = 0; + baseZ = 0; + for (int i = 0; i < frame.length; i++) { + int base = frame.bases[i]; + applyTransform(skeleton.baseTypes[base], skeleton.baseLabels[base], frame.x[i], frame.y[i], frame.z[i]); + } + } + + /** + * Applies the specified {@link SeqFrame} ids. + * + * @param frameId1 the primary frame id. + * @param frameId2 the secondary frame id. + * @param mask the mask contains base ids to prevent the primary frame from using the same bases as the secondary frame. + */ + public void applySequenceFrames(int frameId1, int frameId2, int[] mask) { + if (frameId1 == -1) { + return; + } + + if ((mask == null) || (frameId2 == -1)) { + applySequenceFrame(frameId1); + return; + } + + SeqFrame frame0 = SeqFrame.get(frameId1); + + if (frame0 == null) { + return; + } + + SeqFrame frame1 = SeqFrame.get(frameId2); + + if (frame1 == null) { + applySequenceFrame(frameId1); + return; + } + + SeqSkeleton skeleton = frame0.skeleton; + + baseX = 0; + baseY = 0; + baseZ = 0; + + int counter = 0; + int maskBase = mask[counter++]; + + for (int i = 0; i < frame0.length; i++) { + int base = frame0.bases[i]; + + while (base > maskBase) { + maskBase = mask[counter++]; + } + + if ((base != maskBase) || (skeleton.baseTypes[base] == 0)) { + applyTransform(skeleton.baseTypes[base], skeleton.baseLabels[base], frame0.x[i], frame0.y[i], frame0.z[i]); + } + } + + baseX = 0; + baseY = 0; + baseZ = 0; + + counter = 0; + maskBase = mask[counter++]; + + for (int frame = 0; frame < frame1.length; frame++) { + int group = frame1.bases[frame]; + + while (group > maskBase) { + maskBase = mask[counter++]; + } + + if ((group == maskBase) || (skeleton.baseTypes[group] == 0)) { + applyTransform(skeleton.baseTypes[group], skeleton.baseLabels[group], frame1.x[frame], frame1.y[frame], frame1.z[frame]); + } + } + } + + /** + * Applies a transform of the given type to the specified list of labels using the parameters + * x, y, z. + * + * @param type the transform type. + * @param labels the transform labels. + * @param x the param x. + * @param y the param y. + * @param z the param z. + * @see #applySequenceFrames(int, int, int[]) + * @see #applySequenceFrame(int) + * @see SeqSkeleton#OP_BASE + * @see SeqSkeleton#OP_TRANSLATE + * @see SeqSkeleton#OP_ROTATE + * @see SeqSkeleton#OP_SCALE + * @see SeqSkeleton#OP_ALPHA + */ + public void applyTransform(int type, int[] labels, int x, int y, int z) { + switch (type) { + case SeqSkeleton.OP_BASE: + int count = 0; + baseX = 0; + baseY = 0; + baseZ = 0; + for (int label : labels) { + if (label >= labelVertices.length) { + continue; + } + int[] vertices = labelVertices[label]; + for (int v : vertices) { + baseX += vertexX[v]; + baseY += vertexY[v]; + baseZ += vertexZ[v]; + count++; + } + } + if (count > 0) { + baseX = (baseX / count) + x; + baseY = (baseY / count) + y; + baseZ = (baseZ / count) + z; + } else { + baseX = x; + baseY = y; + baseZ = z; + } + break; + case SeqSkeleton.OP_TRANSLATE: + for (int group : labels) { + if (group >= labelVertices.length) { + continue; + } + int[] vertices = labelVertices[group]; + for (int v : vertices) { + vertexX[v] += x; + vertexY[v] += y; + vertexZ[v] += z; + } + } + break; + case SeqSkeleton.OP_ROTATE: + for (int label : labels) { + if (label >= labelVertices.length) { + continue; + } + int[] vertices = labelVertices[label]; + for (int v : vertices) { + vertexX[v] -= baseX; + vertexY[v] -= baseY; + vertexZ[v] -= baseZ; + int pitch = (x & 0xff) * 8; + int yaw = (y & 0xff) * 8; + int roll = (z & 0xff) * 8; + if (roll != 0) { + int sin = Model.sin[roll]; + int cos = Model.cos[roll]; + int x_ = ((vertexY[v] * sin) + (vertexX[v] * cos)) >> 16; + vertexY[v] = ((vertexY[v] * cos) - (vertexX[v] * sin)) >> 16; + vertexX[v] = x_; + } + if (pitch != 0) { + int sin = Model.sin[pitch]; + int cos = Model.cos[pitch]; + int y_ = ((vertexY[v] * cos) - (vertexZ[v] * sin)) >> 16; + vertexZ[v] = ((vertexY[v] * sin) + (vertexZ[v] * cos)) >> 16; + vertexY[v] = y_; + } + if (yaw != 0) { + int sin = Model.sin[yaw]; + int cos = Model.cos[yaw]; + int x_ = ((vertexZ[v] * sin) + (vertexX[v] * cos)) >> 16; + vertexZ[v] = ((vertexZ[v] * cos) - (vertexX[v] * sin)) >> 16; + vertexX[v] = x_; + } + vertexX[v] += baseX; + vertexY[v] += baseY; + vertexZ[v] += baseZ; + } + } + break; + case SeqSkeleton.OP_SCALE: + for (int label : labels) { + if (label >= labelVertices.length) { + continue; + } + int[] vertices = labelVertices[label]; + for (int v : vertices) { + vertexX[v] -= baseX; + vertexY[v] -= baseY; + vertexZ[v] -= baseZ; + vertexX[v] = (vertexX[v] * x) / 128; + vertexY[v] = (vertexY[v] * y) / 128; + vertexZ[v] = (vertexZ[v] * z) / 128; + vertexX[v] += baseX; + vertexY[v] += baseY; + vertexZ[v] += baseZ; + } + } + break; + case SeqSkeleton.OP_ALPHA: + if ((labelFaces != null) && (faceAlpha != null)) { + for (int label : labels) { + if (label >= labelFaces.length) { + continue; + } + int[] triangles = labelFaces[label]; + for (int t : triangles) { + faceAlpha[t] += x * 8; + if (faceAlpha[t] < 0) { + faceAlpha[t] = 0; + } + if (faceAlpha[t] > 255) { + faceAlpha[t] = 255; + } + } + } + } + break; + } + } + + /** + * Rotates clockwise on the Y axis by 90 degrees. + */ + public void rotateY90() { + for (int v = 0; v < vertexCount; v++) { + int x_ = vertexX[v]; + vertexX[v] = vertexZ[v]; + vertexZ[v] = -x_; + } + } + + /** + * Rotates the model on the X/Pitch axis. + * + * @param angle the angle. + */ + public void rotateX(int angle) { + int sin = Model.sin[angle]; + int cos = Model.cos[angle]; + for (int v = 0; v < vertexCount; v++) { + int y_ = ((vertexY[v] * cos) - (vertexZ[v] * sin)) >> 16; + vertexZ[v] = ((vertexY[v] * sin) + (vertexZ[v] * cos)) >> 16; + vertexY[v] = y_; + } + } + + /** + * Translates the model by the offset provided. + * + * @param x the x. + * @param y the y. + * @param z the z. + */ + public void translate(int x, int y, int z) { + for (int v = 0; v < vertexCount; v++) { + vertexX[v] += x; + vertexY[v] += y; + vertexZ[v] += z; + } + } + + /** + * Replaces use of the color src with color dst. + * + * @param src the source texture id. + * @param dst the destination texture id. + */ + public void replaceColor(int src, int dst) { + for (int k = 0; k < faceCount; k++) { + if (faceColor[k] == src) { + faceColor[k] = dst; + } + } + } + + /** + * Performs the equivalent operation of rotating the entire model on the Y axis by 180 degrees. + */ + public void rotateY180() { + for (int v = 0; v < vertexCount; v++) { + vertexZ[v] = -vertexZ[v]; + } + for (int f = 0; f < faceCount; f++) { + int a = faceVertexA[f]; + faceVertexA[f] = faceVertexC[f]; + faceVertexC[f] = a; + } + } + + /** + * Scales the model. This method assumes 25.7 fixed-point integers, which means the value 1.0 will be 1<<7 + * or 128. + * + * @param x the x scalar. + * @param y the y scalar. + * @param z the z scalar. + */ + public void scale(int x, int y, int z) { + for (int v = 0; v < vertexCount; v++) { + vertexX[v] = (vertexX[v] * x) / 128; + vertexY[v] = (vertexY[v] * z) / 128; + vertexZ[v] = (vertexZ[v] * y) / 128; + } + } + + /** + * Recalculates the normals and optionally applies the lighting immediately after. This method can be + * destructive if applyLighting is set to true. + * + * @param lightAmbient the ambient light. + * @param lightAttenuation the light attenuation. + * @param lightSrcX the light source x. + * @param lightSrcY the light source y. + * @param lightSrcZ the light source z. + * @param applyLighting true to invoke {@link #applyLighting(int, int, int, int, int)} after normals are + * calculated. + * @see #applyLighting(int, int, int, int, int) + */ + public void calculateNormals(int lightAmbient, int lightAttenuation, int lightSrcX, int lightSrcY, int lightSrcZ, boolean applyLighting) { + int lightMagnitude = (int) Math.sqrt((lightSrcX * lightSrcX) + (lightSrcY * lightSrcY) + (lightSrcZ * lightSrcZ)); + int attenuation = (lightAttenuation * lightMagnitude) >> 8; + + if (faceColorA == null) { + faceColorA = new int[faceCount]; + faceColorB = new int[faceCount]; + faceColorC = new int[faceCount]; + } + + if (super.vertexNormal == null) { + super.vertexNormal = new VertexNormal[vertexCount]; + for (int v = 0; v < vertexCount; v++) { + super.vertexNormal[v] = new VertexNormal(); + } + } + + for (int f = 0; f < faceCount; f++) { + int a = faceVertexA[f]; + int b = faceVertexB[f]; + int c = faceVertexC[f]; + int dxAB = vertexX[b] - vertexX[a]; + int dyAB = vertexY[b] - vertexY[a]; + int dzAB = vertexZ[b] - vertexZ[a]; + int dxAC = vertexX[c] - vertexX[a]; + int dyAC = vertexY[c] - vertexY[a]; + int dzAC = vertexZ[c] - vertexZ[a]; + + int nx = (dyAB * dzAC) - (dyAC * dzAB); + int ny = (dzAB * dxAC) - (dzAC * dxAB); + int nz = (dxAB * dyAC) - (dxAC * dyAB); + + while ((nx > 8192) || (ny > 8192) || (nz > 8192) || (nx < -8192) || (ny < -8192) || (nz < -8192)) { + nx >>= 1; + ny >>= 1; + nz >>= 1; + } + + int length = (int) Math.sqrt((nx * nx) + (ny * ny) + (nz * nz)); + + if (length <= 0) { + length = 1; + } + + // normalize + nx = (nx * 256) / length; + ny = (ny * 256) / length; + nz = (nz * 256) / length; + + if ((faceInfo == null) || ((faceInfo[f] & 1) == 0)) { + VertexNormal n = super.vertexNormal[a]; + n.x += nx; + n.y += ny; + n.z += nz; + n.w++; + n = super.vertexNormal[b]; + n.x += nx; + n.y += ny; + n.z += nz; + n.w++; + n = super.vertexNormal[c]; + n.x += nx; + n.y += ny; + n.z += nz; + n.w++; + } else { + int lightness = lightAmbient + (((lightSrcX * nx) + (lightSrcY * ny) + (lightSrcZ * nz)) / (attenuation + (attenuation / 2))); + faceColorA[f] = mulColorLightness(faceColor[f], lightness, faceInfo[f]); + } + } + + if (applyLighting) { + applyLighting(lightAmbient, attenuation, lightSrcX, lightSrcY, lightSrcZ); + } else { + vertexNormalOriginal = new VertexNormal[vertexCount]; + + for (int v = 0; v < vertexCount; v++) { + VertexNormal normal = super.vertexNormal[v]; + VertexNormal copy = vertexNormalOriginal[v] = new VertexNormal(); + copy.x = normal.x; + copy.y = normal.y; + copy.z = normal.z; + copy.w = normal.w; + } + } + + if (applyLighting) { + calculateBoundsCylinder(); + } else { + calculateBoundsAABB(); + } + } + + /** + * Calculates the lightness values for all faces using the provided lighting parameters. This method is destructive + * and nullifies normals and labels, which means it is meant to be applied once to a model. + * + * @param lightAmbient the ambient lighting value. [0...127] + * @param lightAttenuation the light attenuation. + * @param lightSrcX the light source x. + * @param lightSrcY the light source y. + * @param lightSrcZ the light source z. + */ + public void applyLighting(int lightAmbient, int lightAttenuation, int lightSrcX, int lightSrcY, int lightSrcZ) { + for (int f = 0; f < faceCount; f++) { + int a = faceVertexA[f]; + int b = faceVertexB[f]; + int c = faceVertexC[f]; + + if (faceInfo == null) { + int color = faceColor[f]; + + VertexNormal n = super.vertexNormal[a]; + int lightness = lightAmbient + (((lightSrcX * n.x) + (lightSrcY * n.y) + (lightSrcZ * n.z)) / (lightAttenuation * n.w)); + faceColorA[f] = mulColorLightness(color, lightness, 0); + + n = super.vertexNormal[b]; + lightness = lightAmbient + (((lightSrcX * n.x) + (lightSrcY * n.y) + (lightSrcZ * n.z)) / (lightAttenuation * n.w)); + faceColorB[f] = mulColorLightness(color, lightness, 0); + + n = super.vertexNormal[c]; + lightness = lightAmbient + (((lightSrcX * n.x) + (lightSrcY * n.y) + (lightSrcZ * n.z)) / (lightAttenuation * n.w)); + faceColorC[f] = mulColorLightness(color, lightness, 0); + } else if ((faceInfo[f] & 1) == 0) { + int color = faceColor[f]; + int info = faceInfo[f]; + + VertexNormal n = super.vertexNormal[a]; + int lightness = lightAmbient + (((lightSrcX * n.x) + (lightSrcY * n.y) + (lightSrcZ * n.z)) / (lightAttenuation * n.w)); + faceColorA[f] = mulColorLightness(color, lightness, info); + + n = super.vertexNormal[b]; + lightness = lightAmbient + (((lightSrcX * n.x) + (lightSrcY * n.y) + (lightSrcZ * n.z)) / (lightAttenuation * n.w)); + faceColorB[f] = mulColorLightness(color, lightness, info); + + n = super.vertexNormal[c]; + lightness = lightAmbient + (((lightSrcX * n.x) + (lightSrcY * n.y) + (lightSrcZ * n.z)) / (lightAttenuation * n.w)); + faceColorC[f] = mulColorLightness(color, lightness, info); + } + } + + super.vertexNormal = null; + vertexNormalOriginal = null; + vertexLabel = null; + faceLabel = null; + + if (faceInfo != null) { + for (int f = 0; f < faceCount; f++) { + if ((faceInfo[f] & 2) == 2) { + return; + } + } + } + + faceColor = null; + } + + /** + * Draws this model with reduced parameters. + * + * @param pitch the model pitch. + * @param yaw the model yaw. + * @param roll the model roll. + * @param eyePitch the eye pitch. + * @param eyeX the eye x. + * @param eyeY the eye y. + * @param eyeZ the eye z. + */ + public void drawSimple(int pitch, int yaw, int roll, int eyePitch, int eyeX, int eyeY, int eyeZ) { + int centerX = Draw3D.centerX; + int centerY = Draw3D.centerY; + int sinPitch = sin[pitch]; + int cosPitch = cos[pitch]; + int sinYaw = sin[yaw]; + int cosYaw = cos[yaw]; + int sinRoll = sin[roll]; + int cosRoll = cos[roll]; + int sinEyePitch = sin[eyePitch]; + int cosEyePitch = cos[eyePitch]; + int midZ = ((eyeY * sinEyePitch) + (eyeZ * cosEyePitch)) >> 16; + + for (int v = 0; v < vertexCount; v++) { + int x = vertexX[v]; + int y = vertexY[v]; + int z = vertexZ[v]; + + // Local Space -> Model Space + + if (roll != 0) { + int x_ = ((y * sinRoll) + (x * cosRoll)) >> 16; + y = ((y * cosRoll) - (x * sinRoll)) >> 16; + x = x_; + } + + if (pitch != 0) { + int y_ = ((y * cosPitch) - (z * sinPitch)) >> 16; + z = ((y * sinPitch) + (z * cosPitch)) >> 16; + y = y_; + } + + if (yaw != 0) { + int x_ = ((z * sinYaw) + (x * cosYaw)) >> 16; + z = ((z * cosYaw) - (x * sinYaw)) >> 16; + x = x_; + } + + // Model Space -> View Space + + x += eyeX; + y += eyeY; + z += eyeZ; + + int y_ = ((y * cosEyePitch) - (z * sinEyePitch)) >> 16; + z = ((y * sinEyePitch) + (z * cosEyePitch)) >> 16; + y = y_; + + // View Space -> Screen Space + + vertexScreenX[v] = centerX + ((x << 9) / z); + vertexScreenY[v] = centerY + ((y << 9) / z); + vertexScreenZ[v] = z - midZ; + + // Store viewspace coordinates to be transformed into screen space later (textured or clipped triangles) + + if (texturedFaceCount > 0) { + vertexViewSpaceX[v] = x; + vertexViewSpaceY[v] = y; + vertexViewSpaceZ[v] = z; + } + } + try { + draw(false, false, 0); + } catch (Exception ignored) { + } + } + + /** + * Draws this model. + * + * @param yaw the yaw of this model. + * @param sinEyePitch the sin(eyePitch). + * @param cosEyePitch the cos(eyePitch). + * @param sinEyeYaw the sin(eyeYaw). + * @param cosEyeYaw the cos(eyeYaw). + * @param relativeX the relative x. (SceneX - EyeX) + * @param relativeY the relative y. (SceneY - EyeY) + * @param relativeZ the relative z. (SceneZ - EyeZ) + * @param bitset the bitset. + */ + @Override + public void draw(int yaw, int sinEyePitch, int cosEyePitch, int sinEyeYaw, int cosEyeYaw, int relativeX, int relativeY, int relativeZ, int bitset) { + // Relative coordinates are ScenePos - EyePos + + // z' is our relative z value rotated by eye yaw. + int zPrime = ((relativeZ * cosEyeYaw) - (relativeX * sinEyeYaw)) >> 16; + + // midZ is our relative z value rotated by eye yaw and pitch. It's the distance from the camera from the center + // of our model. + int midZ = ((relativeY * sinEyePitch) + (zPrime * cosEyePitch)) >> 16; + + // Our pitch is clamped between 128 and 384 (22.5 degrees and 67.5 degrees) + // We know this will be positive and within 92->38% its original value. + int radiusCosEyePitch = (this.radius * cosEyePitch) >> 16; + + // +Z goes forward, which makes this value supposedly the farthest Z the model should be away from the camera. + int maxZ = midZ + radiusCosEyePitch; + + // early z testing + if ((maxZ <= 50) || (midZ >= 3500)) { + return; + } + + // calculate x' + int midX = ((relativeZ * sinEyeYaw) + (relativeX * cosEyeYaw)) >> 16; + + // calculate left bound + int leftX = (midX - this.radius) << 9; + + // early fail + if ((leftX / maxZ) >= Draw2D.centerX) { + return; + } + + // calculate right bound + int rightX = (midX + this.radius) << 9; + + // early fail + if ((rightX / maxZ) <= -Draw2D.centerX) { + return; + } + + // midY is our relative y value rotated by eye pitch + int midY = ((relativeY * cosEyePitch) - (zPrime * sinEyePitch)) >> 16; + + // Our pitch is clamped between 128 and 384 (22.5 degrees and 67.5 degrees) + // We know this will be positive and within 38->92% its original value. + int radiusSinEyePitch = (this.radius * sinEyePitch) >> 16; + + // calculate bottom bound + int bottomY = (midY + radiusSinEyePitch) << 9; + + // early fail + if ((bottomY / maxZ) <= -Draw2D.centerY) { + return; + } + + // y' = (radius * sin(eyePitch)) + (minY * cos(eyePitch)) + int yPrime = radiusSinEyePitch + ((super.minY * cosEyePitch) >> 16); + + // calculate top boundary + int topY = (midY - yPrime) << 9; + + // early fail + if ((topY / maxZ) >= Draw2D.centerY) { + return; + } + + // (minY * sin(eyePitch)) + (radius * cos(eyePitch)) + int radiusZ = ((super.minY * sinEyePitch) >> 16) + radiusCosEyePitch; + + boolean clipped = (midZ - radiusZ) <= 50; + boolean picking = false; + + if ((bitset > 0) && Model.checkHover) { + int z = midZ - radiusCosEyePitch; + + if (z <= 50) { + z = 50; + } + + if (midX > 0) { + leftX /= maxZ; + rightX /= z; + } else { + rightX /= maxZ; + leftX /= z; + } + + if (midY > 0) { + topY /= maxZ; + bottomY /= z; + } else { + bottomY /= maxZ; + topY /= z; + } + + int mouseX = Model.mouseX - Draw3D.centerX; + int mouseY = Model.mouseY - Draw3D.centerY; + + if ((mouseX > leftX) && (mouseX < rightX) && (mouseY > topY) && (mouseY < bottomY)) { + if (pickBounds) { + pickedBitsets[pickedCount++] = bitset; + } else { + picking = true; + } + } + } + + int centerX = Draw3D.centerX; + int centerY = Draw3D.centerY; + int sinYaw = 0; + int cosYaw = 0; + + if (yaw != 0) { + sinYaw = sin[yaw]; + cosYaw = cos[yaw]; + } + + for (int v = 0; v < vertexCount; v++) { + int x = vertexX[v]; + int y = vertexY[v]; + int z = vertexZ[v]; + + // Local Space -> Model Space + + if (yaw != 0) { + int x_ = ((z * sinYaw) + (x * cosYaw)) >> 16; + z = ((z * cosYaw) - (x * sinYaw)) >> 16; + x = x_; + } + + // Model Space -> View Space + + x += relativeX; + y += relativeY; + z += relativeZ; + + // Rotate on Y axis (Yaw) + int tmp = ((z * sinEyeYaw) + (x * cosEyeYaw)) >> 16; + z = ((z * cosEyeYaw) - (x * sinEyeYaw)) >> 16; + x = tmp; + + // Rotate on X axis (Pitch) + tmp = ((y * cosEyePitch) - (z * sinEyePitch)) >> 16; + z = ((y * sinEyePitch) + (z * cosEyePitch)) >> 16; + y = tmp; + + if (z >= 50) { + vertexScreenX[v] = centerX + ((x << 9) / z); + vertexScreenY[v] = centerY + ((y << 9) / z); + } else { + vertexScreenX[v] = -5000; // used in drawTriangle to denote a near-clipped triangle. + clipped = true; + } + + vertexScreenZ[v] = z - midZ; + + if (clipped || (texturedFaceCount > 0)) { + vertexViewSpaceX[v] = x; + vertexViewSpaceY[v] = y; + vertexViewSpaceZ[v] = z; + } + } + try { + draw(clipped, picking, bitset); + } catch (Exception ignored) { + } + } + + /** + * Draws the {@link Model} with the provided parameters. This method performs depth and priority sorting. + * + * @param clipped whether to check near plane clipping. + * @param picking true to enable picking. + * @param bitset the bitset. Used with pick set to true. + */ + public void draw(boolean clipped, boolean picking, int bitset) { + for (int depth = 0; depth < maxDepth; depth++) { + tmpDepthFaceCount[depth] = 0; + } + + for (int f = 0; f < this.faceCount; f++) { + if ((faceInfo != null) && (faceInfo[f] == -1)) { continue; } - j = j1; - break; - } - if (j == -1) { - anIntArray1627[anInt1626] = k; - anIntArray1628[anInt1626] = l; - anIntArray1629[anInt1626] = i1; - if (model.anIntArray1655 != null) { - anIntArray1655[anInt1626] = model.anIntArray1655[i]; - } - j = anInt1626++; - } - return j; - } - public void method466() { - super.anInt1426 = 0; - anInt1650 = 0; - anInt1651 = 0; - for (int i = 0; i < anInt1626; i++) { - int j = anIntArray1627[i]; - int k = anIntArray1628[i]; - int l = anIntArray1629[i]; - if (-k > super.anInt1426) { - super.anInt1426 = -k; - } - if (k > anInt1651) { - anInt1651 = k; - } - int i1 = j * j + l * l; - if (i1 > anInt1650) { - anInt1650 = i1; - } - } - anInt1650 = (int) (Math.sqrt(anInt1650) + 0.98999999999999999D); - anInt1653 = (int) (Math.sqrt(anInt1650 * anInt1650 + super.anInt1426 * super.anInt1426) + 0.98999999999999999D); - anInt1652 = anInt1653 + (int) (Math.sqrt(anInt1650 * anInt1650 + anInt1651 * anInt1651) + 0.98999999999999999D); - } + int a = faceVertexA[f]; + int b = faceVertexB[f]; + int c = faceVertexC[f]; + int xA = vertexScreenX[a]; + int xB = vertexScreenX[b]; + int xC = vertexScreenX[c]; - public void method467() { - super.anInt1426 = 0; - anInt1651 = 0; - for (int i = 0; i < anInt1626; i++) { - int j = anIntArray1628[i]; - if (-j > super.anInt1426) { - super.anInt1426 = -j; - } - if (j > anInt1651) { - anInt1651 = j; - } - } - anInt1653 = (int) (Math.sqrt(anInt1650 * anInt1650 + super.anInt1426 * super.anInt1426) + 0.98999999999999999D); - anInt1652 = anInt1653 + (int) (Math.sqrt(anInt1650 * anInt1650 + anInt1651 * anInt1651) + 0.98999999999999999D); - } - - public void method468() { - super.anInt1426 = 0; - anInt1650 = 0; - anInt1651 = 0; - anInt1646 = 999999; - anInt1647 = -999999; - anInt1648 = -99999; - anInt1649 = 99999; - for (int j = 0; j < anInt1626; j++) { - int k = anIntArray1627[j]; - int l = anIntArray1628[j]; - int i1 = anIntArray1629[j]; - if (k < anInt1646) { - anInt1646 = k; - } - if (k > anInt1647) { - anInt1647 = k; - } - if (i1 < anInt1649) { - anInt1649 = i1; - } - if (i1 > anInt1648) { - anInt1648 = i1; - } - if (-l > super.anInt1426) { - super.anInt1426 = -l; - } - if (l > anInt1651) { - anInt1651 = l; - } - int j1 = k * k + i1 * i1; - if (j1 > anInt1650) { - anInt1650 = j1; - } - } - anInt1650 = (int) Math.sqrt(anInt1650); - anInt1653 = (int) Math.sqrt(anInt1650 * anInt1650 + super.anInt1426 * super.anInt1426); - anInt1652 = anInt1653 + (int) Math.sqrt(anInt1650 * anInt1650 + anInt1651 * anInt1651); - } - - public void method469() { - if (anIntArray1655 != null) { - int[] ai = new int[256]; - int j = 0; - for (int l = 0; l < anInt1626; l++) { - int j1 = anIntArray1655[l]; - ai[j1]++; - if (j1 > j) { - j = j1; - } - } - anIntArrayArray1657 = new int[j + 1][]; - for (int k1 = 0; k1 <= j; k1++) { - anIntArrayArray1657[k1] = new int[ai[k1]]; - ai[k1] = 0; - } - for (int j2 = 0; j2 < anInt1626; j2++) { - int l2 = anIntArray1655[j2]; - anIntArrayArray1657[l2][ai[l2]++] = j2; - } - anIntArray1655 = null; - } - if (anIntArray1656 != null) { - int[] ai1 = new int[256]; - int k = 0; - for (int i1 = 0; i1 < anInt1630; i1++) { - int l1 = anIntArray1656[i1]; - ai1[l1]++; - if (l1 > k) { - k = l1; - } - } - anIntArrayArray1658 = new int[k + 1][]; - for (int i2 = 0; i2 <= k; i2++) { - anIntArrayArray1658[i2] = new int[ai1[i2]]; - ai1[i2] = 0; - } - for (int k2 = 0; k2 < anInt1630; k2++) { - int i3 = anIntArray1656[k2]; - anIntArrayArray1658[i3][ai1[i3]++] = k2; - } - anIntArray1656 = null; - } - } - - public void method470(int i) { - if (anIntArrayArray1657 == null) { - return; - } - if (i == -1) { - return; - } - SeqTransform transform = SeqTransform.method531(i); - if (transform == null) { - return; - } - SeqSkeleton skeleton = transform.aSkeleton_637; - anInt1681 = 0; - anInt1682 = 0; - anInt1683 = 0; - for (int k = 0; k < transform.anInt638; k++) { - int l = transform.anIntArray639[k]; - method472(skeleton.anIntArray342[l], skeleton.anIntArrayArray343[l], transform.anIntArray640[k], transform.anIntArray641[k], transform.anIntArray642[k]); - } - } - - public void method471(int[] ai, int j, int k) { - if (k == -1) { - return; - } - if (ai == null || j == -1) { - method470(k); - return; - } - SeqTransform transform = SeqTransform.method531(k); - if (transform == null) { - return; - } - SeqTransform transform_1 = SeqTransform.method531(j); - if (transform_1 == null) { - method470(k); - return; - } - SeqSkeleton skeleton = transform.aSkeleton_637; - anInt1681 = 0; - anInt1682 = 0; - anInt1683 = 0; - int l = 0; - int i1 = ai[l++]; - for (int j1 = 0; j1 < transform.anInt638; j1++) { - int k1; - for (k1 = transform.anIntArray639[j1]; k1 > i1; i1 = ai[l++]) { - } - if (k1 != i1 || skeleton.anIntArray342[k1] == 0) { - method472(skeleton.anIntArray342[k1], skeleton.anIntArrayArray343[k1], transform.anIntArray640[j1], transform.anIntArray641[j1], transform.anIntArray642[j1]); - } - } - anInt1681 = 0; - anInt1682 = 0; - anInt1683 = 0; - l = 0; - i1 = ai[l++]; - for (int l1 = 0; l1 < transform_1.anInt638; l1++) { - int i2; - for (i2 = transform_1.anIntArray639[l1]; i2 > i1; i1 = ai[l++]) { - } - if (i2 == i1 || skeleton.anIntArray342[i2] == 0) { - method472(skeleton.anIntArray342[i2], skeleton.anIntArrayArray343[i2], transform_1.anIntArray640[l1], transform_1.anIntArray641[l1], transform_1.anIntArray642[l1]); - } - } - } - - public void method472(int i, int[] ai, int j, int k, int l) { - if (i == 0) { - int j1 = 0; - anInt1681 = 0; - anInt1682 = 0; - anInt1683 = 0; - for (int l3 : ai) { - if (l3 < anIntArrayArray1657.length) { - int[] ai5 = anIntArrayArray1657[l3]; - for (int j6 : ai5) { - anInt1681 += anIntArray1627[j6]; - anInt1682 += anIntArray1628[j6]; - anInt1683 += anIntArray1629[j6]; - j1++; - } - } - } - if (j1 > 0) { - anInt1681 = anInt1681 / j1 + j; - anInt1682 = anInt1682 / j1 + k; - anInt1683 = anInt1683 / j1 + l; + if (clipped && ((xA == -5000) || (xB == -5000) || (xC == -5000))) { + faceNearClipped[f] = true; + int depthAverage = ((vertexScreenZ[a] + vertexScreenZ[b] + vertexScreenZ[c]) / 3) + minDepth; + tmpDepthFaces[depthAverage][tmpDepthFaceCount[depthAverage]++] = f; } else { - anInt1681 = j; - anInt1682 = k; - anInt1683 = l; + if (picking && pointWithinTriangle(mouseX, mouseY, vertexScreenY[a], vertexScreenY[b], vertexScreenY[c], xA, xB, xC)) { + pickedBitsets[pickedCount++] = bitset; + picking = false; + } + + // Back-face culling + int dxAB = xA - xB; + int dyAB = vertexScreenY[a] - vertexScreenY[b]; + int dxCB = xC - xB; + int dyCB = vertexScreenY[c] - vertexScreenY[b]; + + if (((dxAB * dyCB) - (dyAB * dxCB)) <= 0) { + continue; + } + + faceNearClipped[f] = false; + faceClippedX[f] = (xA < 0) || (xB < 0) || (xC < 0) || (xA > Draw2D.boundX) || (xB > Draw2D.boundX) || (xC > Draw2D.boundX); + + int depthAverage = ((vertexScreenZ[a] + vertexScreenZ[b] + vertexScreenZ[c]) / 3) + minDepth; + tmpDepthFaces[depthAverage][tmpDepthFaceCount[depthAverage]++] = f; } - return; } - if (i == 1) { - for (int l2 : ai) { - if (l2 < anIntArrayArray1657.length) { - int[] ai1 = anIntArrayArray1657[l2]; - for (int j5 : ai1) { - anIntArray1627[j5] += j; - anIntArray1628[j5] += k; - anIntArray1629[j5] += l; + + if (facePriority == null) { + for (int depth = maxDepth - 1; depth >= 0; depth--) { + int count = tmpDepthFaceCount[depth]; + if (count > 0) { + int[] faces = tmpDepthFaces[depth]; + for (int f = 0; f < count; f++) { + drawFace(faces[f]); } } } return; } - if (i == 2) { - for (int i3 : ai) { - if (i3 < anIntArrayArray1657.length) { - int[] ai2 = anIntArrayArray1657[i3]; - for (int k5 : ai2) { - anIntArray1627[k5] -= anInt1681; - anIntArray1628[k5] -= anInt1682; - anIntArray1629[k5] -= anInt1683; - int k6 = (j & 0xff) * 8; - int l6 = (k & 0xff) * 8; - int i7 = (l & 0xff) * 8; - if (i7 != 0) { - int j7 = anIntArray1689[i7]; - int i8 = anIntArray1690[i7]; - int l8 = anIntArray1628[k5] * j7 + anIntArray1627[k5] * i8 >> 16; - anIntArray1628[k5] = anIntArray1628[k5] * i8 - anIntArray1627[k5] * j7 >> 16; - anIntArray1627[k5] = l8; - } - if (k6 != 0) { - int k7 = anIntArray1689[k6]; - int j8 = anIntArray1690[k6]; - int i9 = anIntArray1628[k5] * j8 - anIntArray1629[k5] * k7 >> 16; - anIntArray1629[k5] = anIntArray1628[k5] * k7 + anIntArray1629[k5] * j8 >> 16; - anIntArray1628[k5] = i9; - } - if (l6 != 0) { - int l7 = anIntArray1689[l6]; - int k8 = anIntArray1690[l6]; - int j9 = anIntArray1629[k5] * l7 + anIntArray1627[k5] * k8 >> 16; - anIntArray1629[k5] = anIntArray1629[k5] * k8 - anIntArray1627[k5] * l7 >> 16; - anIntArray1627[k5] = j9; - } - anIntArray1627[k5] += anInt1681; - anIntArray1628[k5] += anInt1682; - anIntArray1629[k5] += anInt1683; - } - } - } - return; + + for (int priority = 0; priority < 12; priority++) { + Model.tmpPriorityFaceCount[priority] = 0; + tmpPriorityDepthSum[priority] = 0; } - if (i == 3) { - for (int j3 : ai) { - if (j3 < anIntArrayArray1657.length) { - int[] ai3 = anIntArrayArray1657[j3]; - for (int l5 : ai3) { - anIntArray1627[l5] -= anInt1681; - anIntArray1628[l5] -= anInt1682; - anIntArray1629[l5] -= anInt1683; - anIntArray1627[l5] = (anIntArray1627[l5] * j) / 128; - anIntArray1628[l5] = (anIntArray1628[l5] * k) / 128; - anIntArray1629[l5] = (anIntArray1629[l5] * l) / 128; - anIntArray1627[l5] += anInt1681; - anIntArray1628[l5] += anInt1682; - anIntArray1629[l5] += anInt1683; - } - } + + for (int depth = maxDepth - 1; depth >= 0; depth--) { + int faceCount = tmpDepthFaceCount[depth]; + + if (faceCount <= 0) { + continue; } - return; - } - if (i == 5 && anIntArrayArray1658 != null && anIntArray1639 != null) { - for (int k3 : ai) { - if (k3 < anIntArrayArray1658.length) { - int[] ai4 = anIntArrayArray1658[k3]; - for (int i6 : ai4) { - anIntArray1639[i6] += j * 8; - if (anIntArray1639[i6] < 0) { - anIntArray1639[i6] = 0; - } - if (anIntArray1639[i6] > 255) { - anIntArray1639[i6] = 255; - } - } + + int[] faces = tmpDepthFaces[depth]; + + for (int i = 0; i < faceCount; i++) { + int face = faces[i]; + int priority = facePriority[face]; + int count = Model.tmpPriorityFaceCount[priority]++; + Model.tmpPriorityFaces[priority][count] = face; + + if (priority < 10) { + tmpPriorityDepthSum[priority] += depth; + } else if (priority == 10) { + tmpPriority10FaceDepth[count] = depth; + } else { + tmpPriority11FaceDepth[count] = depth; } } } - } - public void method473() { - for (int j = 0; j < anInt1626; j++) { - int k = anIntArray1627[j]; - anIntArray1627[j] = anIntArray1629[j]; - anIntArray1629[j] = -k; + // These are as the name implies, the average depth between two priorities. + int averagePriorityDepth1_2 = 0; + int averagePriorityDepth3_4 = 0; + int averagePriorityDepth6_8 = 0; + + // Don't think too hard about it. It's just a way of calculating averages with integers but with two sums averaged together. + + if ((Model.tmpPriorityFaceCount[1] > 0) || (Model.tmpPriorityFaceCount[2] > 0)) { + averagePriorityDepth1_2 = (tmpPriorityDepthSum[1] + tmpPriorityDepthSum[2]) / (Model.tmpPriorityFaceCount[1] + Model.tmpPriorityFaceCount[2]); } - } - public void method474(int i) { - int k = anIntArray1689[i]; - int l = anIntArray1690[i]; - for (int i1 = 0; i1 < anInt1626; i1++) { - int j1 = anIntArray1628[i1] * l - anIntArray1629[i1] * k >> 16; - anIntArray1629[i1] = anIntArray1628[i1] * k + anIntArray1629[i1] * l >> 16; - anIntArray1628[i1] = j1; + if ((Model.tmpPriorityFaceCount[3] > 0) || (Model.tmpPriorityFaceCount[4] > 0)) { + averagePriorityDepth3_4 = (tmpPriorityDepthSum[3] + tmpPriorityDepthSum[4]) / (Model.tmpPriorityFaceCount[3] + Model.tmpPriorityFaceCount[4]); } - } - public void method475(int i, int j, int l) { - for (int i1 = 0; i1 < anInt1626; i1++) { - anIntArray1627[i1] += i; - anIntArray1628[i1] += j; - anIntArray1629[i1] += l; + if ((Model.tmpPriorityFaceCount[6] > 0) || (Model.tmpPriorityFaceCount[8] > 0)) { + averagePriorityDepth6_8 = (tmpPriorityDepthSum[6] + tmpPriorityDepthSum[8]) / (Model.tmpPriorityFaceCount[6] + Model.tmpPriorityFaceCount[8]); } - } - public void method476(int i, int j) { - for (int k = 0; k < anInt1630; k++) { - if (anIntArray1640[k] == i) { - anIntArray1640[k] = j; + int priorityFace = 0; + int priorityFaceCount = Model.tmpPriorityFaceCount[10]; + int[] priorityFaces = Model.tmpPriorityFaces[10]; + int[] priorityFaceDepths = tmpPriority10FaceDepth; + + if (priorityFace == priorityFaceCount) { + priorityFace = 0; + priorityFaceCount = Model.tmpPriorityFaceCount[11]; + priorityFaces = Model.tmpPriorityFaces[11]; + priorityFaceDepths = tmpPriority11FaceDepth; + } + + int priorityDepth; + if (priorityFace < priorityFaceCount) { + priorityDepth = priorityFaceDepths[priorityFace]; + } else { + priorityDepth = -1000; + } + + // The code below essentially gives priorities 10 and 11 a chance to draw during priorities 0, 3, and 5 as long + // as the current face depth is slightly deeper than the current priority depth. You can think of that slightly + // deeper concept as a threshold to allow lower priority triangles to draw on top of higher priority triangles. + + // If they didn't do this then higher priority triangles would always draw on top, which look weird. + + for (int priority = 0; priority < 10; priority++) { + while ((priority == 0) && (priorityDepth > averagePriorityDepth1_2)) { + drawFace(priorityFaces[priorityFace++]); + + if ((priorityFace == priorityFaceCount) && (priorityFaces != Model.tmpPriorityFaces[11])) { + priorityFace = 0; + priorityFaceCount = Model.tmpPriorityFaceCount[11]; + priorityFaces = Model.tmpPriorityFaces[11]; + priorityFaceDepths = tmpPriority11FaceDepth; + } + + if (priorityFace < priorityFaceCount) { + priorityDepth = priorityFaceDepths[priorityFace]; + } else { + priorityDepth = -1000; + } + } + + while ((priority == 3) && (priorityDepth > averagePriorityDepth3_4)) { + drawFace(priorityFaces[priorityFace++]); + + if ((priorityFace == priorityFaceCount) && (priorityFaces != Model.tmpPriorityFaces[11])) { + priorityFace = 0; + priorityFaceCount = Model.tmpPriorityFaceCount[11]; + priorityFaces = Model.tmpPriorityFaces[11]; + priorityFaceDepths = tmpPriority11FaceDepth; + } + + if (priorityFace < priorityFaceCount) { + priorityDepth = priorityFaceDepths[priorityFace]; + } else { + priorityDepth = -1000; + } + } + + while ((priority == 5) && (priorityDepth > averagePriorityDepth6_8)) { + drawFace(priorityFaces[priorityFace++]); + + if ((priorityFace == priorityFaceCount) && (priorityFaces != Model.tmpPriorityFaces[11])) { + priorityFace = 0; + priorityFaceCount = Model.tmpPriorityFaceCount[11]; + priorityFaces = Model.tmpPriorityFaces[11]; + priorityFaceDepths = tmpPriority11FaceDepth; + } + + if (priorityFace < priorityFaceCount) { + priorityDepth = priorityFaceDepths[priorityFace]; + } else { + priorityDepth = -1000; + } + } + + int count = Model.tmpPriorityFaceCount[priority]; + int[] faces = Model.tmpPriorityFaces[priority]; + + for (int i = 0; i < count; i++) { + drawFace(faces[i]); } } - } - public void method477() { - for (int j = 0; j < anInt1626; j++) { - anIntArray1629[j] = -anIntArray1629[j]; - } - for (int k = 0; k < anInt1630; k++) { - int l = anIntArray1631[k]; - anIntArray1631[k] = anIntArray1633[k]; - anIntArray1633[k] = l; - } - } + // finish off remaining faces (priorities 10 and 11) - public void method478(int i, int j, int l) { - for (int i1 = 0; i1 < anInt1626; i1++) { - anIntArray1627[i1] = (anIntArray1627[i1] * i) / 128; - anIntArray1628[i1] = (anIntArray1628[i1] * l) / 128; - anIntArray1629[i1] = (anIntArray1629[i1] * j) / 128; - } - } + while (priorityDepth != -1000) { + drawFace(priorityFaces[priorityFace++]); - public void method479(int i, int j, int k, int l, int i1, boolean flag) { - int j1 = (int) Math.sqrt(k * k + l * l + i1 * i1); - int k1 = j * j1 >> 8; - if (anIntArray1634 == null) { - anIntArray1634 = new int[anInt1630]; - anIntArray1635 = new int[anInt1630]; - anIntArray1636 = new int[anInt1630]; - } - if (super.aNormalArray1425 == null) { - super.aNormalArray1425 = new VertexNormal[anInt1626]; - for (int l1 = 0; l1 < anInt1626; l1++) { - super.aNormalArray1425[l1] = new VertexNormal(); + if ((priorityFace == priorityFaceCount) && (priorityFaces != Model.tmpPriorityFaces[11])) { + priorityFace = 0; + priorityFaces = Model.tmpPriorityFaces[11]; + priorityFaceCount = Model.tmpPriorityFaceCount[11]; + priorityFaceDepths = tmpPriority11FaceDepth; } - } - for (int i2 = 0; i2 < anInt1630; i2++) { - int j2 = anIntArray1631[i2]; - int l2 = anIntArray1632[i2]; - int i3 = anIntArray1633[i2]; - int j3 = anIntArray1627[l2] - anIntArray1627[j2]; - int k3 = anIntArray1628[l2] - anIntArray1628[j2]; - int l3 = anIntArray1629[l2] - anIntArray1629[j2]; - int i4 = anIntArray1627[i3] - anIntArray1627[j2]; - int j4 = anIntArray1628[i3] - anIntArray1628[j2]; - int k4 = anIntArray1629[i3] - anIntArray1629[j2]; - int l4 = k3 * k4 - j4 * l3; - int i5 = l3 * i4 - k4 * j3; - int j5; - for (j5 = j3 * j4 - i4 * k3; l4 > 8192 || i5 > 8192 || j5 > 8192 || l4 < -8192 || i5 < -8192 || j5 < -8192; j5 >>= 1) { - l4 >>= 1; - i5 >>= 1; - } - int k5 = (int) Math.sqrt(l4 * l4 + i5 * i5 + j5 * j5); - if (k5 <= 0) { - k5 = 1; - } - l4 = (l4 * 256) / k5; - i5 = (i5 * 256) / k5; - j5 = (j5 * 256) / k5; - if (anIntArray1637 == null || (anIntArray1637[i2] & 1) == 0) { - VertexNormal normal_2 = super.aNormalArray1425[j2]; - normal_2.anInt602 += l4; - normal_2.anInt603 += i5; - normal_2.anInt604 += j5; - normal_2.anInt605++; - normal_2 = super.aNormalArray1425[l2]; - normal_2.anInt602 += l4; - normal_2.anInt603 += i5; - normal_2.anInt604 += j5; - normal_2.anInt605++; - normal_2 = super.aNormalArray1425[i3]; - normal_2.anInt602 += l4; - normal_2.anInt603 += i5; - normal_2.anInt604 += j5; - normal_2.anInt605++; + + if (priorityFace < priorityFaceCount) { + priorityDepth = priorityFaceDepths[priorityFace]; } else { - int l5 = i + (k * l4 + l * i5 + i1 * j5) / (k1 + k1 / 2); - anIntArray1634[i2] = method481(anIntArray1640[i2], l5, anIntArray1637[i2]); + priorityDepth = -1000; } } - if (flag) { - method480(i, k1, k, l, i1); + } + + /** + * Draws the provided face id. + * + * @param face the face id. + */ + public void drawFace(int face) { + if (faceNearClipped[face]) { + drawNearClippedFace(face); + return; + } + + int a = faceVertexA[face]; + int b = faceVertexB[face]; + int c = faceVertexC[face]; + Draw3D.clipX = faceClippedX[face]; + + if (faceAlpha == null) { + Draw3D.alpha = 0; } else { - aNormalArray1660 = new VertexNormal[anInt1626]; - for (int k2 = 0; k2 < anInt1626; k2++) { - VertexNormal normal = super.aNormalArray1425[k2]; - VertexNormal normal_1 = aNormalArray1660[k2] = new VertexNormal(); - normal_1.anInt602 = normal.anInt602; - normal_1.anInt603 = normal.anInt603; - normal_1.anInt604 = normal.anInt604; - normal_1.anInt605 = normal.anInt605; - } + Draw3D.alpha = faceAlpha[face]; } - if (flag) { - method466(); + + int type; + + if (faceInfo == null) { + type = 0; } else { - method468(); + type = faceInfo[face] & 0b11; + } + + if (type == 0) { + Draw3D.fillGouraudTriangle(vertexScreenY[a], vertexScreenY[b], vertexScreenY[c], vertexScreenX[a], vertexScreenX[b], vertexScreenX[c], faceColorA[face], faceColorB[face], faceColorC[face]); + } else if (type == 1) { + Draw3D.fillTriangle(vertexScreenY[a], vertexScreenY[b], vertexScreenY[c], vertexScreenX[a], vertexScreenX[b], vertexScreenX[c], palette[faceColorA[face]]); + } else if (type == 2) { + int texturedFace = faceInfo[face] >> 2; + int ta = texturedVertexA[texturedFace]; + int tb = texturedVertexB[texturedFace]; + int tc = texturedVertexC[texturedFace]; + Draw3D.fillTexturedTriangle(vertexScreenY[a], vertexScreenY[b], vertexScreenY[c], vertexScreenX[a], vertexScreenX[b], vertexScreenX[c], faceColorA[face], faceColorB[face], faceColorC[face], vertexViewSpaceX[ta], vertexViewSpaceX[tb], vertexViewSpaceX[tc], vertexViewSpaceY[ta], vertexViewSpaceY[tb], vertexViewSpaceY[tc], vertexViewSpaceZ[ta], vertexViewSpaceZ[tb], vertexViewSpaceZ[tc], faceColor[face]); + } else if (type == 3) { + int texturedFace = faceInfo[face] >> 2; + int ta = texturedVertexA[texturedFace]; + int tb = texturedVertexB[texturedFace]; + int tc = texturedVertexC[texturedFace]; + Draw3D.fillTexturedTriangle(vertexScreenY[a], vertexScreenY[b], vertexScreenY[c], vertexScreenX[a], vertexScreenX[b], vertexScreenX[c], faceColorA[face], faceColorA[face], faceColorA[face], vertexViewSpaceX[ta], vertexViewSpaceX[tb], vertexViewSpaceX[tc], vertexViewSpaceY[ta], vertexViewSpaceY[tb], vertexViewSpaceY[tc], vertexViewSpaceZ[ta], vertexViewSpaceZ[tb], vertexViewSpaceZ[tc], faceColor[face]); } } - public void method480(int i, int j, int k, int l, int i1) { - for (int j1 = 0; j1 < anInt1630; j1++) { - int k1 = anIntArray1631[j1]; - int i2 = anIntArray1632[j1]; - int j2 = anIntArray1633[j1]; - if (anIntArray1637 == null) { - int i3 = anIntArray1640[j1]; - VertexNormal normal = super.aNormalArray1425[k1]; - int k2 = i + (k * normal.anInt602 + l * normal.anInt603 + i1 * normal.anInt604) / (j * normal.anInt605); - anIntArray1634[j1] = method481(i3, k2, 0); - normal = super.aNormalArray1425[i2]; - k2 = i + (k * normal.anInt602 + l * normal.anInt603 + i1 * normal.anInt604) / (j * normal.anInt605); - anIntArray1635[j1] = method481(i3, k2, 0); - normal = super.aNormalArray1425[j2]; - k2 = i + (k * normal.anInt602 + l * normal.anInt603 + i1 * normal.anInt604) / (j * normal.anInt605); - anIntArray1636[j1] = method481(i3, k2, 0); - } else if ((anIntArray1637[j1] & 1) == 0) { - int j3 = anIntArray1640[j1]; - int k3 = anIntArray1637[j1]; - VertexNormal normal_1 = super.aNormalArray1425[k1]; - int l2 = i + (k * normal_1.anInt602 + l * normal_1.anInt603 + i1 * normal_1.anInt604) / (j * normal_1.anInt605); - anIntArray1634[j1] = method481(j3, l2, k3); - normal_1 = super.aNormalArray1425[i2]; - l2 = i + (k * normal_1.anInt602 + l * normal_1.anInt603 + i1 * normal_1.anInt604) / (j * normal_1.anInt605); - anIntArray1635[j1] = method481(j3, l2, k3); - normal_1 = super.aNormalArray1425[j2]; - l2 = i + (k * normal_1.anInt602 + l * normal_1.anInt603 + i1 * normal_1.anInt604) / (j * normal_1.anInt605); - anIntArray1636[j1] = method481(j3, l2, k3); - } - } - super.aNormalArray1425 = null; - aNormalArray1660 = null; - anIntArray1655 = null; - anIntArray1656 = null; - if (anIntArray1637 != null) { - for (int l1 = 0; l1 < anInt1630; l1++) { - if ((anIntArray1637[l1] & 2) == 2) { - return; - } - } - } - anIntArray1640 = null; - } + /** + * Draws the provided face id assuming it has been clipped by the near Z plane. + * + * @param face the face id. + */ + public void drawNearClippedFace(int face) { + int centerX = Draw3D.centerX; + int centerY = Draw3D.centerY; + int elements = 0; - public void method482(int i, int j, int k, int l, int i1, int j1, int k1) { - int l1 = Draw3D.anInt1466; - int i2 = Draw3D.anInt1467; - int j2 = anIntArray1689[i]; - int k2 = anIntArray1690[i]; - int l2 = anIntArray1689[j]; - int i3 = anIntArray1690[j]; - int j3 = anIntArray1689[k]; - int k3 = anIntArray1690[k]; - int l3 = anIntArray1689[l]; - int i4 = anIntArray1690[l]; - int j4 = j1 * l3 + k1 * i4 >> 16; - for (int k4 = 0; k4 < anInt1626; k4++) { - int l4 = anIntArray1627[k4]; - int i5 = anIntArray1628[k4]; - int j5 = anIntArray1629[k4]; - if (k != 0) { - int k5 = i5 * j3 + l4 * k3 >> 16; - i5 = i5 * k3 - l4 * j3 >> 16; - l4 = k5; - } - if (i != 0) { - int l5 = i5 * k2 - j5 * j2 >> 16; - j5 = i5 * j2 + j5 * k2 >> 16; - i5 = l5; - } - if (j != 0) { - int i6 = j5 * l2 + l4 * i3 >> 16; - j5 = j5 * i3 - l4 * l2 >> 16; - l4 = i6; - } - l4 += i1; - i5 += j1; - j5 += k1; - int j6 = i5 * i4 - j5 * l3 >> 16; - j5 = i5 * l3 + j5 * i4 >> 16; - i5 = j6; - anIntArray1667[k4] = j5 - j4; - anIntArray1665[k4] = l1 + (l4 << 9) / j5; - anIntArray1666[k4] = i2 + (i5 << 9) / j5; - if (anInt1642 > 0) { - anIntArray1668[k4] = l4; - anIntArray1669[k4] = i5; - anIntArray1670[k4] = j5; - } - } - try { - method483(false, false, 0); - } catch (Exception ignored) { - } - } + int a = faceVertexA[face]; + int b = faceVertexB[face]; + int c = faceVertexC[face]; - @Override - public void method443(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2) { - int j2 = l1 * i1 - j1 * l >> 16; - int k2 = k1 * j + j2 * k >> 16; - int l2 = anInt1650 * k >> 16; - int i3 = k2 + l2; - if (i3 <= 50 || k2 >= 3500) { - return; - } - int j3 = l1 * l + j1 * i1 >> 16; - int k3 = j3 - anInt1650 << 9; - if (k3 / i3 >= Draw2D.anInt1386) { - return; - } - int l3 = j3 + anInt1650 << 9; - if (l3 / i3 <= -Draw2D.anInt1386) { - return; - } - int i4 = k1 * k - j2 * j >> 16; - int j4 = anInt1650 * j >> 16; - int k4 = i4 + j4 << 9; - if (k4 / i3 <= -Draw2D.anInt1387) { - return; - } - int l4 = j4 + (super.anInt1426 * k >> 16); - int i5 = i4 - l4 << 9; - if (i5 / i3 >= Draw2D.anInt1387) { - return; - } - int j5 = l2 + (super.anInt1426 * j >> 16); - boolean flag = false; - if (k2 - j5 <= 50) { - flag = true; - } - boolean flag1 = false; - if (i2 > 0 && aBoolean1684) { - int k5 = k2 - l2; - if (k5 <= 50) { - k5 = 50; + int zA = vertexViewSpaceZ[a]; + int zB = vertexViewSpaceZ[b]; + int zC = vertexViewSpaceZ[c]; + + if (zA >= 50) { + clippedX[elements] = vertexScreenX[a]; + clippedY[elements] = vertexScreenY[a]; + clippedColor[elements++] = faceColorA[face]; + } else { + int xA = vertexViewSpaceX[a]; + int yA = vertexViewSpaceY[a]; + int colorA = faceColorA[face]; + + if (zC >= 50) { + int scalar = (50 - zA) * reciprical16[zC - zA]; + clippedX[elements] = centerX + (((xA + (((vertexViewSpaceX[c] - xA) * scalar) >> 16)) << 9) / 50); + clippedY[elements] = centerY + (((yA + (((vertexViewSpaceY[c] - yA) * scalar) >> 16)) << 9) / 50); + clippedColor[elements++] = colorA + (((faceColorC[face] - colorA) * scalar) >> 16); } - if (j3 > 0) { - k3 /= i3; - l3 /= k5; + + if (zB >= 50) { + int scalar = (50 - zA) * reciprical16[zB - zA]; + clippedX[elements] = centerX + (((xA + (((vertexViewSpaceX[b] - xA) * scalar) >> 16)) << 9) / 50); + clippedY[elements] = centerY + (((yA + (((vertexViewSpaceY[b] - yA) * scalar) >> 16)) << 9) / 50); + clippedColor[elements++] = colorA + (((faceColorB[face] - colorA) * scalar) >> 16); + } + } + + if (zB >= 50) { + clippedX[elements] = vertexScreenX[b]; + clippedY[elements] = vertexScreenY[b]; + clippedColor[elements++] = faceColorB[face]; + } else { + int xB = vertexViewSpaceX[b]; + int yB = vertexViewSpaceY[b]; + int colorB = faceColorB[face]; + + if (zA >= 50) { + int scalar = (50 - zB) * reciprical16[zA - zB]; + clippedX[elements] = centerX + (((xB + (((vertexViewSpaceX[a] - xB) * scalar) >> 16)) << 9) / 50); + clippedY[elements] = centerY + (((yB + (((vertexViewSpaceY[a] - yB) * scalar) >> 16)) << 9) / 50); + clippedColor[elements++] = colorB + (((faceColorA[face] - colorB) * scalar) >> 16); + } + + if (zC >= 50) { + int scalar = (50 - zB) * reciprical16[zC - zB]; + clippedX[elements] = centerX + (((xB + (((vertexViewSpaceX[c] - xB) * scalar) >> 16)) << 9) / 50); + clippedY[elements] = centerY + (((yB + (((vertexViewSpaceY[c] - yB) * scalar) >> 16)) << 9) / 50); + clippedColor[elements++] = colorB + (((faceColorC[face] - colorB) * scalar) >> 16); + } + } + + if (zC >= 50) { + clippedX[elements] = vertexScreenX[c]; + clippedY[elements] = vertexScreenY[c]; + clippedColor[elements++] = faceColorC[face]; + } else { + int xC = vertexViewSpaceX[c]; + int yC = vertexViewSpaceY[c]; + int colorC = faceColorC[face]; + + if (zB >= 50) { + int k6 = (50 - zC) * reciprical16[zB - zC]; + clippedX[elements] = centerX + (((xC + (((vertexViewSpaceX[b] - xC) * k6) >> 16)) << 9) / 50); + clippedY[elements] = centerY + (((yC + (((vertexViewSpaceY[b] - yC) * k6) >> 16)) << 9) / 50); + clippedColor[elements++] = colorC + (((faceColorB[face] - colorC) * k6) >> 16); + } + + if (zA >= 50) { + int l6 = (50 - zC) * reciprical16[zA - zC]; + clippedX[elements] = centerX + (((xC + (((vertexViewSpaceX[a] - xC) * l6) >> 16)) << 9) / 50); + clippedY[elements] = centerY + (((yC + (((vertexViewSpaceY[a] - yC) * l6) >> 16)) << 9) / 50); + clippedColor[elements++] = colorC + (((faceColorA[face] - colorC) * l6) >> 16); + } + } + + int x0 = clippedX[0]; + int x1 = clippedX[1]; + int x2 = clippedX[2]; + int y0 = clippedY[0]; + int y1 = clippedY[1]; + int y2 = clippedY[2]; + + // Back-face culling + if ((((x0 - x1) * (y2 - y1)) - ((y0 - y1) * (x2 - x1))) <= 0) { + return; + } + + Draw3D.clipX = false; + + // It's possible for a single triangle to be clipped into two separate triangles. + + if (elements == 3) { + if ((x0 < 0) || (x1 < 0) || (x2 < 0) || (x0 > Draw2D.boundX) || (x1 > Draw2D.boundX) || (x2 > Draw2D.boundX)) { + Draw3D.clipX = true; + } + + int type; + + if (faceInfo == null) { + type = 0; } else { - l3 /= i3; - k3 /= k5; + type = faceInfo[face] & 3; } - if (i4 > 0) { - i5 /= i3; - k4 /= k5; + + if (type == 0) { + Draw3D.fillGouraudTriangle(y0, y1, y2, x0, x1, x2, clippedColor[0], clippedColor[1], clippedColor[2]); + } else if (type == 1) { + Draw3D.fillTriangle(y0, y1, y2, x0, x1, x2, palette[faceColorA[face]]); + } else if (type == 2) { + int texturedFace = faceInfo[face] >> 2; + int tA = texturedVertexA[texturedFace]; + int tB = texturedVertexB[texturedFace]; + int tC = texturedVertexC[texturedFace]; + Draw3D.fillTexturedTriangle(y0, y1, y2, x0, x1, x2, clippedColor[0], clippedColor[1], clippedColor[2], vertexViewSpaceX[tA], vertexViewSpaceX[tB], vertexViewSpaceX[tC], vertexViewSpaceY[tA], vertexViewSpaceY[tB], vertexViewSpaceY[tC], vertexViewSpaceZ[tA], vertexViewSpaceZ[tB], vertexViewSpaceZ[tC], faceColor[face]); + } else if (type == 3) { + int texturedFace = faceInfo[face] >> 2; + int tA = texturedVertexA[texturedFace]; + int tB = texturedVertexB[texturedFace]; + int tC = texturedVertexC[texturedFace]; + Draw3D.fillTexturedTriangle(y0, y1, y2, x0, x1, x2, faceColorA[face], faceColorA[face], faceColorA[face], vertexViewSpaceX[tA], vertexViewSpaceX[tB], vertexViewSpaceX[tC], vertexViewSpaceY[tA], vertexViewSpaceY[tB], vertexViewSpaceY[tC], vertexViewSpaceZ[tA], vertexViewSpaceZ[tB], vertexViewSpaceZ[tC], faceColor[face]); + } + } else if (elements == 4) { + if ((x0 < 0) || (x1 < 0) || (x2 < 0) || (x0 > Draw2D.boundX) || (x1 > Draw2D.boundX) || (x2 > Draw2D.boundX) || (clippedX[3] < 0) || (clippedX[3] > Draw2D.boundX)) { + Draw3D.clipX = true; + } + + int type; + + if (faceInfo == null) { + type = 0; } else { - k4 /= i3; - i5 /= k5; + type = faceInfo[face] & 3; } - int i6 = anInt1685 - Draw3D.anInt1466; - int k6 = anInt1686 - Draw3D.anInt1467; - if (i6 > k3 && i6 < l3 && k6 > i5 && k6 < k4) { - if (aBoolean1659) { - anIntArray1688[anInt1687++] = i2; - } else { - flag1 = true; - } - } - } - int l5 = Draw3D.anInt1466; - int j6 = Draw3D.anInt1467; - int l6 = 0; - int i7 = 0; - if (i != 0) { - l6 = anIntArray1689[i]; - i7 = anIntArray1690[i]; - } - for (int j7 = 0; j7 < anInt1626; j7++) { - int k7 = anIntArray1627[j7]; - int l7 = anIntArray1628[j7]; - int i8 = anIntArray1629[j7]; - if (i != 0) { - int j8 = i8 * l6 + k7 * i7 >> 16; - i8 = i8 * i7 - k7 * l6 >> 16; - k7 = j8; - } - k7 += j1; - l7 += k1; - i8 += l1; - int k8 = i8 * l + k7 * i1 >> 16; - i8 = i8 * i1 - k7 * l >> 16; - k7 = k8; - k8 = l7 * k - i8 * j >> 16; - i8 = l7 * j + i8 * k >> 16; - l7 = k8; - anIntArray1667[j7] = i8 - k2; - if (i8 >= 50) { - anIntArray1665[j7] = l5 + (k7 << 9) / i8; - anIntArray1666[j7] = j6 + (l7 << 9) / i8; - } else { - anIntArray1665[j7] = -5000; - flag = true; - } - if (flag || anInt1642 > 0) { - anIntArray1668[j7] = k7; - anIntArray1669[j7] = l7; - anIntArray1670[j7] = i8; - } - } - try { - method483(flag, flag1, i2); - } catch (Exception ignored) { - } - } - public void method483(boolean flag, boolean flag1, int i) { - for (int j = 0; j < anInt1652; j++) { - anIntArray1671[j] = 0; - } - for (int k = 0; k < anInt1630; k++) { - if (anIntArray1637 == null || anIntArray1637[k] != -1) { - int l = anIntArray1631[k]; - int k1 = anIntArray1632[k]; - int j2 = anIntArray1633[k]; - int i3 = anIntArray1665[l]; - int l3 = anIntArray1665[k1]; - int k4 = anIntArray1665[j2]; - if (flag && (i3 == -5000 || l3 == -5000 || k4 == -5000)) { - aBooleanArray1664[k] = true; - int j5 = (anIntArray1667[l] + anIntArray1667[k1] + anIntArray1667[j2]) / 3 + anInt1653; - anIntArrayArray1672[j5][anIntArray1671[j5]++] = k; - } else { - if (flag1 && method486(anInt1685, anInt1686, anIntArray1666[l], anIntArray1666[k1], anIntArray1666[j2], i3, l3, k4)) { - anIntArray1688[anInt1687++] = i; - flag1 = false; - } - if ((i3 - l3) * (anIntArray1666[j2] - anIntArray1666[k1]) - (anIntArray1666[l] - anIntArray1666[k1]) * (k4 - l3) > 0) { - aBooleanArray1664[k] = false; - aBooleanArray1663[k] = i3 < 0 || l3 < 0 || k4 < 0 || i3 > Draw2D.anInt1385 || l3 > Draw2D.anInt1385 || k4 > Draw2D.anInt1385; - int k5 = (anIntArray1667[l] + anIntArray1667[k1] + anIntArray1667[j2]) / 3 + anInt1653; - anIntArrayArray1672[k5][anIntArray1671[k5]++] = k; - } - } - } - } - if (anIntArray1638 == null) { - for (int i1 = anInt1652 - 1; i1 >= 0; i1--) { - int l1 = anIntArray1671[i1]; - if (l1 > 0) { - int[] ai = anIntArrayArray1672[i1]; - for (int j3 = 0; j3 < l1; j3++) { - method484(ai[j3]); - } - } - } - return; - } - for (int j1 = 0; j1 < 12; j1++) { - anIntArray1673[j1] = 0; - anIntArray1677[j1] = 0; - } - for (int i2 = anInt1652 - 1; i2 >= 0; i2--) { - int k2 = anIntArray1671[i2]; - if (k2 > 0) { - int[] ai1 = anIntArrayArray1672[i2]; - for (int i4 = 0; i4 < k2; i4++) { - int l4 = ai1[i4]; - int l5 = anIntArray1638[l4]; - int j6 = anIntArray1673[l5]++; - anIntArrayArray1674[l5][j6] = l4; - if (l5 < 10) { - anIntArray1677[l5] += i2; - } else if (l5 == 10) { - anIntArray1675[j6] = i2; - } else { - anIntArray1676[j6] = i2; - } - } - } - } - int l2 = 0; - if (anIntArray1673[1] > 0 || anIntArray1673[2] > 0) { - l2 = (anIntArray1677[1] + anIntArray1677[2]) / (anIntArray1673[1] + anIntArray1673[2]); - } - int k3 = 0; - if (anIntArray1673[3] > 0 || anIntArray1673[4] > 0) { - k3 = (anIntArray1677[3] + anIntArray1677[4]) / (anIntArray1673[3] + anIntArray1673[4]); - } - int j4 = 0; - if (anIntArray1673[6] > 0 || anIntArray1673[8] > 0) { - j4 = (anIntArray1677[6] + anIntArray1677[8]) / (anIntArray1673[6] + anIntArray1673[8]); - } - int i6 = 0; - int k6 = anIntArray1673[10]; - int[] ai2 = anIntArrayArray1674[10]; - int[] ai3 = anIntArray1675; - if (i6 == k6) { - i6 = 0; - k6 = anIntArray1673[11]; - ai2 = anIntArrayArray1674[11]; - ai3 = anIntArray1676; - } - int i5; - if (i6 < k6) { - i5 = ai3[i6]; - } else { - i5 = -1000; - } - for (int l6 = 0; l6 < 10; l6++) { - while (l6 == 0 && i5 > l2) { - method484(ai2[i6++]); - if (i6 == k6 && ai2 != anIntArrayArray1674[11]) { - i6 = 0; - k6 = anIntArray1673[11]; - ai2 = anIntArrayArray1674[11]; - ai3 = anIntArray1676; - } - if (i6 < k6) { - i5 = ai3[i6]; - } else { - i5 = -1000; - } - } - while (l6 == 3 && i5 > k3) { - method484(ai2[i6++]); - if (i6 == k6 && ai2 != anIntArrayArray1674[11]) { - i6 = 0; - k6 = anIntArray1673[11]; - ai2 = anIntArrayArray1674[11]; - ai3 = anIntArray1676; - } - if (i6 < k6) { - i5 = ai3[i6]; - } else { - i5 = -1000; - } - } - while (l6 == 5 && i5 > j4) { - method484(ai2[i6++]); - if (i6 == k6 && ai2 != anIntArrayArray1674[11]) { - i6 = 0; - k6 = anIntArray1673[11]; - ai2 = anIntArrayArray1674[11]; - ai3 = anIntArray1676; - } - if (i6 < k6) { - i5 = ai3[i6]; - } else { - i5 = -1000; - } - } - int i7 = anIntArray1673[l6]; - int[] ai4 = anIntArrayArray1674[l6]; - for (int j7 = 0; j7 < i7; j7++) { - method484(ai4[j7]); - } - } - while (i5 != -1000) { - method484(ai2[i6++]); - if (i6 == k6 && ai2 != anIntArrayArray1674[11]) { - i6 = 0; - ai2 = anIntArrayArray1674[11]; - k6 = anIntArray1673[11]; - ai3 = anIntArray1676; - } - if (i6 < k6) { - i5 = ai3[i6]; - } else { - i5 = -1000; + if (type == 0) { + Draw3D.fillGouraudTriangle(y0, y1, y2, x0, x1, x2, clippedColor[0], clippedColor[1], clippedColor[2]); + Draw3D.fillGouraudTriangle(y0, y2, clippedY[3], x0, x2, clippedX[3], clippedColor[0], clippedColor[2], clippedColor[3]); + } else if (type == 1) { + int colorA = palette[faceColorA[face]]; + Draw3D.fillTriangle(y0, y1, y2, x0, x1, x2, colorA); + Draw3D.fillTriangle(y0, y2, clippedY[3], x0, x2, clippedX[3], colorA); + } else if (type == 2) { + int texturedFace = faceInfo[face] >> 2; + int tA = texturedVertexA[texturedFace]; + int tB = texturedVertexB[texturedFace]; + int tC = texturedVertexC[texturedFace]; + Draw3D.fillTexturedTriangle(y0, y1, y2, x0, x1, x2, clippedColor[0], clippedColor[1], clippedColor[2], vertexViewSpaceX[tA], vertexViewSpaceX[tB], vertexViewSpaceX[tC], vertexViewSpaceY[tA], vertexViewSpaceY[tB], vertexViewSpaceY[tC], vertexViewSpaceZ[tA], vertexViewSpaceZ[tB], vertexViewSpaceZ[tC], faceColor[face]); + Draw3D.fillTexturedTriangle(y0, y2, clippedY[3], x0, x2, clippedX[3], clippedColor[0], clippedColor[2], clippedColor[3], vertexViewSpaceX[tA], vertexViewSpaceX[tB], vertexViewSpaceX[tC], vertexViewSpaceY[tA], vertexViewSpaceY[tB], vertexViewSpaceY[tC], vertexViewSpaceZ[tA], vertexViewSpaceZ[tB], vertexViewSpaceZ[tC], faceColor[face]); + } else if (type == 3) { + int texturedFace = faceInfo[face] >> 2; + int tA = texturedVertexA[texturedFace]; + int tB = texturedVertexB[texturedFace]; + int tC = texturedVertexC[texturedFace]; + Draw3D.fillTexturedTriangle(y0, y1, y2, x0, x1, x2, faceColorA[face], faceColorA[face], faceColorA[face], vertexViewSpaceX[tA], vertexViewSpaceX[tB], vertexViewSpaceX[tC], vertexViewSpaceY[tA], vertexViewSpaceY[tB], vertexViewSpaceY[tC], vertexViewSpaceZ[tA], vertexViewSpaceZ[tB], vertexViewSpaceZ[tC], faceColor[face]); + Draw3D.fillTexturedTriangle(y0, y2, clippedY[3], x0, x2, clippedX[3], faceColorA[face], faceColorA[face], faceColorA[face], vertexViewSpaceX[tA], vertexViewSpaceX[tB], vertexViewSpaceX[tC], vertexViewSpaceY[tA], vertexViewSpaceY[tB], vertexViewSpaceY[tC], vertexViewSpaceZ[tA], vertexViewSpaceZ[tB], vertexViewSpaceZ[tC], faceColor[face]); } } } - public void method484(int i) { - if (aBooleanArray1664[i]) { - method485(i); - return; - } - int j = anIntArray1631[i]; - int k = anIntArray1632[i]; - int l = anIntArray1633[i]; - Draw3D.aBoolean1462 = aBooleanArray1663[i]; - if (anIntArray1639 == null) { - Draw3D.anInt1465 = 0; - } else { - Draw3D.anInt1465 = anIntArray1639[i]; - } - int i1; - if (anIntArray1637 == null) { - i1 = 0; - } else { - i1 = anIntArray1637[i] & 3; - } - if (i1 == 0) { - Draw3D.method374(anIntArray1666[j], anIntArray1666[k], anIntArray1666[l], anIntArray1665[j], anIntArray1665[k], anIntArray1665[l], anIntArray1634[i], anIntArray1635[i], anIntArray1636[i]); - return; - } - if (i1 == 1) { - Draw3D.method376(anIntArray1666[j], anIntArray1666[k], anIntArray1666[l], anIntArray1665[j], anIntArray1665[k], anIntArray1665[l], anIntArray1691[anIntArray1634[i]]); - return; - } - if (i1 == 2) { - int j1 = anIntArray1637[i] >> 2; - int l1 = anIntArray1643[j1]; - int j2 = anIntArray1644[j1]; - int l2 = anIntArray1645[j1]; - Draw3D.method378(anIntArray1666[j], anIntArray1666[k], anIntArray1666[l], anIntArray1665[j], anIntArray1665[k], anIntArray1665[l], anIntArray1634[i], anIntArray1635[i], anIntArray1636[i], anIntArray1668[l1], anIntArray1668[j2], anIntArray1668[l2], anIntArray1669[l1], anIntArray1669[j2], anIntArray1669[l2], anIntArray1670[l1], anIntArray1670[j2], anIntArray1670[l2], anIntArray1640[i]); - return; - } - if (i1 == 3) { - int k1 = anIntArray1637[i] >> 2; - int i2 = anIntArray1643[k1]; - int k2 = anIntArray1644[k1]; - int i3 = anIntArray1645[k1]; - Draw3D.method378(anIntArray1666[j], anIntArray1666[k], anIntArray1666[l], anIntArray1665[j], anIntArray1665[k], anIntArray1665[l], anIntArray1634[i], anIntArray1634[i], anIntArray1634[i], anIntArray1668[i2], anIntArray1668[k2], anIntArray1668[i3], anIntArray1669[i2], anIntArray1669[k2], anIntArray1669[i3], anIntArray1670[i2], anIntArray1670[k2], anIntArray1670[i3], anIntArray1640[i]); - } - } - - public void method485(int i) { - int j = Draw3D.anInt1466; - int k = Draw3D.anInt1467; - int l = 0; - int i1 = anIntArray1631[i]; - int j1 = anIntArray1632[i]; - int k1 = anIntArray1633[i]; - int l1 = anIntArray1670[i1]; - int i2 = anIntArray1670[j1]; - int j2 = anIntArray1670[k1]; - if (l1 >= 50) { - anIntArray1678[l] = anIntArray1665[i1]; - anIntArray1679[l] = anIntArray1666[i1]; - anIntArray1680[l++] = anIntArray1634[i]; - } else { - int k2 = anIntArray1668[i1]; - int k3 = anIntArray1669[i1]; - int k4 = anIntArray1634[i]; - if (j2 >= 50) { - int k5 = (50 - l1) * anIntArray1692[j2 - l1]; - anIntArray1678[l] = j + (k2 + ((anIntArray1668[k1] - k2) * k5 >> 16) << 9) / 50; - anIntArray1679[l] = k + (k3 + ((anIntArray1669[k1] - k3) * k5 >> 16) << 9) / 50; - anIntArray1680[l++] = k4 + ((anIntArray1636[i] - k4) * k5 >> 16); - } - if (i2 >= 50) { - int l5 = (50 - l1) * anIntArray1692[i2 - l1]; - anIntArray1678[l] = j + (k2 + ((anIntArray1668[j1] - k2) * l5 >> 16) << 9) / 50; - anIntArray1679[l] = k + (k3 + ((anIntArray1669[j1] - k3) * l5 >> 16) << 9) / 50; - anIntArray1680[l++] = k4 + ((anIntArray1635[i] - k4) * l5 >> 16); - } - } - if (i2 >= 50) { - anIntArray1678[l] = anIntArray1665[j1]; - anIntArray1679[l] = anIntArray1666[j1]; - anIntArray1680[l++] = anIntArray1635[i]; - } else { - int l2 = anIntArray1668[j1]; - int l3 = anIntArray1669[j1]; - int l4 = anIntArray1635[i]; - if (l1 >= 50) { - int i6 = (50 - i2) * anIntArray1692[l1 - i2]; - anIntArray1678[l] = j + (l2 + ((anIntArray1668[i1] - l2) * i6 >> 16) << 9) / 50; - anIntArray1679[l] = k + (l3 + ((anIntArray1669[i1] - l3) * i6 >> 16) << 9) / 50; - anIntArray1680[l++] = l4 + ((anIntArray1634[i] - l4) * i6 >> 16); - } - if (j2 >= 50) { - int j6 = (50 - i2) * anIntArray1692[j2 - i2]; - anIntArray1678[l] = j + (l2 + ((anIntArray1668[k1] - l2) * j6 >> 16) << 9) / 50; - anIntArray1679[l] = k + (l3 + ((anIntArray1669[k1] - l3) * j6 >> 16) << 9) / 50; - anIntArray1680[l++] = l4 + ((anIntArray1636[i] - l4) * j6 >> 16); - } - } - if (j2 >= 50) { - anIntArray1678[l] = anIntArray1665[k1]; - anIntArray1679[l] = anIntArray1666[k1]; - anIntArray1680[l++] = anIntArray1636[i]; - } else { - int i3 = anIntArray1668[k1]; - int i4 = anIntArray1669[k1]; - int i5 = anIntArray1636[i]; - if (i2 >= 50) { - int k6 = (50 - j2) * anIntArray1692[i2 - j2]; - anIntArray1678[l] = j + (i3 + ((anIntArray1668[j1] - i3) * k6 >> 16) << 9) / 50; - anIntArray1679[l] = k + (i4 + ((anIntArray1669[j1] - i4) * k6 >> 16) << 9) / 50; - anIntArray1680[l++] = i5 + ((anIntArray1635[i] - i5) * k6 >> 16); - } - if (l1 >= 50) { - int l6 = (50 - j2) * anIntArray1692[l1 - j2]; - anIntArray1678[l] = j + (i3 + ((anIntArray1668[i1] - i3) * l6 >> 16) << 9) / 50; - anIntArray1679[l] = k + (i4 + ((anIntArray1669[i1] - i4) * l6 >> 16) << 9) / 50; - anIntArray1680[l++] = i5 + ((anIntArray1634[i] - i5) * l6 >> 16); - } - } - int j3 = anIntArray1678[0]; - int j4 = anIntArray1678[1]; - int j5 = anIntArray1678[2]; - int i7 = anIntArray1679[0]; - int j7 = anIntArray1679[1]; - int k7 = anIntArray1679[2]; - if ((j3 - j4) * (k7 - j7) - (i7 - j7) * (j5 - j4) > 0) { - Draw3D.aBoolean1462 = false; - if (l == 3) { - if (j3 < 0 || j4 < 0 || j5 < 0 || j3 > Draw2D.anInt1385 || j4 > Draw2D.anInt1385 || j5 > Draw2D.anInt1385) { - Draw3D.aBoolean1462 = true; - } - int l7; - if (anIntArray1637 == null) { - l7 = 0; - } else { - l7 = anIntArray1637[i] & 3; - } - if (l7 == 0) { - Draw3D.method374(i7, j7, k7, j3, j4, j5, anIntArray1680[0], anIntArray1680[1], anIntArray1680[2]); - } else if (l7 == 1) { - Draw3D.method376(i7, j7, k7, j3, j4, j5, anIntArray1691[anIntArray1634[i]]); - } else if (l7 == 2) { - int j8 = anIntArray1637[i] >> 2; - int k9 = anIntArray1643[j8]; - int k10 = anIntArray1644[j8]; - int k11 = anIntArray1645[j8]; - Draw3D.method378(i7, j7, k7, j3, j4, j5, anIntArray1680[0], anIntArray1680[1], anIntArray1680[2], anIntArray1668[k9], anIntArray1668[k10], anIntArray1668[k11], anIntArray1669[k9], anIntArray1669[k10], anIntArray1669[k11], anIntArray1670[k9], anIntArray1670[k10], anIntArray1670[k11], anIntArray1640[i]); - } else if (l7 == 3) { - int k8 = anIntArray1637[i] >> 2; - int l9 = anIntArray1643[k8]; - int l10 = anIntArray1644[k8]; - int l11 = anIntArray1645[k8]; - Draw3D.method378(i7, j7, k7, j3, j4, j5, anIntArray1634[i], anIntArray1634[i], anIntArray1634[i], anIntArray1668[l9], anIntArray1668[l10], anIntArray1668[l11], anIntArray1669[l9], anIntArray1669[l10], anIntArray1669[l11], anIntArray1670[l9], anIntArray1670[l10], anIntArray1670[l11], anIntArray1640[i]); - } - } - if (l == 4) { - if (j3 < 0 || j4 < 0 || j5 < 0 || j3 > Draw2D.anInt1385 || j4 > Draw2D.anInt1385 || j5 > Draw2D.anInt1385 || anIntArray1678[3] < 0 || anIntArray1678[3] > Draw2D.anInt1385) { - Draw3D.aBoolean1462 = true; - } - int i8; - if (anIntArray1637 == null) { - i8 = 0; - } else { - i8 = anIntArray1637[i] & 3; - } - if (i8 == 0) { - Draw3D.method374(i7, j7, k7, j3, j4, j5, anIntArray1680[0], anIntArray1680[1], anIntArray1680[2]); - Draw3D.method374(i7, k7, anIntArray1679[3], j3, j5, anIntArray1678[3], anIntArray1680[0], anIntArray1680[2], anIntArray1680[3]); - return; - } - if (i8 == 1) { - int l8 = anIntArray1691[anIntArray1634[i]]; - Draw3D.method376(i7, j7, k7, j3, j4, j5, l8); - Draw3D.method376(i7, k7, anIntArray1679[3], j3, j5, anIntArray1678[3], l8); - return; - } - if (i8 == 2) { - int i9 = anIntArray1637[i] >> 2; - int i10 = anIntArray1643[i9]; - int i11 = anIntArray1644[i9]; - int i12 = anIntArray1645[i9]; - Draw3D.method378(i7, j7, k7, j3, j4, j5, anIntArray1680[0], anIntArray1680[1], anIntArray1680[2], anIntArray1668[i10], anIntArray1668[i11], anIntArray1668[i12], anIntArray1669[i10], anIntArray1669[i11], anIntArray1669[i12], anIntArray1670[i10], anIntArray1670[i11], anIntArray1670[i12], anIntArray1640[i]); - Draw3D.method378(i7, k7, anIntArray1679[3], j3, j5, anIntArray1678[3], anIntArray1680[0], anIntArray1680[2], anIntArray1680[3], anIntArray1668[i10], anIntArray1668[i11], anIntArray1668[i12], anIntArray1669[i10], anIntArray1669[i11], anIntArray1669[i12], anIntArray1670[i10], anIntArray1670[i11], anIntArray1670[i12], anIntArray1640[i]); - return; - } - if (i8 == 3) { - int j9 = anIntArray1637[i] >> 2; - int j10 = anIntArray1643[j9]; - int j11 = anIntArray1644[j9]; - int j12 = anIntArray1645[j9]; - Draw3D.method378(i7, j7, k7, j3, j4, j5, anIntArray1634[i], anIntArray1634[i], anIntArray1634[i], anIntArray1668[j10], anIntArray1668[j11], anIntArray1668[j12], anIntArray1669[j10], anIntArray1669[j11], anIntArray1669[j12], anIntArray1670[j10], anIntArray1670[j11], anIntArray1670[j12], anIntArray1640[i]); - Draw3D.method378(i7, k7, anIntArray1679[3], j3, j5, anIntArray1678[3], anIntArray1634[i], anIntArray1634[i], anIntArray1634[i], anIntArray1668[j10], anIntArray1668[j11], anIntArray1668[j12], anIntArray1669[j10], anIntArray1669[j11], anIntArray1669[j12], anIntArray1670[j10], anIntArray1670[j11], anIntArray1670[j12], anIntArray1640[i]); - } - } - } - } - - public boolean method486(int i, int j, int k, int l, int i1, int j1, int k1, int l1) { - if (j < k && j < l && j < i1) { + /** + * Utility function. Checks if (x, y) is within the provided triangle. + * + * @param x the x. + * @param y the y. + * @param yA y of corner a. + * @param yB y of corner b. + * @param yC y of corner c. + * @param xA x of corner a. + * @param xB x of corner b. + * @param xC x of corner c. + * @return true if (x, y) is within the triangle. + */ + public boolean pointWithinTriangle(int x, int y, int yA, int yB, int yC, int xA, int xB, int xC) { + if ((y < yA) && (y < yB) && (y < yC)) { return false; } - if (j > k && j > l && j > i1) { + if ((y > yA) && (y > yB) && (y > yC)) { return false; } - if (i < j1 && i < k1 && i < l1) { + if ((x < xA) && (x < xB) && (x < xC)) { return false; } - return i <= j1 || i <= k1 || i <= l1; + return (x <= xA) || (x <= xB) || (x <= xC); } } diff --git a/src/main/java/ModelHeader.java b/src/main/java/ModelHeader.java index 1acd1e5..310ee4a 100644 --- a/src/main/java/ModelHeader.java +++ b/src/main/java/ModelHeader.java @@ -4,23 +4,23 @@ public class ModelHeader { - public byte[] aByteArray368; - public int anInt369; - public int anInt370; - public int anInt371; - public int anInt372; - public int anInt373; - public int anInt374; - public int anInt375; - public int anInt376; - public int anInt377; - public int anInt378; - public int anInt379; - public int anInt380; - public int anInt381; - public int anInt382; - public int anInt383; - public int anInt384; + public byte[] data; + public int vertexCount; + public int faceCount; + public int texturedFaceCount; + public int obPoint1Position; + public int obPoint2Position; + public int obPoint3Position; + public int obPoint4Position; + public int obPoint5Position; + public int obVertex1Position; + public int obVertex2Position; + public int obFace1Position; + public int obFace2Position; + public int obFace3Position; + public int obFace4Position; + public int obFace5Position; + public int obAxisPosition; public ModelHeader() { } diff --git a/src/main/java/NPCEntity.java b/src/main/java/NPCEntity.java index d61a1ab..f63a197 100644 --- a/src/main/java/NPCEntity.java +++ b/src/main/java/NPCEntity.java @@ -34,28 +34,28 @@ public class NPCEntity extends PathingEntity { if (model == null) { return null; } - super.anInt1507 = model.anInt1426; + super.anInt1507 = model.minY; if (super.anInt1520 != -1 && super.anInt1521 != -1) { SpotAnimType type = SpotAnimType.aTypeArray403[super.anInt1520]; Model model_1 = type.method266(); if (model_1 != null) { int j = type.aType_407.anIntArray353[super.anInt1521]; - Model class30_sub2_sub4_sub6_2 = new Model(true, SeqTransform.method532(j), false, model_1); - class30_sub2_sub4_sub6_2.method475(0, -super.anInt1524, 0); - class30_sub2_sub4_sub6_2.method469(); - class30_sub2_sub4_sub6_2.method470(j); - class30_sub2_sub4_sub6_2.anIntArrayArray1658 = null; - class30_sub2_sub4_sub6_2.anIntArrayArray1657 = null; + Model class30_sub2_sub4_sub6_2 = new Model(true, SeqFrame.isNull(j), false, model_1); + class30_sub2_sub4_sub6_2.translate(0, -super.anInt1524, 0); + class30_sub2_sub4_sub6_2.createLabelReferences(); + class30_sub2_sub4_sub6_2.applySequenceFrame(j); + class30_sub2_sub4_sub6_2.labelFaces = null; + class30_sub2_sub4_sub6_2.labelVertices = null; if (type.anInt410 != 128 || type.anInt411 != 128) { - class30_sub2_sub4_sub6_2.method478(type.anInt410, type.anInt410, type.anInt411); + class30_sub2_sub4_sub6_2.scale(type.anInt410, type.anInt410, type.anInt411); } - class30_sub2_sub4_sub6_2.method479(64 + type.anInt413, 850 + type.anInt414, -30, -50, -30, true); + class30_sub2_sub4_sub6_2.calculateNormals(64 + type.anInt413, 850 + type.anInt414, -30, -50, -30, true); Model[] aclass30_sub2_sub4_sub6 = {model, class30_sub2_sub4_sub6_2}; model = new Model(2, -819, aclass30_sub2_sub4_sub6); } } if (aType_1696.aByte68 == 1) { - model.aBoolean1659 = true; + model.pickBounds = true; } return model; } diff --git a/src/main/java/NPCType.java b/src/main/java/NPCType.java index 4f8ae99..bbc71e0 100644 --- a/src/main/java/NPCType.java +++ b/src/main/java/NPCType.java @@ -53,7 +53,7 @@ public class NPCType { } anInt56 = (anInt56 + 1) % 20; NPCType type = aTypeArray80[anInt56] = new NPCType(); - aBuffer_60.anInt1406 = anIntArray72[i]; + aBuffer_60.position = anIntArray72[i]; type.aLong78 = i; type.method165(aBuffer_60); return type; @@ -96,7 +96,7 @@ public class NPCType { } boolean flag1 = false; for (int value : anIntArray73) { - if (!Model.method463(value)) { + if (!Model.validate(value)) { flag1 = true; } } @@ -105,7 +105,7 @@ public class NPCType { } Model[] aclass30_sub2_sub4_sub6 = new Model[anIntArray73.length]; for (int j = 0; j < anIntArray73.length; j++) { - aclass30_sub2_sub4_sub6[j] = Model.method462(anIntArray73[j]); + aclass30_sub2_sub4_sub6[j] = Model.tryGet(anIntArray73[j]); } Model model; if (aclass30_sub2_sub4_sub6.length == 1) { @@ -115,7 +115,7 @@ public class NPCType { } if (anIntArray76 != null) { for (int k = 0; k < anIntArray76.length; k++) { - model.method476(anIntArray76[k], anIntArray70[k]); + model.replaceColor(anIntArray76[k], anIntArray70[k]); } } return model; @@ -153,7 +153,7 @@ public class NPCType { if (model == null) { boolean flag = false; for (int value : anIntArray94) { - if (!Model.method463(value)) { + if (!Model.validate(value)) { flag = true; } } @@ -162,7 +162,7 @@ public class NPCType { } Model[] aclass30_sub2_sub4_sub6 = new Model[anIntArray94.length]; for (int j1 = 0; j1 < anIntArray94.length; j1++) { - aclass30_sub2_sub4_sub6[j1] = Model.method462(anIntArray94[j1]); + aclass30_sub2_sub4_sub6[j1] = Model.tryGet(anIntArray94[j1]); } if (aclass30_sub2_sub4_sub6.length == 1) { model = aclass30_sub2_sub4_sub6[0]; @@ -171,28 +171,28 @@ public class NPCType { } if (anIntArray76 != null) { for (int k1 = 0; k1 < anIntArray76.length; k1++) { - model.method476(anIntArray76[k1], anIntArray70[k1]); + model.replaceColor(anIntArray76[k1], anIntArray70[k1]); } } - model.method469(); - model.method479(64 + anInt85, 850 + anInt92, -30, -50, -30, true); + model.createLabelReferences(); + model.calculateNormals(64 + anInt85, 850 + anInt92, -30, -50, -30, true); aCache_95.method223(model, aLong78); } - Model model_1 = Model.A_MODEL___1621; - model_1.method464(model, SeqTransform.method532(k) & SeqTransform.method532(j)); + Model model_1 = Model.EMPTY; + model_1.set(model, SeqFrame.isNull(k) & SeqFrame.isNull(j)); if (k != -1 && j != -1) { - model_1.method471(ai, j, k); + model_1.applySequenceFrames(k, j, ai); } else if (k != -1) { - model_1.method470(k); + model_1.applySequenceFrame(k); } if (anInt91 != 128 || anInt86 != 128) { - model_1.method478(anInt91, anInt91, anInt86); + model_1.scale(anInt91, anInt91, anInt86); } - model_1.method466(); - model_1.anIntArrayArray1658 = null; - model_1.anIntArrayArray1657 = null; + model_1.calculateBoundsCylinder(); + model_1.labelFaces = null; + model_1.labelVertices = null; if (aByte68 == 1) { - model_1.aBoolean1659 = true; + model_1.pickBounds = true; } return model_1; } diff --git a/src/main/java/ObjType.java b/src/main/java/ObjType.java index c834c14..a50e708 100644 --- a/src/main/java/ObjType.java +++ b/src/main/java/ObjType.java @@ -88,7 +88,7 @@ public class ObjType { } anInt180 = (anInt180 + 1) % 10; ObjType type = aTypeArray172[anInt180]; - aBuffer_183.anInt1406 = anIntArray195[i]; + aBuffer_183.position = anIntArray195[i]; type.anInt157 = i; type.method197(); type.method203(aBuffer_183); @@ -143,19 +143,19 @@ public class ObjType { } } Image24 class30_sub2_sub1_sub1_1 = new Image24(32, 32); - int k1 = Draw3D.anInt1466; - int l1 = Draw3D.anInt1467; + int k1 = Draw3D.centerX; + int l1 = Draw3D.centerY; int[] ai = Draw3D.anIntArray1472; - int[] ai1 = Draw2D.anIntArray1378; - int i2 = Draw2D.anInt1379; - int j2 = Draw2D.anInt1380; - int k2 = Draw2D.anInt1383; - int l2 = Draw2D.anInt1384; - int i3 = Draw2D.anInt1381; - int j3 = Draw2D.anInt1382; - Draw3D.aBoolean1464 = false; - Draw2D.method331(32, 32, class30_sub2_sub1_sub1_1.anIntArray1439); - Draw2D.method336(32, 0, 0, 0, 32); + int[] ai1 = Draw2D.pixels; + int i2 = Draw2D.width; + int j2 = Draw2D.height; + int k2 = Draw2D.left; + int l2 = Draw2D.right; + int i3 = Draw2D.top; + int j3 = Draw2D.bottom; + Draw3D.jagged = false; + Draw2D.bind(class30_sub2_sub1_sub1_1.anIntArray1439, 32, 32); + Draw2D.fillRect(0, 0, 32, 32, 0); Draw3D.method364(); int k3 = type.anInt181; if (k == -1) { @@ -164,9 +164,9 @@ public class ObjType { if (k > 0) { k3 = (int) ((double) k3 * 1.04D); } - int l3 = Draw3D.anIntArray1470[type.anInt190] * k3 >> 16; - int i4 = Draw3D.anIntArray1471[type.anInt190] * k3 >> 16; - model.method482(0, type.anInt198, type.anInt204, type.anInt190, type.anInt169, l3 + model.anInt1426 / 2 + type.anInt194, i4 + type.anInt194); + int l3 = Draw3D.sin[type.anInt190] * k3 >> 16; + int i4 = Draw3D.cos[type.anInt190] * k3 >> 16; + model.drawSimple(0, type.anInt198, type.anInt204, type.anInt190, type.anInt169, l3 + model.minY / 2 + type.anInt194, i4 + type.anInt194); for (int i5 = 31; i5 >= 0; i5--) { for (int j4 = 31; j4 >= 0; j4--) { if (class30_sub2_sub1_sub1_1.anIntArray1439[i5 + j4 * 32] == 0) { @@ -219,12 +219,12 @@ public class ObjType { if (k == 0) { aCache_158.method223(class30_sub2_sub1_sub1_1, i); } - Draw2D.method331(j2, i2, ai1); - Draw2D.method333(j3, k2, l2, i3); - Draw3D.anInt1466 = k1; - Draw3D.anInt1467 = l1; + Draw2D.bind(ai1, i2, j2); + Draw2D.setBounds(j3, k2, l2, i3); + Draw3D.centerX = k1; + Draw3D.centerY = l1; Draw3D.anIntArray1472 = ai; - Draw3D.aBoolean1464 = true; + Draw3D.jagged = true; if (type.aBoolean176) { class30_sub2_sub1_sub1_1.anInt1444 = 33; } else { @@ -245,10 +245,10 @@ public class ObjType { return true; } boolean flag = true; - if (!Model.method463(k)) { + if (!Model.validate(k)) { flag = false; } - if (l != -1 && !Model.method463(l)) { + if (l != -1 && !Model.validate(l)) { flag = false; } return flag; @@ -264,15 +264,15 @@ public class ObjType { if (k == -1) { return null; } - Model model = Model.method462(k); + Model model = Model.tryGet(k); if (l != -1) { - Model model_1 = Model.method462(l); + Model model_1 = Model.tryGet(l); Model[] aclass30_sub2_sub4_sub6 = {model, model_1}; model = new Model(2, aclass30_sub2_sub4_sub6); } if (anIntArray156 != null) { for (int i1 = 0; i1 < anIntArray156.length; i1++) { - model.method476(anIntArray156[i1], anIntArray160[i1]); + model.replaceColor(anIntArray156[i1], anIntArray160[i1]); } } return model; @@ -291,13 +291,13 @@ public class ObjType { return true; } boolean flag = true; - if (!Model.method463(k)) { + if (!Model.validate(k)) { flag = false; } - if (l != -1 && !Model.method463(l)) { + if (l != -1 && !Model.validate(l)) { flag = false; } - if (i1 != -1 && !Model.method463(i1)) { + if (i1 != -1 && !Model.validate(i1)) { flag = false; } return flag; @@ -315,28 +315,28 @@ public class ObjType { if (j == -1) { return null; } - Model model = Model.method462(j); + Model model = Model.tryGet(j); if (k != -1) { if (l != -1) { - Model model_1 = Model.method462(k); - Model model_3 = Model.method462(l); + Model model_1 = Model.tryGet(k); + Model model_3 = Model.tryGet(l); Model[] aclass30_sub2_sub4_sub6_1 = {model, model_1, model_3}; model = new Model(3, aclass30_sub2_sub4_sub6_1); } else { - Model class30_sub2_sub4_sub6_2 = Model.method462(k); + Model class30_sub2_sub4_sub6_2 = Model.tryGet(k); Model[] aclass30_sub2_sub4_sub6 = {model, class30_sub2_sub4_sub6_2}; model = new Model(2, aclass30_sub2_sub4_sub6); } } if (i == 0 && aByte205 != 0) { - model.method475(0, aByte205, 0); + model.translate(0, aByte205, 0); } if (i == 1 && aByte154 != 0) { - model.method475(0, aByte154, 0); + model.translate(0, aByte154, 0); } if (anIntArray156 != null) { for (int i1 = 0; i1 < anIntArray156.length; i1++) { - model.method476(anIntArray156[i1], anIntArray160[i1]); + model.replaceColor(anIntArray156[i1], anIntArray160[i1]); } } return model; @@ -424,20 +424,20 @@ public class ObjType { if (model != null) { return model; } - model = Model.method462(anInt174); + model = Model.tryGet(anInt174); if (model == null) { return null; } if (anInt167 != 128 || anInt192 != 128 || anInt191 != 128) { - model.method478(anInt167, anInt191, anInt192); + model.scale(anInt167, anInt191, anInt192); } if (anIntArray156 != null) { for (int l = 0; l < anIntArray156.length; l++) { - model.method476(anIntArray156[l], anIntArray160[l]); + model.replaceColor(anIntArray156[l], anIntArray160[l]); } } - model.method479(64 + anInt196, 768 + anInt184, -50, -10, -50, true); - model.aBoolean1659 = true; + model.calculateNormals(64 + anInt196, 768 + anInt184, -50, -10, -50, true); + model.pickBounds = true; aCache_159.method223(model, anInt157); return model; } @@ -454,13 +454,13 @@ public class ObjType { return method198(j).method202(1); } } - Model model = Model.method462(anInt174); + Model model = Model.tryGet(anInt174); if (model == null) { return null; } if (anIntArray156 != null) { for (int l = 0; l < anIntArray156.length; l++) { - model.method476(anIntArray156[l], anIntArray160[l]); + model.replaceColor(anIntArray156[l], anIntArray160[l]); } } return model; diff --git a/src/main/java/PlayerEntity.java b/src/main/java/PlayerEntity.java index 3fd332c..2e211dc 100644 --- a/src/main/java/PlayerEntity.java +++ b/src/main/java/PlayerEntity.java @@ -42,8 +42,8 @@ public class PlayerEntity extends PathingEntity { if (model == null) { return null; } - super.anInt1507 = model.anInt1426; - model.aBoolean1659 = true; + super.anInt1507 = model.minY; + model.pickBounds = true; if (aBoolean1699) { return model; } @@ -51,16 +51,16 @@ public class PlayerEntity extends PathingEntity { SpotAnimType type = SpotAnimType.aTypeArray403[super.anInt1520]; Model class30_sub2_sub4_sub6_2 = type.method266(); if (class30_sub2_sub4_sub6_2 != null) { - Model model_3 = new Model(true, SeqTransform.method532(super.anInt1521), false, class30_sub2_sub4_sub6_2); - model_3.method475(0, -super.anInt1524, 0); - model_3.method469(); - model_3.method470(type.aType_407.anIntArray353[super.anInt1521]); - model_3.anIntArrayArray1658 = null; - model_3.anIntArrayArray1657 = null; + Model model_3 = new Model(true, SeqFrame.isNull(super.anInt1521), false, class30_sub2_sub4_sub6_2); + model_3.translate(0, -super.anInt1524, 0); + model_3.createLabelReferences(); + model_3.applySequenceFrame(type.aType_407.anIntArray353[super.anInt1521]); + model_3.labelFaces = null; + model_3.labelVertices = null; if (type.anInt410 != 128 || type.anInt411 != 128) { - model_3.method478(type.anInt410, type.anInt410, type.anInt411); + model_3.scale(type.anInt410, type.anInt410, type.anInt411); } - model_3.method479(64 + type.anInt413, 850 + type.anInt414, -30, -50, -30, true); + model_3.calculateNormals(64 + type.anInt413, 850 + type.anInt414, -30, -50, -30, true); Model[] aclass30_sub2_sub4_sub6_1 = {model, model_3}; model = new Model(2, -819, aclass30_sub2_sub4_sub6_1); } @@ -71,38 +71,38 @@ public class PlayerEntity extends PathingEntity { } if (Game.anInt1161 >= anInt1707 && Game.anInt1161 < anInt1708) { Model model_1 = aModel_1714; - model_1.method475(anInt1711 - super.anInt1550, anInt1712 - anInt1709, anInt1713 - super.anInt1551); + model_1.translate(anInt1711 - super.anInt1550, anInt1712 - anInt1709, anInt1713 - super.anInt1551); if (super.anInt1510 == 512) { - model_1.method473(); - model_1.method473(); - model_1.method473(); + model_1.rotateY90(); + model_1.rotateY90(); + model_1.rotateY90(); } else if (super.anInt1510 == 1024) { - model_1.method473(); - model_1.method473(); + model_1.rotateY90(); + model_1.rotateY90(); } else if (super.anInt1510 == 1536) { - model_1.method473(); + model_1.rotateY90(); } Model[] aclass30_sub2_sub4_sub6 = {model, model_1}; model = new Model(2, -819, aclass30_sub2_sub4_sub6); if (super.anInt1510 == 512) { - model_1.method473(); + model_1.rotateY90(); } else if (super.anInt1510 == 1024) { - model_1.method473(); - model_1.method473(); + model_1.rotateY90(); + model_1.rotateY90(); } else if (super.anInt1510 == 1536) { - model_1.method473(); - model_1.method473(); - model_1.method473(); + model_1.rotateY90(); + model_1.rotateY90(); + model_1.rotateY90(); } - model_1.method475(super.anInt1550 - anInt1711, anInt1709 - anInt1712, super.anInt1551 - anInt1713); + model_1.translate(super.anInt1550 - anInt1711, anInt1709 - anInt1712, super.anInt1551 - anInt1713); } } - model.aBoolean1659 = true; + model.pickBounds = true; return model; } public void method451(Buffer buffer) { - buffer.anInt1406 = 0; + buffer.position = 0; anInt1702 = buffer.method408(); anInt1706 = buffer.method408(); aType_1698 = null; @@ -209,11 +209,11 @@ public class PlayerEntity extends PathingEntity { } if (type.anInt360 >= 0) { j1 = type.anInt360; - l += j1 - anIntArray1717[5] << 8; + l += (long) j1 - anIntArray1717[5] << 8; } if (type.anInt361 >= 0) { k1 = type.anInt361; - l += k1 - anIntArray1717[3] << 16; + l += (long) k1 - anIntArray1717[3] << 16; } } else if (super.anInt1517 >= 0) { k = SeqType.aTypeArray351[super.anInt1517].anIntArray353[super.anInt1518]; @@ -272,30 +272,30 @@ public class PlayerEntity extends PathingEntity { model_1 = new Model(j2, aclass30_sub2_sub4_sub6); for (int j3 = 0; j3 < 5; j3++) { if (anIntArray1700[j3] != 0) { - model_1.method476(Game.anIntArrayArray1003[j3][0], Game.anIntArrayArray1003[j3][anIntArray1700[j3]]); + model_1.replaceColor(Game.anIntArrayArray1003[j3][0], Game.anIntArrayArray1003[j3][anIntArray1700[j3]]); if (j3 == 1) { - model_1.method476(Game.anIntArray1204[0], Game.anIntArray1204[anIntArray1700[j3]]); + model_1.replaceColor(Game.anIntArray1204[0], Game.anIntArray1204[anIntArray1700[j3]]); } } } - model_1.method469(); - model_1.method479(64, 850, -30, -50, -30, true); + model_1.createLabelReferences(); + model_1.calculateNormals(64, 850, -30, -50, -30, true); aCache_1704.method223(model_1, l); aLong1697 = l; } if (aBoolean1699) { return model_1; } - Model class30_sub2_sub4_sub6_2 = Model.A_MODEL___1621; - class30_sub2_sub4_sub6_2.method464(model_1, SeqTransform.method532(k) & SeqTransform.method532(i1)); + Model class30_sub2_sub4_sub6_2 = Model.EMPTY; + class30_sub2_sub4_sub6_2.set(model_1, SeqFrame.isNull(k) & SeqFrame.isNull(i1)); if (k != -1 && i1 != -1) { - class30_sub2_sub4_sub6_2.method471(SeqType.aTypeArray351[super.anInt1526].anIntArray357, i1, k); + class30_sub2_sub4_sub6_2.applySequenceFrames(k, i1, SeqType.aTypeArray351[super.anInt1526].anIntArray357); } else if (k != -1) { - class30_sub2_sub4_sub6_2.method470(k); + class30_sub2_sub4_sub6_2.applySequenceFrame(k); } - class30_sub2_sub4_sub6_2.method466(); - class30_sub2_sub4_sub6_2.anIntArrayArray1658 = null; - class30_sub2_sub4_sub6_2.anIntArrayArray1657 = null; + class30_sub2_sub4_sub6_2.calculateBoundsCylinder(); + class30_sub2_sub4_sub6_2.labelFaces = null; + class30_sub2_sub4_sub6_2.labelVertices = null; return class30_sub2_sub4_sub6_2; } @@ -344,9 +344,9 @@ public class PlayerEntity extends PathingEntity { Model model = new Model(k, aclass30_sub2_sub4_sub6); for (int j1 = 0; j1 < 5; j1++) { if (anIntArray1700[j1] != 0) { - model.method476(Game.anIntArrayArray1003[j1][0], Game.anIntArrayArray1003[j1][anIntArray1700[j1]]); + model.replaceColor(Game.anIntArrayArray1003[j1][0], Game.anIntArrayArray1003[j1][anIntArray1700[j1]]); if (j1 == 1) { - model.method476(Game.anIntArray1204[0], Game.anIntArray1204[anIntArray1700[j1]]); + model.replaceColor(Game.anIntArray1204[0], Game.anIntArray1204[anIntArray1700[j1]]); } } } diff --git a/src/main/java/ProjectileEntity.java b/src/main/java/ProjectileEntity.java index 8cdb5ae..4360968 100644 --- a/src/main/java/ProjectileEntity.java +++ b/src/main/java/ProjectileEntity.java @@ -72,18 +72,18 @@ public class ProjectileEntity extends Entity { if (aType_1592.aType_407 != null) { j = aType_1592.aType_407.anIntArray353[anInt1593]; } - Model model_1 = new Model(true, SeqTransform.method532(j), false, model); + Model model_1 = new Model(true, SeqFrame.isNull(j), false, model); if (j != -1) { - model_1.method469(); - model_1.method470(j); - model_1.anIntArrayArray1658 = null; - model_1.anIntArrayArray1657 = null; + model_1.createLabelReferences(); + model_1.applySequenceFrame(j); + model_1.labelFaces = null; + model_1.labelVertices = null; } if (aType_1592.anInt410 != 128 || aType_1592.anInt411 != 128) { - model_1.method478(aType_1592.anInt410, aType_1592.anInt410, aType_1592.anInt411); + model_1.scale(aType_1592.anInt410, aType_1592.anInt410, aType_1592.anInt411); } - model_1.method474(anInt1596); - model_1.method479(64 + aType_1592.anInt413, 850 + aType_1592.anInt414, -30, -50, -30, true); + model_1.rotateX(anInt1596); + model_1.calculateNormals(64 + aType_1592.anInt413, 850 + aType_1592.anInt414, -30, -50, -30, true); return model_1; } diff --git a/src/main/java/SceneBuilder.java b/src/main/java/SceneBuilder.java index f5e08fa..15d9109 100644 --- a/src/main/java/SceneBuilder.java +++ b/src/main/java/SceneBuilder.java @@ -114,7 +114,7 @@ public class SceneBuilder { } public static int method184(int i, int i_216_, int i_217_, int i_218_) { - int i_219_ = (65536 - Draw3D.anIntArray1471[i_217_ * 1024 / i_218_] >> 1); + int i_219_ = (65536 - Draw3D.cos[i_217_ * 1024 / i_218_] >> 1); return (i * (65536 - i_219_) >> 16) + (i_216_ * i_219_ >> 16); } @@ -526,7 +526,7 @@ public class SceneBuilder { } int i_58_ = 0; if (i_53_ != -1) { - i_58_ = (Draw3D.anIntArray1482[method187(i_54_, 96)]); + i_58_ = (Draw3D.palette[method187(i_54_, 96)]); } if (i_44_ == 0) { graph.method279(i_10_, i_29_, i_40_, 0, 0, -1, i_45_, i_46_, i_47_, i_48_, method187(i_53_, i_49_), method187(i_53_, i_50_), method187(i_53_, i_51_), method187(i_53_, i_52_), 0, 0, 0, 0, i_58_, 0); @@ -546,7 +546,7 @@ public class SceneBuilder { i_61_ = -1; } else { i_63_ = method177(type.anInt394, type.anInt395, type.anInt396); - i_62_ = (Draw3D.anIntArray1482[method185(type.anInt399, 96)]); + i_62_ = (Draw3D.palette[method185(type.anInt399, 96)]); } graph.method279(i_10_, i_29_, i_40_, i_59_, i_60_, i_61_, i_45_, i_46_, i_47_, i_48_, method187(i_53_, i_49_), method187(i_53_, i_50_), method187(i_53_, i_51_), method187(i_53_, i_52_), method185(i_63_, i_49_), method185(i_63_, i_50_), method185(i_63_, i_51_), method185(i_63_, i_52_), i_58_, i_62_); } @@ -801,7 +801,7 @@ public class SceneBuilder { if (model != null) { for (int i_134_ = 0; i_134_ <= i_132_; i_134_++) { for (int i_135_ = 0; i_135_ <= i_133_; i_135_++) { - int i_136_ = model.anInt1650 / 4; + int i_136_ = model.radius / 4; if (i_136_ > 30) { i_136_ = 30; } diff --git a/src/main/java/SceneGraph.java b/src/main/java/SceneGraph.java index e557f36..02339c6 100644 --- a/src/main/java/SceneGraph.java +++ b/src/main/java/SceneGraph.java @@ -26,15 +26,15 @@ public class SceneGraph { public static int anInt450; public static int anInt451; public static int anInt452; - public static int anInt453; - public static int anInt454; - public static int anInt455; - public static int anInt456; - public static int anInt457; - public static int anInt458; - public static int anInt459; - public static int anInt460; - public static int anInt461; + public static int eyeTileX; + public static int eyeTileZ; + public static int eyeX; + public static int eyeY; + public static int eyeZ; + public static int sinEyePitch; + public static int cosEyePitch; + public static int sinEyeYaw; + public static int cosEyeYaw; public static SceneLoc[] aLocArray462 = new SceneLoc[100]; public static boolean aBoolean467; public static int anInt468; @@ -116,10 +116,10 @@ public class SceneGraph { boolean[][][][] aflag = new boolean[9][32][53][53]; for (int i1 = 128; i1 <= 384; i1 += 32) { for (int j1 = 0; j1 < 2048; j1 += 64) { - anInt458 = Model.anIntArray1689[i1]; - anInt459 = Model.anIntArray1690[i1]; - anInt460 = Model.anIntArray1689[j1]; - anInt461 = Model.anIntArray1690[j1]; + sinEyePitch = Model.sin[i1]; + cosEyePitch = Model.cos[i1]; + sinEyeYaw = Model.sin[j1]; + cosEyeYaw = Model.cos[j1]; int l1 = (i1 - 128) / 32; int j2 = j1 / 64; for (int l2 = -26; l2 <= 26; l2++) { @@ -170,10 +170,10 @@ public class SceneGraph { } public static boolean method311(int i, int j, int k) { - int l = j * anInt460 + k * anInt461 >> 16; - int i1 = j * anInt461 - k * anInt460 >> 16; - int j1 = i * anInt458 + i1 * anInt459 >> 16; - int k1 = i * anInt459 - i1 * anInt458 >> 16; + int l = j * sinEyeYaw + k * cosEyeYaw >> 16; + int i1 = j * cosEyeYaw - k * sinEyeYaw >> 16; + int j1 = i * sinEyePitch + i1 * cosEyePitch >> 16; + int k1 = i * cosEyePitch - i1 * sinEyePitch >> 16; if (j1 < 50 || j1 > 3500) { return false; } @@ -670,26 +670,26 @@ public class SceneGraph { SceneTile tile = aTileArrayArrayArray441[l1][i2][j2]; if (tile != null) { SceneWall wall = tile.aWall_1313; - if (wall != null && wall.aEntity_278 != null && wall.aEntity_278.aNormalArray1425 != null) { + if (wall != null && wall.aEntity_278 != null && wall.aEntity_278.vertexNormal != null) { method307(l1, 1, 1, i2, j2, (Model) wall.aEntity_278); - if (wall.aEntity_279 != null && wall.aEntity_279.aNormalArray1425 != null) { + if (wall.aEntity_279 != null && wall.aEntity_279.vertexNormal != null) { method307(l1, 1, 1, i2, j2, (Model) wall.aEntity_279); method308((Model) wall.aEntity_278, (Model) wall.aEntity_279, 0, 0, 0, false); - ((Model) wall.aEntity_279).method480(j, k1, k, i, i1); + ((Model) wall.aEntity_279).applyLighting(j, k1, k, i, i1); } - ((Model) wall.aEntity_278).method480(j, k1, k, i, i1); + ((Model) wall.aEntity_278).applyLighting(j, k1, k, i, i1); } for (int k2 = 0; k2 < tile.anInt1317; k2++) { SceneLoc loc = tile.aLocArray1318[k2]; - if (loc != null && loc.aEntity_521 != null && loc.aEntity_521.aNormalArray1425 != null) { + if (loc != null && loc.aEntity_521 != null && loc.aEntity_521.vertexNormal != null) { method307(l1, (loc.anInt524 - loc.anInt523) + 1, (loc.anInt526 - loc.anInt525) + 1, i2, j2, (Model) loc.aEntity_521); - ((Model) loc.aEntity_521).method480(j, k1, k, i, i1); + ((Model) loc.aEntity_521).applyLighting(j, k1, k, i, i1); } } SceneGroundDecoration groundDecoration = tile.aGroundDecoration_1315; - if (groundDecoration != null && groundDecoration.aEntity_814.aNormalArray1425 != null) { + if (groundDecoration != null && groundDecoration.aEntity_814.vertexNormal != null) { method306(i2, l1, (Model) groundDecoration.aEntity_814, j2); - ((Model) groundDecoration.aEntity_814).method480(j, k1, k, i, i1); + ((Model) groundDecoration.aEntity_814).applyLighting(j, k1, k, i, i1); } } } @@ -700,25 +700,25 @@ public class SceneGraph { public void method306(int i, int j, Model model, int k) { if (i < anInt438) { SceneTile tile = aTileArrayArrayArray441[j][i + 1][k]; - if (tile != null && tile.aGroundDecoration_1315 != null && tile.aGroundDecoration_1315.aEntity_814.aNormalArray1425 != null) { + if (tile != null && tile.aGroundDecoration_1315 != null && tile.aGroundDecoration_1315.aEntity_814.vertexNormal != null) { method308(model, (Model) tile.aGroundDecoration_1315.aEntity_814, 128, 0, 0, true); } } if (k < anInt438) { SceneTile tile_1 = aTileArrayArrayArray441[j][i][k + 1]; - if (tile_1 != null && tile_1.aGroundDecoration_1315 != null && tile_1.aGroundDecoration_1315.aEntity_814.aNormalArray1425 != null) { + if (tile_1 != null && tile_1.aGroundDecoration_1315 != null && tile_1.aGroundDecoration_1315.aEntity_814.vertexNormal != null) { method308(model, (Model) tile_1.aGroundDecoration_1315.aEntity_814, 0, 0, 128, true); } } if (i < anInt438 && k < anInt439) { SceneTile tile_2 = aTileArrayArrayArray441[j][i + 1][k + 1]; - if (tile_2 != null && tile_2.aGroundDecoration_1315 != null && tile_2.aGroundDecoration_1315.aEntity_814.aNormalArray1425 != null) { + if (tile_2 != null && tile_2.aGroundDecoration_1315 != null && tile_2.aGroundDecoration_1315.aEntity_814.vertexNormal != null) { method308(model, (Model) tile_2.aGroundDecoration_1315.aEntity_814, 128, 0, 128, true); } } if (i < anInt438 && k > 0) { SceneTile tile_3 = aTileArrayArrayArray441[j][i + 1][k - 1]; - if (tile_3 != null && tile_3.aGroundDecoration_1315 != null && tile_3.aGroundDecoration_1315.aEntity_814.aNormalArray1425 != null) { + if (tile_3 != null && tile_3.aGroundDecoration_1315 != null && tile_3.aGroundDecoration_1315.aEntity_814.vertexNormal != null) { method308(model, (Model) tile_3.aGroundDecoration_1315.aEntity_814, 128, 0, -128, true); } } @@ -740,15 +740,15 @@ public class SceneGraph { if (tile != null) { int i3 = (anIntArrayArrayArray440[j2][k2][l2] + anIntArrayArrayArray440[j2][k2 + 1][l2] + anIntArrayArrayArray440[j2][k2][l2 + 1] + anIntArrayArrayArray440[j2][k2 + 1][l2 + 1]) / 4 - (anIntArrayArrayArray440[i][l][i1] + anIntArrayArrayArray440[i][l + 1][i1] + anIntArrayArrayArray440[i][l][i1 + 1] + anIntArrayArrayArray440[i][l + 1][i1 + 1]) / 4; SceneWall wall = tile.aWall_1313; - if (wall != null && wall.aEntity_278 != null && wall.aEntity_278.aNormalArray1425 != null) { + if (wall != null && wall.aEntity_278 != null && wall.aEntity_278.vertexNormal != null) { method308(model, (Model) wall.aEntity_278, (k2 - l) * 128 + (1 - j) * 64, i3, (l2 - i1) * 128 + (1 - k) * 64, flag); } - if (wall != null && wall.aEntity_279 != null && wall.aEntity_279.aNormalArray1425 != null) { + if (wall != null && wall.aEntity_279 != null && wall.aEntity_279.vertexNormal != null) { method308(model, (Model) wall.aEntity_279, (k2 - l) * 128 + (1 - j) * 64, i3, (l2 - i1) * 128 + (1 - k) * 64, flag); } for (int j3 = 0; j3 < tile.anInt1317; j3++) { SceneLoc loc = tile.aLocArray1318[j3]; - if (loc != null && loc.aEntity_521 != null && loc.aEntity_521.aNormalArray1425 != null) { + if (loc != null && loc.aEntity_521 != null && loc.aEntity_521.vertexNormal != null) { int k3 = (loc.anInt524 - loc.anInt523) + 1; int l3 = (loc.anInt526 - loc.anInt525) + 1; method308(model, (Model) loc.aEntity_521, (loc.anInt523 - l) * 128 + (k3 - j) * 64, i3, (loc.anInt525 - i1) * 128 + (l3 - k) * 64, flag); @@ -768,30 +768,30 @@ public class SceneGraph { public void method308(Model model, Model model_1, int i, int j, int k, boolean flag) { anInt488++; int l = 0; - int[] ai = model_1.anIntArray1627; - int i1 = model_1.anInt1626; - for (int j1 = 0; j1 < model.anInt1626; j1++) { - VertexNormal normal = model.aNormalArray1425[j1]; - VertexNormal normal_1 = model.aNormalArray1660[j1]; - if (normal_1.anInt605 != 0) { - int i2 = model.anIntArray1628[j1] - j; - if (i2 <= model_1.anInt1651) { - int j2 = model.anIntArray1627[j1] - i; - if (j2 >= model_1.anInt1646 && j2 <= model_1.anInt1647) { - int k2 = model.anIntArray1629[j1] - k; - if (k2 >= model_1.anInt1649 && k2 <= model_1.anInt1648) { + int[] ai = model_1.vertexX; + int i1 = model_1.vertexCount; + for (int j1 = 0; j1 < model.vertexCount; j1++) { + VertexNormal normal = model.vertexNormal[j1]; + VertexNormal normal_1 = model.vertexNormalOriginal[j1]; + if (normal_1.w != 0) { + int i2 = model.vertexY[j1] - j; + if (i2 <= model_1.maxY) { + int j2 = model.vertexX[j1] - i; + if (j2 >= model_1.minX && j2 <= model_1.maxX) { + int k2 = model.vertexZ[j1] - k; + if (k2 >= model_1.minZ && k2 <= model_1.maxZ) { for (int l2 = 0; l2 < i1; l2++) { - VertexNormal normal_2 = model_1.aNormalArray1425[l2]; - VertexNormal normal_3 = model_1.aNormalArray1660[l2]; - if (j2 == ai[l2] && k2 == model_1.anIntArray1629[l2] && i2 == model_1.anIntArray1628[l2] && normal_3.anInt605 != 0) { - normal.anInt602 += normal_3.anInt602; - normal.anInt603 += normal_3.anInt603; - normal.anInt604 += normal_3.anInt604; - normal.anInt605 += normal_3.anInt605; - normal_2.anInt602 += normal_1.anInt602; - normal_2.anInt603 += normal_1.anInt603; - normal_2.anInt604 += normal_1.anInt604; - normal_2.anInt605 += normal_1.anInt605; + VertexNormal normal_2 = model_1.vertexNormal[l2]; + VertexNormal normal_3 = model_1.vertexNormalOriginal[l2]; + if (j2 == ai[l2] && k2 == model_1.vertexZ[l2] && i2 == model_1.vertexY[l2] && normal_3.w != 0) { + normal.x += normal_3.x; + normal.y += normal_3.y; + normal.z += normal_3.z; + normal.w += normal_3.w; + normal_2.x += normal_1.x; + normal_2.y += normal_1.y; + normal_2.z += normal_1.z; + normal_2.w += normal_1.w; l++; anIntArray486[j1] = anInt488; anIntArray487[l2] = anInt488; @@ -805,14 +805,14 @@ public class SceneGraph { if (l < 3 || !flag) { return; } - for (int k1 = 0; k1 < model.anInt1630; k1++) { - if (anIntArray486[model.anIntArray1631[k1]] == anInt488 && anIntArray486[model.anIntArray1632[k1]] == anInt488 && anIntArray486[model.anIntArray1633[k1]] == anInt488) { - model.anIntArray1637[k1] = -1; + for (int k1 = 0; k1 < model.faceCount; k1++) { + if (anIntArray486[model.faceVertexA[k1]] == anInt488 && anIntArray486[model.faceVertexB[k1]] == anInt488 && anIntArray486[model.faceVertexC[k1]] == anInt488) { + model.faceInfo[k1] = -1; } } - for (int l1 = 0; l1 < model_1.anInt1630; l1++) { - if (anIntArray487[model_1.anIntArray1631[l1]] == anInt488 && anIntArray487[model_1.anIntArray1632[l1]] == anInt488 && anIntArray487[model_1.anIntArray1633[l1]] == anInt488) { - model_1.anIntArray1637[l1] = -1; + for (int l1 = 0; l1 < model_1.faceCount; l1++) { + if (anIntArray487[model_1.faceVertexA[l1]] == anInt488 && anIntArray487[model_1.faceVertexB[l1]] == anInt488 && anIntArray487[model_1.faceVertexC[l1]] == anInt488) { + model_1.faceInfo[l1] = -1; } } } @@ -883,45 +883,42 @@ public class SceneGraph { anInt471 = -1; } - public void method313(int i, int j, int k, int l, int i1, int j1, boolean flag) { - if (i < 0) { - i = 0; - } else if (i >= anInt438 * 128) { - i = anInt438 * 128 - 1; + public void method313(int eyeX, int eyeZ, int eyeYaw, int eyeY, int i1, int eyePitch) { + if (eyeX < 0) { + eyeX = 0; + } else if (eyeX >= anInt438 * 128) { + eyeX = anInt438 * 128 - 1; } - if (j < 0) { - j = 0; - } else if (j >= anInt439 * 128) { - j = anInt439 * 128 - 1; + if (eyeZ < 0) { + eyeZ = 0; + } else if (eyeZ >= anInt439 * 128) { + eyeZ = anInt439 * 128 - 1; } anInt448++; - anInt458 = Model.anIntArray1689[j1]; - anInt459 = Model.anIntArray1690[j1]; - if (flag) { - return; - } - anInt460 = Model.anIntArray1689[k]; - anInt461 = Model.anIntArray1690[k]; - aBooleanArrayArray492 = aBooleanArrayArrayArrayArray491[(j1 - 128) / 32][k / 64]; - anInt455 = i; - anInt456 = l; - anInt457 = j; - anInt453 = i / 128; - anInt454 = j / 128; + sinEyePitch = Model.sin[eyePitch]; + cosEyePitch = Model.cos[eyePitch]; + sinEyeYaw = Model.sin[eyeYaw]; + cosEyeYaw = Model.cos[eyeYaw]; + aBooleanArrayArray492 = aBooleanArrayArrayArrayArray491[(eyePitch - 128) / 32][eyeYaw / 64]; + SceneGraph.eyeX = eyeX; + SceneGraph.eyeY = eyeY; + SceneGraph.eyeZ = eyeZ; + eyeTileX = eyeX / 128; + eyeTileZ = eyeZ / 128; anInt447 = i1; - anInt449 = anInt453 - 25; + anInt449 = eyeTileX - 25; if (anInt449 < 0) { anInt449 = 0; } - anInt451 = anInt454 - 25; + anInt451 = eyeTileZ - 25; if (anInt451 < 0) { anInt451 = 0; } - anInt450 = anInt453 + 25; + anInt450 = eyeTileX + 25; if (anInt450 > anInt438) { anInt450 = anInt438; } - anInt452 = anInt454 + 25; + anInt452 = eyeTileZ + 25; if (anInt452 > anInt439) { anInt452 = anInt439; } @@ -933,7 +930,7 @@ public class SceneGraph { for (int k2 = anInt451; k2 < anInt452; k2++) { SceneTile tile = aclass30_sub3[i2][k2]; if (tile != null) { - if (tile.anInt1321 > i1 || !aBooleanArrayArray492[(i2 - anInt453) + 25][(k2 - anInt454) + 25] && anIntArrayArrayArray440[k1][i2][k2] - l < 2000) { + if (tile.anInt1321 > i1 || !aBooleanArrayArray492[(i2 - eyeTileX) + 25][(k2 - eyeTileZ) + 25] && anIntArrayArrayArray440[k1][i2][k2] - eyeY < 2000) { tile.aBoolean1322 = false; tile.aBoolean1323 = false; tile.anInt1325 = 0; @@ -950,12 +947,12 @@ public class SceneGraph { for (int l1 = anInt442; l1 < anInt437; l1++) { SceneTile[][] aclass30_sub3_1 = aTileArrayArrayArray441[l1]; for (int l2 = -25; l2 <= 0; l2++) { - int i3 = anInt453 + l2; - int k3 = anInt453 - l2; + int i3 = eyeTileX + l2; + int k3 = eyeTileX - l2; if (i3 >= anInt449 || k3 < anInt450) { for (int i4 = -25; i4 <= 0; i4++) { - int k4 = anInt454 + i4; - int i5 = anInt454 - i4; + int k4 = eyeTileZ + i4; + int i5 = eyeTileZ - i4; if (i3 >= anInt449) { if (k4 >= anInt451) { SceneTile tile_1 = aclass30_sub3_1[i3][k4]; @@ -995,12 +992,12 @@ public class SceneGraph { for (int j2 = anInt442; j2 < anInt437; j2++) { SceneTile[][] aclass30_sub3_2 = aTileArrayArrayArray441[j2]; for (int j3 = -25; j3 <= 0; j3++) { - int l3 = anInt453 + j3; - int j4 = anInt453 - j3; + int l3 = eyeTileX + j3; + int j4 = eyeTileX - j3; if (l3 >= anInt449 || j4 < anInt450) { for (int l4 = -25; l4 <= 0; l4++) { - int j5 = anInt454 + l4; - int k5 = anInt454 - l4; + int j5 = eyeTileZ + l4; + int k5 = eyeTileZ - l4; if (l3 >= anInt449) { if (j5 >= anInt451) { SceneTile tile_5 = aclass30_sub3_2[l3][j5]; @@ -1063,25 +1060,25 @@ public class SceneGraph { continue; } } - if (i <= anInt453 && i > anInt449) { + if (i <= eyeTileX && i > anInt449) { SceneTile tile_3 = aclass30_sub3[i - 1][j]; if (tile_3 != null && tile_3.aBoolean1323 && (tile_3.aBoolean1322 || (tile_1.anInt1320 & 1) == 0)) { continue; } } - if (i >= anInt453 && i < anInt450 - 1) { + if (i >= eyeTileX && i < anInt450 - 1) { SceneTile tile_4 = aclass30_sub3[i + 1][j]; if (tile_4 != null && tile_4.aBoolean1323 && (tile_4.aBoolean1322 || (tile_1.anInt1320 & 4) == 0)) { continue; } } - if (j <= anInt454 && j > anInt451) { + if (j <= eyeTileZ && j > anInt451) { SceneTile tile_5 = aclass30_sub3[i][j - 1]; if (tile_5 != null && tile_5.aBoolean1323 && (tile_5.aBoolean1322 || (tile_1.anInt1320 & 8) == 0)) { continue; } } - if (j >= anInt454 && j < anInt452 - 1) { + if (j >= eyeTileZ && j < anInt452 - 1) { SceneTile tile_6 = aclass30_sub3[i][j + 1]; if (tile_6 != null && tile_6.aBoolean1323 && (tile_6.aBoolean1322 || (tile_1.anInt1320 & 2) == 0)) { continue; @@ -1095,19 +1092,19 @@ public class SceneGraph { SceneTile tile_7 = tile_1.aTile_1329; if (tile_7.aUnderlay_1311 != null) { if (!method320(0, i, j)) { - method315(tile_7.aUnderlay_1311, 0, anInt458, anInt459, anInt460, anInt461, i, j); + method315(tile_7.aUnderlay_1311, 0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, i, j); } } else if (tile_7.aOverlay_1312 != null && !method320(0, i, j)) { - method316(i, anInt458, anInt460, tile_7.aOverlay_1312, anInt459, j, anInt461); + method316(i, sinEyePitch, sinEyeYaw, tile_7.aOverlay_1312, cosEyePitch, j, cosEyeYaw); } SceneWall wall = tile_7.aWall_1313; if (wall != null) { - wall.aEntity_278.method443(0, anInt458, anInt459, anInt460, anInt461, wall.anInt274 - anInt455, wall.anInt273 - anInt456, wall.anInt275 - anInt457, wall.anInt280); + wall.aEntity_278.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall.anInt274 - eyeX, wall.anInt273 - eyeY, wall.anInt275 - eyeZ, wall.anInt280); } for (int i2 = 0; i2 < tile_7.anInt1317; i2++) { SceneLoc loc = tile_7.aLocArray1318[i2]; if (loc != null) { - loc.aEntity_521.method443(loc.anInt522, anInt458, anInt459, anInt460, anInt461, loc.anInt519 - anInt455, loc.anInt518 - anInt456, loc.anInt520 - anInt457, loc.anInt529); + loc.aEntity_521.draw(loc.anInt522, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, loc.anInt519 - eyeX, loc.anInt518 - eyeY, loc.anInt520 - eyeZ, loc.anInt529); } } } @@ -1115,25 +1112,25 @@ public class SceneGraph { if (tile_1.aUnderlay_1311 != null) { if (!method320(l, i, j)) { flag1 = true; - method315(tile_1.aUnderlay_1311, l, anInt458, anInt459, anInt460, anInt461, i, j); + method315(tile_1.aUnderlay_1311, l, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, i, j); } } else if (tile_1.aOverlay_1312 != null && !method320(l, i, j)) { flag1 = true; - method316(i, anInt458, anInt460, tile_1.aOverlay_1312, anInt459, j, anInt461); + method316(i, sinEyePitch, sinEyeYaw, tile_1.aOverlay_1312, cosEyePitch, j, cosEyeYaw); } int j1 = 0; int j2 = 0; SceneWall wall_3 = tile_1.aWall_1313; SceneWallDecoration wallDecoration_1 = tile_1.aWallDecoration_1314; if (wall_3 != null || wallDecoration_1 != null) { - if (anInt453 == i) { + if (eyeTileX == i) { j1++; - } else if (anInt453 < i) { + } else if (eyeTileX < i) { j1 += 2; } - if (anInt454 == j) { + if (eyeTileZ == j) { j1 += 3; - } else if (anInt454 > j) { + } else if (eyeTileZ > j) { j1 += 6; } j2 = anIntArray478[j1]; @@ -1162,19 +1159,19 @@ public class SceneGraph { tile_1.anInt1325 = 0; } if ((wall_3.anInt276 & j2) != 0 && !method321(l, i, j, wall_3.anInt276)) { - wall_3.aEntity_278.method443(0, anInt458, anInt459, anInt460, anInt461, wall_3.anInt274 - anInt455, wall_3.anInt273 - anInt456, wall_3.anInt275 - anInt457, wall_3.anInt280); + wall_3.aEntity_278.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall_3.anInt274 - eyeX, wall_3.anInt273 - eyeY, wall_3.anInt275 - eyeZ, wall_3.anInt280); } if ((wall_3.anInt277 & j2) != 0 && !method321(l, i, j, wall_3.anInt277)) { - wall_3.aEntity_279.method443(0, anInt458, anInt459, anInt460, anInt461, wall_3.anInt274 - anInt455, wall_3.anInt273 - anInt456, wall_3.anInt275 - anInt457, wall_3.anInt280); + wall_3.aEntity_279.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall_3.anInt274 - eyeX, wall_3.anInt273 - eyeY, wall_3.anInt275 - eyeZ, wall_3.anInt280); } } - if (wallDecoration_1 != null && !method322(l, i, j, wallDecoration_1.aEntity_504.anInt1426)) { + if (wallDecoration_1 != null && !method322(l, i, j, wallDecoration_1.aEntity_504.minY)) { if ((wallDecoration_1.anInt502 & j2) != 0) { - wallDecoration_1.aEntity_504.method443(wallDecoration_1.anInt503, anInt458, anInt459, anInt460, anInt461, wallDecoration_1.anInt500 - anInt455, wallDecoration_1.anInt499 - anInt456, wallDecoration_1.anInt501 - anInt457, wallDecoration_1.anInt505); + wallDecoration_1.aEntity_504.draw(wallDecoration_1.anInt503, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wallDecoration_1.anInt500 - eyeX, wallDecoration_1.anInt499 - eyeY, wallDecoration_1.anInt501 - eyeZ, wallDecoration_1.anInt505); } else if ((wallDecoration_1.anInt502 & 0x300) != 0) { - int j4 = wallDecoration_1.anInt500 - anInt455; - int l5 = wallDecoration_1.anInt499 - anInt456; - int k6 = wallDecoration_1.anInt501 - anInt457; + int j4 = wallDecoration_1.anInt500 - eyeX; + int l5 = wallDecoration_1.anInt499 - eyeY; + int k6 = wallDecoration_1.anInt501 - eyeZ; int i8 = wallDecoration_1.anInt503; int k9; if (i8 == 1 || i8 == 2) { @@ -1191,54 +1188,54 @@ public class SceneGraph { if ((wallDecoration_1.anInt502 & 0x100) != 0 && k10 < k9) { int i11 = j4 + anIntArray463[i8]; int k11 = k6 + anIntArray464[i8]; - wallDecoration_1.aEntity_504.method443(i8 * 512 + 256, anInt458, anInt459, anInt460, anInt461, i11, l5, k11, wallDecoration_1.anInt505); + wallDecoration_1.aEntity_504.draw(i8 * 512 + 256, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, i11, l5, k11, wallDecoration_1.anInt505); } if ((wallDecoration_1.anInt502 & 0x200) != 0 && k10 > k9) { int j11 = j4 + anIntArray465[i8]; int l11 = k6 + anIntArray466[i8]; - wallDecoration_1.aEntity_504.method443(i8 * 512 + 1280 & 0x7ff, anInt458, anInt459, anInt460, anInt461, j11, l5, l11, wallDecoration_1.anInt505); + wallDecoration_1.aEntity_504.draw(i8 * 512 + 1280 & 0x7ff, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, j11, l5, l11, wallDecoration_1.anInt505); } } } if (flag1) { SceneGroundDecoration groundDecoration = tile_1.aGroundDecoration_1315; if (groundDecoration != null) { - groundDecoration.aEntity_814.method443(0, anInt458, anInt459, anInt460, anInt461, groundDecoration.anInt812 - anInt455, groundDecoration.anInt811 - anInt456, groundDecoration.anInt813 - anInt457, groundDecoration.anInt815); + groundDecoration.aEntity_814.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, groundDecoration.anInt812 - eyeX, groundDecoration.anInt811 - eyeY, groundDecoration.anInt813 - eyeZ, groundDecoration.anInt815); } SceneObjStack objStack_1 = tile_1.aObjStack_1316; if (objStack_1 != null && objStack_1.anInt52 == 0) { if (objStack_1.aEntity_49 != null) { - objStack_1.aEntity_49.method443(0, anInt458, anInt459, anInt460, anInt461, objStack_1.anInt46 - anInt455, objStack_1.anInt45 - anInt456, objStack_1.anInt47 - anInt457, objStack_1.anInt51); + objStack_1.aEntity_49.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack_1.anInt46 - eyeX, objStack_1.anInt45 - eyeY, objStack_1.anInt47 - eyeZ, objStack_1.anInt51); } if (objStack_1.aEntity_50 != null) { - objStack_1.aEntity_50.method443(0, anInt458, anInt459, anInt460, anInt461, objStack_1.anInt46 - anInt455, objStack_1.anInt45 - anInt456, objStack_1.anInt47 - anInt457, objStack_1.anInt51); + objStack_1.aEntity_50.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack_1.anInt46 - eyeX, objStack_1.anInt45 - eyeY, objStack_1.anInt47 - eyeZ, objStack_1.anInt51); } if (objStack_1.aEntity_48 != null) { - objStack_1.aEntity_48.method443(0, anInt458, anInt459, anInt460, anInt461, objStack_1.anInt46 - anInt455, objStack_1.anInt45 - anInt456, objStack_1.anInt47 - anInt457, objStack_1.anInt51); + objStack_1.aEntity_48.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack_1.anInt46 - eyeX, objStack_1.anInt45 - eyeY, objStack_1.anInt47 - eyeZ, objStack_1.anInt51); } } } int k4 = tile_1.anInt1320; if (k4 != 0) { - if (i < anInt453 && (k4 & 4) != 0) { + if (i < eyeTileX && (k4 & 4) != 0) { SceneTile tile_17 = aclass30_sub3[i + 1][j]; if (tile_17 != null && tile_17.aBoolean1323) { aList_477.method249(tile_17); } } - if (j < anInt454 && (k4 & 2) != 0) { + if (j < eyeTileZ && (k4 & 2) != 0) { SceneTile tile_18 = aclass30_sub3[i][j + 1]; if (tile_18 != null && tile_18.aBoolean1323) { aList_477.method249(tile_18); } } - if (i > anInt453 && (k4 & 1) != 0) { + if (i > eyeTileX && (k4 & 1) != 0) { SceneTile tile_19 = aclass30_sub3[i - 1][j]; if (tile_19 != null && tile_19.aBoolean1323) { aList_477.method249(tile_19); } } - if (j > anInt454 && (k4 & 8) != 0) { + if (j > eyeTileZ && (k4 & 8) != 0) { SceneTile tile_20 = aclass30_sub3[i][j - 1]; if (tile_20 != null && tile_20.aBoolean1323) { aList_477.method249(tile_20); @@ -1258,7 +1255,7 @@ public class SceneGraph { if (flag2) { SceneWall wall_1 = tile_1.aWall_1313; if (!method321(l, i, j, wall_1.anInt276)) { - wall_1.aEntity_278.method443(0, anInt458, anInt459, anInt460, anInt461, wall_1.anInt274 - anInt455, wall_1.anInt273 - anInt456, wall_1.anInt275 - anInt457, wall_1.anInt280); + wall_1.aEntity_278.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall_1.anInt274 - eyeX, wall_1.anInt273 - eyeY, wall_1.anInt275 - eyeZ, wall_1.anInt280); } tile_1.anInt1325 = 0; } @@ -1303,13 +1300,13 @@ public class SceneGraph { } } aLocArray462[l1++] = loc_1; - int i5 = anInt453 - loc_1.anInt523; - int i6 = loc_1.anInt524 - anInt453; + int i5 = eyeTileX - loc_1.anInt523; + int i6 = loc_1.anInt524 - eyeTileX; if (i6 > i5) { i5 = i6; } - int i7 = anInt454 - loc_1.anInt525; - int j8 = loc_1.anInt526 - anInt454; + int i7 = eyeTileZ - loc_1.anInt525; + int j8 = loc_1.anInt526 - eyeTileZ; if (j8 > i7) { loc_1.anInt527 = i5 + j8; } else { @@ -1326,10 +1323,10 @@ public class SceneGraph { i3 = loc_2.anInt527; l3 = j5; } else if (loc_2.anInt527 == i3) { - int j7 = loc_2.anInt519 - anInt455; - int k8 = loc_2.anInt520 - anInt457; - int l9 = aLocArray462[l3].anInt519 - anInt455; - int l10 = aLocArray462[l3].anInt520 - anInt457; + int j7 = loc_2.anInt519 - eyeX; + int k8 = loc_2.anInt520 - eyeZ; + int l9 = aLocArray462[l3].anInt519 - eyeX; + int l10 = aLocArray462[l3].anInt520 - eyeZ; if (j7 * j7 + k8 * k8 > l9 * l9 + l10 * l10) { l3 = j5; } @@ -1341,8 +1338,8 @@ public class SceneGraph { } SceneLoc loc_3 = aLocArray462[l3]; loc_3.anInt528 = anInt448; - if (!method323(l, loc_3.anInt523, loc_3.anInt524, loc_3.anInt525, loc_3.anInt526, loc_3.aEntity_521.anInt1426)) { - loc_3.aEntity_521.method443(loc_3.anInt522, anInt458, anInt459, anInt460, anInt461, loc_3.anInt519 - anInt455, loc_3.anInt518 - anInt456, loc_3.anInt520 - anInt457, loc_3.anInt529); + if (!method323(l, loc_3.anInt523, loc_3.anInt524, loc_3.anInt525, loc_3.anInt526, loc_3.aEntity_521.minY)) { + loc_3.aEntity_521.draw(loc_3.anInt522, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, loc_3.anInt519 - eyeX, loc_3.anInt518 - eyeY, loc_3.anInt520 - eyeZ, loc_3.anInt529); } for (int k7 = loc_3.anInt523; k7 <= loc_3.anInt524; k7++) { for (int l8 = loc_3.anInt525; l8 <= loc_3.anInt526; l8++) { @@ -1365,25 +1362,25 @@ public class SceneGraph { if (!tile_1.aBoolean1323 || tile_1.anInt1325 != 0) { continue; } - if (i <= anInt453 && i > anInt449) { + if (i <= eyeTileX && i > anInt449) { SceneTile tile_8 = aclass30_sub3[i - 1][j]; if (tile_8 != null && tile_8.aBoolean1323) { continue; } } - if (i >= anInt453 && i < anInt450 - 1) { + if (i >= eyeTileX && i < anInt450 - 1) { SceneTile tile_9 = aclass30_sub3[i + 1][j]; if (tile_9 != null && tile_9.aBoolean1323) { continue; } } - if (j <= anInt454 && j > anInt451) { + if (j <= eyeTileZ && j > anInt451) { SceneTile tile_10 = aclass30_sub3[i][j - 1]; if (tile_10 != null && tile_10.aBoolean1323) { continue; } } - if (j >= anInt454 && j < anInt452 - 1) { + if (j >= eyeTileZ && j < anInt452 - 1) { SceneTile tile_11 = aclass30_sub3[i][j + 1]; if (tile_11 != null && tile_11.aBoolean1323) { continue; @@ -1394,24 +1391,24 @@ public class SceneGraph { SceneObjStack objStack = tile_1.aObjStack_1316; if (objStack != null && objStack.anInt52 != 0) { if (objStack.aEntity_49 != null) { - objStack.aEntity_49.method443(0, anInt458, anInt459, anInt460, anInt461, objStack.anInt46 - anInt455, objStack.anInt45 - anInt456 - objStack.anInt52, objStack.anInt47 - anInt457, objStack.anInt51); + objStack.aEntity_49.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack.anInt46 - eyeX, objStack.anInt45 - eyeY - objStack.anInt52, objStack.anInt47 - eyeZ, objStack.anInt51); } if (objStack.aEntity_50 != null) { - objStack.aEntity_50.method443(0, anInt458, anInt459, anInt460, anInt461, objStack.anInt46 - anInt455, objStack.anInt45 - anInt456 - objStack.anInt52, objStack.anInt47 - anInt457, objStack.anInt51); + objStack.aEntity_50.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack.anInt46 - eyeX, objStack.anInt45 - eyeY - objStack.anInt52, objStack.anInt47 - eyeZ, objStack.anInt51); } if (objStack.aEntity_48 != null) { - objStack.aEntity_48.method443(0, anInt458, anInt459, anInt460, anInt461, objStack.anInt46 - anInt455, objStack.anInt45 - anInt456 - objStack.anInt52, objStack.anInt47 - anInt457, objStack.anInt51); + objStack.aEntity_48.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack.anInt46 - eyeX, objStack.anInt45 - eyeY - objStack.anInt52, objStack.anInt47 - eyeZ, objStack.anInt51); } } if (tile_1.anInt1328 != 0) { SceneWallDecoration wallDecoration = tile_1.aWallDecoration_1314; - if (wallDecoration != null && !method322(l, i, j, wallDecoration.aEntity_504.anInt1426)) { + if (wallDecoration != null && !method322(l, i, j, wallDecoration.aEntity_504.minY)) { if ((wallDecoration.anInt502 & tile_1.anInt1328) != 0) { - wallDecoration.aEntity_504.method443(wallDecoration.anInt503, anInt458, anInt459, anInt460, anInt461, wallDecoration.anInt500 - anInt455, wallDecoration.anInt499 - anInt456, wallDecoration.anInt501 - anInt457, wallDecoration.anInt505); + wallDecoration.aEntity_504.draw(wallDecoration.anInt503, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wallDecoration.anInt500 - eyeX, wallDecoration.anInt499 - eyeY, wallDecoration.anInt501 - eyeZ, wallDecoration.anInt505); } else if ((wallDecoration.anInt502 & 0x300) != 0) { - int l2 = wallDecoration.anInt500 - anInt455; - int j3 = wallDecoration.anInt499 - anInt456; - int i4 = wallDecoration.anInt501 - anInt457; + int l2 = wallDecoration.anInt500 - eyeX; + int j3 = wallDecoration.anInt499 - eyeY; + int i4 = wallDecoration.anInt501 - eyeZ; int k5 = wallDecoration.anInt503; int j6; if (k5 == 1 || k5 == 2) { @@ -1428,22 +1425,22 @@ public class SceneGraph { if ((wallDecoration.anInt502 & 0x100) != 0 && l7 >= j6) { int i9 = l2 + anIntArray463[k5]; int i10 = i4 + anIntArray464[k5]; - wallDecoration.aEntity_504.method443(k5 * 512 + 256, anInt458, anInt459, anInt460, anInt461, i9, j3, i10, wallDecoration.anInt505); + wallDecoration.aEntity_504.draw(k5 * 512 + 256, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, i9, j3, i10, wallDecoration.anInt505); } if ((wallDecoration.anInt502 & 0x200) != 0 && l7 <= j6) { int j9 = l2 + anIntArray465[k5]; int j10 = i4 + anIntArray466[k5]; - wallDecoration.aEntity_504.method443(k5 * 512 + 1280 & 0x7ff, anInt458, anInt459, anInt460, anInt461, j9, j3, j10, wallDecoration.anInt505); + wallDecoration.aEntity_504.draw(k5 * 512 + 1280 & 0x7ff, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, j9, j3, j10, wallDecoration.anInt505); } } } SceneWall wall_2 = tile_1.aWall_1313; if (wall_2 != null) { if ((wall_2.anInt277 & tile_1.anInt1328) != 0 && !method321(l, i, j, wall_2.anInt277)) { - wall_2.aEntity_279.method443(0, anInt458, anInt459, anInt460, anInt461, wall_2.anInt274 - anInt455, wall_2.anInt273 - anInt456, wall_2.anInt275 - anInt457, wall_2.anInt280); + wall_2.aEntity_279.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall_2.anInt274 - eyeX, wall_2.anInt273 - eyeY, wall_2.anInt275 - eyeZ, wall_2.anInt280); } if ((wall_2.anInt276 & tile_1.anInt1328) != 0 && !method321(l, i, j, wall_2.anInt276)) { - wall_2.aEntity_278.method443(0, anInt458, anInt459, anInt460, anInt461, wall_2.anInt274 - anInt455, wall_2.anInt273 - anInt456, wall_2.anInt275 - anInt457, wall_2.anInt280); + wall_2.aEntity_278.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall_2.anInt274 - eyeX, wall_2.anInt273 - eyeY, wall_2.anInt275 - eyeZ, wall_2.anInt280); } } } @@ -1453,25 +1450,25 @@ public class SceneGraph { aList_477.method249(tile_12); } } - if (i < anInt453) { + if (i < eyeTileX) { SceneTile tile_13 = aclass30_sub3[i + 1][j]; if (tile_13 != null && tile_13.aBoolean1323) { aList_477.method249(tile_13); } } - if (j < anInt454) { + if (j < eyeTileZ) { SceneTile tile_14 = aclass30_sub3[i][j + 1]; if (tile_14 != null && tile_14.aBoolean1323) { aList_477.method249(tile_14); } } - if (i > anInt453) { + if (i > eyeTileX) { SceneTile tile_15 = aclass30_sub3[i - 1][j]; if (tile_15 != null && tile_15.aBoolean1323) { aList_477.method249(tile_15); } } - if (j > anInt454) { + if (j > eyeTileZ) { SceneTile tile_16 = aclass30_sub3[i][j - 1]; if (tile_16 != null && tile_16.aBoolean1323) { aList_477.method249(tile_16); @@ -1482,17 +1479,17 @@ public class SceneGraph { public void method315(SceneTileUnderlay underlay, int i, int j, int k, int l, int i1, int j1, int k1) { int l1; - int i2 = l1 = (j1 << 7) - anInt455; + int i2 = l1 = (j1 << 7) - eyeX; int j2; - int k2 = j2 = (k1 << 7) - anInt457; + int k2 = j2 = (k1 << 7) - eyeZ; int l2; int i3 = l2 = i2 + 128; int j3; int k3 = j3 = k2 + 128; - int l3 = anIntArrayArrayArray440[i][j1][k1] - anInt456; - int i4 = anIntArrayArrayArray440[i][j1 + 1][k1] - anInt456; - int j4 = anIntArrayArrayArray440[i][j1 + 1][k1 + 1] - anInt456; - int k4 = anIntArrayArrayArray440[i][j1][k1 + 1] - anInt456; + int l3 = anIntArrayArrayArray440[i][j1][k1] - eyeY; + int i4 = anIntArrayArrayArray440[i][j1 + 1][k1] - eyeY; + int j4 = anIntArrayArrayArray440[i][j1 + 1][k1 + 1] - eyeY; + int k4 = anIntArrayArrayArray440[i][j1][k1 + 1] - eyeY; int l4 = k2 * l + i2 * i1 >> 16; k2 = k2 * i1 - i2 * l >> 16; i2 = l4; @@ -1529,53 +1526,53 @@ public class SceneGraph { if (j3 < 50) { return; } - int i5 = Draw3D.anInt1466 + (i2 << 9) / k2; - int j5 = Draw3D.anInt1467 + (l3 << 9) / k2; - int k5 = Draw3D.anInt1466 + (i3 << 9) / j2; - int l5 = Draw3D.anInt1467 + (i4 << 9) / j2; - int i6 = Draw3D.anInt1466 + (l2 << 9) / k3; - int j6 = Draw3D.anInt1467 + (j4 << 9) / k3; - int k6 = Draw3D.anInt1466 + (l1 << 9) / j3; - int l6 = Draw3D.anInt1467 + (k4 << 9) / j3; - Draw3D.anInt1465 = 0; + int i5 = Draw3D.centerX + (i2 << 9) / k2; + int j5 = Draw3D.centerY + (l3 << 9) / k2; + int k5 = Draw3D.centerX + (i3 << 9) / j2; + int l5 = Draw3D.centerY + (i4 << 9) / j2; + int i6 = Draw3D.centerX + (l2 << 9) / k3; + int j6 = Draw3D.centerY + (j4 << 9) / k3; + int k6 = Draw3D.centerX + (l1 << 9) / j3; + int l6 = Draw3D.centerY + (k4 << 9) / j3; + Draw3D.alpha = 0; if ((i6 - k6) * (l5 - l6) - (j6 - l6) * (k5 - k6) > 0) { - Draw3D.aBoolean1462 = i6 < 0 || k6 < 0 || k5 < 0 || i6 > Draw2D.anInt1385 || k6 > Draw2D.anInt1385 || k5 > Draw2D.anInt1385; + Draw3D.clipX = i6 < 0 || k6 < 0 || k5 < 0 || i6 > Draw2D.boundX || k6 > Draw2D.boundX || k5 > Draw2D.boundX; if (aBoolean467 && method318(anInt468, anInt469, j6, l6, l5, i6, k6, k5)) { anInt470 = j1; anInt471 = k1; } if (underlay.anInt720 == -1) { if (underlay.anInt718 != 0xbc614e) { - Draw3D.method374(j6, l6, l5, i6, k6, k5, underlay.anInt718, underlay.anInt719, underlay.anInt717); + Draw3D.fillGouraudTriangle(j6, l6, l5, i6, k6, k5, underlay.anInt718, underlay.anInt719, underlay.anInt717); } } else if (!aBoolean436) { if (underlay.aBoolean721) { - Draw3D.method378(j6, l6, l5, i6, k6, k5, underlay.anInt718, underlay.anInt719, underlay.anInt717, i2, i3, l1, l3, i4, k4, k2, j2, j3, underlay.anInt720); + Draw3D.fillTexturedTriangle(j6, l6, l5, i6, k6, k5, underlay.anInt718, underlay.anInt719, underlay.anInt717, i2, i3, l1, l3, i4, k4, k2, j2, j3, underlay.anInt720); } else { - Draw3D.method378(j6, l6, l5, i6, k6, k5, underlay.anInt718, underlay.anInt719, underlay.anInt717, l2, l1, i3, j4, k4, i4, k3, j3, j2, underlay.anInt720); + Draw3D.fillTexturedTriangle(j6, l6, l5, i6, k6, k5, underlay.anInt718, underlay.anInt719, underlay.anInt717, l2, l1, i3, j4, k4, i4, k3, j3, j2, underlay.anInt720); } } else { int i7 = anIntArray485[underlay.anInt720]; - Draw3D.method374(j6, l6, l5, i6, k6, k5, method317(i7, underlay.anInt718), method317(i7, underlay.anInt719), method317(i7, underlay.anInt717)); + Draw3D.fillGouraudTriangle(j6, l6, l5, i6, k6, k5, method317(i7, underlay.anInt718), method317(i7, underlay.anInt719), method317(i7, underlay.anInt717)); } } if ((i5 - k5) * (l6 - l5) - (j5 - l5) * (k6 - k5) > 0) { - Draw3D.aBoolean1462 = i5 < 0 || k5 < 0 || k6 < 0 || i5 > Draw2D.anInt1385 || k5 > Draw2D.anInt1385 || k6 > Draw2D.anInt1385; + Draw3D.clipX = i5 < 0 || k5 < 0 || k6 < 0 || i5 > Draw2D.boundX || k5 > Draw2D.boundX || k6 > Draw2D.boundX; if (aBoolean467 && method318(anInt468, anInt469, j5, l5, l6, i5, k5, k6)) { anInt470 = j1; anInt471 = k1; } if (underlay.anInt720 == -1) { if (underlay.anInt716 != 0xbc614e) { - Draw3D.method374(j5, l5, l6, i5, k5, k6, underlay.anInt716, underlay.anInt717, underlay.anInt719); + Draw3D.fillGouraudTriangle(j5, l5, l6, i5, k5, k6, underlay.anInt716, underlay.anInt717, underlay.anInt719); } } else { if (!aBoolean436) { - Draw3D.method378(j5, l5, l6, i5, k5, k6, underlay.anInt716, underlay.anInt717, underlay.anInt719, i2, i3, l1, l3, i4, k4, k2, j2, j3, underlay.anInt720); + Draw3D.fillTexturedTriangle(j5, l5, l6, i5, k5, k6, underlay.anInt716, underlay.anInt717, underlay.anInt719, i2, i3, l1, l3, i4, k4, k2, j2, j3, underlay.anInt720); return; } int j7 = anIntArray485[underlay.anInt720]; - Draw3D.method374(j5, l5, l6, i5, k5, k6, method317(j7, underlay.anInt716), method317(j7, underlay.anInt717), method317(j7, underlay.anInt719)); + Draw3D.fillGouraudTriangle(j5, l5, l6, i5, k5, k6, method317(j7, underlay.anInt716), method317(j7, underlay.anInt717), method317(j7, underlay.anInt719)); } } } @@ -1583,9 +1580,9 @@ public class SceneGraph { public void method316(int i, int j, int k, SceneTileOverlay overlay, int l, int i1, int j1) { int k1 = overlay.anIntArray673.length; for (int l1 = 0; l1 < k1; l1++) { - int i2 = overlay.anIntArray673[l1] - anInt455; - int k2 = overlay.anIntArray674[l1] - anInt456; - int i3 = overlay.anIntArray675[l1] - anInt457; + int i2 = overlay.anIntArray673[l1] - eyeX; + int k2 = overlay.anIntArray674[l1] - eyeY; + int i3 = overlay.anIntArray675[l1] - eyeZ; int k3 = i3 * k + i2 * j1 >> 16; i3 = i3 * j1 - i2 * k >> 16; i2 = k3; @@ -1600,10 +1597,10 @@ public class SceneGraph { SceneTileOverlay.anIntArray691[l1] = k2; SceneTileOverlay.anIntArray692[l1] = i3; } - SceneTileOverlay.anIntArray688[l1] = Draw3D.anInt1466 + (i2 << 9) / i3; - SceneTileOverlay.anIntArray689[l1] = Draw3D.anInt1467 + (k2 << 9) / i3; + SceneTileOverlay.anIntArray688[l1] = Draw3D.centerX + (i2 << 9) / i3; + SceneTileOverlay.anIntArray689[l1] = Draw3D.centerY + (k2 << 9) / i3; } - Draw3D.anInt1465 = 0; + Draw3D.alpha = 0; k1 = overlay.anIntArray679.length; for (int j2 = 0; j2 < k1; j2++) { int l2 = overlay.anIntArray679[j2]; @@ -1616,24 +1613,24 @@ public class SceneGraph { int i5 = SceneTileOverlay.anIntArray689[j3]; int j5 = SceneTileOverlay.anIntArray689[l3]; if ((i4 - j4) * (j5 - i5) - (l4 - i5) * (k4 - j4) > 0) { - Draw3D.aBoolean1462 = i4 < 0 || j4 < 0 || k4 < 0 || i4 > Draw2D.anInt1385 || j4 > Draw2D.anInt1385 || k4 > Draw2D.anInt1385; + Draw3D.clipX = i4 < 0 || j4 < 0 || k4 < 0 || i4 > Draw2D.boundX || j4 > Draw2D.boundX || k4 > Draw2D.boundX; if (aBoolean467 && method318(anInt468, anInt469, l4, i5, j5, i4, j4, k4)) { anInt470 = i; anInt471 = i1; } if (overlay.anIntArray682 == null || overlay.anIntArray682[j2] == -1) { if (overlay.anIntArray676[j2] != 0xbc614e) { - Draw3D.method374(l4, i5, j5, i4, j4, k4, overlay.anIntArray676[j2], overlay.anIntArray677[j2], overlay.anIntArray678[j2]); + Draw3D.fillGouraudTriangle(l4, i5, j5, i4, j4, k4, overlay.anIntArray676[j2], overlay.anIntArray677[j2], overlay.anIntArray678[j2]); } } else if (!aBoolean436) { if (overlay.aBoolean683) { - Draw3D.method378(l4, i5, j5, i4, j4, k4, overlay.anIntArray676[j2], overlay.anIntArray677[j2], overlay.anIntArray678[j2], SceneTileOverlay.anIntArray690[0], SceneTileOverlay.anIntArray690[1], SceneTileOverlay.anIntArray690[3], SceneTileOverlay.anIntArray691[0], SceneTileOverlay.anIntArray691[1], SceneTileOverlay.anIntArray691[3], SceneTileOverlay.anIntArray692[0], SceneTileOverlay.anIntArray692[1], SceneTileOverlay.anIntArray692[3], overlay.anIntArray682[j2]); + Draw3D.fillTexturedTriangle(l4, i5, j5, i4, j4, k4, overlay.anIntArray676[j2], overlay.anIntArray677[j2], overlay.anIntArray678[j2], SceneTileOverlay.anIntArray690[0], SceneTileOverlay.anIntArray690[1], SceneTileOverlay.anIntArray690[3], SceneTileOverlay.anIntArray691[0], SceneTileOverlay.anIntArray691[1], SceneTileOverlay.anIntArray691[3], SceneTileOverlay.anIntArray692[0], SceneTileOverlay.anIntArray692[1], SceneTileOverlay.anIntArray692[3], overlay.anIntArray682[j2]); } else { - Draw3D.method378(l4, i5, j5, i4, j4, k4, overlay.anIntArray676[j2], overlay.anIntArray677[j2], overlay.anIntArray678[j2], SceneTileOverlay.anIntArray690[l2], SceneTileOverlay.anIntArray690[j3], SceneTileOverlay.anIntArray690[l3], SceneTileOverlay.anIntArray691[l2], SceneTileOverlay.anIntArray691[j3], SceneTileOverlay.anIntArray691[l3], SceneTileOverlay.anIntArray692[l2], SceneTileOverlay.anIntArray692[j3], SceneTileOverlay.anIntArray692[l3], overlay.anIntArray682[j2]); + Draw3D.fillTexturedTriangle(l4, i5, j5, i4, j4, k4, overlay.anIntArray676[j2], overlay.anIntArray677[j2], overlay.anIntArray678[j2], SceneTileOverlay.anIntArray690[l2], SceneTileOverlay.anIntArray690[j3], SceneTileOverlay.anIntArray690[l3], SceneTileOverlay.anIntArray691[l2], SceneTileOverlay.anIntArray691[j3], SceneTileOverlay.anIntArray691[l3], SceneTileOverlay.anIntArray692[l2], SceneTileOverlay.anIntArray692[j3], SceneTileOverlay.anIntArray692[l3], overlay.anIntArray682[j2]); } } else { int k5 = anIntArray485[overlay.anIntArray682[j2]]; - Draw3D.method374(l4, i5, j5, i4, j4, k4, method317(k5, overlay.anIntArray676[j2]), method317(k5, overlay.anIntArray677[j2]), method317(k5, overlay.anIntArray678[j2])); + Draw3D.fillGouraudTriangle(l4, i5, j5, i4, j4, k4, method317(k5, overlay.anIntArray676[j2]), method317(k5, overlay.anIntArray677[j2]), method317(k5, overlay.anIntArray678[j2])); } } } @@ -1676,15 +1673,15 @@ public class SceneGraph { for (int k = 0; k < j; k++) { SceneOccluder occluder = aclass47[k]; if (occluder.anInt791 == 1) { - int l = (occluder.anInt787 - anInt453) + 25; + int l = (occluder.anInt787 - eyeTileX) + 25; if (l < 0 || l > 50) { continue; } - int k1 = (occluder.anInt789 - anInt454) + 25; + int k1 = (occluder.anInt789 - eyeTileZ) + 25; if (k1 < 0) { k1 = 0; } - int j2 = (occluder.anInt790 - anInt454) + 25; + int j2 = (occluder.anInt790 - eyeTileZ) + 25; if (j2 > 50) { j2 = 50; } @@ -1698,7 +1695,7 @@ public class SceneGraph { if (!flag) { continue; } - int j3 = anInt455 - occluder.anInt792; + int j3 = eyeX - occluder.anInt792; if (j3 > 32) { occluder.anInt798 = 1; } else { @@ -1708,23 +1705,23 @@ public class SceneGraph { occluder.anInt798 = 2; j3 = -j3; } - occluder.anInt801 = (occluder.anInt794 - anInt457 << 8) / j3; - occluder.anInt802 = (occluder.anInt795 - anInt457 << 8) / j3; - occluder.anInt803 = (occluder.anInt796 - anInt456 << 8) / j3; - occluder.anInt804 = (occluder.anInt797 - anInt456 << 8) / j3; + occluder.anInt801 = (occluder.anInt794 - eyeZ << 8) / j3; + occluder.anInt802 = (occluder.anInt795 - eyeZ << 8) / j3; + occluder.anInt803 = (occluder.anInt796 - eyeY << 8) / j3; + occluder.anInt804 = (occluder.anInt797 - eyeY << 8) / j3; A_OCCLUDER_ARRAY_476[anInt475++] = occluder; continue; } if (occluder.anInt791 == 2) { - int i1 = (occluder.anInt789 - anInt454) + 25; + int i1 = (occluder.anInt789 - eyeTileZ) + 25; if (i1 < 0 || i1 > 50) { continue; } - int l1 = (occluder.anInt787 - anInt453) + 25; + int l1 = (occluder.anInt787 - eyeTileX) + 25; if (l1 < 0) { l1 = 0; } - int k2 = (occluder.anInt788 - anInt453) + 25; + int k2 = (occluder.anInt788 - eyeTileX) + 25; if (k2 > 50) { k2 = 50; } @@ -1738,7 +1735,7 @@ public class SceneGraph { if (!flag1) { continue; } - int k3 = anInt457 - occluder.anInt794; + int k3 = eyeZ - occluder.anInt794; if (k3 > 32) { occluder.anInt798 = 3; } else { @@ -1748,28 +1745,28 @@ public class SceneGraph { occluder.anInt798 = 4; k3 = -k3; } - occluder.anInt799 = (occluder.anInt792 - anInt455 << 8) / k3; - occluder.anInt800 = (occluder.anInt793 - anInt455 << 8) / k3; - occluder.anInt803 = (occluder.anInt796 - anInt456 << 8) / k3; - occluder.anInt804 = (occluder.anInt797 - anInt456 << 8) / k3; + occluder.anInt799 = (occluder.anInt792 - eyeX << 8) / k3; + occluder.anInt800 = (occluder.anInt793 - eyeX << 8) / k3; + occluder.anInt803 = (occluder.anInt796 - eyeY << 8) / k3; + occluder.anInt804 = (occluder.anInt797 - eyeY << 8) / k3; A_OCCLUDER_ARRAY_476[anInt475++] = occluder; } else if (occluder.anInt791 == 4) { - int j1 = occluder.anInt796 - anInt456; + int j1 = occluder.anInt796 - eyeY; if (j1 > 128) { - int i2 = (occluder.anInt789 - anInt454) + 25; + int i2 = (occluder.anInt789 - eyeTileZ) + 25; if (i2 < 0) { i2 = 0; } - int l2 = (occluder.anInt790 - anInt454) + 25; + int l2 = (occluder.anInt790 - eyeTileZ) + 25; if (l2 > 50) { l2 = 50; } if (i2 <= l2) { - int i3 = (occluder.anInt787 - anInt453) + 25; + int i3 = (occluder.anInt787 - eyeTileX) + 25; if (i3 < 0) { i3 = 0; } - int l3 = (occluder.anInt788 - anInt453) + 25; + int l3 = (occluder.anInt788 - eyeTileX) + 25; if (l3 > 50) { l3 = 50; } @@ -1786,10 +1783,10 @@ public class SceneGraph { } if (flag2) { occluder.anInt798 = 5; - occluder.anInt799 = (occluder.anInt792 - anInt455 << 8) / j1; - occluder.anInt800 = (occluder.anInt793 - anInt455 << 8) / j1; - occluder.anInt801 = (occluder.anInt794 - anInt457 << 8) / j1; - occluder.anInt802 = (occluder.anInt795 - anInt457 << 8) / j1; + occluder.anInt799 = (occluder.anInt792 - eyeX << 8) / j1; + occluder.anInt800 = (occluder.anInt793 - eyeX << 8) / j1; + occluder.anInt801 = (occluder.anInt794 - eyeZ << 8) / j1; + occluder.anInt802 = (occluder.anInt795 - eyeZ << 8) / j1; A_OCCLUDER_ARRAY_476[anInt475++] = occluder; } } @@ -1829,7 +1826,7 @@ public class SceneGraph { int j2 = k1 - 238; if (l < 16) { if (l == 1) { - if (i1 > anInt455) { + if (i1 > eyeX) { if (!method324(i1, k1, j1)) { return false; } @@ -1851,7 +1848,7 @@ public class SceneGraph { return method324(i1, i2, j1 + 128); } if (l == 2) { - if (j1 < anInt457) { + if (j1 < eyeZ) { if (!method324(i1, k1, j1 + 128)) { return false; } @@ -1873,7 +1870,7 @@ public class SceneGraph { return method324(i1 + 128, i2, j1 + 128); } if (l == 4) { - if (i1 < anInt455) { + if (i1 < eyeX) { if (!method324(i1 + 128, k1, j1)) { return false; } @@ -1895,7 +1892,7 @@ public class SceneGraph { return method324(i1 + 128, i2, j1 + 128); } if (l == 8) { - if (j1 > anInt457) { + if (j1 > eyeZ) { if (!method324(i1, k1, j1)) { return false; } diff --git a/src/main/java/SeqFrame.java b/src/main/java/SeqFrame.java new file mode 100644 index 0000000..df60e8a --- /dev/null +++ b/src/main/java/SeqFrame.java @@ -0,0 +1,190 @@ +// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. +// Jad home page: http://www.kpdus.com/jad.html +// Decompiler options: packimports(3) + +/** + * A {@link SeqFrame} contains the {@link SeqSkeleton} and x,y,z parameters to transform a {@link Model}. + * + * @see Model#applySequenceFrame(int) + * @see Model#applySequenceFrames(int, int, int[]) + */ +public class SeqFrame { + + private static SeqFrame[] instances; + /** + * The skeleton associated to this frame. + */ + public SeqSkeleton skeleton; + /** + * The delay in ticks. + */ + public int delay; + /** + * The number of operations the frame performs. + */ + public int length; + /** + * The list of bases the frame uses. + */ + public int[] bases; + /** + * The frame parameters. + */ + + public int[] x, y, z; + + /** + * Syntax sugar. + * + * @param id the id + * @return id == -1 + */ + public static boolean isNull(int id) { + return id == -1; + } + + /** + * Initializes the array of instances. + * + * @param count the count + */ + public static void init(int count) { + instances = new SeqFrame[count + 1]; + } + + /** + * Nullifies the array of instances. + */ + public static void clear() { + instances = null; + } + + /** + * Gets the {@link SeqFrame} + * + * @param id the frame id. + * @return the {@link SeqFrame} or null if it does not exist. + */ + public static SeqFrame get(int id) { + if (instances == null || id < 0 || id >= instances.length) { + return null; + } else { + return instances[id]; + } + } + + /** + * Reads the animation data and stores its frames in {@link #instances}. + *

+ * Note: This method can read multiple {@link SeqFrame} which means the input data can be an entire working + * animation. + * + * @param src the animation data. + * @see #get(int) + */ + public static void readAnimation(byte[] src) { + Buffer offsets = new Buffer(src); + offsets.position = src.length - 8; + + int offset = 0; + Buffer header = new Buffer(src); + header.position = offset; + offset += offsets.method410() + 2; + + Buffer tran1 = new Buffer(src); + tran1.position = offset; + offset += offsets.method410(); + + Buffer tran2 = new Buffer(src); + tran2.position = offset; + offset += offsets.method410(); + + Buffer del = new Buffer(src); + del.position = offset; + offset += offsets.method410(); + + Buffer skel = new Buffer(src); + skel.position = offset; + + SeqSkeleton skeleton = new SeqSkeleton(skel); + + int frameCount = header.method410(); + int[] bases = new int[500]; + int[] x = new int[500]; + int[] y = new int[500]; + int[] z = new int[500]; + + for (int i = 0; i < frameCount; i++) { + SeqFrame frame = instances[header.method410()] = new SeqFrame(); + frame.delay = del.method408(); + frame.skeleton = skeleton; + + int baseCount = header.method408(); + int lastBase = -1; + int length = 0; + for (int base = 0; base < baseCount; base++) { + int flags = tran1.method408(); + + if (flags <= 0) { + continue; + } + + if (skeleton.baseTypes[base] != SeqSkeleton.OP_BASE) { + for (int cur = base - 1; cur > lastBase; cur--) { + if (skeleton.baseTypes[cur] == SeqSkeleton.OP_BASE) { + bases[length] = cur; + x[length] = 0; + y[length] = 0; + z[length] = 0; + length++; + break; + } + } + } + + bases[length] = base; + + int defaultValue = 0; + + if (skeleton.baseTypes[base] == SeqSkeleton.OP_SCALE) { + defaultValue = 128; + } + + if ((flags & 1) != 0) { + x[length] = tran2.method421(); + } else { + x[length] = defaultValue; + } + + if ((flags & 2) != 0) { + y[length] = tran2.method421(); + } else { + y[length] = defaultValue; + } + + if ((flags & 4) != 0) { + z[length] = tran2.method421(); + } else { + z[length] = defaultValue; + } + + lastBase = base; + length++; + } + + frame.length = length; + frame.bases = new int[length]; + frame.x = new int[length]; + frame.y = new int[length]; + frame.z = new int[length]; + + for (int j = 0; j < length; j++) { + frame.bases[j] = bases[j]; + frame.x[j] = x[j]; + frame.y[j] = y[j]; + frame.z[j] = z[j]; + } + } + } + +} diff --git a/src/main/java/SeqSkeleton.java b/src/main/java/SeqSkeleton.java index 8b9b86d..00ce5d1 100644 --- a/src/main/java/SeqSkeleton.java +++ b/src/main/java/SeqSkeleton.java @@ -1,25 +1,48 @@ -// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) - +/** + * A {@link SeqSkeleton} describes the usage and relationship between groups. + * + * @see Model#applySequenceFrame(int) + * @see Model#applySequenceFrames(int, int, int[]) + */ public class SeqSkeleton { - public final int anInt341; - public final int[] anIntArray342; - public final int[][] anIntArrayArray343; + public static final int OP_BASE = 0; + public static final int OP_TRANSLATE = 1; + public static final int OP_ROTATE = 2; + public static final int OP_SCALE = 3; + public static final int OP_ALPHA = 5; + /** + * A base type determines the operation performed on the labels belonging to it. + * + * @see #OP_BASE + * @see #OP_TRANSLATE + * @see #OP_ROTATE + * @see #OP_SCALE + * @see #OP_ALPHA + */ + public final int[] baseTypes; + /** + * The labels belonging to the base. + */ + public final int[][] baseLabels; - public SeqSkeleton(Buffer buffer) { - anInt341 = buffer.method408(); - anIntArray342 = new int[anInt341]; - anIntArrayArray343 = new int[anInt341][]; - for (int j = 0; j < anInt341; j++) { - anIntArray342[j] = buffer.method408(); + /** + * Constructs a new {@link SeqSkeleton} read from the provided input. + * + * @param in the input + */ + public SeqSkeleton(Buffer in) { + final int length = in.method408(); + baseTypes = new int[length]; + baseLabels = new int[length][]; + for (int group = 0; group < length; group++) { + baseTypes[group] = in.method408(); } - for (int k = 0; k < anInt341; k++) { - int l = buffer.method408(); - anIntArrayArray343[k] = new int[l]; - for (int i1 = 0; i1 < l; i1++) { - anIntArrayArray343[k][i1] = buffer.method408(); + for (int group = 0; group < length; group++) { + int count = in.method408(); + baseLabels[group] = new int[count]; + for (int child = 0; child < count; child++) { + baseLabels[group][child] = in.method408(); } } } diff --git a/src/main/java/SeqTransform.java b/src/main/java/SeqTransform.java deleted file mode 100644 index 3225d7c..0000000 --- a/src/main/java/SeqTransform.java +++ /dev/null @@ -1,137 +0,0 @@ -// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) - -public class SeqTransform { - - public static SeqTransform[] aTransformArray635; - public static boolean[] aBooleanArray643; - public int anInt636; - public SeqSkeleton aSkeleton_637; - public int anInt638; - public int[] anIntArray639; - public int[] anIntArray640; - public int[] anIntArray641; - public int[] anIntArray642; - - public SeqTransform() { - } - - public static void method528(int i) { - aTransformArray635 = new SeqTransform[i + 1]; - aBooleanArray643 = new boolean[i + 1]; - for (int j = 0; j < i + 1; j++) { - aBooleanArray643[j] = true; - } - } - - public static void method529(byte[] abyte0) { - Buffer buffer = new Buffer(abyte0); - buffer.anInt1406 = abyte0.length - 8; - int i = buffer.method410(); - int j = buffer.method410(); - int k = buffer.method410(); - int l = buffer.method410(); - int i1 = 0; - Buffer buffer_1 = new Buffer(abyte0); - buffer_1.anInt1406 = i1; - i1 += i + 2; - Buffer class30_sub2_sub2_2 = new Buffer(abyte0); - class30_sub2_sub2_2.anInt1406 = i1; - i1 += j; - Buffer buffer_3 = new Buffer(abyte0); - buffer_3.anInt1406 = i1; - i1 += k; - Buffer buffer_4 = new Buffer(abyte0); - buffer_4.anInt1406 = i1; - i1 += l; - Buffer buffer_5 = new Buffer(abyte0); - buffer_5.anInt1406 = i1; - SeqSkeleton skeleton = new SeqSkeleton(buffer_5); - int k1 = buffer_1.method410(); - int[] ai = new int[500]; - int[] ai1 = new int[500]; - int[] ai2 = new int[500]; - int[] ai3 = new int[500]; - for (int l1 = 0; l1 < k1; l1++) { - int i2 = buffer_1.method410(); - SeqTransform transform = aTransformArray635[i2] = new SeqTransform(); - transform.anInt636 = buffer_4.method408(); - transform.aSkeleton_637 = skeleton; - int j2 = buffer_1.method408(); - int k2 = -1; - int l2 = 0; - for (int i3 = 0; i3 < j2; i3++) { - int j3 = class30_sub2_sub2_2.method408(); - if (j3 > 0) { - if (skeleton.anIntArray342[i3] != 0) { - for (int l3 = i3 - 1; l3 > k2; l3--) { - if (skeleton.anIntArray342[l3] != 0) { - continue; - } - ai[l2] = l3; - ai1[l2] = 0; - ai2[l2] = 0; - ai3[l2] = 0; - l2++; - break; - } - } - ai[l2] = i3; - char c = '\0'; - if (skeleton.anIntArray342[i3] == 3) { - c = '\200'; - } - if ((j3 & 1) != 0) { - ai1[l2] = buffer_3.method421(); - } else { - ai1[l2] = c; - } - if ((j3 & 2) != 0) { - ai2[l2] = buffer_3.method421(); - } else { - ai2[l2] = c; - } - if ((j3 & 4) != 0) { - ai3[l2] = buffer_3.method421(); - } else { - ai3[l2] = c; - } - k2 = i3; - l2++; - if (skeleton.anIntArray342[i3] == 5) { - aBooleanArray643[i2] = false; - } - } - } - transform.anInt638 = l2; - transform.anIntArray639 = new int[l2]; - transform.anIntArray640 = new int[l2]; - transform.anIntArray641 = new int[l2]; - transform.anIntArray642 = new int[l2]; - for (int k3 = 0; k3 < l2; k3++) { - transform.anIntArray639[k3] = ai[k3]; - transform.anIntArray640[k3] = ai1[k3]; - transform.anIntArray641[k3] = ai2[k3]; - transform.anIntArray642[k3] = ai3[k3]; - } - } - } - - public static void method530() { - aTransformArray635 = null; - } - - public static SeqTransform method531(int j) { - if (aTransformArray635 == null) { - return null; - } else { - return aTransformArray635[j]; - } - } - - public static boolean method532(int i) { - return i == -1; - } - -} diff --git a/src/main/java/SeqType.java b/src/main/java/SeqType.java index 69db72f..d6959f7 100644 --- a/src/main/java/SeqType.java +++ b/src/main/java/SeqType.java @@ -42,9 +42,9 @@ public class SeqType { public int method258(int i) { int j = anIntArray355[i]; if (j == 0) { - SeqTransform transform = SeqTransform.method531(anIntArray353[i]); + SeqFrame transform = SeqFrame.get(anIntArray353[i]); if (transform != null) { - j = anIntArray355[i] = transform.anInt636; + j = anIntArray355[i] = transform.delay; } } if (j == 0) { @@ -80,7 +80,7 @@ public class SeqType { for (int l = 0; l < k; l++) { anIntArray357[l] = buffer.method408(); } - anIntArray357[k] = 0x98967f; + anIntArray357[k] = 9999999; } else if (i == 4) { aBoolean358 = true; } else if (i == 5) { diff --git a/src/main/java/SoundTone.java b/src/main/java/SoundTone.java index 045a9ca..c88c00e 100644 --- a/src/main/java/SoundTone.java +++ b/src/main/java/SoundTone.java @@ -238,7 +238,7 @@ public class SoundTone { aEnvelope_99.method325(buffer); int i = buffer.method408(); if (i != 0) { - buffer.anInt1406--; + buffer.position--; aEnvelope_100 = new SoundEnvelope(); aEnvelope_100.method325(buffer); aEnvelope_101 = new SoundEnvelope(); @@ -246,7 +246,7 @@ public class SoundTone { } i = buffer.method408(); if (i != 0) { - buffer.anInt1406--; + buffer.position--; aEnvelope_102 = new SoundEnvelope(); aEnvelope_102.method325(buffer); aEnvelope_103 = new SoundEnvelope(); @@ -254,7 +254,7 @@ public class SoundTone { } i = buffer.method408(); if (i != 0) { - buffer.anInt1406--; + buffer.position--; aEnvelope_104 = new SoundEnvelope(); aEnvelope_104.method325(buffer); aEnvelope_105 = new SoundEnvelope(); diff --git a/src/main/java/SoundTrack.java b/src/main/java/SoundTrack.java index 1000ebf..870a056 100644 --- a/src/main/java/SoundTrack.java +++ b/src/main/java/SoundTrack.java @@ -43,7 +43,7 @@ public class SoundTrack { for (int i = 0; i < 10; i++) { int j = buffer.method408(); if (j != 0) { - buffer.anInt1406--; + buffer.position--; aToneArray329[i] = new SoundTone(); aToneArray329[i].method169(buffer); } @@ -79,7 +79,7 @@ public class SoundTrack { public Buffer method244(int i) { int k = method245(i); - aBuffer_328.anInt1406 = 0; + aBuffer_328.position = 0; aBuffer_328.method402(0x52494646); aBuffer_328.method403(36 + k); aBuffer_328.method402(0x57415645); @@ -93,7 +93,7 @@ public class SoundTrack { aBuffer_328.method400(8); aBuffer_328.method402(0x64617461); aBuffer_328.method403(k); - aBuffer_328.anInt1406 += k; + aBuffer_328.position += k; return aBuffer_328; } diff --git a/src/main/java/SpotAnimEntity.java b/src/main/java/SpotAnimEntity.java index d99864d..913f328 100644 --- a/src/main/java/SpotAnimEntity.java +++ b/src/main/java/SpotAnimEntity.java @@ -30,31 +30,31 @@ public class SpotAnimEntity extends Entity { return null; } int j = aType_1568.aType_407.anIntArray353[anInt1569]; - Model model_1 = new Model(true, SeqTransform.method532(j), false, model); + Model model_1 = new Model(true, SeqFrame.isNull(j), false, model); if (!aBoolean1567) { - model_1.method469(); - model_1.method470(j); - model_1.anIntArrayArray1658 = null; - model_1.anIntArrayArray1657 = null; + model_1.createLabelReferences(); + model_1.applySequenceFrame(j); + model_1.labelFaces = null; + model_1.labelVertices = null; } if (aType_1568.anInt410 != 128 || aType_1568.anInt411 != 128) { - model_1.method478(aType_1568.anInt410, aType_1568.anInt410, aType_1568.anInt411); + model_1.scale(aType_1568.anInt410, aType_1568.anInt410, aType_1568.anInt411); } if (aType_1568.anInt412 != 0) { if (aType_1568.anInt412 == 90) { - model_1.method473(); + model_1.rotateY90(); } if (aType_1568.anInt412 == 180) { - model_1.method473(); - model_1.method473(); + model_1.rotateY90(); + model_1.rotateY90(); } if (aType_1568.anInt412 == 270) { - model_1.method473(); - model_1.method473(); - model_1.method473(); + model_1.rotateY90(); + model_1.rotateY90(); + model_1.rotateY90(); } } - model_1.method479(64 + aType_1568.anInt413, 850 + aType_1568.anInt414, -30, -50, -30, true); + model_1.calculateNormals(64 + aType_1568.anInt413, 850 + aType_1568.anInt414, -30, -50, -30, true); return model_1; } diff --git a/src/main/java/SpotAnimType.java b/src/main/java/SpotAnimType.java index 6e87d26..0d52a61 100644 --- a/src/main/java/SpotAnimType.java +++ b/src/main/java/SpotAnimType.java @@ -75,13 +75,13 @@ public class SpotAnimType { if (model != null) { return model; } - model = Model.method462(anInt405); + model = Model.tryGet(anInt405); if (model == null) { return null; } for (int i = 0; i < 6; i++) { if (anIntArray408[0] != 0) { - model.method476(anIntArray408[i], anIntArray409[i]); + model.replaceColor(anIntArray408[i], anIntArray409[i]); } } aCache_415.method223(model, anInt404); diff --git a/src/main/java/VarbitType.java b/src/main/java/VarbitType.java index 8c0527b..cc93404 100644 --- a/src/main/java/VarbitType.java +++ b/src/main/java/VarbitType.java @@ -32,7 +32,7 @@ public class VarbitType { VarpType.aVarpArray701[aVarbitArray646[j].anInt648].unusedBool3 = true; } } - if (buffer.anInt1406 != buffer.aByteArray1405.length) { + if (buffer.position != buffer.aByteArray1405.length) { System.out.println("varbit load mismatch"); } } diff --git a/src/main/java/VarpType.java b/src/main/java/VarpType.java index 5c3db93..0df6ccc 100644 --- a/src/main/java/VarpType.java +++ b/src/main/java/VarpType.java @@ -40,7 +40,7 @@ public class VarpType { } aVarpArray701[j].method547(buffer, j); } - if (buffer.anInt1406 != buffer.aByteArray1405.length) { + if (buffer.position != buffer.aByteArray1405.length) { System.out.println("varptype load mismatch"); } } diff --git a/src/main/java/VertexNormal.java b/src/main/java/VertexNormal.java index 311671b..c6892a1 100644 --- a/src/main/java/VertexNormal.java +++ b/src/main/java/VertexNormal.java @@ -4,10 +4,10 @@ public class VertexNormal { - public int anInt602; - public int anInt603; - public int anInt604; - public int anInt605; + public int x; + public int y; + public int z; + public int w; public VertexNormal() { }