mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add field of view parameter in 3D axes for perspective projection
This commit is contained in:
parent
d107e5a585
commit
cfe03a014b
@ -117,6 +117,7 @@ public class GLPlot extends Plot {
|
||||
protected float dpiScale; //DPI scale factor
|
||||
protected boolean orthographic;
|
||||
protected float distance;
|
||||
protected float fieldOfView;
|
||||
protected GLAutoDrawable drawable;
|
||||
|
||||
protected Map<Graphic, JOGLGraphicRender> renderMap = new HashMap<>();
|
||||
@ -151,6 +152,7 @@ public class GLPlot extends Plot {
|
||||
this.dpiScale = 1;
|
||||
this.orthographic = true;
|
||||
this.distance = 5.f;
|
||||
this.fieldOfView = 45.f;
|
||||
this.initAngles();
|
||||
this.graphicExtent = new Extent3D();
|
||||
Extent3D extent3D = new Extent3D(-1, 1, -1, 1, -1, 1);
|
||||
@ -1016,6 +1018,22 @@ public class GLPlot extends Plot {
|
||||
this.distance = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get field of view angle for perspective projection
|
||||
* @return Field of view angle in degrees
|
||||
*/
|
||||
public float getFieldOfView() {
|
||||
return this.fieldOfView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set field of view angle for perspective projection
|
||||
* @param value Field of view angle in degrees
|
||||
*/
|
||||
public void setFieldOfView(float value) {
|
||||
this.fieldOfView = value;
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
// <editor-fold desc="methods">
|
||||
/**
|
||||
@ -4426,13 +4444,14 @@ public class GLPlot extends Plot {
|
||||
float far = 1000.0f;
|
||||
switch (this.aspectType) {
|
||||
case EQUAL:
|
||||
glu.gluPerspective(45.0f, h, near, far);
|
||||
glu.gluPerspective(fieldOfView, h, near, far);
|
||||
break;
|
||||
default:
|
||||
glu.gluPerspective(45.0f, 1.0f, near, far);
|
||||
glu.gluPerspective(fieldOfView, 1.0f, near, far);
|
||||
break;
|
||||
}
|
||||
glu.gluLookAt(0.0f, 0.0f, distance, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
|
||||
float z = distance * 45.f / fieldOfView;
|
||||
glu.gluLookAt(0.0f, 0.0f, z, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
|
||||
}
|
||||
gl.glMatrixMode(GL2.GL_MODELVIEW);
|
||||
gl.glLoadIdentity();
|
||||
|
||||
@ -67,7 +67,7 @@ import java.util.zip.ZipInputStream;
|
||||
public static String getVersion(){
|
||||
String version = GlobalUtil.class.getPackage().getImplementationVersion();
|
||||
if (version == null || version.equals("")) {
|
||||
version = "3.5.12";
|
||||
version = "3.6.0-beta1";
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\map\maskout">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\streamplot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\streamslice"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\radar"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
@ -16,19 +13,20 @@
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\patch"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\maskout"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\bar"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\dataframe\dataframe_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\dataframe\reindex_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\maskout\maskout_data_arc_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\maskout\maskout_data_arc.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_perspective_sagittal_specular.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\dataframe\dataframe_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\dataframe\reindex_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\map\maskout\maskout_data_arc_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\map\maskout\maskout_data_arc.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_perspective_sagittal_specular.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
|
||||
Binary file not shown.
@ -265,6 +265,25 @@ class Axes3DGL(Axes3D):
|
||||
"""
|
||||
self._axes.setDistance(dis)
|
||||
|
||||
def get_fov(self):
|
||||
"""
|
||||
Get field of view angles in degrees for perspective projection.
|
||||
|
||||
:return: (*float*) Field of view angles in degrees.
|
||||
"""
|
||||
return self._axes.getFieldOfView()
|
||||
|
||||
def set_fov(self, fov):
|
||||
"""
|
||||
Set field of view angles in degrees for perspective projection.
|
||||
|
||||
:param fov: (*float*) Field of view angles in degrees.
|
||||
"""
|
||||
if fov <= 0 or fov >= 180:
|
||||
warnings.warn('Field of view angles should be in the range of (0, 180)')
|
||||
else:
|
||||
self._axes.setFieldOfView(fov)
|
||||
|
||||
def set_lighting(self, enable=True, **kwargs):
|
||||
"""
|
||||
Set lighting.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user