Texturing a Rigidbody

Post Reply
linyx
Posts: 1
Joined: Mon May 23, 2016 6:15 am

Texturing a Rigidbody

Post by linyx »

Hi guys,

I'm a fairly new person to the bullet physics library. I am currently using JBullet for my physics in my game. How do I texture a cube with different images for different sides?
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: Texturing a Rigidbody

Post by benelot »

Hi linyx,

How do you visualize your Bullet simulated cube? Bullet is a physics engine only, so it does not have any visualization capabilities. The only thing related to visualization it has is the bullet debug drawer. It can be implemented to draw the physics world within any kind of graphics engine, but for this purpose you need a separate graphics engine such as Ogre3D, Irrlicht, pure OpenGL etc. You probably have such an engine as you think about adding textures.

The basic procedure to visualize a cube in a graphics engine looks like this:
  • Create a graphical cube within your graphics engine.
  • Write a simple update loop for your graphics, within which you step your physics and then update the graphical cube position and orientation with the bullet cube's position and orientation.
To texturize your cube, you should then check out how to do this in your graphics engine. Furthermore, if you experience strange physics (cube hovering above ground etc.) you should implrement the debug drawer, which draws you the actual size of the cube. For some graphics engines, the units of the dimensions are different, therefore a 1x1x1 cube in your graphics engine might be bigger/smaller than a 1x1x1 cube in bullet. Then you might need a scaling factor (meaning if a 0.5x0.5x0.5 graphics cube is the same size as a 1x1x1 bullet cube, you need to scale every object in your graphics engine with 0.5 for each dimension.)

Tell me if this helps or if you need anything else.
Post Reply