Git Product home page Git Product logo

Comments (5)

Robmaister avatar Robmaister commented on July 16, 2024

The navigation portion of SharpNav is not written yet. Once it is, the navmesh will have an associated bounding volume tree that will make it very fast to do something like this.

At the moment, you could iterate over every polygon in a NavMesh, see if the XZ point is contained in the triangle, then compare it with the Y distance of the last triangle you tested that contained the point. This will be fairly slow, but it'll get the job done for now.

I'm starting to write some code to visualize a NavMesh/NavMeshDetail, so I can't say for sure that you're going to be given proper data from a NavMesh right now.

I'll leave this issue open until I start on the navigation portion and can provide some sample code for doing this.

from sharpnav.

SallyDT avatar SallyDT commented on July 16, 2024

I'll explain what the use-case is:

When the game-server loads, it loads twice - the meshes and the navigation mesh, headless where FPS = 0.

The game server has to check whether or not the move is valid or not.

X not being the min and max width of the terrain,
Y not being the height of the terrain
Z not being the min and max of the terrain.

X Z is easy to get because those are parameters from the origin X, Z of the terrain loaded and the min, max returned by the mesh.

The Y axis is a bit troublesome because it is on the mesh itself.

It would be something like a probe or function where input is X, Z, return a valid Y position. If Y = INF, then that position is NOT walkable.

There would also be function:
where input is X, return TRUE or FALSE, where FALSE = position is not walkable. Or exceeds the mesh boundary.
Example:
-5, 0, 0, returns false
5, 0, 0 returns true.
assuming the mesh loads into positive 0,0 space and where the mesh is 0-100, 0-5, 0-100.

from sharpnav.

SallyDT avatar SallyDT commented on July 16, 2024

It's not part of the navigation codes.

Here is the second use-case:
I had some difficulties last week, so I converted from Collada to Wavefront OBJ format.

The game server uses 2 meshes - terrain and navigation meshes.

There's a fiddly problem because there is so few, so little reference codes in C# for terrain meshes. There's meshomatic but no way to get the world-space without loading OpenTK.

The terrain is represented thrice - one as a quad tree, terrain and as navigation mesh.

There are more than 3,000 NPCs on the terrain. As the user walks around, the NPCs are made visible or invisible depending on the situation. - that's what the quad tree is for.

Terrain - store the list of Y values so when the NPCs instantiate on the client, the player don't go underground, the NPCs don't go underground or float in the air either :)

When the NPCs instantiates, it stores the X, Z values and gets the terrain data to get the exact Y values.

To check if it is a valid move or note, the player can move to all locations where the mesh is, except where the height is +3, -3 of the previous Y value.

The navigation mesh executes the Recast, Crowd and detour algorithm so the NPCs move around.

from sharpnav.

Robmaister avatar Robmaister commented on July 16, 2024

For use-case 1, the algorithm I described will work, only you would return true if you ever found an overlapping polygon.

For the second use-case, that sounds like you just want to compare the Y values of the start/end points and reject the path if the difference is too high, which is simply checking the difference, unless I'm missing something.

I'd also like to re-iterate that I'm not actually done with the navmesh generation code yet, and anything about interacting with the navmesh I'd consider in the navigation section of the library (much like Detour is the navigation library for Recast-generated meshes). There hasn't been any code written to interact with a NavMesh yet.

from sharpnav.

Robmaister avatar Robmaister commented on July 16, 2024

Update: A large portion of Detour has been ported (though some possible bugs in PolyMeshDetail may hinder you), both use-cases should be possible to do now. The API for doing so is probably going to be somewhat awkward at the moment though. I'm working on refactoring a lot of it right now.

from sharpnav.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.