Revision 15441 import/ext3D/branches/ext3D_v1.1/ext3D/src/com/iver/ai2/gvsig3d/map3d/ViewPort3D.java

View differences:

ViewPort3D.java
14 14
import com.iver.utiles.StringUtilities;
15 15
import com.iver.utiles.XMLEntity;
16 16

  
17
import es.upv.ai2.libjosg.Node;
17 18
import es.upv.ai2.libjosg.Vec3;
18 19
import es.upv.ai2.libjosg.planets.Planet;
19
import es.upv.ai2.libjosg.viewer.Hit;
20 20
import es.upv.ai2.libjosg.viewer.IViewerContainer;
21
import es.upv.ai2.libjosg.viewer.Intersections;
21 22

  
22 23
public class ViewPort3D extends ViewPort implements MouseListener {
23 24

  
......
78 79
		int x = (int) pScreen.getX();
79 80
		int y = this.getImageHeight() - (int) pScreen.getY() - 1;
80 81

  
81
		// get XYZ coordinates on planet
82
		Hit hit = canvas3d.getOSGViewer().pick(x, y);
83
		boolean falseHit = false;
84
		if (hit.getX() == 0.0 && hit.getY() == 0.0 && hit.getZ() == 0.0) // no
85
			// hit
86
			falseHit = true;
87

  
88
		// convert to geo coordinates
82
		Intersections hits = canvas3d.getOSGViewer().rayPick(x, y);
89 83
		Point2D pWorld = new Point2D.Double();
90
		if (proj.getAbrev().compareToIgnoreCase("EPSG:4326") == 0) {
91
			if (falseHit) {
92
				pWorld.setLocation(360, 120); // an absurd location
93
			} else {
84
		if (hits.containsIntersections()) {
85
			// get XYZ coordinates on planet
86
			Vec3 hit = hits.getFirstIntersection().getIntersectionPoint();
87
			// convert to geo coordinates
88
			
89
			if (proj.getAbrev().compareToIgnoreCase("EPSG:4326") == 0) {
94 90
				Vec3 geoPt = planet.convertXYZToLatLongHeight(new Vec3(
95
						(double) hit.getX(), (double) hit.getY(), (double) hit
96
								.getZ()));
91
						(double) hit.x(), (double) hit.y(), (double) hit.x()));
97 92
				pWorld.setLocation(geoPt.y(), geoPt.x());
98
			}
93
			} else
94
				pWorld.setLocation((double) hit.x(), (double) hit.y());
99 95
		} else {
100
			if (falseHit)
101
				pWorld.setLocation(1e100, 1e100); // an absurd location
102
			else
103
				pWorld.setLocation((double) hit.getX(), (double) hit.getY());
96
			if (proj.getAbrev().compareToIgnoreCase("EPSG:4326") == 0) {
97
				pWorld.setLocation(360, 120);
98
			} else
99
				pWorld.setLocation(1e100, 1e100);
104 100
		}
105 101

  
106 102
		return pWorld;
......
142 138

  
143 139
	}
144 140

  
145
	/* (non-Javadoc)
141
	/*
142
	 * (non-Javadoc)
143
	 * 
146 144
	 * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
147 145
	 */
148 146
	public void mouseReleased(MouseEvent e) {
149 147
		// Center point of locator
150 148
		Point2D center = null;
151
		//Scale factor
149
		// Scale factor
152 150
		double factor = 0;
153 151
		if (planet != null) {
154 152
			// Getting center point longitude and latitude

Also available in: Unified diff