[SOLVED] Parsing XYZ coordinates from a text file into Isadora
-
Hi,
I am looking for some advice about reading XYZ coordinates into isadora as a stream of numbers. I have looked at using the newer Data Array actor to read the file and this works except that it appears to be interpreting the numeric coordinates as text. But there does not appear to be an option to convert them back into a numeric float.
There must be a way to do this?
I have tried formatting the external text file using Microsoft Excel so that the data was then in a tab delimited structure which the Data Array actor could read properly, but this has some other inherent issues.
Best Wishes
bonemap
-
How much precision do you need exactly ?
The JavaScript actor is capable of splitting your numbers using the str.split(" ") function, it only seems that Isadora will round all output from the JavaScript output ports, so you can't have this numbers that are so precise. Personally I think that you can only use these kind of numbers as text.
-
@juriaan said:
JavaScript
Thanks Juriaan, it appears that the float is too long for Isadora although I have tested the numbers in a text file with 72 lines of xyz coordinates describing a torus. For this I manually entered tabs using ‘find and replace’ in TextEdit software. The Data Array handled those floats just fine automatically adjusting the numbers to be shorter (as you say rounding them), and I was able to make a point cloud of particles with both the 3D Particles and 3D Model Particles. Having to enter the ‘tab’ manually like that is a bit of a drag, particularly with more complex geometry. I thought there might be a way of parsing the data without the intermediary step of reformatting it as tab delimited.
Best Wishes
Bonemap
-
The Data Array actor does interpret the numeric coordinates as text because you are connecting it to a text chopper. The outputs default to a numeric value, but are mutable; if you connect the outputs to a text input, it will change to send text instead of numbers.
Best Michel
-
@michel said:
numeric coordinates as text because you are connecting it to a text chopper
Thanks Michel, is there an actor that will split the numeric values into the six discrete outputs, similar to what the text chopper is doing only retaining the float format?
Best WIshes
bonemap
-
-
@juriaan said:
perhaps you find it usefull
Hi Juriaan,
Yes! it solved the issue - you are a gem and it works fantastically. Thanks so much for applying your scripting expertise to my particle challenge. I was starting to look at reading the data file directly with javascript, but your solution is amazing!
best wishes
bonemap
-
the numbers are rounded visually but not internally (well JS supports 64bit floats, so they are converted to the nearest 32bit float... thats still very precise).
its only that the input fields only display so many decimal places. -
You can also, load and parse CSV files in Javascript (using a 3rd party JS lib) however... reloading the file is a trick.
The JS actor only loads the external file on enterscene. I cheat this by putting it in an User Actor, and switching the User Actor On/Off. This causes the User Actor internals to 'enter Scene'.
The lib I have used is: https://www.papaparse.com (use local file method...others use web only JS)Unfortunately I can't find a demo file at the moment.
@bonemap how are you extracting the xyz coordinates from the geometries? -
@dusx said:
how are you extracting the xyz coordinates from the geometries
Hi @DusX,
There is no great mystery about extracting the geometry coordinates - I am using Meshlab, it allows saving the raw data as text file with the extension .xyz. I am just replacing the .xyz extension to .txt in the Finder so that the Data Array actor can access its contents. There is a .json export from Meshlab as well and I had started looking at your javascript tutorials to see if I could make any headway reading the datafile directly with javascript. @Juriaan unsurprisingly beat me to a solution. haha!
Best Wishes
bonemap
-
I think you and I are playing around with similar (but different) types of things these days.
I'm feeding xyz values (as Json) all over currently, and was about to look for a way to extract them from geometry, so pointing me at Meshlab is great, thanks.