Raised This Month: $12 Target: $400
 3% 

Using Navigation Meshes to find path?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AwesomeMan
Member
Join Date: Jun 2013
Old 12-01-2014 , 14:25   Using Navigation Meshes to find path?
Reply With Quote #1

Hey, how would I go about using Navigation Meshes ( https://developer.valvesoftware.com/...igation_Meshes ) to find a path, that entity could use. Say, on dust2 from CT to A.
I have done quite a lot of searching but I didn't have any luck. Need this just for CS:GO if it matters.
AwesomeMan is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 12-01-2014 , 16:13   Re: Using Navigation Meshes to find path?
Reply With Quote #2

This can be userful for you perhaps:
https://github.com/KitRifty/sourcepawn-navmesh
__________________
...
Oshizu is offline
arthurdead
Senior Member
Join Date: Jul 2013
Old 12-01-2014 , 19:17   Re: Using Navigation Meshes to find path?
Reply With Quote #3

copy-paste (with slight changes) from sm_navmesh_buildpath

PHP Code:
    new Float:EntityPos[3];
    
GetEntPropVector(entityProp_Data"m_vecAbsOrigin"EntityPos);
    new 
target FindNearestPlayer(entity);
    if(
target != -1)
    {
        new 
Float:TargetPos[3];
        
GetClientAbsOrigin(targetTargetPos);
        new 
iClosestAreaIndex 0;
        new 
bool:bBuiltPath NavMesh_BuildPath(NavMesh_GetNearestArea(EntityPos), NavMesh_GetNearestArea(TargetPos), TargetPosNavMeshShortestPathCost_iClosestAreaIndex0.0);
        if(
bBuiltPath)
        {
            new 
iTempAreaIndex iClosestAreaIndex;
            new 
iParentAreaIndex NavMeshArea_GetParent(iTempAreaIndex);
            new 
iNavDirection;
            new 
Float:flHalfWidth;
            new 
Float:flCenterPortal[3];
            new 
Float:flClosestPoint[3];
            
hPositions[entity] = CreateArray(3);
            
PushArrayArray(hPositions[entity], TargetPos3);
            while(
iParentAreaIndex != -1)
            {
                new 
Float:flTempAreaCenter[3];
                new 
Float:flParentAreaCenter[3];
                
NavMeshArea_GetCenter(iTempAreaIndexflTempAreaCenter);
                
NavMeshArea_GetCenter(iParentAreaIndexflParentAreaCenter);
                
iNavDirection NavMeshArea_ComputeDirection(iTempAreaIndexflParentAreaCenter);
                
NavMeshArea_ComputePortal(iTempAreaIndexiParentAreaIndexiNavDirectionflCenterPortalflHalfWidth);
                
NavMeshArea_ComputeClosestPointInPortal(iTempAreaIndexiParentAreaIndexiNavDirectionflCenterPortalflClosestPoint);
                
flClosestPoint[2] = NavMeshArea_GetZ(iTempAreaIndexflClosestPoint);
                
PushArrayArray(hPositions[entity], flClosestPoint3);
                
iTempAreaIndex iParentAreaIndex;
                
iParentAreaIndex NavMeshArea_GetParent(iTempAreaIndex);
            }
            
PushArrayArray(hPositions[entity], EntityPos3);
            new 
Float:flFromPos[3];
            
GetArrayArray(hPositions[entity], GetArraySize(hPositions[entity])-2flFromPos3);
            
decl Float:vecDistance[3];
            for (new 
03j++)
            {
                
vecDistance[j] = flFromPos[j] - EntityPos[j];
            }
            new 
Float:angles[3];
            
GetVectorAngles(vecDistanceangles);
            
NormalizeVector(vecDistancevecDistance);
            
ScaleVector(vecDistance1000.0 GetTickInterval());
            
AddVectors(vecDistanceEntityPosvecDistance);
            
angles[0] = 0.0;
            
TeleportEntity(entityvecDistanceanglesNULL_VECTOR);
            for(new 
GetArraySize(hPositions[entity]) - 10i--)
            {
                
decl Float:flFromPos2[3], Float:flToPos[3];
                
GetArrayArray(hPositions[entity], iflFromPos23);
                
GetArrayArray(hPositions[entity], 1flToPos3);
                new 
laser PrecacheModel("materials/sprites/laserbeam.vmt");
                
TE_SetupBeamPoints(flFromPos2flToPoslaserlaser0300.15.05.050.0, {02550255}, 30);
                
TE_SendToAll();
            }
        }
    } 
arthurdead is offline
AwesomeMan
Member
Join Date: Jun 2013
Old 12-02-2014 , 06:10   Re: Using Navigation Meshes to find path?
Reply With Quote #4

Thanks. Right now I am having a problem with the navmesh plugin, already created an issue at github. If anyone feels like helping, here's the 'error':
http://i.imgur.com/oq1WE9X.png
AwesomeMan is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 12-02-2014 , 07:49   Re: Using Navigation Meshes to find path?
Reply With Quote #5

Quote:
Originally Posted by AwesomeMan View Post
Thanks. Right now I am having a problem with the navmesh plugin, already created an issue at github. If anyone feels like helping, here's the 'error':
http://i.imgur.com/oq1WE9X.png
It might be caused by too long time of loading navigation perhaps?
This can be userful to you:
Quote:
Originally Posted by BAILOPAN View Post
Hi All,

If you're using SourceMod 1.6 snapshots, I've just added an experimental feature. If a plugin takes too long to execute - for example, it has a bug that causes your server to hang or infinite loop - SourceMod will now try to terminate the plugin. If that happens you'll get an error like this:

Code:
L 08/14/2013 - 23:47:20: [SM] Plugin encountered error 30: Script execution timed out
L 08/14/2013 - 23:47:20: [SM] Displaying call stack trace for plugin "test.smx":
L 08/14/2013 - 23:47:20: [SM]   [0]  Line 13, test.sp::OnPluginStart()
This feature is zero-cost and should not incur any performance overhead. I've also taken care to make sure it doesn't introduce spurious timeouts where none occurred. However, if you find any bugs, please do let me know.

The timeout can be configured or disabled in core.cfg via the new "SlowScriptTimeout" option. It defaults to 8 seconds.

Thanks!
If it's not some infinite loop and loading just takes long time it should be fine. Change in core.cfg "SlowScriptTimeout" to 30 secondsmaybe
__________________
...
Oshizu is offline
AwesomeMan
Member
Join Date: Jun 2013
Old 12-02-2014 , 08:39   Re: Using Navigation Meshes to find path?
Reply With Quote #6

Quote:
Originally Posted by Oshizu View Post
It might be caused by too long time of loading navigation perhaps?
This can be userful to you:


If it's not some infinite loop and loading just takes long time it should be fine. Change in core.cfg "SlowScriptTimeout" to 30 secondsmaybe
30 seconds gives the same, i set it to 0, gave it good few minutes but it doesn't continue past the 'Connection Count: (large number here)'.

In the navmesh plugin, there's this:
Code:
for (new iDirection = 0; iDirection < NAV_DIR_COUNT; iDirection++)
            {
                new iConnectionCount;
                ReadFileCell(hFile, iConnectionCount, UNSIGNED_INT_BYTE_SIZE);
                
                LogMessage("Connection count: %d", iConnectionCount);
                
                if (iConnectionCount > 0)
                {
                    if (iConnectionsStartIndex == -1) iConnectionsStartIndex = iGlobalConnectionsStartIndex;
                
                    for (new iConnectionIndex = 0; iConnectionIndex < iConnectionCount; iConnectionIndex++) 
                    {
                        iConnectionsEndIndex = iGlobalConnectionsStartIndex;
                    
                        new iConnectingAreaID;
                        ReadFileCell(hFile, iConnectingAreaID, UNSIGNED_INT_BYTE_SIZE);
                        
                        new iIndex = PushArrayCell(g_hNavMeshAreaConnections, iConnectingAreaID);
                        SetArrayCell(g_hNavMeshAreaConnections, iIndex, iDirection, NavMeshConnection_Direction);
                        
                        iGlobalConnectionsStartIndex++;
                    }
                }
            }
For every connection it does a loop, and in console it says the connection count is roughly 13million. Which is what I think causes the error. I believe the connection count shouldn't be anywhere as big. Perhaps it's reading the the NAV file wrongly?
AwesomeMan is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 12-02-2014 , 10:36   Re: Using Navigation Meshes to find path?
Reply With Quote #7

It could be the case...
Afterall CS:GO perhaps implemented some new .nav file features which might be misreaded as connections by plugin or something that causes loop to bug out?

You could try maybe open .nav file in notepad++ or something and compare difference?
By running nav_generate on two different games on very same map?
__________________
...

Last edited by Oshizu; 12-02-2014 at 10:37.
Oshizu is offline
AwesomeMan
Member
Join Date: Jun 2013
Old 12-02-2014 , 11:10   Re: Using Navigation Meshes to find path?
Reply With Quote #8

I have gotten .nav file for dust2 from CS:S, and it loaded there perfectly. I don't think any even had more connections than 10. Pretty confident it is something to do with cs:go's nav file now. Opening either .nav file in notepad++ (or any text editor i used) doesn't work out, just gives random 'signs' altho there might be few words like "Above pit" "Bombsite a".

I have googled around to see how I could read nav files but I couldn't find anything.
AwesomeMan is offline
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 03-25-2015 , 09:37   Re: Using Navigation Meshes to find path?
Reply With Quote #9

any progress on this? im getting stuck on the same problem
ImACow is offline
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 01-22-2020 , 20:38   Re: Using Navigation Meshes to find path?
Reply With Quote #10

Has any progress been made on this issue?
manicogaming is offline
Reply


Thread Tools
Display Modes

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 10:59.


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