Revision 31
1.10/trunk/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/display/ProjectionMode.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import org.gvsig.gvsig3d.navigation.NavigationMode; |
4 | 4 |
import org.gvsig.gvsig3dgui.view.View3D; |
5 |
import org.gvsig.osgvp.core.osg.Matrix.Frustum; |
|
5 | 6 |
import org.gvsig.osgvp.terrain.TerrainCameraManipulator; |
7 |
import org.gvsig.osgvp.viewer.Camera; |
|
6 | 8 |
import org.gvsig.osgvp.viewer.OSGViewer; |
7 | 9 |
|
8 | 10 |
import com.iver.andami.PluginServices; |
... | ... | |
16 | 18 |
public void execute(String actionCommand) { |
17 | 19 |
// Getting view3D |
18 | 20 |
com.iver.andami.ui.mdiManager.IWindow view = PluginServices |
19 |
.getMDIManager().getActiveWindow();
|
|
21 |
.getMDIManager().getActiveWindow(); |
|
20 | 22 |
if (!(view instanceof View3D)) |
21 | 23 |
return; |
22 | 24 |
|
... | ... | |
26 | 28 |
|
27 | 29 |
NavigationMode nm = ((View3D) view).getNavMode(); |
28 | 30 |
|
29 |
if (!_perspective) { |
|
30 |
((View3D) view).getCanvas3d().getOSGViewer() |
|
31 |
.setProjectionMatrixAsPerspective( |
|
32 |
_fovy, |
|
33 |
((double) viewer.getWidth()) |
|
34 |
/ ((double) viewer |
|
35 |
.getHeight()), 1, 10000); |
|
36 |
_perspective = true; |
|
37 |
nm.removeAllNavigationModes((TerrainCameraManipulator) viewer.getCameraManipulator()); |
|
38 |
|
|
31 |
if(nm!=null){ |
|
39 | 32 |
|
40 |
} else { |
|
33 |
if (!_perspective) { |
|
34 |
viewer.setProjectionMatrixAsPerspective( |
|
35 |
_fovy,((double) viewer.getWidth())/ ((double) viewer.getHeight()), 1, 10000); |
|
36 |
_perspective = true; |
|
37 |
nm.SetDefaultMode(); |
|
41 | 38 |
|
42 |
_fovy = viewer.getCamera().getProjectionMatrixAsPerspective().fovy; |
|
43 |
|
|
44 |
((View3D) view) |
|
45 |
.getCanvas3d() |
|
46 |
.getOSGViewer() |
|
47 |
.setProjectionMatrixAsOrtho( |
|
48 |
20 * (((double) viewer.getCamera() |
|
49 |
.getProjectionMatrixAsFrustum().left)), |
|
50 |
20 * (((double) viewer.getCamera() |
|
51 |
.getProjectionMatrixAsFrustum().right)), |
|
52 |
20 * (((double)viewer.getCamera() |
|
53 |
.getProjectionMatrixAsFrustum().bottom)), |
|
54 |
20 * (((double) viewer.getCamera() |
|
55 |
.getProjectionMatrixAsFrustum().top)), |
|
56 |
1, 1000); |
|
57 | 39 |
|
58 |
_perspective = false; |
|
59 |
nm.SetAzimutRollMode(); |
|
40 |
} else { |
|
60 | 41 |
|
42 |
Camera cam = viewer.getCamera(); |
|
43 |
_fovy = cam.getProjectionMatrixAsPerspective().fovy; |
|
44 |
Frustum frus = cam.getProjectionMatrixAsFrustum(); |
|
45 |
|
|
46 |
viewer.setProjectionMatrixAsOrtho( |
|
47 |
frus.left, frus.right, frus.bottom, frus.top,1, 1000); |
|
48 |
|
|
49 |
_perspective = false; |
|
50 |
nm.SetAzimutRollMode(); |
|
51 |
|
|
52 |
} |
|
61 | 53 |
} |
62 | 54 |
} |
63 | 55 |
|
... | ... | |
69 | 61 |
PluginServices.getIconTheme().registerDefault( |
70 | 62 |
"projection-icon", |
71 | 63 |
this.getClass().getClassLoader().getResource( |
72 |
"images/projection.png"));
|
|
64 |
"images/projection.png")); |
|
73 | 65 |
|
74 | 66 |
} |
75 | 67 |
|
Also available in: Unified diff