[2.2] Terra and OgreRecast

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
Lax
Hobgoblin
Posts: 510
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 34

[2.2] Terra and OgreRecast

Post by Lax »

Hi all,

has anybody Terra working for OgreRecast navigation map?
The old version OgreRecast has usage for Ogre v1 Terrain:

Code: Select all

InputGeom(Ogre::TerrainGroup *terrainGroup, std::vector<Ogre::Entity*> srcMeshes = std::vector<Ogre::Entity*>());
But the implementatino is of course not compatible to terra.
I tried via heightmap code, but without success.

Best Regards
Lax
Image
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
Image
Lax
Hobgoblin
Posts: 510
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 34

Re: [2.2] Terra and OgreRecast

Post by Lax »

Hi,

no one using Ogre2.x terra and OgreRecast for creating a navigation mesh out of terra?

I already ported OgreRecast for Ogre2.x, so that Ogre::Item's can be mixed with Ogre::v1::Entity's for navigation mesh creation.
I also extended the debug draw mechanisms for OgreRecast.

But I'am still struggeling with terra, getting the vertex information for navigation mesh creation.

Best Regards
Lax
Image
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
Image
Nucleartree
Gnoblar
Posts: 16
Joined: Tue Apr 04, 2017 9:10 pm
Location: Cardiff, UK
x 8

Re: [2.2] Terra and OgreRecast

Post by Nucleartree »

Hi.

I've got a half-baked implementation of recast in my level editor. I'm not using OgreRecast or any wrapper libraries, so I'm not sure how helpful this will be for you, but if it helps then it helps. I'm still using 2.1 but that shouldn't be a problem for you as I get hold of the height values from terra's height array, not downloaded from the gpu.

Pretty much to include the terrain I just loop over the height data in terra and shovel them into a buffer to give to recast.

Code: Select all

    void Terra::writeVertexDataToBuffer(float* bufferStart) const {
        for(int y = 0; y < m_depth; y++){
            for(int x = 0; x < m_width; x++){
                *bufferStart++ = x * m_xzRelativeSize.x;
                *bufferStart++ = m_heightMap[x + y * m_width] - (m_height / 2);
                *bufferStart++ = y * m_xzRelativeSize.y;
            }
        }
    }


    void Terra::writeTriangleDataToBuffer(int offset, int* bufferStart) const {
        int newWidth = m_width - 1;
        int newDepth = m_depth - 1;
        for(int y = 0; y < newDepth; y++){
            for(int x = 0; x < newWidth; x++){
                //Write out two triangles
                *bufferStart++ = offset + x + y * newWidth;
                *bufferStart++ = offset + x + 1 + (y+1) * newWidth;
                *bufferStart++ = offset + x + 1 + y * newWidth;

                *bufferStart++ = offset + x + y * newWidth;
                *bufferStart++ = offset + x + 1 + (y+1) * newWidth;
                *bufferStart++ = offset + x + (y+1) * newWidth;
            }
        }
    }
Link

I'm using quite an unorthodox solution because I only include physics shapes for the nav mesh, but if terrain is the important bit then that should be fine. Please don't judge me too hard on some of this code base :), I had to de-prioritise nav meshes due to time limits so it's not exactly done yet.
Lax
Hobgoblin
Posts: 510
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 34

Re: [2.2] Terra and OgreRecast

Post by Lax »

Hi Nucleartree,

thanks! I will try that out, it seems, as its that what I'm looking for :D

Best Regards
Lax
Image
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
Image
Lax
Hobgoblin
Posts: 510
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 34

Re: [2.2] Terra and OgreRecast

Post by Lax »

Hi all,

got OgreRecast with terra working :)
In the picture below, I activated the recast debug drawing, in order to see, which areas are walkable.

http://www.lukas-kalinowski.com/Homepag ... onMesh.png

I integrated the solution in the OgreRecast project. It can be used the following way:

Code: Select all

this->hasValidNavMesh = this->detourTileCache->TileCacheBuild(terra, entities, items);
What's new too, is that OgreRecast now does work for entities and Ogre v2 items!

If anyone is interested, using my implementation, the source code is available here:

https://sourceforge.net/p/nowa-engine/s ... utGeom.cpp

Best Regards
Lax
Image
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
Image
Post Reply