void renderOutline(Graphics3D g3d) { g3d.glPolygonMode(Graphics3DDraw.GL_FRONT_AND_BACK, Graphics3DDraw.GL_LINE); float radiusProportions = m_config.getRadiusProportions(); IVector3f[] top = m_config.getTopVertices(); IVector3f[] bottom = m_config.getBottomVertices(); // top g3d.glBegin(Graphics3DDraw.GL_LINE_LOOP); g3d.glNormal3f(0, 0, -1); for (int i = 0; i < top.length; i++) g3d.glVertex3f(top[i]); g3d.glEnd(); if (radiusProportions == 0) { // sides g3d.glBegin(Graphics3DDraw.GL_LINES); for (int i = 0; i < top.length; i++) { g3d.glVertex3f(top[i]); g3d.glVertex3f(bottom[0]); } g3d.glEnd(); } else { g3d.glBegin(Graphics3DDraw.GL_LINES); for (int i = 0; i < top.length; i++) { g3d.glVertex3f(top[i]); g3d.glVertex3f(bottom[i]); } g3d.glEnd(); g3d.glBegin(Graphics3DDraw.GL_LINE_LOOP); for (int i = 0; i < bottom.length; i++) g3d.glVertex3f(bottom[i]); g3d.glEnd(); } }
private float getCapDistance(IVector3f i_rayOrigin, IVector3f i_rayDirection) { IVector3f[] bottom = m_config.getBottomVertices(); if (bottom.length > 1) { float d = Math3D.rayIntersectsPolygon( i_rayOrigin, i_rayDirection, bottom, IVector3f.Z_AXIS_NEG, null); if (!Float.isNaN(d)) return d; } IVector3f[] top = m_config.getTopVertices(); return Math3D.rayIntersectsPolygon(i_rayOrigin, i_rayDirection, top, IVector3f.Z_AXIS, null); }
void renderFill(Graphics3D g3d) { g3d.glPolygonMode(Graphics3DDraw.GL_FRONT_AND_BACK, Graphics3DDraw.GL_FILL); float radiusProportions = m_config.getRadiusProportions(); IVector3f[] top = m_config.getTopVertices(); IVector3f[] bottom = m_config.getBottomVertices(); // top g3d.glBegin(Graphics3DDraw.GL_POLYGON); for (int i = 0; i < top.length; i++) g3d.glVertex3f(top[i]); g3d.glEnd(); if (radiusProportions == 0) { // sides g3d.glBegin(Graphics3DDraw.GL_TRIANGLE_FAN); g3d.glVertex3f(bottom[0]); for (int i = top.length - 1; i >= 0; i--) g3d.glVertex3f(top[i]); g3d.glVertex3f(top[top.length - 1]); g3d.glEnd(); } else { g3d.glBegin(Graphics3DDraw.GL_QUAD_STRIP); for (int i = bottom.length - 1; i >= 0; i--) { g3d.glVertex3f(bottom[i]); g3d.glVertex3f(top[i]); } g3d.glVertex3f(bottom[bottom.length - 1]); g3d.glVertex3f(top[top.length - 1]); g3d.glEnd(); // bottom g3d.glBegin(Graphics3DDraw.GL_POLYGON); for (int i = bottom.length - 1; i >= 0; i--) g3d.glVertex3f(bottom[i]); g3d.glEnd(); } }