views:

208

answers:

1

So I have some path generator which now works like this

http://www.openprocessing.org/visuals/?visualID=2615 (There is source; WQRNING - JAVA APPLET)

I want to create some 3D object using paths I generated so it locked in one of perspectives similar to what I get now in 2D.

So how do I dynamically construct 3D object by adding paths?

BTW: actually I ment algorithm like this http://www.derschmale.com/2009/07/20/slice-based-volume-rendering-using-pixel-bender/

So I want to create from such PATH (I do not want to use images and I do not want to use flash I want to use Java + OpenGl)

alt text

such 3d image (But note I want openGL Java and Path's))

alt text

+1  A: 

Hi Ole,

I'm not sure I understand what you're after.

The example you supplied draws 2d paths, but merely uses z. scaling would have worked in a similar way.

So How to dinamicly construct 3d object by adding path's ?

Do you mean extruding/lathing an object, or replicating the scrunch sketch ?

Drawing a path is easy in processing, you just place vertex objects, in a for loop between beginShape() and endShape() calls.

Here is the bit of code that does that in the example you've sent:

 beginShape(); 
  for (int p=0; p<pcount; p++){ 
    vertex(Ring[p].position().x(),Ring[p].position().y()); 
  } 
  endShape(CLOSE);

you can also call vertex(x,y,z)

I wanted to extrude a path a while back, here is my question in case it helps.

Basic sketch is uploaded here.

EDIT: If you have an array of 2 polygons, you can just loop through them, and draw using something similar to beginShape() and endShape(), GL_POLYGON might be handy.

e.g.

import processing.opengl.*;
import javax.media.opengl.*;

int zSpacing = 10;
PVector[][] slices;

void setup() {
  size(600, 500, OPENGL);

  slices = new PVector[3][3];
  //dummy slice 1
  slices[0][0] = new PVector(400, 200,-200);
  slices[0][1] = new PVector(300, 400,-200);
  slices[0][2] = new PVector(500, 400,-200);
  //dummy slice 2
  slices[1][0] = new PVector(410, 210,-200);
  slices[1][1] = new PVector(310, 410,-200);
  slices[1][2] = new PVector(510, 410,-200);
  //dummy slice 3
  slices[2][0] = new PVector(420, 220,-200);
  slices[2][1] = new PVector(320, 420,-200);
  slices[2][2] = new PVector(520, 420,-200);
}

void draw() {
  background(255);

  PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;  // g may change
  GL gl = pgl.beginGL();  // always use the GL object returned by beginGL

  for(int i = 0 ; i < slices.length; i ++){
    gl.glColor3f(0, .15 * i, 0);
    gl.glBegin(GL.GL_POLYGON);
    for(int j = 0; j < slices[i].length; j++){
      gl.glVertex3f(slices[i][j].x, slices[i][j].y,slices[i][j].z + (zSpacing * i));
    }
    gl.glEnd();
  }
  pgl.endGL();
}

The idea is you loop through each slice, and for each slice your loop through all its points. Obviously slices and the number of 3d vectors inside each slice is up to your data. Speaking of which, where does your data come from ?

If slices is not what your after volTron could come in handy: volTron

HTH, George

George Profenza
actually i ment algorithm like this http://www.derschmale.com/2009/07/20/slice-based-volume-rendering-using-pixel-bender/
Blender