According to what James wrote here :
http://processing.org/discourse/yabb2/num_1262458611.html#4I 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