Raised This Month: $ Target: $400
 0% 

IsEntityVisible


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DeepBlueSea
Junior Member
Join Date: Jul 2007
Old 07-24-2008 , 19:45   IsEntityVisible
Reply With Quote #1

Hello,

Please proof me wrong here. But a function like IsEntityVisible() is not possible to realize due to the nature of this engine. Well and don't get me started. The best solutions i found here deem these entitys not to be visible:





Well, i can see 'em. Can you?
The answer why these solutions fail is simple: They are not checking the visibility of a model. They are in fact only checking the visibility of one single point. The entitys' origin. Give me a break... That's worthless...
TraceHull is out of the question, because our trace will end at the next wall. (right? no modifiers here)
Only thing we can do here is to approximate visibility. Huh approximate?
Well, we might just trace at every bone. This is pretty accurate and i did this. (uses up pretty much CPU time, :S )

Still, we are checking only single points. Theoretically there could be a wall with a tiny hole in it and behind that wall there is our enemy. We could be lookin at a body part which is not revealed by any bone point.

Another idea i had: (This pretty much fucked up CPU ressources)
I constructed this function to check visibility of a bounding box of an entity + single point of origin.

Code:
/* == fm_is_bbox_in_sight ==
* Determines if a bounding box of another entity is visible
* and not behind a wall for the given player index. This does not include
* a check if this bbox is in the viewcone of the player. So theoretically 
* there could be a bbox of an entity directly behind us and this would return true,            
* 
 
   H___________G 
   /|         /|
  / |        / |
E------------ F|
 |  |       |  |
 |  |       |  |
 |  |       |  |
 |  |       |  |
 |  |       |  |
 |  |       |  | 
 |  |       |  |
 |  |       |  |
 |  |       |  |
 |  |       |  |
 |  |       |  |
 |  |       |  |
 |  |_D_____|__| C
 | /        | /
 |/_________|/ 
 A          B
  
*/
stock bool:fm_is_bbox_in_sight(index, entity, bboxoffset) 
{
    new Float:origin[3], Float:view_ofs[3], Float:eyepos[3]
    pev(index, pev_origin, origin)
    pev(index, pev_view_ofs, view_ofs)
    xs_vec_add(origin, view_ofs, eyepos)
    
    new Float:mins[3]
    new Float:maxs[3]
    pev(entity, pev_absmin, mins)
    pev(entity, pev_absmax, maxs)
    
    mins[0] -= bboxoffset
    mins[1] -= bboxoffset
    mins[2] -= bboxoffset
    
    maxs[0] += bboxoffset
    maxs[1] += bboxoffset
    maxs[2] += bboxoffset
    
    new Float:boxEdges[8][3]
    
    //A
    boxEdges[0][0] = mins[0] 
    boxEdges[0][1] = mins[1]
    boxEdges[0][2] = mins[2]
    //B
    boxEdges[1][0] = mins[0] 
    boxEdges[1][1] = mins[1] + (maxs[1] - mins[1])
    boxEdges[1][2] = mins[2]
    //C
    boxEdges[2][0] = mins[0] + (maxs[0] - mins[0])
    boxEdges[2][1] = mins[1] + (maxs[1] - mins[1])
    boxEdges[2][2] = mins[2] 
    //D
    boxEdges[3][0] = mins[0] + (maxs[0] - mins[0])
    boxEdges[3][1] = mins[1] 
    boxEdges[3][2] = mins[2] 
    //E
    boxEdges[4][0] = mins[0] 
    boxEdges[4][1] = mins[1]
    boxEdges[4][2] = mins[2] + (maxs[2] - mins[2])
    //F
    boxEdges[5][0] = mins[0] 
    boxEdges[5][1] = mins[1] + (maxs[1] - mins[1])
    boxEdges[5][2] = mins[2] + (maxs[2] - mins[2])
    //G
    boxEdges[6][0] = mins[0] + (maxs[0] - mins[0])
    boxEdges[6][1] = mins[1] + (maxs[1] - mins[1])
    boxEdges[6][2] = mins[2] + (maxs[2] - mins[2])
    //H
    boxEdges[7][0] = mins[0] + (maxs[0] - mins[0])
    boxEdges[7][1] = mins[1] 
    boxEdges[7][2] = mins[2] + (maxs[2] - mins[2])
        
    for(new i = 0; i < 8; i++)
    {
        engfunc(EngFunc_TraceLine, eyepos, boxEdges[i], 0, index)
        new Float:fraction
        global_get(glb_trace_fraction, fraction)
        if (fraction == 1.0)
            return true
    }
    
    new Float:entpos[3]
    pev(entity, pev_origin, entpos)
    engfunc(EngFunc_TraceLine, eyepos, entpos, 0, index)

    switch (pev(entity, pev_solid)) {
        case SOLID_BBOX..SOLID_BSP: return (global_get(glb_trace_ent) == entity)
    }
    
    new Float:fraction
    global_get(glb_trace_fraction, fraction)
    return (fraction == 1.0)
}
Now i am looping through this function with multiple bboxoffsets. (This Argument manipulates the magnitude of the bbox)
To visualize what i am checking:


Those are multiple scaled boxes overlayed. I am tracing every 8 edges of each box, to approximate visibility. It is damn accurate, depending on how many boxes i overlay. But it is also damn CPU Time consuming. So i am currently sticking with the bone-method. I also thought about looping through all hitboxes and applying my overlay-box method on each one.
But hitbox access isn't that easy, and it would be also way too CPU-consuming.

But what the hell do i want from you now?
I was just curious if there was a pro-solution from some AMXX-Aholics here.
Maybe even a solution that delivers irrefutable proof of visibility of a model. (based on the hitboxes is enough, not the actual mdl-surface)

Anyone?
DeepBlueSea is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-24-2008 , 19:56   Re: IsEntityVisible
Reply With Quote #2

Are you speaking of fm_is_ent_visible() from fakemeta_util?

Code:
stock bool:fm_is_ent_visible(index, entity, ignoremonsters = 0) {     new Float:start[3], Float:dest[3]     pev(index, pev_origin, start)     pev(index, pev_view_ofs, dest)     xs_vec_add(start, dest, start)     pev(entity, pev_origin, dest)     engfunc(EngFunc_TraceLine, start, dest, ignoremonsters, index, 0)     new Float:fraction     get_tr2(0, TR_flFraction, fraction)     if (fraction == 1.0 || get_tr2(0, TR_pHit) == entity)         return true     return false }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
DeepBlueSea
Junior Member
Join Date: Jul 2007
Old 07-24-2008 , 20:33   Re: IsEntityVisible
Reply With Quote #3

Quote:
Are you speaking of fm_is_ent_visible() from fakemeta_util?
Hell yes, i was speaking of this function.
It is completely worthless.
DeepBlueSea is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 07-25-2008 , 03:18   Re: IsEntityVisible
Reply With Quote #4

You can try to make a loop and check around the player origin, like origin[1] + 5.0, origin[0] + 5.0 and so...practically should work.
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-25-2008 , 11:51   Re: IsEntityVisible
Reply With Quote #5

In 'fm_is_ent_visible()' , change fraction == 1.0 by fraction >= 0.9 and it will be almost perfect.
__________________

Last edited by Arkshine; 07-25-2008 at 12:00.
Arkshine is offline
DeepBlueSea
Junior Member
Join Date: Jul 2007
Old 07-25-2008 , 12:36   Re: IsEntityVisible
Reply With Quote #6

Almost perfect? There happen to be thick walls in this game...


Sorry for the pixelation. My Graphic-cards ram got kind of hot once.
DeepBlueSea is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-25-2008 , 13:14   Re: IsEntityVisible
Reply With Quote #7

Sorry, I've read too fast your problem and what I've said can't help you.

Now I understand and I will try to think a bit more.
__________________
Arkshine is offline
DeepBlueSea
Junior Member
Join Date: Jul 2007
Old 07-25-2008 , 13:29   Re: IsEntityVisible
Reply With Quote #8

Don't be sorry. At least this got mentioned in this thread.
We can list all possible methods to detect visibility, and their pro and contras.
DeepBlueSea is offline
endeffects
Senior Member
Join Date: Nov 2007
Old 12-23-2008 , 09:02   Re: IsEntityVisible
Reply With Quote #9

i have the same problem like you,
did you found a working solution?
__________________
Get rid of all these fake, spam, redirect servers
on your steam server list!
endeffects is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 12-23-2008 , 10:04   Re: IsEntityVisible
Reply With Quote #10

Try getting the aim origin, then check for all entities in a small sphere that it's center is the aiming origin, and then check fm_is_bbox_in_sight() (or fm_is_ent_visible()). If the functions return false and there's a player near the aiming origin, there's a player half-visible behind a wall.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode