# Clip Support?

Hello,

does someone know if there is a clip support available in jme 3.0? I want to give a clip plane to the renderer (the best would be to associate it to a spatial) so that the scene (or only the spatial) is clipped and meshes are not drawn on one of the twa half spaces of the plane.

Thanks.

Regards,

Equi

It’s tricky, and might not work as you expect but you have a Camera.setClipPlane(plane) method.

It computes a projection matrix based on the oblique near plane clipping technique (Oblique View Frustum Near-Plane Clipping).

The idea is to match the near clip plane with an arbitrary plane to perform the clipping. It’s cheap, and works in almost any cases.

This method sets the clip plane for the current frame though, so you have to call it every frame.

I use it for rendering the reflection map in water. So you can look how it’s done in the SimpleWaterPorcessor or in the WaterFilter.

try it and tell me

Hello,

it is working (somehow). The first thing I don’t understand is following. In the javadoc you can read

Note that this will work properly only if it's called on each update,

However, I can set the clip plane and rotate my spatials and they are clipped. Moreover, how to delete the clip plane? Setting null does not work because the plane object must not be zero. Do I understand it correctly that this clip plane can only be used to clip "everything in fromt of my camera"? When I have a camera at (0,0,20) facing to (0,0,-1) (center of the universe) and I have got a spatial at (10,10,0) and I set the clip plane so that it goes through the center of my spatial (10,10,0) and the normal of the plane is (0,1,0) my spatial should be "sliced" along its y-plane ( (0,1,0) is the y-normal vector of the y plane).

Unfortunately I think that I am wrong and that just the view is cut.

Thanks.

Regards,
Equi
Equilibrium said:
I can set the clip plane and rotate my spatials and they are clipped. Moreover, how to delete the clip plane? Setting null does not work because the plane object must not be zero. Do I understand it correctly that this clip plane can only be used to clip "everything in fromt of my camera"? When I have a camera at (0,0,20) facing to (0,0,-1) (center of the universe) and I have got a spatial at (10,10,0) and I set the clip plane so that it goes through the center of my spatial (10,10,0) and the normal of the plane is (0,1,0) my spatial should be "sliced" along its y-plane ( (0,1,0) is the y-normal vector of the y plane).

That"s what i meant when i said "It’s tricky, and might not work as you expect" :p

this technique assumes the camera is behind the clip plane. It is really made for reflection maps, so if the camera cross the clip plane at some point....things can go nasty...(like inverted depth buffer, etc...).

where did you call the method? in the simpleInit? if you did maybe that's the reason why things seems to work when you rotate the objects and not the cam.
This compute the projection matrix of the camera, so if you move the camera, you have to update it.
maybe it should be done only in this case, and not on every update.