public Ball GetNearestBall(Vector3 position) { OpenPoolManager manager = OpenPoolManager.instance; Ball nearest_ball = balls[0]; float nearest_distance = float.MaxValue; for(int i=1; i<balls.Length; ++i) { Ball ball = balls[i]; if(ball.isTracked) { Vector3 pos = manager.ScreenToWorld(ball.position); float d = Vector3.Distance(position, pos); if(nearest_distance > d) { nearest_distance = d; nearest_ball = ball; } } } if(nearest_ball.isTracked) { return nearest_ball; } else { return null; } }
IPEndPoint sendEndPort = new IPEndPoint(IPAddress.Parse("127.0.0.1"), Config.OSC_PORT); // "localhost" does not recognize OSX native #endregion #region life cycle void Awake() { _instance = this; // assign tracker trackers = new Dictionary <string, AbstractTracker>(); trackers.Add(Config.OSC_ADDRESS_BALL, new BallTracker(Config.BALL_MAX_COUNT)); trackers.Add(Config.OSC_ADDRESS_POCKET, new PocketTracker()); trackers.Add(Config.OSC_ADDRESS_COLLISION, new CollisionTracker()); trackers.Add(Config.OSC_ADDRESS_CUE, new CueTracker()); trackers.Add(Config.OSC_ADDRESS_CALIBRATION, new CaliblationTracker()); oscManager = OSCManager.instance; oscManager.LocalPort = Config.OSC_PORT; }
void Awake() { _instance = this; // assign tracker trackers = new Dictionary<string, AbstractTracker>(); trackers.Add(Config.OSC_ADDRESS_BALL, new BallTracker(Config.BALL_MAX_COUNT)); trackers.Add(Config.OSC_ADDRESS_POCKET, new PocketTracker()); trackers.Add(Config.OSC_ADDRESS_COLLISION, new CollisionTracker()); trackers.Add(Config.OSC_ADDRESS_CUE, new CueTracker()); trackers.Add(Config.OSC_ADDRESS_CALIBRATION, new CaliblationTracker()); oscManager = OSCManager.instance; oscManager.LocalPort = Config.OSC_PORT; }
public override void DrawDebug () { GL.Begin (GL.LINES); GL.Color (Color.green); OpenPoolManager manager = OpenPoolManager.instance; foreach(Ball ball in balls) { if(ball.isTracked) { Vector3 from = manager.ScreenToWorld(ball.position); Vector3 direction = new Vector3(ball.velocity.x, 0, -ball.velocity.y) * 50f; // cube GLUtils.DrawCube(from, Config.BALL_RADIUS); // velocity GL.Vertex(from); GL.Vertex(from+direction); } } GL.End (); }
void Start() { manager = OpenPoolManager.instance; Initialize(); }
void Start() { manager = OpenPoolManager.instance; }
void Start() { manager = OpenPoolManager.instance; }