コード例 #1
0
    /// <summary>
    /// Spawns the brain for one subject- this may be "fsaverage_joel", the average brain.  This will try to use assetBundles and call ObjSpawn if it can't.
    /// </summary>
    /// <returns>The spawn.</returns>
    /// <param name="subject">Subject.</param>
    /// <param name="average_brain">If set to <c>true</c> average brain.</param>
    public override IEnumerator Spawn(string subject, bool average_brain = false)
    {
        CoroutineWithData subjectListRequest = new CoroutineWithData(this, RhinoRequestor.AssetBundleRequest(subject));

        yield return(subjectListRequest.coroutine);

        Debug.Log(subjectListRequest.result);
        if (subjectListRequest.result == null)
        {
            loadingText.text = "AssetBundle not found. Performing alternative (slower) load. Please wait.";
            ObjSpawn(subject, average_brain);
            yield break;
        }
        AssetBundle bundle      = (AssetBundle)subjectListRequest.result;
        GameObject  brainPrefab = bundle.LoadAsset <GameObject>(subject);
        GameObject  brain       = Instantiate(brainPrefab);

        brain.transform.parent = gameObject.transform;
        dk             = brain.transform.GetChild(1).gameObject;
        hcp            = brain.transform.GetChild(0).gameObject;
        dkLeftParent   = dk.transform.GetChild(0).gameObject;
        dkRightParent  = dk.transform.GetChild(1).gameObject;
        hcpLeftParent  = hcp.transform.GetChild(0).gameObject;
        hcpRightParent = hcp.transform.GetChild(1).gameObject;

        currentBundle = bundle;

        //due to weirdness, flip everything
        //gameObject.transform.localScale = new Vector3 (-gameObject.transform.localScale.x, gameObject.transform.localScale.y, gameObject.transform.localScale.z);

        hcp.SetActive(false);
    }
コード例 #2
0
    private IEnumerator FileRequestToObj(string subjectName, string fileName)
    {
        CoroutineWithData objRequest = new CoroutineWithData(this, RhinoRequestor.FileRequest(subjectName, fileName));

        yield return(objRequest.coroutine);

        byte[] objData = (byte[])objRequest.result;
        BuildBrainPiece(objData, fileName);
    }
コード例 #3
0
    private IEnumerator GetStimSiteCSVReader(string subjectName)
    {
        CoroutineWithData fileRequest = new CoroutineWithData(this, RhinoRequestor.FileRequest(subjectName, subjectName + "_allcords.csv"));

        yield return(fileRequest.coroutine);

        string csvText = System.Text.Encoding.Default.GetString((byte[])fileRequest.result);

        yield return(new System.IO.StringReader(csvText));
    }
コード例 #4
0
    private IEnumerator GetElectrodeFileReader(string subjectName, string filename)
    {
        CoroutineWithData fileRequest = new CoroutineWithData(this, RhinoRequestor.ElectrodeRequest(subjectName));

        yield return(fileRequest.coroutine);

        string csvText = (string)fileRequest.result;

        yield return(new System.IO.StringReader(csvText));
    }
コード例 #5
0
    /// <summary>
    /// These requests a lists of all subjects and spawns electrodes for each of them.
    /// </summary>
    /// <returns>The all subjects.</returns>
    /// <param name="average_brain">If set to <c>true</c> average brain.</param>
    public IEnumerator SpawnAllSubjects(bool average_brain)
    {
        CoroutineWithData subjectListRequest = new CoroutineWithData(this, RhinoRequestor.SubjectListRequest());

        yield return(subjectListRequest.coroutine);

        string[] subjects = (string[])subjectListRequest.result;
        foreach (string subject in subjects)
        {
            Debug.Log("Spawning electrodes of: " + subject);
            yield return(Spawn(subject, average_brain: average_brain));
        }
    }
コード例 #6
0
    /// <summary>
    /// this performs the load from Objs instead of an .assetBundle
    /// it is used in case no .assetBundle exists and by CreateAssetBundles to create the asset bundles in the first place.
    /// </summary>
    /// <param name="subjectName">Subject name.</param>
    /// <param name="average_brain">If set to <c>true</c> average brain.</param>
    public void ObjSpawn(string subjectName, bool average_brain = false)
    {
        float startTime = Time.time;

        GameObject subject = new GameObject(subjectName);

        subject.transform.parent = gameObject.transform;
        hcp = new GameObject("hcp");
        hcp.transform.parent = subject.transform;
        dk = new GameObject("dk");
        dk.transform.parent             = subject.transform;
        dkLeftParent                    = new GameObject("dk left");
        dkLeftParent.transform.parent   = dk.transform;
        dkRightParent                   = new GameObject("dk right");
        dkRightParent.transform.parent  = dk.transform;
        hcpLeftParent                   = new GameObject("hcp left");
        hcpLeftParent.transform.parent  = hcp.transform;
        hcpRightParent                  = new GameObject("hcp right");
        hcpRightParent.transform.parent = hcp.transform;

        //CoroutineWithData objListRequest = new CoroutineWithData (this, RhinoRequestor.ObjFilePathListRequest (subjectName));
        //yield return objListRequest.coroutine;
        string[] filenames = RhinoRequestor.EditorObjFilePathListRequest(subjectName);//(string[])objListRequest.result;
        //Debug.Log (filenames.Length);
        foreach (string filename in filenames)
        {
            if (System.IO.Path.GetExtension(filename).Equals(".obj"))
            {
                //if (loadingText != null)
                //	loadingText.text = "Downloading: " + filename;
                EditorFileRequestToObj(subjectName, filename);
            }
            else
            {
                loadingText.text = "Error: I got a non-obj file from list objs get: " + filename;
                throw new UnityException("I got a non-obj file from list objs get: " + filename);
            }
        }

        Debug.Log("Load finished: " + (Time.time - startTime).ToString());

        //due to weirdness, flip everything
        gameObject.transform.localScale = new Vector3(-gameObject.transform.localScale.x, gameObject.transform.localScale.y, gameObject.transform.localScale.z);

        hcp.SetActive(false);
    }
コード例 #7
0
 private void EditorFileRequestToObj(string subjectName, string fileName)
 {
     byte[] objData = RhinoRequestor.EditorFileRequest(subjectName, fileName);
     BuildBrainPiece(objData, fileName);
 }