public static Edge Create(Node vertex1, Node vertex2) { Edge edge = ScriptableObject.CreateInstance<Edge>(); edge.hideFlags = HideFlags.DontSave; edge.node1 = vertex1; edge.node2 = vertex2; return edge; }
public void SetPosition(Node node, Vector2 position) { if(selectedBlendshape && selectedBlendshape.frames.Count > 0) { selectedBlendshape.frames[selectedFrameIndex].vertices[node.index] = position; }else{ texcoords[node.index] = position; } isDirty = true; }
public Vector2 GetPosition(Node node) { if(selectedBlendshape && selectedBlendshape.frames.Count > 0) { return selectedBlendshape.frames[selectedFrameIndex].vertices[node.index]; } return texcoords[node.index]; }
public void Unselect(Node node) { if(IsSelected(node)) { selectedNodes.Remove(node); } }
public bool IsSelected(Node node) { return selectedNodes.Contains(node); }
public void Select(Node node, bool append) { if(!IsSelected(node)) { if(!append) { selectedNodes.Clear(); } selectedNodes.Add(node); } }
public BoneWeight GetBoneWeight(Node node) { return boneWeights[node.index]; }
public bool ContainsNode(Node node) { return node1 == node || node2 == node; }
public void DeleteNode(Node node, bool triangulate = true) { List<Edge> l_edges = new List<Edge>(); for(int i = 0; i < edges.Count; i++) { Edge edge = edges[i]; if(edge.ContainsNode(node)) { l_edges.Add(edge); } } if(l_edges.Count == 2) { Node node1 = l_edges[0].node1 != node ? l_edges[0].node1 : l_edges[0].node2; Node node2 = l_edges[1].node1 != node ? l_edges[1].node1 : l_edges[1].node2; edges.Remove(l_edges[0]); edges.Remove(l_edges[1]); AddEdge(node1,node2); }else{ foreach(Edge edge in l_edges) { edges.Remove(edge); } } m_TexVertices.RemoveAt(node.index); boneWeights.RemoveAt(node.index); if(blendshapes.Count > 0) { List<Vector3> frameVertices = new List<Vector3>(nodes.Count); foreach(BlendShape blendShape in blendshapes) { foreach(BlendShapeFrame frame in blendShape.frames) { frameVertices.Clear(); frameVertices.AddRange(frame.vertices); frameVertices.RemoveAt(node.index); frame.vertices = frameVertices.ToArray(); } } } nodes.Remove(node); for(int i = 0; i < nodes.Count; ++i) { nodes[i].index = i; } if(triangulate) { Triangulate(); } m_DirtyVertices = true; }
public void Unselect(Node node) { selection.Select(node.index,false); }
public bool IsSelected(Node node) { return selection.IsSelected(node.index); }
public void SetBoneWeight(Node node, BoneWeight boneWeight) { boneWeights[node.index] = boneWeight; isDirty = true; }
public void SetTexcoord(Node node, Vector2 position) { texcoords[node.index] = position; isDirty = true; }
public void DeleteNode(Node node, bool triangulate = true) { List<Edge> l_edges = new List<Edge>(); for(int i = 0; i < edges.Count; i++) { Edge edge = edges[i]; if(edge.ContainsNode(node)) { l_edges.Add(edge); } } if(l_edges.Count == 2) { Node node1 = l_edges[0].node1 != node ? l_edges[0].node1 : l_edges[0].node2; Node node2 = l_edges[1].node1 != node ? l_edges[1].node1 : l_edges[1].node2; edges.Remove(l_edges[0]); edges.Remove(l_edges[1]); AddEdge(node1,node2); }else{ foreach(Edge edge in l_edges) { edges.Remove(edge); } } texcoords.RemoveAt(node.index); boneWeights.RemoveAt(node.index); nodes.Remove(node); for(int i = 0; i < nodes.Count; ++i) { nodes[i].index = i; } if(triangulate) { Triangulate(); } }
public Vector2 GetTexcoord(Node node) { return texcoords[node.index]; }
public void AddEdge(Node node1, Node node2) { Edge newEdge = Edge.Create(node1,node2); if(!edges.Contains(newEdge)) { edges.Add(newEdge); Triangulate(); } }
public void SetVertex(Node node, Vector2 position) { SetVertex(node.index,position); }