use of com.badlogic.gdx.graphics.glutils.ShapeRenderer in project libgdx by libgdx.
the class TiledMapLayerOffsetTest method create.
@Override
public void create() {
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
camera = new OrthographicCamera();
camera.setToOrtho(false, (w / h) * 10, 10);
camera.zoom = 2;
camera.update();
cameraController = new OrthoCamController(camera);
Gdx.input.setInputProcessor(cameraController);
font = new BitmapFont();
batch = new SpriteBatch();
shapeRenderer = new ShapeRenderer();
assetManager = new AssetManager();
assetManager.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver()));
assetManager.load(MAP_ORTHO, TiledMap.class);
assetManager.load(MAP_ISO, TiledMap.class);
assetManager.load(MAP_ISO_STAG, TiledMap.class);
assetManager.load(MAP_HEX_X, TiledMap.class);
assetManager.load(MAP_HEX_Y, TiledMap.class);
assetManager.finishLoading();
map = assetManager.get(MAP_ORTHO);
renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f);
}
use of com.badlogic.gdx.graphics.glutils.ShapeRenderer in project libgdx by libgdx.
the class TextureAtlasTest method create.
public void create() {
batch = new SpriteBatch();
renderer = new ShapeRenderer();
atlas = new TextureAtlas(Gdx.files.internal("data/pack"));
jumpAtlas = new TextureAtlas(Gdx.files.internal("data/jump.txt"));
jumpAnimation = new Animation(0.25f, jumpAtlas.findRegions("ALIEN_JUMP_"));
badlogic = atlas.createSprite("badlogicslice");
badlogic.setPosition(50, 50);
// badlogicSmall = atlas.createSprite("badlogicsmall");
badlogicSmall = atlas.createSprite("badlogicsmall-rotated");
badlogicSmall.setPosition(10, 10);
AtlasRegion region = atlas.findRegion("badlogicsmall");
System.out.println("badlogicSmall original size: " + region.originalWidth + ", " + region.originalHeight);
System.out.println("badlogicSmall packed size: " + region.packedWidth + ", " + region.packedHeight);
star = atlas.createSprite("particle-star");
star.setPosition(10, 70);
font = new BitmapFont(Gdx.files.internal("data/font.fnt"), atlas.findRegion("font"), false);
Gdx.gl.glClearColor(0, 1, 0, 1);
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean keyUp(int keycode) {
if (keycode == Keys.UP) {
badlogicSmall.flip(false, true);
} else if (keycode == Keys.RIGHT) {
badlogicSmall.flip(true, false);
} else if (keycode == Keys.LEFT) {
badlogicSmall.setSize(512, 512);
} else if (keycode == Keys.DOWN) {
badlogicSmall.rotate90(true);
}
return super.keyUp(keycode);
}
});
}
use of com.badlogic.gdx.graphics.glutils.ShapeRenderer 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.glutils.ShapeRenderer in project libgdx by libgdx.
the class TriangleRaycastTest method create.
@Override
public void create() {
super.create();
instructions = "Tap a triangle to ray cast\nLong press to toggle debug mode\nSwipe for next test\nCtrl+drag to rotate\nScroll to zoom";
shapeRenderer = new ShapeRenderer();
model = objLoader.loadModel(Gdx.files.internal("data/scene.obj"));
model.materials.get(0).clear();
model.materials.get(0).set(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE));
// Only indexed BvhTriangleMeshShape can be used for triangle picking.
btTriangleIndexVertexArray vertexArray = new btTriangleIndexVertexArray(model.meshParts);
triangleShape = new btBvhTriangleMeshShape(vertexArray, true);
triangleRaycastCallback = new MyTriangleRaycastCallback(Vector3.Zero, Vector3.Zero);
// Ignore intersection with mesh backfaces.
triangleRaycastCallback.setFlags(EFlags.kF_FilterBackfaces);
world.addConstructor("scene", new BulletConstructor(model, 0, triangleShape));
world.add("scene", 0, 0, 0);
disposables.add(model);
disposables.add(triangleRaycastCallback);
disposables.add(triangleShape);
disposables.add(vertexArray);
disposables.add(shapeRenderer);
}
use of com.badlogic.gdx.graphics.glutils.ShapeRenderer in project libgdx by libgdx.
the class FreeTypeIncrementalTest method create.
public void create() {
batch = new SpriteBatch();
shapes = new ShapeRenderer();
shapes.setColor(Color.RED);
FreeTypeFontGenerator.setMaxTextureSize(128);
generator = new FreeTypeFontGenerator(Gdx.files.internal("data/arial.ttf"));
FreeTypeFontParameter param = new FreeTypeFontParameter();
param.incremental = true;
param.size = 24;
param.characters = "howdY ";
FreeTypeBitmapFontData data = new FreeTypeBitmapFontData() {
public int getWrapIndex(Array<Glyph> glyphs, int start) {
return SimplifiedChinese.getWrapIndex(glyphs, start);
}
};
// By default latin chars are used for x and cap height, causing some fonts to display non-latin chars out of bounds.
data.xChars = new char[] { '动' };
data.capChars = new char[] { '动' };
font = generator.generateFont(param, data);
}
Aggregations