Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
antoniocarloss60
antoniocarloss60's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Doubt about Toxiclibs "VolumeBrush"
[0 Replies]
29-Sep-2013 05:21 PM
Forum:
Contributed Library Questions
hello
I'm doing an experiment based on the "VolumeBrush" example. I created a 3D model and exported it in "stl" and after that I modified the sketch to import this model, but when I click to continue drawing the model disappears.
thanks for everything
import toxi.geom.*;
import toxi.geom.mesh.*;
import toxi.volume.*;
import toxi.math.waves.*;
import toxi.processing.*;
import processing.opengl.*;
int DIMX=64;
int DIMY=64;
int DIMZ=64;
float ISO_THRESHOLD = 0.1;
Vec3D SCALE=new Vec3D(1, 1, 1).scaleSelf(100);
VolumetricSpace volume;
VolumetricBrush brushRedondo;
VolumetricBrush brushQuadrado;
IsoSurface surface;
//WETriangleMesh mesh;
WETriangleMesh importMesh;
TriangleMesh exportMesh;
WETriangleMesh mesh;
AbstractWave brushSize;
boolean brushRedondoOn = true;
boolean brushQuadradoOn = false;
boolean isWireframe=false;
boolean doSave=false;
float currScale=4;
float density=0.5;
ToxiclibsSupport gfx;
void setup() {
size(1024, 768, OPENGL);
hint(ENABLE_OPENGL_4X_SMOOTH);
strokeWeight(0.5);
volume=new VolumetricSpaceArray(SCALE, DIMX, DIMY, DIMZ);
brushRedondo=new RoundBrush(volume, SCALE.x/2);
brushQuadrado=new BoxBrush(volume, SCALE.x/2);
brushSize=new SineWave(0, 0.1, SCALE.x*0.07, SCALE.x*0.1);
surface=new ArrayIsoSurface(volume);
importMesh = (WETriangleMesh) new STLReader().loadBinary(sketchPath("scribble1380492459.stl"), STLReader.WEMESH);
mesh=new WETriangleMesh();
exportMesh=new TriangleMesh();
gfx=new ToxiclibsSupport(this);
}
void draw() {
if (brushRedondoOn) {
brushRedondo.setSize(brushSize.update());
}
if (brushQuadradoOn) {
brushQuadrado.setSize(brushSize.update());
}
Vec3D mousePos=new Vec3D((mouseX-width/2)*0.5, (mouseY-height/2)*0.5, sin(frameCount*0.05)*SCALE.z*0.5);
if (mousePressed) {
if (brushRedondoOn) {
brushRedondo.drawAtAbsolutePos(mousePos, density);
}
if (brushQuadradoOn) {
brushQuadrado.drawAtAbsolutePos(mousePos, density);
}
volume.closeSides();
surface.reset();
importMesh.addMesh(mesh);
surface.computeSurfaceMesh(importMesh, ISO_THRESHOLD);
}
if (doSave) {
// save mesh as STL or OBJ file
surface.computeSurfaceMesh(exportMesh, ISO_THRESHOLD);
exportMesh.saveAsSTL(sketchPath("scribble"+(System.currentTimeMillis()/1000)+".stl"));
doSave=false;
}
background(128);
translate(width/2, height/2, 0);
lightSpecular(230, 230, 230);
directionalLight(255, 255, 255, 1, 1, -1);
shininess(1.0);
rotateX(-0.4);
rotateY(frameCount*0.05);
scale(currScale);
beginShape(TRIANGLES);
if (isWireframe) {
stroke(255);
noFill();
}
else {
noStroke();
fill(255);
}
gfx.mesh(importMesh);
noFill();
stroke(255, 0, 0);
gfx.sphere(new Sphere(mousePos, brushSize.value), 20);
}
void keyPressed() {
if (key=='-') {
currScale=max(currScale-0.1, 0.5);
}
if (key=='=') {
currScale=min(currScale+0.1, 10);
}
if (key=='w') {
isWireframe=!isWireframe;
return;
}
if (key=='s') {
doSave=true;
return;
}
if (key>='1' && key<='9') {
density=-0.5+(key-'1')*0.1;
println(density);
}
if (key=='0') {
density=0.5;
}
if (key>='a' && key<='z') {
ISO_THRESHOLD=(key-'a')*0.019+0.01;
}
if (key=='g') {
if (brushRedondoOn) {
brushRedondoOn = false;
brushQuadradoOn = true;
}
else {
brushRedondoOn = true;
brushQuadradoOn = false;
}
}
if (key == 'l') {
new LaplacianSmooth().filter(mesh, 1);
}
}
«Prev
Next »
Moderate user : antoniocarloss60
Forum