Can someone explain this to me? (ADT/Map Tile) menu

User Tag List

Results 1 to 14 of 14
  1. #1
    rik.chong's Avatar Member
    Reputation
    7
    Join Date
    Oct 2009
    Posts
    35
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can someone explain this to me? (ADT/Map Tile)

    Hi all

    I'm making a path-finding bot (based on Recast n Detour), but got stuck on mesh generation.

    Here's a tile of azeroth (29_35.ADT), but the shape is a little bit weird: not a square and some objects are out of area (the marked trees)?
    Can someone explain this to me? (ADT/Map Tile)-29_35-jpg

    If I use a tile size of (533 + 1 / 3), R/D will generate 4 x 5 tiles.

    1 Tile = (533 + 1/3) * (533 + 1/3) not right?



    thanks in advance,
    Rik

    Can someone explain this to me? (ADT/Map Tile)
  2. #2
    ament's Avatar Member
    Reputation
    7
    Join Date
    Mar 2009
    Posts
    19
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A lot of tiles look like that when you export them but it doesn't matter if you set the bounding box properly when you create your navmesh.
    And one tile is 533,33 yards, but the same object can appear in multiple tiles if they're on the border to another tile.
    Last edited by ament; 03-16-2012 at 11:31 AM.

  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)
    You want to pass a little bit more outside geometry to the mesh generator. Such as:

    Code:
        m_cfg.bmin[0] -= m_cfg.borderSize*m_cfg.cs;
        m_cfg.bmin[2] -= m_cfg.borderSize*m_cfg.cs;
        m_cfg.bmax[0] += m_cfg.borderSize*m_cfg.cs;
        m_cfg.bmax[2] += m_cfg.borderSize*m_cfg.cs;
    I actually pass the entire surrounding area (3x3) as I was lazy, but it would be much smarter to pass just a little bit beyond the tile you are trying to generate.
    https://tanaris4.com

  4. #4
    rik.chong's Avatar Member
    Reputation
    7
    Join Date
    Oct 2009
    Posts
    35
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks ament and Tanaris
    Now I'm facing another issue, tiles are not connected, navigation not working ;(

    Can someone explain this to me? (ADT/Map Tile)-not_connected-png

    Here's my R/D config:
    Code:
    #define WOW_TILE_SIZE				(533.0f + (1.0f / 3.0f))
    #define WOW_TILE_VOXELS				1800
    #define MIN_REGION_SIZE				20
    #define MERGE_REGION_SIZE			40
    #define CELL_SIZE					(WOW_TILE_SIZE / (float)WOW_TILE_VOXELS)
    #define CELL_HEIGHT					0.4f
    #define WALKABLE_SLOPE_ANGLE		50.0f
    #define MAX_SIMPLIFICATION_ERR		1.3f
    #define DETAIL_SAMPLE_DIST			3.0f
    #define DETAIL_SAMPLE_MAX_ERR		1.25f
    #define WORLD_UNIT_WALKABLE_HEIGHT	1.652778f
    #define WORLD_UNIT_WALKABLE_CLIMB	1.0f
    #define WORLD_UNIT_WALKABLE_RADIUS	0.2951389f
    #define WALKABLE_HEIGHT				(int)ceilf(WORLD_UNIT_WALKABLE_HEIGHT / CELL_HEIGHT)
    #define WALKABLE_CLIMB				(int)floorf(WORLD_UNIT_WALKABLE_CLIMB  / CELL_HEIGHT)
    #define WALKABLE_RADIUS				(int)ceilf(WORLD_UNIT_WALKABLE_RADIUS / CELL_SIZE)
    #define GRID_DIV					4
    #define MAX_EDGE_LEN				(int)(WORLD_UNIT_WALKABLE_RADIUS * 8.0f)
    #define BORDER_SIZE					(int)(WALKABLE_RADIUS + 4.0f)
    #define TILE_WIDTH					(WOW_TILE_VOXELS / GRID_DIV) + (BORDER_SIZE * 2)
    #define MAX_POLYS					1048576 / (GRID_DIV * GRID_DIV)
    #define MAX_TILES					64
    #define TILE_SIZE					WOW_TILE_VOXELS / GRID_DIV
    ....
    // Init build configuration from GUI
    	memset(&m_cfg, 0, sizeof(m_cfg));
    	m_cfg.cs = CELL_SIZE;
    	m_cfg.ch = CELL_HEIGHT;
    	m_cfg.walkableSlopeAngle = WALKABLE_SLOPE_ANGLE;
    	m_cfg.walkableHeight = WALKABLE_HEIGHT; // (int)ceilf(m_agentHeight / m_cfg.ch);
    	m_cfg.walkableClimb = WALKABLE_CLIMB; // (int)floorf(m_agentMaxClimb / m_cfg.ch);
    	m_cfg.walkableRadius = WALKABLE_RADIUS; // (int)ceilf(m_agentRadius / m_cfg.cs);
    	m_cfg.maxEdgeLen = MAX_EDGE_LEN; // (int)(m_edgeMaxLen / m_cellSize);
    	m_cfg.maxSimplificationError = MAX_SIMPLIFICATION_ERR; // m_edgeMaxError;
    	m_cfg.minRegionArea = MIN_REGION_SIZE; // (int)rcSqr(m_regionMinSize);		// Note: area = size*size
    	m_cfg.mergeRegionArea = MERGE_REGION_SIZE; // (int)rcSqr(m_regionMergeSize);	// Note: area = size*size
    	m_cfg.maxVertsPerPoly = (int)m_vertsPerPoly;
    	m_cfg.tileSize = TILE_SIZE; // (int)m_tileSize;
    	m_cfg.borderSize =BORDER_SIZE; // m_cfg.walkableRadius + 3; // Reserve enough padding.
    	m_cfg.width = TILE_WIDTH; // m_cfg.tileSize + m_cfg.borderSize*2;
    	m_cfg.height = TILE_WIDTH; // m_cfg.tileSize + m_cfg.borderSize*2;
    	m_cfg.detailSampleDist = DETAIL_SAMPLE_DIST; // m_detailSampleDist < 0.9f ? 0 : m_cellSize * m_detailSampleDist;
    	m_cfg.detailSampleMaxError = DETAIL_SAMPLE_MAX_ERR; // m_cellHeight * m_detailSampleMaxError;
    	
    	rcVcopy(m_cfg.bmin, bmin);
    	rcVcopy(m_cfg.bmax, bmax);
    	m_cfg.bmin[0] -= m_cfg.borderSize*m_cfg.cs;
    	m_cfg.bmin[2] -= m_cfg.borderSize*m_cfg.cs;
    	m_cfg.bmax[0] += m_cfg.borderSize*m_cfg.cs;
    	m_cfg.bmax[2] += m_cfg.borderSize*m_cfg.cs;
    Something wrong with the borderSize?

  5. #5
    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)
    You're not dividing the tiles evenly, I had the same problem.

    There is a post by namreeb that gives better parameters, search for that
    https://tanaris4.com

  6. #6
    namreeb's Avatar Legendary

    Reputation
    658
    Join Date
    Sep 2008
    Posts
    1,023
    Thanks G/R
    7/215
    Trade Feedback
    0 (0%)
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    That was my guess too, but looking at his vars, I think he actually is. That is an odd problem indeed.

  7. #7
    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)
    @rik - are you breaking out the ADT into smaller tiles?

    Instead of generating ONE mesh per ADT, I would reco doing 16... such as:

    Code:
    // objData = our tile and the tiles bordering it
    // obj = our tile
    - (void)generateMeshesWithObj:(ObjData*)objData toDirectory:(NSString*)directory andX:(int)tx andY:(int)ty andTile:(ObjData*)obj andTotal:(int)totalTilesInMesh{
        
        NSDate *start = [NSDate date];
        
        // create our mesh loader basd on all this data (3x3 based on the tile we want the mesh for)
        NSLog(@"Getting 3x3 mesh loader for (%d, %d)", tx, ty);
    	rcMeshLoaderObj *loader = CreateMeshLoader(objData);
        if ( !loader ){
            NSLog(@"Unable to create loader for (%d, %d)", tx, ty);
            return;
        }
        
    	InputGeom *geom = new InputGeom();
    	if ( !geom->loadMesh(0, loader) ){
            NSLog(@"Unable to load ObjData");
    		return;
    	}
        
        if ( !geom || !geom->getMesh() || !geom->getChunkyMesh() ){
    		NSLog(@"buildNavigation: Input mesh is not specified.");
    		return;
    	}
        
        // ** Get our bounds for the tile we care about (only care about z)
        NSLog(@"Getting mesh loader for (%d, %d)", tx, ty);
        rcMeshLoaderObj *loader2 = CreateMeshLoader(obj);
        InputGeom *geomTile = new InputGeom();
        if ( !geomTile->loadMesh(0, loader2) ){
            NSLog(@"Unable to load ObjData2(%d, %d)", tx, ty);
            return;
        }
        
        if ( !geomTile || !geomTile->getMesh() || !geomTile->getChunkyMesh() ){
            NSLog(@"buildNavigation: Input mesh is not specified.2(%d, %d)", tx, ty);
            return;
        }
        
        // tile only geom
        const float *bminTile = geomTile->getMeshBoundsMin();
        const float *bmaxTile = geomTile->getMeshBoundsMax();
        // ** End get our bounds for the tile we care about
        
        // entire 3x3 geom
        const float *bminTile2 = geom->getMeshBoundsMin();
        const float *bmaxTile2 = geom->getMeshBoundsMax();
        
        NSLog(@"-- (%d, %d) --", tx ,ty);
        NSLog(@" min: {%0.2f, %0.2f, %0.2f}", bminTile2[0], bminTile2[1], bminTile2[2]);
        NSLog(@" max: {%0.2f, %0.2f, %0.2f}", bmaxTile2[0], bmaxTile2[1], bmaxTile2[2]);
        NSLog(@" diff: {%0.2f, %0.2f, %0.2f}", bmaxTile2[0] - bminTile2[0], bmaxTile2[1] - bminTile2[1], bmaxTile2[2] - bminTile2[2]);
        
        // calculate the bounds of our tile! (For x,y)
        float bmin_calc[3], bmax_calc[3];
        bmin_calc[1] = bminTile[1];
        bmax_calc[1] = bmaxTile[1];
        getTileBounds(tx, ty, bmin_calc, bmax_calc);
        /*NSLog(@" calculated bounds...");
        NSLog(@"  min: {%0.2f, %0.2f, %0.2f}", bmin_calc[0], bmin_calc[1], bmin_calc[2]);
        NSLog(@"  max: {%0.2f, %0.2f, %0.2f}", bmax_calc[0], bmax_calc[1], bmax_calc[2]);*/
        
        float NavMeshOri[3];
    	NavMeshOri[0] = -(32 * GRID_SIZE);
    	NavMeshOri[1] = -(32 * GRID_SIZE);
    	NavMeshOri[2] = -(32 * GRID_SIZE);
        
    	//Get correct grid bounds according to our grid
    	float mini[3];
    	rcVcopy(mini, bmin_calc);
    	mini[0] = (tx - 32) * GRID_SIZE;
    	mini[2] = (ty - 32) * GRID_SIZE;
    	float maxi[3];
    	rcVcopy(maxi, bmax_calc);
    	maxi[0] = mini[0] + GRID_SIZE;
    	maxi[2] = mini[2] + GRID_SIZE;
        
    	//Div our grid
    	int gw = 0, gh = 0;
    	rcCalcGridSize(mini, maxi, CellSize, &gw, &gh);
    	const int ts = TileVoxelSize / GridDiv;
    	const int tw = (gw + ts-1) / ts;
    	const int th = (gh + ts-1) / ts;
    	const float tcs = ts * CellSize;
        int numTiles = th * tw;
        
        NavMeshSetData meshData[numTiles];
        int tileNum = 0;
    
    	for(int Yi = 0; Yi < th; ++Yi){
    		for(int Xi = 0; Xi < tw; ++Xi){
    			//Get correct bound of our smaller tile
    			float mymini[3];
    			mymini[0] = mini[0] + Xi * tcs;
    			mymini[1] = mini[1];
    			mymini[2] = mini[2] + Yi * tcs;
    			float mymaxi[3];
    			mymaxi[0] = mini[0] + (Xi+1) * tcs;
    			mymaxi[1] = maxi[1];
    			mymaxi[2] = mini[2] + (Yi+1) * tcs;
                
    			//Get tile coordinates
    			int tileX = (int)(((mymini[0] + mymaxi[0]) / 2) - NavMeshOri[0]) / (GRID_SIZE / GridDiv); 
    			int tileY = (int)(((mymini[2] + mymaxi[2]) / 2) - NavMeshOri[2]) / (GRID_SIZE / GridDiv);
                
    			rcCalcGridSize(mymini, mymaxi, CellSize, &gw, &gh);
    			NSLog(@"(%i_%i) %i_%i Grid size", tx, ty, tileX, tileY);
                /*NSLog(@" tile size: %d", ts);
                NSLog(@"  min: {%0.2f, %0.2f, %0.2f}", mymini[0], mymini[1], mymini[2]);
                NSLog(@"  max: {%0.2f, %0.2f, %0.2f}", mymaxi[0], mymaxi[1], mymaxi[2]);*/
    
                int dataSize = 0;
                unsigned char *data = [self buildMeshWithGeom:geom andX:tileX andY:tileY andMin:mymini andMax:mymaxi andSize:dataSize];
                if ( data ){
                    meshData[tileNum].data = data;
                    meshData[tileNum++].dataSize = dataSize;                
                }
                
                int percent = int(((float)tileNum/(float)numTiles)*100.0f);
                
                // update our statistics
                [[ThreadStatController sharedInstance] setPercentComplete:percent andX:tx andY:ty];
    		}
        }
    
        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 =  totalTilesInMesh * (GridDiv*GridDiv);
    	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);
        
        if ( geom ){
            delete geom;
        }
        
        NSLog(@"Completed in %0.2f seconds", [start timeIntervalSinceNow] * -1.0f);
    }
    Note: The above is in Objective-C, but you should be able to make sense of it
    https://tanaris4.com

  8. #8
    rik.chong's Avatar Member
    Reputation
    7
    Join Date
    Oct 2009
    Posts
    35
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @Tanaris4
    yes, I am doing 4x4 tiles
    I read your post http://www.ownedcore.com/forums/worl...ing-tiles.html (Recast + Detour - Connecting tiles)
    m_navQuery->init(_navMesh, 65536);
    still not working

    Can someone explain this to me? (ADT/Map Tile)-good-jpgCan someone explain this to me? (ADT/Map Tile)-weird-png

    you can see my screenshot, not all the tiles are not connected.

    between tiles there are white/black lines(gap?)

    the weirdest thing is the white line can be crossed, while the black one seems like walls! but they belong to a same tile, I'm so confused.

  9. #9
    rik.chong's Avatar Member
    Reputation
    7
    Join Date
    Oct 2009
    Posts
    35
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    still no go, can anybody helps?:confused:

  10. #10
    rik.chong's Avatar Member
    Reputation
    7
    Join Date
    Oct 2009
    Posts
    35
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Update:
    I reverted R/D to rev.292, and the problem is gone.
    I'm not skilled in 3D programming, can't fully understand R/D, maybe some generation-related parameters changed after rev.292

  11. #11
    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)
    I can confirm I've same problem with last R&D version. I don't know why yet.

  12. #12
    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)
    It's because your tiles aren't perfectly lined up, you need to change some parameters. My guess is you need to calculate the size of the tile based on the x,y
    https://tanaris4.com

  13. #13
    rik.chong's Avatar Member
    Reputation
    7
    Join Date
    Oct 2009
    Posts
    35
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Tanaris4 View Post
    It's because your tiles aren't perfectly lined up, you need to change some parameters. My guess is you need to calculate the size of the tile based on the x,y
    Thanks for your reply
    I can confirm the tiles lined up correctly, b/c the same code works perfectly in rev.292.
    You can see my screenshot, the line between 2 tiles is discontinuous, part of the line (in white) is connected. Very weird issue.

    Originally Posted by guizmows View Post
    I can confirm I've same problem with last R&D version. I don't know why yet.
    So you're using the older version?
    I made a mesh-generator with rev.292, and the path-finding works well with the latest
    Last edited by rik.chong; 03-29-2012 at 02:17 AM.

  14. #14
    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)
    yes I'm using an old version. I don't remember rev number.

Similar Threads

  1. Can someone do this?
    By Priestofthedead68 in forum World of Warcraft Model Editing
    Replies: 1
    Last Post: 08-01-2008, 07:06 PM
  2. Can someone explain Arena win-trading?
    By jakobud in forum WoW PvP & Battlegrounds
    Replies: 6
    Last Post: 05-19-2008, 10:39 PM
  3. [Request] can someone convert this for me?
    By arthas242 in forum WoW ME Questions and Requests
    Replies: 4
    Last Post: 02-08-2008, 03:40 PM
  4. [Help]Can someone fix this mysql line for me.
    By Kiev in forum World of Warcraft Emulator Servers
    Replies: 9
    Last Post: 01-13-2008, 08:14 AM
  5. Can someone do this for me? please?
    By Elunian in forum WoW ME Questions and Requests
    Replies: 2
    Last Post: 09-10-2007, 02:25 PM
All times are GMT -5. The time now is 06:15 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search