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

Is it possible to render a text file or csv file to animate a 3D object?

Discussion in 'Editor & General Support' started by unity_TR7C4xry9zxIAw, Oct 29, 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.

    Thanks
     
  2. Charlicopter

    Charlicopter

    Joined:
    May 15, 2017
    Posts:
    123
    Yes, you can definitely do this. I'm using CSV's in a similar way right now and it works fine. Recommend CSVHelper by Josh Close. It's fast and easy to use.
     
  3. unity_TR7C4xry9zxIAw

    unity_TR7C4xry9zxIAw

    Joined:
    Jul 8, 2020
    Posts:
    26
    Thank you for your comment. If you are possible, could you tell more details?
     
  4. Charlicopter

    Charlicopter

    Joined:
    May 15, 2017
    Posts:
    123
    This should help.

    To save yourself a lot of headaches, you should make sure the .csv has a simple and consistent layout with column labels.

    You have to create a struct or class with a matching layout. So whatever order your { X, Y, Z, Vel } order is in the colums of your .csv, you'll need to create exactly the same layout with the same names for each property.

    So your class might be called "My_CSV"

    You just add properties to the class that match your .csv layout, then cast to that class like: GetRecords<My_CSV>(cfdData)

    it should return a new My_CSV containing all the data. Then you can just push x, y, z, into a new Vector3, etc, etc...

    It actually may be easier to create My_CSV first and try outputting a new .csv, then just reading it back in to see if everything works right. Then you can know for sure that the .csv data you are trying to import matches the layout correctly.