public void StartRecording(DropBall ball, List <Camera> dropCams) { recording = true; ready = false; frame = 0; BallData ballData = new BallData(ball); List <CameraData> camerasData = new List <CameraData>(dropCams.Count); for (int i = 0; i < dropCams.Count; i++) { camerasData.Add(new CameraData(dropCams[i])); camerasData[i].cameraNumber = i; } data = new DropData(ballData, camerasData); }
private void PlaceBall() { Vector3 spawnPoint = new Vector3(), spawnVelocity = new Vector3(); for (int attempt = 0; attempt < 25; attempt++) { spawnPoint = new Vector3(Random.value * 16 - 8, Random.value * meanBallHeight * 2.0f, Random.value * 16 - 8); spawnVelocity = Random.insideUnitSphere * meanBallVelocity * 4.0f / 3.0f; // Ensure the ball has enough total energy to warrant observation; could work backwards from this limitation instead, not a priority if ((spawnVelocity.sqrMagnitude / 2 - (spawnPoint.y - ballPrefab.radius) * Physics.gravity.y) * ballPrefab.mass > minBallEnergy) { break; } } if (ball != null) { ball.gameObject.SetActive(false); Destroy(ball.gameObject); } ball = Instantiate(ballPrefab, spawnPoint, Quaternion.identity); ball.Initialize(spawnVelocity); }
public BallData(DropBall ball) { times = new List <float>(500); positions = new List <Vector3>(500); this.ball = ball; }