Recast/Detour - 16 tiles per ADT - Proper method to save/load? menu

Shout-Out

User Tag List

Results 1 to 6 of 6
  1. #1
    Tanaris4's Avatar Contributor Authenticator enabled
    Reputation
    148
    Join Date
    Oct 2008
    Posts
    646
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Recast/Detour - 16 tiles per ADT - Proper method to save/load?

    All-

    Since I was able to dump 1 mesh per ADT, I now am working towards everyone's reco on using 16 tiles per ADT, but I'm running into a few problems (can't read them back into 1 tile) and would like to know how I can correct this. Here is how I'm saving the 16 nav meshes to one file:

    Code:
        char fileName[2048];
    	sprintf(fileName,"%s/%i_%i.mesh", [directory UTF8String], tx, ty);
    	FILE* fp = fopen(fileName, "wb");
        if (!fp)
    		return ;
        
    	dtNavMeshParams navMeshParams;
    	navMeshParams.tileWidth = GRID_SIZE / GridDiv;
    	navMeshParams.tileHeight = GRID_SIZE / GridDiv;
    	navMeshParams.orig[0] = -(32 * GRID_SIZE);
    	navMeshParams.orig[1] = -(32 * GRID_SIZE);
    	navMeshParams.orig[2] = -(32 * GRID_SIZE);
    	navMeshParams.maxTiles =  1000;
    	navMeshParams.maxPolys =  MaxPoly;
        
        
        NavMeshSetHeader header;
    	header.magic = NAVMESHSET_MAGIC;
    	header.version = NAVMESHSET_VERSION;
    	header.numTiles = tileNum;
    	
    	memcpy(&header.params, &navMeshParams, sizeof(dtNavMeshParams));
    	fwrite(&header, sizeof(NavMeshSetHeader), 1, fp);
        
        for ( int i = 0; i < tileNum; i++ ){
    		NavMeshTileHeader tileHeader;
    		tileHeader.tileRef = 0;
    		tileHeader.dataSize = meshData[i].dataSize;
    		fwrite(&tileHeader, sizeof(tileHeader), 1, fp);
    		fwrite(meshData[i].data, meshData[i].dataSize, 1, fp);
    		dtFree(meshData[i].data);
    	}
        
    	fclose(fp);
    Now the issue I'm running into is how to read these in, as as soon as I read the first of the 16, it takes over that (x,y) within the dtNavMesh. Here is how I'm reading them in:

    Code:
        // Read tiles.
    	for (int i = 0; i < header.numTiles; ++i){
    		NavMeshTileHeader tileHeader;
    		fread(&tileHeader, sizeof(tileHeader), 1, fp);
    		if (!tileHeader.dataSize)
    			break;
            
            NSLog(@" %d: %d", i, tileHeader.dataSize);
            
    		unsigned char* data = (unsigned char*)dtAlloc(tileHeader.dataSize, DT_ALLOC_PERM);
    		if (!data) break;
    		memset(data, 0, tileHeader.dataSize);
    		fread(data, tileHeader.dataSize, 1, fp);
    		
            dtTileRef* tile = new dtTileRef();
    		dtStatus dtResult = _navMesh->addTile(data, tileHeader.dataSize, DT_TILE_FREE_DATA, 0, tile);
            if ( dtResult != DT_SUCCESS ){
                NSLog(@"Error: could not load into navmesh 0x%X", dtResult);
                
                if (dtStatusDetail(dtResult, DT_OUT_OF_MEMORY))
                {
                }
                dtFree(data);
                return false;
            }
    	}
    Now addTile returns DT_FAILURE on the second tile read since there is already a tile at (x,y) due to the first loop. How can I fix this? I'm at a loss as to how I should read these in now.

    Thanks!
    ~ Tanaris
    Last edited by Tanaris4; 12-22-2011 at 01:40 PM.
    https://tanaris4.com

    Recast/Detour - 16 tiles per ADT - Proper method to save/load?
  2. #2
    guizmows's Avatar Banned
    Reputation
    57
    Join Date
    Feb 2008
    Posts
    414
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just load them like miko is doing but set navMeshParams.origin navMeshParams.tileWidth and navMeshParams.tileHeight correctly

  3. #3
    Tanaris4's Avatar Contributor Authenticator enabled
    Reputation
    148
    Join Date
    Oct 2008
    Posts
    646
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by guizmows View Post
    just load them like miko is doing but set navMeshParams.origin navMeshParams.tileWidth and navMeshParams.tileHeight correctly
    What do u mean correctly?

    ---------- Post added at 03:36 PM ---------- Previous post was at 03:03 PM ----------

    Think I'm there



    Edit 2: Still working on it, for some reason I can't path now and the edges are jagged... hmmmm


    Edit 3: Fixed, I was using a tile size of 1800 when I shouldn't have been doing that - opps
    Last edited by Tanaris4; 12-22-2011 at 04:00 PM.
    https://tanaris4.com

  4. #4
    dook123's Avatar Active Member
    Reputation
    21
    Join Date
    Oct 2008
    Posts
    115
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would you be willing to explain how you fixed your problem? I believe I have the same problem with my navmesh and loading multiple tiles.
    ------------------------------
    If not me than who?

  5. #5
    dook123's Avatar Active Member
    Reputation
    21
    Join Date
    Oct 2008
    Posts
    115
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It would be nice to read what you did to solve this issue.
    ------------------------------
    If not me than who?

  6. #6
    Tanaris4's Avatar Contributor Authenticator enabled
    Reputation
    148
    Join Date
    Oct 2008
    Posts
    646
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was just using the wrong tile width. I had it set to 1800, instead of width + bordersize*2.
    https://tanaris4.com

Similar Threads

  1. Path Generator – Recast/Detour and WowMapper – Step
    By RivaLfr in forum WoW Memory Editing
    Replies: 32
    Last Post: 05-13-2022, 05:38 AM
  2. Recast + Detour - Connecting tiles
    By Tanaris4 in forum WoW Memory Editing
    Replies: 12
    Last Post: 12-21-2011, 04:04 PM
  3. Replies: 1
    Last Post: 12-12-2011, 02:31 AM
  4. [Link] C++ Recast/Detour Wrapper
    By Millow in forum WoW Memory Editing
    Replies: 11
    Last Post: 08-02-2011, 04:26 AM
  5. Proper method to hook a _usercall?
    By Tanaris4 in forum WoW Memory Editing
    Replies: 1
    Last Post: 06-23-2010, 10:11 AM
All times are GMT -5. The time now is 05:45 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search