12/31 : SNN Visualization(without MagicLeap)

 


Working hour : 9~ 12 / 16~22

Works to do

1. marking arrow on the window

    a. extract plane and find center point

    b. place arrow on the center of plane


2. Make SNN file(without magic leap)



   
using System.Collections;
using System.Collections.Generic;

using UnityEngine;
using UnityEngine.XR.MagicLeap;

public class test_2_0920 : MonoBehaviour
{

    private LineRenderer lineRenderer;
    public float lineDrawSpeed = 6f;
    public GameObject Line;
    public List<GameObject> ansblock = new List<GameObject>();
    public int numb;
    private int count=0;
    public GameObject Node;
    public GameObject BBlock;
    public GameObject WBlock;
    

    List<GameObject> Node_1 = new List<GameObject>();
    List<GameObject> Node_2 = new List<GameObject>();
    List<GameObject> Node_3 = new List<GameObject>();
    List<GameObject> BlockList = new List<GameObject>();
    List<GameObject> lines_1 = new List<GameObject>();
    List<GameObject> lines_2 = new List<GameObject>();
    List<GameObject> lines_3 = new List<GameObject>();
    List<GameObject> lines_4 = new List<GameObject>();

    private MLInput.Controller _controller;
    private Dictionary<int, List<int>> numData = new Dictionary<int, List<int>>();
    int targetnumb;
    

    // Start is called before the first frame update
    void Start()
    {
        

        MLInput.Start();
        MLInput.OnControllerButtonDown += OnButtonDown;
       
        _controller = MLInput.GetController(MLInput.Hand.Right);

        numData.Add(0, new List<int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
        numData.Add(1, new List<int> { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
        numData.Add(8, new List<int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
        numData.Add(9, new List<int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });

        float ran_x, ran_y, ran_z;

        for(int i=0; i<numb; i++)
        {
            ran_x = Random.Range(-1.1f, -0.9f);
            ran_y = Random.Range(-1.5f, 1.5f);
            ran_z = Random.Range(3.8f, 9.2f);

            GameObject _obj_1=Instantiate(Node, new Vector3(ran_x, ran_y, ran_z), Quaternion.identity);
            Node_1.Add(_obj_1);

            ran_x = Random.Range(-0.1f, 0.1f);
            ran_y = Random.Range(-1.5f, 1.5f);
            ran_z = Random.Range(3.8f, 9.2f);

            GameObject _obj_2 = Instantiate(Node, new Vector3(ran_x, ran_y, ran_z), Quaternion.identity);
            Node_2.Add(_obj_2);

            ran_x = Random.Range(0.9f, 1.1f);
            ran_y = Random.Range(-1.5f, 1.5f);
            ran_z = Random.Range(3.8f, 9.2f);

            GameObject _obj_3 = Instantiate(Node, new Vector3(ran_x, ran_y, ran_z), Quaternion.identity);
            Node_3.Add(_obj_3);
        }

        for (int row = 0; row < 10; row++)
        {
            for (int col = 0; col < 10; col++)
            {
                GameObject _obj_3 = Instantiate(WBlock, new Vector3(-2f, 0.4f * row - 2.0f, 0.4f * col + 4.5f), Quaternion.identity);
                BlockList.Add(_obj_3);
            }
        }
        
        Debug.Log("Done");

    }

    // Update is called once per frame
    void Update()
    {
       
            
      
    }

    void OnDestroy()
    {
        MLInput.OnControllerButtonDown -= OnButtonDown;
        MLInput.Stop();
    }

    void OnButtonDown(byte controllereld, MLInput.Controller.Button button)
    {
        if(button == MLInput.Controller.Button.HomeTap)
        {
            for (int i = numb - 1; i >= 0; i--)
            {
                Destroy(Node_1[i]);
                Destroy(Node_2[i]);
                Destroy(Node_3[i]);
            }
            for (int j = 99; j >= 0; j--)
            {
                Destroy(BlockList[j]);
            }
            int len = lines_1.Count;
            for (int k = len - 1; k >= 0; k--)
            {
                Destroy(lines_1[k]);
            }
            len = lines_2.Count;
            for (int k = len - 1; k >= 0; k--)
            {
                Destroy(lines_2[k]);
            }
            len = lines_3.Count;
            for (int k = len - 1; k >= 0; k--)
            {
                Destroy(lines_3[k]);
            }
            len = lines_4.Count;
            for (int k = len - 1; k >= 0; k--)
            {
                Destroy(lines_4[k]);
            }
            Renderer Blockcolor = ansblock[targetnumb].GetComponent<Renderer>();
            Blockcolor.material.color = Color.white;
            Node_1.Clear();
            Node_2.Clear();
            Node_3.Clear();
            BlockList.Clear();
            lines_1.Clear();
            lines_2.Clear();
            lines_3.Clear();
            lines_4.Clear();
            gamecontrol();

            count++;
        }
        
    }

    void drawplane()
    {
        targetnumb = Random.Range(0, 10);
        GameObject _obj_3;


        for (int row = 0; row < 10; row++)
        {
            for (int col = 0; col < 10; col++)
            {
                
                if(numData[targetnumb][99-(10*row+col)]==0)
                {
                    _obj_3 = Instantiate(BBlock, new Vector3(-2f, 0.4f * row - 2.0f, 0.4f * col + 4.5f), Quaternion.identity);
                }
                else
                {
                     _obj_3 = Instantiate(WBlock, new Vector3(-2f, 0.4f * row - 2.0f, 0.4f * col + 4.5f), Quaternion.identity);
                }
                BlockList.Add(_obj_3);
            }
        }

    }

    void gamecontrol()
    {
        float ran_x, ran_y, ran_z;
        GameObject temp;
        int p;

        drawplane();

        for (int i = 0; i < numb; i++)
        {
            ran_x = Random.Range(-1.1f, -0.9f);
            ran_y = Random.Range(-1.5f, 1.5f);
            ran_z = Random.Range(3.8f, 9.2f);

            GameObject _obj_1 = Instantiate(Node, new Vector3(ran_x, ran_y, ran_z), Quaternion.identity);
            Node_1.Add(_obj_1);

            ran_x = Random.Range(-0.1f, 0.1f);
            ran_y = Random.Range(-1.5f, 1.5f);
            ran_z = Random.Range(3.8f, 9.2f);

            GameObject _obj_2 = Instantiate(Node, new Vector3(ran_x, ran_y, ran_z), Quaternion.identity);
            Node_2.Add(_obj_2);

            ran_x = Random.Range(0.9f, 1.1f);
            ran_y = Random.Range(-1.5f, 1.5f);
            ran_z = Random.Range(3.8f, 9.2f);

            GameObject _obj_3 = Instantiate(Node, new Vector3(ran_x, ran_y, ran_z), Quaternion.identity);
            Node_3.Add(_obj_3);
        }

        for(int j=0; j<numb*0.9f;j++)
        {
            p = Random.Range(0, 99);

            temp = drawline(new Vector3(BlockList[p].transform.position.x+0.1f, BlockList[p].transform.position.y, BlockList[p].transform.position.z), Node_1[j].transform.position);
            NodetoWhite(Node_1[j]);
            lines_1.Add(temp);
        }
        for (int j = 0; j < numb * 0.7f; j++)
        {
            temp=drawline(Node_1[j].transform.position, Node_2[j].transform.position);
            NodetoWhite(Node_2[j]);
            lines_2.Add(temp);
        }
        for (int j = 0; j < numb * 0.5f; j++)
        {
            temp = drawline(Node_2[j].transform.position, Node_3[j].transform.position);
            NodetoWhite(Node_3[j]);
            lines_3.Add(temp);
        }
        for (int j = 0; j < 5; j++)
        {
            temp=drawline(Node_3[j].transform.position, ansblock[targetnumb].transform.position);
            lines_4.Add(temp);
        }
        Renderer Blockcolor = ansblock[targetnumb].GetComponent<Renderer>();
        Blockcolor.material.color = Color.cyan;
    }

    GameObject drawline(Vector3 start, Vector3 end)
    {
        GameObject liner = Instantiate(Line, new Vector3((start.x + end.x) / 2, (start.y + end.y) / 2, (start.z + end.z) / 2), Quaternion.identity);
        lineRenderer = liner.GetComponent<LineRenderer>();
        lineRenderer.SetPosition(0, start);
        lineRenderer.SetWidth(.002f, .002f);
        lineRenderer.SetPosition(1, end);

        return liner;

    }

    void NodetoWhite(GameObject target)
    {
        Renderer Nodecolor = target.GetComponent<Renderer>();
        Nodecolor.material.color = Color.white;
    }


}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class _201231_1 : MonoBehaviour
{
    //1: using line renderer
    private LineRenderer lineRenderer;
    public float lineDrawSpeed = 6f;
    public GameObject Line;

    List<GameObject> lines_1 = new List<GameObject>();
    List<GameObject> lines_2 = new List<GameObject>();
    List<GameObject> lines_3 = new List<GameObject>();
    List<GameObject> lines_4 = new List<GameObject>();

    //2: node & blocks & answerblocks
    public int numb;
    public List<GameObject> ansblock = new List<GameObject>();

    public GameObject Node;
    public GameObject BBlock;
    public GameObject WBlock;

    List<GameObject> Node_1 = new List<GameObject>();
    List<GameObject> Node_2 = new List<GameObject>();
    List<GameObject> Node_3 = new List<GameObject>();
    List<GameObject> BlockList = new List<GameObject>();
    /*
    //3: using controller
    private MLInput.Controller _controller;
    */
    //4: others
    private Dictionary<int, List<int>> numData = new Dictionary<int, List<int>>();
    private Dictionary<int, List<int>> nodeinfo_1 = new Dictionary<int, List<int>>();
    private Dictionary<int, List<int>> nodeinfo_2 = new Dictionary<int, List<int>>();
    private Dictionary<int, List<int>> nodeinfo_3 = new Dictionary<int, List<int>>();
    int targetnumb;




    // Start is called before the first frame update
    void Start()
    {
        /*MLInput.Start();
        MLInput.OnControllerButtonDown += OnButtonDown;
        _controller = MLInput.GetController(MLInput.Hand.Right);
        */
        numData.Add(0, new List<int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
        numData.Add(1, new List<int> { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
        numData.Add(2, new List<int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });

        for(int i=0; i<numb; i++)
        {
            nodeinfo_1.Add(i, new List<int> { 0, 0, 0});
            nodeinfo_2.Add(i, new List<int> { 0, 0, 0 });
        }

        // Initial blocks & nodes construction

        for (int row = 0; row < 10; row++)
        {
            for (int col = 0; col < 10; col++)
            {
                GameObject _obj_3 = Instantiate(BBlock, new Vector3(-2f, 0.4f * row - 2.0f, 0.4f * col + 4.5f), Quaternion.identity);
                BlockList.Add(_obj_3);
            }
        }

        float ran_x, ran_y, ran_z;

        for (int i = 0; i < numb; i++)
        {
            ran_x = Random.Range(-1.8f, 0.25f);
            ran_y = Random.Range(-1.5f, 1.5f);
            ran_z = Random.Range(3.8f, 9.2f);

            GameObject _obj_1 = Instantiate(Node, new Vector3(ran_x, ran_y, ran_z), Quaternion.identity);
            Node_1.Add(_obj_1);

            ran_x = Random.Range(-0.25f, 2.275f);
            ran_y = Random.Range(-1.5f, 1.5f);
            ran_z = Random.Range(3.8f, 9.2f);

            GameObject _obj_2 = Instantiate(Node, new Vector3(ran_x, ran_y, ran_z), Quaternion.identity);
            Node_2.Add(_obj_2);

            ran_x = Random.Range(2.275f, 4.3f);
            ran_y = Random.Range(-1.5f, 1.5f);
            ran_z = Random.Range(3.8f, 9.2f);

            GameObject _obj_3 = Instantiate(Node, new Vector3(ran_x, ran_y, ran_z), Quaternion.identity);
            Node_3.Add(_obj_3);
        }

        Debug.Log("Done");

    }

    // Update is called once per frame
    void Update()
    {

        /*
         * Convert the content 
         * 
    void OnDestroy()
    {
        MLInput.OnControllerButtonDown -= OnButtonDown;
        MLInput.Stop();
    }

    void OnButtonDown(byte controllereld, MLInput.Controller.Button button)
    {
        if(button == MLInput.Controller.Button.HomeTap)
        {
        }
    }
         */


        if (Input.GetMouseButtonDown(0))
        {
            for (int i = numb - 1; i >= 0; i--)
            {
                Destroy(Node_1[i]);
                Destroy(Node_2[i]);
                Destroy(Node_3[i]);
            }
            for (int j = 99; j >= 0; j--)
            {
                Destroy(BlockList[j]);
            }
            int len = lines_1.Count;
            for (int k = len - 1; k >= 0; k--)
            {
                Destroy(lines_1[k]);
            }
            len = lines_2.Count;
            for (int k = len - 1; k >= 0; k--)
            {
                Destroy(lines_2[k]);
            }
            len = lines_3.Count;
            for (int k = len - 1; k >= 0; k--)
            {
                Destroy(lines_3[k]);
            }
            len = lines_4.Count;
            for (int k = len - 1; k >= 0; k--)
            {
                Destroy(lines_4[k]);
            }
            Node_1.Clear();
            Node_2.Clear();
            Node_3.Clear();
            BlockList.Clear();
            lines_1.Clear();
            lines_2.Clear();
            lines_3.Clear();
            lines_4.Clear();

            
        }
    }

    void gamecontrol()
    {
        
        GameObject temp;
        targetnumb = Random.Range(0, 10);

        // create new numb plane
        //drawplane();

        // create new nodes
        float ran_x, ran_y, ran_z;
        for (int i = 0; i < numb; i++)
        {
            ran_x = Random.Range(-1.8f, 0.25f);
            ran_y = Random.Range(-1.5f, 1.5f);
            ran_z = Random.Range(3.8f, 9.2f);

            GameObject _obj_1 = Instantiate(Node, new Vector3(ran_x, ran_y, ran_z), Quaternion.identity);
            Node_1.Add(_obj_1);

            ran_x = Random.Range(-0.25f, 2.275f);
            ran_y = Random.Range(-1.5f, 1.5f);
            ran_z = Random.Range(3.8f, 9.2f);

            GameObject _obj_2 = Instantiate(Node, new Vector3(ran_x, ran_y, ran_z), Quaternion.identity);
            Node_2.Add(_obj_2);

            ran_x = Random.Range(2.275f, 4.3f);
            ran_y = Random.Range(-1.5f, 1.5f);
            ran_z = Random.Range(3.8f, 9.2f);

            GameObject _obj_3 = Instantiate(Node, new Vector3(ran_x, ran_y, ran_z), Quaternion.identity);
            Node_3.Add(_obj_3);
        }








    }


    GameObject drawline(Vector3 start, Vector3 end)
    {
        GameObject liner = Instantiate(Line, new Vector3((start.x + end.x) / 2, (start.y + end.y) / 2, (start.z + end.z) / 2), Quaternion.identity);
        lineRenderer = liner.GetComponent<LineRenderer>();
        lineRenderer.SetPosition(0, start);
        lineRenderer.SetWidth(.002f, .002f);
        lineRenderer.SetPosition(1, end);

        return liner;

    }

}

댓글

이 블로그의 인기 게시물

0817 : Hand Tracking

0701_Using server in Unity