0

I need to clip 3D shapes for group of the object. I have a Box and some 3D shapes (for example Sphere) inside Box, I want to clip this box that all shape parts, which outside the box were truncated.

I tried setClip method

Group root = new Group(sphere,box);
root.setClip(new Box(box.getWidth(),box.getHeight(),box.getDepth()));

it works with simple scene and direct view. In other situation it looks bad enter image description here

Documents says:

Clipping is essentially a 2D image operation. The result of a Clip set on a Group node with 3D transformed children will cause its children to be rendered in order without Z-buffering applied between those children.

Is it limitation of the setClip or I'm doing something wrong, I'm new in javafx.

rpc1
  • 688
  • 10
  • 23
  • Do you only want to clip (visually) or do you need to modify the mesh as result of manipulation of your 3D shapes? – José Pereda May 06 '20 at 10:31
  • @JoséPereda I think hiding will be enough. – rpc1 May 06 '20 at 10:51
  • Definitely, I wouldn't use clip for 3D. So you should look for other options. Mesh manipulation sounds like one option. – José Pereda May 06 '20 at 10:55
  • @JoséPereda I'm really new in JavaFX, could you provide some links on example or related documentation, because I can't understand how Mesh helps me – rpc1 May 06 '20 at 11:04
  • All 3D built-in shapes (like `Box`, `Shape`) are created with a `TriangleMesh`. If you want to do 3D "operations" you will end up dealing with this mesh one way or another. You don't need to create this from the scratch, there are some 3D libraries out there like [FXyz](https://github.com/FXyz/FXyz) or [JCSG](https://github.com/miho/JCSG) that will help you. – José Pereda May 06 '20 at 11:14
  • Thanks, I'll try – rpc1 May 06 '20 at 11:26

0 Answers0