本文介绍了javafx中3d对象的阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 javafx 中创建 3d 对象的阴影?我试图用

How to create shadow of 3d object in javafx?I tried to create with

Parent root2 = FXMLLoader.load(getClass().getResource("ball.fxml"));

Shadow shadow = new Shadow();

root2.setEffect(shadow);

结果如下:

无阴影

带阴影

有人可以帮我创建 3d 对象的阴影吗?谢谢!

Can someone help me to create shadows of 3d objects?Thanks!

推荐答案

Shadow 效果在 JavaFX 中用于实现 阴影 样式2D 对象的效果;它不会为 3D 对象创建适当的阴影效果,也不是为此目的而构建的.

The Shadow effect in JavaFX is for implementing drop shadow style effects for 2D objects; it will not create appropriate shadow effects for 3D objects and is not built for that purpose.

核心 JavaFX 8 3D API 没有支持为 3D 对象生成阴影效果的内置方法.

The core JavaFX 8 3D API has no in-built methods for supporting generation of shadow effects for 3D objects.

您可以阅读为 3D 对象实现阴影的各种技术并尝试实现适当的基于 Java 8 3D API 提供的图形基元的算法.IMO 这样做可能是一项非常艰巨的任务.

You could read up on various techniques for implementing shadows for 3D objects and attempt implementing an appropriate algorithm based on the graphics primitives that are supplied with the Java 8 3D API. Doing so would likely be a pretty difficult task IMO.

如果 3D 对象的阴影对您很重要,您可能希望考虑替代提供更大程度 3D 阴影支持的 3D API.

If shadows for 3D objects are important for you, you may wish to consider an alternative 3D API that provides a greater degree of 3D shadow support.

这篇关于javafx中3d对象的阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 22:38