Esempio n. 1
0
    // Use Awake() to initialize field variables.
    public void Awake()
    {
        //It is assumed that all the necessary components are already attached to CommHub gameObject, which  is referred to by
        // gameObject field of this object, the current instance of the current Class.

        m_displayController          = this.gameObject.GetComponent <DisplayScriptTreeOfVoice>();
        m_actionPlanController       = this.gameObject.GetComponent <ActionPlanController>();
        m_actionPlanUpdateController = this.gameObject.GetComponent <ActionPlanUpdateController>();
        m_boidsController            = this.gameObject.GetComponent <SimpleBoidsTreeOfVoice>();
        m_boidsRenderer = this.gameObject.GetComponent <BoidRendererTreeOfVoice>();

        m_actionPlanFileManager = this.gameObject.GetComponent <ActionPlanFileManager>();

        //debugging
        m_LEDColorGenController = this.gameObject.GetComponent <LEDColorGenController>(); // compute Shader use

        if (m_LEDColorGenController == null)
        {
            Debug.LogError("The component LEDColorGenController  should be added to CommHub");
            // Application.Quit();
        }


        m_pointerEventsController = this.gameObject.GetComponent <PointerEventsController>();
        // this  gets the reference  to the instance of  class PointerEventsController
        // The instance is automatically created (by new  PointerEventsController() ) when the component is added to the gameObject
        // The gameboject will has the reference to that instance.

        m_IRSensorMasterController = this.gameObject.GetComponent <IRSensorMasterController>();
        m_LEDMasterController      = this.gameObject.GetComponent <LEDMasterController>();
        m_neuroHeadSetController   = this.gameObject.GetComponent <NeuroHeadSetController>();
    }
Esempio n. 2
0
    //string dictPath { get { return Application.dataPath + "/" + fileName; } }

    //string dictPath { get { return UnityEngine.Application.dataPath + "/" + fileName; } }

    void Start()
    {
        //// get it from ActionPLanController component attached to CommHub
        m_actionPlanController = this.gameObject.GetComponent <ActionPlanController>();
        // this.gameObject is CommHub object to which ActionPlanFileManager component is attached

        if (m_actionPlanController == null)
        {
            Debug.LogError("Add ActionPlanController component to CommHub gameObject");
            UnityEngine.Application.Quit();
        }

        m_actionPlan = m_actionPlanController.m_actionPlan;
    }
Esempio n. 3
0
    public Dictionary <String, List <ActionPlanController.Action> > m_actionPlan; //// first defined in SimpleBoidsTreeOfVoice class

    ////public Dictionary<string, List<int>> myDict = new Dictionary<string, List<int>>();



    //string dictPath { get { return Application.dataPath + "/" + fileName; } }

    //string dictPath { get { return UnityEngine.Application.dataPath + "/" + fileName; } }

    void Start()
    {
        m_dictPath = UnityEngine.Application.dataPath + "/ActionPlans/";
        m_fileName = "actionPlan1.xml";
        //m_fileName = "actionPlan.xml";
        //// get it from ActionPLanController component attached to CommHub
        m_actionPlanController = this.gameObject.GetComponent <ActionPlanController>();
        // this.gameObject is CommHub object to which ActionPlanFileManager component is attached

        if (m_actionPlanController == null)
        {
            Debug.LogError("Add ActionPlanController component to CommHub gameObject");
            UnityEngine.Application.Quit();
        }

        m_actionPlan = m_actionPlanController.m_actionPlan;
    }
Esempio n. 4
0
    private void Awake()
    {
        // DEBUG code
        string fileName = "SimpleBoids1.txt";

        string path = "Assets/Resources/DebugFiles/" + fileName;

        //Write some text to the test.txt file
        m_writer = new StreamWriter(path, true); // do append

        //// 벽의 크기
        //GroundMinCorner = new Vector3(-10f, -10f, -10f);
        //GroundMaxCorner = new Vector3(10f, -10f, 10f);

        //CeilingMinCorner = new Vector3(-10f, 10f, -10f);
        //CeilingMaxCorner = new Vector3(10f, 10f, 10f);

        // 시뮬레이션 공간의 센터
        //RoomCenter = (GroundMinCorner + CeilingMaxCorner) / 2f;
        //RoomSize = CeilingMaxCorner - GroundMinCorner;



        m_MinDomainRadius = CeilingInnerRadius; // the minumum radius of of the xz domain; used LED boid rendering
        m_MaxDomainRadius = GroundRadius;

        m_actionPlanController = this.gameObject.GetComponent <ActionPlanController>();

        if (m_actionPlanController is null)
        {
            Debug.Log("ActionPlanController component should be added to CommHub");
        }

        m_threadGroupSize = Mathf.CeilToInt(m_BoidsNum / (float)BLOCK_SIZE);


        Debug.Log("################################");
        Debug.Log("I am in Awake() in SimpleBoids initializing for the simulation of boids");
        Debug.Log("################################");



        InitializeValues();
        InitializeBuffers();
    }//  private void Awake()
Esempio n. 5
0
    }     // DetermineParaValue()

    private void Awake()
    {
        m_actionPlanController = this.gameObject.GetComponent <ActionPlanController>();

        if (m_actionPlanController is null)
        {
            Debug.Log("ActionPlanController component should be added to CommHub");
        }

        m_threadGroupSize = Mathf.CeilToInt(m_BoidsNum / (float)BLOCK_SIZE);


        Debug.Log("################################");
        Debug.Log("I am in Awake() in SimpleBoids initializing for the simulation of boids");
        Debug.Log("################################");



        InitializeValues();
        InitializeBuffers();
    }//  private void Awake()
Esempio n. 6
0
    // public Dictionary<String, List<SimpleBoidsTreeOfVoice.Action>> m_actionPlan; //// first defined in SimpleBoidsTreeOfVoice class



    //public string fileName = "dict.bin";

    //string dictPath { get { return Application.dataPath + "/" + fileName; } }

    //string dictPath { get { return UnityEngine.Application.dataPath + "/" + fileName; } }

    void Start()
    {
        // Check if global components are defined
        //if (m_boidsController == null)
        //{
        //    Debug.LogError("The global Variable m_boidsController is not  defined in Inspector");

        //}

        m_actionPlanController = this.gameObject.GetComponent <ActionPlanController>();

        if (m_actionPlanController == null)
        {
            Debug.LogError("The ActionPlanController component should be added to CommHub");
        }
        //m_actionPlan = m_boidsController.m_actionPlan;

        m_inputFieldContainer  = m_actionPlanController.m_inputFieldContainer;
        m_textContainer        = m_actionPlanController.m_textContainer;
        m_placeholderContainer = m_actionPlanController.m_placeholderContainer;
        m_inputFieldHashTable  = m_actionPlanController.m_inputFieldHashTable;
    }
    //class Test
    //{
    //    public static void Main()
    //    {
    //        string path = @"c:\temp\MyTest.txt";
    //        if (!File.Exists(path))
    //        {
    //            // Create a file to write to.
    //            using (StreamWriter sw = File.CreateText(path))
    //            {
    //                sw.WriteLine("Hello");
    //                sw.WriteLine("And");
    //                sw.WriteLine("Welcome");
    //            }
    //        }

    //        // Open the file to read from.
    //        using (StreamReader sr = File.OpenText(path))
    //        {
    //            string s = "";
    //            while ((s = sr.ReadLine()) != null)
    //            {
    //                Console.WriteLine(s);
    //            }
    //        }
    //    }
    //}

    private void Awake()
    {
        // DEBUG code
        string fileName  = "SimpleBoidSimul";
        string fileIndex = System.DateTime.Now.ToString("yyyyMMddHHmmss");

        fileIndex.Replace(" ", string.Empty);
        //fileIndex = string.Join("",
        //       fileIndex.Split(default(string[]), StringSplitOptions.RemoveEmptyEntries));
        // String[] Split(String[] separator, StringSplitOptions options);
        //Because string is a reference type and the default value for all reference types is null.

        //https://answers.unity.com/questions/990496/ioexception-sharing-violation-on-path-please-help.html?_ga=2.11865712.591554826.1574537830-1174358732.1569135042

        //File.CreateText(pathToLoad)).Dispose();
        //using (TextWriter writer = new StreamWriter(pathToLoad, false))
        //{
        //    writer.WriteLine("00:00:00,00/00/0000,1,1,500,20000,1500,50,20,10,5,2,1,1,0,10,50,50");
        //    writer.Close();
        //}

        m_path = "Assets/Resources/DebugFiles/" + fileName + fileIndex + ".txt";

        //File.CreateText(path).Dispose();

        ////Write some text to the test.txt file
        //m_writer = new StreamWriter(path, false); // do not append
        //m_oStream = new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.None);
        ////m_ioStream = new FileStream(path,
        ////                               FileMode.OpenOrCreate,
        ////                               FileAccess.ReadWrite,
        ////                               FileShare.None);
        //m_writer = new System.IO.StreamWriter(m_oStream);

        //// 벽의 크기
        //GroundMinCorner = new Vector3(-10f, -10f, -10f);
        //GroundMaxCorner = new Vector3(10f, -10f, 10f);

        //CeilingMinCorner = new Vector3(-10f, 10f, -10f);
        //CeilingMaxCorner = new Vector3(10f, 10f, 10f);

        // 시뮬레이션 공간의 센터
        //RoomCenter = (GroundMinCorner + CeilingMaxCorner) / 2f;
        //RoomSize = CeilingMaxCorner - GroundMinCorner;



        //m_MinDomainRadius = CeilingInnerRadius; // the minumum radius of of the xz domain; used LED boid rendering
        m_MaxDomainRadius = GroundRadius;

        m_actionPlanController = this.gameObject.GetComponent <ActionPlanController>();

        if (m_actionPlanController is null)
        {
            Debug.Log("ActionPlanController component should be added to CommHub");
        }


        m_BoidComputeShader = Resources.Load <ComputeShader>("ComputeShaders/SimulateSimpleBoids");

        if (m_BoidComputeShader is null)
        {
            Debug.Log("Compute Shader BoidComputeShader is not bound");
        }
        m_threadGroupSize = Mathf.CeilToInt(m_BoidsNum / (float)BLOCK_SIZE);


        Debug.Log("################################");
        Debug.Log("I am in Awake() in SimpleBoids initializing for the simulation of boids");
        Debug.Log("################################");



        InitializeValues();     // Parameters for Boid Simulation
        InitializeBuffers();    // Buffer for Boid Structures
    }//  private void Awake()
    public Dictionary <String, List <ActionPlanController.Action> > m_actionPlan; //// first defined in SimpleBoidsTreeOfVoice class

    // Warning: paths returned by FileBrowser dialogs do not contain a trailing '\' character
    // Warning: FileBrowser can only show 1 dialog at a time

    void Start()
    {
        //// get it from ActionPLanController component attached to CommHub
        m_actionPlanController = this.gameObject.GetComponent <ActionPlanController>();

        // this.gameObject is CommHub object to which ActionPlanFileManager component is attached

        if (m_actionPlanController == null)
        {
            Debug.LogError("Add ActionPlanController component to CommHub gameObject");
            UnityEngine.Application.Quit();
        }

        m_actionPlan = m_actionPlanController.m_actionPlan;


        // Set filters (optional)
        // It is sufficient to set the filters just once (instead of each time before showing the file browser dialog),
        // if all the dialogs will be using the same filters
        FileBrowser.SetFilters(true, new FileBrowser.Filter("Images", ".jpg", ".png"), new FileBrowser.Filter("Text Files", ".txt", ".pdf"));

        // Set default filter that is selected when the dialog is shown (optional)
        // Returns true if the default filter is set successfully
        // In this case, set Images filter as the default filter
        FileBrowser.SetDefaultFilter(".jpg");

        // Set excluded file extensions (optional) (by default, .lnk and .tmp extensions are excluded)
        // Note that when you use this function, .lnk and .tmp extensions will no longer be
        // excluded unless you explicitly add them as parameters to the function
        FileBrowser.SetExcludedExtensions(".lnk", ".tmp", ".zip", ".rar", ".exe");

        // Add a new quick link to the browser (optional) (returns true if quick link is added successfully)
        // It is sufficient to add a quick link just once
        // Name: Users
        // Path: C:\Users
        // Icon: default (folder icon)
        FileBrowser.AddQuickLink("Users", "C:\\Users", null);

        // Show a save file dialog
        // onSuccess event: not registered (which means this dialog is pretty useless)
        // onCancel event: not registered
        // Save file/folder: file, Initial path: "C:\", Title: "Save As", submit button text: "Save"

        string initialPath = "C:\\";


        //    _LoadActionPlan(m_actionPlan);
        //
        //FileBrowser.ShowSaveDialog( (path) => { this._SaveActionPlan(path); },  null, false, m_dictPath, "Save As", "Save" );

        // Show a select folder dialog
        // onSuccess event: print the selected folder's path
        // onCancel event: print "Canceled"
        // Load file/folder: folder, Initial path: default (Documents), Title: "Select Folder", submit button text: "Select"

        //FileBrowser.ShowLoadDialog((path) => { Debug.Log("Selected: " + path); },
        //                               () => { Debug.Log("Canceled"); },
        //                               true, null, "Select Folder", "Select");

        //FileBrowser.ShowLoadDialog((path) => { this._LoadActionPlan(path); },
        //                               () => { Debug.Log("Canceled"); },
        //                               true, null, "Select Folder", "Select");


        //// Coroutine example
        //StartCoroutine(ShowLoadDialogCoroutine());
    } // Start()