Adding some rigid bodies
Now, we will create individual bodies and set their properties and put them into our dynamics world, as follows:
modelbuilder.begin(); MeshPartBuilder mpb = modelbuilder.part("parts", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.Color, new Material(ColorAttribute.createDiffuse(Color.WHITE))); mpb.setColor(1f, 1f, 1f, 1f); mpb.box(0, 0, 0, 40, 1, 40); Model model = modelbuilder.end(); groundInstance = new ModelInstance(model); btCollisionShape groundshape = new btBoxShape(new Vector3(20, 1 / 2f, 20)); btRigidBodyConstructionInfo bodyInfo = new btRigidBodyConstructionInfo(0, null, groundshape, Vector3.Zero); btRigidBody body = new btRigidBody(bodyInfo); world.addRigidBody(body);
The preceding steps are to create ...
Get Learning LibGDX Game Development - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.