Jump to content
gamecreator

InfiniteViewRange / NavMesh Issues

Recommended Posts

The below code works fine.  It shows a debug nav mesh.  However, if you uncomment the SetViewRange line, the nav mesh no longer shows.  I don't know if it no longer generates or if SetDebugNavigationMode just doesn't display nav meshes for InfiniteViewRange objects.  I also don't know if SetDebugNavigationMode is an official function (that's why I didn't put this in the bug forum).  It's not documented but this example uses it anyway: https://www.leadwerks.com/learn?page=Tutorials_Lua-Scripting_Introduction-to-Lua

So at least a heads up for Josh.  Maybe it's an easy fix or I'm doing something wrong.

Model *tempfloornavmesh;
tempfloornavmesh = Model::Box(50, 1, 50);
tempfloornavmesh->SetPosition(0, -0.2, 0, true);
tempfloornavmesh->SetColor(1.0, 1.0, 0.0);
//	tempfloornavmesh->SetViewRange(Entity::InfiniteViewRange);  //  Anything lower will make things disappear

Shape* shape = Shape::Box(0, 0, 0, 0, 0, 0, 50, 1, 50);
tempfloornavmesh->SetShape(shape);
shape->Release();

tempfloornavmesh->SetNavigationMode(true);

camera->SetDebugNavigationMode(true);
world->BuildNavMesh();

Spent quite a bit of time trying to figure out what was wrong.  :(

Share this post


Link to post

Wait.  Navmesh stops generating after a while?  Why??  How do I extend that by code?  Looks like it's at 512x512.  Josh, is this some arbitrary limitation you put in?

navmesh.thumb.jpg.cc0a9e0110af49b427bcbd6ab4490a2c.jpg

Share this post


Link to post

Try World->SetSize() to increase size of world. Also make sure the navmesh isn't hiding under polygons, it tends to get a little inaccurate at greater distances.

  • Like 1

Share this post


Link to post
7 minutes ago, Josh said:

Try World->SetSize() to increase size of world.

Was going to suggest this as it was available in LE2, but I didn't see it in lua or the documentation so I was unsure if it existed anymore. Can we please get this exposed to lua?

Share this post


Link to post

world->SetSize(4096) worked for me though the navmesh generation is now about 30+ seconds with 1 pillar per room (for 100 rooms).  Not a problem so far with doing the generation at the start of the game.

Share this post


Link to post
13 minutes ago, gamecreator said:

world->SetSize(4096) worked for me though the navmesh generation is now about 30+ seconds with 1 pillar per room (for 100 rooms).  Not a problem so far with doing the generation at the start of the game.

Are you creating worlds that large? If they are about the same size as shown in your pictures then a world size of 1024x1024 should be enough.

Share this post


Link to post

SetWorldSize is doing something weird.  Without it (or if I use it and specify the default 1024 size), the navmesh on the left is generated.  If I specify a larger size, it takes significantly longer and it generates a mesh that looks like the one on the right.  That's all that is changed but maybe Leadwerks is changing other factors/defaults as well internally.  I haven't tried changing the BuildNavMesh parameters yet so I'll play with that next.

macklebee, I'll give you a detailed answer with some screenshots in a few minutes but the short answer is yes an no.  ;)

navmesh.jpg

Share this post


Link to post

Right now, each room is 60 units wide and 40 high to accommodate a character that's the standard 1.8 meters high.  It's not a big room and I was hoping for bigger, and for different shapes other than a rectangle.

1.thumb.jpg.65b76a68bebb605a86105048512e3728.jpg

There's a space of 20 units between rooms to the right and 40 above, just some arbitrary numbers for testing.  So every 80 right or up, there's space for a new room.  So if a 100 room dungeon is generated in a perfect square (which will never happen), that's 800x800 (10x10 grid) plus the height and width of the last room.  The plan was to make it multiplayer and a host running the simulations for each room there's a player in but the players shouldn't see any other rooms ...

3.thumb.jpg.94a1dc34e2f5de21bb35909c612aea79.jpg

... so I was gonna spread the rooms out further but I think I'm going to need to either cover up the rooms somehow with some blocker or show/hide the other rooms with players in them and everything else in them every frame.  Probably not a big deal but this would have been much easier if I could just spread out the rooms more (though people with dual or more monitor setups might still end up seeing them anyway so hiding the other rooms some way is probably for the best, if show/hide isn't too expensive).

And the reason I gave you a yes and no answer above is because for simplicity's sake I'm cheating.  The rooms generate only in the positive space and even then, I start the first room to branch off of at about 800, 800 so that rooms can branch in any direction and still stay in the positive space to be represented easier in an array.  In this I can definitely improve the program.  I can just start at 0,0 and branch in any direction from there but represent the rooms in an array with an offset.  That should help a ton.

So, some insight into the madness.  I'll keep at it but some interesting bumps along the road.  Thank you for the help.

Edit: thinking about it further, I can keep doing the array as I've been doing and just offset the model positions so that the middle of the array positions the room at 0,0,0 in global space.  Not hard at all.

Share this post


Link to post

Any thoughts about why a larger world->SetSize would the increase the minimum distance from the pillar?  I've tried all sorts of BuildNavMesh numbers (maxedgelength and maxedgeerror) up and down and nothing gets closer.  I even tried to seriously reduce the shape size but that didn't help either (i.e. Shape::Box(0,0,0, 0,0,0, 0.002,2.0,0.002)).

navmesh.jpg

 

Share this post


Link to post

One-time bump.  I'd really love to work on this and maybe even submit something for the tournament (with less than 2 weeks to go) but I can't have large areas be blocked off from navigation and enemies not approaching players who are standing next to pillars.

Share this post


Link to post

Hey Gamecreator,

Did you ever resolve this?

We're going through the same issue after updating our project file from 4.4 to 4.6 beta.  Our map size is 4096 and has the exact issue you describe with Navmesh generation

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...