use of com.badlogic.gdx.graphics.g3d.Model in project libgdx by libgdx.
the class GimpactTest method create.
@Override
public void create() {
super.create();
final Model chassisModel = objLoader.loadModel(Gdx.files.internal("data/car.obj"));
disposables.add(chassisModel);
chassisModel.materials.get(0).clear();
chassisModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.RED), ColorAttribute.createSpecular(Color.WHITE));
chassisVertexArray = new btTriangleIndexVertexArray(chassisModel.meshParts);
btGImpactMeshShape chassisShape = new btGImpactMeshShape(chassisVertexArray);
chassisShape.setLocalScaling(new Vector3(1f, 1f, 1f));
chassisShape.setMargin(0f);
chassisShape.updateBound();
world.addConstructor("chassis", new BulletConstructor(chassisModel, 1f, chassisShape));
(ground = world.add("ground", 0f, 0f, 0f)).setColor(0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 1f);
for (float y = 10f; y < 50f; y += 5f) world.add("chassis", -2f + (float) Math.random() * 4f, y, -2f + (float) Math.random() * 4f).setColor(0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 1f);
btGImpactCollisionAlgorithm.registerAlgorithm(world.dispatcher);
}
use of com.badlogic.gdx.graphics.g3d.Model in project libgdx by libgdx.
the class MeshShapeTest method create.
@Override
public void create() {
super.create();
final Model sphereModel = modelBuilder.createSphere(0.5f, 0.5f, 0.5f, 8, 8, new Material(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE)), Usage.Position | Usage.Normal);
disposables.add(sphereModel);
final BulletConstructor sphereConstructor = new BulletConstructor(sphereModel, 0.25f, new btSphereShape(0.25f));
sphereConstructor.bodyInfo.setRestitution(1f);
world.addConstructor("sphere", sphereConstructor);
final Model sceneModel = objLoader.loadModel(Gdx.files.internal("data/scene.obj"));
disposables.add(sceneModel);
final BulletConstructor sceneConstructor = new BulletConstructor(sceneModel, 0f, new btBvhTriangleMeshShape(sceneModel.meshParts));
sceneConstructor.bodyInfo.setRestitution(0.25f);
world.addConstructor("scene", sceneConstructor);
world.add("scene", (new Matrix4()).setToTranslation(0f, 2f, 0f).rotate(Vector3.Y, -90)).setColor(0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 1f);
world.add("ground", 0f, 0f, 0f).setColor(0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 1f);
for (float x = -3; x < 7; x++) {
for (float z = -5; z < 5; z++) {
world.add("sphere", x, 10f + (float) Math.random() * 0.1f, z).setColor(0.5f + 0.5f * (float) Math.random(), 0.5f + 0.5f * (float) Math.random(), 0.5f + 0.5f * (float) Math.random(), 1f);
}
}
}
use of com.badlogic.gdx.graphics.g3d.Model in project libgdx by libgdx.
the class ConvexHullDistanceTest method create.
@Override
public void create() {
super.create();
final Model carModel = objLoader.loadModel(Gdx.files.internal("data/car.obj"));
disposables.add(carModel);
carModel.materials.get(0).clear();
carModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE));
world.addConstructor("car", new BulletConstructor(carModel, 5f, createConvexHullShape(carModel, true)));
// Create the entities
world.add("ground", 0f, 0f, 0f).setColor(0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 1f);
for (float y = 10f; y < 50f; y += 5f) world.add("car", -2f + (float) Math.random() * 4f, y, -2f + (float) Math.random() * 4f).setColor(0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 1f);
distance = new ConvexHullDistance();
shapeRenderer = new ShapeRenderer();
}
use of com.badlogic.gdx.graphics.g3d.Model in project libgdx by libgdx.
the class ConvexHullTest method create.
@Override
public void create() {
super.create();
final Model carModel = objLoader.loadModel(Gdx.files.internal("data/car.obj"));
disposables.add(carModel);
carModel.materials.get(0).clear();
carModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE));
world.addConstructor("car", new BulletConstructor(carModel, 5f, createConvexHullShape(carModel, true)));
// Create the entities
world.add("ground", 0f, 0f, 0f).setColor(0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 1f);
for (float y = 10f; y < 50f; y += 5f) world.add("car", -2f + (float) Math.random() * 4f, y, -2f + (float) Math.random() * 4f).setColor(0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 1f);
}
use of com.badlogic.gdx.graphics.g3d.Model in project libgdx by libgdx.
the class FrustumCullingTest method create.
@Override
public void create() {
super.create();
instructions = "Tap to toggle view\nLong press to toggle debug mode\nSwipe for next test\nCtrl+drag to rotate\nScroll to zoom";
tempManifoldArr = new btPersistentManifoldArray();
world.addConstructor("collisionBox", new BulletConstructor(world.getConstructor("box").model));
// Create the entities
final float dX = BOX_X_MAX - BOX_X_MIN;
final float dY = BOX_Y_MAX - BOX_Y_MIN;
final float dZ = BOX_Z_MAX - BOX_Z_MIN;
for (int i = 0; i < BOXCOUNT; i++) world.add("collisionBox", BOX_X_MIN + dX * (float) Math.random(), BOX_Y_MIN + dY * (float) Math.random(), BOX_Z_MIN + dZ * (float) Math.random()).setColor(Color.GRAY);
frustumCam = new PerspectiveCamera(camera.fieldOfView, camera.viewportWidth, camera.viewportHeight);
frustumCam.far = Vector3.len(BOX_X_MAX, BOX_Y_MAX, BOX_Z_MAX);
frustumCam.update();
overviewCam = camera;
overviewCam.position.set(BOX_X_MAX, BOX_Y_MAX, BOX_Z_MAX);
overviewCam.lookAt(Vector3.Zero);
overviewCam.far = 150f;
overviewCam.update();
final Model frustumModel = createFrustumModel(frustumCam.frustum.planePoints);
disposables.add(frustumModel);
frustumObject = createFrustumObject(frustumCam.frustum.planePoints);
world.add(frustumEntity = new BulletEntity(frustumModel, frustumObject, 0, 0, 0));
frustumEntity.setColor(Color.BLUE);
}
Aggregations