You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//we make the square out of two triangles so 0,1,2 is a triangle made out of the first 3 points above and 2,3,0 is a triangle made out of the last 3 points above
46
+
std::vector<ofIndexType> indices = {0, 1, 2, 2, 3, 0};
47
+
48
+
// loop through the image in the x and y axes
49
+
int skip = 3; // load a subset of the points
50
+
int pixelCount = 0;
51
+
for(int y = 0; y < img.getHeight(); y += skip) {
52
+
for(int x = 0; x < img.getWidth(); x += skip) {
53
+
ofColor cur = img.getColor(x, y);
54
+
if(cur.a > 0) {
55
+
// the alpha value encodes depth, let's remap it to a good depth range
56
+
float z = ofMap(cur.a, 0, 255, -300, 300);
57
+
cur.a = 255;
58
+
glm::vec3 pos(x, y, z);
59
+
//build our pixel/point as a small square from the offsets above
60
+
for( auto & offset : offsets){
61
+
mesh.addColor(cur);
62
+
mesh.addVertex(offset + pos);
63
+
}
64
+
//add the index so the triangles can be made out of the vertex data
65
+
for( auto & index : indices ){
66
+
mesh.addIndex(pixelCount + index);
67
+
}
68
+
pixelCount+=4;
69
+
}
70
+
}
71
+
}
72
+
#endif
28
73
29
74
ofEnableDepthTest();
30
-
#ifndef TARGET_EMSCRIPTEN
31
-
glEnable(GL_POINT_SMOOTH); // use circular points instead of square points
0 commit comments