use of com.badlogic.gdx.graphics.g3d.ModelBatch in project libgdx by libgdx.
the class FogTest method create.
@Override
public void create() {
modelBatch = new ModelBatch();
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
environment.set(new ColorAttribute(ColorAttribute.Fog, 0.13f, 0.13f, 0.13f, 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(30f, 10f, 30f);
cam.lookAt(0, 0, 0);
cam.near = 0.1f;
cam.far = 45f;
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)));
}
use of com.badlogic.gdx.graphics.g3d.ModelBatch in project libgdx by libgdx.
the class MaterialTest method create.
@Override
public void create() {
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), true);
// Create material attributes. Each material can contain x-number of attributes.
textureAttribute = new TextureAttribute(TextureAttribute.Diffuse, texture);
colorAttribute = new ColorAttribute(ColorAttribute.Diffuse, Color.ORANGE);
blendingAttribute = new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
ModelBuilder builder = new ModelBuilder();
model = builder.createBox(1, 1, 1, new Material(), Usage.Position | Usage.Normal | Usage.TextureCoordinates);
model.manageDisposable(texture);
modelInstance = new ModelInstance(model);
modelInstance.transform.rotate(Vector3.X, 45);
material = modelInstance.materials.get(0);
builder.begin();
MeshPartBuilder mpb = builder.part("back", GL20.GL_TRIANGLES, Usage.Position | Usage.TextureCoordinates, new Material(textureAttribute));
mpb.rect(-2, -2, -2, 2, -2, -2, 2, 2, -2, -2, 2, -2, 0, 0, 1);
backModel = builder.end();
background = new ModelInstance(backModel);
modelBatch = new ModelBatch();
camera = new PerspectiveCamera(45, 4, 4);
camera.position.set(0, 0, 3);
camera.direction.set(0, 0, -1);
camera.update();
Gdx.input.setInputProcessor(this);
}
use of com.badlogic.gdx.graphics.g3d.ModelBatch in project libgdx by libgdx.
the class ModelLoaderTest method create.
@Override
public void create() {
camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.position.set(0, 0, 5);
camera.near = 1;
camera.far = 100;
camera.update();
assets = new AssetManager();
assets.load("data/g3d/cube.g3dj", Model.class);
spriteBatch = new SpriteBatch();
modelBatch = new ModelBatch();
// assets.getLogger().setLevel(Logger.DEBUG);
}
use of com.badlogic.gdx.graphics.g3d.ModelBatch in project nhglib by VoidZombie.
the class GraphicsSystem method end.
@Override
protected void end() {
super.end();
for (int i = 0; i < cameras.size; i++) {
Camera camera = cameras.get(i);
ModelBatch modelBatch = modelBatches.get(i);
ModelCache dynamicCache = dynamicCaches.get(i);
ModelCache staticCache = staticCaches.get(i);
dynamicCache.end();
GLUtils.clearScreen(clearColor);
modelBatch.begin(camera);
modelBatch.render(staticCache, environment);
modelBatch.render(dynamicCache, environment);
modelBatch.end();
if (Nhg.debugDrawPhysics && debugDrawer != null) {
debugDrawer.begin(camera);
physicsSystem.debugDraw();
debugDrawer.end();
}
}
}
Aggregations