+
+static Object *gen_pipe_corner(float x, float y, float z, float rad)
+{
+ Mesh tmp;
+ Object *obj = new Object;
+ obj->mesh = new Mesh;
+
+ float xoffs = CON_RAD(rad);
+ float pipelen = 0.5 - CON_WIDTH - (rad * 2.0 - xoffs + CON_WIDTH);
+
+ float sign = z >= 0.0f ? 1.0f : -1.0f;
+
+ gen_torus(&tmp, rad * 2.0, rad, 4, 6, 0.25);
+ xform.rotation_y(deg_to_rad(sign >= 0.0f ? -90 : 180));
+ xform.translate(xoffs - rad * 2.0, 0, sign * (0.5 + rad * 2.0 - xoffs));
+ tmp.apply_xform(xform);
+ obj->mesh->append(tmp);
+
+ for(int i=0; i<2; i++) {
+ Mesh pipe;
+ gen_cylinder(&tmp, rad, pipelen, 6, 1);
+ xform.rotation_x(deg_to_rad(90));
+ xform.rotate_z(deg_to_rad(90));
+ xform.translate(xoffs, 0, sign * (1 - pipelen / 2 - CON_WIDTH));
+ tmp.apply_xform(xform);
+ pipe.append(tmp);
+
+ gen_conn(&tmp, rad);
+ xform.rotation_x(deg_to_rad(90));
+ xform.translate(xoffs, 0, sign * (1 - CON_WIDTH / 2));
+ tmp.apply_xform(xform);
+ pipe.append(tmp);
+
+ gen_conn(&tmp, rad);
+ xform.rotation_x(deg_to_rad(90));
+ xform.translate(xoffs, 0, sign * (0.5 + rad * 2.0 - xoffs + CON_WIDTH / 2.0));
+ tmp.apply_xform(xform);
+ pipe.append(tmp);
+
+ if(i > 0) {
+ xform = Mat4::identity;
+ xform.translate(-xoffs, 0, sign * -0.5);
+ xform.rotate_y(deg_to_rad(sign * -90));
+ xform.translate(xoffs, 0, sign * 0.5);
+ xform.translate(-xoffs, 0, sign * -xoffs);
+ pipe.apply_xform(xform);
+ }
+
+ obj->mesh->append(pipe);
+ }
+
+ obj->xform.translation(x, y, 0);
+ return obj;
+}
+
+static unsigned char *gen_texture(int x, int y)
+{
+ unsigned char *pixels = new unsigned char[x * y * 3];
+ unsigned char *ptr = pixels;
+
+ for(int i=0; i<y; i++) {
+ for(int j=0; j<x; j++) {
+ *ptr++ = i ^ j;
+ *ptr++ = (i ^ j) << 1;
+ *ptr++ = (i ^ j) << 2;
+ }
+ }
+ return pixels;
+}