private void InitPregeneratedPoses() { // first, set the unity random seed, so the generated poses will all be the same UnityEngine.Random.InitState(12345); PregeneratedInitialSessionPose = GenerateSessionPose(WAITING_FOR_USER); PregeneratedSessionPoses.Clear(); for (int i = 0; i < ParameterNumAlignmentsInSession; i++) { PregeneratedSessionPoses.Add(GenerateSessionPose(i)); } // now, set a new seed based on the timestamp, and then shuffle the pregenerated poses. // this way, we use the same poses, but they are randomized in order. UnityEngine.Random.InitState((int)(Time.time * 1000)); PregeneratedSessionPoses.Shuffle(); string s = "generated poses:\n"; foreach (var pose in PregeneratedSessionPoses) { s += "\t" + pose.pos + "\t" + pose.rot + "\n"; } Debug.Log(s); }
private void GetPregeneratedPose(int index, out Vector3 positionInViveSpace, out Quaternion rotationInViveSpace) { if (index == WAITING_FOR_USER) { UnityPose initialPose = PregeneratedInitialSessionPose; positionInViveSpace = initialPose.pos; rotationInViveSpace = initialPose.rot; } else { UnityPose pose = PregeneratedSessionPoses[index]; positionInViveSpace = pose.pos; rotationInViveSpace = pose.rot; } }