-
-
Notifications
You must be signed in to change notification settings - Fork 440
Expand file tree
/
Copy pathTypes.java
More file actions
152 lines (131 loc) · 4.57 KB
/
Copy pathTypes.java
File metadata and controls
152 lines (131 loc) · 4.57 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package app.f3d.F3D;
public class Types {
// Load the native library
static {
System.loadLibrary("f3d-java");
}
/**
* Describe a colormap, which is a vector of repeated: val,r,g,b
*/
public static class Colormap {
public double[] data;
public Colormap() {
data = new double[0];
}
public Colormap(double[] data) {
this.data = data;
}
}
/**
* Light type enumeration.
*/
public enum LightType {
HEADLIGHT(1),
CAMERA_LIGHT(2),
SCENE_LIGHT(3);
private final int value;
LightType(int value) {
this.value = value;
}
public int getValue() {
return value;
}
public static LightType fromValue(int value) {
for (LightType type : values()) {
if (type.value == value) {
return type;
}
}
throw new IllegalArgumentException("Unknown light type: " + value);
}
}
/**
* Structure describing the state of a light.
*/
public static class LightState {
public LightType type = LightType.SCENE_LIGHT;
public double[] position = new double[] { 0.0, 0.0, 0.0 };
public double[] color = new double[] { 1.0, 1.0, 1.0 };
public double[] direction = new double[] { 1.0, 0.0, 0.0 };
public boolean positionalLight = false;
public double intensity = 1.0;
public boolean switchState = true;
public LightState() {
}
public LightState(LightType type, double[] position, double[] color,
double[] direction, boolean positionalLight,
double intensity, boolean switchState) {
this.type = type;
this.position = position;
this.color = color;
this.direction = direction;
this.positionalLight = positionalLight;
this.intensity = intensity;
this.switchState = switchState;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
LightState other = (LightState) obj;
return type == other.type &&
java.util.Arrays.equals(position, other.position) &&
java.util.Arrays.equals(color, other.color) &&
java.util.Arrays.equals(direction, other.direction) &&
positionalLight == other.positionalLight &&
intensity == other.intensity &&
switchState == other.switchState;
}
}
/**
* Structure describing a single node of the scene hierarchy.
*/
public static class NodeState {
public int id = -1;
public int parentId = -1;
public int level = 0;
public String label = "";
public boolean visible = true;
public boolean hasChildren = false;
public boolean collapsed = false;
public NodeState() {
}
}
/**
* Describes a 3D surfacic mesh.
*/
public static class Mesh {
public float[] points = new float[0];
public float[] normals = new float[0];
public float[] textureCoordinates = new float[0];
public int[] faceSides = new int[0];
public int[] faceIndices = new int[0];
public Mesh() {
}
public Mesh(float[] points, float[] normals, float[] textureCoordinates,
int[] faceSides, int[] faceIndices) {
this.points = points != null ? points : new float[0];
this.normals = normals != null ? normals : new float[0];
this.textureCoordinates = textureCoordinates != null ? textureCoordinates : new float[0];
this.faceSides = faceSides != null ? faceSides : new int[0];
this.faceIndices = faceIndices != null ? faceIndices : new int[0];
}
/**
* Validates the mesh.
*
* @return ValidationResult containing whether mesh is valid and error message if invalid
*/
public native ValidationResult isValid();
/**
* Result of mesh validation.
*/
public static class ValidationResult {
public boolean valid;
public String errorMessage;
public ValidationResult(boolean valid, String errorMessage) {
this.valid = valid;
this.errorMessage = errorMessage;
}
}
}
}