use of com.badlogic.gdx.graphics.PerspectiveCamera in project libgdx by libgdx.
the class EdgeDetectionTest method create.
public void create() {
ShaderProgram.pedantic = false;
/*
* shader = new ShaderProgram(Gdx.files.internal("data/shaders/default.vert").readString(), Gdx.files.internal(
* "data/shaders/depthtocolor.frag").readString()); if (!shader.isCompiled()) { Gdx.app.log("EdgeDetectionTest",
* "couldn't compile scene shader: " + shader.getLog()); }
*/
batchShader = new ShaderProgram(Gdx.files.internal("data/shaders/batch.vert").readString(), Gdx.files.internal("data/shaders/convolution.frag").readString());
if (!batchShader.isCompiled()) {
Gdx.app.log("EdgeDetectionTest", "couldn't compile post-processing shader: " + batchShader.getLog());
}
ObjLoader objLoader = new ObjLoader();
scene = objLoader.loadModel(Gdx.files.internal("data/scene.obj"));
sceneInstance = new ModelInstance(scene);
modelBatch = new ModelBatch();
fbo = new FrameBuffer(Format.RGB565, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(0, 0, 10);
cam.lookAt(0, 0, 0);
cam.far = 30;
batch = new SpriteBatch();
batch.setShader(batchShader);
fboRegion = new TextureRegion(fbo.getColorBufferTexture());
fboRegion.flip(false, true);
logger = new FPSLogger();
calculateOffsets();
}
use of com.badlogic.gdx.graphics.PerspectiveCamera in project libgdx by libgdx.
the class BaseBulletTest method create.
@Override
public void create() {
init();
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.3f, 0.3f, 0.3f, 1.f));
light = shadows ? new DirectionalShadowLight(1024, 1024, 20f, 20f, 1f, 300f) : new DirectionalLight();
light.set(0.8f, 0.8f, 0.8f, -0.5f, -1f, 0.7f);
environment.add(light);
if (shadows)
environment.shadowMap = (DirectionalShadowLight) light;
shadowBatch = new ModelBatch(new DepthShaderProvider());
modelBatch = new ModelBatch();
world = createWorld();
world.performanceCounter = performanceCounter;
final float width = Gdx.graphics.getWidth();
final float height = Gdx.graphics.getHeight();
if (width > height)
camera = new PerspectiveCamera(67f, 3f * width / height, 3f);
else
camera = new PerspectiveCamera(67f, 3f, 3f * height / width);
camera.position.set(10f, 10f, 10f);
camera.lookAt(0, 0, 0);
camera.update();
// Create some simple models
final Model groundModel = modelBuilder.createRect(20f, 0f, -20f, -20f, 0f, -20f, -20f, 0f, 20f, 20f, 0f, 20f, 0, 1, 0, new Material(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE), FloatAttribute.createShininess(16f)), Usage.Position | Usage.Normal);
disposables.add(groundModel);
final Model boxModel = modelBuilder.createBox(1f, 1f, 1f, new Material(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE), FloatAttribute.createShininess(64f)), Usage.Position | Usage.Normal);
disposables.add(boxModel);
// Add the constructors
// mass = 0: static body
world.addConstructor("ground", new BulletConstructor(groundModel, 0f));
// mass = 1kg: dynamic body
world.addConstructor("box", new BulletConstructor(boxModel, 1f));
// mass = 0: static body
world.addConstructor("staticbox", new BulletConstructor(boxModel, 0f));
}
use of com.badlogic.gdx.graphics.PerspectiveCamera 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);
}
use of com.badlogic.gdx.graphics.PerspectiveCamera in project libgdx by libgdx.
the class TextureRegion3DTest method create.
@Override
public void create() {
Gdx.gl.glClearColor(0.2f, 0.3f, 1.0f, 0.f);
atlas = new TextureAtlas(Gdx.files.internal("data/testpack"));
regions = atlas.getRegions();
modelBatch = new ModelBatch(new DefaultShaderProvider());
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .4f, .4f, .4f, 1f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(10f, 10f, 10f);
cam.lookAt(0, 0, 0);
cam.near = 0.1f;
cam.far = 300f;
cam.update();
ModelBuilder modelBuilder = new ModelBuilder();
final Material material = new Material(ColorAttribute.createDiffuse(1f, 1f, 1f, 1f), new TextureAttribute(TextureAttribute.Diffuse));
model = modelBuilder.createBox(5f, 5f, 5f, material, Usage.Position | Usage.Normal | Usage.TextureCoordinates);
instance = new ModelInstance(model);
attribute = instance.materials.get(0).get(TextureAttribute.class, TextureAttribute.Diffuse);
Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
}
use of com.badlogic.gdx.graphics.PerspectiveCamera in project libgdx by libgdx.
the class PairCacheTest 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";
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(0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 0.25f + 0.5f * (float) Math.random(), 1f);
manifoldArray = new btPersistentManifoldArray();
disposables.add(manifoldArray);
overviewCam = camera;
overviewCam.position.set(BOX_X_MAX, BOX_Y_MAX, BOX_Z_MAX);
overviewCam.lookAt(Vector3.Zero);
overviewCam.far = 150f;
overviewCam.update();
frustumCam = new PerspectiveCamera(camera.fieldOfView, camera.viewportWidth, camera.viewportHeight);
frustumCam.far = Vector3.len(BOX_X_MAX, BOX_Y_MAX, BOX_Z_MAX);
frustumCam.update();
final Model ghostModel = FrustumCullingTest.createFrustumModel(frustumCam.frustum.planePoints);
disposables.add(ghostModel);
// The ghost object does not need to be shaped as a camera frustum, it can have any collision shape.
ghostObject = FrustumCullingTest.createFrustumObject(frustumCam.frustum.planePoints);
disposables.add(ghostObject);
world.add(ghostEntity = new BulletEntity(ghostModel, ghostObject, 0, 0, 0));
disposables.add(ghostEntity);
shapeRenderer = new ShapeRenderer();
disposables.add(shapeRenderer);
}
Aggregations