Line of sight

jchmack

21-05-2007 21:11:10

I need to hide the mesh of an object when the object is not in a direct line of sight with the player. I know that ogre automatically culls objects from the camera but i need to know how to see if one player can "see" another. Right now i do raycasts towards the direction of the players node. This works pretty much how i want it to work. But not perfectly... the characters arm or weapon is sticking out from behind a corner. The node is not in line of sight but the weapon is. How can i Check this?

daedar

21-05-2007 21:32:08

You can't know (and you never will) wether a scene node is in the frustum or not, because of Ogre's efficient scene culling. So you'll have to use raycast as you do.

But I don"t really understand your problem... you want to check if your bullet shot hits the arm or the weapon of your character (not the entire boundingbox)? if so, you'll probably have to add kinematics actors for every part of your character's body and manually setPosition depending of your skeleton's bones (some kind of ragdoll). But I'm not sure I've understood your problem :?

jchmack

22-05-2007 03:47:30

okay maybe i wasn't very clear on my explanation.

I have a 3rd person bird's eye view (Think of a RTS). When an enemy unit is hiding behind a wall the player can still see it (because of the birds eye view). Although his character cannot. I want to hide the enemy units mesh whenever the enemy is hidden from the character.

My current solution is to raycast to the enemy units node (in the center of the body). But there are times when although the node(center) is not visible the enemy should be able to be seen. (body extremity or weapon is sticking out).

How can i test for this?

daedar

22-05-2007 09:00:58

Ok that's clear now :wink:

This is called occlusion test and I think this should be done with the 3D engine not with the physic one. I don't know if you've already tested Warhammer 40000 (the video game) but it has a great occlusion test where all hidden polys are displayed in green and visible ones are normally displayed.

Aiursrage2k

25-05-2007 06:04:38

The cheapest/easiest solution is to strategically pick points on the body, instead of only casting a ray to the centre, cast many. One to the hand, one to gun, you can improve the accuracy by casting more rays.


A typical rough-and-ready algorithm would be something like a combination of the two. First you check if the units are close enough and in the right direction to see each other – whether they could see each other with no blocking. Then draw one (or more if you need more accuracy, for FPSs perhaps five, one to each corner and one to the middle of the projected BB) ray from unit to unit and check it for intersections against potential blockers (terrain and units in that part of your spatial partitioning scheme).

http://www.gamedev.net/community/forums ... _id=437557

jchmack

25-05-2007 07:07:33

The cheapest/easiest solution is to strategically pick points on the body, instead of only casting a ray to the centre, cast many. One to the hand, one to gun, you can improve the accuracy by casting more rays.


A typical rough-and-ready algorithm would be something like a combination of the two. First you check if the units are close enough and in the right direction to see each other – whether they could see each other with no blocking. Then draw one (or more if you need more accuracy, for FPSs perhaps five, one to each corner and one to the middle of the projected BB) ray from unit to unit and check it for intersections against potential blockers (terrain and units in that part of your spatial partitioning scheme).


this is what i decided to do first check the distance then the bounding box aligned to the casting player. it works nicely. I beleive that Warhammer uses a method specific to some video cards "occlusion querries" or something.

@Aiursrage2k btw i like your name I am going to be a god Starcraft2

edit: from my post at gamedev:

It does, of course, require that the graphics card supports occlusion queries.


http://www.gamedev.net/community/forums ... _id=448848