@qat wrote:
Hi, I am trying to adapt the ofxMarchingCubes add-on to work with my particle-based fluid simulation. To render some spheres, the example is as follows:
//SPHERES ofVec3f step = ofVec3f(3./mc.resX, 1.5/mc.resY, 3./mc.resZ) * PI; for(int i=0; i<mc.resX; i++){ for(int j=0; j<mc.resY; j++){ for(int k=0; k<mc.resZ; k++){; float val = sin(float(i)*step.x) * sin(float(j+elapsedTime)*step.y) * sin(float(k+elapsedTime)*step.z); val *= val; mc.setIsoValue( i, j, k, val ); } } }
How can I adapt this to work with many points? I have made several attempts but I think they are way off. Does anyone know how to do it? Obviously you start by looping over all the particles, and use the coordinates of each particle, but I’m pretty lost after that. Thanks. Here was my attempt, which gives me a wall and runs very slowly:
for(int p = 0; p < particleSystem.size(); p++) { BinnedParticle& cur = particleSystem[p]; particleSystem.computeDensity3D(cur, particleNeighborhood, particleRepulsion); particleSystem.computePressure(cur, particleNeighborhood, particleRepulsion); particleSystem.updateForces3D(cur, particleNeighborhood, particleRepulsion); ofVec3f step = vec3 (particleSystem[p].x/mc.resX, particleSystem[p].y/mc.resY, particleSystem[p].z/mc.resZ) ; //mc.setIsoValue( step.x, step.y, step.z, .6); for(int i=0; i<mc.resX; i++){ for(int j=0; j<mc.resY; j++){ for(int k=0; k<mc.resZ; k++){ float val = (float(i)*step.x) * (float(j)*step.y) * (float(k)*step.z); mc.setIsoValue( i, j, k, val ); } } } } mc.update();
Posts: 1
Participants: 1