Dodecahedron Mapping

Hi everyone
I built a dodecahedron with half transparent mirrors. I have 23 pixels per edge and i have 5 led strips in total that i connected in serial with the Pixelblaze Output Expander. The first strip starts at corner 4 > 8 > 10 > 6 then from 6 i just bring the data line back to 10 > 2 > 13 > 15. Then from 15 the data line goes back to 8 but this is done with the Output Expander. Then from 8 > 0 > 16 and so on (see the Mapping Code provided).

Mapping:

function pixelblazeMapping(pixelCount) {
  var phi = (1 + Math.sqrt(5)) / 2;
  var a = 1;
  var b = 1 / phi;

  var verts = [
    [-a, -a, -a], [-a, -a,  a], [-a,  a, -a], [-a,  a,  a],
    [ a, -a, -a], [ a, -a,  a], [ a,  a, -a], [ a,  a,  a],
    [ 0, -b, -phi], [ 0, -b,  phi], [ 0,  b, -phi], [ 0,  b,  phi],
    [-b, -phi, 0], [-b,  phi, 0], [ b, -phi, 0], [ b,  phi, 0],
    [-phi, 0, -b], [ phi, 0, -b], [-phi, 0,  b], [ phi, 0,  b]
  ];

  // Single physical string, forward LEDs and cable-back segments
  var stringSegments = [
    {from:4, to:8, led:true},
    {from:8, to:10, led:true},
    {from:10, to:6, led:true},
    {from:6, to:10, led:false}, // data cable back
    {from:10, to:2, led:true},
    {from:2, to:13, led:true},
    {from:13, to:15, led:true},
    {from:15, to:8, led:false}, // data cable back
    {from:8, to:0, led:true},
    {from:0, to:16, led:true},
    {from:16, to:2, led:true},
    {from:2, to:16, led:false}, // data cable back
    {from:16, to:18, led:true},
    {from:18, to:3, led:true},
    {from:3, to:13, led:true},
    {from:13, to:0, led:false}, // data cable back
    {from:0, to:12, led:true},
    {from:12, to:1, led:true},
    {from:1, to:18, led:true},
    {from:18, to:1, led:false}, // data cable back
    {from:1, to:9, led:true},
    {from:9, to:11, led:true},
    {from:11, to:3, led:true},
    {from:3, to:12, led:false}, // data cable back
    {from:12, to:14, led:true},
    {from:14, to:5, led:true},
    {from:5, to:9, led:true},
    {from:9, to:5, led:false},  // data cable back
    {from:5, to:19, led:true},
    {from:19, to:7, led:true},
    {from:7, to:11, led:true},
    {from:11, to:14, led:false},// data cable back
    {from:14, to:4, led:true},
    {from:4, to:17, led:true},
    {from:17, to:19, led:true},
    {from:19, to:17, led:false},// data cable back
    {from:17, to:6, led:true},
    {from:6, to:15, led:true},
    {from:15, to:7, led:true}
  ];

  var ledsPerEdge = 23;
  var points = [];

  for (var s = 0; s < stringSegments.length; s++) {
    if(!stringSegments[s].led) continue; // skip cable-back segments

    var v0 = verts[stringSegments[s].from];
    var v1 = verts[stringSegments[s].to];

    for (var i = 0; i < ledsPerEdge; i++) {
      var t = i / (ledsPerEdge - 1);
      var x = v0[0]*(1-t) + v1[0]*t;
      var y = v0[1]*(1-t) + v1[1]*t;
      var z = v0[2]*(1-t) + v1[2]*t;

      points.push([x,y,z]);
      if(points.length >= pixelCount) return points;
    }
  }

  return points;
}

Everything looks pretty good in the Mapper:

But in real life the mapping is not properly working. the 3D patterns do not seem to appear appropriate and i have no clue how to solve that problem. Any tipps and hints are much appreciated. Thanks Beat (yes it’s a real swiss name :wink:

Short video of the dodecahedron

When I’m checking out a 3d pixel map, I make a stationary pattern that lights up all pixels with values of x > 0.5 to see if that looks right, then check for values of y > 0.5, then z > 0.5 to see if the results look right in each dimension. E.g.

export function render3D (index, x, y, z) {
   r = 0
   g = 0
   b = 0
   if (x > 0.5)  {  // After checking x, check y and z
      r = 1;
   }
   rgb(r, g, b)
}
1 Like

You could consider

rgb(x > 0.5, y > 0.5, z > 0.5)

which tells you more but might be hard to interpret if the mapping is super wrong. :smiling_face:

looking at your code to calculate the LEDs, it appears that you’re going to double or triple count LEDs at some of the vertices. The edges share vertices, but you count the pixel at the starting vertex for every edge you compute. How are your pixel strips laid out at the corners?