Пример #1
0
    // Use this for initialization
    void Start()
    {
        NodeLinkDataLoader dataLoader = new NodeLinkDataLoader();

        dataLoader.srcType = graphType;
        dataLoader.LoadNodeLinkData();
        populateMaps(dataLoader);
        generate3DPoints();
        generateNodesAndLinks();
        activateBaseObject();
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        sphereCenter = gameObject.transform.position;

        NodeLinkDataLoader dataLoader = new NodeLinkDataLoader();

        dataLoader.srcType = DataSourceType.MOVIES;
        //dataLoader.LoadNodeLinkData();
        dataLoader.LoadRawData();
        populateMaps(dataLoader);
        generate3DPoints();
        generateNodesAndLinks();

        if (leftController != null)
        {
            leftContManager = leftController.GetComponent <ForceDirTrackedObject>();
        }
        if (rightController != null)
        {
            rightContManager = rightController.GetComponent <ForceDirTrackedObject>();
        }
    }
Пример #3
0
    protected void populateMaps(NodeLinkDataLoader dataLoader)
    {
        nodeMap  = new Dictionary <string, NodeInfo>();
        linkList = new List <LinkInfo>();
        groupMap = new Dictionary <string, List <NodeInfo> >();

        Color[] palette = ColorUtils.getColorPalette();
        ColorUtils.randomizeColorPalette(palette);

        Dictionary <int, int> colorSet = new Dictionary <int, int>();
        int currGroup;

        NodeInfo        currNode;
        List <NodeInfo> currGrpList;

        foreach (NLNode node in dataLoader.nodes)
        {
            currNode         = new NodeInfo();
            currNode.id      = node.id;
            currNode.group   = node.group;
            currNode.groupId = node.groupId;
            currNode.color   = palette[currNode.group % palette.Length];

            nodeMap.Add(node.id, currNode);

            if (!groupMap.TryGetValue(currNode.groupId, out currGrpList))
            {
                currGrpList = new List <NodeInfo>();
                groupMap.Add(currNode.groupId, currGrpList);
            }

            currGrpList.Add(currNode);

            if (!colorSet.TryGetValue(currNode.group, out currGroup))
            {
                colorSet.Add(currNode.group, 0);
            }
        }

        foreach (NLCoord coord in dataLoader.coords)
        {
            if (nodeMap.TryGetValue(coord.id, out currNode))
            {
                currNode.pos2d = new Vector2(coord.x, coord.y);
            }
        }

        NodeInfo startNode;
        NodeInfo endNode;
        LinkInfo currLink;



        Random.InitState(97);

        foreach (NLLink link in dataLoader.links)
        {
            if (nodeMap.TryGetValue(link.source, out startNode) &&
                nodeMap.TryGetValue(link.target, out endNode))
            {
                currLink            = new LinkInfo();
                currLink.start      = startNode;
                currLink.end        = endNode;
                currLink.lineWidth  = link.lineWidth;
                currLink.forceValue = Mathf.Sqrt((float)link.value) + Random.value * 0.5f;
                linkList.Add(currLink);
            }
        }
    }