aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys/neodymium/renderer/QuadNormal.java
blob: 9ef32acdb874371778397e0695e879afb82a8502 (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() == 1f) {
                    return POSITIVE_Z;
                } else if(normal.getZ() == -1f) {
                    return NEGATIVE_Z;
                }
            } else if(normal.getZ() == 0f) {
                if(normal.getY() == 1f) {
                    return POSITIVE_Y;
                } else if(normal.getY() == -1f) {
                    return NEGATIVE_Y;
                }
            }
        } else if(normal.getY() == 0f) {
            if(normal.getZ() == 0f) {
                if(normal.getX() == 1f) {
                    return POSITIVE_X;
                } else if(normal.getX() == -1f) {
                    return NEGATIVE_X;
                }
            }
        }
        return NONE;
    }
}