コード例 #1
0
        protected override void InitializeService()
        {
            CreateFramebuffers();
            renderer.Resize += new EventHandler <EventArgs>(window_Resize);

            tMaterial = MaterialManager.MakeMaterial("tMaterial", "TFloat");

            //materialManager.MakeSimpleMaterial("CurveToolControlHandle", 1.0f, 1.0f,1.0f);
            HandleMaterial = MaterialManager.MakeMaterial("CurveToolControlHandle", "Schlick");
            float diffuse = 0.5f;
            float specular = 1.0f;
            float roughness = 0.02f;
            float r = 1.0f; float g = 1.0f; float b = 1.0f;

            HandleMaterial.Floats("surface_diffuse_reflectance_color").Set(diffuse * r, diffuse * g, diffuse * b);
            HandleMaterial.Floats("surface_specular_reflectance_color").Set(specular * r, specular * r, specular * r);
            HandleMaterial.Floats("surface_roughness").Set(roughness);
            HandleMaterial.Sync();
        }
コード例 #2
0
    public static void DrawWireMesh(Mesh mesh, Transform transform, Color color)
    {
        Shader.SetGlobalColor("_HandleColor", color);
        Shader.SetGlobalInt("_EnableShading", 0);

        HandleMaterial.SetPass(2);

        GL.wireframe = true;
        Graphics.DrawMeshNow(mesh, transform.localToWorldMatrix);
        GL.wireframe = false;

        HandleMaterial.SetPass(3);

        GL.wireframe = true;
        Graphics.DrawMeshNow(mesh, transform.localToWorldMatrix);
        GL.wireframe = false;

        //handleMaterial.SetPass(1);

        //GL.wireframe = true;
        //Graphics.DrawMeshNow(mesh, transform.localToWorldMatrix);
        //GL.wireframe = false;
    }
コード例 #3
0
        /// <summary> Draws the connection curves of a virtual connection </summary>
        /// <param name="vc">Target virtual connection being drawn</param>
        private void DrawConnectionCurve(VirtualConnection vc)
        {
            //connect
            m_connectionAlpha = 1f;
            if (m_mode == GraphMode.Connect)
            {
                m_connectionAlpha = 0.5f;
            }

            m_normalColor = DGUI.Utility.IsProSkin
                                ? DGUI.Colors.GetDColor(ColorName.UnityDark).Light
                                : DGUI.Colors.GetDColor(ColorName.UnityLight).Dark;
            m_outputColor = DGUI.Colors.GetDColor(DGUI.Colors.NodyOutputColorName).Normal;
            m_inputColor  = DGUI.Colors.GetDColor(DGUI.Colors.NodyInputColorName).Normal;

            m_normalColor.a = m_connectionAlpha;
            m_outputColor.a = m_connectionAlpha;
            m_inputColor.a  = m_connectionAlpha;

            m_connectionColor = m_normalColor;

            m_animateInput  = false;
            m_animateOutput = false;

            //A node is selected and the Alt Key is not pressed -> show the connection color depending on socket type of this node (if it is an output or an input one)
            if (WindowSettings.SelectedNodes.Count == 1 && !m_altKeyPressed)
            {
                //                Node selectedNode = NodesDatabase[m_selectedNodes.Ids[0]];
                Node selectedNode = WindowSettings.SelectedNodes[0];
                if (selectedNode == null)
                {
                    return;
                }
                if (selectedNode.ContainsConnection(vc.ConnectionId))
                {
                    if (selectedNode == vc.OutputNode)
                    {
                        //color for output connection
                        m_connectionColor = m_outputColor;
                        m_animateOutput   = true;
                    }

                    if (selectedNode == vc.InputNode)
                    {
                        //color for input connection
                        m_connectionColor = m_inputColor;
                        m_animateInput    = true;
                    }
                }
            }

            float currentCurveWidth = NodySettings.Instance.CurveWidth;

            if (EditorApplication.isPlaying)
            {
                if (vc.InputNode.GetConnection(vc.ConnectionId).Ping)
                {
                    vc.Ping.value  = true;
                    vc.Ping.target = false;
                    vc.InputNode.GetConnection(vc.ConnectionId).Ping = false;
                }
                else if (vc.OutputNode.GetConnection(vc.ConnectionId).Ping)
                {
                    vc.Ping.value  = true;
                    vc.Ping.target = false;
                    vc.OutputNode.GetConnection(vc.ConnectionId).Ping = false;
                }

                if (vc.Ping.faded > 0)
                {
                    m_connectionColor = Color.LerpUnclamped(m_connectionColor, DGUI.Colors.GetDColor(DGUI.Colors.ActionColorName).Normal, vc.Ping.faded);
                    currentCurveWidth = NodySettings.Instance.CurveWidth * (1 + 2 * vc.Ping.faded);
                }
            }
            else if (vc.Ping.faded > 0)
            {
                vc.Ping.value  = false;
                vc.Ping.target = false;
            }


            m_dotColor = m_connectionColor;


            if (m_altKeyPressed) //delete mode is enabled -> check if we should color the connection to RED
            {
                //check this connection's points by testing if the mouse if hovering over one of this connection's virtual points
                bool colorTheConnectionRed = vc.InputVirtualPoint == m_currentHoveredVirtualPoint || vc.OutputVirtualPoint == m_currentHoveredVirtualPoint;
                if (colorTheConnectionRed)
                {
                    m_connectionColor  = Color.red; //set the connection color to RED -> as the developer might want to remove this connection
                    currentCurveWidth += 1;         //make the red curve just a tiny bit more thick to make it stand out even better
                }
            }

            m_connectionBackgroundColor = new Color(m_connectionColor.r * 0.2f,
                                                    m_connectionColor.g * 0.2f,
                                                    m_connectionColor.b * 0.2f,
                                                    m_connectionAlpha - 0.2f);
            HandleMaterial.SetPass(0);
            HandleUtility.handleMaterial.SetPass(0);

            Handles.DrawBezier(vc.OutputVirtualPoint.Rect.position,
                               vc.InputVirtualPoint.Rect.position,
                               vc.OutputTangent,
                               vc.InputTangent,
                               m_connectionBackgroundColor,
                               null,
                               currentCurveWidth + 2);
            Handles.DrawBezier(vc.OutputVirtualPoint.Rect.position,
                               vc.InputVirtualPoint.Rect.position,
                               vc.OutputTangent,
                               vc.InputTangent,
                               m_connectionColor,
                               null,
                               currentCurveWidth);

            if (!HasFocus)
            {
                return;                                      //if the window does not have focus -> return (DO NOT PLAY ANIMATION)
            }
            if (!MouseInsideWindow)
            {
                return;                                      //if the mouse is not inside the window -> return (DO NOT PLAY ANIMATION)
            }
            if (!m_animateInput && !m_animateOutput)
            {
                return;                                      //if the animation is not enabled for both points -> return (DO NOT PLAY ANIMATION)
            }
            m_numberOfPoints = (int)(Vector2.Distance(vc.OutputVirtualPoint.Rect.position,
                                                      vc.InputVirtualPoint.Rect.position) *
                                     NodySettings.Instance.CurvePointsMultiplier);  //points multiplier - useful for a smooth dot travel - smaller means fewer travel point (makes the point 'jumpy') and higher means more travel points (make the point move smoothly)
            if (m_numberOfPoints <= 0)
            {
                return;
            }
            m_bezierPoints = Handles.MakeBezierPoints(vc.OutputVirtualPoint.Rect.position,
                                                      vc.InputVirtualPoint.Rect.position,
                                                      vc.OutputTangent,
                                                      vc.InputTangent,
                                                      m_numberOfPoints);

            m_dotPointIndex = 0;
            m_numberOfPoints--; //we set the number of points as the bezierPoints length - 1

            if (m_animateInput)
            {
                m_dotPointIndex = (int)(AnimationTime * m_numberOfPoints);
            }
            else if (m_animateOutput)
            {
                m_dotPointIndex = m_numberOfPoints - (int)((1 - AnimationTime) * m_numberOfPoints);
            }

            m_dotPointIndex = Mathf.Clamp(m_dotPointIndex, 0, m_numberOfPoints);

            m_dotPoint = m_bezierPoints[m_dotPointIndex];

            m_dotSize = currentCurveWidth * 2;

            //make the dot a bit brighter
            m_dotColor = new Color(m_dotColor.r * 1.2f,
                                   m_dotColor.g * 1.2f,
                                   m_dotColor.b * 1.2f,
                                   m_dotColor.a);

            GUI.color = m_dotColor;
            GUI.Box(new Rect(m_dotPoint.x - m_dotSize / 2, m_dotPoint.y - m_dotSize / 2, m_dotSize, m_dotSize), "", DotStyle);
            GUI.color = Color.white;
        }
コード例 #4
0
 internal static void ApplyLineMaterial()
 {
     HandleMaterial.SetPass(0);
 }