Found the missing pieces to make decals work.
This commit is contained in:
parent
04ee758e6a
commit
5deae1d3db
@ -45,13 +45,11 @@ RocketActions.MoveDownAct.ttip.Movedown = Move this component downwards.
|
||||
|
||||
! RocketPanel
|
||||
RocketPanel.FigTypeAct.Sideview = Side view
|
||||
RocketPanel.FigTypeAct.ttip.Sideview = Side view
|
||||
RocketPanel.FigTypeAct.Backview = Back view
|
||||
RocketPanel.FigTypeAct.ttip.Backview = Rear view
|
||||
RocketPanel.FigViewAct.2D = 2D View
|
||||
RocketPanel.FigViewAct.ttip.2D = 2D View
|
||||
RocketPanel.FigViewAct.3D = 3D View
|
||||
RocketPanel.FigViewAct.ttip.3D = 3D View
|
||||
RocketPanel.FigTypeAct.Figure3D = 3D Figure
|
||||
RocketPanel.FigTypeAct.Realistic3D = 3D Realistic
|
||||
|
||||
|
||||
RocketPanel.lbl.Motorcfg = Motor configuration:
|
||||
RocketPanel.lbl.infoMessage = <html>Click to select Shift+click to select other Double-click to edit Click+drag to move
|
||||
|
||||
|
@ -51,6 +51,27 @@ public class RealisticRenderStrategy extends RenderStrategy {
|
||||
public void init(GLAutoDrawable drawable) {
|
||||
oldTexCache = new HashMap<String,Texture>();
|
||||
texCache = new HashMap<String,Texture>();
|
||||
|
||||
GL2 gl = drawable.getGL().getGL2();
|
||||
|
||||
gl.glLightModelfv(GL2ES1.GL_LIGHT_MODEL_AMBIENT,
|
||||
new float[] { 0,0,0 }, 0);
|
||||
|
||||
float amb = 0.3f;
|
||||
float dif = 1.0f - amb;
|
||||
float spc = 1.0f;
|
||||
gl.glLightfv(GLLightingFunc.GL_LIGHT1, GLLightingFunc.GL_AMBIENT,
|
||||
new float[] { amb, amb, amb, 1 }, 0);
|
||||
gl.glLightfv(GLLightingFunc.GL_LIGHT1, GLLightingFunc.GL_DIFFUSE,
|
||||
new float[] { dif, dif, dif, 1 }, 0);
|
||||
gl.glLightfv(GLLightingFunc.GL_LIGHT1, GLLightingFunc.GL_SPECULAR,
|
||||
new float[] { spc, spc, spc, 1 }, 0);
|
||||
|
||||
gl.glEnable(GLLightingFunc.GL_LIGHT1);
|
||||
gl.glEnable(GLLightingFunc.GL_LIGHTING);
|
||||
gl.glShadeModel(GLLightingFunc.GL_SMOOTH);
|
||||
|
||||
gl.glEnable(GLLightingFunc.GL_NORMALIZE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -394,6 +394,21 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
||||
|
||||
gl.glDepthFunc(GL.GL_LEQUAL); // the type of depth test to do
|
||||
|
||||
float amb = 0.5f;
|
||||
float dif = 1.0f;
|
||||
gl.glLightfv(GLLightingFunc.GL_LIGHT1, GLLightingFunc.GL_AMBIENT,
|
||||
new float[] { amb, amb, amb, 1 }, 0);
|
||||
gl.glLightfv(GLLightingFunc.GL_LIGHT1, GLLightingFunc.GL_DIFFUSE,
|
||||
new float[] { dif, dif, dif, 1 }, 0);
|
||||
gl.glLightfv(GLLightingFunc.GL_LIGHT1, GLLightingFunc.GL_SPECULAR,
|
||||
new float[] { dif, dif, dif, 1 }, 0);
|
||||
|
||||
gl.glEnable(GLLightingFunc.GL_LIGHT1);
|
||||
gl.glEnable(GLLightingFunc.GL_LIGHTING);
|
||||
gl.glShadeModel(GLLightingFunc.GL_SMOOTH);
|
||||
|
||||
gl.glEnable(GLLightingFunc.GL_NORMALIZE);
|
||||
|
||||
extrasOverlay = new Overlay(drawable);
|
||||
caretOverlay = new Overlay(drawable);
|
||||
|
||||
|
@ -19,12 +19,12 @@ import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.ComboBoxModel;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.JViewport;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
@ -86,6 +86,23 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
||||
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
|
||||
/*RocketPanel.FigTypeAct.Sideview = Side view
|
||||
RocketPanel.FigTypeAct.Backview = Back view
|
||||
RocketPanel.FigViewAct.3DFigure = 3D Figure
|
||||
RocketPanel.FigViewAct.3DRealistic = 3D Realistic*/
|
||||
|
||||
private static enum VIEW_TYPE {
|
||||
Sideview,
|
||||
Backview,
|
||||
Figure3D,
|
||||
Realistic3D;
|
||||
@Override
|
||||
public String toString(){
|
||||
return trans.get("RocketPanel.FigTypeAct." + super.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean is3d;
|
||||
private final RocketFigure figure;
|
||||
private final RocketFigure3d figure3d;
|
||||
@ -100,7 +117,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
||||
private TreeSelectionModel selectionModel = null;
|
||||
|
||||
private BasicSlider rotationSlider;
|
||||
ScaleSelector scaleSelector;
|
||||
private ScaleSelector scaleSelector;
|
||||
|
||||
|
||||
/* Calculation of CP and CG */
|
||||
@ -245,48 +262,35 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
||||
setPreferredSize(new Dimension(800, 300));
|
||||
|
||||
|
||||
//// Create toolbar
|
||||
|
||||
ButtonGroup bg = new ButtonGroup();
|
||||
|
||||
// Side/back buttons
|
||||
FigureTypeAction action = new FigureTypeAction(RocketFigure.TYPE_SIDE);
|
||||
//// Side view
|
||||
action.putValue(Action.NAME, trans.get("RocketPanel.FigTypeAct.Sideview"));
|
||||
//// Side view
|
||||
action.putValue(Action.SHORT_DESCRIPTION, trans.get("RocketPanel.FigTypeAct.ttip.Sideview"));
|
||||
JToggleButton toggle = new JToggleButton(action);
|
||||
bg.add(toggle);
|
||||
add(toggle, "spanx, split");
|
||||
|
||||
action = new FigureTypeAction(RocketFigure.TYPE_BACK);
|
||||
//// Back view
|
||||
action.putValue(Action.NAME, trans.get("RocketPanel.FigTypeAct.Backview"));
|
||||
//// Back view
|
||||
action.putValue(Action.SHORT_DESCRIPTION, trans.get("RocketPanel.FigTypeAct.ttip.Backview"));
|
||||
toggle = new JToggleButton(action);
|
||||
bg.add(toggle);
|
||||
add(toggle, "gap rel");
|
||||
|
||||
//// 3d Toggle
|
||||
final JToggleButton toggle3d = new JToggleButton(new AbstractAction("3D") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
{
|
||||
putValue(Action.NAME, "3D");//TODO
|
||||
putValue(Action.SHORT_DESCRIPTION, "3D"); //TODO
|
||||
}
|
||||
// View Type Dropdown
|
||||
ComboBoxModel cm = new DefaultComboBoxModel(VIEW_TYPE.values()) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if ( ((JToggleButton)e.getSource()).isSelected() ){
|
||||
go3D();
|
||||
} else {
|
||||
public void setSelectedItem(Object o) {
|
||||
super.setSelectedItem(o);
|
||||
VIEW_TYPE v = (VIEW_TYPE) o;
|
||||
switch (v) {
|
||||
case Sideview:
|
||||
figure.setType(RocketFigure.TYPE_SIDE);
|
||||
go2D();
|
||||
break;
|
||||
case Backview:
|
||||
figure.setType(RocketFigure.TYPE_BACK);
|
||||
go2D();
|
||||
break;
|
||||
case Realistic3D:
|
||||
figure3d.setType(RocketFigure3d.TYPE_REALISTIC);
|
||||
go3D();
|
||||
break;
|
||||
case Figure3D:
|
||||
figure3d.setType(RocketFigure3d.TYPE_FIGURE);
|
||||
go3D();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
bg.add(toggle3d);
|
||||
toggle3d.setEnabled(RocketFigure3d.is3dEnabled());
|
||||
add(toggle3d, "gap rel");
|
||||
};
|
||||
add(new JLabel("View Type:"), "spanx, split");
|
||||
add(new JComboBox(cm));
|
||||
|
||||
|
||||
// Zoom level selector
|
||||
scaleSelector = new ScaleSelector(scrollPane);
|
||||
@ -296,7 +300,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
||||
|
||||
// Stage selector
|
||||
StageSelector stageSelector = new StageSelector(configuration);
|
||||
add(stageSelector, "");
|
||||
add(stageSelector);
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user