Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question I want to know Is it possible?

Discussion in 'Editor & General Support' started by unity_TR7C4xry9zxIAw, Nov 2, 2020.

  1. unity_TR7C4xry9zxIAw

    unity_TR7C4xry9zxIAw

    Joined:
    Jul 8, 2020
    Posts:
    26
    Hello,

    I want to use unity to animate a 3D object, using CFD data collected. I just want to upload or enter some points, maybe 30,000 records, (x,y,z data points) and have it rendered to see what they represent in terms of an animation. Additionally, my files(.txt or .csv) have x, y, z coordinate and velocity.

    Recently, I heard i can visualize that using textcomponent or particle system. Unfortunately I don't know much about these things. Please help me...

    Thanks
     
  2. daveMennenoh

    daveMennenoh

    Joined:
    May 14, 2020
    Posts:
    100
    This is pretty simple actually - your first step will be to just load in your text file and parse it into discrete data points. That will depend on how the text is formatted... but here's a simple example that will just read a file from a Data folder in your assets folder...

    Code (CSharp):
    1. using UnityEngine;
    2. using System.IO;
    3.  
    4. public class FileReader : MonoBehaviour
    5. {
    6.     // Start is called before the first frame update
    7.     void Start()
    8.     {
    9.         string path = "Assets/Data/testData.txt";      
    10.         StreamReader reader = new StreamReader(path);
    11.         string theText = reader.ReadToEnd();
    12.         reader.Close();
    13.         print(theText);
    14.     }  
    15. }
     
  3. unity_TR7C4xry9zxIAw

    unity_TR7C4xry9zxIAw

    Joined:
    Jul 8, 2020
    Posts:
    26
    Oh, Thank you for your comment!
     
  4. unity_TR7C4xry9zxIAw

    unity_TR7C4xry9zxIAw

    Joined:
    Jul 8, 2020
    Posts:
    26
    Could I ask more? I want to visualize data in Scene view. Someone told me using just textcomponent. what is textcomponent? and could i get some tip about visualize data if you know that?
     
  5. daveMennenoh

    daveMennenoh

    Joined:
    May 14, 2020
    Posts:
    100
    Text component is for rendering text and if you Google Unity text component you can find a lot of info. I'm not sure using text will be the best way to go... I would add a cube, or sphere or something, and move it around based on your input. Can you get your text into Unity?
     
  6. unity_TR7C4xry9zxIAw

    unity_TR7C4xry9zxIAw

    Joined:
    Jul 8, 2020
    Posts:
    26
    Sorry for the late reply.
    Yes, I succeeded thanks to your help. And I also got my cvs file into Unity. I can see spheres based my csv file. Additionally, I hope to animate my file. Is it possible?
     
  7. vEKU

    vEKU

    Joined:
    Dec 26, 2016
    Posts:
    1
    You will have to elaborate more on how your data is structured. How many files you have and what kind of information each one of them stores. Is the velocity constant or by velocity you mean the velocity of a point on a specific frame?
     
  8. unity_TR7C4xry9zxIAw

    unity_TR7C4xry9zxIAw

    Joined:
    Jul 8, 2020
    Posts:
    26
    Ah, my file is .txt and .csv file.
    They have same information. Information in file is x,y,z coordinate and velocity of a point on a specific frame. And maybe have 20,000 data. As mentioned above, I can see my files in the scene using CSVReader scripts and Plotter scripts from here.(https://sites.psu.edu/bdssblog/2017/04/06/basic-data-visualization-in-unity-scatterplot-creation/)
    But, I also want to animate this databall(sphere).
     
    Last edited: Nov 11, 2020