JavaFX 8中三角网格的高度图

3

我刚刚制作了这个小应用程序,想要分享一下...

我从几个示例中取出了代码,并对其进行了调整以适应我的需求。你可以在这里获取源代码:gitHub源代码

以下是两张屏幕截图... screenShot 1

enter image description here

如果你觉得它有趣或有用,或者想帮助改进它... 随意做或说!

编辑:好的,似乎在某些图像上会引入很多延迟,我尝试实现一个时间轴,希望将一些处理推到GPU上...(我相信这就是它的工作方式)..有人能想到更好的方法来创建更新线程吗?

Timeline defaultTimeline = new Timeline();
    defaultTimeline.getKeyFrames().addAll(new KeyFrame(new Duration(14 - (System.currentTimeMillis() % 14)), (ActionEvent t) -> {

        Timeline everySecond = new Timeline();
        everySecond.setCycleCount(Timeline.INDEFINITE);
        everySecond.getKeyFrames().addAll(new KeyFrame(Duration.valueOf(14 + "ms"), (ActionEvent event) -> {
            update();                  
        }));
        everySecond.play();
        System.err.println("Playing");
    }));
    defaultTimeline.play();

以及更新方法:

 private void update() {
    if(pixelSkipSlider.isValueChanging()){
        if(meshView.getMesh() != null){
            meshView.setMesh(MeshUtils.createHeightMap(meshImageView.getImage(), (int)pixelSkipSlider.getValue() , (float)maxHeightSlider.getValue(), (float)scaleSlider.getValue()));
        }
    }
    if(maxHeightSlider.isValueChanging()){
        if(meshView.getMesh() != null){
            meshView.setMesh(MeshUtils.createHeightMap(meshImageView.getImage(), (int)pixelSkipSlider.getValue() , (float)maxHeightSlider.getValue(), (float)scaleSlider.getValue()));
        }
    }
    if(scaleSlider.isValueChanging()){
        if(meshView.getMesh() != null){
            meshView.setMesh(MeshUtils.createHeightMap(meshImageView.getImage(), (int)pixelSkipSlider.getValue() , (float)maxHeightSlider.getValue(), (float)scaleSlider.getValue()));
        }
    }
}    

看起来很棒,非常有趣,但这不是一个问题。StackOverflow是一个问答网站,因此请求关闭该主题。 - jewelsea
我进行了编辑,因为我确实遇到了一些问题,不过还是感谢你提醒我。 - jdub1581
1个回答

1
在这个问题被提出时,我不知道JavaFX属性的invalidated()方法,重写该方法并使用它是我首选的更新属性的方法。通过这样做,平台的表现就像它应该的那样,我的问题已经解决了。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接