How to clip 3d model

Hello there, well, let’s say i have a 3d model representing a floor and I want to clip that floor, so only a specific part of it will be rendered, I do have the coordinates of the red polygon.
as the following image.

So how can I be able to do so? should I use ClipingPlanes?
please if my question isn’t clear let me know :slight_smile:

This can be done with a stencil buffer.
https://docs.panda3d.org/1.10/python/programming/render-attributes/stencil-attribute

2 Likes

thank you so much for your answer I just don’t think this is what am looking for. since all I want is to cut the 3d model (clip it)

That is pretty much what the stencil buffer does, I believe: clips the rendering of the affected nodes.

Otherwise, could you perhaps elaborate on what you’re trying to achieve, please? Knowing better what you’re aiming for may aid us in making suggestions.

1 Like

I think you are confused by the fact that this happens in screen coordinates. But perhaps the use of shaders can expand this technique. I personally have not used it more widely, so I can’t give any advice.

1 Like

thanks to both of you for helping me :slight_smile:
Actually, what I am trying to achieve is the following:
I have a world view, and in that world, I do have some walls/floors …etc, I am trying to add a feature where the user can modify those walls/floors (those are flat 3d models), that is somehow will be done by the user where he will select and mark the points which will cut from the 3d model (As in the previous picture with the red lines).

I have seen the Clip Planes topic in the docs, as well as the example with the teapot, for a bit it seems it is what I am looking for, but I don’t know if it can help me accomplish my goal since it clips the model only in vertical and horizontal.

So do you have any ideas on how I can accomplish my goal or any alternative steps? I am a newbie here so please excuse my dumb question if it is.

And sorry for being late.

Hmm… So do I understand then that you don’t want to clip the rendering of the model, but actually modify the vertices of the model?

If so, then I don’t think that Clip Planes will work either–as I understand them, they likewise affect the manner in which the model is rendered, rather than modifying the model itself.

(Although as a side-note, I don’t believe that they need to be horizontal or vertical.)

To modify an actual model, you might want to look into procedural geometry–perhaps search the forum for examples of this.

However, there might be easier approaches that aren’t occurring to me right now, so perhaps wait and see whether anyone else posts a alternative suggestion before acting on my suggestion above!

1 Like

You are actually talking about boolean operations on polygons, which is not provided in Panda3D. However, Panda3D uses python and C++ (that is, you can search for the right library)

Next, you will need to recreate the geometry with the help of Panda3D structures.

https://docs.panda3d.org/1.10/python/programming/internal-structures/index

2 Likes