use of com.badlogic.gdx.graphics.g3d.ModelBatch 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.g3d.ModelBatch 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.g3d.ModelBatch 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.g3d.ModelBatch in project libgdx by libgdx.
the class FrameBufferCubemapTest method create.
@Override
public void create() {
super.create();
camFb = new PerspectiveCamera(90, 800, 800);
camFb.position.set(10f, 10f, 10f);
camFb.lookAt(0, 0, 0);
camFb.near = 0.1f;
camFb.far = 1000f;
camFb.update();
fb = new FrameBufferCubemap(Format.RGBA8888, 800, 800, true);
cubemap = fb.getColorBufferTexture();
ObjLoader objLoader = new ObjLoader();
cubeMesh = objLoader.loadModel(Gdx.files.internal("data/cube.obj"));
cubeInstance = new ModelInstance(cubeMesh);
cubeBatch = new ModelBatch(Gdx.files.internal("data/shaders/cubemap-vert.glsl"), Gdx.files.internal("data/shaders/cubemap-frag.glsl"));
cubeInstance.materials.get(0).set(new CubemapAttribute(CubemapAttribute.EnvironmentMap, cubemap));
camCube = new PerspectiveCamera(67, Gdx.graphics.getWidth() * 0.5f, Gdx.graphics.getHeight() * 0.5f);
camCube.position.set(0f, 2f, 2f);
camCube.lookAt(0, 0, 0);
camCube.near = 1f;
camCube.far = 300f;
camCube.update();
}
use of com.badlogic.gdx.graphics.g3d.ModelBatch in project libgdx by libgdx.
the class Basic3DTest method create.
@Override
public void create() {
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 = 1f;
cam.far = 30f;
cam.update();
ModelBuilder modelBuilder = new ModelBuilder();
model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position | Usage.Normal);
instance = new ModelInstance(model);
Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
}
Aggregations