How to dynamically build a 3D object by adding paths? (Java, OpenGL)

So, I have a path generator that now works like this

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

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

So, how do I dynamically build a 3D object by adding paths?

By the way: actually I mean an 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 a three-dimensional image (but note, I want openGL Java and Path's))

alt text

+3
source share
1 answer

I'm not sure I understand what you need.

The above example draws 2d paths, but just uses z. scaling would work the same way.

So, how to dynamically build a 3d object by adding a path?

Do you mean extruding / cropping an object or replicating thumbnail screenshots?

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

Here is a bit of code that does this in the example you sent:

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

(x, y, z)

, question, .

.

EDIT: , - beginShape() endShape(), GL_POLYGON .

.

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();
}

, , . , . , ?

, volTron: volTron http://dm.ncl.ac.uk/joescully/voltronlib/images/s2.jpg

,

+1

Source: https://habr.com/ru/post/1733742/


All Articles