void WorldFold::resetWorldFold() { for (int i = 0; i < MAX_WORLD_FOLDS; i++) { worldFoldMatrix[i].CreateIdentityMatrix(); worldFoldResultMatrix[i].CreateIdentityMatrix(); worldFoldExists[i] = false; worldFoldKey[i] = 1; } worldFoldCenter = VC3(0,0,0); wfCameraMatrix.CreateIdentityMatrix(); wfCameraPosition = VC3(0,0,0); }
void WorldFold::setCameraPosition(const VC3 &position) { if (fabs(wfCameraPosition.x - position.x) > 0.001f) { // TODO: rotate camera toward half angle when approacing a fold... // once past the fold, on the other side, flip rotation to negative half angle to match new fold wfCameraMatrix.CreateIdentityMatrix(); // TODO: update only if camera matrix has changed. worldFoldMatrixUpdate(CENTER_WORLD_FOLD_INDEX); wfCameraPosition = position; } }
void worldFoldMatrixUpdate(int fromIndex) { assert(fromIndex >= 0); assert(fromIndex < MAX_WORLD_FOLDS); if (fromIndex == CENTER_WORLD_FOLD_INDEX) { int i = CENTER_WORLD_FOLD_INDEX; worldFoldResultMatrix[i] = worldFoldMatrix[i]; worldFoldKey[i] = (((worldFoldKey[i] + 1) & 0x000fffff) | (i << 20)); } if (fromIndex <= CENTER_WORLD_FOLD_INDEX) { MAT result; result.CreateIdentityMatrix(); for (int i = fromIndex; i >= 0; i--) { worldFoldResultMatrix[i] = result*worldFoldMatrix[i]; result = worldFoldResultMatrix[i]; worldFoldKey[i] = (((worldFoldKey[i] + 1) & 0x000fffff) | (i << 20)); } } if (fromIndex >= CENTER_WORLD_FOLD_INDEX) { MAT result; result.CreateIdentityMatrix(); for (int i = fromIndex; i < MAX_WORLD_FOLDS; i++) { worldFoldResultMatrix[i] = result*worldFoldMatrix[i]; result = worldFoldResultMatrix[i]; worldFoldKey[i] = (((worldFoldKey[i] + 1) & 0x000fffff) | (i << 20)); } } }