[fixes #969] Added custom left and right side appearance fins
This commit is contained in:
parent
9eea6edfe4
commit
354c05fa60
@ -810,9 +810,13 @@ AppearanceCfg.lbl.texture.center = Center:
|
||||
AppearanceCfg.lbl.texture.rotation = Rotation:
|
||||
AppearanceCfg.lbl.texture.repeat = Repeat:
|
||||
AppearanceCfg.lbl.InsideSameAsOutside = Same as outside
|
||||
AppearanceCfg.lbl.LeftSideSameAsRightSide = Same as right side
|
||||
AppearanceCfg.lbl.ttip.InsideSameAsOutside = Use the same appearance for the inside as for the outside
|
||||
AppearanceCfg.lbl.ttip.LeftSideSameAsRightSide = Use the same appearance for the left side as for the right side
|
||||
AppearanceCfg.lbl.EdgesSameAsInside = Use inside appearance for edges
|
||||
AppearanceCfg.lbl.EdgesSameAsLeftSide = Use left side appearance for edges
|
||||
AppearanceCfg.lbl.ttip.EdgesSameAsInside = Use the inside appearance (checked) or outside appearance (unchecked) for the edges
|
||||
AppearanceCfg.lbl.ttip.EdgesSameAsLeftSide = Use the left side appearance (checked) or right side appearance (unchecked) for the edges
|
||||
|
||||
! Texture Wrap Modes
|
||||
TextureWrap.Repeat = Repeat
|
||||
@ -878,6 +882,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:
|
||||
|
@ -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();
|
||||
|
||||
@ -126,6 +122,11 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
private double totalVolume = Double.NaN;
|
||||
private Coordinate centerOfMass = Coordinate.NaN;
|
||||
|
||||
// Settings for inside/edge appearance
|
||||
private Appearance insideAppearance = null;
|
||||
private boolean insideSameAsOutside = true;
|
||||
private boolean edgesSameAsInside = true;
|
||||
|
||||
/**
|
||||
* New FinSet with given number of fins and given base rotation angle.
|
||||
* Sets the component relative position to POSITION_RELATIVE_BOTTOM,
|
||||
@ -1269,4 +1270,49 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Appearance getInsideAppearance() {
|
||||
return this.insideAppearance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsideAppearance(Appearance appearance) {
|
||||
this.insideAppearance = appearance;
|
||||
if (this.insideAppearance != null) {
|
||||
Decal d = this.insideAppearance.getTexture();
|
||||
if (d != null) {
|
||||
d.getImage().addChangeListener(new StateChangeListener() {
|
||||
|
||||
@Override
|
||||
public void stateChanged(EventObject e) {
|
||||
fireComponentChangeEvent(ComponentChangeEvent.TEXTURE_CHANGE);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
// CHECK - should this be a TEXTURE_CHANGE and not NONFUNCTIONAL_CHANGE?
|
||||
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEdgesSameAsInside() {
|
||||
return this.edgesSameAsInside;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEdgesSameAsInside(boolean newState) {
|
||||
this.edgesSameAsInside = newState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInsideSameAsOutside() {
|
||||
return this.insideSameAsOutside;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsideSameAsOutside(boolean newState) {
|
||||
this.insideSameAsOutside = newState;
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,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;
|
||||
@ -309,17 +310,32 @@ public class AppearancePanel extends JPanel {
|
||||
appearanceSection(document, c, false, outsidePanel);
|
||||
appearanceSection(document, c, true, insidePanel);
|
||||
|
||||
tabbedPane.addTab(trans.get("RocketCompCfg.tab.Outside"), null, outsidePanel,
|
||||
// Get translator keys
|
||||
String tr_outside, tr_inside, tr_edges, tr_edges_ttip;
|
||||
if (c instanceof FinSet) {
|
||||
tr_outside = "RocketCompCfg.tab.RightSide";
|
||||
tr_inside = "RocketCompCfg.tab.LeftSide";
|
||||
tr_edges = "AppearanceCfg.lbl.EdgesSameAsLeftSide";
|
||||
tr_edges_ttip = "AppearanceCfg.lbl.ttip.EdgesSameAsLeftSide";
|
||||
}
|
||||
else {
|
||||
tr_outside = "RocketCompCfg.tab.Outside";
|
||||
tr_inside = "RocketCompCfg.tab.Inside";
|
||||
tr_edges = "AppearanceCfg.lbl.EdgesSameAsInside";
|
||||
tr_edges_ttip = "AppearanceCfg.lbl.ttip.EdgesSameAsInside";
|
||||
}
|
||||
|
||||
tabbedPane.addTab(trans.get(tr_outside), null, outsidePanel,
|
||||
"Outside Tool Tip");
|
||||
tabbedPane.addTab(trans.get("RocketCompCfg.tab.Inside"), null, insidePanel,
|
||||
tabbedPane.addTab(trans.get(tr_inside), null, insidePanel,
|
||||
"Inside Tool Tip");
|
||||
add(tabbedPane, "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"));
|
||||
edges.setText(trans.get(tr_edges));
|
||||
edges.setToolTipText(trans.get(tr_edges_ttip));
|
||||
add(edges, "wrap");
|
||||
|
||||
edges.addActionListener(new ActionListener() {
|
||||
@ -406,13 +422,24 @@ public class AppearancePanel extends JPanel {
|
||||
else
|
||||
panel.add(materialDefault, "wrap");
|
||||
|
||||
// Get translation keys
|
||||
String tr_insideOutside, tr_insideOutside_ttip;
|
||||
if (c instanceof FinSet) {
|
||||
tr_insideOutside = "AppearanceCfg.lbl.LeftSideSameAsRightSide";
|
||||
tr_insideOutside_ttip = "AppearanceCfg.lbl.ttip.LeftSideSameAsRightSide";
|
||||
}
|
||||
else {
|
||||
tr_insideOutside = "AppearanceCfg.lbl.InsideSameAsOutside";
|
||||
tr_insideOutside_ttip = "AppearanceCfg.lbl.ttip.InsideSameAsOutside";
|
||||
}
|
||||
|
||||
// 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.setText(trans.get(tr_insideOutside));
|
||||
customInside.setToolTipText(trans.get(tr_insideOutside_ttip));
|
||||
customInside.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -99,13 +99,13 @@ public class RealisticRenderer extends RocketRenderer {
|
||||
|
||||
render(gl, geom, Surface.INSIDE, innerApp, true, alpha);
|
||||
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);
|
||||
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 ) {
|
||||
|
@ -13,11 +13,12 @@ import net.sf.openrocket.rocketcomponent.EllipticalFinSet;
|
||||
import net.sf.openrocket.rocketcomponent.FinSet;
|
||||
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);
|
||||
@ -61,51 +62,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.OUTSIDE) {
|
||||
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.INSIDE) {
|
||||
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