Merge pull request #973 from SiboVG/issue-969
[fixes #969] Added custom left and right appearance for fin set
This commit is contained in:
commit
e558db9bf8
@ -809,10 +809,12 @@ AppearanceCfg.lbl.texture.offset = Offset:
|
||||
AppearanceCfg.lbl.texture.center = Center:
|
||||
AppearanceCfg.lbl.texture.rotation = Rotation:
|
||||
AppearanceCfg.lbl.texture.repeat = Repeat:
|
||||
AppearanceCfg.lbl.InsideSameAsOutside = Same as outside
|
||||
AppearanceCfg.lbl.ttip.InsideSameAsOutside = Use the same appearance for the inside as for the outside
|
||||
AppearanceCfg.lbl.EdgesSameAsInside = Use inside appearance for edges
|
||||
AppearanceCfg.lbl.ttip.EdgesSameAsInside = Use the inside appearance (checked) or outside appearance (unchecked) for the edges
|
||||
AppearanceCfg.lbl.separateInsideOutside = Use separate appearance for outside and inside
|
||||
AppearanceCfg.lbl.separateLeftSideRightSide = Use separate appearance for left and right side(s)
|
||||
AppearanceCfg.lbl.ttip.separateInsideOutside = Use a separate appearance for outside and inside
|
||||
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
|
||||
TextureWrap.Repeat = Repeat
|
||||
@ -878,6 +880,8 @@ RocketCompCfg.lbl.InstanceCount = Instance Count
|
||||
RocketCompCfg.lbl.InstanceSeparation = Instance Separation
|
||||
RocketCompCfg.tab.Outside = Outside
|
||||
RocketCompCfg.tab.Inside = Inside
|
||||
RocketCompCfg.tab.RightSide = Right Side
|
||||
RocketCompCfg.tab.LeftSide = Left Side
|
||||
|
||||
! BulkheadConfig
|
||||
BulkheadCfg.tab.Diameter = Diameter:
|
||||
|
@ -30,7 +30,7 @@ public class InsideAppearanceHandler extends AppearanceHandler {
|
||||
if ("insideSameAsOutside".equals(element)) {
|
||||
boolean insideSameAsOutside = Boolean.parseBoolean(content);
|
||||
if (component instanceof InsideColorComponent)
|
||||
((InsideColorComponent)component).getInsideColorComponentHandler().setInsideSameAsOutside(insideSameAsOutside);
|
||||
((InsideColorComponent)component).getInsideColorComponentHandler().setSeparateInsideOutside(insideSameAsOutside);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class RocketComponentSaver {
|
||||
if (ap_in != null) {
|
||||
elements.add("<inside-appearance>");
|
||||
elements.add("<edgesSameAsInside>" + handler.isEdgesSameAsInside() + "</edgesSameAsInside>");
|
||||
elements.add("<insideSameAsOutside>" + handler.isInsideSameAsOutside() + "</insideSameAsOutside>");
|
||||
elements.add("<insideSameAsOutside>" + handler.isSeparateInsideOutside() + "</insideSameAsOutside>");
|
||||
buildAppearanceElements(elements, ap_in);
|
||||
elements.add("</inside-appearance>");
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
package net.sf.openrocket.rocketcomponent;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.*;
|
||||
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.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.RadiusMethod;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.BoundingBox;
|
||||
|
||||
import net.sf.openrocket.rocketcomponent.Transition.Shape;
|
||||
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.MathUtil;
|
||||
import net.sf.openrocket.util.Transformation;
|
||||
|
||||
public abstract class FinSet extends ExternalComponent implements AxialPositionable, BoxBounded, RingInstanceable {
|
||||
public abstract class FinSet extends ExternalComponent implements AxialPositionable, BoxBounded, RingInstanceable, InsideColorComponent {
|
||||
private static final Logger log = LoggerFactory.getLogger(FinSet.class);
|
||||
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 totalVolume = Double.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.
|
||||
@ -1269,4 +1267,9 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InsideColorComponentHandler getInsideColorComponentHandler() {
|
||||
return this.insideColorComponentHandler;
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ import java.util.EventObject;
|
||||
public class InsideColorComponentHandler {
|
||||
private final RocketComponent component;
|
||||
private Appearance insideAppearance = null;
|
||||
private boolean insideSameAsOutside = true;
|
||||
private boolean edgesSameAsInside = true;
|
||||
private boolean separateInsideOutside = false; // Flag for separate inside and outside appearance
|
||||
private boolean edgesSameAsInside = false; // Flag for setting the edge appearance to the inside (true) or outside (false) appearance
|
||||
|
||||
public InsideColorComponentHandler(RocketComponent 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
|
||||
* outside (return false)
|
||||
* Checks whether the component should use a separate appearance for the inside and outside.
|
||||
*
|
||||
* @return true if edges should use the same appearance as the inside,
|
||||
* false if edges should use the same appearance as the outside
|
||||
* @return true if a separate inside and outside appearance should be used,
|
||||
* false if the inside should have the outside appearance
|
||||
*/
|
||||
public boolean isInsideSameAsOutside() {
|
||||
return this.insideSameAsOutside;
|
||||
public boolean isSeparateInsideOutside() {
|
||||
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) {
|
||||
this.insideSameAsOutside = newState;
|
||||
public void setSeparateInsideOutside(boolean newState) {
|
||||
this.separateInsideOutside = newState;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,20 @@ import java.awt.event.ActionListener;
|
||||
import java.lang.reflect.Method;
|
||||
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.event.ChangeEvent;
|
||||
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.l10n.Translator;
|
||||
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
||||
import net.sf.openrocket.rocketcomponent.FinSet;
|
||||
import net.sf.openrocket.rocketcomponent.InsideColorComponent;
|
||||
import net.sf.openrocket.rocketcomponent.InsideColorComponentHandler;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
@ -67,6 +81,10 @@ public class AppearancePanel extends JPanel {
|
||||
// faster.
|
||||
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
|
||||
* on the 0-1 scale
|
||||
@ -303,33 +321,100 @@ public class AppearancePanel extends JPanel {
|
||||
if (c instanceof InsideColorComponent) {
|
||||
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 insidePanel = new JPanel(new MigLayout("fill", "[150][grow][150][grow]"));
|
||||
|
||||
appearanceSection(document, c, false, outsidePanel);
|
||||
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");
|
||||
tabbedPane.addTab(trans.get("RocketCompCfg.tab.Inside"), null, insidePanel,
|
||||
outsideInsidePane.addTab(trans.get(tr_inside), null, insidePanel,
|
||||
"Inside Tool Tip");
|
||||
add(tabbedPane, "span 4, growx, wrap");
|
||||
add(outsideInsidePane, "span 4, growx, wrap");
|
||||
|
||||
// Checkbox to set edges the same as inside/outside
|
||||
BooleanModel b = new BooleanModel(handler.isEdgesSameAsInside());
|
||||
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() {
|
||||
// Show the outside/inside tabbed display when customInside is selected
|
||||
customInside.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
customInside.getActionListeners()[0].actionPerformed(null);
|
||||
edgesComboBox.getActionListeners()[0].actionPerformed(null);
|
||||
}
|
||||
else
|
||||
appearanceSection(document, c, false, this);
|
||||
@ -402,27 +487,7 @@ public class AppearancePanel extends JPanel {
|
||||
}
|
||||
});
|
||||
materialDefault.setText(trans.get("AppearanceCfg.lbl.Usedefault"));
|
||||
if (insideBuilder)
|
||||
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");
|
||||
}
|
||||
panel.add(materialDefault, "wrap");
|
||||
|
||||
// Texture File
|
||||
panel.add(new JLabel(trans.get("AppearanceCfg.lbl.Texture")));
|
||||
|
@ -95,17 +95,21 @@ public class RealisticRenderer extends RocketRenderer {
|
||||
Appearance app = getAppearance(c);
|
||||
if (c instanceof InsideColorComponent) {
|
||||
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);
|
||||
if (((InsideColorComponent) c).getInsideColorComponentHandler().isEdgesSameAsInside())
|
||||
render(gl, geom, Surface.EDGES, innerApp, false, alpha);
|
||||
else
|
||||
render(gl, geom, Surface.EDGES, app, false, alpha);
|
||||
if (((InsideColorComponent) c).getInsideColorComponentHandler().isEdgesSameAsInside()) {
|
||||
render(gl, geom, Surface.EDGES, innerApp, true, alpha);
|
||||
}
|
||||
else {
|
||||
render(gl, geom, Surface.EDGES, app, true, alpha);
|
||||
}
|
||||
}
|
||||
else {
|
||||
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);
|
||||
|
||||
|
@ -112,9 +112,7 @@ public class ComponentRenderer {
|
||||
renderMassObject(gl, (MassObject) c);
|
||||
} else if (c instanceof FinSet) {
|
||||
FinSet fins = (FinSet) c;
|
||||
if (which == Surface.OUTSIDE) {
|
||||
fr.renderFinSet(gl, fins);
|
||||
}
|
||||
fr.renderFinSet(gl, fins, which);
|
||||
} else if (c instanceof TubeFinSet) {
|
||||
renderTubeFins( gl, (TubeFinSet) c, which);
|
||||
} 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.FinSet;
|
||||
import net.sf.openrocket.rocketcomponent.InsideColorComponent;
|
||||
import net.sf.openrocket.util.BoundingBox;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.gui.figure3d.geometry.Geometry.Surface;
|
||||
|
||||
public class FinRenderer {
|
||||
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();
|
||||
gl.glMatrixMode(GL.GL_TEXTURE);
|
||||
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.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
|
||||
|
||||
@ -61,51 +69,57 @@ public class FinRenderer {
|
||||
GLU.gluTessCallback(tobj, GLU.GLU_TESS_END, cb);
|
||||
|
||||
// fin side: +z
|
||||
GLU.gluTessBeginPolygon(tobj, null);
|
||||
GLU.gluTessBeginContour(tobj);
|
||||
gl.glNormal3f(0, 0, 1);
|
||||
for (int i = finPoints.length - 1; i >= 0; i--) {
|
||||
Coordinate c = finPoints[i];
|
||||
double[] p = new double[] { c.x, c.y + finSet.getBodyRadius(),
|
||||
c.z + finSet.getThickness() / 2.0 };
|
||||
GLU.gluTessVertex(tobj, p, 0, p);
|
||||
|
||||
if (which == Surface.INSIDE) { // Right side
|
||||
GLU.gluTessBeginPolygon(tobj, null);
|
||||
GLU.gluTessBeginContour(tobj);
|
||||
gl.glNormal3f(0, 0, 1);
|
||||
for (int i = finPoints.length - 1; i >= 0; i--) {
|
||||
Coordinate c = finPoints[i];
|
||||
double[] p = new double[]{c.x, c.y + finSet.getBodyRadius(),
|
||||
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
|
||||
GLU.gluTessBeginPolygon(tobj, null);
|
||||
GLU.gluTessBeginContour(tobj);
|
||||
gl.glNormal3f(0, 0, -1);
|
||||
for (int i = 0; i < finPoints.length; i++) {
|
||||
Coordinate c = finPoints[i];
|
||||
double[] p = new double[] { c.x, c.y + finSet.getBodyRadius(),
|
||||
c.z - finSet.getThickness() / 2.0 };
|
||||
GLU.gluTessVertex(tobj, p, 0, p);
|
||||
|
||||
if (which == Surface.OUTSIDE) { // Left side
|
||||
GLU.gluTessBeginPolygon(tobj, null);
|
||||
GLU.gluTessBeginContour(tobj);
|
||||
gl.glNormal3f(0, 0, -1);
|
||||
for (int i = 0; i < finPoints.length; i++) {
|
||||
Coordinate c = finPoints[i];
|
||||
double[] p = new double[]{c.x, c.y + finSet.getBodyRadius(),
|
||||
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
|
||||
if (!(finSet instanceof EllipticalFinSet))
|
||||
gl.glShadeModel(GLLightingFunc.GL_FLAT);
|
||||
gl.glBegin(GL.GL_TRIANGLE_STRIP);
|
||||
for (int i = 0; i <= finPoints.length; i++) {
|
||||
Coordinate c = finPoints[i % finPoints.length];
|
||||
// if ( i > 1 ){
|
||||
Coordinate c2 = finPoints[(i - 1 + finPoints.length)
|
||||
% 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(),
|
||||
c.z - finSet.getThickness() / 2.0);
|
||||
gl.glVertex3d(c.x, c.y + finSet.getBodyRadius(),
|
||||
c.z + finSet.getThickness() / 2.0);
|
||||
if (which == Surface.EDGES) {
|
||||
if (!(finSet instanceof EllipticalFinSet))
|
||||
gl.glShadeModel(GLLightingFunc.GL_FLAT);
|
||||
gl.glBegin(GL.GL_TRIANGLE_STRIP);
|
||||
for (int i = 0; i <= finPoints.length; i++) {
|
||||
Coordinate c = finPoints[i % finPoints.length];
|
||||
// if ( i > 1 ){
|
||||
Coordinate c2 = finPoints[(i - 1 + finPoints.length)
|
||||
% 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(),
|
||||
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))
|
||||
gl.glShadeModel(GLLightingFunc.GL_SMOOTH);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user