PDA

View Full Version : adding a 3D cone to a line



Hellcowboy
11-03-2011, 12:08 PM
I have this standard line made in my program
glBegin(GL_LINES);
glColor3f(0.0f, 1.0f, 1.0f);
glVertex3f(Cx,Cy,Cz);
glVertex3f(Nx+Cx,Ny+Cy,Nz+Cz);
glEnd();

The thing is I want to make a cone on the end of the line
from (Nx+Cx,Ny+Cy,Nz+Cz) to (Nx+Cx,Ny+Cy,Nz+Cz)+5 or whatever value makes it looks better so that the lines look like arrows

Kryshard
11-03-2011, 01:34 PM
try this:

gl.glColor3f( 0f,0f,0f);
glu.gluSphere(glu.gluNewQuadric(), 0.002, 10,10);

//x
gl.glRotatef(90,0f,1f,0f);
gl.glColor3d(.6f,.0f,.0f); // x = blue

glu.gluCylinder(glu.gluNewQuadric(), .001, .001, .1, 10, 10); gl.glTranslatef(0,0,.1f); glu.gluCylinder(glu.gluNewQuadric(), .002f, .0f, 0.01f, 10,10);
gl.glTranslatef(0,0,-.1f);
gl.glRotatef(-90,0f,1f,0f);

//y
gl.glRotatef(-90,1f,0f,0f);
gl.glColor3d(0.0f,.6f,.0f); // y = red
glu.gluCylinder(glu.gluNewQuadric(), .001, .001, .1, 10,10); gl.glTranslatef(0,0,.1f); glu.gluCylinder(glu.gluNewQuadric(), .002f, .0f, 0.01f, 10,10);
gl.glTranslatef(0,0,-.1f);
gl.glRotatef(90,1f,0f,0f);

//z
gl.glColor3d(.0f,.0f,.6f); // z = green
glu.gluCylinder(glu.gluNewQuadric(), .001, .001, .1, 10,10); gl.glTranslatef(0,0,.1f); glu.gluCylinder(glu.gluNewQuadric(), .002f, .0f, 0.01f, 10,10);