1

collada 模型,Spitfire 飞机未显示,代码如下:

public class Main extends Application {

   private static final double HOME_LAT     = 44.72;
   private static final double HOME_LON     = -0.5;
   private static final double CAMERA_ALT   = 10_000.0;
   private static final double AIRCRAFT_ALT =  3_000.0;

   private final WorldWindowGLJPanel _ww    = new WorldWindowGLJPanel();
   private final ColladaRoot         _aircraft;
   private /* */ double              _scale = 1.0;

   public Main() throws IOException, XMLStreamException {
      _aircraft = ColladaRoot.createAndParse(
         getClass().getResource( "spit.dae" ));
      _aircraft.setAltitudeMode( WorldWind.ABSOLUTE );
      _aircraft.setModelScale( new Vec4( _scale ));
      _aircraft.setPosition(
         Position.fromDegrees( HOME_LAT, HOME_LON, AIRCRAFT_ALT ));
      _ww.setModel( new BasicModel());
      _ww.getView().setEyePosition(
         Position.fromDegrees( HOME_LAT, HOME_LON, CAMERA_ALT ));
      final RenderableLayer layer = new RenderableLayer();
      layer.addRenderable( new ColladaController( _aircraft ));
      _ww.getModel().getLayers().add( layer );
   }

   private void scaleIt() {
      _scale *= 2.0;
      _aircraft.setModelScale( new Vec4( _scale ));
      _ww.redraw();
      System.err.println( _scale );
   }

   @Override
   public void start( Stage primaryStage ) throws Exception {
      final SwingNode rootPane = new SwingNode();
      rootPane.setContent( _ww );
      final Button scaleIt = new Button( "Scale Aircraft" );
      final Scene scene = new Scene(
         new BorderPane( rootPane, scaleIt, null, null, null ));
      scaleIt.setMaxWidth( Double.MAX_VALUE );
      scaleIt.setOnAction( e -> scaleIt());
      primaryStage.setScene( scene );
      primaryStage.show();
   }

   public static void main( String[] args ) {
      launch( args );
   }
}

问:如何强制 WorldWind 渲染 3D Collada 模型?

4

0 回答 0