Java 类com.badlogic.gdx.graphics.PerspectiveCamera 实例源码

项目:StreetCampusFighter    文件:GameScreen.java   
public GameScreen(){
    spriteBatch = new SpriteBatch(); // buffer ok
    texture     = new Texture(Gdx.files.internal("bg/gameBG.jpg"));
    viewMatrix  = new Matrix4();  // matriz de visualização
    tranMatrix  = new Matrix4();  // matriz de escala

    // camera
    camera = new PerspectiveCamera(67.0f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.near = 0.1f;
    camera.far  = 1000f;
    camera.position.set(0, 5, 10);
    camera.lookAt(0, 5, 0);
    camera.update();

    // ambiente
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1,1,1,1));

    // renderizador
    modelBatch = new ModelBatch();
    p1 = new Player(1);
    p2 = new Player(2);



}
项目:Tower-Defense-Galaxy    文件:VRCamera.java   
public VRCamera(int width, int height, int viewportWidth, int viewportHeight) {
    leftCamera = new PerspectiveCamera(90, viewportWidth, viewportHeight);
    rightCamera = new PerspectiveCamera(90, viewportWidth, viewportHeight);
    leftBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, width, height, true);
    rightBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, width, height, true);
    leftTexture = new TextureRegion();
    rightTexture = new TextureRegion();
    batch = new SpriteBatch();
    this.width = width;
    this.height = height;
    this.viewportWidth = viewportWidth;
    this.viewportHeight = viewportHeight;
    tmpVector3 = new Vector3();
    position = new Vector3(250, 20, 250);
    positionLeft = new Vector3(249.5f, 20, 250);
    positionRight = new Vector3(250.5f, 20, 250);
    direction = new Vector3();
    up = new Vector3(0, 1, 0);
    eyeDistance = 0.5f;
}
项目:enklave    文件:ScreenBricks.java   
@Override
public void show() {
    stage = new Stage(new StretchViewport(Width,Height));
    stage.addActor(tabContinue);
    PerspectiveCamera camera2 = new PerspectiveCamera(40, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera2.position.set(0, -Width * 0.075f, Width * 0.135f);
    camera2.lookAt(0, 0, 0);
    camera2.far = Width*0.3f;
    camera2.near = 1;
    camera2.update();
    controller = new CameraInputController(camera2);
    CameraGroupStrategy cameraGroupStrategy = new CameraGroupStrategy(camera2);
    batch = new DecalBatch(cameraGroupStrategy);
    modelBatch = new ModelBatch();
    InputMultiplexer in = new InputMultiplexer();
    in.addProcessor(stage);
    in.addProcessor(controller);
    Gdx.input.setInputProcessor(in);
}
项目:enklave    文件:ScreenExtensions.java   
public ScreenExtensions(GameManager gameManager) {
    this.gameManager = gameManager;
    manager = ManagerAssets.getInstance();
    addExtensions = this;
    camera = new PerspectiveCamera(40, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.position.set(0, 0, Gdx.graphics.getHeight() * 0.183f);//initial 180
    camera.lookAt(0, 0, 0);
    camera.far = 2500;
    camera.near = 1;
    camera.update();
    controller = new CameraInputController(camera);
    cam = new OrthographicCamera();
    batchsprite = new SpriteBatch();

    renderer = new ImmediateModeRenderer20(false, true, 1);
    gd = new GestureDetector(this);
}
项目:enklave    文件:ScreenCombat.java   
public ScreenCombat(GameManager gameManager) {
    this.gameManager = gameManager;
    managerAssets = ManagerAssets.getInstance();
    cam = new OrthographicCamera();
    UpdateDisplayCombat.getInstance().setScreenCombat(this);
    camera = new PerspectiveCamera(40, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.position.set(0, 0, 350);//initial 180
    camera.lookAt(0, 0, 0);
    camera.far = 2500;
    camera.near = 1;
    camera.update();
    centerPlayer = new Integer[7];
    for(int i=0;i<7;i++){
        centerPlayer[i]=-1;
    }
}
项目:enklave    文件:ScreenCrafting.java   
public ScreenCrafting(GameManager game) {
    this.gameManager = game;
    informationProfile = InformationProfile.getInstance();
    managerAssets = ManagerAssets.getInstance();
    queue = QueueBuildCraft.getInstance();
    intances = new Array<ModelInstance>();
    camera = new PerspectiveCamera(45,WIDTH,HEIGHT);
    camera.position.set(0,0,1020);
    camera.lookAt(0, 0, 0);
    camera.near = 1;
    camera.far = 1500;
    camera.update();
    nameRes.add("SCRAP");
    nameRes.add("BRICK");
    nameRes.add("CELL");
    arrayDecal = new Array<Decal>();
}
项目:enklave    文件:Enklave3D.java   
public boolean touchEnklave(PerspectiveCamera camera,int screenX,int screenY){
        coordonate = null;
        instanceModel.calculateBoundingBox(box).mul(instanceModel.transform);
        box.getCenter(position);
        box.getDimensions(dimensions);
        Ray ray = camera.getPickRay(screenX,screenY);
//        instanceModel.transform.getTranslation(position);
//        position.add(box.getCenter(new Vector3()));
//        Gdx.app.log("res"+ray.toString(),"position"+position);
        if(Intersector.intersectRayBoundsFast(ray,box)){ // position, box.getDimensions(new Vector3()).len(), null)) {
            coordonate = new SpaceCoordonate();
            coordonate.x = Math.abs(Math.abs(position.x) - Math.abs(camera.position.x)) / (Gdx.graphics.getHeight() * 0.026f);
            coordonate.y = Math.abs(Math.abs(position.y) - Math.abs(camera.position.y)) / (Gdx.graphics.getHeight() * 0.026f);
            coordonate.z = -(Math.abs((Gdx.graphics.getHeight() * 0.033f) - Math.abs(camera.position.z)) / (Gdx.graphics.getHeight() * 0.026f));
            if (box.getCenterX() < camera.position.x) {
                coordonate.x = -coordonate.x;
            }
            if (box.getCenterY() < camera.position.y) {
                coordonate.y = -coordonate.y;
            }
            return true;
        }
        return false;
    }
项目:gdx-cclibs    文件:PerspectiveCameraSerializer.java   
@Override
public PerspectiveCamera read (Kryo kryo, Input input, Class<PerspectiveCamera> type) {
    PerspectiveCamera camera = new PerspectiveCamera();
    Vector3 position = kryo.readObject(input, Vector3.class);
    Vector3 direction = kryo.readObject(input, Vector3.class);
    Vector3 up = kryo.readObject(input, Vector3.class);
    camera.position.set(position);
    camera.direction.set(direction);
    camera.up.set(up);
    camera.near = input.readFloat();
    camera.far = input.readFloat();
    camera.viewportWidth = input.readFloat();
    camera.viewportHeight = input.readFloat();
    camera.fieldOfView = input.readFloat();
    camera.update();
    return camera;
}
项目:VuforiaLibGDX    文件:Renderer.java   
public Renderer(VuforiaRenderer arRenderer) {

        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));

        this.vuforiaRenderer = arRenderer;

        modelBatch = new ModelBatch();
    }
项目:GdxVR-Sample-1    文件:VRCamera.java   
/** Конструктор */
VRCamera(float fov, float parallax, float near, float far) {
    this.parallax = parallax;
    leftCam = new PerspectiveCamera(fov, Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight());
    leftCam.near = near;
    leftCam.far = far;
    leftCam.update();
    rightCam = new PerspectiveCamera(fov, Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight());
    rightCam.near = near;
    rightCam.far = far;
    rightCam.update();
    position = new Vector3(0, 0, 0);
    direction = new Vector3(0, 0, 1);
    up = new Vector3(0, 1, 0);
    upDirCross = new Vector3().set(direction).crs(up).nor();
}
项目:Chemtris    文件:BoxThree.java   
public BoxThree(PerspectiveCamera cam, boolean[][][] collision) {
    super(cam,collision);

    for(float x = 2f; x < 5f; ++x){
        for(float z = 2f; z < 5f; ++z){
            for(float y = 10f; y < 13f; ++y){
                ModelInstance p = new ModelInstance(white,x,y,z);
                ModelInstance s = new ModelInstance(gray,x,y,z);
                ModelInstance f = new ModelInstance(wire,x,y,z);

                parts.add(p);
                shadow.add(s);
                frame.add(f);
            }
        }
    }


    traceShadow();
}
项目:Chemtris    文件:GameModel.java   
public GameModel(PerspectiveCamera cam, boolean [][][] collision){
    //setup the model instances
    parts = new Array<ModelInstance>();
    frame = new Array<ModelInstance>();
    shadow = new Array<ModelInstance>();

    //setup environment
    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, -1f, -0.8f, -0.2f));

    //setup collision matrix
    matrix = collision;

    //setup camera
    camera = cam;



}
项目:Chemtris    文件:Column.java   
public Column(PerspectiveCamera cam, boolean[][][] collision) {
    super(cam, collision);
    x = X.FRONT;
    y = Y.UP;

    for(float y = 10f; y < 12f; ++y){
        ModelInstance p = new ModelInstance(white,2f,y,2f);
        ModelInstance s = new ModelInstance(gray,2f,y,2f);
        ModelInstance f = new ModelInstance(wire,2f,y,2f);

        parts.add(p);
        shadow.add(s);
        frame.add(f);
    }

    traceShadow();
}
项目:Chemtris    文件:BoxTwo.java   
public BoxTwo(PerspectiveCamera cam, boolean[][][] collision) {
    super(cam, collision);

    for(float x = 2f; x < 4f; ++x){
        for(float z = 2f; z < 4f; ++z){
            for(float y = 10f; y < 12f; ++y){
                ModelInstance p = new ModelInstance(white,x,y,z);
                ModelInstance s = new ModelInstance(gray,x,y,z);
                ModelInstance f = new ModelInstance(wire,x,y,z);

                parts.add(p);
                shadow.add(s);
                frame.add(f);
            }
        }
    }


    traceShadow();
}
项目:Chemtris    文件:ColumnTwo.java   
public ColumnTwo(PerspectiveCamera cam, boolean[][][] collision) {
    super(cam, collision);
    x = X.FRONT;
    y = Y.UP;

    for(float y = 10f; y < 13f; ++y){
        ModelInstance p = new ModelInstance(white,2f,y,2f);
        ModelInstance s = new ModelInstance(gray,2f,y,2f);
        ModelInstance f = new ModelInstance(wire,2f,y,2f);

        parts.add(p);
        shadow.add(s);
        frame.add(f);
    }

    traceShadow();
}
项目:neblina-libgdx3d    文件:Renderer.java   
public Renderer () {
    try {
        lights = new Environment();
        lights.add(new DirectionalLight().set(Color.WHITE, new Vector3(-1, -0.5f, 0).nor()));

        spriteBatch = new SpriteBatch();
        modelBatch = new ModelBatch();

        backgroundTexture = new Texture(Gdx.files.internal("data/planet.jpg"), Format.RGB565, true);
        backgroundTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);

        font = new BitmapFont(Gdx.files.internal("data/font10.fnt"), Gdx.files.internal("data/font10.png"), false);

        camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
项目:Radix    文件:RadixClient.java   
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();
}
项目:DigBlock    文件:Player.java   
public Player() {
    rotCount=0;
    jumpCount=0;
    tmp = new Vector3();
    tmp2 = new Vector3();
    out = new Vector3();
    rot = new Vector2();
    move = new Vector2();
    newBlk = new Int3();
    curBlk = new Int3();
    jump = false;
    jumpReady = false;
    falling = false;
    currentChunk = new Int3();
    cam = new PerspectiveCamera(75f, Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
    cam.position.set(0.5f, 35f, 0.5f);
    cam.direction.set(0f, 0f, 1f);
    cam.near = 0.1f;
}
项目:Mundus    文件:Scene.java   
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);
}
项目:vrmleditor    文件:Input.java   
@Override
public boolean scrolled(int amount) {
    int x = Gdx.input.getX();
    int y = Gdx.input.getY();

    // get camera and viewport
    int index = getCameraCode(x, y);
    Camera camera = renderer.getCamera(index);

    if (camera instanceof OrthographicCamera) {
        OrthographicCamera cam = (OrthographicCamera) camera;
        cam.zoom += ((float) amount / Constants.ZOOM_ORTHOGRAPHIC);
    } else if (camera instanceof PerspectiveCamera) {
        camera.position.sub(camera.direction.tmp().mul((float) amount / Constants.ZOOM_PERSPECTIVE));
    }

    return true;
}
项目:android-screen-recorder    文件:Renderer.java   
public Renderer () {
    try {
        lights = new Environment();
        lights.add(new DirectionalLight().set(Color.WHITE, new Vector3(-1, -0.5f, 0).nor()));

        spriteBatch = new SpriteBatch();
        modelBatch = new ModelBatch();

        backgroundTexture = new Texture(Gdx.files.internal("data/planet.jpg"), Format.RGB565, true);
        backgroundTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);

        font = new BitmapFont(Gdx.files.internal("data/font10.fnt"), Gdx.files.internal("data/font10.png"), false);

        camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
项目:ForgE    文件:BlockPreviews.java   
@Override
protected void onInitialize() {
  if (removeOld) {
    clearOld();
  }

  ForgE.blocks.loadAtlasAndUvsIfNull();
  this.levelEnv            = new LevelEnv();
  this.shader              = (TerrainShader)ForgE.shaders.get("block-preview");

  this.renderContext       = new RenderContext(new DefaultTextureBinder(DefaultTextureBinder.WEIGHTED, 1));
  this.camera              = new PerspectiveCamera(40, PREVIEW_SIZE/2, PREVIEW_SIZE/2);
  //this.buffer              = new FrameBuffer(Pixmap.Format.RGBA8888, PREVIEW_SIZE, PREVIEW_SIZE, true);
  camera.near = 0.01f;
  camera.far  = 5f;
  camera.position.set(0f, 2.5f, 0f);
  camera.lookAt(new Vector3(0.2f,2.35f,0.2f));
  camera.update();

  this.blocks = ForgE.blocks.list();
  this.i      = 1;
}
项目:ForgE    文件:FrustrumDebugAndRenderer.java   
public void render(PerspectiveCamera camera) {
  if (!isEnabled()) {
    return;
  }
  renderer.setProjectionMatrix(camera.combined);
  renderer.begin(ShapeRenderer.ShapeType.Line); {
    renderer.setColor(Color.WHITE);

    for (ICamera frustrumCamera : cameras) {
      for (int sequence = 0; sequence < RENDER_SEQUENCE.length; sequence++) {
        for (int index = 1; index < RENDER_SEQUENCE[sequence].length; index += 2) {
          short a = RENDER_SEQUENCE[sequence][index];
          short b = RENDER_SEQUENCE[sequence][index - 1];
          Vector3 aPoint = frustrumCamera.getDebugFrustrum().planePoints[a];
          Vector3 bPoint = frustrumCamera.getDebugFrustrum().planePoints[b];
          renderer.line(bPoint, aPoint);
        }
      }
    }

  } renderer.end();
}
项目:ForgE    文件:LoadingScreen.java   
@Override
protected void onInitialize() {
  this.shapeRenderer = new ShapeRenderer();
  this.camera        = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
  this.fpsLogger     = new FPSLogger();
  this.promiseTicker = new GdxPromiseFrameTicker();
  this.boxTransMat   = new Matrix4();

  camera.position.set(0, 8, 0);
  camera.lookAt(Vector3.Zero);
  ForgE.log(TAG, "Preparing to load: " + teleport.mapId);
  AsyncLevelLoader loader                 = new AsyncLevelLoader();
  GeometryBuilderTask geometryBuilderTask = new GeometryBuilderTask(promiseTicker);
  loader.then(geometryBuilderTask);
  geometryBuilderTask.then(new LevelAssetsLoaderTask(promiseTicker)).then(this);
  loader.execute(teleport.mapId);

  this.indicatorRotation = 0f;
}
项目:libgdxcn    文件:ProjectTest.java   
@Override
public void create () {
    ObjLoader objLoader = new ObjLoader();
    sphere = objLoader.loadObj(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();
}
项目:libgdxcn    文件:ShaderTest.java   
@Override
public void create () {
    modelBatch = new ModelBatch(new BaseShaderProvider() {
        @Override
        protected Shader createShader (Renderable renderable) {
            return new TestShader();
        }
    });

    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();

    camController = new CameraInputController(cam);
    Gdx.input.setInputProcessor(camController);

    Material material = new Material(new TestAttribute(1f));
    ModelBuilder builder = new ModelBuilder();
    model = builder.createCone(5, 5, 5, 20, material, Usage.Position);
    instance = new ModelInstance(model);
    testAttribute = (TestAttribute)instance.materials.get(0).get(TestAttribute.ID);
}
项目:libgdxcn    文件:FogTest.java   
@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)));
}
项目:libgdxcn    文件:BaseG3dTest.java   
@Override
public void create () {
    if (assets == null) assets = new AssetManager();

    modelBatch = new ModelBatch();

    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 = 1000f;
    cam.update();

    createAxes();

    Gdx.input.setInputProcessor(inputController = new CameraInputController(cam));
}
项目:libgdx-demo-invaders    文件:Renderer.java   
public Renderer () {
    try {
        lights = new Environment();
        lights.add(new DirectionalLight().set(Color.WHITE, new Vector3(-1, -0.5f, 0).nor()));

        spriteBatch = new SpriteBatch();
        modelBatch = new ModelBatch();

        backgroundTexture = new Texture(Gdx.files.internal("data/planet.jpg"), Format.RGB565, true);
        backgroundTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);

        font = new BitmapFont(Gdx.files.internal("data/font10.fnt"), Gdx.files.internal("data/font10.png"), false);

        camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
项目:libgdxcn    文件:Basic3DTest.java   
@Override
    public void create () {
        modelBatch = new ModelBatch(new DefaultShaderProvider());
// modelBatch = new ModelBatch();
        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();
        model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position
            | Usage.Normal);
        instance = new ModelInstance(model);

// model = new G3dModelLoader(new UBJsonReader()).loadModel(Gdx.files.internal("data/g3d/knight.g3db"));
// instance = new ModelInstance(model);

        Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
    }
项目:libgdxcn    文件:ProjectiveTextureTest.java   
public void setupScene () {
    plane = new Mesh(true, 4, 6, new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(
        Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE));
    plane.setVertices(new float[] {-10, -1, 10, 0, 1, 0, 10, -1, 10, 0, 1, 0, 10, -1, -10, 0, 1, 0, -10, -1, -10, 0, 1, 0});
    plane.setIndices(new short[] {3, 2, 1, 1, 0, 3});

    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), Format.RGB565, true);
    texture.setFilter(TextureFilter.MipMap, TextureFilter.Nearest);

    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(0, 5, 10);
    cam.lookAt(0, 0, 0);
    cam.update();
    controller = new PerspectiveCamController(cam);

    projector = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    projector.position.set(2, 3, 2);
    projector.lookAt(0, 0, 0);
    projector.normalizeUp();
    projector.update();
}
项目:libgdxcn    文件:FramebufferToTextureTest.java   
@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.loadObj(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();
}
项目:amatsukaze    文件:Basic3D.java   
@Override
public void create() {
    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, -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 = 300f;
    cam.update();

    camController = new CameraInputController(cam);
    Gdx.input.setInputProcessor(camController);

    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-vr    文件:TypeTransformer.java   
public static EyeParams transform(Viewport viewport) {
    int eye = viewport == VirtualReality.head.getLeftEye() ? 0 : 1;
    EyeParams eyeParams = new EyeParams(eye);

    eyeParams.getViewport().setViewport(viewport.getScreenX(), viewport.getScreenY(), MathUtils.nextPowerOfTwo(viewport.getScreenWidth()),
            MathUtils.nextPowerOfTwo(viewport.getScreenHeight()));

    float fov = ((PerspectiveCamera) viewport.getCamera()).fieldOfView;
    eyeParams.getFov().setLeft(fov);
    eyeParams.getFov().setRight(fov);
    eyeParams.getFov().setTop(fov);
    eyeParams.getFov().setBottom(fov);

    for (int i = 0; i < 16; i++) {
        eyeParams.getTransform().getEyeView()[i] = viewport.getCamera().view.val[i];
    }

    for (int i = 0; i < 16; i++) {
        eyeParams.getTransform().getPerspective()[i] = viewport.getCamera().projection.val[i];
    }

    return eyeParams;
}
项目:gaiasky    文件:SGRStereoscopic.java   
private void moveCamera(ICamera camera, Vector3d sideRemainder, Vector3d side, Vector3d sideCapped, double angle, boolean switchSides) {
    PerspectiveCamera cam = camera.getCamera();
    Vector3 sidef = sideCapped.put(aux1);

    if (switchSides) {
        cam.position.add(sidef);
        cam.direction.rotate(cam.up, (float) -angle);

        // Uncomment to enable 3D in points
        camera.getPos().add(sideRemainder);
        camera.setShift(sideRemainder);

    } else {
        cam.position.sub(sidef);
        cam.direction.rotate(cam.up, (float) angle);

        // Uncomment to enable 3D in points
        camera.getPos().sub(sideRemainder);
        camera.setShift(sideRemainder);
        camera.getShift().scl(-1d);
    }
    cam.update();
}
项目:gaiasky    文件:AbstractCamera.java   
public AbstractCamera(CameraManager parent) {
    this.parent = parent;
    pos = new Vector3d();
    posinv = new Vector3d();
    shift = new Vector3d();
    tmp = new Vector3d();

    frustum = new Frustumd();

    camLeft = new PerspectiveCamera(GlobalConf.scene.CAMERA_FOV, Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight());
    camLeft.near = (float) CAM_NEAR;
    camLeft.far = (float) CAM_FAR;

    camRight = new PerspectiveCamera(GlobalConf.scene.CAMERA_FOV, Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight());
    camRight.near = (float) CAM_NEAR;
    camRight.far = (float) CAM_FAR;

    projection = new Matrix4d();
    view = new Matrix4d();
    combined = new Matrix4d();
}
项目:amatsukaze    文件:BaseG3dTest.java   
@Override
public void create () {
    if (assets == null) assets = new AssetManager();

    modelBatch = new ModelBatch();

    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 = 1000f;
    cam.update();

    createAxes();

    Gdx.input.setInputProcessor(inputController = new CameraInputController(cam));
}
项目:amatsukaze    文件:ShaderTest.java   
@Override
public void create () {
    modelBatch = new ModelBatch(new BaseShaderProvider() {
        @Override
        protected Shader createShader (Renderable renderable) {
            return new TestShader();
        }
    });

    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();

    camController = new CameraInputController(cam);
    Gdx.input.setInputProcessor(camController);

    Material material = new Material(new TestAttribute(1f));
    ModelBuilder builder = new ModelBuilder();
    model = builder.createCone(5, 5, 5, 20, material, Usage.Position);
    instance = new ModelInstance(model);
    testAttribute = (TestAttribute)instance.materials.get(0).get(TestAttribute.ID);
}
项目:TinyVoxel    文件:Manager.java   
public void drawShadows(PerspectiveCamera camera) {
    drawCounter -= Time.getDelta();
    if (drawCounter < 0) {
        drawCounter = Config.SHADOW_FRAMES;
    } else {
        return;
    }

    ShadowManager.get().begin(camera.position, lod);

    ShaderProgram shadowShader = ShadowManager.get().shader;

    for (int i = 0; i < bundleArray.size; i++) {
        Bundle bundle = bundleArray.items[i];
        if (!bundle.visible || !bundle.inLargeRange || !bundle.inRange)
            continue;
        bundle.drawShadows(camera, shadowShader, lod, 3);
    }

    ShadowManager.get().end();
}
项目:amatsukaze    文件:FogTest.java   
@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)));
}