-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add saving/loading navmesh features #9
Comments
Saving / Loading a navmesh makes sense when it does not have to be generated every time would mean it can start up quicker. |
Hi, thanks for your interest :) It should not be very hard, but you'll need to patch some files to have it working from the js. First, did you reach to compile the project ? ? Now, about the load/save.
I think the main difference with the cpp is the file handling. It's probably easier to just work with Strings or Buffers and put the fs logic directly in the javascript part. What do you think ? |
Hey thanks for the reply :) I suppose after I build it the editor Will work better? Possibly can have overloaded method? It would just have to tell difference between string and file path. Cheers I will have to check it out. |
Hello. Is this still being worked on? Does anyone already have a solution for this? |
Hi, I don't know about @LiamKarlMitchell but I'm not currently working on it. If you have specific needs or ideas about it, please share them here :-) |
Hi! I need to be able to save/load the nav meshes (instead of having to calculate them every time I run my application) because it takes too long to generate them for the large models my application uses. Using web workers helps with responsiveness since I can still interact with the program whilst the mesh gets generated but what I really need is a much better startup time which I believe can be achieved through directly saving and loading the nav meshes. |
Sorry, I have been busy with other things. Also noticed that recast was not being entirely accurate with the mesh (height wise) was getting flattened. Maybe there are some settings I can tweak for that but I haven't had the chance. Something we did end up doing was using Atangeo Balancer to create lower poly mesh whilst keeping true to the topology as much as we could. Here is a breif document on our findings. Less detail means loading quicker right :) (We found we could goto about 35% of the total faces. In the meantime before this sort of feature is implemented would you happen to know of an open source algorithm or command line app that could be put in the build pipeline to compact the maps down?" Have to reduce polycount whilst keeping the topology and edges correctly. |
Sorry, I'm very new to this and have nothing to recommend. I'm running on Windows and have finally managed to compile the code with Emscripten but the library I get (recast.js) is 1 whole megabyte less than the one online... and more importantly it also doesn't work when I substitute the pre-compiled one (that I've been using in my project) with it. If I ever figure out how to get all this working and I have anything worth sharing, I'll post it. |
I began to hack something, but I struggle a bit on the serialization. doing it by hand seems a pity, and shipping an external lib like Boost seems overkill. I think I'll try to use the built-in file dump and use that as a workaround in the meanwhile. |
Hi @LiamKarlMitchell , hi @DoisKoh , I have a load/save capable branch in Do you think you could test it ? I've made examples for both saving and loading It works at least with the test level, but don't know if it's really faster with a bigger mesh. |
Hi @vincent thank's I will take a look into this. |
Thank you. Note that using a navmesh saved from the RecastDemo app should work, this could ease the process a bit. |
Sure :), I plan to use a grunt task to load each one and save it. Currently we have code that uses A* and Funnel on simplified meshes to do our navigation. Maybe I can get it in there over the next week. |
Hah! Well I recently completed a simple working version as well... Saving of Nav Mesh // Loads the model into recast to get ready for generating the nav mesh
recast.OBJLoader(modelPath + ".obj", function() {
// Build the nav mesh and then download it as a text file
// buildSoloSave() returns a string (all lines end with line feed '\n' only,
// just write that string into a text file for loading.) "download" is just a
// function I'm using to save the text to a file. You can get it in
// the demo app linked below.
var a = recast.buildSoloSave();
download(a, modelName + ".txt", "text/plain");
}); Loading of Nav Mesh // Load the nav mesh from a text file
recast.getFileContents(modelPath + ".txt", function(contents) {
// Reads the nav mesh data from a text file, then creates the detour tiled mesh or whatever
recast.loadNavMeshFromContents(contents);
}
} Link to download recastjs with save/load Link to download Demo App I'm busy with something else now, but I'm going to try yours out and we're probably going to switch to your solution since I'm just a temp and your code will be maintained. |
I've added a small tool to convert .obj to a tilecache here https://github.com/vincent/recast.js/blob/f.load.save/tools/make-tilecache |
Can you paste the code you are using ? |
@vincent Any updates on the issue ? |
not yet, sorry. I hope I'll have some free time this week end. |
We all hope for free time on the weekend :D |
Hey @balakrishnanv Can you tell me a bit more about this issue ? It seems I cannot reproduce it in the simple use cases. Which branch are you using ? fyi, load and save features have been merged in master by now. cheers, |
I have not been able to get loading and saving to work. I used @vincent tool make-tilecache.js, but the callback on this line is never triggered:
... and so of course no tilecache file ever gets written. In my main project, I can use the OBJLoader and buildSolo() with no problems. |
hi @jdestefx I'm struggling to reproduce your issue. Could you check that you called |
Using the code from your recent edits to the docs, I was finally able to get a .bin file created, but now when I try to use recast.loadTileMesh, I get a lot of file-related errors, particularly "file not found" errors. Looking over the recast.loadTileMesh functions, I'm even more confused:
|
No description provided.
The text was updated successfully, but these errors were encountered: