Merge pull request #52 from bkuker/kruland-integration-transition-fix

Fixes and improves 3d rendering of transitions
This commit is contained in:
Bill Kuker 2013-03-31 08:32:27 -07:00
commit f1ef2f39d0
2 changed files with 30 additions and 6 deletions

View File

@ -128,7 +128,7 @@ public class ComponentRenderer {
if (which == Surface.INSIDE) { if (which == Surface.INSIDE) {
gl.glFrontFace(GL.GL_CCW); gl.glFrontFace(GL.GL_CCW);
} }
TransitionRenderer.drawTransition(gl, t, LOD, t.getType() == Shape.CONICAL ? 4 : LOD / 2); TransitionRenderer.drawTransition(gl, t, LOD, t.getType() == Shape.CONICAL ? 4 : LOD / 2, which == Surface.INSIDE ? -t.getThickness() : 0);
if (which == Surface.INSIDE) { if (which == Surface.INSIDE) {
gl.glFrontFace(GL.GL_CW); gl.glFrontFace(GL.GL_CW);
} }
@ -136,8 +136,20 @@ public class ComponentRenderer {
} }
if (which == Surface.EDGES || which == Surface.INSIDE) { if (which == Surface.EDGES || which == Surface.INSIDE) {
//Render aft edge
gl.glPushMatrix();
gl.glTranslated(t.getLength(), 0, 0);
if (which == Surface.EDGES) {
gl.glRotated(90, 0, 1.0, 0);
glu.gluDisk(q, Math.max(0, t.getAftRadius() - t.getThickness()), t.getAftRadius(), LOD, 2);
} else {
gl.glRotated(270, 0, 1.0, 0);
glu.gluDisk(q, Math.max(0, t.getAftRadius() - t.getThickness()), t.getAftRadius(), LOD, 2);
}
gl.glPopMatrix();
// Render AFT shoulder // Render AFT shoulder
{ if (t.getAftShoulderLength() > 0) {
gl.glPushMatrix(); gl.glPushMatrix();
gl.glTranslated(t.getLength(), 0, 0); gl.glTranslated(t.getLength(), 0, 0);
double iR = (t.isFilled() || t.isAftShoulderCapped()) ? 0 : t.getAftShoulderRadius() - t.getAftShoulderThickness(); double iR = (t.isFilled() || t.isAftShoulderCapped()) ? 0 : t.getAftShoulderRadius() - t.getAftShoulderThickness();
@ -159,8 +171,20 @@ public class ComponentRenderer {
gl.glPopMatrix(); gl.glPopMatrix();
} }
//Render Fore edge
gl.glPushMatrix();
gl.glRotated(180, 0, 1.0, 0);
if (which == Surface.EDGES) {
gl.glRotated(90, 0, 1.0, 0);
glu.gluDisk(q, Math.max(0, t.getForeRadius() - t.getThickness()), t.getForeRadius(), LOD, 2);
} else {
gl.glRotated(270, 0, 1.0, 0);
glu.gluDisk(q, Math.max(0, t.getForeRadius() - t.getThickness()), t.getForeRadius(), LOD, 2);
}
gl.glPopMatrix();
// Render Fore shoulder // Render Fore shoulder
{ if (t.getForeShoulderLength() > 0) {
gl.glPushMatrix(); gl.glPushMatrix();
gl.glRotated(180, 0, 1.0, 0); gl.glRotated(180, 0, 1.0, 0);
//gl.glTranslated(t.getLength(), 0, 0); //gl.glTranslated(t.getLength(), 0, 0);

View File

@ -126,7 +126,7 @@ final class TransitionRenderer {
} }
static final void drawTransition(final GL2 gl, final Transition tr, static final void drawTransition(final GL2 gl, final Transition tr,
final int slices, final int stacks) { final int slices, final int stacks, final double offsetRadius) {
double da, r, dzBase; double da, r, dzBase;
double x, y, z, nz, lnz = 0; double x, y, z, nz, lnz = 0;
@ -145,8 +145,8 @@ final class TransitionRenderer {
double dz = t < 0.025 ? dzBase / 8.0 : dzBase; double dz = t < 0.025 ? dzBase / 8.0 : dzBase;
double zNext = Math.min(z + dz, tr.getLength()); double zNext = Math.min(z + dz, tr.getLength());
r = tr.getRadius(z); r = Math.max(0, tr.getRadius(z) + offsetRadius);
double rNext = tr.getRadius(zNext); double rNext = Math.max(0, tr.getRadius(zNext) + offsetRadius);
// Z component of normal vectors // Z component of normal vectors