private void OnDrawGizmos()
        {
            Gizmos.matrix = transform.localToWorldMatrix;
            Gizmos.color  = Color.white;
            Gizmos.DrawSphere(m_Point, .1f);
            float distances = UGeometry.PointRayProjection(m_Point, m_Ray);

            Handles_Extend.DrawLine(m_Ray.ToLine(distances));
            Gizmos.color = Color.blue;
            Gizmos.DrawSphere(m_Ray.GetPoint(distances), .1f);

            Gizmos.color = Color.white;
            Vector2 lineRayDistances = UGeometry.LineRayProjection(m_Line1, m_Ray1);

            Gizmos_Extend.DrawLine(m_Line1);
            Gizmos_Extend.DrawLine(m_Ray1.ToLine(lineRayDistances.y));
            Gizmos.color = Color.blue;
            Gizmos.DrawSphere(m_Line1.GetPoint(lineRayDistances.x), .1f);
            Gizmos.color = Color.red;
            Gizmos.DrawSphere(m_Ray1.GetPoint(lineRayDistances.y), .1f);

            Gizmos.color = Color.white;
            Vector2 rayrayDistances = UGeometry.RayRayProjection(m_Ray20, m_Ray21);

            Gizmos_Extend.DrawLine(m_Ray20.ToLine(rayrayDistances.x));
            Gizmos_Extend.DrawLine(m_Ray21.ToLine(rayrayDistances.y));
            Gizmos.color = Color.blue;
            Gizmos.DrawSphere(m_Ray20.GetPoint(rayrayDistances.x), .1f);
            Gizmos.color = Color.red;
            Gizmos.DrawSphere(m_Ray21.GetPoint(rayrayDistances.y), .1f);
        }
示例#2
0
        void OnInteractGUI(SceneView _sceneView, GameObject _meshObject)
        {
            Handles.color = GetPaintColor(m_PaintColor);
            if (m_PaintPosition != Vector3.zero)
            {
                Handles_Extend.DrawWireSphere(m_PaintPosition, Quaternion.identity, m_PaintSize);
            }

            if (Event.current.type == EventType.MouseMove)
            {
                Vector3 cameraLocal = _meshObject.transform.worldToLocalMatrix.MultiplyPoint(_sceneView.camera.transform.position);
                if (RayDirectedTriangleIntersect(m_Polygons, m_ModifingMesh.vertices, ObjLocalSpaceRay(_sceneView, _meshObject), out Vector3 hitPosition, out GDirectedTriangle hitTriangle) != -1)
                {
                    m_PaintPosition = hitPosition;
                    m_PaintAffectedIndices.Clear();
                    float sqrRaidus = m_PaintSize * m_PaintSize;
                    m_Verticies.FindAllIndexes(m_PaintAffectedIndices, (index, p) => {
                        bool normalPassed = false;
                        switch (m_PaintNormal)
                        {
                        case enum_PaintNormal.ViewNormal: normalPassed = Vector3.Dot(m_Normals[index], p - cameraLocal) < 0; break;

                        case enum_PaintNormal.TriangleNormal: normalPassed = Vector3.Dot(m_Normals[index], hitTriangle.normal) > 0; break;

                        case enum_PaintNormal.Every: normalPassed = true; break;
                        }
                        return(normalPassed && (hitPosition - p).sqrMagnitude < sqrRaidus);
                    });
                }
            }

            if (!m_AvailableDatas)
            {
                return;
            }
            if (Event.current.type == EventType.MouseDown)
            {
                int button = Event.current.button;
                if (button != 0 && button != 2)
                {
                    return;
                }
                switch (m_PaintMode)
                {
                default: throw new Exception("Invalid Type:" + m_PaintMode);

                case enum_PaintMode.Const:
                    m_PaintAffectedIndices.Traversal(index => m_VertexDatas[index] = ApplyModify(m_VertexDatas[index], m_PaintValue, m_PaintMode, m_PaintColor));
                    break;

                case enum_PaintMode.Modify:
                    float value = button == 0 ? m_PaintValue : -m_PaintValue;
                    m_PaintAffectedIndices.Traversal(index => m_VertexDatas[index] = ApplyModify(m_VertexDatas[index], value, m_PaintMode, m_PaintColor));
                    break;
                }
                OnDataChange();
            }
        }
示例#3
0
 public virtual void OnEditorSceneGUIDebug(SceneView _sceneView, GameObject _meshObject)
 {
     Handles.color = Color.red;
     Handles_Extend.DrawArrow(mouseRay.origin, mouseRay.direction, .2f, .01f);
     Handles.DrawLine(mouseRay.origin, mouseRay.direction * 10f + mouseRay.origin);
     Handles.matrix = _meshObject.transform.localToWorldMatrix;
     Handles.SphereHandleCap(0, collisionPoint, Quaternion.identity, .05f, EventType.Repaint);
     Handles.DrawLines(collisionTriangle.triangle.GetDrawLinesVerticies());
 }
示例#4
0
        void OnDrawSceneHandles(SceneView _sceneView)
        {
            Handles.color = Color.white.SetAlpha(.5f);
            Handles.DrawWireCube(m_ModifingMesh.bounds.center, m_ModifingMesh.bounds.size * 1.2f);

            if (!m_SelectingPolygon)
            {
                return;
            }

            GMeshPolygon _mainPolygon = m_Polygons[m_SelectedPolygon];

            foreach (var subPolygon in m_SubPolygons)
            {
                GDirectedTriangle directedTriangle = m_Polygons[subPolygon].GetDirectedTriangle(m_Verticies);
                if (Vector3.Dot(directedTriangle.normal, _sceneView.camera.transform.forward) > 0)
                {
                    continue;
                }
                Handles.color = Color.yellow.SetAlpha(.1f);
                Handles.DrawAAConvexPolygon(directedTriangle.triangle.verticies);
                Handles.color = Color.yellow;
                Handles.DrawLines(directedTriangle.triangle.GetDrawLinesVerticies());
            }
            GTriangle mainTriangle = _mainPolygon.GetTriangle(m_Verticies);

            Handles.color = Color.green.SetAlpha(.3f);
            Handles.DrawAAConvexPolygon(mainTriangle.verticies);
            Handles.color = Color.green;
            Handles.DrawLines(mainTriangle.GetDrawLinesVerticies());

            if (!m_EditingVectors)
            {
                return;
            }
            Handles.color = Color.green;
            foreach (var indice in _mainPolygon.indices)
            {
                Handles_Extend.DrawArrow(m_Verticies[indice], m_VertexDatas[indice], .1f * m_GUISize, .01f * m_GUISize);
                if (m_SelectedVertexIndex == indice)
                {
                    continue;
                }
                Handles_Extend.DrawWireSphere(m_Verticies[indice], m_VertexDatas[indice], C_VertexSphereRadius * m_GUISize);
            }
            Handles.color = Color.yellow;
            foreach (var subPolygon in m_SubPolygons)
            {
                foreach (var indice in m_Polygons[subPolygon].indices)
                {
                    Handles.DrawLine(m_Verticies[indice], m_Verticies[indice] + m_VertexDatas[indice] * .03f * m_GUISize);
                }
            }
        }
示例#5
0
 public static void DrawWireCapsule(Vector3 _pos, Quaternion _rot, Vector3 _scale, float _radius, float _height)
 {
     Handles.color  = Gizmos.color;
     Handles.matrix = Gizmos.matrix;
     Handles_Extend.DrawWireCapsule(_pos, _rot, _scale, _radius, _height);
 }
示例#6
0
 public static void DrawLine(GLine _line)
 {
     Handles.color  = Gizmos.color;
     Handles.matrix = Gizmos.matrix;
     Handles_Extend.DrawLine(_line);
 }
示例#7
0
 public static void DrawCone(GHeightCone _cone)
 {
     Handles.color  = Gizmos.color;
     Handles.matrix = Gizmos.matrix;
     Handles_Extend.DrawCone(_cone);
 }
示例#8
0
 public static void DrawTrapezium(Vector3 _pos, Quaternion _rot, Vector4 trapeziumInfo)
 {
     Handles.color  = Gizmos.color;
     Handles.matrix = Gizmos.matrix;
     Handles_Extend.DrawTrapezium(_pos, _rot, trapeziumInfo);
 }
示例#9
0
 public static void DrawCylinder(Vector3 _pos, Quaternion _rot, float _radius, float _height)
 {
     Handles.color  = Gizmos.color;
     Handles.matrix = Gizmos.matrix;
     Handles_Extend.DrawCylinder(_pos, _rot, _radius, _height);
 }
示例#10
0
 public static void DrawArrow(Vector3 _pos, Quaternion _rot, float _length, float _radius)
 {
     Handles.color  = Gizmos.color;
     Handles.matrix = Gizmos.matrix;
     Handles_Extend.DrawArrow(_pos, _rot, _length, _radius);
 }
示例#11
0
 public static void DrawWireCube(Vector3 _pos, Quaternion _rot, Vector3 _cubeSize)
 {
     Handles.color  = Gizmos.color;
     Handles.matrix = Gizmos.matrix;
     Handles_Extend.DrawWireCube(_pos, _rot, _cubeSize);
 }