KBEngine官方论坛

 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 配置 开服
楼主: DarkWere

Navigation mesh for UE4

[复制链接]

30

主题

7138

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
16457
QQ
发表于 2017-5-10 21:47:32 | 显示全部楼层
DarkWere 发表于 2017-5-10 19:12
My mistake. I was trying to compile the latest version of recastnavigation, but at the moment of kbe ...

From the description of recastnavigation, the position of the monster must be on the ground.
The map unit of UE4 is centimeters, KBE is meters.
Perhaps because of this, your monster is not in the area of effective navigation
热爱游戏、热爱开源!
柯标
3603661@qq.com

柯标
3603661@qq.com
回复

使用道具 举报

11

主题

96

帖子

813

积分

高级会员

Rank: 4

积分
813
 楼主| 发表于 2017-5-10 22:16:36 | 显示全部楼层
As I can see spawn positions for this map (kbengine_ue4_demo) in scripts/data/d_spaces_spawn.py are set in meters.
Spawned entities are in correct places while playing in kbengine_ue4_demo client.
Does client convert units to Unreal Engine from kbengine somewhere?
回复

使用道具 举报

8

主题

3374

帖子

7586

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
7586
QQ
发表于 2017-5-10 22:21:25 | 显示全部楼层
DarkWere 发表于 2017-5-10 22:16
As I can see spawn positions for this map (kbengine_ue4_demo) in scripts/data/d_spaces_spawn.py are  ...

Yes, the client converts the coordinates of the server synchronization to centimeters..

But your navmesh in the service side may be centimeters(Export the obj size)
柯标
3603661@qq.com
回复

使用道具 举报

11

主题

96

帖子

813

积分

高级会员

Rank: 4

积分
813
 楼主| 发表于 2017-5-10 22:24:23 | 显示全部楼层
Oh, I've got this.
So, now I need to convert obj from centimeters to meters, then generate navmesh again.
Right?
回复

使用道具 举报

8

主题

3374

帖子

7586

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
7586
QQ
发表于 2017-5-10 22:42:28 | 显示全部楼层
DarkWere 发表于 2017-5-10 22:24
Oh, I've got this.
So, now I need to convert obj from centimeters to meters, then generate navmesh a ...

yes
柯标
3603661@qq.com
回复

使用道具 举报

11

主题

96

帖子

813

积分

高级会员

Rank: 4

积分
813
 楼主| 发表于 2017-5-11 00:35:06 | 显示全部楼层
Well, next problem:

I've converted the map to meters, build a navmesh.

I've changed scripts/cell/space.py this way:
KBEngine.addSpaceGeometryMapping(self.spaceID, None, resPath, True, {0 : "srv_xinshoucun_1.navmesh", 1 : "srv_xinshoucun.navmesh", 7 : "kbengine_ue4_demo.navmesh"})

The navmesh loaded succesfully:

    INFO    cellapp01 500 7129652375332859700  [2017-05-10 21:12:47 377] - KBEngine::addSpaceGeometryMapping: spaceID=6, respath=spaces/kbengine_ue4_demo, shouldLoadOnServer=1!
   S_DBG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:47 377] - onSpaceData: spaceID=6, key=_mapping, value=spaces/kbengine_ue4_demo.
   S_DBG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:47 377] - created space[7] entityID = 1110, res = spaces/kbengine_ue4_demo.
   ERROR    cellapp01 500 7129652375332859700  [2017-05-10 21:12:47 377] - NavMeshHandle::create: open(/home/oleg/kbengine/kbengine_demos_assets/res/spaces/kbengine_ue4_demo/srv_xinshoucun_1.navmesh) is error!
   ERROR    cellapp01 500 7129652375332859700  [2017-05-10 21:12:47 377] - NavMeshHandle::create: open(/home/oleg/kbengine/kbengine_demos_assets/res/spaces/kbengine_ue4_demo/srv_xinshoucun.navmesh) is error!
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:47 377] - NavMeshHandle::create: (/home/oleg/kbengine/kbengine_demos_assets/res/spaces/kbengine_ue4_demo/kbengine_ue4_demo.navmesh), layer=7
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:47 383] -      ==> tiles loaded: 2809
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:47 383] -      ==> BVTree nodes: 7324
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:47 383] -      ==> 3662 polygons (12677 vertices)
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:47 383] -      ==> 21789 triangles (10607 vertices)
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:47 383] -      ==> 1.30 MB of data (not including pointers)
    INFO    cellapp01 500 7129652375332859700  [2017-05-10 21:12:47 476] - KBEngine::onLoadedSpaceGeometryMapping: spaceID=6, respath=spaces/kbengine_ue4_demo!
   S_DBG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:47 476] - onSpaceGeometryLoaded: spaceID=6, mapping=spaces/kbengine_ue4_demo.
   S_DBG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:47 476] - onAllSpaceGeometryLoaded: spaceID=6, isBootstrap=1, mapping=spaces/kbengine_ue4_demo.

But the monsters still standing still, and I've got this error:

   S_DBG    cellapp01 500 7129652375332859700  [2017-05-10 21:14:17 378] - Avatar::onGetWitness: 1200.
   S_DBG    cellapp01 500 7129652375332859700  [2017-05-10 21:14:17 378] - Space::onEnter space[7] entityID = 1200.
WARNING    cellapp01 500 7129652375332859700  [2017-05-10 21:14:17 378] - Witness::update(1200): sendToClient 1567 Bytes.
   ERROR    cellapp01 500 7129652375332859700  [2017-05-10 21:14:17 476] - NavMeshHandle::findRandomPointAroundCircle: not found layer(0)
   ERROR    cellapp01 500 7129652375332859700  [2017-05-10 21:14:17 476] - NavMeshHandle::findRandomPointAroundCircle: not found layer(0)
   ERROR    cellapp01 500 7129652375332859700  [2017-05-10 21:14:17 477] - NavMeshHandle::findRandomPointAroundCircle: not found layer(0)
and so on...

What is the problem now?
Help me pls!
Thanks in advance!
回复

使用道具 举报

11

主题

96

帖子

813

积分

高级会员

Rank: 4

积分
813
 楼主| 发表于 2017-5-11 00:40:50 | 显示全部楼层
回复

使用道具 举报

30

主题

7138

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
16457
QQ
发表于 2017-5-11 11:27:59 | 显示全部楼层
2 errors

  1.    ERROR    cellapp01 500 7129652375332859700  [2017-05-10 21:12:47 377] - NavMeshHandle::create: open(/home/oleg/kbengine/kbengine_demos_assets/res/spaces/kbengine_ue4_demo/srv_xinshoucun_1.navmesh) is error!
  2.    ERROR    cellapp01 500 7129652375332859700  [2017-05-10 21:12:47 377] - NavMeshHandle::create: open(/home/oleg/kbengine/kbengine_demos_assets/res/spaces/kbengine_ue4_demo/srv_xinshoucun.navmesh) is error!
复制代码
热爱游戏、热爱开源!
柯标
3603661@qq.com

柯标
3603661@qq.com
回复

使用道具 举报

30

主题

7138

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
16457
QQ
发表于 2017-5-11 11:30:02 | 显示全部楼层
        FILE* fp = fopen(res.c_str(), "rb");
        if (!fp)
        {
                ERROR_MSG(fmt::format("NavMeshHandle::create: open({}) error!\n",
                        Resmgr::getSingleton().matchRes(res)));

                return false;
        }
热爱游戏、热爱开源!
柯标
3603661@qq.com

柯标
3603661@qq.com
回复

使用道具 举报

11

主题

96

帖子

813

积分

高级会员

Rank: 4

积分
813
 楼主| 发表于 2017-5-11 12:58:01 | 显示全部楼层
Yes, but this navmeshes were loaded earlier!

   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 376] - Spaces::createNewSpace: new space(Space) 1.
    INFO    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 376] - EntityApp::createEntity: new Space 1026
    INFO    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 376] - KBEngine::addSpaceGeometryMapping: spaceID=1, respath=spaces/xinshoucun, shouldLoadOnServer=1!
   S_DBG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 377] - onSpaceData: spaceID=1, key=_mapping, value=spaces/xinshoucun.
   S_DBG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 377] - created space[1] entityID = 1026, res = spaces/xinshoucun.
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 378] - NavMeshHandle::create: (/home/oleg/kbengine/kbengine_demos_assets/res/spaces/xinshoucun/srv_xinshoucun_1.navmesh), layer=0
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 385] -      ==> tiles loaded: 25
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 385] -      ==> BVTree nodes: 14760
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 385] -      ==> 7380 polygons (13002 vertices)
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 385] -      ==> 21866 triangles (6102 vertices)
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 385] -      ==> 1.18 MB of data (not including pointers)
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 385] - NavMeshHandle::create: (/home/oleg/kbengine/kbengine_demos_assets/res/spaces/xinshoucun/srv_xinshoucun.navmesh), layer=1
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 397] -      ==> tiles loaded: 25
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 397] -      ==> BVTree nodes: 19604
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 397] -      ==> 9802 polygons (18805 vertices)
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 397] -      ==> 27368 triangles (6525 vertices)
   DEBUG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 397] -      ==> 1.57 MB of data (not including pointers)
   ERROR    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 397] - NavMeshHandle::create: open(/home/oleg/kbengine/kbengine_demos_assets/res/spaces/xinshoucun/kbengine_ue4_demo.navmesh) is error!
    INFO    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 476] - KBEngine::onLoadedSpaceGeometryMapping: spaceID=1, respath=spaces/xinshoucun!
   S_DBG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 477] - onSpaceGeometryLoaded: spaceID=1, mapping=spaces/xinshoucun.
   S_DBG    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 477] - onAllSpaceGeometryLoaded: spaceID=1, isBootstrap=1, mapping=spaces/xinshoucun.
回复

使用道具 举报

30

主题

7138

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
16457
QQ
发表于 2017-5-11 15:21:52 | 显示全部楼层
now is: ERROR    cellapp01 500 7129652375332859700  [2017-05-10 21:12:41 397] - NavMeshHandle::create: open(/home/oleg/kbengine/kbengine_demos_assets/res/spaces/xinshoucun/kbengine_ue4_demo.navmesh) is error!

Are you sure this file can be found(/home/oleg/kbengine/kbengine_demos_assets/res/spaces/xinshoucun/kbengine_ue4_demo.navmesh)?
热爱游戏、热爱开源!
柯标
3603661@qq.com

柯标
3603661@qq.com
回复

使用道具 举报

30

主题

7138

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
16457
QQ
发表于 2017-5-11 15:23:14 | 显示全部楼层
DarkWere 发表于 2017-5-11 12:58
Yes, but this navmeshes were loaded earlier!

   DEBUG    cellapp01 500 7129652375332859700  [2017-0 ...

/home/oleg/kbengine/kbengine_demos_assets/res/spaces/xinshoucun/srv_xinshoucun_1.navmesh
/home/oleg/kbengine/kbengine_demos_assets/res/spaces/kbengine_ue4_demo/srv_xinshoucun_1.navmesh


They were thought to be two different navmesh,
So the data you load previously is not reusable in this space.


NavigationHandlePtr Navigation::loadNavigation(std::string resPath, const std::map< int, std::string >& params)
{
        KBEngine::thread::ThreadGuard tg(&mutex_);
        if(resPath == "")
                return NULL;
       
        KBEUnordered_map<std::string, NavigationHandlePtr>::iterator iter = navhandles_.find(resPath);
        if(iter != navhandles_.end())
        {
                return iter->second;
        }

        NavigationHandle* pNavigationHandle_ = NULL;

        std::string path = resPath;
        path = Resmgr::getSingleton().matchPath(path);
        if(path.size() == 0)
                return NULL;
               
        wchar_t* wpath = strutil::char2wchar(path.c_str());
        std::wstring wspath = wpath;
        free(wpath);

        std::vector<std::wstring> results;
        Resmgr::getSingleton().listPathRes(wspath, L"tmx", results);
       
        if(results.size() > 0)
        {
                pNavigationHandle_ = NavTileHandle::create(resPath, params);
        }
        else        
        {
                results.clear();
                Resmgr::getSingleton().listPathRes(wspath, L"navmesh", results);

                if(results.size() == 0)
                {
                        return NULL;
                }

                pNavigationHandle_ = NavMeshHandle::create(resPath, params);
        }


        navhandles_[resPath] = NavigationHandlePtr(pNavigationHandle_);
        return pNavigationHandle_;
}

热爱游戏、热爱开源!
柯标
3603661@qq.com

柯标
3603661@qq.com
回复

使用道具 举报

30

主题

7138

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
16457
QQ
发表于 2017-5-11 16:03:25 | 显示全部楼层
kbe 发表于 2017-5-11 15:23
/home/oleg/kbengine/kbengine_demos_assets/res/spaces/xinshoucun/srv_xinshoucun_1.navmesh
/home/oleg ...

I think this will improve in the future, and can use some algorithms to ensure File uniqueness (MD5 (File))
热爱游戏、热爱开源!
柯标
3603661@qq.com

柯标
3603661@qq.com
回复

使用道具 举报

11

主题

96

帖子

813

积分

高级会员

Rank: 4

积分
813
 楼主| 发表于 2017-5-11 16:10:07 | 显示全部楼层
So, if I've understand correctly there should be all three navmeshes:

srv_xinshoucun_1.navmesh
srv_xinshoucun.navmesh
kbengine_ue4_demo.navmesh

in res/spaces/kbengine_ue4_demo folder?
回复

使用道具 举报

30

主题

7138

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
16457
QQ
发表于 2017-5-11 16:19:46 | 显示全部楼层
DarkWere 发表于 2017-5-11 16:10
So, if I've understand correctly there should be all three navmeshes:

srv_xinshoucun_1.navmesh

yes
热爱游戏、热爱开源!
柯标
3603661@qq.com

柯标
3603661@qq.com
回复

使用道具 举报

11

主题

96

帖子

813

积分

高级会员

Rank: 4

积分
813
 楼主| 发表于 2017-5-11 16:30:30 | 显示全部楼层
Thanks a lot, I really appreciate you for all your help and patience with me!
回复

使用道具 举报

11

主题

96

帖子

813

积分

高级会员

Rank: 4

积分
813
 楼主| 发表于 2017-5-11 18:36:46 | 显示全部楼层
A problem still persist.

All navmeshes has loaded successfully but monsters standing still.
I've got this error messages in a log.

cellapp01: [ERROR]: NavMeshHandle::findStraightPath(spaces/kbengine_ue4_demo): Could not find any nearby poly's (0, 0)
   cellapp01: [ERROR]: NavMeshHandle::findStraightPath(spaces/kbengine_ue4_demo): Could not find any nearby poly's (0, 0)
   cellapp01: [ERROR]: NavMeshHandle::findRandomPointAroundCircle(spaces/kbengine_ue4_demo): Could not find any nearby poly's (0)
   cellapp01: [ERROR]: NavMeshHandle::findRandomPointAroundCircle(spaces/kbengine_ue4_demo): Could not find any nearby poly's (0)
   cellapp01: [ERROR]: NavMeshHandle::findRandomPointAroundCircle(spaces/kbengine_ue4_demo): Could not find any nearby poly's (0)
   cellapp01: [ERROR]: NavMeshHandle::findStraightPath(spaces/kbengine_ue4_demo): Could not find any nearby poly's (0, 0)
   cellapp01: [ERROR]: NavMeshHandle::findRandomPointAroundCircle(spaces/kbengine_ue4_demo): Could not find any nearby poly's (0)
   cellapp01: [ERROR]: NavMeshHandle::findRandomPointAroundCircle(spaces/kbengine_ue4_demo): Could not find any nearby poly's (0)
   cellapp01: [ERROR]: NavMeshHandle::findRandomPointAroundCircle(spaces/kbengine_ue4_demo): Could not find any nearby poly's (0)
   cellapp01: [ERROR]: NavMeshHandle::findStraightPath(spaces/kbengine_ue4_demo): Could not find any nearby poly's (0, 0)
   cellapp01: [ERROR]: NavMeshHandle::findStraightPath(spaces/kbengine_ue4_demo): Could not find any nearby poly's (0, 0)
   cellapp01: [ERROR]: NavMeshHandle::findRandomPointAroundCircle(spaces/kbengine_ue4_demo): Could not find any nearby poly's (0)
   cellapp01: [ERROR]: NavMeshHandle::findStraightPath(spaces/kbengine_ue4_demo): Could not find any nearby poly's (0, 0)

What is the problem? kbengine_ue4_demo.navmesh not suitable for current placements of the monsters?
回复

使用道具 举报

8

主题

3374

帖子

7586

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
7586
QQ
发表于 2017-5-11 18:57:14 | 显示全部楼层
The current location of the monster may not be on the ground.


You can try navigating the coordinates of the monster using the recasedemo
柯标
3603661@qq.com
回复

使用道具 举报

30

主题

7138

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
16457
QQ
发表于 2017-5-11 19:15:51 | 显示全部楼层
  1.         dtNavMeshQuery* navmeshQuery = iter->second.pNavmeshQuery;
  2.         // dtNavMesh*

  3.         float spos[3];
  4.         spos[0] = start.x;
  5.         spos[1] = start.y;
  6.         spos[2] = start.z;

  7.         float epos[3];
  8.         epos[0] = end.x;
  9.         epos[1] = end.y;
  10.         epos[2] = end.z;

  11.         dtQueryFilter filter;
  12.         filter.setIncludeFlags(0xffff);
  13.         filter.setExcludeFlags(0);

  14.         const float extents[3] = {2.f, 4.f, 2.f};

  15.         dtPolyRef startRef = INVALID_NAVMESH_POLYREF;
  16.         dtPolyRef endRef = INVALID_NAVMESH_POLYREF;

  17.         float startNearestPt[3];
  18.         float endNearestPt[3];
  19.         navmeshQuery->findNearestPoly(spos, extents, &filter, &startRef, startNearestPt);
  20.         navmeshQuery->findNearestPoly(epos, extents, &filter, &endRef, endNearestPt);

  21.         if (!startRef || !endRef)
  22.         {
  23.                 ERROR_MSG(fmt::format("NavMeshHandle::findStraightPath({2}): Could not find any nearby poly's ({0}, {1})\n", startRef, endRef, resPath));
  24.                 return NAV_ERROR_NEARESTPOLY;
  25.         }
复制代码



findNearestPoly error,
You can get more answers to this question by asking (https://github.com/recastnavigation/recastnavigation/issues)
热爱游戏、热爱开源!
柯标
3603661@qq.com

柯标
3603661@qq.com
回复

使用道具 举报

11

主题

96

帖子

813

积分

高级会员

Rank: 4

积分
813
 楼主| 发表于 2017-5-22 16:22:38 | 显示全部楼层
Does it need to set "rangemgr_y" to true in kbengine_defs.xml in order to navmesh to work?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|KBEngine Forum

GMT+8, 2018-12-15 00:36 , Processed in 0.034687 second(s), 19 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表