Search in sources :

Example 6 with VertexNormal

use of net.runelite.cache.models.VertexNormal 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

VertexNormal (net.runelite.cache.models.VertexNormal)6 FaceNormal (net.runelite.cache.models.FaceNormal)4 Color (java.awt.Color)1 FileNotFoundException (java.io.FileNotFoundException)1 PrintWriter (java.io.PrintWriter)1 ModelDefinition (net.runelite.cache.definitions.ModelDefinition)1 TextureDefinition (net.runelite.cache.definitions.TextureDefinition)1 File (net.runelite.cache.fs.File)1 Vector3f (net.runelite.cache.models.Vector3f)1