Merge pull request from SiboVG/issue-969

[fixes ] Added custom left and right appearance for fin set
This commit is contained in:
Billy Olsen 2021-08-14 20:39:19 -07:00 committed by GitHub
commit e558db9bf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 198 additions and 111 deletions
core
resources/l10n
src/net/sf/openrocket
swing/src/net/sf/openrocket/gui

@ -809,10 +809,12 @@ AppearanceCfg.lbl.texture.offset = Offset:
AppearanceCfg.lbl.texture.center = Center: AppearanceCfg.lbl.texture.center = Center:
AppearanceCfg.lbl.texture.rotation = Rotation: AppearanceCfg.lbl.texture.rotation = Rotation:
AppearanceCfg.lbl.texture.repeat = Repeat: AppearanceCfg.lbl.texture.repeat = Repeat:
AppearanceCfg.lbl.InsideSameAsOutside = Same as outside AppearanceCfg.lbl.separateInsideOutside = Use separate appearance for outside and inside
AppearanceCfg.lbl.ttip.InsideSameAsOutside = Use the same appearance for the inside as for the outside AppearanceCfg.lbl.separateLeftSideRightSide = Use separate appearance for left and right side(s)
AppearanceCfg.lbl.EdgesSameAsInside = Use inside appearance for edges AppearanceCfg.lbl.ttip.separateInsideOutside = Use a separate appearance for outside and inside
AppearanceCfg.lbl.ttip.EdgesSameAsInside = Use the inside appearance (checked) or outside appearance (unchecked) for the edges AppearanceCfg.lbl.ttip.separateLeftSideRightSide = Use a separate appearance for left and right side(s)
AppearanceCfg.lbl.AppearanceEdges = Appearance for edges:
AppearanceCfg.lbl.ttip.AppearanceEdges = Select the appearance that should be used for the edges
! Texture Wrap Modes ! Texture Wrap Modes
TextureWrap.Repeat = Repeat TextureWrap.Repeat = Repeat
@ -878,6 +880,8 @@ RocketCompCfg.lbl.InstanceCount = Instance Count
RocketCompCfg.lbl.InstanceSeparation = Instance Separation RocketCompCfg.lbl.InstanceSeparation = Instance Separation
RocketCompCfg.tab.Outside = Outside RocketCompCfg.tab.Outside = Outside
RocketCompCfg.tab.Inside = Inside RocketCompCfg.tab.Inside = Inside
RocketCompCfg.tab.RightSide = Right Side
RocketCompCfg.tab.LeftSide = Left Side
! BulkheadConfig ! BulkheadConfig
BulkheadCfg.tab.Diameter = Diameter: BulkheadCfg.tab.Diameter = Diameter:

@ -30,7 +30,7 @@ public class InsideAppearanceHandler extends AppearanceHandler {
if ("insideSameAsOutside".equals(element)) { if ("insideSameAsOutside".equals(element)) {
boolean insideSameAsOutside = Boolean.parseBoolean(content); boolean insideSameAsOutside = Boolean.parseBoolean(content);
if (component instanceof InsideColorComponent) if (component instanceof InsideColorComponent)
((InsideColorComponent)component).getInsideColorComponentHandler().setInsideSameAsOutside(insideSameAsOutside); ((InsideColorComponent)component).getInsideColorComponentHandler().setSeparateInsideOutside(insideSameAsOutside);
return; return;
} }

@ -58,7 +58,7 @@ public class RocketComponentSaver {
if (ap_in != null) { if (ap_in != null) {
elements.add("<inside-appearance>"); elements.add("<inside-appearance>");
elements.add("<edgesSameAsInside>" + handler.isEdgesSameAsInside() + "</edgesSameAsInside>"); elements.add("<edgesSameAsInside>" + handler.isEdgesSameAsInside() + "</edgesSameAsInside>");
elements.add("<insideSameAsOutside>" + handler.isInsideSameAsOutside() + "</insideSameAsOutside>"); elements.add("<insideSameAsOutside>" + handler.isSeparateInsideOutside() + "</insideSameAsOutside>");
buildAppearanceElements(elements, ap_in); buildAppearanceElements(elements, ap_in);
elements.add("</inside-appearance>"); elements.add("</inside-appearance>");
} }

@ -1,12 +1,13 @@
package net.sf.openrocket.rocketcomponent; package net.sf.openrocket.rocketcomponent;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.util.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import net.sf.openrocket.appearance.Appearance;
import net.sf.openrocket.appearance.Decal;
import net.sf.openrocket.util.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -18,15 +19,10 @@ import net.sf.openrocket.rocketcomponent.position.AxialMethod;
import net.sf.openrocket.rocketcomponent.position.AxialPositionable; import net.sf.openrocket.rocketcomponent.position.AxialPositionable;
import net.sf.openrocket.rocketcomponent.position.RadiusMethod; import net.sf.openrocket.rocketcomponent.position.RadiusMethod;
import net.sf.openrocket.startup.Application; import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.BoundingBox;
import net.sf.openrocket.rocketcomponent.Transition.Shape; import net.sf.openrocket.rocketcomponent.Transition.Shape;
import net.sf.openrocket.util.Coordinate; public abstract class FinSet extends ExternalComponent implements AxialPositionable, BoxBounded, RingInstanceable, InsideColorComponent {
import net.sf.openrocket.util.MathUtil;
import net.sf.openrocket.util.Transformation;
public abstract class FinSet extends ExternalComponent implements AxialPositionable, BoxBounded, RingInstanceable {
private static final Logger log = LoggerFactory.getLogger(FinSet.class); private static final Logger log = LoggerFactory.getLogger(FinSet.class);
private static final Translator trans = Application.getTranslator(); private static final Translator trans = Application.getTranslator();
@ -125,6 +121,8 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
private double singlePlanformArea = Double.NaN; private double singlePlanformArea = Double.NaN;
private double totalVolume = Double.NaN; private double totalVolume = Double.NaN;
private Coordinate centerOfMass = Coordinate.NaN; private Coordinate centerOfMass = Coordinate.NaN;
private final InsideColorComponentHandler insideColorComponentHandler = new InsideColorComponentHandler(this);
/** /**
* New FinSet with given number of fins and given base rotation angle. * New FinSet with given number of fins and given base rotation angle.
@ -1269,4 +1267,9 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
return toReturn; return toReturn;
} }
@Override
public InsideColorComponentHandler getInsideColorComponentHandler() {
return this.insideColorComponentHandler;
}
} }

@ -14,8 +14,8 @@ import java.util.EventObject;
public class InsideColorComponentHandler { public class InsideColorComponentHandler {
private final RocketComponent component; private final RocketComponent component;
private Appearance insideAppearance = null; private Appearance insideAppearance = null;
private boolean insideSameAsOutside = true; private boolean separateInsideOutside = false; // Flag for separate inside and outside appearance
private boolean edgesSameAsInside = true; private boolean edgesSameAsInside = false; // Flag for setting the edge appearance to the inside (true) or outside (false) appearance
public InsideColorComponentHandler(RocketComponent component) { public InsideColorComponentHandler(RocketComponent component) {
this.component = component; this.component = component;
@ -76,22 +76,21 @@ public class InsideColorComponentHandler {
} }
/** /**
* Checks whether the component should use the same appearance for the inside as the outside (return true) or as the * Checks whether the component should use a separate appearance for the inside and outside.
* outside (return false)
* *
* @return true if edges should use the same appearance as the inside, * @return true if a separate inside and outside appearance should be used,
* false if edges should use the same appearance as the outside * false if the inside should have the outside appearance
*/ */
public boolean isInsideSameAsOutside() { public boolean isSeparateInsideOutside() {
return this.insideSameAsOutside; return this.separateInsideOutside;
} }
/** /**
* Sets the new state for insideSameAsOutside to newState * Sets the new state for separateInsideOutside to newState
* *
* @param newState new edgesUseInsideAppearance value * @param newState new separateInsideOutside value
*/ */
public void setInsideSameAsOutside(boolean newState) { public void setSeparateInsideOutside(boolean newState) {
this.insideSameAsOutside = newState; this.separateInsideOutside = newState;
} }
} }

@ -6,7 +6,20 @@ import java.awt.event.ActionListener;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.EventObject; import java.util.EventObject;
import javax.swing.*; import javax.swing.JPanel;
import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.JOptionPane;
import javax.swing.JSpinner;
import javax.swing.JSlider;
import javax.swing.JTabbedPane;
import javax.swing.colorchooser.ColorSelectionModel; import javax.swing.colorchooser.ColorSelectionModel;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
@ -34,6 +47,7 @@ import net.sf.openrocket.gui.util.EditDecalHelper.EditDecalHelperException;
import net.sf.openrocket.gui.util.SwingPreferences; import net.sf.openrocket.gui.util.SwingPreferences;
import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent; import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
import net.sf.openrocket.rocketcomponent.FinSet;
import net.sf.openrocket.rocketcomponent.InsideColorComponent; import net.sf.openrocket.rocketcomponent.InsideColorComponent;
import net.sf.openrocket.rocketcomponent.InsideColorComponentHandler; import net.sf.openrocket.rocketcomponent.InsideColorComponentHandler;
import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.rocketcomponent.RocketComponent;
@ -67,6 +81,10 @@ public class AppearancePanel extends JPanel {
// faster. // faster.
private Appearance defaultAppearance = null; private Appearance defaultAppearance = null;
private JTabbedPane outsideInsidePane = null;
private JCheckBox customInside = null;
/** /**
* A non-unit that adjusts by a small amount, suitable for values that are * A non-unit that adjusts by a small amount, suitable for values that are
* on the 0-1 scale * on the 0-1 scale
@ -303,33 +321,100 @@ public class AppearancePanel extends JPanel {
if (c instanceof InsideColorComponent) { if (c instanceof InsideColorComponent) {
InsideColorComponentHandler handler = ((InsideColorComponent)c).getInsideColorComponentHandler(); InsideColorComponentHandler handler = ((InsideColorComponent)c).getInsideColorComponentHandler();
JTabbedPane tabbedPane = new JTabbedPane(); // Get translator keys
String tr_outside, tr_inside, tr_insideOutside, tr_insideOutside_ttip;
if (c instanceof FinSet) {
tr_outside = "RocketCompCfg.tab.LeftSide";
tr_inside = "RocketCompCfg.tab.RightSide";
tr_insideOutside = "AppearanceCfg.lbl.separateLeftSideRightSide";
tr_insideOutside_ttip = "AppearanceCfg.lbl.ttip.separateLeftSideRightSide";
}
else {
tr_outside = "RocketCompCfg.tab.Outside";
tr_inside = "RocketCompCfg.tab.Inside";
tr_insideOutside = "AppearanceCfg.lbl.separateInsideOutside";
tr_insideOutside_ttip = "AppearanceCfg.lbl.ttip.separateInsideOutside";
}
// Checkbox for using separate outside/inside appearance
BooleanModel b_customInside = new BooleanModel(handler.isSeparateInsideOutside());
this.customInside = new JCheckBox(b_customInside);
customInside.setText(trans.get(tr_insideOutside));
customInside.setToolTipText(trans.get(tr_insideOutside_ttip));
add(customInside, "span 2");
// Checkbox to set edges the same as inside/outside
JPanel edgesPanel = new JPanel(new MigLayout());
JLabel edgesText = new JLabel(trans.get("AppearanceCfg.lbl.AppearanceEdges"));
edgesPanel.add(edgesText);
String[] options = new String[] {trans.get(tr_outside), trans.get(tr_inside)};
JComboBox edgesComboBox = new JComboBox(options);
if (handler.isEdgesSameAsInside()) {
edgesComboBox.setSelectedItem(trans.get(tr_inside));
}
else {
edgesComboBox.setSelectedItem(trans.get(tr_outside));
}
edgesPanel.add(edgesComboBox);
edgesPanel.setToolTipText(trans.get("AppearanceCfg.lbl.ttip.AppearanceEdges"));
add(edgesPanel, "span 2, wrap");
outsideInsidePane = new JTabbedPane();
JPanel outsidePanel = new JPanel(new MigLayout("fill", "[150][grow][150][grow]")); JPanel outsidePanel = new JPanel(new MigLayout("fill", "[150][grow][150][grow]"));
JPanel insidePanel = new JPanel(new MigLayout("fill", "[150][grow][150][grow]")); JPanel insidePanel = new JPanel(new MigLayout("fill", "[150][grow][150][grow]"));
appearanceSection(document, c, false, outsidePanel); appearanceSection(document, c, false, outsidePanel);
appearanceSection(document, c, true, insidePanel); appearanceSection(document, c, true, insidePanel);
tabbedPane.addTab(trans.get("RocketCompCfg.tab.Outside"), null, outsidePanel, outsideInsidePane.addTab(trans.get(tr_outside), null, outsidePanel,
"Outside Tool Tip"); "Outside Tool Tip");
tabbedPane.addTab(trans.get("RocketCompCfg.tab.Inside"), null, insidePanel, outsideInsidePane.addTab(trans.get(tr_inside), null, insidePanel,
"Inside Tool Tip"); "Inside Tool Tip");
add(tabbedPane, "span 4, growx, wrap"); add(outsideInsidePane, "span 4, growx, wrap");
// Checkbox to set edges the same as inside/outside // Show the outside/inside tabbed display when customInside is selected
BooleanModel b = new BooleanModel(handler.isEdgesSameAsInside()); customInside.addActionListener(new ActionListener() {
JCheckBox edges = new JCheckBox(b);
edges.setText(trans.get("AppearanceCfg.lbl.EdgesSameAsInside"));
edges.setToolTipText(trans.get("AppearanceCfg.lbl.ttip.EdgesSameAsInside"));
add(edges, "wrap");
edges.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
handler.setEdgesSameAsInside(edges.isSelected()); handler.setSeparateInsideOutside(customInside.isSelected());
c.fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
if (customInside.isSelected()) {
remove(outsidePanel);
outsideInsidePane.insertTab(trans.get(tr_outside), null, outsidePanel,
"Outside Tool Tip", 0);
outsideInsidePane.setSelectedIndex(0);
add(outsideInsidePane, "span 4, growx, wrap");
}
else {
remove(outsideInsidePane);
add(outsidePanel, "span 4, growx, wrap");
}
edgesText.setEnabled(customInside.isSelected());
edgesComboBox.setEnabled(customInside.isSelected());
updateUI();
}
});
// Change the edge appearance upon item selection
edgesComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (edgesComboBox.getSelectedItem() == null) return;
if (edgesComboBox.getSelectedItem().equals(trans.get(tr_outside))) {
handler.setEdgesSameAsInside(false);
}
else if (edgesComboBox.getSelectedItem().equals(trans.get(tr_inside))) {
handler.setEdgesSameAsInside(true);
}
else {
return;
}
c.fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE); c.fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
} }
}); });
customInside.getActionListeners()[0].actionPerformed(null);
edgesComboBox.getActionListeners()[0].actionPerformed(null);
} }
else else
appearanceSection(document, c, false, this); appearanceSection(document, c, false, this);
@ -402,27 +487,7 @@ public class AppearancePanel extends JPanel {
} }
}); });
materialDefault.setText(trans.get("AppearanceCfg.lbl.Usedefault")); materialDefault.setText(trans.get("AppearanceCfg.lbl.Usedefault"));
if (insideBuilder) panel.add(materialDefault, "wrap");
panel.add(materialDefault);
else
panel.add(materialDefault, "wrap");
// Custom inside color
if (insideBuilder) {
InsideColorComponentHandler handler = ((InsideColorComponent)c).getInsideColorComponentHandler();
BooleanModel b = new BooleanModel(handler.isInsideSameAsOutside());
JCheckBox customInside = new JCheckBox(b);
customInside.setText(trans.get("AppearanceCfg.lbl.InsideSameAsOutside"));
customInside.setToolTipText(trans.get("AppearanceCfg.lbl.ttip.InsideSameAsOutside"));
customInside.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
handler.setInsideSameAsOutside(customInside.isSelected());
c.fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
}
});
panel.add(customInside, "wrap");
}
// Texture File // Texture File
panel.add(new JLabel(trans.get("AppearanceCfg.lbl.Texture"))); panel.add(new JLabel(trans.get("AppearanceCfg.lbl.Texture")));

@ -95,17 +95,21 @@ public class RealisticRenderer extends RocketRenderer {
Appearance app = getAppearance(c); Appearance app = getAppearance(c);
if (c instanceof InsideColorComponent) { if (c instanceof InsideColorComponent) {
Appearance innerApp = getInsideAppearance(c); Appearance innerApp = getInsideAppearance(c);
if (((InsideColorComponent) c).getInsideColorComponentHandler().isInsideSameAsOutside()) innerApp = app; if (!((InsideColorComponent) c).getInsideColorComponentHandler().isSeparateInsideOutside()) {
innerApp = app;
}
render(gl, geom, Surface.INSIDE, innerApp, true, alpha); render(gl, geom, Surface.INSIDE, innerApp, true, alpha);
if (((InsideColorComponent) c).getInsideColorComponentHandler().isEdgesSameAsInside()) if (((InsideColorComponent) c).getInsideColorComponentHandler().isEdgesSameAsInside()) {
render(gl, geom, Surface.EDGES, innerApp, false, alpha); render(gl, geom, Surface.EDGES, innerApp, true, alpha);
else }
render(gl, geom, Surface.EDGES, app, false, alpha); else {
render(gl, geom, Surface.EDGES, app, true, alpha);
}
} }
else { else {
render(gl, geom, Surface.INSIDE, app, true, alpha); render(gl, geom, Surface.INSIDE, app, true, alpha);
render(gl, geom, Surface.EDGES, app, false, alpha); render(gl, geom, Surface.EDGES, app, true, alpha);
} }
render(gl, geom, Surface.OUTSIDE, app, true, alpha); render(gl, geom, Surface.OUTSIDE, app, true, alpha);

@ -112,9 +112,7 @@ public class ComponentRenderer {
renderMassObject(gl, (MassObject) c); renderMassObject(gl, (MassObject) c);
} else if (c instanceof FinSet) { } else if (c instanceof FinSet) {
FinSet fins = (FinSet) c; FinSet fins = (FinSet) c;
if (which == Surface.OUTSIDE) { fr.renderFinSet(gl, fins, which);
fr.renderFinSet(gl, fins);
}
} else if (c instanceof TubeFinSet) { } else if (c instanceof TubeFinSet) {
renderTubeFins( gl, (TubeFinSet) c, which); renderTubeFins( gl, (TubeFinSet) c, which);
} else if ( c instanceof AxialStage ) { } else if ( c instanceof AxialStage ) {

@ -11,18 +11,26 @@ import com.jogamp.opengl.glu.GLUtessellatorCallbackAdapter;
import net.sf.openrocket.rocketcomponent.EllipticalFinSet; import net.sf.openrocket.rocketcomponent.EllipticalFinSet;
import net.sf.openrocket.rocketcomponent.FinSet; import net.sf.openrocket.rocketcomponent.FinSet;
import net.sf.openrocket.rocketcomponent.InsideColorComponent;
import net.sf.openrocket.util.BoundingBox; import net.sf.openrocket.util.BoundingBox;
import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.Coordinate;
import net.sf.openrocket.gui.figure3d.geometry.Geometry.Surface;
public class FinRenderer { public class FinRenderer {
private GLUtessellator tobj = GLU.gluNewTess(); private GLUtessellator tobj = GLU.gluNewTess();
public void renderFinSet(final GL2 gl, FinSet finSet ) { public void renderFinSet(final GL2 gl, FinSet finSet, Surface which) {
BoundingBox bounds = finSet.getInstanceBoundingBox(); BoundingBox bounds = finSet.getInstanceBoundingBox();
gl.glMatrixMode(GL.GL_TEXTURE); gl.glMatrixMode(GL.GL_TEXTURE);
gl.glPushMatrix(); gl.glPushMatrix();
gl.glScaled(1 / (bounds.max.x - bounds.min.x), 1 / (bounds.max.y - bounds.min.y), 0); // Mirror the right side fin texture to avoid e.g. mirrored decal text
if (which == Surface.INSIDE && ((InsideColorComponent) finSet).getInsideColorComponentHandler().isSeparateInsideOutside()) {
gl.glScaled(-1 / (bounds.max.x - bounds.min.x), 1 / (bounds.max.y - bounds.min.y), 0);
}
else {
gl.glScaled(1 / (bounds.max.x - bounds.min.x), 1 / (bounds.max.y - bounds.min.y), 0);
}
gl.glTranslated(-bounds.min.x, -bounds.min.y - finSet.getBodyRadius(), 0); gl.glTranslated(-bounds.min.x, -bounds.min.y - finSet.getBodyRadius(), 0);
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
@ -61,51 +69,57 @@ public class FinRenderer {
GLU.gluTessCallback(tobj, GLU.GLU_TESS_END, cb); GLU.gluTessCallback(tobj, GLU.GLU_TESS_END, cb);
// fin side: +z // fin side: +z
GLU.gluTessBeginPolygon(tobj, null); if (which == Surface.INSIDE) { // Right side
GLU.gluTessBeginContour(tobj); GLU.gluTessBeginPolygon(tobj, null);
gl.glNormal3f(0, 0, 1); GLU.gluTessBeginContour(tobj);
for (int i = finPoints.length - 1; i >= 0; i--) { gl.glNormal3f(0, 0, 1);
Coordinate c = finPoints[i]; for (int i = finPoints.length - 1; i >= 0; i--) {
double[] p = new double[] { c.x, c.y + finSet.getBodyRadius(), Coordinate c = finPoints[i];
c.z + finSet.getThickness() / 2.0 }; double[] p = new double[]{c.x, c.y + finSet.getBodyRadius(),
GLU.gluTessVertex(tobj, p, 0, p); c.z + finSet.getThickness() / 2.0};
GLU.gluTessVertex(tobj, p, 0, p);
}
GLU.gluTessEndContour(tobj);
GLU.gluTessEndPolygon(tobj);
} }
GLU.gluTessEndContour(tobj);
GLU.gluTessEndPolygon(tobj);
// fin side: -z // fin side: -z
GLU.gluTessBeginPolygon(tobj, null); if (which == Surface.OUTSIDE) { // Left side
GLU.gluTessBeginContour(tobj); GLU.gluTessBeginPolygon(tobj, null);
gl.glNormal3f(0, 0, -1); GLU.gluTessBeginContour(tobj);
for (int i = 0; i < finPoints.length; i++) { gl.glNormal3f(0, 0, -1);
Coordinate c = finPoints[i]; for (int i = 0; i < finPoints.length; i++) {
double[] p = new double[] { c.x, c.y + finSet.getBodyRadius(), Coordinate c = finPoints[i];
c.z - finSet.getThickness() / 2.0 }; double[] p = new double[]{c.x, c.y + finSet.getBodyRadius(),
GLU.gluTessVertex(tobj, p, 0, p); c.z - finSet.getThickness() / 2.0};
GLU.gluTessVertex(tobj, p, 0, p);
}
GLU.gluTessEndContour(tobj);
GLU.gluTessEndPolygon(tobj);
} }
GLU.gluTessEndContour(tobj);
GLU.gluTessEndPolygon(tobj);
// Strip around the edge // Strip around the edge
if (!(finSet instanceof EllipticalFinSet)) if (which == Surface.EDGES) {
gl.glShadeModel(GLLightingFunc.GL_FLAT); if (!(finSet instanceof EllipticalFinSet))
gl.glBegin(GL.GL_TRIANGLE_STRIP); gl.glShadeModel(GLLightingFunc.GL_FLAT);
for (int i = 0; i <= finPoints.length; i++) { gl.glBegin(GL.GL_TRIANGLE_STRIP);
Coordinate c = finPoints[i % finPoints.length]; for (int i = 0; i <= finPoints.length; i++) {
// if ( i > 1 ){ Coordinate c = finPoints[i % finPoints.length];
Coordinate c2 = finPoints[(i - 1 + finPoints.length) // if ( i > 1 ){
% finPoints.length]; Coordinate c2 = finPoints[(i - 1 + finPoints.length)
gl.glNormal3d(c2.y - c.y, c.x - c2.x, 0); % finPoints.length];
// } gl.glNormal3d(c2.y - c.y, c.x - c2.x, 0);
gl.glTexCoord2d(c.x, c.y + finSet.getBodyRadius()); // }
gl.glVertex3d(c.x, c.y + finSet.getBodyRadius(), gl.glTexCoord2d(c.x, c.y + finSet.getBodyRadius());
c.z - finSet.getThickness() / 2.0); gl.glVertex3d(c.x, c.y + finSet.getBodyRadius(),
gl.glVertex3d(c.x, c.y + finSet.getBodyRadius(), c.z - finSet.getThickness() / 2.0);
c.z + finSet.getThickness() / 2.0); gl.glVertex3d(c.x, c.y + finSet.getBodyRadius(),
c.z + finSet.getThickness() / 2.0);
}
gl.glEnd();
} }
gl.glEnd();
if (!(finSet instanceof EllipticalFinSet)) if (!(finSet instanceof EllipticalFinSet))
gl.glShadeModel(GLLightingFunc.GL_SMOOTH); gl.glShadeModel(GLLightingFunc.GL_SMOOTH);