Example #1
0
uint8_t MarchingCubes::IndexMirrorZ(const uint8_t index) {
  uint8_t new_index = 0;
  for (int i = 0; i < 8; i++) {
    const uint8_t single_index = index & (1u << i);
    if (single_index) {
      Vector3 v = corners_as_vectors_[i];
      v.Translate(-0.5f, -0.5f, 0.5f)->MirrorZ()->Translate(0.5f, 0.5f, -0.5f);
      new_index = new_index | (1u << ConvertVectorToCorner(v));
    }
  }

  return new_index;
}
Example #2
0
uint8_t MarchingCubes::IndexRotateZ(const uint8_t index, const int degrees) {
  if (degrees == 0 || degrees % 360 == 0) {
    return index;
  }

  if (degrees % 90) {
    return -1;
  }

  uint8_t new_index = 0;
  for (int i = 0; i < 8; i++) {
    const uint8_t single_index = index & (1u << i);
    if (single_index) {
      Vector3 v = corners_as_vectors_[i];
      v.Translate(-0.5f, -0.5f, 0.5f)->RotateZ(degrees)->Translate(0.5f, 0.5f,
                                                                   -0.5f);
      new_index = new_index | (1u << ConvertVectorToCorner(v));
    }
  }

  return new_index;
}