[Gvsig_desarrolladores] OSGVP: Usar un jpg como suelo de un planeta

Rafa Gaitan rafa.gaitan en gmail.com
Lun Ene 26 10:35:25 CET 2009


Hola María,

El código parece correcto, voy a hacer unas pruebas a ver si es algo que se
me ha olvidado comentarte y te digo.

Un Saludo,
Rafa.


2009/1/23 Maria Arias de Reyna <marias en emergya.es>

> El Viernes 23 Enero 2009 11:41, Rafa Gaitan escribió:
> > Por otro lado si lo que quieres es NO subdividir y poner una única
> textura,
> > añadiendo esto cuando creas el planeta es suficiente:
> >
> >     planet.setEnabledSubdivision(false);
>
> He intentado hacer lo que me has dicho, pero no consigo verlo. He creado
> una
> clase mundo que extiende a planeta y que llama a las funciones que me has
> indicado. Pero aunque me pinta la proyección y me deja moverla y girarla,
> en
> ningún momento llama a la función de requestTextureLayer(...).
>
> public class Mundo extends Planet  {
>
>         public Mundo() throws NodeException {
>                 super("Mi Mundo",
>                                 Planet.CoordinateSystemType.PROJECTED,
> "WKT", "EPSG:23030",
>                                 1, 1, 2, 2, 1.0, 1.0);
>                 addTextureLayer(getExtent());
>                 setEnabledSubdivision(false);
>         }
> }
>
> Y luego llamo creo el mundo y lo pinto con la clase ejemplo:
>
> public class Ejemplo implements RequestLayerListener{
>
>        private static IViewerContainer canvas3d;
>        private static PlanetViewer planetViewer;
>        private static Mundo earth;
>
>        public void ejecutar()
>        {
>                JPanel jContentPane = new JPanel();
>                jContentPane.setLayout(new BorderLayout());
>                JFrame jFrame = new JFrame();
>                jFrame.setContentPane(jContentPane);
>                jFrame.setSize(800, 600);
>                jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>
>                /**
>                 * Create a planet viewer
>                 */
>                try {
>                        planetViewer = new PlanetViewer();
>                } catch (NodeException e) {
>                        // TODO Auto-generated catch block
>                        e.printStackTrace();
>                }
>                /**
>                 * Define the viewer type and add to the canvas
>                 */
>                canvas3d = ViewerFactory.getInstance().createViewer(
>                                ViewerFactory.VIEWER_TYPE.CANVAS_VIEWER,
> planetViewer);
>                jContentPane.add((Component)canvas3d, BorderLayout.CENTER);
>                ViewerFactory.getInstance().startAnimator();
>                /**
>                 * Add a planet to the scene data
>                 */
>                try {
>                        earth = new Mundo();
>                } catch (NodeException e3) {
>                        // TODO Auto-generated catch block
>                        e3.printStackTrace();
>                }
>                try {
>                        planetViewer.addPlanet(earth);
>
>                } catch (NodeException e2) {
>                        e2.printStackTrace();
>                }
>                earth.setRequestLayerListener(this);
>                /**
>                 * Put the camera in the scene
>                 */
>                double difx = earth.getExtent().getWidth() / 2.0d;
>                double dify = earth.getExtent().getHeight() / 2.0d;
>                double posx = earth.getExtent().getX() + difx;
>                double posy = earth.getExtent().getY() + dify;
>                double height = Math.sqrt(difx * difx + dify * dify) * 4.0f;
>
>                Camera cam = planetViewer.getCamera();
>                cam.setViewByLookAt((float) posx, (float) posy, (float)
> height,
>                                (float) posx, (float) posy, 0f, 0f, 1f, 0f);
>                planetViewer.setCamera(cam);
>                /**
>                 * Customizing the manipulator
>                 */
>                CustomTerrainManipulator manip = (CustomTerrainManipulator)
> planetViewer
>                                .getCameraManipulator();
>
>  manip.addAzimButtonMask(MouseButtonMaskType.LEFT_MOUSE_BUTTON, 'a');
>
>  manip.addRollButtonMask(MouseButtonMaskType.MIDDLE_MOUSE_BUTTON, 'b');
>
>  manip.addZoomButtonMask(MouseButtonMaskType.MIDDLE_MOUSE_BUTTON, 'c');
>                manip.setMinCameraDistance(earth.getRadiusEquatorial() +
> 10);
>                manip.setMaxCameraDistance(earth.getRadiusEquatorial() +
> 1000);
>                manip.setEnabledNorthOrientation(true);
>                jFrame.setVisible(true);
>                jFrame.addWindowListener(new WindowAdapter() {
>                        public void windowClosing(WindowEvent e) {
>                                ViewerFactory.getInstance().stopAnimator();
>                                canvas3d.dispose();
>                        }
>                });
>        }
>
>
>
>        public void requestElevationLayer(Planet arg0, RequestLayerEvent
> arg1) {
>                // TODO Auto-generated method stub
>
>        }
>
>        public void requestTextureLayer(Planet arg0, RequestLayerEvent
> arg1){
>                earth.setTexture(arg1.getTerrainNode(), "/earth.gif", 0);
>        }
>
> }
>
> --
> María Arias de Reyna Domínguez
> Emergya Consultoría
>
>
> _______________________________________________
> gvSIG_desarrolladores mailing list
> gvSIG_desarrolladores en runas.cap.gva.es
> http://runas.cap.gva.es/mailman/listinfo/gvsig_desarrolladores
>
>


-- 
Rafael Gaitán Linares
Instituto de Automática e Informática Industrial  http://www.ai2.upv.es
Ciudad Politécnica de la Innovación
Universidad Politécnica de Valencia
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: http://runas.cap.gva.es/pipermail/gvsig_desarrolladores/attachments/20090126/32073699/attachment.htm


Más información sobre la lista de distribución gvSIG_desarrolladores