Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Confluence
For you

Programming
Results will update as you type.
  • Tiling and Repetition
  • Reactors
    • Simple Reactor
    • Vector Fields
    • Bitmap or SVG Permutations
    • (Extra) Curve Reactor
    • Lesson 2.4 - Exercises
    • 3D Reactors
  • Programming Basics: Parametric and Generative Graphic Design 2016
  • Archive
  • High Scores
  • Artificial Neural Network
  • Alternatives to the Processing IDE
  • p5.js Programming
  • Programming in Processing (java)

    Two hearts overlapped with each other
    Welcome back
    Catch up on the top discussions and highlights from your team.
    /
    3D Reactors
    Published Jan 07, 2020

    3D Reactors

     

    It’s possible to export 3D geometry suitable for 3D printing with the objectExport library from nervous system.

    import peasy.PeasyCam; import nervoussystem.obj.*; PeasyCam cam; boolean record = false; void setup() { size(1000, 1000, P3D); cam = new PeasyCam(this, 400); lights(); stroke(50); } void draw() { background(0); if (record) { beginRecord("nervoussystem.obj.OBJExport", "filename.obj"); } pushMatrix(); PVector Reactor = new PVector(mouseX-width/2, mouseY-height/2); for (int x = -5; x<=5; x++) { for (int y = -5; y<=5; y++) { PVector midPoint = new PVector(x*100, y*100); midPoint.sub(Reactor); float dist = midPoint.mag()*.1; pushMatrix(); translate(x*100, y*100, dist); sphere(dist); popMatrix(); } } popMatrix(); if (record) { endRecord(); record = false; } } void keyPressed() { if (key == 'r') { record = true; } }

     

    Here is a more advanced example with constructed polygon forms.

     

    import peasy.PeasyCam; import nervoussystem.obj.*; PeasyCam cam; boolean record = false; void setup() { size(1000, 1000, P3D); cam = new PeasyCam(this, 400); } void draw() { background(0); if (record) { beginRecord("nervoussystem.obj.OBJExport", "filename.obj"); } stroke(100); pushMatrix(); PVector Reactor = new PVector(mouseX-width/2, mouseY-height/2); for (int x = -500; x<=500; x+= 200) { for (int y = -500; y<=500; y+= 200) { PVector midPoint = new PVector(x, y); midPoint.sub(Reactor); midPoint.normalize(); midPoint.mult(300); midPoint.rotate(radians(dist(x,y,Reactor.x,Reactor.y)/10)); midPoint.z = 200;// all pyramids are the same height Pyramid(x, y, midPoint); } } popMatrix(); if (record) { endRecord(); record = false; } } void Pyramid(float x, float y, PVector Point) { pushMatrix(); translate(x, y, 0); beginShape(TRIANGLES); //side A vertex(-100, -100, -100); vertex( 100, -100, -100); vertex(Point.x, Point.y, Point.z); //side B vertex( 100, -100, -100); vertex( 100, 100, -100); vertex(Point.x, Point.y, Point.z); //side C vertex( 100, 100, -100); vertex(-100, 100, -100); vertex(Point.x, Point.y, Point.z); //side D vertex(-100, 100, -100); vertex(-100, -100, -100); vertex(Point.x, Point.y, Point.z); endShape(CLOSE); // pyramid base beginShape(TRIANGLE_STRIP); vertex(-100, -100, -100); vertex(100, -100, -100); vertex( -100, 100, -100); vertex( 100, 100, -100); endShape(CLOSE); popMatrix(); } void keyPressed() { if (key == 'r') { record = true; } }

     

    Related content
    Reactors
    Reactors
    Luke Franzke
    p5.js Reactors
    p5.js Reactors
    Luke Franzke
    (Extra) Curve Reactor
    (Extra) Curve Reactor
    Luke Franzke
    p5.js Simple Reactor
    p5.js Simple Reactor
    Luke Franzke
    p5.js Particle System
    p5.js Particle System
    paulina.zybinska (Unlicensed)
    Spatial Interaction FS2016
    Spatial Interaction FS2016
    Joël Gähwiler (Unlicensed)
    {"serverDuration": 64, "requestCorrelationId": "7dd55c846e914ece8dabb23055417292"}