// Transform Vector3 exchangeTransformVector(Vector3 pVelocity, RacketPosition pRacketPos) { Vector3 v = pVelocity; if (pRacketPos == RacketPosition.BOTTOM) // BOTTOM → そのまま { return(v); } else if (pRacketPos == RacketPosition.TOP) // TOP { v.x = -v.x; v.z += z_diff_vertical; } else if (pRacketPos == RacketPosition.LEFT) // LEFT // XとZを交代 { float tmp = -(v.x - x_diff_horizontal) * STAGE_HEIGHT / STAGE_WIDTH; v.x = -x_diff_horizontal; v.z = v.z - z_diff_horizontal + tmp + STAGE_HEIGHT / 2; } else // RIGHT { float tmp = (v.x - x_diff_horizontal) * STAGE_HEIGHT / STAGE_WIDTH; v.x = x_diff_horizontal; v.z = z_diff_horizontal + tmp + STAGE_HEIGHT / 2; } return(v); }
// Velocity Vector3 exchangeVelocityVector(Vector3 pVelocity, RacketPosition pRacketPos) { Vector3 v = pVelocity; if (pRacketPos == RacketPosition.BOTTOM) { return(v); } else if (pRacketPos == RacketPosition.TOP) { v.x = -v.x; } else if (pRacketPos == RacketPosition.LEFT) { float tmp = -v.x * STAGE_HEIGHT / STAGE_WIDTH; v.x = v.z; v.z = tmp; } else // RIGHT { float tmp = v.x * STAGE_HEIGHT / STAGE_WIDTH; v.x = v.z; v.z = tmp; } return(v); }
Vector3 exchangeVector(Vector3 pVelocity, RacketPosition pRacketPos, bool pIsVelocity = true) { Vector3 v = pVelocity; if (pIsVelocity) { v = exchangeVelocityVector(v, pRacketPos); } else { v = exchangeTransformVector(v, pRacketPos); } return(v); }