We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi All, i'm working on project were we have kind of a water nozzle system, a bidimensional array. Nothing new, the idea is to make water shapes fall from those nozzles.
So what i need is a way to import a solid into processing, section it, and for each sections see what points (each one corresponding to a nozzle) is inside or outside.
I have two ways in my mind: taking actual sections as image (i would prefer) and then having a filled shape, to do a bidimensional boolean operation (i saw something in toxic lib) or having actual 3d boolean, to see if a point is or is not inside a shape).
I had a look to toxic lib but i was unable to really find a way to di this slicing of a 3d object.
I guess is a common problem, for example, for preparing 3d print file starting from a stl.
Any suggestion?
Answers
So like one of these falling water nozzle systems, only a grid rather than a strip?
What is your input data format -- or what are the formats you are considering?
You could render the shape, set the perspective to underneath the shape, and set a narrow clipping slice area which is a thin plane perpendicular to the camera perspective. Now advance the object toward the camera each frame, and different cross sections will be rendered according to how they intersect with the clipping area. Check the image values to activate your nozzles. (untested)
Hi jeremy, actually our goal is more like this: The point is that is tridimentional. The clipping function act in a bidimentional way from the point of view. So basically what i think i need to do is more something like this: Any idea about some library, even a java library, i could potentially use for doing this in processing?
Yes, I understood -- sorry if that wasn't clear from my response.
That is why I recommended using
perspective()
-- you can set a clipping plane (the line passing through your dragon) using only theperspective()
commandzNear
andzFar
arguments. As long as you load your 3D object in "overhead" position, then calling perspective will give you the cross sections you need in (a) and (b) -- and these can be used to drive nozzle activation.Here is a simple example sketch. For demo objects it shows a simple rotated cube and a simple sphere. Moving the clipping plane over the volumes generates nozzle activation data as a cross sectional image that changes over time.
In the case of your dragon object, you need to load the dragon shape into the space and orient it so that the default camera appears to be "overhead." Then manipulating zNear / zFar as in this example sketch will give you the expected clipping results as in (a) and (b).
These cross sectional shapes could be hollow or filled, and they could be played in real-time or they could be written to an array of nozzle data so that the graphic scan only needs to be performed once per object.
Hi Jeremy, just tried this importing an external obj, it works as well, looks like a very creative solution :-) I could try to render this in a pgraphic to reimport it. Do you think there is any way to have an inner fill in the shapes? Thank you btw
I'm actually not sure if there is a built-in way to render clipped object faces as solid -- I don't believe so.
One simple approach is to implement flood fill of the background -- then invert to find the foreground. This won't work if there are captured background shapes, however.
There is a scanline flood fill example in this thread:
...and (now added) a four way floodfill example in this thread: