Revision 14999
import/ext3D/trunk/ext3D/src/com/iver/ai2/gvsig3d/map3d/layers/FLayers3D.java | ||
---|---|---|
1 | 1 |
package com.iver.ai2.gvsig3d.map3d.layers; |
2 | 2 |
|
3 | 3 |
import java.awt.Point; |
4 |
import java.awt.geom.Point2D; |
|
4 | 5 |
import java.awt.geom.Rectangle2D; |
5 | 6 |
import java.io.File; |
6 | 7 |
import java.util.ArrayList; |
7 | 8 |
|
8 | 9 |
import org.cresques.cts.IProjection; |
9 |
import org.gvsig.cacheservice.CacheService; |
|
10 | 10 |
import org.gvsig.cacheservice.CacheServiceException; |
11 | 11 |
import org.gvsig.cacheservice.TileNum; |
12 | 12 |
|
13 | 13 |
import com.iver.ai2.gvsig3d.cacheservices.FLayerCacheService; |
14 | 14 |
import com.iver.ai2.gvsig3d.cacheservices.VectorCacheService; |
15 |
import com.iver.ai2.gvsig3d.gui.VectorTest; |
|
15 | 16 |
import com.iver.ai2.gvsig3d.map3d.MapContext3D; |
16 | 17 |
import com.iver.ai2.gvsig3d.utils.UtilCoord; |
17 | 18 |
import com.iver.cit.gvsig.fmap.DriverException; |
... | ... | |
34 | 35 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
35 | 36 |
import com.iver.utiles.XMLEntity; |
36 | 37 |
|
38 |
import es.upv.ai2.libjosg.Node; |
|
37 | 39 |
import es.upv.ai2.libjosg.Vec3; |
38 | 40 |
import es.upv.ai2.libjosg.planets.Planet; |
39 | 41 |
import es.upv.ai2.libjosg.planets.RequestLayerListener; |
... | ... | |
72 | 74 |
public FLayers3D(MapContext fmap, FLayers parent, ViewPort vp) { |
73 | 75 |
|
74 | 76 |
super(fmap, parent); |
75 |
vp.setAdjustable(false); |
|
76 |
Rectangle2D extend = new Rectangle2D.Double(-20000000.0, 10000000.0, |
|
77 |
20000000.0, -10000000.0);
|
|
78 |
vp.setExtent(extend); |
|
77 |
// vp.setAdjustable(false);
|
|
78 |
// Rectangle2D extend = new Rectangle2D.Double(-20000000.0, 10000000.0,
|
|
79 |
// 20000000.0, -10000000.0);
|
|
80 |
// vp.setExtent(extend);
|
|
79 | 81 |
if (fmap == null) { |
80 | 82 |
MapContext newMap = new MapContext3D(this, vp); |
81 | 83 |
this.fmap = newMap; |
... | ... | |
450 | 452 |
public void setViewProjection(IProjection projection) { |
451 | 453 |
m_viewProjection = projection; |
452 | 454 |
} |
453 |
|
|
455 |
|
|
456 |
|
|
454 | 457 |
public void zoomToExtent(Rectangle2D geoExtent, double maxHeight) { |
455 | 458 |
|
456 |
|
|
457 |
|
|
458 |
// int planetType = this.m_planet.getType(); |
|
459 |
// |
|
460 |
// if (planetType == PlanetType.PLANE_MODE) { |
|
461 |
// |
|
462 |
// } else if (planetType == PlanetType.SPHERICAL_MODE) { |
|
463 |
// |
|
464 |
// } |
|
465 |
|
|
466 | 459 |
double minLat = geoExtent.getMinY(); |
467 | 460 |
double maxLat = geoExtent.getMaxY(); |
468 | 461 |
double cenLon = geoExtent.getCenterX(); |
469 | 462 |
double cenLat = geoExtent.getCenterY(); |
463 |
// search for Gazetteer |
|
464 |
if (( geoExtent.getHeight() == 0 ) && (geoExtent.getWidth()==0)){ |
|
465 |
cenLon = geoExtent.getX(); |
|
466 |
cenLat = geoExtent.getY(); |
|
467 |
// TODO: Insercion de un simbolo para situar al objeto buscado en Nomenglator |
|
468 |
//insertaText("OOO", new Vec3(cenLon,cenLat,50)); |
|
469 |
} |
|
470 | 470 |
|
471 | 471 |
// calculate altitude |
472 | 472 |
double avLat = 0; |
... | ... | |
485 | 485 |
double elevation = (Math.max(deltaLon, deltaLat) * zoomFactor) |
486 | 486 |
+ maxHeight; |
487 | 487 |
|
488 |
// calculate XYZ positions for camera. TODO: define utilities
|
|
488 |
// Calculate XYZ positions for camera. TODO: define utilities
|
|
489 | 489 |
// to go from GeoCoords to XYZ and viceversa |
490 |
Vec3 eye = UtilCoord.GeoToCarte((planetRadius + elevation), cenLon, |
|
491 |
cenLat); |
|
492 | 490 |
|
493 |
// double sx = Math.cos(cenLat) * Math.cos(cenLon); |
|
494 |
// double sy = Math.cos(cenLat) * Math.sin(cenLon); |
|
495 |
// double sz = Math.sin(cenLat); |
|
496 |
// |
|
497 |
// Vec3 eye = new Vec3(); |
|
498 |
// eye.setX((planetRadius + elevation) * sx); |
|
499 |
// eye.setY((planetRadius + elevation) * sy); |
|
500 |
// eye.setZ((planetRadius + elevation) * sz); |
|
491 |
int planetType = this.m_planet.getType(); |
|
501 | 492 |
|
493 |
Vec3 eye = new Vec3(); |
|
502 | 494 |
Vec3 center = new Vec3(); |
503 |
// center.setX((planetRadius) * sx); |
|
504 |
// center.setY((planetRadius) * sy); |
|
505 |
// center.setZ((planetRadius) * sz); |
|
506 |
|
|
507 |
center.setX(0.0); |
|
508 |
center.setY(0.0); |
|
509 |
center.setZ(0.0); |
|
510 |
|
|
511 | 495 |
Vec3 up = new Vec3(); |
512 |
up.setX(0); |
|
513 |
up.setY(0); |
|
514 |
up.setZ(1.0); |
|
496 |
// Calculate positions for PLAIN MODE. |
|
497 |
if (planetType == PlanetType.PLANE_MODE) { |
|
498 |
|
|
499 |
double difx = (geoExtent.getWidth() - geoExtent.getX()) / 2.0d; |
|
500 |
double dify = (geoExtent.getHeight() - geoExtent.getY()) / 2.0d; |
|
501 |
double posx = geoExtent.getX() + difx; |
|
502 |
double posy = geoExtent.getY() + dify; |
|
515 | 503 |
|
516 |
// eye.setX(8779908.177996919); |
|
517 |
// eye.setY(-1824297.7539430668); |
|
518 |
// eye.setZ(6399120.469045121); |
|
519 |
|
|
504 |
double height; |
|
505 |
height = Math.sqrt(difx * difx + dify * dify); |
|
506 |
|
|
507 |
// EYE |
|
508 |
eye.setX(cenLon); eye.setY(cenLat); eye.setZ(height); |
|
509 |
// CENTER |
|
510 |
center.setX(cenLon); center.setY(cenLat); center.setZ(0.0); |
|
511 |
// UP |
|
512 |
up.setX(0.0); up.setY(1.0); up.setZ(0.0); |
|
513 |
} else |
|
514 |
// Calculate positions for SPHERICAL MODE. |
|
515 |
if (planetType == PlanetType.SPHERICAL_MODE) { |
|
516 |
// EYE |
|
517 |
eye = UtilCoord.GeoToCarte((planetRadius + elevation), cenLon, |
|
518 |
cenLat); |
|
519 |
// CENTER |
|
520 |
center.setX(0.0); center.setY(0.0); center.setZ(0.0); |
|
521 |
// UP |
|
522 |
up.setX(0.0); up.setY(0.0); up.setZ(1.0); |
|
523 |
} |
|
520 | 524 |
Camera cam = new Camera(); |
521 | 525 |
cam.setViewByLookAt(eye, center, up); |
522 | 526 |
m_canvas3d.setCamera(cam); |
... | ... | |
562 | 566 |
} |
563 | 567 |
|
564 | 568 |
if (dataType == Layer3DProps.layer3DImage) { |
565 |
// float opacity = 1.0f;
|
|
569 |
// float opacity = 1.0f;
|
|
566 | 570 |
String fileExtension = "png"; |
567 | 571 |
evt.getTilePagedLod().setTexture(tileFileName, |
568 | 572 |
fileExtension, textureStage); |
569 |
m_planet.setLayerOpacity(textureStage, props3D.getOpacity()); |
|
573 |
m_planet |
|
574 |
.setLayerOpacity(textureStage, props3D.getOpacity()); |
|
570 | 575 |
textureStage++; |
571 | 576 |
} else { |
572 | 577 |
String fileExtension = "tif"; |
... | ... | |
625 | 630 |
} |
626 | 631 |
|
627 | 632 |
if (dataType == Layer3DProps.layer3DImage) { |
628 |
// float opacity = 1.0f;
|
|
633 |
// float opacity = 1.0f;
|
|
629 | 634 |
String fileExtension = "png"; |
630 | 635 |
evt.getTilePagedLod().setTexture(tileFileName, fileExtension, |
631 | 636 |
order); |
Also available in: Unified diff