render.PushCustomClipPlane

Could someone explain how it (render.PushCustomClipPlane) works?

I need to clip the six sides of a CUBE.

What do you mean by this? Squares have 4 sides.

cube*

Ok… what do you mean by clip? Clip the rendering operation to INSIDE or OUTSIDE the cube or what?

inside the cube

Don’t people usually just use stencils for this? I’ve got no idea otherwise.

i’m using this in conjunction with stencils.



	render.PushCustomClipPlane(right, (right):Dot(pos));


this will cut in the middle of a cube, of course pos is the GetPos() and right is the GetRight()

[editline]12th February 2015[/editline]




	local mns, mxs = ent:GetRenderBounds();
	local dif = mxs - mns;
	
	local pos = ent:GetPos();
	
	local up = ent:GetUp();
	local right = ent:GetRight();
	local fwd = ent:GetForward();
	
	
	
	render.PushCustomClipPlane(-right, (-right):Dot(pos + right * dif / 2));
	render.PushCustomClipPlane(right, (right):Dot(pos - right * dif / 2));
	render.PushCustomClipPlane(-up, (-up):Dot(pos + up * dif / 2));
	render.PushCustomClipPlane(up, (up):Dot(pos - up * dif / 2));
	render.PushCustomClipPlane(-fwd, (-fwd):Dot(pos + fwd * dif / 2));
	render.PushCustomClipPlane(fwd, (fwd):Dot(pos - fwd * dif / 2));


this is how i did it,
solved.