Wishing for a use of the z-buffer...

Blitz3D Forums/Blitz3D Programming/Wishing for a use of the z-buffer...

Damien Sturdy(Posted 2005) [#1]
Hey peeps

Had a fantastic idea that was ruined, but i'll let you know what i thought and then you can tell me how you knew it wouldnt work from day one :P

Cropping meshes: I was planning on doing a multiple pass render, but the 2nd time around,draw a plane to prevent meshes being drawn past a certain point...

The problem is that the mesh still seems to get rendered? Basically the dragons head would stick through this "plane" that has eaten the Z-order.. and whatever is behind it doesnt get rendered, thus, water possible. The great thing is it doesnt have to be a plane that you use to crop. you could use any mesh....

*gets idea*

CopyRect might save the day again here.......^.^
I'll try that again later..

But while i'm here,
Any ideas peeps?


GfK(Posted 2005) [#2]
Are you using 'CameraClsMode camera,True,False'? As you should be able to achieve this with a bit of fiddling about.

[edit] is this what you're trying to do?

Graphics3D 800,600
light = CreateLight()
camera = CreateCamera()
plane = CreatePlane()
MoveEntity camera,0,3,-10
cube = CreateCube()
MoveEntity cube,0,5,0


While Not KeyDown(1)
	CameraClsMode camera,True,True
	HideEntity cube : ShowEntity plane
	RenderWorld

	CameraClsMode camera,True,False
	HideEntity plane : ShowEntity cube
	TurnEntity cube,0,1,0
	TranslateEntity cube,0,-0.03,0
	RenderWorld
	Flip
Wend



Rob Farley(Posted 2005) [#3]
Create several cameras with different cameraranges. And, as Dave said, make sure the clsmode is off


Damien Sturdy(Posted 2005) [#4]
camerarange wont do it ;)

I'm doing CameraClsMode .

I beleive what i need to do is copyrect the previous render (without the z-order clipping plane) onto the screen ready for the second render :)


Ross C(Posted 2005) [#5]
Why won't camera range work? As Gfk shows, using cameraclsmode will leave the previous render onscreen whilst the current frame is rendered on top.


Damien Sturdy(Posted 2005) [#6]
Yeah, i know. My entire Mirror system runs like that

I was thinking:

Render part one (clear everything), copyrect to image....
Render ONLY the plane
Copyrect image back to screen
Render part two. (dont clear background)

Anyway, im terrible when it comes to explaining, i may have a workaround. I'l get back to you :)


Tom(Posted 2005) [#7]
Try this Cygnus, might help in your task.

http://www.tomspeed.com/clipplanes.zip

put the .decls and .dll into Userlibs

cursors & 'a' & 'z' to rotate/move the plane

Most DX7 cards have user defined 'clipping planes', usualy 6 of them. You can turn them on/off independantly, you can set their position & rotation.

Clipping planes work just like a cameras near/far range, and anything behind the planes won't get rendered.

Note: user defined means they have nothing to do with Blitz3Ds native camera/viewport clipping regions, these work seperately.

[Edit] Throw 'Wireframe True' in the example code to see it working better :)

Tom


Damien Sturdy(Posted 2005) [#8]
@Tom, i managed to get it to work last night but i overlooked the obvious....

I got the meshes to clip (pure blitzcode) along a plane, but didnt realised that my technique will only work for an angle where the camera is above the object. as soon as my entity hits the water, his head still pops up above the water :(


Now, as for this code above, i can't WAIT to try it.

I'm at work now, just got there. Can you tell me, will it enable me to say, crop the head off a dragon and see the effect from any angle? If so, this will be the key to my water system, and i'll have it complete pretty much as soon as i figure out the hide/show entity speed issues and how/if i can use tweening with it....(Mark, please please please add a flag to some of those commands ;) )


Damien Sturdy(Posted 2005) [#9]
PERFECT! Nice one. I've applied this to my project, works really well!

I'll go off and apply it to "D-Grafix" water code now, it should fix the bug or at least, minimise the problem effect.....