From 02235d15846cb58a3a4cff347f14b4346904a2cd Mon Sep 17 00:00:00 2001 From: Max Weber Date: Wed, 8 Dec 2021 21:55:02 -0700 Subject: [PATCH] cache: add rev202 model formats --- .../cache/definitions/ModelDefinition.java | 179 +- .../definitions/loaders/ModelLoader.java | 1674 ++++++++++++----- .../cache/item/ItemSpriteFactory.java | 52 +- .../runelite/cache/models/ObjExporter.java | 16 +- 4 files changed, 1289 insertions(+), 632 deletions(-) diff --git a/cache/src/main/java/net/runelite/cache/definitions/ModelDefinition.java b/cache/src/main/java/net/runelite/cache/definitions/ModelDefinition.java index 2259026a4d..939fdf90da 100644 --- a/cache/src/main/java/net/runelite/cache/definitions/ModelDefinition.java +++ b/cache/src/main/java/net/runelite/cache/definitions/ModelDefinition.java @@ -12,45 +12,40 @@ public class ModelDefinition public int id; public int vertexCount = 0; - public int[] vertexPositionsX; - public int[] vertexPositionsY; - public int[] vertexPositionsZ; + public int[] vertexX; + public int[] vertexY; + public int[] vertexZ; public transient VertexNormal[] vertexNormals; public int faceCount; - public int[] faceVertexIndices1; - public int[] faceVertexIndices2; - public int[] faceVertexIndices3; - public byte[] faceAlphas; + public int[] faceIndices1; + public int[] faceIndices2; + public int[] faceIndices3; + public byte[] faceTransparencies; public short[] faceColors; public byte[] faceRenderPriorities; public byte[] faceRenderTypes; public transient FaceNormal[] faceNormals; - public int textureTriangleCount; - public short[] textureTriangleVertexIndices1; - public short[] textureTriangleVertexIndices2; - public short[] textureTriangleVertexIndices3; + public int numTextureFaces; + public short[] texIndices1; + public short[] texIndices2; + public short[] texIndices3; public transient float[][] faceTextureUCoordinates; public transient float[][] faceTextureVCoordinates; public short[] texturePrimaryColors; public short[] faceTextures; - public byte[] textureCoordinates; + public byte[] textureCoords; public byte[] textureRenderTypes; - public int[] vertexSkins; - public int[] faceSkins; + public int[] packedVertexGroups; + public int[] packedTransparencyVertexGroups; public byte priority; - public short[] aShortArray2574; - public short[] aShortArray2575; - public short[] aShortArray2577; - public short[] aShortArray2578; - public byte[] aByteArray2580; - public short[] aShortArray2586; - private transient int[][] vertexGroups; + public int[][] animayaGroups; + public int[][] animayaScales; private transient int[] origVX; private transient int[] origVY; @@ -77,17 +72,17 @@ public class ModelDefinition for (var1 = 0; var1 < this.faceCount; ++var1) { - int vertexA = this.faceVertexIndices1[var1]; - int vertexB = this.faceVertexIndices2[var1]; - int vertexC = this.faceVertexIndices3[var1]; + int vertexA = this.faceIndices1[var1]; + int vertexB = this.faceIndices2[var1]; + int vertexC = this.faceIndices3[var1]; - int xA = this.vertexPositionsX[vertexB] - this.vertexPositionsX[vertexA]; - int yA = this.vertexPositionsY[vertexB] - this.vertexPositionsY[vertexA]; - int zA = this.vertexPositionsZ[vertexB] - this.vertexPositionsZ[vertexA]; + int xA = this.vertexX[vertexB] - this.vertexX[vertexA]; + int yA = this.vertexY[vertexB] - this.vertexY[vertexA]; + int zA = this.vertexZ[vertexB] - this.vertexZ[vertexA]; - int xB = this.vertexPositionsX[vertexC] - this.vertexPositionsX[vertexA]; - int yB = this.vertexPositionsY[vertexC] - this.vertexPositionsY[vertexA]; - int zB = this.vertexPositionsZ[vertexC] - this.vertexPositionsZ[vertexA]; + int xB = this.vertexX[vertexC] - this.vertexX[vertexA]; + int yB = this.vertexY[vertexC] - this.vertexY[vertexA]; + int zB = this.vertexZ[vertexC] - this.vertexZ[vertexA]; // Compute cross product int var11 = yA * zB - yB * zA; @@ -168,13 +163,13 @@ public class ModelDefinition for (int i = 0; i < faceCount; i++) { int textureCoordinate; - if (textureCoordinates == null) + if (textureCoords == null) { textureCoordinate = -1; } else { - textureCoordinate = textureCoordinates[i]; + textureCoordinate = textureCoords[i]; } int textureIdx; @@ -215,33 +210,33 @@ public class ModelDefinition if (textureRenderType == 0) { - int faceVertexIdx1 = faceVertexIndices1[i]; - int faceVertexIdx2 = faceVertexIndices2[i]; - int faceVertexIdx3 = faceVertexIndices3[i]; + int faceVertexIdx1 = faceIndices1[i]; + int faceVertexIdx2 = faceIndices2[i]; + int faceVertexIdx3 = faceIndices3[i]; - short triangleVertexIdx1 = textureTriangleVertexIndices1[textureCoordinate]; - short triangleVertexIdx2 = textureTriangleVertexIndices2[textureCoordinate]; - short triangleVertexIdx3 = textureTriangleVertexIndices3[textureCoordinate]; + short triangleVertexIdx1 = texIndices1[textureCoordinate]; + short triangleVertexIdx2 = texIndices2[textureCoordinate]; + short triangleVertexIdx3 = texIndices3[textureCoordinate]; - float triangleX = (float) vertexPositionsX[triangleVertexIdx1]; - float triangleY = (float) vertexPositionsY[triangleVertexIdx1]; - float triangleZ = (float) vertexPositionsZ[triangleVertexIdx1]; + float triangleX = (float) vertexX[triangleVertexIdx1]; + float triangleY = (float) vertexY[triangleVertexIdx1]; + float triangleZ = (float) vertexZ[triangleVertexIdx1]; - float f_882_ = (float) vertexPositionsX[triangleVertexIdx2] - triangleX; - float f_883_ = (float) vertexPositionsY[triangleVertexIdx2] - triangleY; - float f_884_ = (float) vertexPositionsZ[triangleVertexIdx2] - triangleZ; - float f_885_ = (float) vertexPositionsX[triangleVertexIdx3] - triangleX; - float f_886_ = (float) vertexPositionsY[triangleVertexIdx3] - triangleY; - float f_887_ = (float) vertexPositionsZ[triangleVertexIdx3] - triangleZ; - float f_888_ = (float) vertexPositionsX[faceVertexIdx1] - triangleX; - float f_889_ = (float) vertexPositionsY[faceVertexIdx1] - triangleY; - float f_890_ = (float) vertexPositionsZ[faceVertexIdx1] - triangleZ; - float f_891_ = (float) vertexPositionsX[faceVertexIdx2] - triangleX; - float f_892_ = (float) vertexPositionsY[faceVertexIdx2] - triangleY; - float f_893_ = (float) vertexPositionsZ[faceVertexIdx2] - triangleZ; - float f_894_ = (float) vertexPositionsX[faceVertexIdx3] - triangleX; - float f_895_ = (float) vertexPositionsY[faceVertexIdx3] - triangleY; - float f_896_ = (float) vertexPositionsZ[faceVertexIdx3] - triangleZ; + float f_882_ = (float) vertexX[triangleVertexIdx2] - triangleX; + float f_883_ = (float) vertexY[triangleVertexIdx2] - triangleY; + float f_884_ = (float) vertexZ[triangleVertexIdx2] - triangleZ; + float f_885_ = (float) vertexX[triangleVertexIdx3] - triangleX; + float f_886_ = (float) vertexY[triangleVertexIdx3] - triangleY; + float f_887_ = (float) vertexZ[triangleVertexIdx3] - triangleZ; + float f_888_ = (float) vertexX[faceVertexIdx1] - triangleX; + float f_889_ = (float) vertexY[faceVertexIdx1] - triangleY; + float f_890_ = (float) vertexZ[faceVertexIdx1] - triangleZ; + float f_891_ = (float) vertexX[faceVertexIdx2] - triangleX; + float f_892_ = (float) vertexY[faceVertexIdx2] - triangleY; + float f_893_ = (float) vertexZ[faceVertexIdx2] - triangleZ; + float f_894_ = (float) vertexX[faceVertexIdx3] - triangleX; + float f_895_ = (float) vertexY[faceVertexIdx3] - triangleY; + float f_896_ = (float) vertexZ[faceVertexIdx3] - triangleZ; float f_897_ = f_883_ * f_887_ - f_884_ * f_886_; float f_898_ = f_884_ * f_885_ - f_882_ * f_887_; @@ -274,7 +269,7 @@ public class ModelDefinition public void computeAnimationTables() { - if (this.vertexSkins != null) + if (this.packedVertexGroups != null) { int[] groupCounts = new int[256]; int numGroups = 0; @@ -282,7 +277,7 @@ public class ModelDefinition for (var3 = 0; var3 < this.vertexCount; ++var3) { - var4 = this.vertexSkins[var3]; + var4 = this.packedVertexGroups[var3]; ++groupCounts[var4]; if (var4 > numGroups) { @@ -300,10 +295,10 @@ public class ModelDefinition for (var3 = 0; var3 < this.vertexCount; this.vertexGroups[var4][groupCounts[var4]++] = var3++) { - var4 = this.vertexSkins[var3]; + var4 = this.packedVertexGroups[var3]; } - this.vertexSkins = null; + this.packedVertexGroups = null; } // triangleSkinValues is here @@ -314,13 +309,13 @@ public class ModelDefinition int sin = CircularAngle.SINE[orientation]; int cos = CircularAngle.COSINE[orientation]; - assert vertexPositionsX.length == vertexPositionsY.length; - assert vertexPositionsY.length == vertexPositionsZ.length; + assert vertexX.length == vertexY.length; + assert vertexY.length == vertexZ.length; - for (int i = 0; i < vertexPositionsX.length; ++i) + for (int i = 0; i < vertexX.length; ++i) { - vertexPositionsX[i] = vertexPositionsX[i] * cos + vertexPositionsZ[i] * sin >> 16; - vertexPositionsZ[i] = vertexPositionsZ[i] * cos - vertexPositionsX[i] * sin >> 16; + vertexX[i] = vertexX[i] * cos + vertexZ[i] * sin >> 16; + vertexZ[i] = vertexZ[i] * cos - vertexX[i] * sin >> 16; } reset(); @@ -333,23 +328,23 @@ public class ModelDefinition return; } - System.arraycopy(origVX, 0, vertexPositionsX, 0, origVX.length); - System.arraycopy(origVY, 0, vertexPositionsY, 0, origVY.length); - System.arraycopy(origVZ, 0, vertexPositionsZ, 0, origVZ.length); + System.arraycopy(origVX, 0, vertexX, 0, origVX.length); + System.arraycopy(origVY, 0, vertexY, 0, origVY.length); + System.arraycopy(origVZ, 0, vertexZ, 0, origVZ.length); } public void animate(int type, int[] frameMap, int dx, int dy, int dz) { if (origVX == null) { - origVX = Arrays.copyOf(vertexPositionsX, vertexPositionsX.length); - origVY = Arrays.copyOf(vertexPositionsY, vertexPositionsY.length); - origVZ = Arrays.copyOf(vertexPositionsZ, vertexPositionsZ.length); + origVX = Arrays.copyOf(vertexX, vertexX.length); + origVY = Arrays.copyOf(vertexY, vertexY.length); + origVZ = Arrays.copyOf(vertexZ, vertexZ.length); } - final int[] verticesX = vertexPositionsX; - final int[] verticesY = vertexPositionsY; - final int[] verticesZ = vertexPositionsZ; + final int[] verticesX = vertexX; + final int[] verticesY = vertexY; + final int[] verticesZ = vertexZ; int var6 = frameMap.length; int var7; int var8; @@ -512,14 +507,14 @@ public class ModelDefinition int var1; for (var1 = 0; var1 < this.vertexCount; ++var1) { - this.vertexPositionsZ[var1] = -this.vertexPositionsZ[var1]; + this.vertexZ[var1] = -this.vertexZ[var1]; } for (var1 = 0; var1 < this.faceCount; ++var1) { - int var2 = this.faceVertexIndices1[var1]; - this.faceVertexIndices1[var1] = this.faceVertexIndices3[var1]; - this.faceVertexIndices3[var1] = var2; + int var2 = this.faceIndices1[var1]; + this.faceIndices1[var1] = this.faceIndices3[var1]; + this.faceIndices3[var1] = var2; } reset(); @@ -529,9 +524,9 @@ public class ModelDefinition { for (int var1 = 0; var1 < this.vertexCount; ++var1) { - int var2 = this.vertexPositionsX[var1]; - this.vertexPositionsX[var1] = this.vertexPositionsZ[var1]; - this.vertexPositionsZ[var1] = -var2; + int var2 = this.vertexX[var1]; + this.vertexX[var1] = this.vertexZ[var1]; + this.vertexZ[var1] = -var2; } reset(); @@ -541,8 +536,8 @@ public class ModelDefinition { for (int var1 = 0; var1 < this.vertexCount; ++var1) { - this.vertexPositionsX[var1] = -this.vertexPositionsX[var1]; - this.vertexPositionsZ[var1] = -this.vertexPositionsZ[var1]; + this.vertexX[var1] = -this.vertexX[var1]; + this.vertexZ[var1] = -this.vertexZ[var1]; } reset(); @@ -552,9 +547,9 @@ public class ModelDefinition { for (int var1 = 0; var1 < this.vertexCount; ++var1) { - int var2 = this.vertexPositionsZ[var1]; - this.vertexPositionsZ[var1] = this.vertexPositionsX[var1]; - this.vertexPositionsX[var1] = -var2; + int var2 = this.vertexZ[var1]; + this.vertexZ[var1] = this.vertexX[var1]; + this.vertexX[var1] = -var2; } reset(); @@ -571,9 +566,9 @@ public class ModelDefinition { for (int var4 = 0; var4 < this.vertexCount; ++var4) { - this.vertexPositionsX[var4] = this.vertexPositionsX[var4] * var1 / 128; - this.vertexPositionsY[var4] = var2 * this.vertexPositionsY[var4] / 128; - this.vertexPositionsZ[var4] = var3 * this.vertexPositionsZ[var4] / 128; + this.vertexX[var4] = this.vertexX[var4] * var1 / 128; + this.vertexY[var4] = var2 * this.vertexY[var4] / 128; + this.vertexZ[var4] = var3 * this.vertexZ[var4] / 128; } reset(); @@ -610,9 +605,9 @@ public class ModelDefinition { for (int i = 0; i < this.vertexCount; i++) { - this.vertexPositionsX[i] += xOffset; - this.vertexPositionsY[i] += yOffset; - this.vertexPositionsZ[i] += zOffset; + this.vertexX[i] += xOffset; + this.vertexY[i] += yOffset; + this.vertexZ[i] += zOffset; } this.reset(); } diff --git a/cache/src/main/java/net/runelite/cache/definitions/loaders/ModelLoader.java b/cache/src/main/java/net/runelite/cache/definitions/loaders/ModelLoader.java index 4529f8a069..22226c3d8a 100644 --- a/cache/src/main/java/net/runelite/cache/definitions/loaders/ModelLoader.java +++ b/cache/src/main/java/net/runelite/cache/definitions/loaders/ModelLoader.java @@ -10,13 +10,21 @@ public class ModelLoader ModelDefinition def = new ModelDefinition(); def.id = modelId; - if (b[b.length - 1] == -1 && b[b.length - 2] == -1) + if (b[b.length - 1] == -3 && b[b.length - 2] == -1) { - this.load1(def, b); + decodeType3(def, b); + } + else if (b[b.length - 1] == -2 && b[b.length - 2] == -1) + { + decodeType2(def, b); + } + else if (b[b.length - 1] == -1 && b[b.length - 2] == -1) + { + decodeType1(def, b); } else { - this.load2(def, b); + decodeOldFormat(def, b); } def.computeNormals(); @@ -26,702 +34,1356 @@ public class ModelLoader return def; } - private void load1(ModelDefinition model, byte[] var1) + void decodeType3(ModelDefinition def, byte[] var1) { InputStream var2 = new InputStream(var1); - InputStream var24 = new InputStream(var1); InputStream var3 = new InputStream(var1); - InputStream var28 = new InputStream(var1); + InputStream var4 = new InputStream(var1); + InputStream var5 = new InputStream(var1); InputStream var6 = new InputStream(var1); - InputStream var55 = new InputStream(var1); - InputStream var51 = new InputStream(var1); - var2.setOffset(var1.length - 23); - int verticeCount = var2.readUnsignedShort(); - int triangleCount = var2.readUnsignedShort(); - int textureTriangleCount = var2.readUnsignedByte(); + InputStream var7 = new InputStream(var1); + InputStream var8 = new InputStream(var1); + var2.setOffset(var1.length - 26); + int var9 = var2.readUnsignedShort(); + int var10 = var2.readUnsignedShort(); + int var11 = var2.readUnsignedByte(); + int var12 = var2.readUnsignedByte(); int var13 = var2.readUnsignedByte(); - int modelPriority = var2.readUnsignedByte(); - int var50 = var2.readUnsignedByte(); + int var14 = var2.readUnsignedByte(); + int var15 = var2.readUnsignedByte(); + int var16 = var2.readUnsignedByte(); int var17 = var2.readUnsignedByte(); - int modelTexture = var2.readUnsignedByte(); - int modelVertexSkins = var2.readUnsignedByte(); + int var18 = var2.readUnsignedByte(); + int var19 = var2.readUnsignedShort(); int var20 = var2.readUnsignedShort(); int var21 = var2.readUnsignedShort(); - int var42 = var2.readUnsignedShort(); int var22 = var2.readUnsignedShort(); - int var38 = var2.readUnsignedShort(); - int textureAmount = 0; - int var7 = 0; - int var29 = 0; - int position; - if (textureTriangleCount > 0) + int var23 = var2.readUnsignedShort(); + int var24 = var2.readUnsignedShort(); + int var25 = 0; + int var26 = 0; + int var27 = 0; + int var28; + if (var11 > 0) { - model.textureRenderTypes = new byte[textureTriangleCount]; + def.textureRenderTypes = new byte[var11]; var2.setOffset(0); - for (position = 0; position < textureTriangleCount; ++position) + for (var28 = 0; var28 < var11; ++var28) { - byte renderType = model.textureRenderTypes[position] = var2.readByte(); - if (renderType == 0) + byte var29 = def.textureRenderTypes[var28] = var2.readByte(); + if (var29 == 0) { - ++textureAmount; + ++var25; } - if (renderType >= 1 && renderType <= 3) + if (var29 >= 1 && var29 <= 3) { - ++var7; + ++var26; } - if (renderType == 2) + if (var29 == 2) { - ++var29; + ++var27; } } } - position = textureTriangleCount + verticeCount; - int renderTypePos = position; - if (var13 == 1) + var28 = var11 + var9; + int var58 = var28; + if (var12 == 1) { - position += triangleCount; + var28 += var10; } - int var49 = position; - position += triangleCount; - int priorityPos = position; - if (modelPriority == 255) + int var30 = var28; + var28 += var10; + int var31 = var28; + if (var13 == 255) { - position += triangleCount; + var28 += var10; } - int triangleSkinPos = position; + int var32 = var28; + if (var15 == 1) + { + var28 += var10; + } + + int var33 = var28; + var28 += var24; + int var34 = var28; + if (var14 == 1) + { + var28 += var10; + } + + int var35 = var28; + var28 += var22; + int var36 = var28; + if (var16 == 1) + { + var28 += var10 * 2; + } + + int var37 = var28; + var28 += var23; + int var38 = var28; + var28 += var10 * 2; + int var39 = var28; + var28 += var19; + int var40 = var28; + var28 += var20; + int var41 = var28; + var28 += var21; + int var42 = var28; + var28 += var25 * 6; + int var43 = var28; + var28 += var26 * 6; + int var44 = var28; + var28 += var26 * 6; + int var45 = var28; + var28 += var26 * 2; + int var46 = var28; + var28 += var26; + int var47 = var28; + var28 = var28 + var26 * 2 + var27 * 2; + def.vertexCount = var9; + def.faceCount = var10; + def.numTextureFaces = var11; + def.vertexX = new int[var9]; + def.vertexY = new int[var9]; + def.vertexZ = new int[var9]; + def.faceIndices1 = new int[var10]; + def.faceIndices2 = new int[var10]; + def.faceIndices3 = new int[var10]; if (var17 == 1) { - position += triangleCount; + def.packedVertexGroups = new int[var9]; } - int var35 = position; - if (modelVertexSkins == 1) + if (var12 == 1) { - position += verticeCount; + def.faceRenderTypes = new byte[var10]; } - int alphaPos = position; - if (var50 == 1) + if (var13 == 255) { - position += triangleCount; - } - - int var11 = position; - position += var22; - int texturePos = position; - if (modelTexture == 1) - { - position += triangleCount * 2; - } - - int textureCoordPos = position; - position += var38; - int colorPos = position; - position += triangleCount * 2; - int var40 = position; - position += var20; - int var41 = position; - position += var21; - int var8 = position; - position += var42; - int var43 = position; - position += textureAmount * 6; - int var37 = position; - position += var7 * 6; - int var48 = position; - position += var7 * 6; - int var56 = position; - position += var7 * 2; - int var45 = position; - position += var7; - int var46 = position; - position += var7 * 2 + var29 * 2; - model.vertexCount = verticeCount; - model.faceCount = triangleCount; - model.textureTriangleCount = textureTriangleCount; - model.vertexPositionsX = new int[verticeCount]; - model.vertexPositionsY = new int[verticeCount]; - model.vertexPositionsZ = new int[verticeCount]; - model.faceVertexIndices1 = new int[triangleCount]; - model.faceVertexIndices2 = new int[triangleCount]; - model.faceVertexIndices3 = new int[triangleCount]; - if (modelVertexSkins == 1) - { - model.vertexSkins = new int[verticeCount]; - } - - if (var13 == 1) - { - model.faceRenderTypes = new byte[triangleCount]; - } - - if (modelPriority == 255) - { - model.faceRenderPriorities = new byte[triangleCount]; + def.faceRenderPriorities = new byte[var10]; } else { - model.priority = (byte) modelPriority; + def.priority = (byte) var13; } - if (var50 == 1) + if (var14 == 1) { - model.faceAlphas = new byte[triangleCount]; + def.faceTransparencies = new byte[var10]; } - if (var17 == 1) + if (var15 == 1) { - model.faceSkins = new int[triangleCount]; + def.packedTransparencyVertexGroups = new int[var10]; } - if (modelTexture == 1) + if (var16 == 1) { - model.faceTextures = new short[triangleCount]; + def.faceTextures = new short[var10]; } - if (modelTexture == 1 && textureTriangleCount > 0) + if (var16 == 1 && var11 > 0) { - model.textureCoordinates = new byte[triangleCount]; + def.textureCoords = new byte[var10]; } - model.faceColors = new short[triangleCount]; - if (textureTriangleCount > 0) + if (var18 == 1) { - model.textureTriangleVertexIndices1 = new short[textureTriangleCount]; - model.textureTriangleVertexIndices2 = new short[textureTriangleCount]; - model.textureTriangleVertexIndices3 = new short[textureTriangleCount]; - if (var7 > 0) - { - model.aShortArray2574 = new short[var7]; - model.aShortArray2575 = new short[var7]; - model.aShortArray2586 = new short[var7]; - model.aShortArray2577 = new short[var7]; - model.aByteArray2580 = new byte[var7]; - model.aShortArray2578 = new short[var7]; - } - - if (var29 > 0) - { - model.texturePrimaryColors = new short[var29]; - } + def.animayaGroups = new int[var9][]; + def.animayaScales = new int[var9][]; } - var2.setOffset(textureTriangleCount); - var24.setOffset(var40); - var3.setOffset(var41); - var28.setOffset(var8); - var6.setOffset(var35); - int vX = 0; - int vY = 0; - int vZ = 0; - - int vertexZOffset; - int var10; - int vertexYOffset; - int var15; - int point; - for (point = 0; point < verticeCount; ++point) + def.faceColors = new short[var10]; + if (var11 > 0) { - int vertexFlags = var2.readUnsignedByte(); - int vertexXOffset = 0; - if ((vertexFlags & 1) != 0) - { - vertexXOffset = var24.readShortSmart(); - } - - vertexYOffset = 0; - if ((vertexFlags & 2) != 0) - { - vertexYOffset = var3.readShortSmart(); - } - - vertexZOffset = 0; - if ((vertexFlags & 4) != 0) - { - vertexZOffset = var28.readShortSmart(); - } - - model.vertexPositionsX[point] = vX + vertexXOffset; - model.vertexPositionsY[point] = vY + vertexYOffset; - model.vertexPositionsZ[point] = vZ + vertexZOffset; - vX = model.vertexPositionsX[point]; - vY = model.vertexPositionsY[point]; - vZ = model.vertexPositionsZ[point]; - if (modelVertexSkins == 1) - { - model.vertexSkins[point] = var6.readUnsignedByte(); - } - } - - var2.setOffset(colorPos); - var24.setOffset(renderTypePos); - var3.setOffset(priorityPos); - var28.setOffset(alphaPos); - var6.setOffset(triangleSkinPos); - var55.setOffset(texturePos); - var51.setOffset(textureCoordPos); - - for (point = 0; point < triangleCount; ++point) - { - model.faceColors[point] = (short) var2.readUnsignedShort(); - if (var13 == 1) - { - model.faceRenderTypes[point] = var24.readByte(); - } - - if (modelPriority == 255) - { - model.faceRenderPriorities[point] = var3.readByte(); - } - - if (var50 == 1) - { - model.faceAlphas[point] = var28.readByte(); - } - - if (var17 == 1) - { - model.faceSkins[point] = var6.readUnsignedByte(); - } - - if (modelTexture == 1) - { - model.faceTextures[point] = (short) (var55.readUnsignedShort() - 1); - } - - if (model.textureCoordinates != null && model.faceTextures[point] != -1) - { - model.textureCoordinates[point] = (byte) (var51.readUnsignedByte() - 1); - } + def.texIndices1 = new short[var11]; + def.texIndices2 = new short[var11]; + def.texIndices3 = new short[var11]; } var2.setOffset(var11); - var24.setOffset(var49); - int trianglePointX = 0; - int trianglePointY = 0; - int trianglePointZ = 0; - vertexYOffset = 0; + var3.setOffset(var39); + var4.setOffset(var40); + var5.setOffset(var41); + var6.setOffset(var33); + int var48 = 0; + int var49 = 0; + int var50 = 0; - int var16; - for (vertexZOffset = 0; vertexZOffset < triangleCount; ++vertexZOffset) + int var51; + int var52; + int var53; + int var54; + int var55; + for (var51 = 0; var51 < var9; ++var51) { - int numFaces = var24.readUnsignedByte(); - if (numFaces == 1) + var52 = var2.readUnsignedByte(); + var53 = 0; + if ((var52 & 1) != 0) { - trianglePointX = var2.readShortSmart() + vertexYOffset; - trianglePointY = var2.readShortSmart() + trianglePointX; - trianglePointZ = var2.readShortSmart() + trianglePointY; - vertexYOffset = trianglePointZ; - model.faceVertexIndices1[vertexZOffset] = trianglePointX; - model.faceVertexIndices2[vertexZOffset] = trianglePointY; - model.faceVertexIndices3[vertexZOffset] = trianglePointZ; + var53 = var3.readShortSmart(); } - if (numFaces == 2) + var54 = 0; + if ((var52 & 2) != 0) { - trianglePointY = trianglePointZ; - trianglePointZ = var2.readShortSmart() + vertexYOffset; - vertexYOffset = trianglePointZ; - model.faceVertexIndices1[vertexZOffset] = trianglePointX; - model.faceVertexIndices2[vertexZOffset] = trianglePointY; - model.faceVertexIndices3[vertexZOffset] = trianglePointZ; + var54 = var4.readShortSmart(); } - if (numFaces == 3) + var55 = 0; + if ((var52 & 4) != 0) { - trianglePointX = trianglePointZ; - trianglePointZ = var2.readShortSmart() + vertexYOffset; - vertexYOffset = trianglePointZ; - model.faceVertexIndices1[vertexZOffset] = trianglePointX; - model.faceVertexIndices2[vertexZOffset] = trianglePointY; - model.faceVertexIndices3[vertexZOffset] = trianglePointZ; + var55 = var5.readShortSmart(); } - if (numFaces == 4) + def.vertexX[var51] = var48 + var53; + def.vertexY[var51] = var49 + var54; + def.vertexZ[var51] = var50 + var55; + var48 = def.vertexX[var51]; + var49 = def.vertexY[var51]; + var50 = def.vertexZ[var51]; + if (var17 == 1) { - int var57 = trianglePointX; - trianglePointX = trianglePointY; - trianglePointY = var57; - trianglePointZ = var2.readShortSmart() + vertexYOffset; - vertexYOffset = trianglePointZ; - model.faceVertexIndices1[vertexZOffset] = trianglePointX; - model.faceVertexIndices2[vertexZOffset] = var57; - model.faceVertexIndices3[vertexZOffset] = trianglePointZ; + def.packedVertexGroups[var51] = var6.readUnsignedByte(); } } - var2.setOffset(var43); - var24.setOffset(var37); - var3.setOffset(var48); - var28.setOffset(var56); - var6.setOffset(var45); - var55.setOffset(var46); - - for (int texIndex = 0; texIndex < textureTriangleCount; ++texIndex) + if (var18 == 1) { - int type = model.textureRenderTypes[texIndex] & 255; - if (type == 0) + for (var51 = 0; var51 < var9; ++var51) { - model.textureTriangleVertexIndices1[texIndex] = (short) var2.readUnsignedShort(); - model.textureTriangleVertexIndices2[texIndex] = (short) var2.readUnsignedShort(); - model.textureTriangleVertexIndices3[texIndex] = (short) var2.readUnsignedShort(); - } + var52 = var6.readUnsignedByte(); + def.animayaGroups[var51] = new int[var52]; + def.animayaScales[var51] = new int[var52]; - if (type == 1) - { - model.textureTriangleVertexIndices1[texIndex] = (short) var24.readUnsignedShort(); - model.textureTriangleVertexIndices2[texIndex] = (short) var24.readUnsignedShort(); - model.textureTriangleVertexIndices3[texIndex] = (short) var24.readUnsignedShort(); - model.aShortArray2574[texIndex] = (short) var3.readUnsignedShort(); - model.aShortArray2575[texIndex] = (short) var3.readUnsignedShort(); - model.aShortArray2586[texIndex] = (short) var3.readUnsignedShort(); - model.aShortArray2577[texIndex] = (short) var28.readUnsignedShort(); - model.aByteArray2580[texIndex] = var6.readByte(); - model.aShortArray2578[texIndex] = (short) var55.readUnsignedShort(); - } - - if (type == 2) - { - model.textureTriangleVertexIndices1[texIndex] = (short) var24.readUnsignedShort(); - model.textureTriangleVertexIndices2[texIndex] = (short) var24.readUnsignedShort(); - model.textureTriangleVertexIndices3[texIndex] = (short) var24.readUnsignedShort(); - model.aShortArray2574[texIndex] = (short) var3.readUnsignedShort(); - model.aShortArray2575[texIndex] = (short) var3.readUnsignedShort(); - model.aShortArray2586[texIndex] = (short) var3.readUnsignedShort(); - model.aShortArray2577[texIndex] = (short) var28.readUnsignedShort(); - model.aByteArray2580[texIndex] = var6.readByte(); - model.aShortArray2578[texIndex] = (short) var55.readUnsignedShort(); - model.texturePrimaryColors[texIndex] = (short) var55.readUnsignedShort(); - } - - if (type == 3) - { - model.textureTriangleVertexIndices1[texIndex] = (short) var24.readUnsignedShort(); - model.textureTriangleVertexIndices2[texIndex] = (short) var24.readUnsignedShort(); - model.textureTriangleVertexIndices3[texIndex] = (short) var24.readUnsignedShort(); - model.aShortArray2574[texIndex] = (short) var3.readUnsignedShort(); - model.aShortArray2575[texIndex] = (short) var3.readUnsignedShort(); - model.aShortArray2586[texIndex] = (short) var3.readUnsignedShort(); - model.aShortArray2577[texIndex] = (short) var28.readUnsignedShort(); - model.aByteArray2580[texIndex] = var6.readByte(); - model.aShortArray2578[texIndex] = (short) var55.readUnsignedShort(); + for (var53 = 0; var53 < var52; ++var53) + { + def.animayaGroups[var51][var53] = var6.readUnsignedByte(); + def.animayaScales[var51][var53] = var6.readUnsignedByte(); + } } } - var2.setOffset(position); - vertexZOffset = var2.readUnsignedByte(); - if (vertexZOffset != 0) + var2.setOffset(var38); + var3.setOffset(var58); + var4.setOffset(var31); + var5.setOffset(var34); + var6.setOffset(var32); + var7.setOffset(var36); + var8.setOffset(var37); + + for (var51 = 0; var51 < var10; ++var51) + { + def.faceColors[var51] = (short) var2.readUnsignedShort(); + if (var12 == 1) + { + def.faceRenderTypes[var51] = var3.readByte(); + } + + if (var13 == 255) + { + def.faceRenderPriorities[var51] = var4.readByte(); + } + + if (var14 == 1) + { + def.faceTransparencies[var51] = var5.readByte(); + } + + if (var15 == 1) + { + def.packedTransparencyVertexGroups[var51] = var6.readUnsignedByte(); + } + + if (var16 == 1) + { + def.faceTextures[var51] = (short) (var7.readUnsignedShort() - 1); + } + + if (def.textureCoords != null && def.faceTextures[var51] != -1) + { + def.textureCoords[var51] = (byte) (var8.readUnsignedByte() - 1); + } + } + + var2.setOffset(var35); + var3.setOffset(var30); + var51 = 0; + var52 = 0; + var53 = 0; + var54 = 0; + + int var56; + for (var55 = 0; var55 < var10; ++var55) + { + var56 = var3.readUnsignedByte(); + if (var56 == 1) + { + var51 = var2.readShortSmart() + var54; + var52 = var2.readShortSmart() + var51; + var53 = var2.readShortSmart() + var52; + var54 = var53; + def.faceIndices1[var55] = var51; + def.faceIndices2[var55] = var52; + def.faceIndices3[var55] = var53; + } + + if (var56 == 2) + { + var52 = var53; + var53 = var2.readShortSmart() + var54; + var54 = var53; + def.faceIndices1[var55] = var51; + def.faceIndices2[var55] = var52; + def.faceIndices3[var55] = var53; + } + + if (var56 == 3) + { + var51 = var53; + var53 = var2.readShortSmart() + var54; + var54 = var53; + def.faceIndices1[var55] = var51; + def.faceIndices2[var55] = var52; + def.faceIndices3[var55] = var53; + } + + if (var56 == 4) + { + int var57 = var51; + var51 = var52; + var52 = var57; + var53 = var2.readShortSmart() + var54; + var54 = var53; + def.faceIndices1[var55] = var51; + def.faceIndices2[var55] = var57; + def.faceIndices3[var55] = var53; + } + } + + var2.setOffset(var42); + var3.setOffset(var43); + var4.setOffset(var44); + var5.setOffset(var45); + var6.setOffset(var46); + var7.setOffset(var47); + + for (var55 = 0; var55 < var11; ++var55) + { + var56 = def.textureRenderTypes[var55] & 255; + if (var56 == 0) + { + def.texIndices1[var55] = (short) var2.readUnsignedShort(); + def.texIndices2[var55] = (short) var2.readUnsignedShort(); + def.texIndices3[var55] = (short) var2.readUnsignedShort(); + } + } + + var2.setOffset(var28); + var55 = var2.readUnsignedByte(); + if (var55 != 0) { - //new Class41(); var2.readUnsignedShort(); var2.readUnsignedShort(); var2.readUnsignedShort(); var2.readInt(); } + } - private void load2(ModelDefinition model, byte[] var1) + void decodeType2(ModelDefinition def, byte[] var1) { boolean var2 = false; - boolean var43 = false; + boolean var3 = false; + InputStream var4 = new InputStream(var1); InputStream var5 = new InputStream(var1); - InputStream var39 = new InputStream(var1); - InputStream var26 = new InputStream(var1); - InputStream var9 = new InputStream(var1); - InputStream var3 = new InputStream(var1); - var5.setOffset(var1.length - 18); - int var10 = var5.readUnsignedShort(); - int var11 = var5.readUnsignedShort(); - int var12 = var5.readUnsignedByte(); - int var13 = var5.readUnsignedByte(); - int var14 = var5.readUnsignedByte(); - int var30 = var5.readUnsignedByte(); - int var15 = var5.readUnsignedByte(); - int var28 = var5.readUnsignedByte(); - int var27 = var5.readUnsignedShort(); - int var20 = var5.readUnsignedShort(); - int var36 = var5.readUnsignedShort(); - int var23 = var5.readUnsignedShort(); - byte var16 = 0; - int var46 = var16 + var10; - int var24 = var46; - var46 += var11; - int var25 = var46; - if (var14 == 255) + InputStream var6 = new InputStream(var1); + InputStream var7 = new InputStream(var1); + InputStream var8 = new InputStream(var1); + var4.setOffset(var1.length - 23); + int var9 = var4.readUnsignedShort(); + int var10 = var4.readUnsignedShort(); + int var11 = var4.readUnsignedByte(); + int var12 = var4.readUnsignedByte(); + int var13 = var4.readUnsignedByte(); + int var14 = var4.readUnsignedByte(); + int var15 = var4.readUnsignedByte(); + int var16 = var4.readUnsignedByte(); + int var17 = var4.readUnsignedByte(); + int var18 = var4.readUnsignedShort(); + int var19 = var4.readUnsignedShort(); + int var20 = var4.readUnsignedShort(); + int var21 = var4.readUnsignedShort(); + int var22 = var4.readUnsignedShort(); + byte var23 = 0; + int var24 = var23 + var9; + int var25 = var24; + var24 += var10; + int var26 = var24; + if (var13 == 255) { - var46 += var11; + var24 += var10; } - int var4 = var46; + int var27 = var24; if (var15 == 1) { - var46 += var11; + var24 += var10; } - int var42 = var46; - if (var13 == 1) + int var28 = var24; + if (var12 == 1) { - var46 += var11; + var24 += var10; } - int var37 = var46; - if (var28 == 1) + int var29 = var24; + var24 += var22; + int var30 = var24; + if (var14 == 1) { - var46 += var10; + var24 += var10; } - int var29 = var46; - if (var30 == 1) + int var31 = var24; + var24 += var21; + int var32 = var24; + var24 += var10 * 2; + int var33 = var24; + var24 += var11 * 6; + int var34 = var24; + var24 += var18; + int var35 = var24; + var24 += var19; + int var10000 = var24 + var20; + def.vertexCount = var9; + def.faceCount = var10; + def.numTextureFaces = var11; + def.vertexX = new int[var9]; + def.vertexY = new int[var9]; + def.vertexZ = new int[var9]; + def.faceIndices1 = new int[var10]; + def.faceIndices2 = new int[var10]; + def.faceIndices3 = new int[var10]; + if (var11 > 0) { - var46 += var11; + def.textureRenderTypes = new byte[var11]; + def.texIndices1 = new short[var11]; + def.texIndices2 = new short[var11]; + def.texIndices3 = new short[var11]; } - int var44 = var46; - var46 += var23; - int var17 = var46; - var46 += var11 * 2; - int var32 = var46; - var46 += var12 * 6; - int var34 = var46; - var46 += var27; - int var35 = var46; - var46 += var20; - int var10000 = var46 + var36; - model.vertexCount = var10; - model.faceCount = var11; - model.textureTriangleCount = var12; - model.vertexPositionsX = new int[var10]; - model.vertexPositionsY = new int[var10]; - model.vertexPositionsZ = new int[var10]; - model.faceVertexIndices1 = new int[var11]; - model.faceVertexIndices2 = new int[var11]; - model.faceVertexIndices3 = new int[var11]; - if (var12 > 0) + if (var16 == 1) { - model.textureRenderTypes = new byte[var12]; - model.textureTriangleVertexIndices1 = new short[var12]; - model.textureTriangleVertexIndices2 = new short[var12]; - model.textureTriangleVertexIndices3 = new short[var12]; + def.packedVertexGroups = new int[var9]; } - if (var28 == 1) + if (var12 == 1) { - model.vertexSkins = new int[var10]; + def.faceRenderTypes = new byte[var10]; + def.textureCoords = new byte[var10]; + def.faceTextures = new short[var10]; } - if (var13 == 1) + if (var13 == 255) { - model.faceRenderTypes = new byte[var11]; - model.textureCoordinates = new byte[var11]; - model.faceTextures = new short[var11]; - } - - if (var14 == 255) - { - model.faceRenderPriorities = new byte[var11]; + def.faceRenderPriorities = new byte[var10]; } else { - model.priority = (byte) var14; + def.priority = (byte) var13; } - if (var30 == 1) + if (var14 == 1) { - model.faceAlphas = new byte[var11]; + def.faceTransparencies = new byte[var10]; } if (var15 == 1) { - model.faceSkins = new int[var11]; + def.packedTransparencyVertexGroups = new int[var10]; } - model.faceColors = new short[var11]; - var5.setOffset(var16); - var39.setOffset(var34); - var26.setOffset(var35); - var9.setOffset(var46); - var3.setOffset(var37); - int var41 = 0; - int var33 = 0; - int var19 = 0; - - int var6; - int var7; - int var8; - int var18; - int var31; - for (var18 = 0; var18 < var10; ++var18) + if (var17 == 1) { - var8 = var5.readUnsignedByte(); - var31 = 0; - if ((var8 & 1) != 0) + def.animayaGroups = new int[var9][]; + def.animayaScales = new int[var9][]; + } + + def.faceColors = new short[var10]; + var4.setOffset(var23); + var5.setOffset(var34); + var6.setOffset(var35); + var7.setOffset(var24); + var8.setOffset(var29); + int var37 = 0; + int var38 = 0; + int var39 = 0; + + int var40; + int var41; + int var42; + int var43; + int var44; + for (var40 = 0; var40 < var9; ++var40) + { + var41 = var4.readUnsignedByte(); + var42 = 0; + if ((var41 & 1) != 0) { - var31 = var39.readShortSmart(); + var42 = var5.readShortSmart(); } - var6 = 0; - if ((var8 & 2) != 0) + var43 = 0; + if ((var41 & 2) != 0) { - var6 = var26.readShortSmart(); + var43 = var6.readShortSmart(); } - var7 = 0; - if ((var8 & 4) != 0) + var44 = 0; + if ((var41 & 4) != 0) { - var7 = var9.readShortSmart(); + var44 = var7.readShortSmart(); } - model.vertexPositionsX[var18] = var41 + var31; - model.vertexPositionsY[var18] = var33 + var6; - model.vertexPositionsZ[var18] = var19 + var7; - var41 = model.vertexPositionsX[var18]; - var33 = model.vertexPositionsY[var18]; - var19 = model.vertexPositionsZ[var18]; - if (var28 == 1) + def.vertexX[var40] = var37 + var42; + def.vertexY[var40] = var38 + var43; + def.vertexZ[var40] = var39 + var44; + var37 = def.vertexX[var40]; + var38 = def.vertexY[var40]; + var39 = def.vertexZ[var40]; + if (var16 == 1) { - model.vertexSkins[var18] = var3.readUnsignedByte(); + def.packedVertexGroups[var40] = var8.readUnsignedByte(); } } - var5.setOffset(var17); - var39.setOffset(var42); - var26.setOffset(var25); - var9.setOffset(var29); - var3.setOffset(var4); - - for (var18 = 0; var18 < var11; ++var18) + if (var17 == 1) { - model.faceColors[var18] = (short) var5.readUnsignedShort(); - if (var13 == 1) + for (var40 = 0; var40 < var9; ++var40) { - var8 = var39.readUnsignedByte(); - if ((var8 & 1) == 1) + var41 = var8.readUnsignedByte(); + def.animayaGroups[var40] = new int[var41]; + def.animayaScales[var40] = new int[var41]; + + for (var42 = 0; var42 < var41; ++var42) { - model.faceRenderTypes[var18] = 1; + def.animayaGroups[var40][var42] = var8.readUnsignedByte(); + def.animayaScales[var40][var42] = var8.readUnsignedByte(); + } + } + } + + var4.setOffset(var32); + var5.setOffset(var28); + var6.setOffset(var26); + var7.setOffset(var30); + var8.setOffset(var27); + + for (var40 = 0; var40 < var10; ++var40) + { + def.faceColors[var40] = (short) var4.readUnsignedShort(); + if (var12 == 1) + { + var41 = var5.readUnsignedByte(); + if ((var41 & 1) == 1) + { + def.faceRenderTypes[var40] = 1; var2 = true; } else { - model.faceRenderTypes[var18] = 0; + def.faceRenderTypes[var40] = 0; } - if ((var8 & 2) == 2) + if ((var41 & 2) == 2) { - model.textureCoordinates[var18] = (byte) (var8 >> 2); - model.faceTextures[var18] = model.faceColors[var18]; - model.faceColors[var18] = 127; - if (model.faceTextures[var18] != -1) + def.textureCoords[var40] = (byte) (var41 >> 2); + def.faceTextures[var40] = def.faceColors[var40]; + def.faceColors[var40] = 127; + if (def.faceTextures[var40] != -1) { - var43 = true; + var3 = true; } } else { - model.textureCoordinates[var18] = -1; - model.faceTextures[var18] = -1; + def.textureCoords[var40] = -1; + def.faceTextures[var40] = -1; } } - if (var14 == 255) + if (var13 == 255) { - model.faceRenderPriorities[var18] = var26.readByte(); + def.faceRenderPriorities[var40] = var6.readByte(); } - if (var30 == 1) + if (var14 == 1) { - model.faceAlphas[var18] = var9.readByte(); + def.faceTransparencies[var40] = var7.readByte(); } if (var15 == 1) { - model.faceSkins[var18] = var3.readUnsignedByte(); + def.packedTransparencyVertexGroups[var40] = var8.readUnsignedByte(); } } - var5.setOffset(var44); - var39.setOffset(var24); - var18 = 0; - var8 = 0; - var31 = 0; - var6 = 0; + var4.setOffset(var31); + var5.setOffset(var25); + var40 = 0; + var41 = 0; + var42 = 0; + var43 = 0; - int var21; - int var22; - for (var7 = 0; var7 < var11; ++var7) + int var45; + int var46; + for (var44 = 0; var44 < var10; ++var44) { - var22 = var39.readUnsignedByte(); - if (var22 == 1) + var45 = var5.readUnsignedByte(); + if (var45 == 1) { - var18 = var5.readShortSmart() + var6; - var8 = var5.readShortSmart() + var18; - var31 = var5.readShortSmart() + var8; - var6 = var31; - model.faceVertexIndices1[var7] = var18; - model.faceVertexIndices2[var7] = var8; - model.faceVertexIndices3[var7] = var31; + var40 = var4.readShortSmart() + var43; + var41 = var4.readShortSmart() + var40; + var42 = var4.readShortSmart() + var41; + var43 = var42; + def.faceIndices1[var44] = var40; + def.faceIndices2[var44] = var41; + def.faceIndices3[var44] = var42; } - if (var22 == 2) + if (var45 == 2) { - var8 = var31; - var31 = var5.readShortSmart() + var6; - var6 = var31; - model.faceVertexIndices1[var7] = var18; - model.faceVertexIndices2[var7] = var8; - model.faceVertexIndices3[var7] = var31; + var41 = var42; + var42 = var4.readShortSmart() + var43; + var43 = var42; + def.faceIndices1[var44] = var40; + def.faceIndices2[var44] = var41; + def.faceIndices3[var44] = var42; } - if (var22 == 3) + if (var45 == 3) { - var18 = var31; - var31 = var5.readShortSmart() + var6; - var6 = var31; - model.faceVertexIndices1[var7] = var18; - model.faceVertexIndices2[var7] = var8; - model.faceVertexIndices3[var7] = var31; + var40 = var42; + var42 = var4.readShortSmart() + var43; + var43 = var42; + def.faceIndices1[var44] = var40; + def.faceIndices2[var44] = var41; + def.faceIndices3[var44] = var42; } - if (var22 == 4) + if (var45 == 4) { - var21 = var18; - var18 = var8; - var8 = var21; - var31 = var5.readShortSmart() + var6; - var6 = var31; - model.faceVertexIndices1[var7] = var18; - model.faceVertexIndices2[var7] = var21; - model.faceVertexIndices3[var7] = var31; + var46 = var40; + var40 = var41; + var41 = var46; + var42 = var4.readShortSmart() + var43; + var43 = var42; + def.faceIndices1[var44] = var40; + def.faceIndices2[var44] = var46; + def.faceIndices3[var44] = var42; } } + var4.setOffset(var33); + + for (var44 = 0; var44 < var11; ++var44) + { + def.textureRenderTypes[var44] = 0; + def.texIndices1[var44] = (short) var4.readUnsignedShort(); + def.texIndices2[var44] = (short) var4.readUnsignedShort(); + def.texIndices3[var44] = (short) var4.readUnsignedShort(); + } + + if (def.textureCoords != null) + { + boolean var47 = false; + + for (var45 = 0; var45 < var10; ++var45) + { + var46 = def.textureCoords[var45] & 255; + if (var46 != 255) + { + if (def.faceIndices1[var45] == (def.texIndices1[var46] & '\uffff') && def.faceIndices2[var45] == (def.texIndices2[var46] & '\uffff') && def.faceIndices3[var45] == (def.texIndices3[var46] & '\uffff')) + { + def.textureCoords[var45] = -1; + } + else + { + var47 = true; + } + } + } + + if (!var47) + { + def.textureCoords = null; + } + } + + if (!var3) + { + def.faceTextures = null; + } + + if (!var2) + { + def.faceRenderTypes = null; + } + + } + + void decodeType1(ModelDefinition def, byte[] var1) + { + InputStream var2 = new InputStream(var1); + InputStream var3 = new InputStream(var1); + InputStream var4 = new InputStream(var1); + InputStream var5 = new InputStream(var1); + InputStream var6 = new InputStream(var1); + InputStream var7 = new InputStream(var1); + InputStream var8 = new InputStream(var1); + var2.setOffset(var1.length - 23); + int var9 = var2.readUnsignedShort(); + int var10 = var2.readUnsignedShort(); + int var11 = var2.readUnsignedByte(); + int var12 = var2.readUnsignedByte(); + int var13 = var2.readUnsignedByte(); + int var14 = var2.readUnsignedByte(); + int var15 = var2.readUnsignedByte(); + int var16 = var2.readUnsignedByte(); + int var17 = var2.readUnsignedByte(); + int var18 = var2.readUnsignedShort(); + int var19 = var2.readUnsignedShort(); + int var20 = var2.readUnsignedShort(); + int var21 = var2.readUnsignedShort(); + int var22 = var2.readUnsignedShort(); + int var23 = 0; + int var24 = 0; + int var25 = 0; + int var26; + if (var11 > 0) + { + def.textureRenderTypes = new byte[var11]; + var2.setOffset(0); + + for (var26 = 0; var26 < var11; ++var26) + { + byte var27 = def.textureRenderTypes[var26] = var2.readByte(); + if (var27 == 0) + { + ++var23; + } + + if (var27 >= 1 && var27 <= 3) + { + ++var24; + } + + if (var27 == 2) + { + ++var25; + } + } + } + + var26 = var11 + var9; + int var56 = var26; + if (var12 == 1) + { + var26 += var10; + } + + int var28 = var26; + var26 += var10; + int var29 = var26; + if (var13 == 255) + { + var26 += var10; + } + + int var30 = var26; + if (var15 == 1) + { + var26 += var10; + } + + int var31 = var26; + if (var17 == 1) + { + var26 += var9; + } + + int var32 = var26; + if (var14 == 1) + { + var26 += var10; + } + + int var33 = var26; + var26 += var21; + int var34 = var26; + if (var16 == 1) + { + var26 += var10 * 2; + } + + int var35 = var26; + var26 += var22; + int var36 = var26; + var26 += var10 * 2; + int var37 = var26; + var26 += var18; + int var38 = var26; + var26 += var19; + int var39 = var26; + var26 += var20; + int var40 = var26; + var26 += var23 * 6; + int var41 = var26; + var26 += var24 * 6; + int var42 = var26; + var26 += var24 * 6; + int var43 = var26; + var26 += var24 * 2; + int var44 = var26; + var26 += var24; + int var45 = var26; + var26 = var26 + var24 * 2 + var25 * 2; + def.vertexCount = var9; + def.faceCount = var10; + def.numTextureFaces = var11; + def.vertexX = new int[var9]; + def.vertexY = new int[var9]; + def.vertexZ = new int[var9]; + def.faceIndices1 = new int[var10]; + def.faceIndices2 = new int[var10]; + def.faceIndices3 = new int[var10]; + if (var17 == 1) + { + def.packedVertexGroups = new int[var9]; + } + + if (var12 == 1) + { + def.faceRenderTypes = new byte[var10]; + } + + if (var13 == 255) + { + def.faceRenderPriorities = new byte[var10]; + } + else + { + def.priority = (byte) var13; + } + + if (var14 == 1) + { + def.faceTransparencies = new byte[var10]; + } + + if (var15 == 1) + { + def.packedTransparencyVertexGroups = new int[var10]; + } + + if (var16 == 1) + { + def.faceTextures = new short[var10]; + } + + if (var16 == 1 && var11 > 0) + { + def.textureCoords = new byte[var10]; + } + + def.faceColors = new short[var10]; + if (var11 > 0) + { + def.texIndices1 = new short[var11]; + def.texIndices2 = new short[var11]; + def.texIndices3 = new short[var11]; + } + + var2.setOffset(var11); + var3.setOffset(var37); + var4.setOffset(var38); + var5.setOffset(var39); + var6.setOffset(var31); + int var46 = 0; + int var47 = 0; + int var48 = 0; + + int var49; + int var50; + int var51; + int var52; + int var53; + for (var49 = 0; var49 < var9; ++var49) + { + var50 = var2.readUnsignedByte(); + var51 = 0; + if ((var50 & 1) != 0) + { + var51 = var3.readShortSmart(); + } + + var52 = 0; + if ((var50 & 2) != 0) + { + var52 = var4.readShortSmart(); + } + + var53 = 0; + if ((var50 & 4) != 0) + { + var53 = var5.readShortSmart(); + } + + def.vertexX[var49] = var46 + var51; + def.vertexY[var49] = var47 + var52; + def.vertexZ[var49] = var48 + var53; + var46 = def.vertexX[var49]; + var47 = def.vertexY[var49]; + var48 = def.vertexZ[var49]; + if (var17 == 1) + { + def.packedVertexGroups[var49] = var6.readUnsignedByte(); + } + } + + var2.setOffset(var36); + var3.setOffset(var56); + var4.setOffset(var29); var5.setOffset(var32); + var6.setOffset(var30); + var7.setOffset(var34); + var8.setOffset(var35); - for (var7 = 0; var7 < var12; ++var7) + for (var49 = 0; var49 < var10; ++var49) { - model.textureRenderTypes[var7] = 0; - model.textureTriangleVertexIndices1[var7] = (short) var5.readUnsignedShort(); - model.textureTriangleVertexIndices2[var7] = (short) var5.readUnsignedShort(); - model.textureTriangleVertexIndices3[var7] = (short) var5.readUnsignedShort(); + def.faceColors[var49] = (short) var2.readUnsignedShort(); + if (var12 == 1) + { + def.faceRenderTypes[var49] = var3.readByte(); + } + + if (var13 == 255) + { + def.faceRenderPriorities[var49] = var4.readByte(); + } + + if (var14 == 1) + { + def.faceTransparencies[var49] = var5.readByte(); + } + + if (var15 == 1) + { + def.packedTransparencyVertexGroups[var49] = var6.readUnsignedByte(); + } + + if (var16 == 1) + { + def.faceTextures[var49] = (short) (var7.readUnsignedShort() - 1); + } + + if (def.textureCoords != null && def.faceTextures[var49] != -1) + { + def.textureCoords[var49] = (byte) (var8.readUnsignedByte() - 1); + } } - if (model.textureCoordinates != null) + var2.setOffset(var33); + var3.setOffset(var28); + var49 = 0; + var50 = 0; + var51 = 0; + var52 = 0; + + int var54; + for (var53 = 0; var53 < var10; ++var53) + { + var54 = var3.readUnsignedByte(); + if (var54 == 1) + { + var49 = var2.readShortSmart() + var52; + var50 = var2.readShortSmart() + var49; + var51 = var2.readShortSmart() + var50; + var52 = var51; + def.faceIndices1[var53] = var49; + def.faceIndices2[var53] = var50; + def.faceIndices3[var53] = var51; + } + + if (var54 == 2) + { + var50 = var51; + var51 = var2.readShortSmart() + var52; + var52 = var51; + def.faceIndices1[var53] = var49; + def.faceIndices2[var53] = var50; + def.faceIndices3[var53] = var51; + } + + if (var54 == 3) + { + var49 = var51; + var51 = var2.readShortSmart() + var52; + var52 = var51; + def.faceIndices1[var53] = var49; + def.faceIndices2[var53] = var50; + def.faceIndices3[var53] = var51; + } + + if (var54 == 4) + { + int var55 = var49; + var49 = var50; + var50 = var55; + var51 = var2.readShortSmart() + var52; + var52 = var51; + def.faceIndices1[var53] = var49; + def.faceIndices2[var53] = var55; + def.faceIndices3[var53] = var51; + } + } + + var2.setOffset(var40); + var3.setOffset(var41); + var4.setOffset(var42); + var5.setOffset(var43); + var6.setOffset(var44); + var7.setOffset(var45); + + for (var53 = 0; var53 < var11; ++var53) + { + var54 = def.textureRenderTypes[var53] & 255; + if (var54 == 0) + { + def.texIndices1[var53] = (short) var2.readUnsignedShort(); + def.texIndices2[var53] = (short) var2.readUnsignedShort(); + def.texIndices3[var53] = (short) var2.readUnsignedShort(); + } + } + + var2.setOffset(var26); + var53 = var2.readUnsignedByte(); + if (var53 != 0) + { + var2.readUnsignedShort(); + var2.readUnsignedShort(); + var2.readUnsignedShort(); + var2.readInt(); + } + + } + + void decodeOldFormat(ModelDefinition def, byte[] var1) + { + boolean var2 = false; + boolean var3 = false; + InputStream var4 = new InputStream(var1); + InputStream var5 = new InputStream(var1); + InputStream var6 = new InputStream(var1); + InputStream var7 = new InputStream(var1); + InputStream var8 = new InputStream(var1); + var4.setOffset(var1.length - 18); + int var9 = var4.readUnsignedShort(); + int var10 = var4.readUnsignedShort(); + int var11 = var4.readUnsignedByte(); + int var12 = var4.readUnsignedByte(); + int var13 = var4.readUnsignedByte(); + int var14 = var4.readUnsignedByte(); + int var15 = var4.readUnsignedByte(); + int var16 = var4.readUnsignedByte(); + int var17 = var4.readUnsignedShort(); + int var18 = var4.readUnsignedShort(); + int var19 = var4.readUnsignedShort(); + int var20 = var4.readUnsignedShort(); + byte var21 = 0; + int var22 = var21 + var9; + int var23 = var22; + var22 += var10; + int var24 = var22; + if (var13 == 255) + { + var22 += var10; + } + + int var25 = var22; + if (var15 == 1) + { + var22 += var10; + } + + int var26 = var22; + if (var12 == 1) + { + var22 += var10; + } + + int var27 = var22; + if (var16 == 1) + { + var22 += var9; + } + + int var28 = var22; + if (var14 == 1) + { + var22 += var10; + } + + int var29 = var22; + var22 += var20; + int var30 = var22; + var22 += var10 * 2; + int var31 = var22; + var22 += var11 * 6; + int var32 = var22; + var22 += var17; + int var33 = var22; + var22 += var18; + int var10000 = var22 + var19; + def.vertexCount = var9; + def.faceCount = var10; + def.numTextureFaces = var11; + def.vertexX = new int[var9]; + def.vertexY = new int[var9]; + def.vertexZ = new int[var9]; + def.faceIndices1 = new int[var10]; + def.faceIndices2 = new int[var10]; + def.faceIndices3 = new int[var10]; + if (var11 > 0) + { + def.textureRenderTypes = new byte[var11]; + def.texIndices1 = new short[var11]; + def.texIndices2 = new short[var11]; + def.texIndices3 = new short[var11]; + } + + if (var16 == 1) + { + def.packedVertexGroups = new int[var9]; + } + + if (var12 == 1) + { + def.faceRenderTypes = new byte[var10]; + def.textureCoords = new byte[var10]; + def.faceTextures = new short[var10]; + } + + if (var13 == 255) + { + def.faceRenderPriorities = new byte[var10]; + } + else + { + def.priority = (byte) var13; + } + + if (var14 == 1) + { + def.faceTransparencies = new byte[var10]; + } + + if (var15 == 1) + { + def.packedTransparencyVertexGroups = new int[var10]; + } + + def.faceColors = new short[var10]; + var4.setOffset(var21); + var5.setOffset(var32); + var6.setOffset(var33); + var7.setOffset(var22); + var8.setOffset(var27); + int var35 = 0; + int var36 = 0; + int var37 = 0; + + int var38; + int var39; + int var40; + int var41; + int var42; + for (var38 = 0; var38 < var9; ++var38) + { + var39 = var4.readUnsignedByte(); + var40 = 0; + if ((var39 & 1) != 0) + { + var40 = var5.readShortSmart(); + } + + var41 = 0; + if ((var39 & 2) != 0) + { + var41 = var6.readShortSmart(); + } + + var42 = 0; + if ((var39 & 4) != 0) + { + var42 = var7.readShortSmart(); + } + + def.vertexX[var38] = var35 + var40; + def.vertexY[var38] = var36 + var41; + def.vertexZ[var38] = var37 + var42; + var35 = def.vertexX[var38]; + var36 = def.vertexY[var38]; + var37 = def.vertexZ[var38]; + if (var16 == 1) + { + def.packedVertexGroups[var38] = var8.readUnsignedByte(); + } + } + + var4.setOffset(var30); + var5.setOffset(var26); + var6.setOffset(var24); + var7.setOffset(var28); + var8.setOffset(var25); + + for (var38 = 0; var38 < var10; ++var38) + { + def.faceColors[var38] = (short) var4.readUnsignedShort(); + if (var12 == 1) + { + var39 = var5.readUnsignedByte(); + if ((var39 & 1) == 1) + { + def.faceRenderTypes[var38] = 1; + var2 = true; + } + else + { + def.faceRenderTypes[var38] = 0; + } + + if ((var39 & 2) == 2) + { + def.textureCoords[var38] = (byte) (var39 >> 2); + def.faceTextures[var38] = def.faceColors[var38]; + def.faceColors[var38] = 127; + if (def.faceTextures[var38] != -1) + { + var3 = true; + } + } + else + { + def.textureCoords[var38] = -1; + def.faceTextures[var38] = -1; + } + } + + if (var13 == 255) + { + def.faceRenderPriorities[var38] = var6.readByte(); + } + + if (var14 == 1) + { + def.faceTransparencies[var38] = var7.readByte(); + } + + if (var15 == 1) + { + def.packedTransparencyVertexGroups[var38] = var8.readUnsignedByte(); + } + } + + var4.setOffset(var29); + var5.setOffset(var23); + var38 = 0; + var39 = 0; + var40 = 0; + var41 = 0; + + int var43; + int var44; + for (var42 = 0; var42 < var10; ++var42) + { + var43 = var5.readUnsignedByte(); + if (var43 == 1) + { + var38 = var4.readShortSmart() + var41; + var39 = var4.readShortSmart() + var38; + var40 = var4.readShortSmart() + var39; + var41 = var40; + def.faceIndices1[var42] = var38; + def.faceIndices2[var42] = var39; + def.faceIndices3[var42] = var40; + } + + if (var43 == 2) + { + var39 = var40; + var40 = var4.readShortSmart() + var41; + var41 = var40; + def.faceIndices1[var42] = var38; + def.faceIndices2[var42] = var39; + def.faceIndices3[var42] = var40; + } + + if (var43 == 3) + { + var38 = var40; + var40 = var4.readShortSmart() + var41; + var41 = var40; + def.faceIndices1[var42] = var38; + def.faceIndices2[var42] = var39; + def.faceIndices3[var42] = var40; + } + + if (var43 == 4) + { + var44 = var38; + var38 = var39; + var39 = var44; + var40 = var4.readShortSmart() + var41; + var41 = var40; + def.faceIndices1[var42] = var38; + def.faceIndices2[var42] = var44; + def.faceIndices3[var42] = var40; + } + } + + var4.setOffset(var31); + + for (var42 = 0; var42 < var11; ++var42) + { + def.textureRenderTypes[var42] = 0; + def.texIndices1[var42] = (short) var4.readUnsignedShort(); + def.texIndices2[var42] = (short) var4.readUnsignedShort(); + def.texIndices3[var42] = (short) var4.readUnsignedShort(); + } + + if (def.textureCoords != null) { boolean var45 = false; - for (var22 = 0; var22 < var11; ++var22) + for (var43 = 0; var43 < var10; ++var43) { - var21 = model.textureCoordinates[var22] & 255; - if (var21 != 255) + var44 = def.textureCoords[var43] & 255; + if (var44 != 255) { - if ((model.textureTriangleVertexIndices1[var21] & '\uffff') == model.faceVertexIndices1[var22] && (model.textureTriangleVertexIndices2[var21] & '\uffff') == model.faceVertexIndices2[var22] && (model.textureTriangleVertexIndices3[var21] & '\uffff') == model.faceVertexIndices3[var22]) + if (def.faceIndices1[var43] == (def.texIndices1[var44] & '\uffff') && def.faceIndices2[var43] == (def.texIndices2[var44] & '\uffff') && def.faceIndices3[var43] == (def.texIndices3[var44] & '\uffff')) { - model.textureCoordinates[var22] = -1; + def.textureCoords[var43] = -1; } else { @@ -732,19 +1394,19 @@ public class ModelLoader if (!var45) { - model.textureCoordinates = null; + def.textureCoords = null; } } - if (!var43) + if (!var3) { - model.faceTextures = null; + def.faceTextures = null; } if (!var2) { - model.faceRenderTypes = null; + def.faceRenderTypes = null; } - } + } } diff --git a/cache/src/main/java/net/runelite/cache/item/ItemSpriteFactory.java b/cache/src/main/java/net/runelite/cache/item/ItemSpriteFactory.java index c93edf3611..cd70e9b218 100644 --- a/cache/src/main/java/net/runelite/cache/item/ItemSpriteFactory.java +++ b/cache/src/main/java/net/runelite/cache/item/ItemSpriteFactory.java @@ -227,22 +227,22 @@ public class ItemSpriteFactory litModel.field1856 = new int[def.faceCount]; litModel.field1854 = new int[def.faceCount]; litModel.field1823 = new int[def.faceCount]; - if (def.textureTriangleCount > 0 && def.textureCoordinates != null) + if (def.numTextureFaces > 0 && def.textureCoords != null) { - int[] var9 = new int[def.textureTriangleCount]; + int[] var9 = new int[def.numTextureFaces]; int var10; for (var10 = 0; var10 < def.faceCount; ++var10) { - if (def.textureCoordinates[var10] != -1) + if (def.textureCoords[var10] != -1) { - ++var9[def.textureCoordinates[var10] & 255]; + ++var9[def.textureCoords[var10] & 255]; } } litModel.field1852 = 0; - for (var10 = 0; var10 < def.textureTriangleCount; ++var10) + for (var10 = 0; var10 < def.numTextureFaces; ++var10) { if (var9[var10] > 0 && def.textureRenderTypes[var10] == 0) { @@ -256,13 +256,13 @@ public class ItemSpriteFactory var10 = 0; - for (int i = 0; i < def.textureTriangleCount; ++i) + for (int i = 0; i < def.numTextureFaces; ++i) { if (var9[i] > 0 && def.textureRenderTypes[i] == 0) { - litModel.field1844[var10] = def.textureTriangleVertexIndices1[i] & '\uffff'; - litModel.field1865[var10] = def.textureTriangleVertexIndices2[i] & '\uffff'; - litModel.field1846[var10] = def.textureTriangleVertexIndices3[i] & '\uffff'; + litModel.field1844[var10] = def.texIndices1[i] & '\uffff'; + litModel.field1865[var10] = def.texIndices2[i] & '\uffff'; + litModel.field1846[var10] = def.texIndices3[i] & '\uffff'; var9[i] = var10++; } else @@ -275,9 +275,9 @@ public class ItemSpriteFactory for (int i = 0; i < def.faceCount; ++i) { - if (def.textureCoordinates[i] != -1) + if (def.textureCoords[i] != -1) { - litModel.field1840[i] = (byte) var9[def.textureCoordinates[i] & 255]; + litModel.field1840[i] = (byte) var9[def.textureCoords[i] & 255]; } else { @@ -299,13 +299,13 @@ public class ItemSpriteFactory } byte faceAlpha; - if (def.faceAlphas == null) + if (def.faceTransparencies == null) { faceAlpha = 0; } else { - faceAlpha = def.faceAlphas[faceIdx]; + faceAlpha = def.faceTransparencies[faceIdx]; } short faceTexture; @@ -355,15 +355,15 @@ public class ItemSpriteFactory else { int var15 = def.faceColors[faceIdx] & '\uffff'; - vertexNormal = def.vertexNormals[def.faceVertexIndices1[faceIdx]]; + vertexNormal = def.vertexNormals[def.faceIndices1[faceIdx]]; tmp = (y * vertexNormal.y + z * vertexNormal.z + x * vertexNormal.x) / (var7 * vertexNormal.magnitude) + ambient; litModel.field1856[faceIdx] = method2608(var15, tmp); - vertexNormal = def.vertexNormals[def.faceVertexIndices2[faceIdx]]; + vertexNormal = def.vertexNormals[def.faceIndices2[faceIdx]]; tmp = (y * vertexNormal.y + z * vertexNormal.z + x * vertexNormal.x) / (var7 * vertexNormal.magnitude) + ambient; litModel.field1854[faceIdx] = method2608(var15, tmp); - vertexNormal = def.vertexNormals[def.faceVertexIndices3[faceIdx]]; + vertexNormal = def.vertexNormals[def.faceIndices3[faceIdx]]; tmp = (y * vertexNormal.y + z * vertexNormal.z + x * vertexNormal.x) / (var7 * vertexNormal.magnitude) + ambient; litModel.field1823[faceIdx] = method2608(var15, tmp); @@ -385,15 +385,15 @@ public class ItemSpriteFactory } else { - vertexNormal = def.vertexNormals[def.faceVertexIndices1[faceIdx]]; + vertexNormal = def.vertexNormals[def.faceIndices1[faceIdx]]; tmp = (y * vertexNormal.y + z * vertexNormal.z + x * vertexNormal.x) / (var7 * vertexNormal.magnitude) + ambient; litModel.field1856[faceIdx] = bound2to126(tmp); - vertexNormal = def.vertexNormals[def.faceVertexIndices2[faceIdx]]; + vertexNormal = def.vertexNormals[def.faceIndices2[faceIdx]]; tmp = (y * vertexNormal.y + z * vertexNormal.z + x * vertexNormal.x) / (var7 * vertexNormal.magnitude) + ambient; litModel.field1854[faceIdx] = bound2to126(tmp); - vertexNormal = def.vertexNormals[def.faceVertexIndices3[faceIdx]]; + vertexNormal = def.vertexNormals[def.faceIndices3[faceIdx]]; tmp = (y * vertexNormal.y + z * vertexNormal.z + x * vertexNormal.x) / (var7 * vertexNormal.magnitude) + ambient; litModel.field1823[faceIdx] = bound2to126(tmp); @@ -401,15 +401,15 @@ public class ItemSpriteFactory } litModel.verticesCount = def.vertexCount; - litModel.verticesX = def.vertexPositionsX; - litModel.verticesY = def.vertexPositionsY; - litModel.verticesZ = def.vertexPositionsZ; + litModel.verticesX = def.vertexX; + litModel.verticesY = def.vertexY; + litModel.verticesZ = def.vertexZ; litModel.indicesCount = def.faceCount; - litModel.indices1 = def.faceVertexIndices1; - litModel.indices2 = def.faceVertexIndices2; - litModel.indices3 = def.faceVertexIndices3; + litModel.indices1 = def.faceIndices1; + litModel.indices2 = def.faceIndices2; + litModel.indices3 = def.faceIndices3; litModel.field1838 = def.faceRenderPriorities; - litModel.field1882 = def.faceAlphas; + litModel.field1882 = def.faceTransparencies; litModel.field1842 = def.priority; litModel.field1841 = def.faceTextures; return litModel; diff --git a/cache/src/main/java/net/runelite/cache/models/ObjExporter.java b/cache/src/main/java/net/runelite/cache/models/ObjExporter.java index fb65f99972..75b67f689f 100644 --- a/cache/src/main/java/net/runelite/cache/models/ObjExporter.java +++ b/cache/src/main/java/net/runelite/cache/models/ObjExporter.java @@ -53,9 +53,9 @@ public class ObjExporter for (int i = 0; i < model.vertexCount; ++i) { - objWriter.println("v " + model.vertexPositionsX[i] + " " - + model.vertexPositionsY[i] * -1 + " " - + model.vertexPositionsZ[i] * -1); + objWriter.println("v " + model.vertexX[i] + " " + + model.vertexY[i] * -1 + " " + + model.vertexZ[i] * -1); } if (model.faceTextures != null) @@ -78,9 +78,9 @@ public class ObjExporter for (int i = 0; i < model.faceCount; ++i) { - int x = model.faceVertexIndices1[i] + 1; - int y = model.faceVertexIndices2[i] + 1; - int z = model.faceVertexIndices3[i] + 1; + int x = model.faceIndices1[i] + 1; + int y = model.faceIndices2[i] + 1; + int z = model.faceIndices3[i] + 1; objWriter.println("usemtl m" + i); if (model.faceTextures != null) @@ -129,9 +129,9 @@ public class ObjExporter int alpha = 0; - if (model.faceAlphas != null) + if (model.faceTransparencies != null) { - alpha = model.faceAlphas[i] & 0xFF; + alpha = model.faceTransparencies[i] & 0xFF; } if (alpha != 0)