aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys/neodymium/renderer/QuadNormal.java
blob: 99d1a45ad7813e83b721a81e9c483febd67871a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package makamys.neodymium.renderer;

import org.lwjgl.util.vector.Vector3f;

public enum QuadNormal {
    NONE, POSITIVE_X, NEGATIVE_X, POSITIVE_Y, NEGATIVE_Y, POSITIVE_Z, NEGATIVE_Z;

    public static QuadNormal fromVector(Vector3f normal) {
        if(normal.getX() == 0f) {
            if(normal.getY() == 0f) {
                if(normal.getZ() > 0) {
                    return POSITIVE_Z;
                } else if(normal.getZ() < 0) {
                    return NEGATIVE_Z;
                }
            } else if(normal.getZ() == 0f) {
                if(normal.getY() > 0) {
                    return POSITIVE_Y;
                } else if(normal.getY() < 0) {
                    return NEGATIVE_Y;
                }
            }
        } else if(normal.getY() == 0f) {
            if(normal.getZ() == 0f) {
                if(normal.getX() > 0) {
                    return POSITIVE_X;
                } else if(normal.getX() < 0) {
                    return NEGATIVE_X;
                }
            }
        }
        return NONE;
    }
}