[Bullet] Irrlicht Terrain Mesh to Bullet Mesh

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

[Bullet] Irrlicht Terrain Mesh to Bullet Mesh

Post by Nadro »

Hi, I have question about converting mesh generated from heightmap to Bullet btTriangleMesh. My current mesh converter don't work with terrain meshes. I get mesh in follow steps:
1. I generate ITerrainSceneNode.
2. I copy terrain LOD Buffer to CDynamicMeshBuffer.
3. I convert MeshBuffer to btTriangleMesh.

This is differences between 'collision' and 'drawing' meshes:
Image
Image

Image
Image

Collision mesh look as mix between Convex Hull and BVH... I have similar results when I use btTriangleIndexVertexArray instead btTriangleMesh
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Have you looked at the bullet height field primitive? It is designed specifically for terrain.

Look at "btHeightfieldTerrainShape.h" in the bullet sdk under src\BulletCollision\CollisionShapes.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

No, currently I don't test btHeightfieldTerrainShape, because two independent create meshes first via Irrlicht and second via Bullet can return differences results eg. more smoothly etc... so I think BVH is better solution for it. I think problem is in Irrlicht terrain mesh structure, so converter can't rewrite it properly.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

The Terrain Scene Node has no index that is required in Bullet. You can create the terrain in Bullet first and then pass it to Terrain Scene Node afterwards.
Image
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

Thanks for interesting of my problem, but I solved my problem.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
m506
Posts: 12
Joined: Wed Jun 18, 2008 5:34 am

Post by m506 »

would you mind telling us what you did? I have similar problems.

Thanks
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

In currently Irrlicht version indices are storage in irr::u32, so in Your Irrlicht to Bullet mesh converter You also have to change irr::u16 to irr::u32 eg.

Code: Select all

irr::u16* mb_indices = mb->getIndices();
to

Code: Select all

irr::u32* mb_indices = (irr::u32*)mb->getIndices();
Now all will be ok ;)
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Nadro wrote:In currently Irrlicht version indices are storage in irr::u32, so in Your Irrlicht to Bullet mesh converter You also have to change irr::u16 to irr::u32 eg.

Code: Select all

irr::u16* mb_indices = mb->getIndices();
to

Code: Select all

irr::u32* mb_indices = (irr::u32*)mb->getIndices();
Now all will be ok ;)
You should check the index type first with getIndexType()
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Post Reply