Third person cross-hair
#1 Members - Reputation: 184
Posted 06 August 2011 - 03:37 AM
I'm working on a third person (kind of) shooter and until now I've made the targeting with the cross-hair with a ray test. This works well for the map, but not so well for the enemies because for the map I do a correct triangle test, but for the enemies only a ray ellipsoid test (a triangle test would be far too slow).
Now I thought it would be much simpler and faster to just get the z-buffer data. Is there a problem with that? I only need the z-buffer data of one pixel (the one in the centre where the cross-hair is).
How can this be done best with DirectX9? Making the z-Buffer lockable is probably not the best idea as I also need the stencil buffer..? Could I maybe do it with a pixel shader? Or is it just no good idea?
#2 Members - Reputation: 280
Posted 06 August 2011 - 11:28 AM
My open source DirectX 10/11 graphics engine. https://sites.google.com/site/dawoodoz
"My design pattern is the simplest to understand. Everyone else is just too stupid to understand it."
#3 Crossbones+ - Reputation: 967
Posted 06 August 2011 - 11:52 AM
What makes you say that? I think it could be the fastest solution. You could also use multiple primitives to represent an enemy and test against those.I'm working on a third person (kind of) shooter and until now I've made the targeting with the cross-hair with a ray test. This works well for the map, but not so well for the enemies because for the map I do a correct triangle test, but for the enemies only a ray ellipsoid test (a triangle test would be far too slow).
#4 Members - Reputation: 184
Posted 06 August 2011 - 02:22 PM
But now I found another problem: When I cast a ray from the near clipping plane to the far clipping plane it can also occur that the intersection occurs behind the player so the bullet goes backwards. How can I solve this? Can I somehow find out the depth (z) value of where the player is so I don't cast from z=0 to z=1 but from like z = 0.5 to z=1..??
Thanks for the answers






