mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
bugfix VolumeRender
This commit is contained in:
parent
bcf93c34d2
commit
20e9848b27
@ -495,6 +495,14 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vertex number
|
||||
* @return Vertex number
|
||||
*/
|
||||
public int getVertexNumber() {
|
||||
return this.vertexBufferData.length / 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate normals
|
||||
*/
|
||||
|
||||
@ -2393,14 +2393,10 @@ public class Plot3DGL extends Plot implements GLEventListener {
|
||||
try {
|
||||
if (this.clipPlane)
|
||||
this.disableClipPlane(gl);
|
||||
VolumeRender volumeRender = null;
|
||||
if (!this.renderMap.containsKey(graphic)) {
|
||||
volumeRender = new VolumeRender(gl, (VolumeGraphic) graphic);
|
||||
renderMap.put(graphic, volumeRender);
|
||||
} else {
|
||||
volumeRender = (VolumeRender) renderMap.get(graphic);
|
||||
volumeRender.updateShaders();
|
||||
renderMap.put(graphic, new VolumeRender(gl, (VolumeGraphic) graphic));
|
||||
}
|
||||
VolumeRender volumeRender = (VolumeRender) renderMap.get(graphic);
|
||||
volumeRender.setTransform(this.transform);
|
||||
volumeRender.setOrthographic(this.orthographic);
|
||||
volumeRender.updateMatrix();
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
package org.meteoinfo.chart.render.jogl;
|
||||
|
||||
import com.jogamp.common.nio.Buffers;
|
||||
import com.jogamp.opengl.GL;
|
||||
import com.jogamp.opengl.GL2;
|
||||
import com.jogamp.opengl.util.GLBuffers;
|
||||
import org.meteoinfo.chart.graphic.VolumeGraphic;
|
||||
import org.meteoinfo.chart.jogl.Program;
|
||||
import org.meteoinfo.chart.jogl.Transform;
|
||||
@ -25,6 +27,7 @@ public class VolumeRender extends JOGLGraphicRender {
|
||||
private int volumeTexture;
|
||||
private int normalsTexture;
|
||||
private Program program;
|
||||
private IntBuffer vbo;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -34,6 +37,7 @@ public class VolumeRender extends JOGLGraphicRender {
|
||||
super(gl);
|
||||
|
||||
useShader = true;
|
||||
initVertexBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,7 +60,7 @@ public class VolumeRender extends JOGLGraphicRender {
|
||||
public VolumeRender(GL2 gl, VolumeGraphic graphic, Transform transform) {
|
||||
this(gl, graphic);
|
||||
|
||||
this.transform = transform;
|
||||
this.setTransform(transform);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,6 +101,23 @@ public class VolumeRender extends JOGLGraphicRender {
|
||||
return this.volume == null ? 1.0f : this.volume.getBrightness();
|
||||
}
|
||||
|
||||
private void initVertexBuffer() {
|
||||
vbo = GLBuffers.newDirectIntBuffer(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransform(Transform transform) {
|
||||
super.setTransform(transform);
|
||||
|
||||
float[] vertexBufferData = volume.getVertexBufferData(this.transform);
|
||||
|
||||
gl.glGenBuffers(1, vbo);
|
||||
gl.glBindBuffer(GL_ARRAY_BUFFER, vbo.get(0));
|
||||
gl.glBufferData(GL_ARRAY_BUFFER, vertexBufferData.length * Float.BYTES,
|
||||
Buffers.newDirectFloatBuffer(vertexBufferData), GL_STATIC_DRAW);
|
||||
gl.glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void bindingTextures() {
|
||||
//ColorMap 2D texture
|
||||
this.colorTexture = getTextureID();
|
||||
@ -263,12 +284,8 @@ public class VolumeRender extends JOGLGraphicRender {
|
||||
program.use(gl);
|
||||
setUniforms();
|
||||
|
||||
IntBuffer intBuffer = IntBuffer.allocate(1);
|
||||
gl.glGenBuffers(1, intBuffer);
|
||||
int vertexBuffer = intBuffer.get(0);
|
||||
gl.glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
|
||||
float[] vertexBufferData = volume.getVertexBufferData(this.transform);
|
||||
gl.glBufferData(GL_ARRAY_BUFFER, vertexBufferData.length * Float.BYTES, Buffers.newDirectFloatBuffer(vertexBufferData), GL_STATIC_DRAW);
|
||||
gl.glBindBuffer(GL_ARRAY_BUFFER, vbo.get(0));
|
||||
|
||||
// 1st attribute buffer : vertices
|
||||
gl.glEnableVertexAttribArray(0);
|
||||
//gl.glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
|
||||
@ -293,9 +310,10 @@ public class VolumeRender extends JOGLGraphicRender {
|
||||
|
||||
gl.glDisable(GL_DEPTH_TEST);
|
||||
|
||||
gl.glDrawArrays(GL_TRIANGLES, 0, vertexBufferData.length / 3); // Starting from vertex 0; 3 vertices total -> 1 triangle
|
||||
gl.glDrawArrays(GL_TRIANGLES, 0, volume.getVertexNumber()); // Starting from vertex 0; 3 vertices total -> 1 triangle
|
||||
|
||||
gl.glDisableVertexAttribArray(0);
|
||||
gl.glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
gl.glActiveTexture(GL_TEXTURE0);
|
||||
gl.glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
@ -1,34 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\plot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\plot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\LaSW"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\slice"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\calipso"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\mesh"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\traj"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface\isosurface_2.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_2.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surf_elev_2.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\plot_cuace_3d_volume.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\plot_cuace_3d_volume_specular.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface\isosurface_2.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_2.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surf_elev_2.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\plot_cuace_3d_volume.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\plot_cuace_3d_volume_specular.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user