bulletphysics / bullet3

Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.
http://bulletphysics.org
Other
12.19k stars 2.85k forks source link

Incorrect texture rendering for 3D meshes from .obj file #1813

Closed anoopsonar30 closed 3 years ago

anoopsonar30 commented 5 years ago

I've been trying to render 3D meshes from the S3DIS database which can be found at - http://buildingparser.stanford.edu/dataset.html

The render for area_3 in pybullet looks like this - pybulletrender1

where the textures are all messed up and in the incorrect places. Moreover the roof isn't rendered at all. On importing the same .obj file into a software like 3DS Max I got the following perfect renders -

3dsmaxrender 3dsmaxrender2

Moreover, I've been trying to render a husky robot on the floor of this 3D environment. However, pybullet renders both area_3 and husky for a split second after which area_3 disappears and only the husky is left. Could someone look into this? The 3D environment above is rendered using the createMultiBody() function using the .obj file and the husky is rendered from it's URDF.

erwincoumans commented 5 years ago

PyBullet (and the underlying Bullet Robotics APIs) rendering has some limitations:

1) wavefront obj files can have at most 1 texture 2) there is a limited pre-allocated memory for visual meshes

You can use obj2sdf utility to get around (1), it creates additional obj files for each material/texture. Use premake to build Bullet, you get the App_obj2sdf executable (it is in the 'Extras' folder).

You can try increasing the default memory allocation to get around (2), or reduce/simplify the mesh/obj file. See https://github.com/bulletphysics/bullet3/blob/master/examples/OpenGLWindow/SimpleOpenGL3App.h#L19, increase the maxShapeCapacityInBytes.

Can you share the full reproduction case, including PyBullet python file and the actual obj file and textures in some github repo?

By the way, the Stanford GIBSON project also uses PyBullet and its own renderer, which may be able to render those datasets better. Still, it would be good to fix PyBullet to allow to render this too.