public void Initialize(GraphTransform transform, float scale) { var tmpUp = transform.Transform(Vector3.up); var tmp = transform.Transform(Vector3.zero); up = (tmpUp - tmp).normalized; upheight = up * height; finalRadius = diameter * scale * 0.5F; }
public override GraphTransform UpdateTransform() { var boundMatrix = Matrix4x4.TRS(Center, Quaternion.Euler(Rotation), new Vector3(1, 1, 1)); var m = Matrix4x4.TRS(boundMatrix.MultiplyPoint3x4(-new Vector3(m_Width * m_NodeSize, 0, m_Depth * m_NodeSize) * 0.5f), Quaternion.Euler(Rotation), new Vector3(1, 1, 1)); transform = new GraphTransform(m); return(transform); }
/// <summary>Draws some debug lines representing the rect</summary> public void DebugDraw(GraphTransform transform, Color color) { Vector3 p1 = transform.Transform(new Vector3(xmin, 0, ymin)); Vector3 p2 = transform.Transform(new Vector3(xmin, 0, ymax)); Vector3 p3 = transform.Transform(new Vector3(xmax, 0, ymax)); Vector3 p4 = transform.Transform(new Vector3(xmax, 0, ymin)); Debug.DrawLine(p1, p2, color); Debug.DrawLine(p2, p3, color); Debug.DrawLine(p3, p4, color); Debug.DrawLine(p4, p1, color); }
private GridGraph(int width, int depth, int nodesize) { m_GraphIndex = GridGraphIndex++; m_Width = width; m_Depth = depth; m_NodeSize = nodesize; collision = new GraphCollision(); transform = new GraphTransform(Matrix4x4.identity); collision.Initialize(transform, nodesize); m_GridNodes = new GridNode[width * depth]; for (int i = 0; i < width * depth; i++) { var node = new GridNode(); node.NodeIndex = FreeNodeIndex++; node.GraphIndex = m_GraphIndex; m_GridNodes[i] = node; } m_FirstFree = FreeNodeIndex; SetOffset(); }