mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
using full model view transform for 3D plot
This commit is contained in:
parent
16a9d12261
commit
cc40c304bb
@ -1022,8 +1022,7 @@ public class GLChart implements GLEventListener {
|
||||
GL2 gl = drawable.getGL().getGL2();
|
||||
this.gl = gl;
|
||||
this.glu = GLU.createGLU(gl);
|
||||
//Background
|
||||
//gl.glClearColor(1f, 1f, 1f, 1.0f);
|
||||
|
||||
gl.glEnable(GL2.GL_POINT_SMOOTH);
|
||||
gl.glEnable(GL2.GL_DEPTH_TEST);
|
||||
gl.glShadeModel(GL2.GL_SMOOTH);
|
||||
|
||||
@ -74,7 +74,6 @@ public class MeshGraphic extends GraphicCollection3D {
|
||||
public void setVertexPosition(float[] value) {
|
||||
vertexPosition = value;
|
||||
updateExtent();
|
||||
//calculateNormalVectors(vertexData);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,6 +103,7 @@ public class MeshGraphic extends GraphicCollection3D {
|
||||
public void setRows(int value) {
|
||||
this.rows = value;
|
||||
this.columns = this.getVertexNumber() / value;
|
||||
calculateNormalVectors(vertexPosition);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -121,6 +121,7 @@ public class MeshGraphic extends GraphicCollection3D {
|
||||
public void setColumns(int value) {
|
||||
this.columns = value;
|
||||
this.rows = this.getVertexNumber() / value;
|
||||
calculateNormalVectors(vertexPosition);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -74,7 +74,7 @@ public class TriMeshGraphic extends GraphicCollection3D {
|
||||
public void setVertexPosition(float[] value) {
|
||||
vertexPosition = value;
|
||||
updateExtent();
|
||||
//calculateNormalVectors(vertexPosition);
|
||||
calculateNormalVectors(vertexPosition);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package org.meteoinfo.chart.graphic;
|
||||
|
||||
import org.meteoinfo.chart.jogl.Transform;
|
||||
import org.meteoinfo.common.Extent;
|
||||
import org.meteoinfo.geometry.colors.OpacityTransferFunction;
|
||||
import org.meteoinfo.chart.render.jogl.RayCastingType;
|
||||
import org.meteoinfo.common.Extent3D;
|
||||
@ -19,7 +20,6 @@ import java.util.List;
|
||||
import static org.joml.Math.clamp;
|
||||
|
||||
public class VolumeGraphic extends GraphicCollection3D {
|
||||
//public static Buffer buffer = null;
|
||||
final int width;
|
||||
final int height;
|
||||
final int depth;
|
||||
@ -165,6 +165,67 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
this.setSingleLegend(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExtent(Extent value) {
|
||||
super.setExtent(value);
|
||||
|
||||
Extent3D extent = (Extent3D) this.getExtent();
|
||||
float xMin = (float) extent.minX;
|
||||
float xMax = (float) extent.maxX;
|
||||
float yMin = (float) extent.minY;
|
||||
float yMax = (float) extent.maxY;
|
||||
float zMin = (float) extent.minZ;
|
||||
float zMax = (float) extent.maxZ;
|
||||
float[] p0 = new float[]{xMin, yMin, zMin};
|
||||
float[] p1 = new float[]{xMax, yMin, zMin};
|
||||
float[] p2 = new float[]{xMax, yMax, zMin};
|
||||
float[] p3 = new float[]{xMin, yMax, zMin};
|
||||
float[] p4 = new float[]{xMin, yMin, zMax};
|
||||
float[] p5 = new float[]{xMax, yMin, zMax};
|
||||
float[] p6 = new float[]{xMax, yMax, zMax};
|
||||
float[] p7 = new float[]{xMin, yMax, zMax};
|
||||
this.aabbMin = p0;
|
||||
this.aabbMax = p6;
|
||||
this.vertexBufferData = new float[] {
|
||||
p0[0], p0[1], p0[2], // triangle 1 : begin
|
||||
p1[0], p1[1], p1[2],
|
||||
p4[0], p4[1], p4[2], // triangle 1 : end
|
||||
p4[0], p4[1], p4[2], // triangle 2 : begin
|
||||
p5[0], p5[1], p5[2],
|
||||
p1[0], p1[1], p1[2], // triangle 2 : end
|
||||
p1[0], p1[1], p1[2],
|
||||
p5[0], p5[1], p5[2],
|
||||
p2[0], p2[1], p2[2], //3
|
||||
p5[0], p5[1], p5[2],
|
||||
p2[0], p2[1], p2[2],
|
||||
p6[0], p6[1], p6[2], //4
|
||||
p2[0], p2[1], p2[2],
|
||||
p6[0], p6[1], p6[2],
|
||||
p3[0], p3[1], p3[2], //5
|
||||
p6[0], p6[1], p6[2],
|
||||
p3[0], p3[1], p3[2],
|
||||
p7[0], p7[1], p7[2], //6
|
||||
p3[0], p3[1], p3[2],
|
||||
p7[0], p7[1], p7[2],
|
||||
p0[0], p0[1], p0[2], //7
|
||||
p7[0], p7[1], p7[2],
|
||||
p0[0], p0[1], p0[2],
|
||||
p4[0], p4[1], p4[2], //8
|
||||
p0[0], p0[1], p0[2],
|
||||
p1[0], p1[1], p1[2],
|
||||
p3[0], p3[1], p3[2], //9
|
||||
p1[0], p1[1], p1[2],
|
||||
p3[0], p3[1], p3[2],
|
||||
p2[0], p2[1], p2[2], //10
|
||||
p4[0], p4[1], p4[2],
|
||||
p5[0], p5[1], p5[2],
|
||||
p7[0], p7[1], p7[2], //11
|
||||
p5[0], p5[1], p5[2],
|
||||
p7[0], p7[1], p7[2],
|
||||
p6[0], p6[1], p6[2], //12
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Set color map
|
||||
* @param colorMap Color map
|
||||
@ -434,7 +495,7 @@ public class VolumeGraphic extends GraphicCollection3D {
|
||||
this.rayCastingType = RayCastingType.valueOf(value.toUpperCase());
|
||||
}
|
||||
|
||||
final float[] vertexBufferData = new float[]{
|
||||
private float[] vertexBufferData = new float[]{
|
||||
-1.0f, -1.0f, -1.0f, // triangle 1 : begin
|
||||
-1.0f, -1.0f, 1.0f,
|
||||
-1.0f, 1.0f, 1.0f, // triangle 1 : end
|
||||
|
||||
@ -33,7 +33,7 @@ public class PipeShape extends PolylineZShape {
|
||||
this.setPoints(shape.getPoints());
|
||||
this.radius = radius;
|
||||
this.steps = steps;
|
||||
//generatePipe();
|
||||
generatePipe();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package org.meteoinfo.chart.jogl;
|
||||
|
||||
import com.jogamp.common.nio.Buffers;
|
||||
import com.jogamp.opengl.GL2;
|
||||
import com.jogamp.opengl.GLAutoDrawable;
|
||||
import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
|
||||
@ -30,6 +31,7 @@ import java.awt.*;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.List;
|
||||
|
||||
public class EarthGLPlot extends GLPlot {
|
||||
@ -220,7 +222,27 @@ public class EarthGLPlot extends GLPlot {
|
||||
|
||||
gl.glPushMatrix();
|
||||
|
||||
Vector3f center = transform.getCenter();
|
||||
Vector3f scale = transform.getScale();
|
||||
this.modelViewMatrix = new Matrix4f();
|
||||
if (pitchAngle != 0) {
|
||||
float ss = getScale();
|
||||
modelViewMatrix.translate(0, 0, ss);
|
||||
modelViewMatrix.rotate((float) Math.toRadians(70.f * (pitchAngle / 90.f)), 1.0f, 0.0f, 0.0f);
|
||||
modelViewMatrix.translate(0, 0, -ss);
|
||||
}
|
||||
modelViewMatrix.rotate((float) Math.toRadians(angleX), 1.0f, 0.0f, 0.0f);
|
||||
modelViewMatrix.rotate((float) Math.toRadians(angleY), 0.0f, 0.0f, 1.0f);
|
||||
if (headAngle != 0) {
|
||||
modelViewMatrix.rotate((float) Math.toRadians(headAngle), 0.0f, 1.0f, 0.0f);
|
||||
}
|
||||
modelViewMatrix.scale(scale);
|
||||
modelViewMatrix.translate(center.negate());
|
||||
|
||||
FloatBuffer fb = Buffers.newDirectFloatBuffer(16);
|
||||
gl.glLoadMatrixf(modelViewMatrix.get(fb));
|
||||
|
||||
/*if (pitchAngle != 0) {
|
||||
float scale = getScale();
|
||||
gl.glTranslatef(0, 0, scale);
|
||||
gl.glRotatef(70.f * (pitchAngle / 90.f), 1.0f, 0.0f, 0.0f);
|
||||
@ -230,7 +252,7 @@ public class EarthGLPlot extends GLPlot {
|
||||
gl.glRotatef(angleY, 0.0f, 0.0f, 1.0f);
|
||||
if (headAngle != 0) {
|
||||
gl.glRotatef(headAngle, 0.0f, 1.0f, 0.0f);
|
||||
}
|
||||
}*/
|
||||
|
||||
this.updateMatrix(gl);
|
||||
|
||||
@ -281,126 +303,6 @@ public class EarthGLPlot extends GLPlot {
|
||||
this.alwaysUpdateBuffers = false;
|
||||
}
|
||||
|
||||
public void display_bak(GLAutoDrawable drawable) {
|
||||
final GL2 gl = drawable.getGL().getGL2();
|
||||
float[] rgba = this.background.getRGBComponents(null);
|
||||
gl.glClearColor(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
|
||||
gl.glLoadIdentity();
|
||||
|
||||
this.lighting.setPosition(gl);
|
||||
|
||||
gl.glPushMatrix();
|
||||
|
||||
gl.glShadeModel(GL2.GL_SMOOTH);
|
||||
|
||||
gl.glEnable(GL2.GL_BLEND);
|
||||
gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
|
||||
//gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE);
|
||||
|
||||
if (this.antialias) {
|
||||
if (this.sampleBuffers)
|
||||
gl.glEnable(GL2.GL_MULTISAMPLE);
|
||||
else {
|
||||
gl.glEnable(GL2.GL_LINE_SMOOTH);
|
||||
gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_NICEST);
|
||||
gl.glEnable(GL2.GL_POINT_SMOOTH);
|
||||
gl.glHint(GL2.GL_POINT_SMOOTH_HINT, GL2.GL_NICEST);
|
||||
//gl.glEnable(GL2.GL_POLYGON_SMOOTH);
|
||||
//gl.glHint(GL2.GL_POLYGON_SMOOTH_HINT, GL2.GL_NICEST);
|
||||
}
|
||||
} else {
|
||||
if (this.sampleBuffers)
|
||||
gl.glDisable(GL2.GL_MULTISAMPLE);
|
||||
else {
|
||||
gl.glDisable(GL2.GL_LINE_SMOOTH);
|
||||
gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_FASTEST);
|
||||
gl.glDisable(GL2.GL_POINT_SMOOTH);
|
||||
gl.glHint(GL2.GL_POINT_SMOOTH_HINT, GL2.GL_FASTEST);
|
||||
//gl.glDisable(GL2.GL_POLYGON_SMOOTH);
|
||||
//gl.glHint(GL2.GL_POLYGON_SMOOTH_HINT, GL2.GL_FASTEST);
|
||||
}
|
||||
}
|
||||
|
||||
//gl.glScalef(scaleX, scaleY, scaleZ);
|
||||
|
||||
if (pitchAngle != 0) {
|
||||
float scale = getScale();
|
||||
gl.glTranslatef(0, 0, scale);
|
||||
gl.glRotatef(70.f * (pitchAngle / 90.f), 1.0f, 0.0f, 0.0f);
|
||||
gl.glTranslatef(0, 0, -scale);
|
||||
}
|
||||
gl.glRotatef(angleX, 1.0f, 0.0f, 0.0f);
|
||||
gl.glRotatef(angleY, 0.0f, 0.0f, 1.0f);
|
||||
if (headAngle != 0) {
|
||||
gl.glRotatef(headAngle, 0.0f, 1.0f, 0.0f);
|
||||
}
|
||||
|
||||
this.updateMatrix(gl);
|
||||
|
||||
this.setLight(gl);
|
||||
|
||||
this.updateTextRender(this.xAxis.getTickLabelFont());
|
||||
|
||||
//Draw graphics
|
||||
for (int m = 0; m < this.graphics.getNumGraphics(); m++) {
|
||||
Graphic graphic = this.graphics.get(m);
|
||||
drawGraphics(gl, graphic);
|
||||
}
|
||||
|
||||
//Draw text
|
||||
for (int m = 0; m < this.graphics.getNumGraphics(); m++) {
|
||||
Graphic graphic = this.graphics.get(m);
|
||||
if (graphic.getNumGraphics() == 1) {
|
||||
Shape shape = graphic.getGraphicN(0).getShape();
|
||||
if (shape.getShapeType() == ShapeTypes.TEXT) {
|
||||
this.drawText(gl, (ChartText3D) shape);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < graphic.getNumGraphics(); i++) {
|
||||
Shape shape = graphic.getGraphicN(i).getShape();
|
||||
if (shape.getShapeType() == ShapeTypes.TEXT) {
|
||||
this.drawText(gl, (ChartText3D) shape);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Stop lighting
|
||||
if (this.lighting.isEnable()) {
|
||||
this.lighting.stop(gl);
|
||||
}
|
||||
|
||||
//Draw axis
|
||||
this.drawAllZAxis(gl);
|
||||
|
||||
//Draw legend
|
||||
gl.glPopMatrix();
|
||||
this.updateMatrix(gl);
|
||||
if (!this.legends.isEmpty()) {
|
||||
ChartColorBar legend = (ChartColorBar) this.legends.get(0);
|
||||
if (legend.getLegendScheme().getColorMap() == null)
|
||||
this.drawLegend(gl, legend);
|
||||
else
|
||||
this.drawColorbar(gl, legend);
|
||||
}
|
||||
|
||||
//Draw title
|
||||
this.drawTitle();
|
||||
|
||||
this.textRenderer.dispose();
|
||||
this.textRenderer = null;
|
||||
|
||||
gl.glFlush();
|
||||
|
||||
//Do screen-shot
|
||||
if (this.doScreenShot) {
|
||||
AWTGLReadBufferUtil glReadBufferUtil = new AWTGLReadBufferUtil(drawable.getGLProfile(), false);
|
||||
this.screenImage = glReadBufferUtil.readPixelsToBufferedImage(drawable.getGL(), true);
|
||||
this.doScreenShot = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawZAxis(GL2 gl, PointF loc) {
|
||||
float[] rgba;
|
||||
@ -417,14 +319,14 @@ public class EarthGLPlot extends GLPlot {
|
||||
gl.glLineWidth(this.zAxis.getLineWidth() * this.dpiScale);
|
||||
gl.glBegin(GL2.GL_LINES);
|
||||
Vector3f xyz = SphericalTransform.transform(loc.X, loc.Y, (float) this.dataExtent.minZ);
|
||||
x = this.transform.transform_x(xyz.x);
|
||||
y = this.transform.transform_y(xyz.y);
|
||||
z = this.transform.transform_z(xyz.z);
|
||||
x = xyz.x;
|
||||
y = xyz.y;
|
||||
z = xyz.z;
|
||||
gl.glVertex3f(x, y, z);
|
||||
xyz = SphericalTransform.transform(loc.X, loc.Y, (float) this.dataExtent.maxZ);
|
||||
x = this.transform.transform_x(xyz.x);
|
||||
y = this.transform.transform_y(xyz.y);
|
||||
z = this.transform.transform_z(xyz.z);
|
||||
x = xyz.x;
|
||||
y = xyz.y;
|
||||
z = xyz.z;
|
||||
gl.glVertex3f(x, y, z);
|
||||
gl.glEnd();
|
||||
|
||||
@ -438,6 +340,7 @@ public class EarthGLPlot extends GLPlot {
|
||||
float tickLen = this.zAxis.getTickLength() * this.lenScale;
|
||||
xAlign = XAlign.RIGHT;
|
||||
yAlign = YAlign.CENTER;
|
||||
Vector3f center = this.transform.getCenter();
|
||||
strWidth = 0.0f;
|
||||
for (int i = 0; i < this.zAxis.getTickValues().length; i += skip) {
|
||||
v = (float) this.zAxis.getTickValues()[i];
|
||||
@ -446,19 +349,19 @@ public class EarthGLPlot extends GLPlot {
|
||||
}
|
||||
|
||||
xyz = SphericalTransform.transform(loc.X, loc.Y, v);
|
||||
x = this.transform.transform_x(xyz.x);
|
||||
y = this.transform.transform_y(xyz.y);
|
||||
z = this.transform.transform_z(xyz.z);
|
||||
x = xyz.x;
|
||||
y = xyz.y;
|
||||
z = xyz.z;
|
||||
x1 = x;
|
||||
y1 = y;
|
||||
if (x < 0) {
|
||||
if (y > 0) {
|
||||
if (x < center.x) {
|
||||
if (y > center.y) {
|
||||
y1 += tickLen;
|
||||
} else {
|
||||
x1 -= tickLen;
|
||||
}
|
||||
} else {
|
||||
if (y > 0) {
|
||||
if (y > center.y) {
|
||||
x1 += tickLen;
|
||||
} else {
|
||||
y1 -= tickLen;
|
||||
@ -489,19 +392,19 @@ public class EarthGLPlot extends GLPlot {
|
||||
if (label != null) {
|
||||
v = (float) (dataExtent.minZ + dataExtent.maxZ) / 2;
|
||||
xyz = SphericalTransform.transform(loc.X, loc.Y, v);
|
||||
x = this.transform.transform_x(xyz.x);
|
||||
y = this.transform.transform_y(xyz.y);
|
||||
z = this.transform.transform_z(xyz.z);
|
||||
x = xyz.x;
|
||||
y = xyz.y;
|
||||
z = xyz.z;
|
||||
x1 = x;
|
||||
y1 = y;
|
||||
if (x < 0) {
|
||||
if (y > 0) {
|
||||
if (x < center.x) {
|
||||
if (y > center.y) {
|
||||
y1 += tickLen;
|
||||
} else {
|
||||
x1 -= tickLen;
|
||||
}
|
||||
} else {
|
||||
if (y > 0) {
|
||||
if (y > center.y) {
|
||||
x1 += tickLen;
|
||||
} else {
|
||||
y1 -= tickLen;
|
||||
@ -533,10 +436,10 @@ public class EarthGLPlot extends GLPlot {
|
||||
gl.glLineWidth(this.zAxis.getLineWidth() * this.dpiScale);
|
||||
gl.glBegin(GL2.GL_LINES);
|
||||
Vector3f xyz = SphericalTransform.transform(loc.X, loc.Y, (float) this.dataExtent.minZ);
|
||||
xyz = this.transform.transform(xyz);
|
||||
//xyz = this.transform.transform(xyz);
|
||||
gl.glVertex3f(xyz.x, xyz.y, xyz.z);
|
||||
Vector3f xyz1 = SphericalTransform.transform(loc.X, loc.Y, (float) this.dataExtent.maxZ);
|
||||
xyz1 = this.transform.transform(xyz1);
|
||||
//xyz1 = this.transform.transform(xyz1);
|
||||
gl.glVertex3f(xyz1.x, xyz1.y, xyz1.z);
|
||||
gl.glEnd();
|
||||
|
||||
@ -558,7 +461,7 @@ public class EarthGLPlot extends GLPlot {
|
||||
}
|
||||
|
||||
xyz = SphericalTransform.transform(loc.X, loc.Y, v);
|
||||
xyz = this.transform.transform(xyz);
|
||||
//xyz = this.transform.transform(xyz);
|
||||
mvMatrix.transformPosition(xyz);
|
||||
xyz1 = new Vector3f(xyz.x, xyz.y, xyz.z);
|
||||
float xShift;
|
||||
@ -596,7 +499,7 @@ public class EarthGLPlot extends GLPlot {
|
||||
if (label != null) {
|
||||
v = (float) (dataExtent.minZ + dataExtent.maxZ) / 2;
|
||||
xyz = SphericalTransform.transform(loc.X, loc.Y, v);
|
||||
xyz = this.transform.transform(xyz);
|
||||
//xyz = this.transform.transform(xyz);
|
||||
mvMatrix.transformPosition(xyz);
|
||||
if (left) {
|
||||
xyz.x -= tickLen;
|
||||
|
||||
@ -10,9 +10,7 @@ import com.jogamp.opengl.util.awt.TextRenderer;
|
||||
import com.jogamp.opengl.util.gl2.GLUT;
|
||||
import com.jogamp.opengl.util.texture.Texture;
|
||||
import com.jogamp.opengl.util.texture.awt.AWTTextureIO;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector2f;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.*;
|
||||
import org.meteoinfo.chart.*;
|
||||
import org.meteoinfo.chart.axis.Axis;
|
||||
import org.meteoinfo.chart.graphic.*;
|
||||
@ -46,6 +44,7 @@ import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.Math;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.ArrayList;
|
||||
@ -97,6 +96,8 @@ public class GLPlot extends Plot {
|
||||
protected int viewport[] = new int[4];
|
||||
protected float mvmatrix[] = new float[16];
|
||||
protected float projmatrix[] = new float[16];
|
||||
protected Matrix4f modelViewMatrix = new Matrix4f();
|
||||
protected Matrix4f projectionMatrix = new Matrix4f();
|
||||
protected Matrix4f viewProjMatrix = new Matrix4f();
|
||||
|
||||
protected float angleX;
|
||||
@ -1229,13 +1230,19 @@ public class GLPlot extends Plot {
|
||||
|
||||
gl.glPushMatrix();
|
||||
|
||||
//gl.glScalef(scaleX, scaleY, scaleZ);
|
||||
|
||||
gl.glRotatef(angleX, 1.0f, 0.0f, 0.0f);
|
||||
gl.glRotatef(angleY, 0.0f, 0.0f, 1.0f);
|
||||
Vector3f center = transform.getCenter();
|
||||
Vector3f scale = transform.getScale();
|
||||
this.modelViewMatrix = new Matrix4f();
|
||||
modelViewMatrix.rotate((float) Math.toRadians(angleX), 1.0f, 0.0f, 0.0f);
|
||||
modelViewMatrix.rotate((float) Math.toRadians(angleY), 0.0f, 0.0f, 1.0f);
|
||||
if (headAngle != 0) {
|
||||
gl.glRotatef(headAngle, 0.0f, 1.0f, 0.0f);
|
||||
modelViewMatrix.rotate((float) Math.toRadians(headAngle), 0.0f, 1.0f, 0.0f);
|
||||
}
|
||||
modelViewMatrix.scale(scale);
|
||||
modelViewMatrix.translate(center.negate());
|
||||
|
||||
FloatBuffer fb = Buffers.newDirectFloatBuffer(16);
|
||||
gl.glLoadMatrixf(modelViewMatrix.get(fb));
|
||||
|
||||
this.updateMatrix(gl);
|
||||
|
||||
@ -1324,24 +1331,24 @@ public class GLPlot extends Plot {
|
||||
}
|
||||
|
||||
private void enableClipPlane(GL2 gl) {
|
||||
float xMin = this.transform.transform_x((float) axesExtent.minX);
|
||||
float xMax = this.transform.transform_x((float) axesExtent.maxX) + 0.01f;
|
||||
float yMin = this.transform.transform_y((float) axesExtent.minY);
|
||||
float yMax = this.transform.transform_y((float) axesExtent.maxY) + 0.01f;
|
||||
float zMin = this.transform.transform_z((float) axesExtent.minZ);
|
||||
float zMax = this.transform.transform_z((float) axesExtent.maxZ) + 0.01f;
|
||||
float s = 1.01f;
|
||||
gl.glClipPlane(GL2.GL_CLIP_PLANE0, new double[]{1, 0, 0, xMax}, 0);
|
||||
float xMin = (float) axesExtent.minX - (float) axesExtent.getWidth() * 0.001f;
|
||||
float xMax = (float) axesExtent.maxX + (float) axesExtent.getWidth() * 0.001f;
|
||||
float yMin = (float) axesExtent.minY - (float) axesExtent.getHeight() * 0.001f;
|
||||
float yMax = (float) axesExtent.maxY + (float) axesExtent.getHeight() * 0.001f;
|
||||
float zMin = (float) axesExtent.minZ - (float) axesExtent.getZLength() * 0.001f;
|
||||
float zMax = (float) axesExtent.maxZ + (float) axesExtent.getZLength() * 0.001f;
|
||||
|
||||
gl.glClipPlane(GL2.GL_CLIP_PLANE0, new double[]{-1, 0, 0, xMax}, 0);
|
||||
gl.glEnable(GL2.GL_CLIP_PLANE0);
|
||||
gl.glClipPlane(GL2.GL_CLIP_PLANE1, new double[]{-1, 0, 0, xMax}, 0);
|
||||
gl.glClipPlane(GL2.GL_CLIP_PLANE1, new double[]{1, 0, 0, -xMin}, 0);
|
||||
gl.glEnable(GL2.GL_CLIP_PLANE1);
|
||||
gl.glClipPlane(GL2.GL_CLIP_PLANE2, new double[]{0, -1, 0, yMax}, 0);
|
||||
gl.glEnable(GL2.GL_CLIP_PLANE2);
|
||||
gl.glClipPlane(GL2.GL_CLIP_PLANE3, new double[]{0, 1, 0, yMax}, 0);
|
||||
gl.glClipPlane(GL2.GL_CLIP_PLANE3, new double[]{0, 1, 0, -yMin}, 0);
|
||||
gl.glEnable(GL2.GL_CLIP_PLANE3);
|
||||
gl.glClipPlane(GL2.GL_CLIP_PLANE4, new double[]{0, 0, 1, zMax}, 0);
|
||||
gl.glClipPlane(GL2.GL_CLIP_PLANE4, new double[]{0, 0, -1, zMax}, 0);
|
||||
gl.glEnable(GL2.GL_CLIP_PLANE4);
|
||||
gl.glClipPlane(GL2.GL_CLIP_PLANE5, new double[]{0, 0, -1, zMax}, 0);
|
||||
gl.glClipPlane(GL2.GL_CLIP_PLANE5, new double[]{0, 0, 1, -zMin}, 0);
|
||||
gl.glEnable(GL2.GL_CLIP_PLANE5);
|
||||
}
|
||||
|
||||
@ -1356,8 +1363,8 @@ public class GLPlot extends Plot {
|
||||
gl.glEnable(GL2.GL_COLOR_MATERIAL);
|
||||
//double side normalize
|
||||
gl.glLightModeli(GL2.GL_LIGHT_MODEL_TWO_SIDE, GL2.GL_TRUE);
|
||||
//gl.glEnable(GL2.GL_AUTO_NORMAL);
|
||||
//gl.glEnable(GL2.GL_NORMALIZE);
|
||||
//gl.glEnable(GL2.GL_RESCALE_NORMAL);
|
||||
gl.glEnable(GL2.GL_NORMALIZE);
|
||||
//gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, FloatBuffer.wrap(this.lighting.mat_diffuse));
|
||||
}
|
||||
}
|
||||
@ -1392,11 +1399,16 @@ public class GLPlot extends Plot {
|
||||
*/
|
||||
protected void drawBase(GL2 gl) {
|
||||
float xMin, xMax, yMin, yMax, zMin;
|
||||
xMin = this.transform.transform_x((float) axesExtent.minX);
|
||||
xMin = (float) axesExtent.minX;
|
||||
xMax = (float) axesExtent.maxX;
|
||||
yMin = (float) axesExtent.minY;
|
||||
yMax = (float) axesExtent.maxY;
|
||||
zMin = (float) axesExtent.minZ;
|
||||
/*xMin = this.transform.transform_x((float) axesExtent.minX);
|
||||
xMax = this.transform.transform_x((float) axesExtent.maxX);
|
||||
yMin = this.transform.transform_y((float) axesExtent.minY);
|
||||
yMax = this.transform.transform_y((float) axesExtent.maxY);
|
||||
zMin = this.transform.transform_z((float) axesExtent.minZ);
|
||||
zMin = this.transform.transform_z((float) axesExtent.minZ);*/
|
||||
|
||||
float[] rgba = this.boxColor.getRGBComponents(null);
|
||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
@ -1420,8 +1432,10 @@ public class GLPlot extends Plot {
|
||||
gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport, 0);
|
||||
gl.glGetFloatv(GL2.GL_MODELVIEW_MATRIX, mvmatrix, 0);
|
||||
gl.glGetFloatv(GL2.GL_PROJECTION_MATRIX, projmatrix, 0);
|
||||
viewProjMatrix = toMatrix(projmatrix).
|
||||
mul(toMatrix(mvmatrix));
|
||||
modelViewMatrix = toMatrix(mvmatrix);
|
||||
projectionMatrix = toMatrix(projmatrix);
|
||||
viewProjMatrix = projectionMatrix.
|
||||
mul(modelViewMatrix);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1547,12 +1561,18 @@ public class GLPlot extends Plot {
|
||||
|
||||
protected void drawBox(GL2 gl) {
|
||||
float xMin, xMax, yMin, yMax, zMin, zMax;
|
||||
xMin = this.transform.transform_x((float) axesExtent.minX);
|
||||
xMin = (float) axesExtent.minX;
|
||||
xMax = (float) axesExtent.maxX;
|
||||
yMin = (float) axesExtent.minY;
|
||||
yMax = (float) axesExtent.maxY;
|
||||
zMin = (float) axesExtent.minZ;
|
||||
zMax = (float) axesExtent.maxZ;
|
||||
/*xMin = this.transform.transform_x((float) axesExtent.minX);
|
||||
xMax = this.transform.transform_x((float) axesExtent.maxX);
|
||||
yMin = this.transform.transform_y((float) axesExtent.minY);
|
||||
yMax = this.transform.transform_y((float) axesExtent.maxY);
|
||||
zMin = this.transform.transform_z((float) axesExtent.minZ);
|
||||
zMax = this.transform.transform_z((float) axesExtent.maxZ);
|
||||
zMax = this.transform.transform_z((float) axesExtent.maxZ);*/
|
||||
|
||||
float[] rgba = this.boxColor.getRGBComponents(null);
|
||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
@ -1595,12 +1615,18 @@ public class GLPlot extends Plot {
|
||||
|
||||
protected void drawBoundingBox(GL2 gl) {
|
||||
float xMin, xMax, yMin, yMax, zMin, zMax;
|
||||
xMin = this.transform.transform_x((float) axesExtent.minX);
|
||||
xMin = (float) axesExtent.minX;
|
||||
xMax = (float) axesExtent.maxX;
|
||||
yMin = (float) axesExtent.minY;
|
||||
yMax = (float) axesExtent.maxY;
|
||||
zMin = (float) axesExtent.minZ;
|
||||
zMax = (float) axesExtent.maxZ;
|
||||
/*xMin = this.transform.transform_x((float) axesExtent.minX);
|
||||
xMax = this.transform.transform_x((float) axesExtent.maxX);
|
||||
yMin = this.transform.transform_y((float) axesExtent.minY);
|
||||
yMax = this.transform.transform_y((float) axesExtent.maxY);
|
||||
zMin = this.transform.transform_z((float) axesExtent.minZ);
|
||||
zMax = this.transform.transform_z((float) axesExtent.maxZ);
|
||||
zMax = this.transform.transform_z((float) axesExtent.maxZ);*/
|
||||
|
||||
float[] rgba = this.boxColor.getRGBComponents(null);
|
||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
@ -1643,12 +1669,18 @@ public class GLPlot extends Plot {
|
||||
|
||||
protected void drawXYGridLine(GL2 gl) {
|
||||
float xMin, xMax, yMin, yMax, zMin, zMax;
|
||||
xMin = this.transform.transform_x((float) axesExtent.minX);
|
||||
xMin = (float) axesExtent.minX;
|
||||
xMax = (float) axesExtent.maxX;
|
||||
yMin = (float) axesExtent.minY;
|
||||
yMax = (float) axesExtent.maxY;
|
||||
zMin = (float) axesExtent.minZ;
|
||||
zMax = (float) axesExtent.maxZ;
|
||||
/*xMin = this.transform.transform_x((float) axesExtent.minX);
|
||||
xMax = this.transform.transform_x((float) axesExtent.maxX);
|
||||
yMin = this.transform.transform_y((float) axesExtent.minY);
|
||||
yMax = this.transform.transform_y((float) axesExtent.maxY);
|
||||
zMin = this.transform.transform_z((float) axesExtent.minZ);
|
||||
zMax = this.transform.transform_z((float) axesExtent.maxZ);
|
||||
zMax = this.transform.transform_z((float) axesExtent.maxZ);*/
|
||||
|
||||
float[] rgba;
|
||||
float x, y, x1, y1, v;
|
||||
@ -1668,20 +1700,20 @@ public class GLPlot extends Plot {
|
||||
|
||||
this.xAxis.updateTickLabels();
|
||||
java.util.List<ChartText> tlabs = this.xAxis.getTickLabels();
|
||||
float axisLen = this.toScreenLength(-1.0f, y, -1.0f, 1.0f, y, -1.0f);
|
||||
float axisLen = this.toScreenLength(xMin, y, zMin, xMax, y, zMin);
|
||||
skip = getLabelGap(this.xAxis.getTickLabelFont(), tlabs, axisLen);
|
||||
for (int i = 0; i < this.xAxis.getTickValues().length; i += skip) {
|
||||
v = (float) this.xAxis.getTickValues()[i];
|
||||
if (v < axesExtent.minX || v > axesExtent.maxX) {
|
||||
if (v <= axesExtent.minX || v >= axesExtent.maxX) {
|
||||
continue;
|
||||
}
|
||||
v = this.transform.transform_x(v);
|
||||
//v = this.transform.transform_x(v);
|
||||
if (i == tlabs.size()) {
|
||||
break;
|
||||
}
|
||||
|
||||
//Draw grid line
|
||||
if (this.gridLine.isDrawXLine() && (v != -1.0f && v != 1.0f)) {
|
||||
if (this.gridLine.isDrawXLine()) {
|
||||
rgba = this.gridLine.getColor().getRGBComponents(null);
|
||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
gl.glLineWidth(this.gridLine.getSize() * this.dpiScale);
|
||||
@ -1710,20 +1742,20 @@ public class GLPlot extends Plot {
|
||||
|
||||
this.yAxis.updateTickLabels();
|
||||
tlabs = this.yAxis.getTickLabels();
|
||||
axisLen = this.toScreenLength(x, -1.0f, -1.0f, x, 1.0f, -1.0f);
|
||||
axisLen = this.toScreenLength(x, yMin, zMin, x, yMax, zMin);
|
||||
skip = getLabelGap(this.yAxis.getTickLabelFont(), tlabs, axisLen);
|
||||
for (int i = 0; i < this.yAxis.getTickValues().length; i += skip) {
|
||||
v = (float) this.yAxis.getTickValues()[i];
|
||||
if (v < axesExtent.minY || v > axesExtent.maxY) {
|
||||
if (v <= axesExtent.minY || v >= axesExtent.maxY) {
|
||||
continue;
|
||||
}
|
||||
v = this.transform.transform_y(v);
|
||||
//v = this.transform.transform_y(v);
|
||||
if (i == tlabs.size()) {
|
||||
break;
|
||||
}
|
||||
|
||||
//Draw grid line
|
||||
if (this.gridLine.isDrawYLine() && (v != -1.0f && v != 1.0f)) {
|
||||
if (this.gridLine.isDrawYLine()) {
|
||||
rgba = this.gridLine.getColor().getRGBComponents(null);
|
||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
gl.glLineWidth(this.gridLine.getSize() * this.dpiScale);
|
||||
@ -1744,12 +1776,18 @@ public class GLPlot extends Plot {
|
||||
|
||||
protected void drawZGridLine(GL2 gl) {
|
||||
float xMin, xMax, yMin, yMax, zMin, zMax;
|
||||
xMin = this.transform.transform_x((float) axesExtent.minX);
|
||||
xMin = (float) axesExtent.minX;
|
||||
xMax = (float) axesExtent.maxX;
|
||||
yMin = (float) axesExtent.minY;
|
||||
yMax = (float) axesExtent.maxY;
|
||||
zMin = (float) axesExtent.minZ;
|
||||
zMax = (float) axesExtent.maxZ;
|
||||
/*xMin = this.transform.transform_x((float) axesExtent.minX);
|
||||
xMax = this.transform.transform_x((float) axesExtent.maxX);
|
||||
yMin = this.transform.transform_y((float) axesExtent.minY);
|
||||
yMax = this.transform.transform_y((float) axesExtent.maxY);
|
||||
zMin = this.transform.transform_z((float) axesExtent.minZ);
|
||||
zMax = this.transform.transform_z((float) axesExtent.maxZ);
|
||||
zMax = this.transform.transform_z((float) axesExtent.maxZ);*/
|
||||
|
||||
float[] rgba;
|
||||
float x, y, x1, y1, v;
|
||||
@ -1787,23 +1825,23 @@ public class GLPlot extends Plot {
|
||||
skip = getLabelGap(this.zAxis.getTickLabelFont(), tlabs, axisLen);
|
||||
for (int i = 0; i < this.zAxis.getTickValues().length; i += skip) {
|
||||
v = (float) this.zAxis.getTickValues()[i];
|
||||
if (v < axesExtent.minZ || v > axesExtent.maxZ) {
|
||||
if (v <= axesExtent.minZ || v >= axesExtent.maxZ) {
|
||||
continue;
|
||||
}
|
||||
v = this.transform.transform_z(v);
|
||||
//v = this.transform.transform_z(v);
|
||||
if (i == tlabs.size()) {
|
||||
break;
|
||||
}
|
||||
|
||||
//Draw grid line
|
||||
if (this.gridLine.isDrawZLine() && this.boxed && (v != zMin && v != zMax)) {
|
||||
if (this.gridLine.isDrawZLine() && this.boxed) {
|
||||
rgba = this.gridLine.getColor().getRGBComponents(null);
|
||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
gl.glLineWidth(this.gridLine.getSize() * this.dpiScale);
|
||||
gl.glBegin(GL2.GL_LINE_STRIP);
|
||||
gl.glVertex3f(x, y, v);
|
||||
if (x < 0) {
|
||||
if (y > 0) {
|
||||
if (x < x1) {
|
||||
if (y > y1) {
|
||||
gl.glVertex3f(x1, y, v);
|
||||
gl.glVertex3f(x1, y1, v);
|
||||
} else {
|
||||
@ -1811,7 +1849,7 @@ public class GLPlot extends Plot {
|
||||
gl.glVertex3f(x1, y1, v);
|
||||
}
|
||||
} else {
|
||||
if (y > 0) {
|
||||
if (y > y1) {
|
||||
gl.glVertex3f(x, y1, v);
|
||||
gl.glVertex3f(x1, y1, v);
|
||||
} else {
|
||||
@ -1853,12 +1891,18 @@ public class GLPlot extends Plot {
|
||||
|
||||
protected void drawAxis(GL2 gl) {
|
||||
float xMin, xMax, yMin, yMax, zMin, zMax;
|
||||
xMin = this.transform.transform_x((float) axesExtent.minX);
|
||||
xMin = (float) axesExtent.minX;
|
||||
xMax = (float) axesExtent.maxX;
|
||||
yMin = (float) axesExtent.minY;
|
||||
yMax = (float) axesExtent.maxY;
|
||||
zMin = (float) axesExtent.minZ;
|
||||
zMax = (float) axesExtent.maxZ;
|
||||
/*xMin = this.transform.transform_x((float) axesExtent.minX);
|
||||
xMax = this.transform.transform_x((float) axesExtent.maxX);
|
||||
yMin = this.transform.transform_y((float) axesExtent.minY);
|
||||
yMax = this.transform.transform_y((float) axesExtent.maxY);
|
||||
zMin = this.transform.transform_z((float) axesExtent.minZ);
|
||||
zMax = this.transform.transform_z((float) axesExtent.maxZ);
|
||||
zMax = this.transform.transform_z((float) axesExtent.maxZ);*/
|
||||
|
||||
gl.glDepthFunc(GL.GL_ALWAYS);
|
||||
|
||||
@ -1869,6 +1913,7 @@ public class GLPlot extends Plot {
|
||||
XAlign xAlign;
|
||||
YAlign yAlign;
|
||||
Rectangle2D rect;
|
||||
Vector3f center = this.transform.getCenter();
|
||||
float strWidth, strHeight;
|
||||
if (this.displayXY) {
|
||||
//Draw x/y axis lines
|
||||
@ -1887,12 +1932,12 @@ public class GLPlot extends Plot {
|
||||
gl.glEnd();
|
||||
|
||||
//x axis ticks
|
||||
float tickLen = this.xAxis.getTickLength() * this.lenScale;
|
||||
float tickLen = this.xAxis.getTickLength() * this.lenScale * transform.getYLength() / 2;
|
||||
this.xAxis.updateTickLabels();
|
||||
java.util.List<ChartText> tlabs = this.xAxis.getTickLabels();
|
||||
float axisLen = this.toScreenLength(xMin, y, zMin, xMax, y, zMin);
|
||||
skip = getLabelGap(this.xAxis.getTickLabelFont(), tlabs, axisLen);
|
||||
float y1 = y > 0 ? y + tickLen : y - tickLen;
|
||||
float y1 = y > center.y ? y + tickLen : y - tickLen;
|
||||
if (this.angleY < 90 || (this.angleY >= 180 && this.angleY < 270)) {
|
||||
xAlign = XAlign.LEFT;
|
||||
} else {
|
||||
@ -1913,7 +1958,7 @@ public class GLPlot extends Plot {
|
||||
if (v < axesExtent.minX || v > axesExtent.maxX) {
|
||||
continue;
|
||||
}
|
||||
v = this.transform.transform_x(v);
|
||||
//v = this.transform.transform_x(v);
|
||||
if (i == tlabs.size()) {
|
||||
break;
|
||||
}
|
||||
@ -1946,12 +1991,13 @@ public class GLPlot extends Plot {
|
||||
this.updateTextRender(label.getFont());
|
||||
strWidth += this.tickSpace;
|
||||
float angle = this.toScreenAngle(xMin, y, zMin, xMax, y, zMin);
|
||||
angle = y < 0 ? 270 - angle : 90 - angle;
|
||||
angle = y < center.y ? 270 - angle : 90 - angle;
|
||||
float yShift = Math.min(-strWidth, -strWidth);
|
||||
if (this.angleX <= -120) {
|
||||
yShift = -yShift;
|
||||
}
|
||||
drawString(gl, label, 0.0f, y1, zMin, XAlign.CENTER, yAlign, angle, 0, yShift);
|
||||
float x1 = (xMin + xMax) / 2;
|
||||
drawString(gl, label, x1, y1, zMin, XAlign.CENTER, yAlign, angle, 0, yShift);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1975,8 +2021,8 @@ public class GLPlot extends Plot {
|
||||
tlabs = this.yAxis.getTickLabels();
|
||||
axisLen = this.toScreenLength(x, yMin, zMin, x, yMax, zMin);
|
||||
skip = getLabelGap(this.yAxis.getTickLabelFont(), tlabs, axisLen);
|
||||
tickLen = this.yAxis.getTickLength() * this.lenScale;
|
||||
float x1 = x > 0 ? x + tickLen : x - tickLen;
|
||||
tickLen = this.yAxis.getTickLength() * this.lenScale * transform.getXLength() / 2;
|
||||
float x1 = x > center.x ? x + tickLen : x - tickLen;
|
||||
if (this.angleY < 90 || (this.angleY >= 180 && this.angleY < 270)) {
|
||||
xAlign = XAlign.RIGHT;
|
||||
} else {
|
||||
@ -1997,7 +2043,7 @@ public class GLPlot extends Plot {
|
||||
if (v < axesExtent.minY || v > axesExtent.maxY) {
|
||||
continue;
|
||||
}
|
||||
v = this.transform.transform_y(v);
|
||||
//v = this.transform.transform_y(v);
|
||||
if (i == tlabs.size()) {
|
||||
break;
|
||||
}
|
||||
@ -2029,13 +2075,14 @@ public class GLPlot extends Plot {
|
||||
if (label != null) {
|
||||
this.updateTextRender(label.getFont());
|
||||
strWidth += this.tickSpace;
|
||||
float angle = this.toScreenAngle(x, yMin, zMin, x, yMax, xMin);
|
||||
angle = x > 0 ? 270 - angle : 90 - angle;
|
||||
float angle = this.toScreenAngle(x, yMin, zMin, x, yMax, zMin);
|
||||
angle = x > center.x ? 270 - angle : 90 - angle;
|
||||
float yShift = Math.min(-strWidth, -strWidth);
|
||||
if (this.angleX <= -120) {
|
||||
yShift = -yShift;
|
||||
}
|
||||
drawString(gl, label, x1, 0.0f, zMin, XAlign.CENTER, yAlign, angle, 0, yShift);
|
||||
y1 = (yMin + yMax) / 2;
|
||||
drawString(gl, label, x1, y1, zMin, XAlign.CENTER, yAlign, angle, 0, yShift);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2065,11 +2112,16 @@ public class GLPlot extends Plot {
|
||||
YAlign yAlign;
|
||||
Rectangle2D rect;
|
||||
float strWidth, strHeight;
|
||||
Vector3f center = this.transform.getCenter();
|
||||
|
||||
x = this.transform.transform_x(loc.X);
|
||||
x = loc.X;
|
||||
y = loc.Y;
|
||||
float zMin = (float) axesExtent.minZ;
|
||||
float zMax = (float) axesExtent.maxZ;
|
||||
/*x = this.transform.transform_x(loc.X);
|
||||
y = this.transform.transform_y(loc.Y);
|
||||
float zMin = this.transform.transform_z((float) axesExtent.minZ);
|
||||
float zMax = this.transform.transform_z((float) axesExtent.maxZ);
|
||||
float zMax = this.transform.transform_z((float) axesExtent.maxZ);*/
|
||||
|
||||
//z axis line
|
||||
rgba = this.zAxis.getLineColor().getRGBComponents(null);
|
||||
@ -2087,15 +2139,15 @@ public class GLPlot extends Plot {
|
||||
skip = getLabelGap(this.zAxis.getTickLabelFont(), tlabs, axisLen);
|
||||
float x1 = x;
|
||||
float y1 = y;
|
||||
float tickLen = this.zAxis.getTickLength() * this.lenScale;
|
||||
if (x < 0) {
|
||||
if (y > 0) {
|
||||
float tickLen = this.zAxis.getTickLength() * this.lenScale * transform.getYLength() / 2;
|
||||
if (x < center.x) {
|
||||
if (y > center.y) {
|
||||
y1 += tickLen;
|
||||
} else {
|
||||
x1 -= tickLen;
|
||||
}
|
||||
} else {
|
||||
if (y > 0) {
|
||||
if (y > center.y) {
|
||||
x1 += tickLen;
|
||||
} else {
|
||||
y1 -= tickLen;
|
||||
@ -2112,7 +2164,7 @@ public class GLPlot extends Plot {
|
||||
if (v < axesExtent.minZ || v > axesExtent.maxZ) {
|
||||
continue;
|
||||
}
|
||||
v = this.transform.transform_z(v);
|
||||
//v = this.transform.transform_z(v);
|
||||
if (i == tlabs.size()) {
|
||||
break;
|
||||
}
|
||||
@ -2141,7 +2193,8 @@ public class GLPlot extends Plot {
|
||||
if (label != null) {
|
||||
this.updateTextRender(label.getFont());
|
||||
float yShift = strWidth + this.tickSpace * 3;
|
||||
drawString(gl, label, x1, y1, 0.0f, XAlign.CENTER, YAlign.BOTTOM, 90.f, 0, yShift);
|
||||
float z1 = (zMax + zMin) * 0.5f;
|
||||
drawString(gl, label, x1, y1, z1, XAlign.CENTER, YAlign.BOTTOM, 90.f, 0, yShift);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2161,14 +2214,14 @@ public class GLPlot extends Plot {
|
||||
PointF loc = zAxisOption.getLocation();
|
||||
boolean left = zAxisOption.isLeft();
|
||||
|
||||
x = this.transform.transform_x(loc.X);
|
||||
x = loc.X;
|
||||
y = loc.Y;
|
||||
float zMin = (float) axesExtent.minZ;
|
||||
float zMax = (float) axesExtent.maxZ;
|
||||
/*x = this.transform.transform_x(loc.X);
|
||||
y = this.transform.transform_y(loc.Y);
|
||||
float zMin = this.transform.transform_z((float) axesExtent.minZ);
|
||||
float zMax = this.transform.transform_z((float) axesExtent.maxZ);
|
||||
|
||||
/*gl.glTranslatef(x, y, 0);
|
||||
x = y = 0;
|
||||
gl.glRotatef(-angleY, 0.0f, 0.0f, 1.0f);*/
|
||||
float zMax = this.transform.transform_z((float) axesExtent.maxZ);*/
|
||||
|
||||
//z axis line
|
||||
rgba = this.zAxis.getLineColor().getRGBComponents(null);
|
||||
@ -2198,7 +2251,7 @@ public class GLPlot extends Plot {
|
||||
if (v < axesExtent.minZ || v > axesExtent.maxZ) {
|
||||
continue;
|
||||
}
|
||||
v = this.transform.transform_z(v);
|
||||
//v = this.transform.transform_z(v);
|
||||
if (i == tlabs.size()) {
|
||||
break;
|
||||
}
|
||||
@ -2359,6 +2412,7 @@ public class GLPlot extends Plot {
|
||||
Rectangle2D rect = textRenderer.getBounds(str.subSequence(0, str.length()));
|
||||
gl.glMatrixMode(GL2.GL_MODELVIEW);
|
||||
gl.glPushMatrix();
|
||||
gl.glLoadIdentity();
|
||||
gl.glTranslatef(x, y, 0.0f);
|
||||
if (angle != 0) {
|
||||
gl.glRotatef(angle, 0.0f, 0.0f, 1.0f);
|
||||
@ -2635,7 +2689,7 @@ public class GLPlot extends Plot {
|
||||
}
|
||||
|
||||
protected void drawText(GL2 gl, ChartText3D text) {
|
||||
Vector3f xyz = this.transform.transform((float) text.getX(), (float) text.getY(), (float) text.getZ());
|
||||
Vector3f xyz = new Vector3f((float) text.getX(), (float) text.getY(), (float) text.getZ());
|
||||
this.updateTextRender(text.getFont());
|
||||
if (text.isDraw3D()) {
|
||||
this.drawString3D(gl, text, xyz.x, xyz.y, xyz.z);
|
||||
@ -2645,7 +2699,7 @@ public class GLPlot extends Plot {
|
||||
}
|
||||
|
||||
protected void drawText3D(GL2 gl, ChartText3D text) {
|
||||
Vector3f xyz = this.transform.transform((float) text.getX(), (float) text.getY(), (float) text.getZ());
|
||||
Vector3f xyz = new Vector3f((float) text.getX(), (float) text.getY(), (float) text.getZ());
|
||||
this.drawString3D(gl, text, xyz.x, xyz.y, xyz.z);
|
||||
}
|
||||
|
||||
@ -2662,7 +2716,7 @@ public class GLPlot extends Plot {
|
||||
gl.glPointSize(pb.getSize() * this.dpiScale);
|
||||
gl.glBegin(GL2.GL_POINTS);
|
||||
PointZ p = (PointZ) shape.getPoint();
|
||||
gl.glVertex3fv(Transform.toArray(transform.transform((float) p.X, (float) p.Y, (float) p.Z)), 0);
|
||||
gl.glVertex3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
gl.glEnd();
|
||||
}
|
||||
}
|
||||
@ -2677,7 +2731,7 @@ public class GLPlot extends Plot {
|
||||
float[] rgba = pb.getColor().getRGBComponents(null);
|
||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
PointZ p = (PointZ) shape.getPoint();
|
||||
gl.glVertex3fv(Transform.toArray(transform.transform((float) p.X, (float) p.Y, (float) p.Z)), 0);
|
||||
gl.glVertex3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
}
|
||||
gl.glEnd();
|
||||
}
|
||||
@ -2694,7 +2748,7 @@ public class GLPlot extends Plot {
|
||||
gl.glColor4fv(rgba, 0);
|
||||
gl.glPushMatrix();
|
||||
PointZ p = (PointZ) shape.getPoint();
|
||||
Vector3f xyz = transform.transform((float) p.X, (float) p.Y, (float) p.Z);
|
||||
Vector3f xyz = new Vector3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
gl.glTranslated(xyz.x, xyz.y, xyz.z);
|
||||
GLUquadric sphere = glu.gluNewQuadric();
|
||||
glu.gluQuadricDrawStyle(sphere, GLU.GLU_FILL);
|
||||
@ -2719,7 +2773,7 @@ public class GLPlot extends Plot {
|
||||
for (ParticleGraphics.Particle p : (java.util.List<ParticleGraphics.Particle>)map.getValue()) {
|
||||
float[] rgba = p.rgba;
|
||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
gl.glVertex3fv(transform.transformArray((float) p.x, (float) p.y, (float) p.z), 0);
|
||||
gl.glVertex3f((float) p.x, (float) p.y, (float) p.z);
|
||||
}
|
||||
gl.glEnd();
|
||||
}
|
||||
@ -2870,7 +2924,7 @@ public class GLPlot extends Plot {
|
||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
gl.glLineWidth(plb.getWidth() * this.dpiScale);
|
||||
p = ps.get(i);
|
||||
gl.glVertex3fv(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z), 0);
|
||||
gl.glVertex3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
}
|
||||
gl.glEnd();
|
||||
} else {
|
||||
@ -2882,7 +2936,7 @@ public class GLPlot extends Plot {
|
||||
gl.glBegin(GL2.GL_LINE_STRIP);
|
||||
java.util.List<PointZ> ps = (java.util.List<PointZ>) line.getPointList();
|
||||
for (PointZ p : ps) {
|
||||
gl.glVertex3fv(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z), 0);
|
||||
gl.glVertex3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
}
|
||||
gl.glEnd();
|
||||
}
|
||||
@ -3165,7 +3219,7 @@ public class GLPlot extends Plot {
|
||||
for (Primitive primitive : tessPolygon.getPrimitives()) {
|
||||
gl.glBegin(primitive.type);
|
||||
for (PointZ p : primitive.vertices) {
|
||||
gl.glVertex3fv(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z), 0);
|
||||
gl.glVertex3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
}
|
||||
gl.glEnd();
|
||||
}
|
||||
@ -3182,7 +3236,7 @@ public class GLPlot extends Plot {
|
||||
PointZ p;
|
||||
for (int i = 0; i < tessPolygon.getOutLine().size(); i++) {
|
||||
p = ((java.util.List<PointZ>) tessPolygon.getOutLine()).get(i);
|
||||
gl.glVertex3fv(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z), 0);
|
||||
gl.glVertex3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
}
|
||||
gl.glEnd();
|
||||
|
||||
@ -3193,7 +3247,7 @@ public class GLPlot extends Plot {
|
||||
newPList = (java.util.List<PointZ>) tessPolygon.getHoleLines().get(h);
|
||||
for (int j = 0; j < newPList.size(); j++) {
|
||||
p = newPList.get(j);
|
||||
gl.glVertex3fv(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z), 0);
|
||||
gl.glVertex3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
}
|
||||
gl.glEnd();
|
||||
}
|
||||
@ -3215,7 +3269,7 @@ public class GLPlot extends Plot {
|
||||
for (Primitive primitive : tessPolygon.getPrimitives()) {
|
||||
gl.glBegin(primitive.type);
|
||||
for (PointZ p : primitive.vertices) {
|
||||
gl.glVertex3fv(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z), 0);
|
||||
gl.glVertex3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
}
|
||||
gl.glEnd();
|
||||
}
|
||||
@ -3232,7 +3286,7 @@ public class GLPlot extends Plot {
|
||||
PointZ p;
|
||||
for (int i = 0; i < aPG.getOutLine().size(); i++) {
|
||||
p = ((java.util.List<PointZ>) aPG.getOutLine()).get(i);
|
||||
gl.glVertex3fv(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z), 0);
|
||||
gl.glVertex3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
}
|
||||
gl.glEnd();
|
||||
|
||||
@ -3243,7 +3297,7 @@ public class GLPlot extends Plot {
|
||||
newPList = (java.util.List<PointZ>) aPG.getHoleLines().get(h);
|
||||
for (int j = 0; j < newPList.size(); j++) {
|
||||
p = newPList.get(j);
|
||||
gl.glVertex3fv(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z), 0);
|
||||
gl.glVertex3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
}
|
||||
}
|
||||
gl.glEnd();
|
||||
@ -3337,7 +3391,7 @@ public class GLPlot extends Plot {
|
||||
gl.glBegin(GL2.GL_POLYGON);
|
||||
for (int i = 0; i < aPG.getOutLine().size(); i++) {
|
||||
p = ((java.util.List<PointZ>) aPG.getOutLine()).get(i);
|
||||
gl.glVertex3fv(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z), 0);
|
||||
gl.glVertex3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
}
|
||||
gl.glEnd();
|
||||
}
|
||||
@ -3349,7 +3403,7 @@ public class GLPlot extends Plot {
|
||||
gl.glBegin(GL2.GL_LINE_STRIP);
|
||||
for (int i = 0; i < aPG.getOutLine().size(); i++) {
|
||||
p = ((java.util.List<PointZ>) aPG.getOutLine()).get(i);
|
||||
gl.glVertex3fv(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z), 0);
|
||||
gl.glVertex3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
}
|
||||
gl.glEnd();
|
||||
}
|
||||
@ -3381,7 +3435,7 @@ public class GLPlot extends Plot {
|
||||
gl.glBegin(GL2.GL_QUADS);
|
||||
for (int i = 0; i < aPG.getOutLine().size(); i++) {
|
||||
p = ((java.util.List<PointZ>) aPG.getOutLine()).get(i);
|
||||
gl.glVertex3fv(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z), 0);
|
||||
gl.glVertex3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
}
|
||||
gl.glEnd();
|
||||
}
|
||||
@ -3393,7 +3447,7 @@ public class GLPlot extends Plot {
|
||||
gl.glBegin(GL2.GL_LINE_STRIP);
|
||||
for (int i = 0; i < aPG.getOutLine().size(); i++) {
|
||||
p = ((java.util.List<PointZ>) aPG.getOutLine()).get(i);
|
||||
gl.glVertex3fv(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z), 0);
|
||||
gl.glVertex3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
}
|
||||
gl.glEnd();
|
||||
}
|
||||
@ -3425,7 +3479,7 @@ public class GLPlot extends Plot {
|
||||
gl.glBegin(GL2.GL_TRIANGLES);
|
||||
for (int i = 0; i < aPG.getOutLine().size(); i++) {
|
||||
p = ((java.util.List<PointZ>) aPG.getOutLine()).get(i);
|
||||
gl.glVertex3fv(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z), 0);
|
||||
gl.glVertex3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
}
|
||||
gl.glEnd();
|
||||
}
|
||||
@ -3437,7 +3491,7 @@ public class GLPlot extends Plot {
|
||||
gl.glBegin(GL2.GL_LINE_STRIP);
|
||||
for (int i = 0; i < aPG.getOutLine().size(); i++) {
|
||||
p = ((java.util.List<PointZ>) aPG.getOutLine()).get(i);
|
||||
gl.glVertex3fv(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z), 0);
|
||||
gl.glVertex3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
}
|
||||
gl.glEnd();
|
||||
}
|
||||
@ -3450,9 +3504,9 @@ public class GLPlot extends Plot {
|
||||
gl.glEnable(GL2.GL_POLYGON_OFFSET_FILL);
|
||||
gl.glPolygonOffset(1.0f, 1.0f);
|
||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
float[] x0 = transform.transformf(points[0]);
|
||||
float[] x1 = transform.transformf(points[1]);
|
||||
float[] x2 = transform.transformf(points[2]);
|
||||
float[] x0 = points[0].toFloatArray();
|
||||
float[] x1 = points[1].toFloatArray();
|
||||
float[] x2 = points[2].toFloatArray();
|
||||
gl.glBegin(GL2.GL_TRIANGLES);
|
||||
if (this.lighting.isEnable()) {
|
||||
float[] normal = JOGLUtil.normalize(x0, x1, x2);
|
||||
@ -3471,7 +3525,7 @@ public class GLPlot extends Plot {
|
||||
gl.glBegin(GL2.GL_LINE_STRIP);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
p = points[i];
|
||||
gl.glVertex3fv(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z), 0);
|
||||
gl.glVertex3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
}
|
||||
gl.glEnd();
|
||||
}
|
||||
@ -3506,16 +3560,16 @@ public class GLPlot extends Plot {
|
||||
// Front Face
|
||||
//gl.glTexCoord2f(0.0f, 0.0f);
|
||||
gl.glTexCoord2f(0.0f, 1.0f);
|
||||
gl.glVertex3fv(transform.transformArray((float) coords.get(0).X, (float) coords.get(0).Y, (float) coords.get(0).Z), 0);
|
||||
gl.glVertex3f((float) coords.get(0).X, (float) coords.get(0).Y, (float) coords.get(0).Z);
|
||||
//gl.glTexCoord2f(1.0f, 0.0f);
|
||||
gl.glTexCoord2f(1.0f, 1.0f);
|
||||
gl.glVertex3fv(transform.transformArray((float) coords.get(1).X, (float) coords.get(1).Y, (float) coords.get(1).Z), 0);
|
||||
gl.glVertex3f((float) coords.get(1).X, (float) coords.get(1).Y, (float) coords.get(1).Z);
|
||||
//gl.glTexCoord2f(1.0f, 1.0f);
|
||||
gl.glTexCoord2f(1.0f, 0.0f);
|
||||
gl.glVertex3fv(transform.transformArray((float) coords.get(2).X, (float) coords.get(2).Y, (float) coords.get(2).Z), 0);
|
||||
gl.glVertex3f((float) coords.get(2).X, (float) coords.get(2).Y, (float) coords.get(2).Z);
|
||||
//gl.glTexCoord2f(0.0f, 1.0f);
|
||||
gl.glTexCoord2f(0.0f, 0.0f);
|
||||
gl.glVertex3fv(transform.transformArray((float) coords.get(3).X, (float) coords.get(3).Y, (float) coords.get(3).Z), 0);
|
||||
gl.glVertex3f((float) coords.get(3).X, (float) coords.get(3).Y, (float) coords.get(3).Z);
|
||||
gl.glEnd();
|
||||
|
||||
// Unbinding the texture
|
||||
@ -3582,16 +3636,16 @@ public class GLPlot extends Plot {
|
||||
// Front Face
|
||||
//gl.glTexCoord2f(0.0f, 0.0f);
|
||||
gl.glTexCoord2f(0.0f, 1.0f * yRepeat);
|
||||
gl.glVertex3fv(transform.transformArray((float) coords.get(0).X, (float) coords.get(0).Y + height, (float) coords.get(0).Z), 0);
|
||||
gl.glVertex3f((float) coords.get(0).X, (float) coords.get(0).Y + height, (float) coords.get(0).Z);
|
||||
//gl.glTexCoord2f(1.0f, 0.0f);
|
||||
gl.glTexCoord2f(1.0f * xRepeat, 1.0f * yRepeat);
|
||||
gl.glVertex3fv(transform.transformArray((float) coords.get(1).X + width, (float) coords.get(1).Y + height, (float) coords.get(1).Z), 0);
|
||||
gl.glVertex3f((float) coords.get(1).X + width, (float) coords.get(1).Y + height, (float) coords.get(1).Z);
|
||||
//gl.glTexCoord2f(1.0f, 1.0f);
|
||||
gl.glTexCoord2f(1.0f * xRepeat, 0.0f);
|
||||
gl.glVertex3fv(transform.transformArray((float) coords.get(2).X + width, (float) coords.get(2).Y, (float) coords.get(2).Z), 0);
|
||||
gl.glVertex3f((float) coords.get(2).X + width, (float) coords.get(2).Y, (float) coords.get(2).Z);
|
||||
//gl.glTexCoord2f(0.0f, 1.0f);
|
||||
gl.glTexCoord2f(0.0f, 0.0f);
|
||||
gl.glVertex3fv(transform.transformArray((float) coords.get(3).X, (float) coords.get(3).Y, (float) coords.get(3).Z), 0);
|
||||
gl.glVertex3f((float) coords.get(3).X, (float) coords.get(3).Y, (float) coords.get(3).Z);
|
||||
gl.glEnd();
|
||||
gl.glFlush();
|
||||
|
||||
@ -3894,7 +3948,7 @@ public class GLPlot extends Plot {
|
||||
java.util.List<PointZ> ps = cubic.getPoints();
|
||||
java.util.List<float[]> vertex = new ArrayList<>();
|
||||
for (PointZ p : ps) {
|
||||
vertex.add(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z));
|
||||
vertex.add(new float[]{(float) p.X, (float) p.Y, (float) p.Z});
|
||||
}
|
||||
|
||||
gl.glEnable(GL2.GL_POLYGON_OFFSET_FILL);
|
||||
@ -3941,7 +3995,7 @@ public class GLPlot extends Plot {
|
||||
java.util.List<PointZ> ps = cylinder.getPoints();
|
||||
java.util.List<float[]> vertex = new ArrayList<>();
|
||||
for (PointZ p : ps) {
|
||||
vertex.add(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z));
|
||||
vertex.add(new float[]{(float) p.X, (float) p.Y, (float) p.Z});
|
||||
}
|
||||
double height = vertex.get(1)[2] - vertex.get(0)[2];
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
package org.meteoinfo.chart.jogl;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
@ -401,6 +402,16 @@ public class Lighting {
|
||||
gl.glLightfv(this.light, GL2.GL_POSITION, position, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set light position
|
||||
* @param gl GL2
|
||||
* @param pos Light position
|
||||
*/
|
||||
public void setPosition(GL2 gl, Vector4f pos) {
|
||||
float[] posf = new float[]{pos.x, pos.y, pos.z, pos.w};
|
||||
gl.glLightfv(this.light, GL2.GL_POSITION, posf, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the lighting
|
||||
*
|
||||
|
||||
@ -2,6 +2,7 @@ package org.meteoinfo.chart.jogl;
|
||||
|
||||
import com.jogamp.opengl.GL;
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.joml.Vector3f;
|
||||
import org.meteoinfo.chart.ChartText;
|
||||
import org.meteoinfo.chart.graphic.GraphicCollection3D;
|
||||
import org.meteoinfo.chart.graphic.GraphicProjectionUtil;
|
||||
@ -138,12 +139,18 @@ public class MapGLPlot extends GLPlot {
|
||||
super.drawAxis(gl);
|
||||
} else {
|
||||
float xMin, xMax, yMin, yMax, zMin, zMax;
|
||||
xMin = this.transform.transform_x((float) axesExtent.minX);
|
||||
xMin = (float) axesExtent.minX;
|
||||
xMax = (float) axesExtent.maxX;
|
||||
yMin = (float) axesExtent.minY;
|
||||
yMax = (float) axesExtent.maxY;
|
||||
zMin = (float) axesExtent.minZ;
|
||||
zMax = (float) axesExtent.maxZ;
|
||||
/*xMin = this.transform.transform_x((float) axesExtent.minX);
|
||||
xMax = this.transform.transform_x((float) axesExtent.maxX);
|
||||
yMin = this.transform.transform_y((float) axesExtent.minY);
|
||||
yMax = this.transform.transform_y((float) axesExtent.maxY);
|
||||
zMin = this.transform.transform_z((float) axesExtent.minZ);
|
||||
zMax = this.transform.transform_z((float) axesExtent.maxZ);
|
||||
zMax = this.transform.transform_z((float) axesExtent.maxZ);*/
|
||||
|
||||
gl.glDepthFunc(GL.GL_ALWAYS);
|
||||
|
||||
@ -154,6 +161,7 @@ public class MapGLPlot extends GLPlot {
|
||||
XAlign xAlign;
|
||||
YAlign yAlign;
|
||||
Rectangle2D rect;
|
||||
Vector3f center = this.transform.getCenter();
|
||||
float strWidth, strHeight;
|
||||
MapGridLine3D mapGridLine = (MapGridLine3D) gridLine;
|
||||
if (this.displayXY) {
|
||||
@ -173,9 +181,9 @@ public class MapGLPlot extends GLPlot {
|
||||
gl.glEnd();
|
||||
|
||||
//Longitude axis ticks
|
||||
float tickLen = this.xAxis.getTickLength() * this.lenScale;
|
||||
float tickLen = this.xAxis.getTickLength() * this.lenScale * transform.getYLength() / 2;
|
||||
float axisLen = this.toScreenLength(xMin, y, zMin, xMax, y, zMin);
|
||||
float y1 = y > 0 ? y + tickLen : y - tickLen;
|
||||
float y1 = y > center.y ? y + tickLen : y - tickLen;
|
||||
if (this.angleY < 90 || (this.angleY >= 180 && this.angleY < 270)) {
|
||||
xAlign = XAlign.LEFT;
|
||||
} else {
|
||||
@ -196,7 +204,7 @@ public class MapGLPlot extends GLPlot {
|
||||
if (x < axesExtent.minX || x > axesExtent.maxX) {
|
||||
continue;
|
||||
}
|
||||
x = this.transform.transform_x(x);
|
||||
//x = this.transform.transform_x(x);
|
||||
|
||||
//Draw tick line
|
||||
rgba = this.xAxis.getLineColor().getRGBComponents(null);
|
||||
@ -223,12 +231,13 @@ public class MapGLPlot extends GLPlot {
|
||||
if (label != null) {
|
||||
strWidth += this.tickSpace;
|
||||
float angle = this.toScreenAngle(xMin, y, zMin, xMax, y, zMin);
|
||||
angle = y < 0 ? 270 - angle : 90 - angle;
|
||||
angle = y < center.y ? 270 - angle : 90 - angle;
|
||||
float yShift = Math.min(-strWidth, -strWidth);
|
||||
if (this.angleX <= -120) {
|
||||
yShift = -yShift;
|
||||
}
|
||||
drawString(gl, label, 0.0f, y1, zMin, XAlign.CENTER, yAlign, angle, 0, yShift);
|
||||
float x1 = (xMin + xMax) / 2;
|
||||
drawString(gl, label, x1, y1, zMin, XAlign.CENTER, yAlign, angle, 0, yShift);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
@ -248,8 +257,8 @@ public class MapGLPlot extends GLPlot {
|
||||
|
||||
//y axis ticks
|
||||
axisLen = this.toScreenLength(x, yMin, zMin, x, yMax, zMin);
|
||||
tickLen = this.yAxis.getTickLength() * this.lenScale;
|
||||
float x1 = x > 0 ? x + tickLen : x - tickLen;
|
||||
tickLen = this.yAxis.getTickLength() * this.lenScale * transform.getXLength() / 2;
|
||||
float x1 = x > center.x ? x + tickLen : x - tickLen;
|
||||
if (this.angleY < 90 || (this.angleY >= 180 && this.angleY < 270)) {
|
||||
xAlign = XAlign.RIGHT;
|
||||
} else {
|
||||
@ -270,7 +279,7 @@ public class MapGLPlot extends GLPlot {
|
||||
if (y < axesExtent.minY || y > axesExtent.maxY) {
|
||||
continue;
|
||||
}
|
||||
y = this.transform.transform_y(y);
|
||||
//y = this.transform.transform_y(y);
|
||||
|
||||
//Draw tick line
|
||||
rgba = this.yAxis.getLineColor().getRGBComponents(null);
|
||||
@ -297,12 +306,13 @@ public class MapGLPlot extends GLPlot {
|
||||
if (label != null) {
|
||||
strWidth += this.tickSpace;
|
||||
float angle = this.toScreenAngle(x, yMin, zMin, x, yMax, xMin);
|
||||
angle = x > 0 ? 270 - angle : 90 - angle;
|
||||
angle = x > center.x ? 270 - angle : 90 - angle;
|
||||
float yShift = Math.min(-strWidth, -strWidth);
|
||||
if (this.angleX <= -120) {
|
||||
yShift = -yShift;
|
||||
}
|
||||
drawString(gl, label, x1, 0.0f, zMin, XAlign.CENTER, yAlign, angle, 0, yShift);
|
||||
y1 = (yMin + yMax) / 2;
|
||||
drawString(gl, label, x1, y1, zMin, XAlign.CENTER, yAlign, angle, 0, yShift);
|
||||
}
|
||||
}
|
||||
|
||||
@ -337,15 +347,15 @@ public class MapGLPlot extends GLPlot {
|
||||
skip = getLabelGap(this.zAxis.getTickLabelFont(), tlabs, axisLen);
|
||||
float x1 = x;
|
||||
float y1 = y;
|
||||
float tickLen = this.zAxis.getTickLength() * this.lenScale;
|
||||
if (x < 0) {
|
||||
if (y > 0) {
|
||||
float tickLen = this.zAxis.getTickLength() * this.lenScale * transform.getYLength() / 2;
|
||||
if (x < center.x) {
|
||||
if (y > center.y) {
|
||||
y1 += tickLen;
|
||||
} else {
|
||||
x1 -= tickLen;
|
||||
}
|
||||
} else {
|
||||
if (y > 0) {
|
||||
if (y > center.y) {
|
||||
x1 += tickLen;
|
||||
} else {
|
||||
y1 -= tickLen;
|
||||
@ -360,7 +370,7 @@ public class MapGLPlot extends GLPlot {
|
||||
if (v < axesExtent.minZ || v > axesExtent.maxZ) {
|
||||
continue;
|
||||
}
|
||||
v = this.transform.transform_z(v);
|
||||
//v = this.transform.transform_z(v);
|
||||
if (i == tlabs.size()) {
|
||||
break;
|
||||
}
|
||||
@ -385,7 +395,8 @@ public class MapGLPlot extends GLPlot {
|
||||
ChartText label = this.zAxis.getLabel();
|
||||
if (label != null) {
|
||||
float yShift = strWidth + this.tickSpace * 3;
|
||||
drawString(gl, label, x1, y1, 0.0f, XAlign.CENTER, YAlign.BOTTOM, 90.f, 0, yShift);
|
||||
float z1 = (zMax + zMin) * 0.5f;
|
||||
drawString(gl, label, x1, y1, z1, XAlign.CENTER, YAlign.BOTTOM, 90.f, 0, yShift);
|
||||
}
|
||||
}
|
||||
gl.glDepthFunc(GL2.GL_LEQUAL);
|
||||
|
||||
@ -104,8 +104,56 @@ public class Transform {
|
||||
}
|
||||
|
||||
this.transformMatrix = new Matrix4f()
|
||||
.translate((this.xmax + this.xmin) / 2, (this.ymax + this.ymin) / 2, (this.zmax + this.zmin) / 2)
|
||||
.scale((this.xmax - this.xmin) / 2, (this.ymax - this.ymin) / 2, (this.zmax - this.zmin) / 2);
|
||||
.translate((this.xmax + this.xmin) / 2, (this.ymax + this.ymin) / 2, -(this.zmax + this.zmin) / 2)
|
||||
.scale(2 / (this.xmax - this.xmin), 2 / (this.ymax - this.ymin), 2 / (this.zmax - this.zmin));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get transform center
|
||||
* @return The center
|
||||
*/
|
||||
public Vector3f getCenter() {
|
||||
return new Vector3f((xmax + xmin) / 2, (ymax + ymin) / 2, (zmax + zmin) / 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get transform scale
|
||||
* @return The scale
|
||||
*/
|
||||
public Vector3f getScale() {
|
||||
return new Vector3f(2 / (this.xmax - this.xmin), 2 / (this.ymax - this.ymin), 2 / (this.zmax - this.zmin));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get transform extent
|
||||
* @return The extent
|
||||
*/
|
||||
public Extent3D getExtent() {
|
||||
return new Extent3D(xmin, xmax, ymin, ymax, zmin, zmax);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get x length
|
||||
* @return X length
|
||||
*/
|
||||
public float getXLength() {
|
||||
return xmax - xmin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get y length
|
||||
* @return Y length
|
||||
*/
|
||||
public float getYLength() {
|
||||
return ymax - ymin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get z length
|
||||
* @return Z length
|
||||
*/
|
||||
public float getZLength() {
|
||||
return zmax - zmin;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -18,6 +18,8 @@ public abstract class JOGLGraphicRender implements GraphicRender {
|
||||
protected float mvmatrix[] = new float[16];
|
||||
protected float projmatrix[] = new float[16];
|
||||
protected Matrix4f viewProjMatrix = new Matrix4f();
|
||||
protected Matrix4f modelViewMatrix = new Matrix4f();
|
||||
protected Matrix4f projectionMatrix = new Matrix4f();
|
||||
protected boolean useShader = false;
|
||||
protected Lighting lighting = new Lighting();
|
||||
protected float dpiScale = 1.0f;
|
||||
@ -132,7 +134,9 @@ public abstract class JOGLGraphicRender implements GraphicRender {
|
||||
gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport, 0);
|
||||
gl.glGetFloatv(GL2.GL_MODELVIEW_MATRIX, mvmatrix, 0);
|
||||
gl.glGetFloatv(GL2.GL_PROJECTION_MATRIX, projmatrix, 0);
|
||||
viewProjMatrix = toMatrix(projmatrix).
|
||||
mul(toMatrix(mvmatrix));
|
||||
modelViewMatrix = toMatrix(mvmatrix);
|
||||
projectionMatrix = toMatrix(projmatrix);
|
||||
viewProjMatrix = projectionMatrix.
|
||||
mul(modelViewMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ public class LineRender extends JOGLGraphicRender {
|
||||
private int sizePosition;
|
||||
private int sizeColor;
|
||||
private int sizeNormal;
|
||||
private float[] vertexPosition;
|
||||
private float[] vertexColor;
|
||||
private float lineWidth = 1.0f;
|
||||
private List<Integer> linePointNumbers;
|
||||
@ -131,7 +132,7 @@ public class LineRender extends JOGLGraphicRender {
|
||||
}
|
||||
|
||||
private float[] getVertexPosition() {
|
||||
float[] vertexData = new float[this.vertexNum * 3];
|
||||
vertexPosition = new float[this.vertexNum * 3];
|
||||
int i = 0;
|
||||
linePointNumbers = new ArrayList<>();
|
||||
for (Graphic graphic : this.graphics.getGraphics()) {
|
||||
@ -140,15 +141,15 @@ public class LineRender extends JOGLGraphicRender {
|
||||
List<PointZ> ps = (List<PointZ>) line.getPointList();
|
||||
linePointNumbers.add(ps.size());
|
||||
for (PointZ p : ps) {
|
||||
vertexData[i] = transform.transform_x((float) p.X);
|
||||
vertexData[i + 1] = transform.transform_y((float) p.Y);
|
||||
vertexData[i + 2] = transform.transform_z((float) p.Z);
|
||||
vertexPosition[i] = (float) p.X;
|
||||
vertexPosition[i + 1] = (float) p.Y;
|
||||
vertexPosition[i + 2] = (float) p.Z;
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return vertexData;
|
||||
return vertexPosition;
|
||||
}
|
||||
|
||||
private void updateConeVertex() {
|
||||
@ -170,8 +171,8 @@ public class LineRender extends JOGLGraphicRender {
|
||||
if (i % interval == 0) {
|
||||
PointZ p2 = ps.get(i);
|
||||
PointZ p1 = ps.get(i - 1);
|
||||
v1 = transform.transform((float) p1.X, (float) p1.Y, (float) p1.Z);
|
||||
v2 = transform.transform((float) p2.X, (float) p2.Y, (float) p2.Z);
|
||||
v1 = new Vector3f((float) p1.X, (float) p1.Y, (float) p1.Z);
|
||||
v2 = new Vector3f((float) p2.X, (float) p2.Y, (float) p2.Z);
|
||||
slb = (StreamlineBreak) cbc.get(i);
|
||||
Cylinder cylinder = new Cylinder(slb.getArrowHeadWidth() * 0.02f,
|
||||
0, slb.getArrowHeadLength() * 0.02f, 8, 1, true);
|
||||
@ -207,8 +208,8 @@ public class LineRender extends JOGLGraphicRender {
|
||||
if (i % interval == 0) {
|
||||
PointZ p2 = ps.get(i);
|
||||
PointZ p1 = ps.get(i - 1);
|
||||
v1 = transform.transform((float) p1.X, (float) p1.Y, (float) p1.Z);
|
||||
v2 = transform.transform((float) p2.X, (float) p2.Y, (float) p2.Z);
|
||||
v1 = new Vector3f((float) p1.X, (float) p1.Y, (float) p1.Z);
|
||||
v2 = new Vector3f((float) p2.X, (float) p2.Y, (float) p2.Z);
|
||||
Cylinder cylinder = new Cylinder(slb.getArrowHeadWidth() * 0.02f,
|
||||
0, slb.getArrowHeadLength() * 0.02f, 8, 1, true);
|
||||
Matrix4f matrix = new Matrix4f();
|
||||
@ -221,9 +222,10 @@ public class LineRender extends JOGLGraphicRender {
|
||||
vertexPositionList.add(matrix.mul(v));
|
||||
}
|
||||
List<Vector3f> normals = cylinder.getNormals();
|
||||
for (Vector3f v : normals) {
|
||||
vertexNormalList.addAll(normals);
|
||||
/*for (Vector3f v : normals) {
|
||||
vertexNormalList.add(matrix.mul(v));
|
||||
}
|
||||
}*/
|
||||
float[] color = slb.getColor().getRGBComponents(null);
|
||||
for (int j = 0; j < n; j++) {
|
||||
vertexColorList.add(new Vector4f(color));
|
||||
@ -273,8 +275,10 @@ public class LineRender extends JOGLGraphicRender {
|
||||
super.setTransform((Transform) transform.clone());
|
||||
|
||||
if (updateBuffer) {
|
||||
float[] vertexData = this.getVertexPosition();
|
||||
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
|
||||
if (this.vertexPosition == null) {
|
||||
this.getVertexPosition();
|
||||
}
|
||||
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexPosition);
|
||||
sizePosition = vertexBuffer.capacity() * Float.BYTES;
|
||||
|
||||
FloatBuffer colorBuffer = GLBuffers.newDirectFloatBuffer(vertexColor);
|
||||
|
||||
@ -81,9 +81,10 @@ public class MeshRender extends JOGLGraphicRender {
|
||||
super.setTransform((Transform) transform.clone());
|
||||
|
||||
if (updateBuffer) {
|
||||
float[] vertexData = meshGraphic.getVertexPosition(this.transform);
|
||||
//float[] vertexData = meshGraphic.getVertexPosition(this.transform);
|
||||
float[] vertexData = meshGraphic.getVertexPosition();
|
||||
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData);
|
||||
meshGraphic.calculateNormalVectors(vertexData);
|
||||
//meshGraphic.calculateNormalVectors(vertexData);
|
||||
FloatBuffer normalBuffer = GLBuffers.newDirectFloatBuffer(meshGraphic.getVertexNormal());
|
||||
sizePosition = vertexBuffer.capacity() * Float.BYTES;
|
||||
sizeNormal = normalBuffer.capacity() * Float.BYTES;
|
||||
|
||||
@ -135,7 +135,7 @@ public class PipeRender extends JOGLGraphicRender{
|
||||
linePointNumbers = new ArrayList<>();
|
||||
for (Graphic graphic : this.graphics.getGraphics()) {
|
||||
PipeShape shape = (PipeShape) graphic.getShape();
|
||||
shape.transform(transform);
|
||||
//shape.transform(transform);
|
||||
Pipe pipe = shape.getPipe();
|
||||
linePointNumbers.add(pipe.getVertexCount());
|
||||
for (int j = 0; j < pipe.getContourCount(); j++) {
|
||||
@ -221,8 +221,8 @@ public class PipeRender extends JOGLGraphicRender{
|
||||
if (i % interval == 0) {
|
||||
PointZ p2 = ps.get(i);
|
||||
PointZ p1 = ps.get(i - 1);
|
||||
v1 = transform.transform((float) p1.X, (float) p1.Y, (float) p1.Z);
|
||||
v2 = transform.transform((float) p2.X, (float) p2.Y, (float) p2.Z);
|
||||
v1 = new Vector3f((float) p1.X, (float) p1.Y, (float) p1.Z);
|
||||
v2 = new Vector3f((float) p2.X, (float) p2.Y, (float) p2.Z);
|
||||
slb = (StreamlineBreak) cbc.get(i);
|
||||
Cylinder cylinder = new Cylinder(slb.getArrowHeadWidth() * 0.02f,
|
||||
0, slb.getArrowHeadLength() * 0.02f, 8, 1, true);
|
||||
@ -260,8 +260,8 @@ public class PipeRender extends JOGLGraphicRender{
|
||||
if (i % interval == 0) {
|
||||
PointZ p2 = ps.get(i);
|
||||
PointZ p1 = ps.get(i - 1);
|
||||
v1 = transform.transform((float) p1.X, (float) p1.Y, (float) p1.Z);
|
||||
v2 = transform.transform((float) p2.X, (float) p2.Y, (float) p2.Z);
|
||||
v1 = new Vector3f((float) p1.X, (float) p1.Y, (float) p1.Z);
|
||||
v2 = new Vector3f((float) p2.X, (float) p2.Y, (float) p2.Z);
|
||||
Cylinder cylinder = new Cylinder(slb.getArrowHeadWidth() * 0.02f,
|
||||
0, slb.getArrowHeadLength() * 0.02f, 8, 1, true);
|
||||
Matrix4f matrix = new Matrix4f();
|
||||
|
||||
@ -41,6 +41,7 @@ public class PointRender extends JOGLGraphicRender {
|
||||
private float[] vertexNormal;
|
||||
private float[] vertexColor;
|
||||
private int[] vertexIndices;
|
||||
private List<Vector3f> objNormals;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -132,9 +133,12 @@ public class PointRender extends JOGLGraphicRender {
|
||||
ParticleGraphics particles = (ParticleGraphics) graphics;
|
||||
for (Map.Entry<Integer, java.util.List> map : particles.getParticleList()) {
|
||||
for (ParticleGraphics.Particle p : (java.util.List<ParticleGraphics.Particle>)map.getValue()) {
|
||||
vertexPosition[i] = transform.transform_x((float) p.x);
|
||||
vertexPosition[i] = (float) p.x;
|
||||
vertexPosition[i + 1] = (float) p.y;
|
||||
vertexPosition[i + 2] = (float) p.z;
|
||||
/*vertexPosition[i] = transform.transform_x((float) p.x);
|
||||
vertexPosition[i + 1] = transform.transform_y((float) p.y);
|
||||
vertexPosition[i + 2] = transform.transform_z((float) p.z);
|
||||
vertexPosition[i + 2] = transform.transform_z((float) p.z);*/
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
@ -142,9 +146,12 @@ public class PointRender extends JOGLGraphicRender {
|
||||
for (Graphic graphic : this.graphics.getGraphics()) {
|
||||
PointZShape shape = (PointZShape) graphic.getShape();
|
||||
PointZ p = (PointZ) shape.getPoint();
|
||||
vertexPosition[i] = transform.transform_x((float) p.X);
|
||||
vertexPosition[i] = (float) p.X;
|
||||
vertexPosition[i + 1] = (float) p.Y;
|
||||
vertexPosition[i + 2] = (float) p.Z;
|
||||
/*vertexPosition[i] = transform.transform_x((float) p.X);
|
||||
vertexPosition[i + 1] = transform.transform_y((float) p.Y);
|
||||
vertexPosition[i + 2] = transform.transform_z((float) p.Z);
|
||||
vertexPosition[i + 2] = transform.transform_z((float) p.Z);*/
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
@ -162,7 +169,8 @@ public class PointRender extends JOGLGraphicRender {
|
||||
PointZ p = (PointZ) shape.getPoint();
|
||||
PointBreak pb = (PointBreak) graphic.getLegend();
|
||||
Sphere sphere = new Sphere(pb.getSize() * sphereScale * dpiScale, 36, 18);
|
||||
vp = transform.transform((float) p.X, (float) p.Y, (float) p.Z);
|
||||
//vp = transform.transform((float) p.X, (float) p.Y, (float) p.Z);
|
||||
vp = new Vector3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
Matrix4f matrix = new Matrix4f();
|
||||
matrix.translate(vp);
|
||||
List<Vector3f> vertices = sphere.getVertices();
|
||||
@ -172,6 +180,9 @@ public class PointRender extends JOGLGraphicRender {
|
||||
vertexPositionList.add(matrix.mul(v));
|
||||
}
|
||||
List<Vector3f> normals = sphere.getNormals();
|
||||
if (vertexNormalList.isEmpty()) {
|
||||
this.objNormals = normals;
|
||||
}
|
||||
vertexNormalList.addAll(normals);
|
||||
float[] color = pb.getColor().getRGBComponents(null);
|
||||
for (int j = 0; j < n; j++) {
|
||||
@ -218,7 +229,8 @@ public class PointRender extends JOGLGraphicRender {
|
||||
PointZ p = (PointZ) shape.getPoint();
|
||||
PointBreak pb = (PointBreak) graphic.getLegend();
|
||||
Sphere sphere = new Sphere(pb.getSize() * sphereScale * dpiScale, 36, 18);
|
||||
vp = transform.transform((float) p.X, (float) p.Y, (float) p.Z);
|
||||
//vp = transform.transform((float) p.X, (float) p.Y, (float) p.Z);
|
||||
vp = new Vector3f((float) p.X, (float) p.Y, (float) p.Z);
|
||||
Matrix4f matrix = new Matrix4f();
|
||||
matrix.translate(vp);
|
||||
List<Vector3f> vertices = sphere.getVertices();
|
||||
@ -253,7 +265,8 @@ public class PointRender extends JOGLGraphicRender {
|
||||
this.updateVertex();
|
||||
} else {
|
||||
//this.updateVertex();
|
||||
this.updateVertexPosition();
|
||||
//this.updateVertexPosition();
|
||||
//this.updateSphereVertexNormal();
|
||||
}
|
||||
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(this.vertexPosition);
|
||||
sizePosition = vertexBuffer.capacity() * Float.BYTES;
|
||||
@ -318,7 +331,6 @@ public class PointRender extends JOGLGraphicRender {
|
||||
gl.glEnableClientState(GL2.GL_NORMAL_ARRAY);
|
||||
gl.glNormalPointer(GL.GL_FLOAT, 0, sizePosition + sizeColor);
|
||||
|
||||
//gl.glEnable(GL.GL_CULL_FACE);
|
||||
gl.glDrawElements(GL2.GL_TRIANGLES, this.vertexIndices.length, GL.GL_UNSIGNED_INT, 0);
|
||||
|
||||
gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
|
||||
|
||||
@ -87,8 +87,8 @@ public class QuiverRender extends JOGLGraphicRender {
|
||||
PointZ sp = (PointZ) shape.getPoint();
|
||||
PointZ ep = (PointZ) shape.getEndPoint();
|
||||
|
||||
Vector3f v1 = transform.transform((float) sp.X, (float) sp.Y, (float) sp.Z);
|
||||
Vector3f v2 = transform.transform((float) ep.X, (float) ep.Y, (float) ep.Z);
|
||||
Vector3f v1 = new Vector3f((float) sp.X, (float) sp.Y, (float) sp.Z);
|
||||
Vector3f v2 = new Vector3f((float) ep.X, (float) ep.Y, (float) ep.Z);
|
||||
float[] color = pb.getColor().getRGBComponents(null);
|
||||
vertexPosition[pi] = v1.x;
|
||||
vertexPosition[pi + 1] = v1.y;
|
||||
@ -111,9 +111,10 @@ public class QuiverRender extends JOGLGraphicRender {
|
||||
vertexPositionList.add(matrix.mul(v));
|
||||
}
|
||||
List<Vector3f> normals = cylinder.getNormals();
|
||||
for (Vector3f v : normals) {
|
||||
vertexNormalList.addAll(normals);
|
||||
/*for (Vector3f v : normals) {
|
||||
vertexNormalList.add(matrix.mul(v));
|
||||
}
|
||||
}*/
|
||||
for (int j = 0; j < n; j++) {
|
||||
vertexColorList.add(new Vector4f(color));
|
||||
}
|
||||
@ -165,7 +166,9 @@ public class QuiverRender extends JOGLGraphicRender {
|
||||
super.setTransform((Transform) transform.clone());
|
||||
|
||||
if (updateBuffer) {
|
||||
this.updateVertexArrays();
|
||||
if (this.vertexPosition == null) {
|
||||
this.updateVertexArrays();
|
||||
}
|
||||
|
||||
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexPosition);
|
||||
sizePosition = vertexBuffer.capacity() * Float.BYTES;
|
||||
|
||||
@ -71,9 +71,13 @@ public class TriMeshRender extends JOGLGraphicRender {
|
||||
super.setTransform((Transform) transform.clone());
|
||||
|
||||
if (updateBuffer) {
|
||||
vertexPosition = meshGraphic.getVertexPosition(this.transform);
|
||||
if (vertexPosition == null) {
|
||||
vertexPosition = meshGraphic.getVertexPosition();
|
||||
}
|
||||
FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexPosition);
|
||||
meshGraphic.calculateNormalVectors(vertexPosition);
|
||||
if (meshGraphic.getVertexNormal() == null) {
|
||||
meshGraphic.calculateNormalVectors(vertexPosition);
|
||||
}
|
||||
FloatBuffer normalBuffer = GLBuffers.newDirectFloatBuffer(meshGraphic.getVertexNormal());
|
||||
FloatBuffer colorBuffer = GLBuffers.newDirectFloatBuffer(meshGraphic.getVertexColor());
|
||||
sizePosition = vertexBuffer.capacity() * Float.BYTES;
|
||||
|
||||
@ -114,7 +114,7 @@ public class VolumeRender extends JOGLGraphicRender {
|
||||
super.setTransform((Transform) transform.clone());
|
||||
|
||||
if (updateBuffer) {
|
||||
float[] vertexBufferData = volume.getVertexBufferData(this.transform);
|
||||
float[] vertexBufferData = volume.getVertexBufferData();
|
||||
|
||||
gl.glGenBuffers(1, vbo);
|
||||
gl.glBindBuffer(GL_ARRAY_BUFFER, vbo.get(0));
|
||||
|
||||
@ -43,6 +43,15 @@ public class Extent3D extends Extent{
|
||||
public double getZLength() {
|
||||
return this.maxZ - this.minZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get center point
|
||||
*
|
||||
* @return Center point
|
||||
*/
|
||||
public double[] getCenter() {
|
||||
return new double[]{(maxX + minX) / 2, (maxY + minY) / 2, (maxZ + minZ) / 2};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get is 3D or not
|
||||
|
||||
@ -97,6 +97,14 @@ public class PointZ extends PointD implements Cloneable{
|
||||
public double[] toArray() {
|
||||
return new double[]{X, Y, Z};
|
||||
}
|
||||
|
||||
/**
|
||||
* To float array
|
||||
* @return Float array
|
||||
*/
|
||||
public float[] toFloatArray() {
|
||||
return new float[]{(float) X, (float) Y, (float) Z};
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone
|
||||
|
||||
@ -1,32 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\dataframe">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\particles"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\wind"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\plot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\quiver"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\slice"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\stem"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\streamplot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\streamslice"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\text"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\bar"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\scatter"/>
|
||||
<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\contour"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\bar"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\geod"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\geoshow"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\topology"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="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\surf"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth\scatter_sphere.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\dataframe\dataframe_groupby_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\maskout\polygonindex_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth\streamslice_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth\bar3.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surf_sphere_radius.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth\scatter_sphere.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\dataframe\dataframe_groupby_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\map\maskout\polygonindex_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth\streamslice_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth\bar3.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surf_sphere_radius.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
@ -34,5 +36,5 @@
|
||||
</Font>
|
||||
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
||||
<Figure DoubleBuffering="true"/>
|
||||
<Startup MainFormLocation="-7,0" MainFormSize="1381,848"/>
|
||||
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
|
||||
</MeteoInfo>
|
||||
|
||||
Binary file not shown.
@ -66,8 +66,7 @@ def shaperead(fn, encoding=None):
|
||||
except:
|
||||
raise
|
||||
else:
|
||||
print
|
||||
'File not exists: ' + fn
|
||||
print('File not exists: {}'.format(fn))
|
||||
raise
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
@ -695,7 +695,7 @@ class Axes3D(Axes):
|
||||
:param y: (*array_like*) Input y data.
|
||||
:param z: (*array_like*) Input z data.
|
||||
:param s: (*int*) Size of points.
|
||||
:param c: (*Color*) Color of the points. Or z vlaues.
|
||||
:param c: (*Color*) Color of the points. Or z values.
|
||||
:param alpha: (*int*) The alpha blending value, between 0 (transparent) and 1 (opaque).
|
||||
:param marker: (*string*) Marker of the points.
|
||||
:param label: (*string*) Label of the points series.
|
||||
|
||||
Binary file not shown.
@ -1047,7 +1047,7 @@ class Axes3DGL(Axes3D):
|
||||
z = args[2]
|
||||
args = args[3:]
|
||||
|
||||
if kwargs.has_key('colors'):
|
||||
if 'colors' in kwargs.keys():
|
||||
cn = len(kwargs['colors'])
|
||||
else:
|
||||
cn = None
|
||||
@ -1069,20 +1069,20 @@ class Axes3DGL(Axes3D):
|
||||
# ls = ls.convertTo(ShapeTypes.POLYGON, True)
|
||||
ls = ls.convertTo(ShapeTypes.POLYGON)
|
||||
face_interp = None
|
||||
if kwargs.has_key('facecolor'):
|
||||
if 'facecolor' in kwargs.keys():
|
||||
facecolor = kwargs.pop('facecolor', None)
|
||||
face_interp = (facecolor == 'interp')
|
||||
if not face_interp:
|
||||
if not facecolor in ['flat', 'texturemap', 'none']:
|
||||
if facecolor not in ['flat', 'texturemap', 'none']:
|
||||
kwargs['facecolor'] = facecolor
|
||||
else:
|
||||
kwargs['facecolor'] = None
|
||||
edgecolor = kwargs.pop('edgecolor', None)
|
||||
edge_interp = None
|
||||
if not edgecolor is None:
|
||||
if edgecolor is not None:
|
||||
edge_interp = (edgecolor == 'interp')
|
||||
if not edge_interp:
|
||||
if not edgecolor in ['flat', 'texturemap', 'none']:
|
||||
if edgecolor not in ['flat', 'texturemap', 'none']:
|
||||
kwargs['edgecolor'] = edgecolor
|
||||
plotutil.setlegendscheme(ls, **kwargs)
|
||||
graphics = GraphicFactory.surface(x.asarray(), y.asarray(), z.asarray(), ls)
|
||||
@ -1437,7 +1437,7 @@ class Axes3DGL(Axes3D):
|
||||
alpha_max = kwargs.pop('alpha_max', 0.6)
|
||||
density = kwargs.pop('density', 2)
|
||||
graphics = GraphicFactory.particles(data.asarray(), x.asarray(), y.asarray(), z.asarray(), ls, \
|
||||
alpha_min, alpha_max, density)
|
||||
alpha_min, alpha_max, density)
|
||||
s = kwargs.pop('s', None)
|
||||
if s is None:
|
||||
s = kwargs.pop('size', None)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user