add location argument in model function

This commit is contained in:
wyq 2023-03-24 14:04:04 +08:00
parent 5aba94c0dd
commit 30430acf37
5 changed files with 32 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import java.util.List;
public class Model extends TriMeshGraphic {
protected Vector3f location = new Vector3f();
protected Vector3f angle = new Vector3f();
protected float scale = 1;
@ -16,6 +17,31 @@ public class Model extends TriMeshGraphic {
}
/**
* Get location
* @return Location
*/
public Vector3f getLocation() {
return location;
}
/**
* Set location
* @param value Location
*/
public void setLocation(Vector3f value) {
location = value;
}
/**
* Set location
* @param value Location
*/
public void setLocation(List<Number> value) {
location = new Vector3f(value.get(0).floatValue(), value.get(1).floatValue(),
value.get(2).floatValue());
}
/**
* Get angle
* @return The angle

View File

@ -161,7 +161,8 @@ public class ModelRender extends JOGLGraphicRender {
gl.glPushMatrix();
FloatBuffer fb = Buffers.newDirectFloatBuffer(16);
Matrix4f modelView = new Matrix4f(this.modelViewMatrixR);
modelView.scale(this.model.getScale());
modelView.translate(this.transform.transform(model.getLocation()));
modelView.scale(model.getScale());
modelView.rotateXYZ(model.getRadians());
gl.glLoadMatrixf(modelView.get(fb));

View File

@ -34,5 +34,5 @@
</Font>
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
<Figure DoubleBuffering="true"/>
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
<Startup MainFormLocation="-7,0" MainFormSize="1361,797"/>
</MeteoInfo>

View File

@ -1382,6 +1382,9 @@ class Axes3DGL(Axes3D):
graphics = GraphicFactory.model(T._array, x._array, y._array, z._array,
normal._array, ls)
location = kwargs.pop('location', None)
if location is not None:
graphics.setLocation(location)
angle = kwargs.pop('angle', None)
if angle is not None:
graphics.setAngle(angle)