Beispiel #1
0
        private void OnSceneGUI()
        {
            通孔 t = target as 通孔;

            Handles.color = Color.yellow;
            HandleExtention.DrawColumn(t.transform, Vector3.zero, t.直径 * 0.001f / 2, t.厚度 * 0.001f);
        }
Beispiel #2
0
        private void OnSceneGUI()
        {
            长孔 t = target as 长孔;

            Handles.color = Color.yellow;
            HandleExtention.DrawDualHole(t.transform, Vector3.zero, t.长度 * 0.001f, t.直径 * 0.001f / 2, t.厚度 * 0.001f);
        }
 public static void DrawBeam(Transform transform, Vector3 p1, Vector3 p2, float width, float height)
 {
     HandleExtention.DrawLineWithOffset(transform, p1, p2, Vector3.forward * width / 2 + Vector3.up * height / 2);
     HandleExtention.DrawLineWithOffset(transform, p1, p2, Vector3.forward * width / 2 - Vector3.up * height / 2);
     HandleExtention.DrawLineWithOffset(transform, p1, p2, -Vector3.forward * width / 2 + Vector3.up * height / 2);
     HandleExtention.DrawLineWithOffset(transform, p1, p2, -Vector3.forward * width / 2 - Vector3.up * height / 2);
 }
Beispiel #4
0
        private void OnSceneGUI()
        {
            螺丝 t = target as 螺丝;

            Handles.color = Color.yellow;
            HandleExtention.DrawColumn(t.transform, Vector3.zero + Vector3.forward * t.长度 * 0.001f / 2, t.直径 * 0.001f / 2, t.长度 * 0.001f);
            HandleExtention.DrawEnd(t.transform, Vector3.zero + Vector3.forward * t.长度 * 0.001f, t.直径 * 0.001f / 2, 0);
        }
        private void OnSceneGUI()
        {
            双层长孔 t = target as 双层长孔;

            Handles.color = Color.yellow;

            HandleExtention.DrawDualHole(t.transform, Vector3.zero + Vector3.forward * t.厚度1 * 0.001f / 2, t.长度 * 0.001f, t.直径1 * 0.001f / 2, t.厚度1 * 0.001f);
            HandleExtention.DrawDualHole(t.transform, Vector3.zero - Vector3.forward * t.厚度2 * 0.001f / 2, t.长度 * 0.001f, t.直径2 * 0.001f / 2, t.厚度2 * 0.001f);
        }
        public static void DrawDualHole(Transform transform, Vector3 center, float distanceBetweenCenters, float radius, float thickness)
        {
            var center1 = center + Vector3.left * distanceBetweenCenters / 2;
            var center2 = center - Vector3.left * distanceBetweenCenters / 2;

            HandleExtention.DrawColumn(transform, center1, radius, thickness);
            HandleExtention.DrawColumn(transform, center2, radius, thickness);

            HandleExtention.DrawBeam(transform, center1, center2, thickness, radius * 2);
        }
        public static void DrawEnd(Transform transform, Vector3 center, float radius, float endInSet = 0.6f)
        {
            int segments = 10;

            for (int i = 0; i < segments; i++)
            {
                var angle  = Mathf.PI * 2 * i / segments;
                var radial = new Vector3(radius * Mathf.Sin(angle), radius * Mathf.Cos(angle), 0);
                HandleExtention.DrawLine(transform, center + Vector3.forward * radius * endInSet, center + radial);
            }
        }
        public static void DrawColumn(Transform transform, Vector3 center, float radius, float thickness)
        {
            int segments = 10;
            var offset   = Vector3.forward * thickness / 2;

            HandleExtention.DrawWireDisc(transform, center - offset, Vector3.forward, radius);
            HandleExtention.DrawWireDisc(transform, center + offset, Vector3.forward, radius);
            for (int i = 0; i < segments; i++)
            {
                var angle  = Mathf.PI * 2 * i / segments;
                var radial = new Vector3(radius * Mathf.Sin(angle), radius * Mathf.Cos(angle), 0);
                HandleExtention.DrawLine(transform, center + radial + offset, center + radial - offset);
            }
        }
 private static void DrawLineWithOffset(Transform transform, Vector3 p1, Vector3 p2, Vector3 offset)
 {
     HandleExtention.DrawLine(transform, p1 + offset, p2 + offset);
 }