We are about to switch to a new forum software. Until then we have removed the registration on this forum.
In essence what I'm trying to do is show a different .stl file depending on which values processing is being fed by the potentiometer on my Arduino, and then just to have that shape auto-rotating on loop on the screen.
I'm more familiar with Arduino than I am with processing, so I've been trying to wrap my head around how that might be possible. I've been using the toxiclibs to import the files, but I can only work out how to upload 1 file permanently, not multiple files depending on different variables.
Is there an easier way of doing this? The files don't necessarily need to be .stl files, I just need to be able to import some files from Rhinoceros 5, and have them rotating and viewable on the screen. I had a look at the Saito OBJ loader as well, but that seems to not work with processing 3.0.
Does that make sense?
Thanks!
Answers
What is an stl file? Is the rotation related to the status of the potentiometer?
Could your concept of rotation be interpreted as the swapping of still images?
If you were working with still images, you can load them in an array in setup and loop through them in draw.
For your information, processing has a method to load images (loadImage) and it can read jpg, gif, png, tga format. More info at https://processing.org/reference/loadImage_.html
You might also consider looking at the function loadShape:
https://processing.org/reference/loadShape_.html
It loads svg and obj files.
In case you have only one image, then you can rotate and translate your coordinate frame before placement. I think that could work.
Kf
Perfect! that sounds like a much easier solution than what I had in mind.
Think of it a bit like a character select screen in a video game, as you turn the potentiometer, a new shape comes up on the screen
To follow this up, I tried out some code that I thought would work, but it comes up with the error :
Unsupported format: 'RubixCube.obj'
I've put the RubixCube file in the data folder, so I think it might be that I'm misunderstanding how to use Pshape/loadShape. Here's what I wrote:
For a potentiometer, you can use GUI controls from contolP5 lib or from G4P GUI builder (I think they have one). Now, if you want to use your stl object, then you will need to converted to an obj object. This is the tricky part. Would all .obj files have the same internal structure? If they would, then loadShape should work all the time. I am not an expert doing this, but what I would do if to find out what sort of .obj files processing can handle. How are you generating your Object files?
A reference I got from Daniel Sauter's book is the following:
If you find any documentation about the format of Object files that processing handle, you can share them in this post. I would also suggest browsing the forum to see what other post are out there related to working with this type of files and working with loadShape function.
I hope this helps,
Kf