-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVertexX2_Mesh.pde
75 lines (65 loc) · 1.84 KB
/
VertexX2_Mesh.pde
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
class VertexX2_Mesh extends Basic_Mesh{
ArrayList<IntList> vertex_list;
VertexX2_Mesh() {
build();
shape.disableStyle();
s_points.disableStyle();
}
void build() {
vertices = new ArrayList<PVector>();
vertex_list = new ArrayList<IntList>();
PShape s = loadShape("wolf.obj");
int children = s.getChildCount();
for (int i = 0; i < children; i++) {
PShape child = s.getChild(i);
IntList next_vertex = new IntList();
int total = child.getVertexCount();
for(int j=0; j< total;j++){
vertices.add(child.getVertex(j));
next_vertex.append(vertices.size()-1);
}
vertex_list.add(next_vertex);
}
shape = createShape();
s_points = createShape();
shape.beginShape(TRIANGLES);
s_points.beginShape(POINTS);
for(int i =0; i < vertex_list.size();i++) {
PVector cvertex;
for(int nxt: vertex_list.get(i)) {
cvertex = vertices.get(nxt);
shape.vertex(cvertex.x, cvertex.y, cvertex.z);
s_points.vertex(cvertex.x, cvertex.y, cvertex.z);
}
}
s_points.endShape();
shape.endShape();
}
void drawImmediate() {
if(mode == 3){
PShape s = createShape();
s.beginShape(POINTS);
for(int i =0; i < vertex_list.size();i++) {
PVector cvertex;
for(int nxt: vertex_list.get(i)) {
cvertex = vertices.get(nxt);
s.vertex(cvertex.x, cvertex.y, cvertex.z);
}
}
s.endShape();
shape(s, 0, -100);
}else{
PShape s = createShape();
s.beginShape(TRIANGLES);
for(int i =0; i < vertex_list.size();i++) {
PVector cvertex;
for(int nxt: vertex_list.get(i)) {
cvertex = vertices.get(nxt);
s.vertex(cvertex.x, cvertex.y, cvertex.z);
}
}
s.endShape();
shape(s, 0, -100);
}
}
}