Giter VIP home page Giter VIP logo

jme3-recast4j-demo's Introduction

jme3-recast4j-demo

This is a demonstrational Application to show how the abstractionalbBindings to use recast4j (a java only port of recast+detour) in jMonkeyEngine 3 can be used Later this demo will use maven/jCenter to get the latest version of jme3-recast4j, currently you have to build it your own and place it into this directory as jme3-recast4j.jar. The Repo will come with it pre-packaged but that might be outdated and removed in the future

jme3-recast4j-demo's People

Contributors

mefisto94 avatar mitm001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jme3-recast4j-demo's Issues

Crowd members can wander off when certain filters are used.

Crowd members can break ranks and wander off outside the navmesh when the filter used doesn't have a proper exclude flag when clicking on another flagged geometry.

For example, a filter with include walk and exclude none.

Clicking on swim flagged pond will send them off onto their own paths.

Filter include walk and exclude swim will stop this behavior since it excludes the swim flag.

Figure out how to use markConvexPolyArea and markBoxArea for marking area types.

Need to try and figure out how to use these two methods.

RecastArea.java#L243-L377

I have successfully been able to mark triangles with the markBoxArea which uses AABB bounding box but the area type is removed once the navmesh is built.

This is the Recast version of these two methods.
Recast.h#L972-L993

This is where markConvexPolyArea is used in solo mesh builds.
RecastSoloMeshTest.java#L155

This is the loop to use:

// (Optional) Mark areas.
List<ConvexVolume> vols = geomProvider.getConvexVolumes(); 
for (ConvexVolume convexVolume: vols) { 
    RecastArea.markConvexPolyArea(m_ctx, convexVolume.verts, convexVolume.hmin, convexVolume.hmax, convexVolume.areaMod, m_chf);
}

I could only get markBoxArea to work if I used it prior to RecastArea.erodeWalkableArea at this point.
RecastSoloMeshTest.java#L151

One problem faced was that Piotr does not have ConvexVolumes working for SimpleInputGeomProvider.

SimpleInputGeomProvider.java#L83

To overcome this I just created my own convexVolumes list.

To use markBoxArea I created a custom object to hold the variables,

private class BoxArea {
    public float[] bmin; 
    public float[] bmax; 
    public AreaModification areaMod;

    public BoxArea(float[] bmin, float[] bmax, AreaModification areaMod) {
        this.bmin = bmin;
        this.bmax = bmax;
        this.areaMod = areaMod;
    }
        
}

used depthFirstTraversal on the geometry going into GeometryProviderBuilder and set the bmin, bmax, and areaMod.

For ConvexVolumes I used a similar technique except with ConvexVolume objects and used verts from the triangles returned in the TriMesh loop. I based the triangles lengths from each geometry gathered by the depthFirstTraversal triangle lengths.

RecastSoloMeshTest.java#L113

Add door connections to recast level.

Need to add door connections to geometry in recast level through blender.

Either by adding a material or separating the transition into a separate object and adding user data.

Selecting Invalid Targets Leads to an NPE

java.lang.NullPointerException
	at org.recast4j.detour.DetourCommon.vCopy(DetourCommon.java:101)
	at org.recast4j.detour.crowd.Crowd.checkPathValidity(Crowd.java:826)
	at org.recast4j.detour.crowd.Crowd.update(Crowd.java:875)
	at com.jme3.recast4j.Detour.Crowd.Crowd.update(Crowd.java:84)
	at com.jme3.recast4j.Detour.Crowd.CrowdManager.lambda$update$0(CrowdManager.java:78)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
	at com.jme3.recast4j.Detour.Crowd.CrowdManager.update(CrowdManager.java:78)
	at com.jme3.recast4j.Detour.Crowd.Impl.CrowdManagerAppstate.update(CrowdManagerAppstate.java:48)
	at com.jme3.app.state.AppStateManager.update(AppStateManager.java:303)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:253)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:197)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232)
	at java.lang.Thread.run(Thread.java:748)

is thrown when the fish try to swim outside of the pond

Edit: So this is something probably relevant to recast4j as the Crowd should try to fall back when a target is invalid. We could try to prevent illegal requestMoveToTargets on our side, but I'm not sure whether we can apply filters on our own. (targetPoly != 0 isn't enough here)

Maybe we could work around it by selecting the right filters here: https://github.com/MeFisto94/jme3-recast4j-demo/blob/master/src/main/java/com/jme3/recast4j/demo/states/tutorial/CrowdState.java#L383

On the other hand Crowd should now it's query filters, right?
Edit2: So I checked it, it has to be done in https://github.com/MeFisto94/jme3-recast4j/blob/master/src/main/java/com/jme3/recast4j/Detour/Crowd/Crowd.java#L243
But which of the n filters to pick? If I got that right I can have multiple filters at the same time? but which one is active?

Sooo one can use getFilter(i) from 0 to DT_CROWD_MAX_QUERY_FILTER_TYPE = 16, but I guess one can only use one filter at a time, so maybe there is an index which is the active filter.

Edit3: Crowd Uses m_filters[ag.params.queryFilterType]

Placement of the "End Waypoint Debug Box"

As said in the title the End Waypoint Box is placed immediately usually, placed at the clicked target spot.
But it has to be placed where the last waypoint is or maybe we need yet another color for that, so that when Detour is falsely pícking another polygon which is connected, one sees where Jaime is navigating to instead of just having a line leading into nothing

StraightPath picking raycasts fail on solo navmesh builds.

Picking fails when inside the pond. Jaime will sometimes just continue until he walks off the edge. Most times he will just get stuck. Waypoint boxes fail to be placed for endpoint.

Might be due to picking not accounting for height and pond is below grade.

Add mechanism to force path replan on crowd.

Add code to force path replan for all crowd/characters outside a predetermined radius when a door is closed to stop paths that are over a predetermined distance left to travel through the target door.

In situations where there is a hud/minimap the user could click a room a great distance away, generate a path to the room through a door and then someone else could close a door. Path needs to be replaned under those circumstances.

Add movement routines.

Add movement routines that will move the character to predetermined distance before triggering door open/close.

Agent state leads to dead agent in crowd.

If your agent gets set to

 CrowdAgentState       [DT_CROWDAGENT_STATE_INVALID]

which happens when there are no polygons under the agent, like when you set a filter to exclude WALK, and they are on WALK surface, there is no way to reset their CrowdAgentState except by adding to the crowd again....

Add a new startup panel.

What about adding a startup panel so we can switch more easily between navmesh builds, areas and filters. Seems to be needed at this point.

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.