コード例 #1
0
 public void Update(Mesh inputMesh, Axis axis)
 {
     vertices = inputMesh.vertices;
     normals  = inputMesh.normals;
     tangents = inputMesh.tangents;
     colors   = inputMesh.colors;
     if (colors.Length != vertices.Length)
     {
         colors = new Color[vertices.Length];
         for (int i = 0; i < colors.Length; i++)
         {
             colors[i] = Color.white;
         }
     }
     uv     = inputMesh.uv;
     bounds = new TS_Bounds(inputMesh.bounds);
     subMeshes.Clear();
     for (int i = 0; i < inputMesh.subMeshCount; i++)
     {
         subMeshes.Add(new Submesh(inputMesh.GetTriangles(i)));
     }
     _axis = axis;
     Mirror(_mirror);
     GroupVertices(axis);
 }
コード例 #2
0
ファイル: LevelSegment.cs プロジェクト: AgostinoMatt/Runner
 void ExpandBounds(ref TS_Bounds b, Vector3 point)
 {
     if (point.x < b.min.x)
     {
         b.min.x = point.x;
     }
     if (point.y < b.min.y)
     {
         b.min.y = point.y;
     }
     if (point.z < b.min.z)
     {
         b.min.z = point.z;
     }
     if (point.x > b.max.x)
     {
         b.max.x = point.x;
     }
     if (point.y > b.max.y)
     {
         b.max.y = point.y;
     }
     if (point.z > b.max.z)
     {
         b.max.z = point.z;
     }
 }
コード例 #3
0
        public static void DrawBounds(LevelSegment segment)
        {
            if (segment.alwaysDraw)
            {
                return;
            }
            TS_Bounds bound = segment.GetBounds();
            Transform trs   = segment.transform;
            Vector3   a     = trs.TransformPoint(bound.min);
            Vector3   b     = trs.TransformPoint(new Vector3(bound.max.x, bound.min.y, bound.min.z));
            Vector3   c     = trs.TransformPoint(new Vector3(bound.max.x, bound.min.y, bound.max.z));
            Vector3   d     = trs.TransformPoint(new Vector3(bound.min.x, bound.min.y, bound.max.z));

            Vector3 e = trs.TransformPoint(new Vector3(bound.min.x, bound.max.y, bound.min.z));
            Vector3 f = trs.TransformPoint(new Vector3(bound.max.x, bound.max.y, bound.min.z));
            Vector3 g = trs.TransformPoint(new Vector3(bound.max.x, bound.max.y, bound.max.z));
            Vector3 h = trs.TransformPoint(new Vector3(bound.min.x, bound.max.y, bound.max.z));

            Handles.color = Color.green;
            Handles.DrawLine(a, b);
            Handles.DrawLine(b, c);
            Handles.DrawLine(c, d);
            Handles.DrawLine(d, a);

            Handles.DrawLine(e, f);
            Handles.DrawLine(f, g);
            Handles.DrawLine(g, h);
            Handles.DrawLine(h, e);

            Handles.DrawLine(a, e);
            Handles.DrawLine(b, f);
            Handles.DrawLine(c, g);
            Handles.DrawLine(d, h);
        }
コード例 #4
0
 public ExtrudableMesh()
 {
     vertices     = new Vector3[0];
     normals      = new Vector3[0];
     tangents     = new Vector4[0];
     colors       = new Color[0];
     uv           = new Vector2[0];
     subMeshes    = new List <Submesh>();
     bounds       = new TS_Bounds(Vector3.zero, Vector3.zero);
     vertexGroups = new List <VertexGroup>();
 }
コード例 #5
0
 private void CalculateBounds()
 {
     if (bounds == null)
     {
         bounds = new TS_Bounds(Vector3.zero, Vector3.zero);
     }
     bounds.min = (bounds.max = Vector3.zero);
     for (int i = 0; i < bendProperties.Length; i++)
     {
         CalculatePropertyBounds(ref bendProperties[i]);
     }
     for (int j = 0; j < bendProperties.Length; j++)
     {
         GetPercent(bendProperties[j]);
     }
 }
コード例 #6
0
ファイル: LevelSegment.cs プロジェクト: AgostinoMatt/Runner
 private void CalculateBounds()
 {
     if (bounds == null)
     {
         bounds = new TS_Bounds(Vector3.zero, Vector3.zero);
     }
     bounds.min = bounds.max = Vector3.zero;
     for (int i = 0; i < objectProperties.Length; i++)
     {
         GetBounds(ref objectProperties[i]);
     }
     for (int i = 0; i < customPaths.Length; i++)
     {
         customPaths[i].Transform();
         for (int j = 0; j < customPaths[i].localPoints.Length; j++)
         {
             //ExpandBounds(ref bounds, customPaths[i].localPoints[j].position);
         }
     }
 }
コード例 #7
0
        protected override void OnSceneGUI()
        {
            base.OnSceneGUI();
            ObjectBender bender = (ObjectBender)target;

            if (selected.Count > 0)
            {
                Handles.BeginGUI();
                for (int i = 0; i < selected.Count; i++)
                {
                    Vector2 screenPosition = HandleUtility.WorldToGUIPoint(bender.bendProperties[selected[i]].transform.transform.position);
                    DreamteckEditorGUI.Label(new Rect(screenPosition.x - 120 + bender.bendProperties[selected[i]].transform.transform.name.Length * 4, screenPosition.y, 120, 25), bender.bendProperties[selected[i]].transform.transform.name);
                }
                Handles.EndGUI();
            }
            for (int i = 0; i < bender.bendProperties.Length; i++)
            {
                if (bender.bendProperties[i].bendSpline && bender.bendProperties[i].splineComputer != null)
                {
                    DSSplineDrawer.DrawSplineComputer(bender.bendProperties[i].splineComputer, 0.0, 1.0, 0.2f);
                }
            }

            //Draw bounds
            if (bender.bend)
            {
                return;
            }
            TS_Bounds bound = bender.GetBounds();
            Vector3   a     = bender.transform.TransformPoint(bound.min);
            Vector3   b     = bender.transform.TransformPoint(new Vector3(bound.max.x, bound.min.y, bound.min.z));
            Vector3   c     = bender.transform.TransformPoint(new Vector3(bound.max.x, bound.min.y, bound.max.z));
            Vector3   d     = bender.transform.TransformPoint(new Vector3(bound.min.x, bound.min.y, bound.max.z));

            Vector3 e = bender.transform.TransformPoint(new Vector3(bound.min.x, bound.max.y, bound.min.z));
            Vector3 f = bender.transform.TransformPoint(new Vector3(bound.max.x, bound.max.y, bound.min.z));
            Vector3 g = bender.transform.TransformPoint(new Vector3(bound.max.x, bound.max.y, bound.max.z));
            Vector3 h = bender.transform.TransformPoint(new Vector3(bound.min.x, bound.max.y, bound.max.z));

            Handles.color = Color.gray;
            Handles.DrawLine(a, b);
            Handles.DrawLine(b, c);
            Handles.DrawLine(c, d);
            Handles.DrawLine(d, a);

            Handles.DrawLine(e, f);
            Handles.DrawLine(f, g);
            Handles.DrawLine(g, h);
            Handles.DrawLine(h, e);

            Handles.DrawLine(a, e);
            Handles.DrawLine(b, f);
            Handles.DrawLine(c, g);
            Handles.DrawLine(d, h);

            Vector3 r  = bender.transform.right;
            Vector3 fr = bender.transform.forward;

            switch (bender.axis)
            {
            case ObjectBender.Axis.Z: Handles.color = Color.blue; Handles.DrawLine(r + b, r + c);  break;

            case ObjectBender.Axis.X: Handles.color = Color.red; Handles.DrawLine(b - fr, a - fr); break;

            case ObjectBender.Axis.Y: Handles.color = Color.green; Handles.DrawLine(b - fr + r, f - fr + r); break;
            }
        }