We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi Guys!
Is there a way to import files while the sketch is currently beeing excecuted? E.g.: I have a button(controlp5) and when pressed it opens my filemanager and lets me pick a picture for instance.
For my application i want to change an 3D object, so a .mtl - File. My hopes aren't high, that this is possible but maybe someone has an idea. :D
Answers
select a file to input:
https://processing.org/reference/selectInput_.html
load an obj file:
https://processing.org/reference/loadShape_.html
not sure about .mtl files
No problem.
Look at selectInput
Inside the call back function, copy the file path inside a global String variable loadPath that you declared before setup ().
Then use loadStrings together with loadPath to open the mtl.
I always use a state system to make sure I only load once loadPath is set. So once the load command gets in I tell draw() to be in a state waitForLoad (integer variable / constant) and I then start selectInput. Once loadPath is set, I load and set the state back to stateNormal (integer variable as well).
here is an example to demonstrate the states.
This full sketch just displays the content of a text or mtl file after you loaded it.
I hope this helps.
Chrisir ;-)
Thanks guys! It works
great!