/*** * 1 2 * 3 4 ***/ List <Vector3> InterpolateSpine(Square square, Square top, Square left, Square bot, Square right) { Node p0, p1, p2, p3; p0 = square.centreBottom; p1 = square.centreBottom; p2 = square.centreBottom; p3 = square.centreBottom; //Config bool neighborStraight0 = false; bool neighborStraight1 = false; switch (square.configuration) { case 0: break; //1 point case 0b0001: switch (left.configuration) { case 0b0011: p0 = left.centreLeft; p1 = left.centreRight; break; case 0b0010: p0 = left.centreBottom; p1 = left.centreRight; break; case 0b1011: p0 = left.centreTop; p1 = left.centreRight; neighborStraight0 = true; break; } switch (bot.configuration) { case 0b1000: p2 = bot.centreTop; p3 = bot.centreLeft; break; case 0b1001: p2 = bot.centreTop; p3 = bot.centreBottom; break; case 0b1011: p2 = bot.centreTop; p3 = bot.centreRight; neighborStraight1 = true; break; } break; case 0b0010: switch (right.configuration) { case 0b0011: p0 = right.centreRight; p1 = right.centreLeft; break; case 0b0001: p0 = right.centreBottom; p1 = right.centreLeft; break; case 0b0111: p0 = right.centreTop; p1 = right.centreLeft; neighborStraight0 = true; break; } switch (bot.configuration) { case 0b0110: p2 = bot.centreTop; p3 = bot.centreBottom; break; case 0b0100: p2 = bot.centreTop; p3 = bot.centreRight; break; case 0b0111: p2 = bot.centreTop; p3 = bot.centreLeft; neighborStraight1 = true; break; } break; case 0b0100: switch (top.configuration) { case 0b0110: p0 = top.centreTop; p1 = top.centreBottom; break; case 0b0010: p0 = top.centreRight; p1 = top.centreBottom; break; case 0b1110: p0 = top.centreLeft; p1 = top.centreBottom; neighborStraight0 = true; break; } switch (right.configuration) { case 0b1100: p2 = right.centreLeft; p3 = right.centreRight; break; case 0b1000: p2 = right.centreLeft; p3 = right.centreTop; break; case 0b1110: p2 = right.centreLeft; p3 = right.centreBottom; neighborStraight1 = true; break; } break; case 0b1000: switch (top.configuration) { case 0b1001: p0 = top.centreTop; p1 = top.centreBottom; break; case 0b0001: p0 = top.centreLeft; p1 = top.centreBottom; break; case 0b1101: p0 = top.centreRight; p1 = top.centreBottom; neighborStraight0 = true; break; } switch (left.configuration) { case 0b1100: p2 = left.centreRight; p3 = left.centreLeft; break; case 0b0100: p2 = left.centreRight; p3 = left.centreTop; break; case 0b1101: p2 = left.centreRight; p3 = left.centreBottom; neighborStraight1 = true; break; } break; //3 points case 0b0111: switch (top.configuration) { case 0b1110: p0 = top.centreLeft; p1 = top.centreBottom; break; case 0b0110: p0 = top.centreTop; p1 = top.centreBottom; break; case 0b0010: p0 = top.centreRight; p1 = top.centreBottom; neighborStraight0 = true; break; } switch (left.configuration) { case 0b1011: p2 = left.centreRight; p3 = left.centreTop; break; case 0b0011: p2 = left.centreRight; p3 = left.centreLeft; break; case 0b0010: p2 = left.centreRight; p3 = left.centreBottom; neighborStraight1 = true; break; } break; case 0b1011: switch (top.configuration) { case 0b1001: p0 = top.centreTop; p1 = top.centreBottom; break; case 0b1101: p0 = top.centreRight; p1 = top.centreBottom; break; case 0b0001: p0 = top.centreLeft; p1 = top.centreBottom; neighborStraight0 = true; break; } switch (right.configuration) { case 0b0011: p2 = right.centreLeft; p3 = right.centreRight; break; case 0b0111: p2 = right.centreLeft; p3 = right.centreTop; break; case 0b0001: p2 = right.centreLeft; p3 = right.centreBottom; neighborStraight1 = true; break; } break; case 0b1101: switch (right.configuration) { case 0b1100: p0 = right.centreRight; p1 = right.centreLeft; break; case 0b1110: p0 = right.centreBottom; p1 = right.centreLeft; break; case 0b1000: p0 = right.centreTop; p1 = right.centreLeft; neighborStraight0 = true; break; } switch (bot.configuration) { case 0b1001: p2 = bot.centreTop; p3 = bot.centreBottom; break; case 0b1011: p2 = bot.centreTop; p3 = bot.centreRight; break; case 0b1000: p2 = bot.centreTop; p3 = bot.centreLeft; neighborStraight1 = true; break; } break; case 0b1110: switch (left.configuration) { case 0b1100: p0 = left.centreLeft; p1 = left.centreRight; break; case 0b1101: p0 = left.centreBottom; p1 = left.centreRight; break; case 0b0100: p0 = left.centreTop; p1 = left.centreRight; neighborStraight0 = true; break; } switch (bot.configuration) { case 0b0111: p2 = bot.centreTop; p3 = bot.centreLeft; break; case 0b0110: p2 = bot.centreTop; p3 = bot.centreBottom; break; case 0b0100: p2 = bot.centreTop; p3 = bot.centreRight; neighborStraight1 = true; break; } break; } if (neighborStraight0 && neighborStraight1) { return(null); } var retval = CatmullRomSpline.getPoints(p0.position, p1.position, p2.position, p3.position); return(retval); }