How to apply Bullet physics to drawn Opengl 3d shapes

后端 未结 4 1699
情话喂你
情话喂你 2020-12-30 13:55

I was just wondering whether there is a way to apply bullet physics to opengl drawn objects (created using glVertex3f or triangle mesh with glVertexAttribPointer). I am curr

4条回答
  •  佛祖请我去吃肉
    2020-12-30 14:43

    Without studying the specifics of Bullet or OpenGL (I've coded in OpenGL a little) it seems you wish to apply Bullet to an object twice, once for the CollisionShape (whatever that is) and then for the drawn opengl object.

    It seems it would be a matter of creating your OpenGL object in a memory object, applying the Bullet method to get your CollisionShape (whatever that is), saving this data in memory, then applying the Bullet method to this new triangle list for world positioning (if my understanding of your question is right).

    It would be similar to applying 2 different transforms on an object separately without the benefit of matrix math. You would calculate the new positions of the vectors based on rotation, then after you have these points move them in the world based on translation. You would have an intermediate step that is used in memory to apply your second translation. That is the way I had done it in my first 3d rendered I made without learning how it was done to see if I could come up with it on my own.

    Maybe this will help you, maybe it won't. If it doesn't, perhaps you can explain where you are having troubles and I (or others) can look into the specifics of OpenGL and Bullet to come up with the actual algorithm for you (although I'm sure it probably exists somewhere). If you search enough you'll probably find code on the Interwebs that does something similar that you can modify, or you can try to do it on your own.

    It could be my method wouldn't work, but I see no reason why it wouldn't if I understand your question correctly (which I may not, not knowing what a "CollisionShape" is in the first place).

提交回复
热议问题