/**
* AnimatedNoise demo showing how to utilize the IsoSurface class to efficiently
* visualise volumetric data, in this case using animated 4D SimplexNoise. The demo also
* shows how to save the generated mesh as binary STL file (or alternatively in
* OBJ format) for later use in other 3D tools/digital fabrication.
*
* I've planned further classes for the toxi.geom.volume package to easier draw
* and manipulate volumetric data.
*
* Controls:
* Click mouse button to toggle rendering style between shaded/wireframe.
* Press 's' to save generated mesh as STL file
*/
/*
* Copyright (c) 2010 Karsten Schmidt
*
* This demo & library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* http://creativecommons.org/licenses/LGPL/2.1/
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
import toxi.geom.*;
import toxi.geom.mesh.*;
import toxi.volume.*;
import toxi.math.noise.*;
import processing.opengl.*;
int DIMX=64;
int DIMY=64;
int DIMZ=64;
float ISO_THRESHOLD = 0.1;
float NS=0.03;
Vec3D SCALE=new Vec3D(1,1,1).scaleSelf(300);
boolean isWireframe=false;
float currScale=1;
VolumetricSpace volume=new VolumetricSpace(SCALE,DIMX,DIMY,DIMZ);
IsoSurface surface=new IsoSurface(volume);
TriangleMesh mesh;
void setup() {
size(1024,576,OPENGL);
}
void draw() {
float[] volumeData=volume.getData();
// fill volume with noise
for(int z=0,index=0; z