Disable Z-Depth?

Blitz3D Forums/Blitz3D Beginners Area/Disable Z-Depth?

Guy Fawkes(Posted 2010) [#1]
How do you disable Z-Depth on an entity?


Ross C(Posted 2010) [#2]
You can use Entity Order to place the entity is a diiferent position. What are you trying to achieve?


Guy Fawkes(Posted 2010) [#3]
gun is poking through wall. i want to disable it.


Ross C(Posted 2010) [#4]
EntityOrder gun,-1 should do the trick. - numbers should push things to the front, whilst + should push them further to the back.


puki(Posted 2010) [#5]
Another option is to scale the gun small and then position it so that it looks like completely normal - its distance from the camera is what makes it look normal size yet, in the game world, it is small.


Ross C(Posted 2010) [#6]
Problem is, you need to position it alot closer to the camera, and probably reducing your camera near range, opening up a greater possiblity of z-buffer inaccuracies.


Zethrax(Posted 2010) [#7]
The problem with changing the enityorder of the gun is that doing that disables z-buffering for the gun. This results in the gun's polygons being drawn in the wrong order.

And as Ross said, making the gun smaller and moving it nearer to the camera would require a lower near clipping range. The resolution of the z-buffer is much higher the nearer you get to the camera, so a smaller near clipping value can cause problems with the z-buffer.

The best approach is to set up a second camera to draw the gun. You can see an example of this approach in my code archive code linked below. Look at the HUD camera and gun code for example code.

http://www.blitzbasic.com/codearcs/codearcs.php?code=1137


GfK(Posted 2010) [#8]
Render the gun on a different camera.


Kryzon(Posted 2010) [#9]
I think EntityOrder will work properly. Just make it -1 and it should work.

Or render the gun in the same camera but with different passes:

Render everything except the gun\hands, then hide all this stuff (parent everything to a pivot when initialising. Hide\show this pivot when necessary, makes it easier).

Use CameraClsMode Camera,False,True

Show the gun\hands, render again.

Repeat this every loop.
I can't vouche for the performance of this method; you'll have to test it and Bill's archive entry too - don't forget to show the FPS and\or get the time taken for the functions to finish.