ClipPlane in MiniB3D

BlitzMax Modules Forums/MiniB3D/ClipPlane in MiniB3D

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

As promised the 2 functions for setting and desetting clipplanes.

Rem
bbdoc:
End Rem
Function SetClippingPlane(X:Float , Y:Float , Z:Float , NX:Float , NY:Float , NZ:Float , Clip:Int = 0 , Camera:TCamera = Null)
	Local PL:TPlane = TPlane.CreatePlane(TVector.Create(X , Y , Z) , TVector.Create(NX , NY , NZ) )
	Camera.Update()
	glEnable(GL_CLIP_PLANE0+Clip);
	glClipPlane(GL_CLIP_PLANE0+Clip, [Double(pl.equation[0]),Double(pl.equation[1]),Double(pl.equation[2]),Double(pl.equation[3])]);
End Function

Rem
bbdoc:
End Rem
Function DeactivateClippingPlane(Clip:Int = 0)
		glDisable(GL_CLIP_PLANE0+Clip);
End Function


These are taken from the current version of the extended version.
x,y,z represent the position of the plane (the plane in fact is infinity)

nx,ny,nz represents the normal direction of the plane
camera is needed due to matrix calculations.

eg: SetClippingPlane(0,140,0,0,-1,0,1,Cam)
will activate a clipplane nr 1 at position y = 140 and direction downwards, so everything below 140 is clipped.