Search in sources :

Example 1 with ObjLoader

use of com.badlogic.gdx.graphics.g3d.loader.ObjLoader 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();
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ShaderProgram(com.badlogic.gdx.graphics.glutils.ShaderProgram) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) ObjLoader(com.badlogic.gdx.graphics.g3d.loader.ObjLoader) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) FrameBuffer(com.badlogic.gdx.graphics.glutils.FrameBuffer) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) FPSLogger(com.badlogic.gdx.graphics.FPSLogger)

Example 2 with ObjLoader

use of com.badlogic.gdx.graphics.g3d.loader.ObjLoader 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();
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) CubemapAttribute(com.badlogic.gdx.graphics.g3d.attributes.CubemapAttribute) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) ObjLoader(com.badlogic.gdx.graphics.g3d.loader.ObjLoader) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) FrameBufferCubemap(com.badlogic.gdx.graphics.glutils.FrameBufferCubemap)

Example 3 with ObjLoader

use of com.badlogic.gdx.graphics.g3d.loader.ObjLoader in project libgdx by libgdx.

the class ProjectTest method create.

@Override
public void create() {
    ObjLoader objLoader = new ObjLoader();
    sphere = objLoader.loadModel(Gdx.files.internal("data/sphere.obj"));
    sphere.materials.get(0).set(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE));
    cam = new PerspectiveCamera(45, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.far = 200;
    Random rand = new Random();
    for (int i = 0; i < instances.length; i++) {
        instances[i] = new ModelInstance(sphere, rand.nextFloat() * 100 - rand.nextFloat() * 100, rand.nextFloat() * 100 - rand.nextFloat() * 100, rand.nextFloat() * -100 - 3);
    }
    batch = new SpriteBatch();
    font = new BitmapFont();
    logo = new TextureRegion(new Texture(Gdx.files.internal("data/badlogicsmall.jpg")));
    modelBatch = new ModelBatch();
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Random(java.util.Random) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) ObjLoader(com.badlogic.gdx.graphics.g3d.loader.ObjLoader) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) ColorAttribute(com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture)

Example 4 with ObjLoader

use of com.badlogic.gdx.graphics.g3d.loader.ObjLoader in project libgdx by libgdx.

the class FramebufferToTextureTest method create.

@Override
public void create() {
    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), true);
    texture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
    ObjLoader objLoader = new ObjLoader();
    mesh = objLoader.loadModel(Gdx.files.internal("data/cube.obj"));
    mesh.materials.get(0).set(new TextureAttribute(TextureAttribute.Diffuse, texture));
    modelInstance = new ModelInstance(mesh);
    modelBatch = new ModelBatch();
    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(3, 3, 3);
    cam.direction.set(-1, -1, -1);
    batch = new SpriteBatch();
    font = new BitmapFont();
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) ObjLoader(com.badlogic.gdx.graphics.g3d.loader.ObjLoader) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) Texture(com.badlogic.gdx.graphics.Texture) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) TextureAttribute(com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute)

Aggregations

PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)4 ModelBatch (com.badlogic.gdx.graphics.g3d.ModelBatch)4 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)4 ObjLoader (com.badlogic.gdx.graphics.g3d.loader.ObjLoader)4 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)3 Texture (com.badlogic.gdx.graphics.Texture)2 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)2 FPSLogger (com.badlogic.gdx.graphics.FPSLogger)1 ColorAttribute (com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)1 CubemapAttribute (com.badlogic.gdx.graphics.g3d.attributes.CubemapAttribute)1 TextureAttribute (com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute)1 FrameBuffer (com.badlogic.gdx.graphics.glutils.FrameBuffer)1 FrameBufferCubemap (com.badlogic.gdx.graphics.glutils.FrameBufferCubemap)1 ShaderProgram (com.badlogic.gdx.graphics.glutils.ShaderProgram)1 Random (java.util.Random)1