How animate a textured cube loaded from an OBJ file?

Post Reply
Herk
Posts: 3
Joined: Fri Nov 11, 2016 7:49 am

How animate a textured cube loaded from an OBJ file?

Post by Herk »

Hi, Forumers.

I seem to be able to successfully create a btConvexHullShape collision object from the textured cube in "App_BulletExampleBrowser" example "Importers/ImportObjDemo", and then create a dynamic rigid body; the rigid body, however, does not respond gravity. I noticed that a related tutorial, "Simple rigid body loaded from an object file," uses a different method to load its .obj file; that method, however, that doesn't seem to allow for texturing with the .png texture used in the "Importers/ImportObjDemo."

Any pointers or suggestions would be appreciated appreciated.

Thanks.
Herk
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: How animate a textured cube loaded from an OBJ file?

Post by benelot »

Hi,

The thing about textures is that to get a texturized object moving along with the physics object, you need a separate graphical representation with the texture that just copies the movement of the physics object. This means you need a graphics engine additional to bullet to get the texture stuff done for you. What are you trying to achieve in the long run? Give some context.
Herk
Posts: 3
Joined: Fri Nov 11, 2016 7:49 am

Re: How animate a textured cube loaded from an OBJ file?

Post by Herk »

Hi, Benelot.

Thank you for your reply.

What I am initially hoping to be able to do is replace the "m_guiHelper->autogenerateGraphicsObjects" used, for example, in the tutorials with more colorful objects, such as the Wavefront textured cubes used in "App_BulletExampleBrowser/Renderers/TinyRendererSetUp" (which can be animated/rotated) and in "App_BulletExampleBrowser/Importers/ImportObjDemo" (which seems to be static). Not only do I find the textured Wavefront Obj cubes more pleasing to look at, I also find their variegated surfaces make visually tracking rotations much easier.

My rendering environment is as follows: in Xcode, I build small, simple, Bullet-tutorial-like Command Line Tool apps which rely exclusively on the OpenGL rendering capabilities of Bullet (2.85.1). I find this approach relieves one of the considerable tedium of creating OpenGL apps from scratch. If, however, the transformation (rotation) code used in "App_BulletExampleBrowser/Renderers/TinyRendererSetUp" is typical of what's required to animate textured objects in Bullet, then I may have no choice but to use OpenGL directly. Since I'm a complete novice wrt bullet & physics programming, I thought possibly I was missing, or unaware of, a simple way of animating the ExampleBrowser's textured examples.

Thanks, again, for taking the time to reply.

Best Regards.
Herk
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: How animate a textured cube loaded from an OBJ file?

Post by Erwin Coumans »

It should be easy to replace autogenerateGraphicsObjects with a version that adds textures in a few lines. You basically have to call 'textureIndex = renderer->registerTexture(meshData.m_textureImage,meshData.m_textureWidth,meshData.m_textureHeight);' and pass that index when creating the graphics object in the Bullet Example Browser.

Easiest is using the more recent URDF or SDF loaders to create rigid bodies, it has automatic texture loading support.
Herk
Posts: 3
Joined: Fri Nov 11, 2016 7:49 am

Re: How animate a textured cube loaded from an OBJ file? TH

Post by Herk »

Great! I'll see what I can do. That's just the sort of thing a newcomer would probably never, or very belatedly, realize/think possible.

Thanks a lot, Erwin.

Sincerely,
Herk
susan123
Posts: 3
Joined: Sun Nov 20, 2016 8:47 am

Re: How animate a textured cube loaded from an OBJ file?

Post by susan123 »

Erwin Coumans wrote:It should be easy to replace autogenerateGraphicsObjects with a version that adds textures in a few lines. You basically have to call 'textureIndex = renderer->registerTexture(meshData.m_textureImage,meshData.m_textureWidth,meshData.m_textureHeight);' and pass that index when creating the graphics object in the Bullet Example Browser.
subchorionichemorrhagehealth care tippoikilothermia

Easiest is using the more recent URDF or SDF loaders to create rigid bodies, it has automatic texture loading support.
Thank you so much for your efforts but would it be possible for you to explain it via visuals because i am little confused to get through it!
hyperthymesiadorsalgia
Post Reply