building navmesh at runtime and using it for spawned aiplayers

There are no stupid questions, just stupid answers.
5 posts Page 1 of 1
slapin
Posts: 24
Joined: Thu Aug 10, 2017 12:56 am
  by slapin » Sun Sep 10, 2017 11:14 pm
Hi all!

I was looking very hard for how to instantiate navmesh at run time and save it into save game for later use and could not find anything.
Is there some example?
Also I tried to use pre-made navmesh with spawned aiplayer but could not find any example on how to do that and what I miss.
I probably don't know enough to search properly so could you please help and provide some info (best for post 3.7 or latest version).
Any links?

Thanks!
Duion
Posts: 833
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Sun Sep 10, 2017 11:57 pm
You could trigger to regenerate the navmesh while the game is running, you can regenerate small parts like one cell to save performance.
slapin
Posts: 24
Joined: Thu Aug 10, 2017 12:56 am
by slapin » Mon Sep 11, 2017 12:52 am
I'd kill for an example though.

My map is randomly generated at start, so I need to have navmesh generated at start,
then small portions can be generated.

But I wonder how to use the result mesh.

i.e. if I use from script

$navmesh = new NavMesh() {
position = "0 0 0";
scale = "512 512 10";
};
$navmesh.build();


what comes next?
Duion
Posts: 833
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Mon Sep 11, 2017 1:40 am
Try out the functions in the world editor on the navmesh, there is an option to select single tiles and regenerate them.
But in your case it is probably enough to generate the navmesh once as a whole at start, it will add quite some loading time though, since navmesh generation takes a while.
You need to try it in editor first manually to find good settings.
Azaezel
Posts: 384
Joined: Tue Feb 03, 2015 9:50 pm
 
by Azaezel » Tue Sep 12, 2017 9:44 pm
Old create on the fly code is old, but should by and large still be accurate

Code: Select all

function addNav()
{
   %newMesh = new NavMesh(theNavMesh)
   {
      saveIntermediates = "0";
      buildThreaded = "1";
      build = "0";
      fileName = "levels/temp/nav.nm"; //<--------------------- file save loc
      borderSize = "1";
      cellSize = "0.3";
      cellHeight = "0.25";
      actorHeight = "2";
      actorClimb = "0.25";
      actorRadius = "0.3";
      walkableSlope = "45";
      detailSampleDist = "6";
      detailSampleError = "1";
      maxEdgeLen = "12";
      simplificationError = "1.3";
      minRegionArea = "8";
      mergeRegionArea = "20";
      tileSize = "32";
      renderMode = "Navmesh";
      renderInput = "0";
      renderConnections = "0";
      position = "0 0 3.5";
      rotation = "1 0 0 0";
      scale = "30 30 10"; //<--------------------- dimensions
      canSave = "1";
      canSaveDynamicFields = "1";
      alwaysRender = "0";
      cornerAngle = "30";
      createCoverPoints = "0";
      renderContours = "0";
      renderGeometry = "0";
      renderNavmesh = "1";
      renderSegments = "1";
   };
   MissionGroup.add(%newMesh);
}


https://github.com/GarageGames/Torque3D ... h.cpp#L669 for generating the mesh results.

https://github.com/GarageGames/Torque3D/pull/1573 for per-object filtering
https://github.com/GarageGames/Torque3D ... h.cpp#L104 for regenerating the mesh around a given object.
5 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests