Java Code Examples for com.badlogic.gdx.graphics.PerspectiveCamera#lookAt()

The following examples show how to use com.badlogic.gdx.graphics.PerspectiveCamera#lookAt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GameWorldRenderer.java    From uracer-kotd with Apache License 2.0 6 votes vote down vote up
private void createCams () {
	int refW = Config.Graphics.ReferenceScreenWidth;
	int refH = Config.Graphics.ReferenceScreenHeight;

	camOrtho = new OrthographicCamera(refW, refH);
	halfViewport.set(camOrtho.viewportWidth / 2, camOrtho.viewportHeight / 2);

	// creates and setup orthographic camera
	camTilemap = new OrthographicCamera(refW, refH);
	camTilemap.zoom = 1;

	// creates and setup perspective camera
	// strategically choosen near/far planes, Blender models' 14.2 meters <=> one 256px tile
	// with far plane @48
	camPersp = new PerspectiveCamera(47.27123f, refW, refH);
	camPersp.near = CamPerspPlaneNear;
	camPersp.far = CamPerspPlaneFar;
	camPersp.lookAt(0, 0, -1);
	camPersp.position.set(camTilemap.position.x, camTilemap.position.y, CamPerspElevation);
	camPersp.update();

	camController = new CameraController(Config.Graphics.CameraInterpolationMode, halfViewport, world.worldSizePx,
		world.worldSizeTiles);
}
 
Example 2
Source File: Renderer.java    From VuforiaLibGDX with MIT License 6 votes vote down vote up
public Renderer() {

        lights = new Environment();
        lights.set(new ColorAttribute(ColorAttribute.AmbientLight, Color.WHITE));

        camera = new PerspectiveCamera(60, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        camera.near = 1.0F;
        camera.far = 1000.0F;
        //set camera into "Vuforia - style" direction
        camera.position.set(new Vector3(0,0,0));
        camera.lookAt(new Vector3(0,0,1));

        IntBuffer buffer = BufferUtils.newIntBuffer(16);
        Gdx.gl.glGetIntegerv(GL20.GL_MAX_TEXTURE_IMAGE_UNITS, buffer);
        int units = buffer.get(0);
        Log.d("TAG", "Max texture units: "+units);
        modelBatch = new ModelBatch(new RenderContext(new DefaultTextureBinder(DefaultTextureBinder.WEIGHTED, 0)));
    }
 
Example 3
Source File: RadixClient.java    From Radix with MIT License 6 votes vote down vote up
private void setupOGL() {
    camera = new PerspectiveCamera(90, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.position.set(10f, 150f, 10f);
    camera.lookAt(0, 0, 0);
    camera.near = 0.1f;
    camera.far = 450f;
    camera.update();
    hudCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    guiBatch = new SpriteBatch();
    guiBatch.setProjectionMatrix(hudCamera.combined);

    if(android) {
        setupTouchControls();
    }

    Gdx.input.setInputProcessor(new RadixInputHandler(this));

    if(settingsManager.getVisualSettings().getNonContinuous().getValue()) {
        Gdx.graphics.setContinuousRendering(false);
    }

    sceneTheme = new SceneTheme();
    sceneTheme.init();
}
 
Example 4
Source File: Scene.java    From Mundus with Apache License 2.0 6 votes vote down vote up
public Scene() {
    environment = new MundusEnvironment();
    currentSelection = null;
    terrains = new Array<TerrainAsset>();

    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(0, 1, -3);
    cam.lookAt(0, 1, -1);
    cam.near = 0.2f;
    cam.far = 10000;

    DirectionalLight dirLight = new DirectionalLight();
    dirLight.color.set(1, 1, 1, 1);
    dirLight.intensity = 1f;
    dirLight.direction.set(0, -1f, 0);
    dirLight.direction.nor();
    environment.add(dirLight);
    environment.getAmbientLight().intensity = 0.3f;

    sceneGraph = new SceneGraph(this);
}
 
Example 5
Source File: WorldGenerator.java    From Skyland with MIT License 5 votes vote down vote up
public static PerspectiveCamera generatePerspectiveCamera(float near, float far, Vector3 position, Vector3 lookat) {
    PerspectiveCamera camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.position.set(position);
    camera.lookAt(lookat);
    camera.near = near;
    camera.far = far;
    camera.update();
    return camera;
}
 
Example 6
Source File: FluidSimulatorGeneric.java    From fluid-simulator-v2 with Apache License 2.0 5 votes vote down vote up
public FluidSimulatorGeneric(FluidSimulatorStarter fluidSimulatorStarter) {
		this.game = fluidSimulatorStarter;
		// LibGDX single batches cannot have a size more than 5460
		batch = new SpriteBatch(IS_DESKTOP ? 5460 : ANDROID_SIZE);
		font = new BitmapFont();
		camera = new OrthographicCamera(WORLD_WIDTH, WORLD_HEIGHT);
		camera.position.set(0, (WORLD_HEIGHT / 2) - 1, 0);
		immediateRenderer = new ImmediateModeRenderer20(SIZE*6, false, true, 0);
		irt = new Renderer20(SIZE*6, false, true, 1);
		irt2 = new ImmediateModeRenderer20(SIZE*11, false, true, 1);
		shapeRenderer = new ShapeRenderer(SIZE);
		renderer = new Box2DDebugRenderer(true, true, false, true, false, false);
		
		//3D
		camera3D = new PerspectiveCamera(67, WORLD_WIDTH, WORLD_HEIGHT);
		camera3D.position.set(0, 130f, 250f);
		camera3D.lookAt(0,150f,0);
		camera3D.near = 0.1f;
		camera3D.far = 500f;
		camera3D.update();
		ModelBuilder modelBuilder = new ModelBuilder();
//        model = modelBuilder.createSphere(5f, 5f, 5f, 4, 4, GL10.GL_TRIANGLES,
//                new Material(ColorAttribute.createDiffuse(Color.GREEN)),
//                Usage.Position | Usage.Normal);
        model = modelBuilder.createBox(5f, 5f, 5f,
            new Material(ColorAttribute.createDiffuse(Color.GREEN)),
            Usage.Position | Usage.Normal);
        instance = new ModelInstance(model);
        modelBatch = new ModelBatch();
        environment = new Environment();
        environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
        environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, 0, -0.8f, -0.2f));
        camController = new Camera3DController(camera3D);
        camController.setFluidSimulator(this);
		
		world = new World(new Vector2(0, -9.8f), false);
		world.setContactListener(this);
	}