================ Continue from previous chapter ====================
If you don't have enough knowledge, read xoppa's blog too.
https://xoppa.github.io/blog/using-the-libgdx-3d-physics-bullet-wrapper-part1/
Using the libGDX 3D physics Bullet wrapper - part1 | blog.xoppa.com
Many 3D games require some sort of collision detection between 3D objects. Sometimes it's possible to do this with some basic math and bounding boxes and...
xoppa.github.io
Now let's handle the crash event.


Override and add ContactListener as follows:

And set the userValue of the cube and sphere as follows: You can then identify the object by this userValue in the contact listener above.
Let's print

userValue is printed.
Add an IntMap to get the PrimitiveModel that the userValue points to. IntMap is a Map whose key is integer and has Object.


In the event of a collision, we will change the color of the sphere and print the collision position.

Output screen

Finally, dispose.

1. Dispose the PrimitiveModel. In the previous post, the shapes of the PrimitiveModel were called links to each collsion fragment model used to create a rigid body. Dispose at this time. Dispose the collsion body and finally dispose your model.
2. modelInstance simply disposes the model.
3. Dispose the wset and contactListener.
'LibGdx' 카테고리의 다른 글
libgdx - Convert c ++ bullet file to libgdx file - 2( terrainDemo ) (0) | 2019.12.17 |
---|---|
libgdx - Convert c ++ bullet file to libgdx file - 1( terrainDemo ) (0) | 2019.12.14 |
libgdx-collision handling 2 (collision, bullet engine) (0) | 2019.11.18 |
libgdx-collision handling (collision, bullet engine) (0) | 2019.11.18 |
libgdx-loading page implementation 5 (1) | 2019.11.17 |
댓글