Loading...
Logo
Processing Forum
Hi,

I could do with a hand with the best way to modify 3D shapes on the fly.

Creating basic shapes using begin and endShape() doesn't look too hard, but am not sure adding noise, randomisation, and dynamic movement to line vertices would be the best method.

The Hemesh library looks interesting ( http://www.wblut.com/2010/05/04/hemesh-a-3d-mesh-library-for-processing/), as here you can get some nice modified object complexity, without too much effort. It's just not clear to me how to, for example, extrude just an edge, and play around with that. I was looking at the extrude class but couldn't get a result (see below).

[Moderator's note: removed useless, oversized and unreadable image of a JavaDoc page. A simple copy/paste of the textual information or just a link would be more useful.]

There is also the Hemesh GUI tool, that lets you export to a stl file. I understand the unlekkerLib allows you to import these, but again am not sure how much dynsmic control you have over the shape in P5.

Essestially I want to make large and small modifications to shapes so they can be animated. I have tried using another class that adds noise to all Hemesh vertices but this was just a little too random.

Replies(9)

Would something like this ToxicLibs example be the kind of thing you're looking for?
Cheers
K
Thanks for the heads up on the library.

Was looking at this example which seems to be what I'm after: http://openprocessing.org/visuals/?visualID=11128
      - With a bit of an explanation here: http://forum.processing.org/topic/toxiclibs-trianglemesh-question

However, I've installed 0020 and 0019 versions of the libraries, and am getting the below error when trying to run the example: -

The package "toxi.geom.mesh.TriangleMesh.Face" does not exist. You might be missing a library ........

I haven't got time to Google it right now but will later.





______________________
www.systemarray.com
toxi.geom.mesh.Face is at the same level than toxi.geom.mesh.Triangle, perhaps it has been promoted...
Note that the MeshFaceExtrude is in the samples provided by the library (toxiclibscore > examples > mesh > MeshFaceExtrude) and slightly different from the OpenProcessing version.

The extrude modifier in Hemesh can be used to extrude faces. As in, not edges.

Here is an example which uses a Selector to allow extrusion of mouse-selected faces. There is probably a faster way to do this, but I can't find better syntax right now and this is just an example. Check out the tutorials (not the examples) that come with the current download of Hemesh for much more on accessing mesh elements.
Copy code
  1. // Based on the Hemesh library tutorial: Face Selection With HET Selector

  2. import wblut.math.*;
  3. import wblut.hemesh.modifiers.*;
  4. import wblut.hemesh.kdtree.*;
  5. import wblut.hemesh.creators.*;
  6. import wblut.hemesh.tools.*;
  7. import wblut.hemesh.*;
  8. import wblut.hemesh.subdividors.*;
  9. import wblut.geom.*;
  10. import processing.opengl.*;

  11. HE_Mesh mesh;
  12. HET_Selector selector;
  13. float ax,ay;

  14. void setup() {
  15.   size(600,600,OPENGL);
  16.   hint(ENABLE_OPENGL_4X_SMOOTH);
  17.   mesh=new HE_Mesh(new HEC_Cube(this).setEdge(100));
  18.   selector=new HET_Selector(this);
  19. }

  20. void draw() {
  21.   background(120);
  22.   lights();
  23.   translate(width/2,height/2,0);
  24.   rotateX(ax += 0.02);
  25.   rotateY(ay -= 0.01);
  26.   noStroke();
  27.   fill(200);
  28.   mesh.drawFaces(selector);
  29.   fill(255,0,0);
  30.   if (selector.lastKey() !=null) { mesh.drawFace(selector.lastKey()); }
  31.   stroke(0);
  32.   mesh.drawEdges();
  33. }

  34. void mousePressed() { extrudeFace(); }

  35. void extrudeFace() {
  36.   HE_Selection selection = new HE_Selection();
  37.   Iterator <HE_Face> fItr = mesh.fItr();
  38.   HE_Face f;
  39.   while (fItr.hasNext()) { // not the most efficient way, but hey...
  40.     f = fItr.next();
  41.     if (f.key() == selector.lastKey()) { selection.add(f); }
  42.   }
  43.   mesh.modifySelected(new HEM_Extrude().setDistance(50), selection);
  44. }

If a second version of HemeshGui ever sees the light of day, I'll definitely include some more stuff like this, but making HemeshGui was more of a learning process in many ways then a structured route towards something already envisioned. My idea and hope was that releasing that piece of personal code in the spirit of open-source, could be useful to others. You can see a demo of HemeshGui in action here: http://vimeo.com/18055833
It looked as though having two Toxiclibs libraries in the library folder can cause issues. I removed the earlier version, and tried to run the new version in the examples folder.

The previoius error seems to have gone, but am now getting the below in the MeshFaceExtrude example: -

cannot find a class or type named Triangle

... which was pointing to the following line: -

Vec3D centroid = new Triangle(f.a, f.b, f.c).computeCentroid();

Any ideas?


@amnon.owed; thanks for that example, that's really cool :) I really like the library, however think that being able to pull a mesh edge and attached faces will give more of the effect I'm after for my current project.

Good work on the GUI, love it :)
Change it to :
Vec3D centroid = new Triangle3d(f.a, f.b, f.c).computeCentroid();

and it should work. 
Cheers
K
Excellent - thanks, it did work, the d has to be uppper case though, as in Triangle3D

______________________
www.systemarray.com
Sorry to not have replied any sooner... It should be common sense to NEVER have more than one version of a library installed since else you'll run into all sorts of compilation errors caused by version conflicts. The 0020 release has introduced to some small API changes to improve the overall experience and you should ALWAYS trust the bundled examples more than stuff you find online. All bundled examples are always kept updated and so provide reference implementations, but I unfortunately don't have the time to update all 40+ already published examples on OpenProcessing too. If someone would like to volunteer, please get in touch...
Hey there,

No probs. .

The bundled 0020 MeshFaceExtrude example did have the aforementioned new Triangle(...), as opposed to new Triangle3D(...)

Plus thank you very much for the library, am having lots of fun :)


______________________
www.systemarray.com