Java 类com.badlogic.gdx.graphics.g3d.utils.FirstPersonCameraController 实例源码

项目:ForgE    文件:GameplayScreen.java   
@Override
protected void onInitialize() {
  Gdx.input.setCursorCatched(true);
  this.cameraController     = new FirstPersonCameraController(level.camera);
  level.camera.far          = FAR_CAMERA;
  level.camera.near         = NEAR_CAMERA;
  level.camera.fieldOfView  = 70;
  this.playerEntity       = ForgE.entities.get("player").build(level.entities);
  playerEntity.getComponent(PlayerComponent.class).camera = level.camera;
  level.terrainMap.localVoxelPositionToWorldPosition(teleport.voxelPosition, playerEntity.getComponent(PositionComponent.class).vector);
  playerEntity.getComponent(PositionComponent.class).vector.sub(-0.5f);
  level.entities.addEntity(playerEntity);

  Entity teapotEntity      = ForgE.entities.get("crate-p").build(level.entities);
  teapotEntity.getComponent(PositionComponent.class).vector.set(playerEntity.getComponent(PositionComponent.class).vector).add(0,1,-4);
  level.entities.addEntity(teapotEntity);

}
项目:libgdxcn    文件:VoxelTest.java   
@Override
public void create () {
    spriteBatch = new SpriteBatch();
    font = new BitmapFont();
    modelBatch = new ModelBatch();
    DefaultShader.defaultCullFace = GL20.GL_FRONT;
    camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.near = 0.5f;
    camera.far = 1000;
    controller = new FirstPersonCameraController(camera);
    Gdx.input.setInputProcessor(controller);

    lights = new Environment();
    lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
    lights.add(new DirectionalLight().set(1, 1, 1, 0, -1, 0));

    Texture texture = new Texture(Gdx.files.internal("data/g3d/tiles.png"));
    TextureRegion[][] tiles = TextureRegion.split(texture, 32, 32);

    MathUtils.random.setSeed(0);
    voxelWorld = new VoxelWorld(tiles[0], 20, 4, 20);
    PerlinNoiseGenerator.generateVoxels(voxelWorld, 0, 63, 10);
    float camX = voxelWorld.voxelsX / 2f;
    float camZ = voxelWorld.voxelsZ / 2f;
    float camY = voxelWorld.getHighest(camX, camZ) + 1.5f;
    camera.position.set(camX, camY, camZ);
}