public Node(GameObject myGameObject, int myIndex) { gameObject = myGameObject; nodeForce = myGameObject.GetComponent <NodeForce> (); index = myIndex; }
public Node(GameObject myGameObject, int myIndex) { gameObject = myGameObject; nodeForce = myGameObject.GetComponent<NodeForce> (); index = myIndex; }
void parseGraph(string nodeAsset, int dimensionality, int type) { TextAsset positionsText = Resources.Load(nodeAsset) as TextAsset; string[,] myPositionsGrid = CSVReader.SplitCsvGrid(positionsText.text); int numberOfNodes = myPositionsGrid.GetUpperBound(1) - 1; masterNodeList = new Node[numberOfNodes]; indicesToShowOrExplode = new int[numberOfNodes]; // add nodes for (int i = 1; (i < numberOfNodes + 1); i++) { if (i != 0) { adjacencyList.AddVertex(i); } Vector3 position; int startIndexCoordinates; if (type == DATA_MNIST) { startIndexCoordinates = 3; } else { startIndexCoordinates = 8; } float x_3d = float.Parse(myPositionsGrid[startIndexCoordinates, i]) * ConstantsSpacerock.GRAPH_SPREAD_MULTIPLIER * ConstantsSpacerock.TOTAL_GRAPH_SCALE_MULTIPLIER; float y_3d = float.Parse(myPositionsGrid[startIndexCoordinates + 1, i]) * ConstantsSpacerock.GRAPH_SPREAD_MULTIPLIER * ConstantsSpacerock.TOTAL_GRAPH_SCALE_MULTIPLIER; float z_3d = float.Parse(myPositionsGrid[startIndexCoordinates + 2, i]) * ConstantsSpacerock.GRAPH_SPREAD_MULTIPLIER * ConstantsSpacerock.TOTAL_GRAPH_SCALE_MULTIPLIER; float x_2d = float.Parse(myPositionsGrid[startIndexCoordinates + 3, i]) * ConstantsSpacerock.GRAPH_SPREAD_MULTIPLIER * ConstantsSpacerock.TOTAL_GRAPH_SCALE_MULTIPLIER; float y_2d = float.Parse(myPositionsGrid[startIndexCoordinates + 4, i]) * ConstantsSpacerock.GRAPH_SPREAD_MULTIPLIER * ConstantsSpacerock.TOTAL_GRAPH_SCALE_MULTIPLIER; if (dimensionality == GRAPH_3D) { position = new Vector3( x_3d, y_3d, z_3d ); } else { position = new Vector3( x_2d, y_3d, 0.0f ); } string label = myPositionsGrid[0, i]; GameObject myNodeInstance = Instantiate(Resources.Load("Node") as GameObject, position, Quaternion.identity) as GameObject; //don't do getcomp live LayerSelfBasedOnRelativeLocations layerScript = myNodeInstance.GetComponent <LayerSelfBasedOnRelativeLocations>(); layerScript.eagleEyeCamera = eagleEyeCamera; layerScript.headsetLocation = playerCamera; NodeForce nodeScript = myNodeInstance.GetComponent <NodeForce>(); nodeScript.x_3d = x_3d; nodeScript.y_3d = y_3d; nodeScript.z_3d = z_3d; nodeScript.x_2d = x_2d; nodeScript.y_2d = y_2d; nodeScript.SetText(myPositionsGrid[1, i]); nodeScript.degree = int.Parse(myPositionsGrid[2, i]); nodeScript.SetScaleFromDegree(nodeScript.degree); masterNodeList[i - 1] = new Node(myNodeInstance, i - 1); if (type == DATA_TWITTER) { masterNodeList[i - 1].nodeForce.group = int.Parse(myPositionsGrid[3, i]); masterNodeList[i - 1].nodeForce.followerCount = (int)float.Parse(myPositionsGrid[4, i]); } else if (type == DATA_MNIST) { masterNodeList[i - 1].nodeForce.group = (int)float.Parse(myPositionsGrid[1, i]); } NodeGroup nodeGroupWrapperObject; // if this is a new key, make a new group if (!nodeGroups.ContainsKey(masterNodeList[i - 1].nodeForce.group)) { GameObject nodeGroupObject = Instantiate(Resources.Load("NodeGroupContainer") as GameObject, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity) as GameObject; nodeGroupWrapperObject = new NodeGroup(nodeGroupObject); nodeGroupWrapperObject.nodeGroupContainerScript.groupNumber = masterNodeList[i - 1].nodeForce.group; nodeGroupWrapperObject.gameObject.transform.parent = nodeContainer.transform; nodeGroups.Add( masterNodeList[i - 1].nodeForce.group, nodeGroupWrapperObject ); } else // give access to the existing group { nodeGroupWrapperObject = nodeGroups[masterNodeList[i - 1].nodeForce.group]; } masterNodeList[i - 1].nodeForce.SetColorByGroup(masterNodeList[i - 1].nodeForce.group); masterNodeList[i - 1].gameObject.transform.parent = nodeGroupWrapperObject.gameObject.transform; // not sure if this is gonna work right, off the bat // populate an array for the mnist image if (type == DATA_MNIST) { for (int q = 0; q < MNIST_IMAGE_SIZE; q++) { for (int r = 0; r < MNIST_IMAGE_SIZE; r++) { //print("q: " + q + "... r: " + r); masterNodeList[i - 1].nodeForce.image[q, r] = float.Parse(myPositionsGrid[startIndexCoordinates + 5 + q * MNIST_IMAGE_SIZE + r, i]); } } } nameToID.Add(label, i - 1); } }