- Home /
How to create an object from 3D points in a text file?!
Hi,
I was wondering if it is possible to create a physical object in Unity using a set of 3D points whose values have been stored in a simple text file (or say, a CSV). In other words I want to be able to create an object with many points above the "ground" level and the location of those points (vertexes) are included in a text file (X,Y,Z). Is there a way to do such primitive drawings?! I had a brief look at GL option but cannot even draw a simple line! Could someone please provide an example (script)?! Also, I would like to be able to change the file outside Unity (change the points' locations) and have the changes reflected in Unity!
Thank you in advance for your attention and kind replies.
Regards,
M.H.
Answer by Eric5h5 · Jul 19, 2010 at 07:28 AM
Sure, use the Mesh class. Use System.IO for reading files. Look at the procedural examples for illustrations of how the Mesh class is used. (GL is for immediate mode, but GL.LINES draws lines without any particular difficulty, as long as you have Unity Pro.)
Hi Eric5h5,
Thank you for your useful comments. The System.IO does not have any useful methods(commands) for parsing CSV files, Does it? Also, if I were to draw some arbitary lines how can the space between be filled to create a full 3D object? Does the meshing do that?!
B.T.W., how come I can't do this in Unity:
// while ( (tcxt = fReader.ReadLine()) != null ){
I had to do this which obviously not ideal at all! //tcxt = fReader.ReadLine(); //while ( tcxt != null ){
Does it not support assigning and condition checking in one line!! Java and Java Script do?! Thanks.
Your answer
Follow this Question
Related Questions
How to access value within instantiated class in different object? 1 Answer
Changing Pixel Colors for Passing Objects 1 Answer
icon or text activates script 0 Answers
Low level text writing 1 Answer
parsing csv file 2 Answers