1 using System.Collections;
2 using System.Collections.Generic;
16 public float log_interval = 15;
22 private float last_log;
30 private void Reset () {
31 minP =
new float[]{
float.MaxValue,
float.MaxValue,
float.MaxValue};
32 maxP =
new float[]{
float.MinValue,
float.MinValue,
float.MinValue};
38 Vector3 p = transform.position;
39 minP[0] = Mathf.Min( minP[0], p.x);
40 minP[1] = Mathf.Min( minP[1], p.y);
41 minP[2] = Mathf.Min( minP[2], p.z);
42 maxP[0] = Mathf.Max( maxP[0], p.x);
43 maxP[1] = Mathf.Max( maxP[1], p.y);
44 maxP[2] = Mathf.Max( maxP[2], p.z);
46 if ((Time.time - last_log) > log_interval) {
48 Debug.Log(
string.Format(
" x=({0:000.0},{1:000.0}) y=({2:000.0},{3:000.0}) z=({4:000.0},{5:000.0})",
54 float midX = (maxP[0] + minP[0])/2f;
55 float midY = (maxP[1] + minP[1])/2f;
56 float midZ = (maxP[2] + minP[2])/2f;
57 float maxExtent = Mathf.Max((maxP[0] - minP[0]), (maxP[1] - minP[1]));
58 maxExtent = Mathf.Max(maxExtent, (maxP[2] - minP[2]));
60 float scale = desired_size/maxExtent;
61 Debug.Log(
string.Format(
"offset/scale = Vector3({0:00.0}f,{1:00.0}f,{2:00.0}f), {3:0.00}f",
62 -midX, -midY, -midZ, scale
Bound stats. Simple method to track min/max in each co-ordinate to determine the extent of an attract...
float desired_size
Size of the bounding box into which system should fit.