1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
float t=1f; //Epaisseur
float distance = (float)Math.sqrt(Math.pow((double)x1 - x2,2d) +
Math.pow((double)y1 - y2,2d) +
Math.pow((double)z1 - z2,2d));
double anglez = Math.atan2(y2 - y1, x2 - x1);
gl.glPushMatrix();
gl.glTranslatef(x1+(float)Math.cos(anglez)*distance/2f, y1+(float)Math.sin(anglez)*distance/2f, 1);
gl.glRotatef((float)Math.toDegrees(anglez), 0, 0, 1);
gl.glScalef(distance/2f, t, 0f);
gl.glBegin(GL.GL_TRIANGLE_STRIP);
gl.glVertex3f(1, 1, 0);
gl.glVertex3f(-1, 1,0);
gl.glVertex3f(1, -1, 0);
gl.glVertex3f(-1,-1, 0);
gl.glEnd();
gl.glPopMatrix(); |