Skip to content

Instantly share code, notes, and snippets.

@jeonghopark
Last active December 21, 2016 11:34
Show Gist options
  • Select an option

  • Save jeonghopark/e37835b40194ab2015d6f03e3ccdb466 to your computer and use it in GitHub Desktop.

Select an option

Save jeonghopark/e37835b40194ab2015d6f03e3ccdb466 to your computer and use it in GitHub Desktop.

Revisions

  1. jeonghopark revised this gist Dec 21, 2016. 1 changed file with 4 additions and 7 deletions.
    11 changes: 4 additions & 7 deletions mesh_trianglestrip.pde
    Original file line number Diff line number Diff line change
    @@ -14,15 +14,15 @@ FloatList movingV = new FloatList();

    void setup() {
    size(800, 500, P3D);

    camera = new PeasyCam(this, 400);

    meshStrip = createShape();

    for (int i=0; i<meshNUM; i++) {
    meshPos.add(new PVector( i * xStep, 0, 0) );
    }

    meshStrip.beginShape(TRIANGLE_STRIP);
    meshStrip.stroke(0, 40);
    for (int i=0; i<meshPos.size(); i++) {
    @@ -37,7 +37,6 @@ void setup() {
    void draw() {
    background(120);


    for (int i=0; i<meshStrip.getVertexCount(); i+=1) {
    movingV.set(i, sin(radians(i * 360.0/meshStrip.getVertexCount() + frameCount * 2)) * 30);
    PVector _v = new PVector(meshStrip.getVertex(i).x, meshStrip.getVertex(i).y, movingV.get(i));
    @@ -48,6 +47,4 @@ void draw() {

    shape(meshStrip, 0, 0);



    }
  2. jeonghopark revised this gist Dec 21, 2016. 1 changed file with 23 additions and 2 deletions.
    25 changes: 23 additions & 2 deletions mesh_trianglestrip.pde
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    import peasy.*;

    PeasyCam camera;

    ArrayList<PVector> meshPos = new ArrayList();

    float xStep = 20;
    @@ -6,27 +10,44 @@ int meshNUM = 20;

    PShape meshStrip;

    FloatList movingV = new FloatList();

    void setup() {
    size(800, 500, P3D);

    camera = new PeasyCam(this, 400);

    meshStrip = createShape();

    for (int i=0; i<meshNUM; i++) {
    meshPos.add(new PVector( i * xStep, 0, 0) );
    }

    meshStrip.beginShape(TRIANGLE_STRIP);
    meshStrip.stroke(0, 40);
    for (int i=0; i<meshPos.size(); i++) {
    meshStrip.vertex(meshPos.get(i).x, meshPos.get(i).y, meshPos.get(i).z);
    meshStrip.vertex(meshPos.get(i).x, meshPos.get(i).y + yStep, meshPos.get(i).z);
    meshStrip.vertex(meshPos.get(i).x, meshPos.get(i).y + yStep, meshPos.get(i).z);
    }
    meshStrip.endShape(CLOSE);

    }


    void draw() {
    background(120);


    translate(width * 0.5 - xStep * meshNUM * 0.5, height * 0.5);
    for (int i=0; i<meshStrip.getVertexCount(); i+=1) {
    movingV.set(i, sin(radians(i * 360.0/meshStrip.getVertexCount() + frameCount * 2)) * 30);
    PVector _v = new PVector(meshStrip.getVertex(i).x, meshStrip.getVertex(i).y, movingV.get(i));
    meshStrip.setVertex(i, _v);
    }

    translate(-xStep * meshNUM * 0.5, 0);

    shape(meshStrip, 0, 0);



    }
  3. jeonghopark revised this gist Dec 21, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions mesh_trianglestrip.pde
    Original file line number Diff line number Diff line change
    @@ -27,5 +27,6 @@ void setup() {
    void draw() {
    background(120);

    translate(width * 0.5 - xStep * meshNUM * 0.5, height * 0.5);
    shape(meshStrip, 0, 0);
    }
  4. jeonghopark revised this gist Dec 21, 2016. 1 changed file with 16 additions and 11 deletions.
    27 changes: 16 additions & 11 deletions mesh_trianglestrip.pde
    Original file line number Diff line number Diff line change
    @@ -4,23 +4,28 @@ float xStep = 20;
    float yStep = 20;
    int meshNUM = 20;

    PShape meshStrip;

    void setup() {
    size(800, 500, P3D);


    meshStrip = createShape();

    for (int i=0; i<meshNUM; i++) {
    meshPos.add(new PVector( i * xStep, 0, 0) );
    meshPos.add(new PVector( i * xStep, 0, 0) );
    }

    meshStrip.beginShape(TRIANGLE_STRIP);
    for (int i=0; i<meshPos.size(); i++) {
    meshStrip.vertex(meshPos.get(i).x, meshPos.get(i).y, meshPos.get(i).z);
    meshStrip.vertex(meshPos.get(i).x, meshPos.get(i).y + yStep, meshPos.get(i).z);
    }
    meshStrip.endShape(CLOSE);
    }


    void draw() {
    background(120);

    beginShape(TRIANGLE_STRIP);
    for (int i=0; i<meshPos.size(); i++) {
    vertex(meshPos.get(i).x, meshPos.get(i).y, meshPos.get(i).z);
    vertex(meshPos.get(i).x, meshPos.get(i).y + yStep, meshPos.get(i).z);
    }
    endShape(CLOSE);

    }

    shape(meshStrip, 0, 0);
    }
  5. jeonghopark revised this gist Dec 21, 2016. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions mesh_trianglestrip.pde
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,14 @@
    ArrayList<PVector> meshPos = new ArrayList();

    float xStep = 20;
    float yStep = 20;
    int meshNUM = 20;

    void setup() {
    size(800, 500, P3D);

    for (int i=0; i<20; i++) {
    meshPos.add(new PVector( i * 10, 0, 0) );
    for (int i=0; i<meshNUM; i++) {
    meshPos.add(new PVector( i * xStep, 0, 0) );
    }
    }

    @@ -15,7 +19,7 @@ void draw() {
    beginShape(TRIANGLE_STRIP);
    for (int i=0; i<meshPos.size(); i++) {
    vertex(meshPos.get(i).x, meshPos.get(i).y, meshPos.get(i).z);
    vertex(meshPos.get(i).x, meshPos.get(i).y + 20, meshPos.get(i).z);
    vertex(meshPos.get(i).x, meshPos.get(i).y + yStep, meshPos.get(i).z);
    }
    endShape(CLOSE);

  6. jeonghopark created this gist Dec 21, 2016.
    22 changes: 22 additions & 0 deletions mesh_trianglestrip.pde
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    ArrayList<PVector> meshPos = new ArrayList();

    void setup() {
    size(800, 500, P3D);

    for (int i=0; i<20; i++) {
    meshPos.add(new PVector( i * 10, 0, 0) );
    }
    }


    void draw() {
    background(120);

    beginShape(TRIANGLE_STRIP);
    for (int i=0; i<meshPos.size(); i++) {
    vertex(meshPos.get(i).x, meshPos.get(i).y, meshPos.get(i).z);
    vertex(meshPos.get(i).x, meshPos.get(i).y + 20, meshPos.get(i).z);
    }
    endShape(CLOSE);

    }