看看FXyz library。它是开源的,你可以从代码中学习。
对于纹理,看看这个post。
FXyz有SurfacePlotMesh
的类,它正是你想要的:情节基于函数g = f(x,y)
,通过使用Function<Point2D, Number> function
参数3D表面。
它还包含纹理,因此您可以根据Function<Point3D, Number> density
包含密度图。每个值都映射到一种颜色。
检查此项测试Function2DPlotTest
here。
有了这段代码可以绘制一个函数:
@Override
public void start(Stage primaryStage) {
PerspectiveCamera camera = new PerspectiveCamera(true);
camera.setTranslateZ(-30);
SurfacePlotMesh surface = new SurfacePlotMesh(
p-> Math.sin(p.magnitude() + 1e-10)/(p.magnitude() + 1e-10),
20, 20, 100, 100, 4);
surface.setCullFace(CullFace.NONE);
surface.setTextureModeVertices3D(1530, p -> p.magnitude());
surface.getTransforms().addAll(new Rotate(200, Rotate.X_AXIS), new Rotate(-20, Rotate.Y_AXIS));
final Group group = new Group(surface);
Scene scene = new Scene(group, 600, 400, true, SceneAntialiasing.BALANCED);
scene.setCamera(camera);
primaryStage.setScene(scene);
primaryStage.show();
}

如果你添加一个密度图:
surface.setTextureModeVertices3D(1530, p -> p.magnitude());
你会得到这样的:

现在如果你想表面的动画,你只需要创建一个:
private SurfacePlotMesh surface;
private long lastEffect;
@Override
public void start(Stage primaryStage) {
PerspectiveCamera camera = new PerspectiveCamera(true);
camera.setTranslateZ(-30);
surface = new SurfacePlotMesh(
p-> Math.sin(p.magnitude() + 1e-10)/(p.magnitude() + 1e-10),
20, 20, 100, 100, 4);
surface.setCullFace(CullFace.NONE);
surface.setTextureModeVertices3D(1530, p -> p.magnitude());
surface.getTransforms().addAll(new Rotate(200, Rotate.X_AXIS), new Rotate(-20, Rotate.Y_AXIS));
final Group group = new Group(surface);
Scene scene = new Scene(group, 600, 400, true, SceneAntialiasing.BALANCED);
scene.setCamera(camera);
primaryStage.setScene(scene);
primaryStage.show();
lastEffect = System.nanoTime();
AtomicInteger count=new AtomicInteger();
AnimationTimer timerEffect = new AnimationTimer() {
@Override
public void handle(long now) {
if (now > lastEffect + 1_000_000_000l) {
double t = (count.get() % 5 + 1);
surface.setFunction2D(p -> Math.sin(t * p.magnitude() + 1e-10)/(t * p.magnitude() + 1e-10));
count.getAndIncrement();
lastEffect = now;
}
}
};
timerEffect.start();
}
,你会得到你的面动画:



这是关于动画“c瞬间“表面或关于改变表面? – fabian
它会根据时间更改新数据表面 – yerpy