We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › A decent replacement for line() in 3D
Pages: 1 2 
A decent replacement for line() in 3D (Read 4432 times)
Re: A decent replacement for line() in 3D
Reply #15 - Jan 7th, 2010, 3:18pm
 


Great!

Re: A decent replacement for line() in 3D
Reply #16 - Jan 13th, 2010, 9:42am
 
According to what James wrote here : http://processing.org/discourse/yabb2/num_1262458611.html#4

I need to write whats in pushMatrix into opengl, and i have some problem with it. Can you please help for this one, it souldnt be hard... here is what i did for now

Code:
void drawLine(float x1, float y1, float z1, float x2, float y2, float z2, float weight, color strokeColour){
PVector p1 = new PVector(x1, y1, z1);
PVector p2 = new PVector(x2, y2, z2);
PVector v1 = new PVector(x2-x1, y2-y1, z2-z1);
float rho = sqrt(pow(v1.x,2)+pow(v1.y,2)+pow(v1.z,2));
float phi = acos(v1.z/rho);
float the = atan2(v1.y,v1.x);
v1.mult(0.5);

/*
pushMatrix();
translate(x1,y1,z1);
translate(v1.x, v1.y, v1.z);
rotateZ(the);
rotateY(phi);
noStroke();
fill(0,255,255);
box(weight,weight,p1.dist(p2)*1.2);
popMatrix();
*/

float zval = p1.dist(p2)*0.6;
println(rho + " "+ phi+" "+the);
float rad = radians(120)*weight; //I will draw a 3 faced form instead of a cube

pgl.beginGL();
gl.glPushMatrix();
gl.glTranslatef(x1,y1,z1);
gl.glTranslatef(v1.x, v1.y, v1.z);
gl.glRotatef(the, 0.0, 0.0, 1.0);
gl.glRotatef(phi, 0.0, 1.0, 0.0);
gl.glColor4f( red(strokeColour), green(strokeColour), blue(strokeColour), 1 );
gl.glBegin(GL.GL_QUAD_STRIP);
gl.glVertex3f(rad, -rad, zval);
gl.glVertex3f(rad, -rad, -zval);
gl.glVertex3f(-rad, -rad, zval);
gl.glVertex3f(-rad, -rad, -zval);
gl.glEnd();
gl.glBegin(GL.GL_QUADS);
gl.glVertex3f(-rad, -rad, -zval);
gl.glVertex3f(-rad, -rad, zval);
gl.glVertex3f(0, rad, zval);
gl.glVertex3f(0, rad, -zval);
gl.glEnd();
gl.glBegin(GL.GL_QUADS);
gl.glVertex3f(0, rad, -zval);
gl.glVertex3f(0, rad, zval);
gl.glVertex3f(rad, -rad, zval);
gl.glVertex3f(rad, -rad, -zval);
gl.glEnd();
gl.glPopMatrix();
pgl.endGL();

}


thanks
Re: A decent replacement for line() in 3D
Reply #17 - Jan 20th, 2010, 2:00pm
 
@James: See what quark sent me:

Sender: Quark
To: Chrisir

Subject: Line 3D - done
Date: Yesterday at 8:42am  
Line 3D addition is done; if you download the latest version of Shapes 3D (V1.5.2) it includes an example of creating a Bezier line in 3D.

Enjoy

Pages: 1 2