본문 바로가기
LibGdx

libgdx-collision handling 3 (collision, bullet engine)

by ses jeon 2019. 11. 18.

================ 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

core.zip
0.01MB

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.

 

 

 

 

 

댓글