Search in sources :

Example 1 with FaceNormal

use of net.runelite.cache.models.FaceNormal in project ostracker by OSTracker.

the class ModelData method method1624.

public final Model method1624(int var1, int var2, int var3, int var4, int var5) {
    this.computeNormals();
    int var6 = (int) Math.sqrt((double) (var3 * var3 + var4 * var4 + var5 * var5));
    int var7 = var2 * var6 >> 8;
    Model var8 = new Model();
    var8.field1412 = new int[this.triangleFaceCount];
    var8.field1416 = new int[this.triangleFaceCount];
    var8.field1379 = new int[this.triangleFaceCount];
    if (this.texturePointCount > 0 && this.textureCoords != null) {
        // var16 contains how many faces use a specific texture
        int[] var16 = new int[this.texturePointCount];
        int var10;
        for (var10 = 0; var10 < this.triangleFaceCount; ++var10) {
            if (this.textureCoords[var10] != -1) {
                ++var16[this.textureCoords[var10] & 255];
            }
        }
        var8.field1385 = 0;
        for (var10 = 0; var10 < this.texturePointCount; ++var10) {
            if (var16[var10] > 0 && this.textureRenderTypes[var10] == 0) {
                ++var8.field1385;
            }
        }
        var8.texTriangleX = new int[var8.field1385];
        var8.texTriangleY = new int[var8.field1385];
        var8.texTriangleZ = new int[var8.field1385];
        var10 = 0;
        int var11;
        for (var11 = 0; var11 < this.texturePointCount; ++var11) {
            if (var16[var11] > 0 && this.textureRenderTypes[var11] == 0) {
                var8.texTriangleX[var10] = this.texTriangleX[var11] & '￿';
                var8.texTriangleY[var10] = this.texTriangleY[var11] & '￿';
                var8.texTriangleZ[var10] = this.texTriangleZ[var11] & '￿';
                var16[var11] = var10++;
            } else {
                var16[var11] = -1;
            }
        }
        var8.triangleTextureIndex = new byte[this.triangleFaceCount];
        for (var11 = 0; var11 < this.triangleFaceCount; ++var11) {
            if (this.textureCoords[var11] != -1) {
                var8.triangleTextureIndex[var11] = (byte) var16[this.textureCoords[var11] & 255];
            } else {
                var8.triangleTextureIndex[var11] = -1;
            }
        }
    }
    for (int var9 = 0; var9 < this.triangleFaceCount; ++var9) {
        byte var17;
        if (this.faceRenderType == null) {
            var17 = 0;
        } else {
            var17 = this.faceRenderType[var9];
        }
        byte var18;
        if (this.faceAlphas == null) {
            var18 = 0;
        } else {
            var18 = this.faceAlphas[var9];
        }
        short var12;
        if (this.faceTextures == null) {
            var12 = -1;
        } else {
            var12 = this.faceTextures[var9];
        }
        if (var18 == -2) {
            var17 = 3;
        }
        if (var18 == -1) {
            var17 = 2;
        }
        VertexNormal var13;
        int var14;
        FaceNormal var19;
        if (var12 == -1) {
            if (var17 != 0) {
                if (var17 == 1) {
                    var19 = this.faceNormals[var9];
                    var14 = var1 + (var3 * var19.x + var4 * var19.y + var5 * var19.z) / (var7 + var7 / 2);
                    var8.field1412[var9] = method1568(this.faceColor[var9] & '￿', var14);
                    var8.field1379[var9] = -1;
                } else if (var17 == 3) {
                    var8.field1412[var9] = 128;
                    var8.field1379[var9] = -1;
                } else {
                    var8.field1379[var9] = -2;
                }
            } else {
                int var15 = this.faceColor[var9] & '￿';
                if (this.normals2 != null && this.normals2[this.trianglePointsX[var9]] != null) {
                    var13 = this.normals2[this.trianglePointsX[var9]];
                } else {
                    var13 = this.normals[this.trianglePointsX[var9]];
                }
                var14 = var1 + (var3 * var13.x + var4 * var13.y + var5 * var13.z) / (var7 * var13.magnitude);
                var8.field1412[var9] = method1568(var15, var14);
                if (this.normals2 != null && this.normals2[this.trianglePointsY[var9]] != null) {
                    var13 = this.normals2[this.trianglePointsY[var9]];
                } else {
                    var13 = this.normals[this.trianglePointsY[var9]];
                }
                var14 = var1 + (var3 * var13.x + var4 * var13.y + var5 * var13.z) / (var7 * var13.magnitude);
                var8.field1416[var9] = method1568(var15, var14);
                if (this.normals2 != null && this.normals2[this.trianglePointsZ[var9]] != null) {
                    var13 = this.normals2[this.trianglePointsZ[var9]];
                } else {
                    var13 = this.normals[this.trianglePointsZ[var9]];
                }
                var14 = var1 + (var3 * var13.x + var4 * var13.y + var5 * var13.z) / (var7 * var13.magnitude);
                var8.field1379[var9] = method1568(var15, var14);
            }
        } else if (var17 != 0) {
            if (var17 == 1) {
                var19 = this.faceNormals[var9];
                var14 = var1 + (var3 * var19.x + var4 * var19.y + var5 * var19.z) / (var7 + var7 / 2);
                var8.field1412[var9] = method1569(var14);
                var8.field1379[var9] = -1;
            } else {
                var8.field1379[var9] = -2;
            }
        } else {
            if (this.normals2 != null && this.normals2[this.trianglePointsX[var9]] != null) {
                var13 = this.normals2[this.trianglePointsX[var9]];
            } else {
                var13 = this.normals[this.trianglePointsX[var9]];
            }
            var14 = var1 + (var3 * var13.x + var4 * var13.y + var5 * var13.z) / (var7 * var13.magnitude);
            var8.field1412[var9] = method1569(var14);
            if (this.normals2 != null && this.normals2[this.trianglePointsY[var9]] != null) {
                var13 = this.normals2[this.trianglePointsY[var9]];
            } else {
                var13 = this.normals[this.trianglePointsY[var9]];
            }
            var14 = var1 + (var3 * var13.x + var4 * var13.y + var5 * var13.z) / (var7 * var13.magnitude);
            var8.field1416[var9] = method1569(var14);
            if (this.normals2 != null && this.normals2[this.trianglePointsZ[var9]] != null) {
                var13 = this.normals2[this.trianglePointsZ[var9]];
            } else {
                var13 = this.normals[this.trianglePointsZ[var9]];
            }
            var14 = var1 + (var3 * var13.x + var4 * var13.y + var5 * var13.z) / (var7 * var13.magnitude);
            var8.field1379[var9] = method1569(var14);
        }
    }
    this.computeAnimationTables();
    var8.field1369 = this.vertexCount;
    var8.verticesX = this.vertexX;
    var8.verticesY = this.vertexY;
    var8.verticesZ = this.vertexZ;
    var8.field1384 = this.triangleFaceCount;
    var8.indices1 = this.trianglePointsX;
    var8.indices2 = this.trianglePointsY;
    var8.indices3 = this.trianglePointsZ;
    var8.field1383 = this.faceRenderPriorities;
    var8.field1381 = this.faceAlphas;
    var8.faceTextures = this.faceTextures;
    return var8;
}
Also used : VertexNormal(net.runelite.cache.models.VertexNormal) FaceNormal(net.runelite.cache.models.FaceNormal)

Example 2 with FaceNormal

use of net.runelite.cache.models.FaceNormal in project runelite by runelite.

the class ModelDefinition method computeNormals.

public void computeNormals() {
    if (this.vertexNormals != null) {
        return;
    }
    this.vertexNormals = new VertexNormal[this.vertexCount];
    int var1;
    for (var1 = 0; var1 < this.vertexCount; ++var1) {
        this.vertexNormals[var1] = new VertexNormal();
    }
    for (var1 = 0; var1 < this.faceCount; ++var1) {
        int vertexA = this.faceVertexIndices1[var1];
        int vertexB = this.faceVertexIndices2[var1];
        int vertexC = this.faceVertexIndices3[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 xB = this.vertexPositionsX[vertexC] - this.vertexPositionsX[vertexA];
        int yB = this.vertexPositionsY[vertexC] - this.vertexPositionsY[vertexA];
        int zB = this.vertexPositionsZ[vertexC] - this.vertexPositionsZ[vertexA];
        // Compute cross product
        int var11 = yA * zB - yB * zA;
        int var12 = zA * xB - zB * xA;
        int var13 = xA * yB - xB * yA;
        while (var11 > 8192 || var12 > 8192 || var13 > 8192 || var11 < -8192 || var12 < -8192 || var13 < -8192) {
            var11 >>= 1;
            var12 >>= 1;
            var13 >>= 1;
        }
        int length = (int) Math.sqrt((double) (var11 * var11 + var12 * var12 + var13 * var13));
        if (length <= 0) {
            length = 1;
        }
        var11 = var11 * 256 / length;
        var12 = var12 * 256 / length;
        var13 = var13 * 256 / length;
        byte var15;
        if (this.faceRenderTypes == null) {
            var15 = 0;
        } else {
            var15 = this.faceRenderTypes[var1];
        }
        if (var15 == 0) {
            VertexNormal var16 = this.vertexNormals[vertexA];
            var16.x += var11;
            var16.y += var12;
            var16.z += var13;
            ++var16.magnitude;
            var16 = this.vertexNormals[vertexB];
            var16.x += var11;
            var16.y += var12;
            var16.z += var13;
            ++var16.magnitude;
            var16 = this.vertexNormals[vertexC];
            var16.x += var11;
            var16.y += var12;
            var16.z += var13;
            ++var16.magnitude;
        } else if (var15 == 1) {
            if (this.faceNormals == null) {
                this.faceNormals = new FaceNormal[this.faceCount];
            }
            FaceNormal var17 = this.faceNormals[var1] = new FaceNormal();
            var17.x = var11;
            var17.y = var12;
            var17.z = var13;
        }
    }
}
Also used : VertexNormal(net.runelite.cache.models.VertexNormal) FaceNormal(net.runelite.cache.models.FaceNormal)

Example 3 with FaceNormal

use of net.runelite.cache.models.FaceNormal in project runelite by runelite.

the class ItemSpriteFactory method light.

private static Model light(ModelDefinition def, int ambient, int contrast, int x, int y, int z) {
    def.computeNormals();
    int somethingMagnitude = (int) Math.sqrt((double) (z * z + x * x + y * y));
    int var7 = somethingMagnitude * contrast >> 8;
    Model litModel = new Model();
    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) {
        int[] var9 = new int[def.textureTriangleCount];
        int var10;
        for (var10 = 0; var10 < def.faceCount; ++var10) {
            if (def.textureCoordinates[var10] != -1) {
                ++var9[def.textureCoordinates[var10] & 255];
            }
        }
        litModel.field1852 = 0;
        for (var10 = 0; var10 < def.textureTriangleCount; ++var10) {
            if (var9[var10] > 0 && def.textureRenderTypes[var10] == 0) {
                ++litModel.field1852;
            }
        }
        litModel.field1844 = new int[litModel.field1852];
        litModel.field1865 = new int[litModel.field1852];
        litModel.field1846 = new int[litModel.field1852];
        var10 = 0;
        for (int i = 0; i < def.textureTriangleCount; ++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';
                var9[i] = var10++;
            } else {
                var9[i] = -1;
            }
        }
        litModel.field1840 = new byte[def.faceCount];
        for (int i = 0; i < def.faceCount; ++i) {
            if (def.textureCoordinates[i] != -1) {
                litModel.field1840[i] = (byte) var9[def.textureCoordinates[i] & 255];
            } else {
                litModel.field1840[i] = -1;
            }
        }
    }
    for (int faceIdx = 0; faceIdx < def.faceCount; ++faceIdx) {
        byte faceType;
        if (def.faceRenderTypes == null) {
            faceType = 0;
        } else {
            faceType = def.faceRenderTypes[faceIdx];
        }
        byte faceAlpha;
        if (def.faceAlphas == null) {
            faceAlpha = 0;
        } else {
            faceAlpha = def.faceAlphas[faceIdx];
        }
        short faceTexture;
        if (def.faceTextures == null) {
            faceTexture = -1;
        } else {
            faceTexture = def.faceTextures[faceIdx];
        }
        if (faceAlpha == -2) {
            faceType = 3;
        }
        if (faceAlpha == -1) {
            faceType = 2;
        }
        VertexNormal vertexNormal;
        int tmp;
        FaceNormal faceNormal;
        if (faceTexture == -1) {
            if (faceType != 0) {
                if (faceType == 1) {
                    faceNormal = def.faceNormals[faceIdx];
                    tmp = (y * faceNormal.y + z * faceNormal.z + x * faceNormal.x) / (var7 / 2 + var7) + ambient;
                    litModel.field1856[faceIdx] = method2608(def.faceColors[faceIdx] & '\uffff', tmp);
                    litModel.field1823[faceIdx] = -1;
                } else if (faceType == 3) {
                    litModel.field1856[faceIdx] = 128;
                    litModel.field1823[faceIdx] = -1;
                } else {
                    litModel.field1823[faceIdx] = -2;
                }
            } else {
                int var15 = def.faceColors[faceIdx] & '\uffff';
                vertexNormal = def.vertexNormals[def.faceVertexIndices1[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]];
                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]];
                tmp = (y * vertexNormal.y + z * vertexNormal.z + x * vertexNormal.x) / (var7 * vertexNormal.magnitude) + ambient;
                litModel.field1823[faceIdx] = method2608(var15, tmp);
            }
        } else if (faceType != 0) {
            if (faceType == 1) {
                faceNormal = def.faceNormals[faceIdx];
                tmp = (y * faceNormal.y + z * faceNormal.z + x * faceNormal.x) / (var7 / 2 + var7) + ambient;
                litModel.field1856[faceIdx] = bound2to126(tmp);
                litModel.field1823[faceIdx] = -1;
            } else {
                litModel.field1823[faceIdx] = -2;
            }
        } else {
            vertexNormal = def.vertexNormals[def.faceVertexIndices1[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]];
            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]];
            tmp = (y * vertexNormal.y + z * vertexNormal.z + x * vertexNormal.x) / (var7 * vertexNormal.magnitude) + ambient;
            litModel.field1823[faceIdx] = bound2to126(tmp);
        }
    }
    litModel.verticesCount = def.vertexCount;
    litModel.verticesX = def.vertexPositionsX;
    litModel.verticesY = def.vertexPositionsY;
    litModel.verticesZ = def.vertexPositionsZ;
    litModel.indicesCount = def.faceCount;
    litModel.indices1 = def.faceVertexIndices1;
    litModel.indices2 = def.faceVertexIndices2;
    litModel.indices3 = def.faceVertexIndices3;
    litModel.field1838 = def.faceRenderPriorities;
    litModel.field1882 = def.faceAlphas;
    litModel.field1842 = def.priority;
    litModel.field1841 = def.faceTextures;
    return litModel;
}
Also used : VertexNormal(net.runelite.cache.models.VertexNormal) FaceNormal(net.runelite.cache.models.FaceNormal)

Example 4 with FaceNormal

use of net.runelite.cache.models.FaceNormal in project ostracker by OSTracker.

the class ModelData method computeNormals.

public void computeNormals() {
    if (this.normals == null) {
        this.normals = new VertexNormal[this.vertexCount];
        int var1;
        for (var1 = 0; var1 < this.vertexCount; ++var1) {
            this.normals[var1] = new VertexNormal();
        }
        for (var1 = 0; var1 < this.triangleFaceCount; ++var1) {
            int var2 = this.trianglePointsX[var1];
            int var3 = this.trianglePointsY[var1];
            int var4 = this.trianglePointsZ[var1];
            int var5 = this.vertexX[var3] - this.vertexX[var2];
            int var6 = this.vertexY[var3] - this.vertexY[var2];
            int var7 = this.vertexZ[var3] - this.vertexZ[var2];
            int var8 = this.vertexX[var4] - this.vertexX[var2];
            int var9 = this.vertexY[var4] - this.vertexY[var2];
            int var10 = this.vertexZ[var4] - this.vertexZ[var2];
            int var11 = var6 * var10 - var9 * var7;
            int var12 = var7 * var8 - var10 * var5;
            int var13;
            for (var13 = var5 * var9 - var8 * var6; var11 > 8192 || var12 > 8192 || var13 > 8192 || var11 < -8192 || var12 < -8192 || var13 < -8192; var13 >>= 1) {
                var11 >>= 1;
                var12 >>= 1;
            }
            int var14 = (int) Math.sqrt((double) (var11 * var11 + var12 * var12 + var13 * var13));
            if (var14 <= 0) {
                var14 = 1;
            }
            var11 = var11 * 256 / var14;
            var12 = var12 * 256 / var14;
            var13 = var13 * 256 / var14;
            byte var15;
            if (this.faceRenderType == null) {
                var15 = 0;
            } else {
                var15 = this.faceRenderType[var1];
            }
            if (var15 == 0) {
                VertexNormal var16 = this.normals[var2];
                var16.x += var11;
                var16.y += var12;
                var16.z += var13;
                ++var16.magnitude;
                var16 = this.normals[var3];
                var16.x += var11;
                var16.y += var12;
                var16.z += var13;
                ++var16.magnitude;
                var16 = this.normals[var4];
                var16.x += var11;
                var16.y += var12;
                var16.z += var13;
                ++var16.magnitude;
            } else if (var15 == 1) {
                if (this.faceNormals == null) {
                    this.faceNormals = new FaceNormal[this.triangleFaceCount];
                }
                FaceNormal var17 = this.faceNormals[var1] = new FaceNormal();
                var17.x = var11;
                var17.y = var12;
                var17.z = var13;
            }
        }
    }
}
Also used : VertexNormal(net.runelite.cache.models.VertexNormal) FaceNormal(net.runelite.cache.models.FaceNormal)

Aggregations

FaceNormal (net.runelite.cache.models.FaceNormal)4 VertexNormal (net.runelite.cache.models.VertexNormal)4