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

项目:Tower-Defense-Galaxy    文件:CampaignScreen.java   
@Override
public void renderForCamera(Camera camera) {
    spriteBatch.begin();
    spriteBatch.draw(background, 0, 0, viewport.getWorldWidth(), viewport.getWorldHeight(), (int)(scroll / (float)length * (background.getWidth() - viewport.getScreenWidth())), 0, viewport.getScreenWidth(), (int)viewport.getWorldHeight(), false, false);
    for(int i = 0; i < campaignWorlds.size(); i++)
        if(segmentWidth + i * segmentWidth - scroll > 0 && halfFreeWidth + i * segmentWidth - scroll < background.getWidth() - viewport.getWorldWidth())
            spriteBatch.draw(campaignWorlds.get(i).icon, halfFreeWidth + i * segmentWidth - scroll, viewport.getWorldHeight() / 2f - ICON_SIZE / 2);
    if(selection != -1) {
        layout.setText(game.getFonts().get("moonhouse64"), campaignWorlds.get(selection).name);
        spriteBatch.draw(textBack, viewport.getWorldWidth() / 2 - (layout.width + 40) / 2, viewport.getWorldHeight() - 72 - layout.height, layout.width + 40, layout.height + 40);
        game.getFonts().get("moonhouse64").draw(spriteBatch, campaignWorlds.get(selection).name, viewport.getWorldWidth() / 2 - layout.width / 2, viewport.getWorldHeight() - 10 - layout.height);
        layout.setText(game.getFonts().get("moonhouse64"), campaignWorlds.get(selection).desc);
        spriteBatch.draw(textBack, viewport.getWorldWidth() / 2 - (layout.width + 40) / 2, layout.height + 20, layout.width + 40, layout.height + 40);
        game.getFonts().get("moonhouse64").draw(spriteBatch, campaignWorlds.get(selection).desc, viewport.getWorldWidth() / 2 - layout.width / 2, layout.height + 83);
    }
    spriteBatch.end();
}
项目:gdxjam-ugg    文件:CameraController.java   
private void keepInBoundaries(){
    final Camera camera = viewport.getCamera();
    final Vector3 position = camera.position;
    if(position.x < boundary.x){
        position.x = boundary.x;
    }
    if(position.x > boundary.x + boundary.width){
        position.x = boundary.x + boundary.width;
    }
    if(position.y < boundary.y){
        position.y = boundary.y;
    }
    if(position.y > boundary.y + boundary.height) {
        position.y = boundary.y + boundary.height;
    }
}
项目:Quilly-s-Castle    文件:NPCAIComponent.java   
@Override
   public void update(Entity entity, GameWorld world, Map map, Camera camera, float deltaTime) {
if (State.IMMOBILE != state) {
    stateTime -= deltaTime;
    if (stateTime <= 0) {
    // change state
    stateTime = MathUtils.random(2);
    State nextState = State.getRandom();
    if (State.WALKING == nextState) {
        entity.sendMessage(MessageType.SET_STATE, State.WALKING, Direction.getRandom());
    } else {
        entity.sendMessage(MessageType.SET_STATE, nextState);
    }
    }

}
   }
项目:space-travels-3    文件:GameScreen.java   
private void updateCamera()
{
    if (!GameEntityManager.getGameEntities().contains(this.level.getShip()))
    {
        return;
    }
    Camera camera = SpaceTravels3.gameViewport.getCamera();

    camera.position.set(
        this.level.getShip().physicsComponent.getPosition().x,
        this.level.getShip().physicsComponent.getPosition().y,
        0f);
    camera.update();

    SpaceTravels3.spriteBatch.setProjectionMatrix(camera.combined);
}
项目:fabulae    文件:GameMap.java   
@Override
public void update(float deltaTime, Camera camera) {
    sun.update(!isWorldMap());
    updateLocalGameObjects(deltaTime);
    super.update(deltaTime, camera);
    for (GameLocation loc : locations) {
        loc.update(deltaTime, camera);
    }

    fogOfWarRayHandler.setCombinedMatrix(camera.combined);
    fogOfWarRayHandler.update();
    unpausableTweenManager.update(deltaTime);
    if (!GameState.isPaused()) {
        tweenManager.update(deltaTime);
        if (particleEffectManager != null) {
            particleEffectManager.update(deltaTime);
        }
    }
}
项目:fabulae    文件:GameState.java   
private float updateFastForward(float deltaTime, Camera camera) {
    if (fastForwarding && fastForwarded >= fastForwardBy) {
        fastForwarding = false;
        UIManager.hideProgressDialog();
        if (fastForwardCallback != null) {
            fastForwardCallback.onFinished();
        }
        fastForwardCallback = null;
    }

    if (fastForwarding && !isPaused) {
        int currentTimeMultiplier = currentMap.getGameTimeMultiplier();
        deltaTime = Configuration.getFastForwardStep()
                * Math.max(Configuration.getWorldGameTimeMultiplier(),
                        Configuration.getLocalGameTimeMultiplier())
                / currentTimeMultiplier;
        fastForwarded += deltaTime;
        UIManager.updateProgressDialog((fastForwarded / 3600) * currentTimeMultiplier);
        if (fastForwardRandomEncounter != null && fastForwarded >= fastForwardRandomAfter) {
            handleFastForwardRandomEncounter();
        }
    }
    return deltaTime;
}
项目:eamaster    文件:WheelWorld.java   
public void render(ModelBatch batch, Environment environment) {
        if (drawShapes) {
            batch.render(hub.modelInstance, environment);
            batch.render(rim.modelInstance, environment);

            for (int i = 0; i < spokesToDraw; i++) {
                spokes.get(i).updateSpokeRender();
                batch.render(spokes.get(i).modelInstance, environment);
            }
//            spokes.forEach(s -> batch.render(s.modelInstance, environment));
//            bulletWorld.updateAabbs();
        }


        if (debugDrawer.getDebugMode() > 0) {
            Camera camera = batch.getCamera();
            batch.flush();
            debugDrawer.begin(camera);
            bulletWorld.debugDrawWorld();
            debugDrawer.end();
        }
    }
项目:eamaster    文件:World.java   
public void render(ModelBatch batch, Environment environment) {
        if (drawShapes) {
            for (WorldEntity entity : entities) {
                batch.render(entity.instance, environment);
            }

            batch.render(instances);
        }

        if (getDebugMode() > 0) {
            Camera camera = batch.getCamera();
            batch.flush();
            debugDrawer.begin(camera);
            bulletWorld.debugDrawWorld();
            debugDrawer.end();
//            batch.begin(camera);
        }
    }
项目:braingdx    文件:StatePopulator.java   
public void populate(TiledMap tiledMap, State state, Camera camera, MapLayerRendererFactory rendererFactory,
      TiledMapConfig config) {
   MapLayers mapLayers = tiledMap.getLayers();
   handleMapProperties(tiledMap.getProperties(), state, config);
   List<String> layerIds = new ArrayList<String>();
   int lastTileLayerIndex = 0;
   for (int i = 0; i < mapLayers.getCount(); ++i) {
      MapLayer mapLayer = mapLayers.get(i);
      if (mapLayer instanceof TiledMapTileLayer) {
         if (i > 0) {
            lastTileLayerIndex++;
         }
         String layerId = handleTiledMapTileLayer((TiledMapTileLayer) mapLayer, i, tiledMap, camera, rendererFactory,
               config);
         layerIds.add(layerId);
         populateStaticMapData(lastTileLayerIndex, (TiledMapTileLayer) mapLayer, state, config);
      } else {
         // Not a tiledlayer so consider it as an object layer
         handleObjectLayer(lastTileLayerIndex, mapLayer, state, config);
      }
   }
   state.setLayerIds(layerIds);
}
项目:METRO    文件:AbstractTrainStatisticView.java   
/**
 * Draws the view with all information depending on the subclass.
 * 
 * @param sp
 *            The sprite batch to draw on.
 * @param position
 *            The position of the view in pixel coordinates.
 */
public void draw(SpriteBatch sp, Point position)
{
    METRO.__spriteBatch.end();
    METRO.__spriteBatch.begin();

    // Create scissor to draw only in the area of the statistic view.
    com.badlogic.gdx.math.Rectangle scissors = new com.badlogic.gdx.math.Rectangle();
    com.badlogic.gdx.math.Rectangle clipBounds = new com.badlogic.gdx.math.Rectangle(position.x + METRO.__getXOffset(), position.y + METRO.__getYOffset(), _size.x + 1, _size.y
            + 1);
    ScissorStack.calculateScissors((Camera) METRO.__camera, METRO.__spriteBatch.getTransformMatrix(), clipBounds, scissors);
    ScissorStack.pushScissors(scissors);

    drawView(sp);

    ScissorStack.popScissors();
}
项目:METRO    文件:List.java   
@Override
protected void draw()
{
    METRO.__spriteBatch.end();
    METRO.__spriteBatch.begin();

    // Create scissor to draw only in the area of the list box.
    com.badlogic.gdx.math.Rectangle scissors = new com.badlogic.gdx.math.Rectangle();
    com.badlogic.gdx.math.Rectangle clipBounds = new com.badlogic.gdx.math.Rectangle(_area.x + METRO.__getXOffset(), _area.y + METRO.__getYOffset(), _area.width
            + 1, _area.height + 1);
    ScissorStack.calculateScissors((Camera) METRO.__camera, METRO.__spriteBatch.getTransformMatrix(), clipBounds, scissors);
    ScissorStack.pushScissors(scissors);

    if (_decorated) clearBackground();

    drawEntries();

    if (_decorated) drawBorders();

    drawScrollbar();

    ScissorStack.popScissors();
}
项目:METRO    文件:Canvas.java   
@Override
protected void draw()
{
    Contract.RequireNotNull(_painter);

    Draw.setOffset(_area.x, _area.y);
    Fill.setOffset(_area.x, _area.y);

    com.badlogic.gdx.math.Rectangle scissors = new com.badlogic.gdx.math.Rectangle();
    com.badlogic.gdx.math.Rectangle clipBounds = new com.badlogic.gdx.math.Rectangle(_area.x + METRO.__getXOffset(), _area.y + METRO.__getYOffset(), _area.width
            + 1, _area.height + 1);

    ScissorStack.calculateScissors((Camera) METRO.__camera, METRO.__spriteBatch.getTransformMatrix(), clipBounds, scissors);
    ScissorStack.pushScissors(scissors);

    _painter.paint();

    ScissorStack.popScissors();

    Draw.setOffset(METRO.__getXOffset(), METRO.__getYOffset());
    Fill.setOffset(METRO.__getXOffset(), METRO.__getYOffset());
}
项目:DoubleHelix    文件:SubsurfaceScatteringShader.java   
@Override
public void begin(Camera camera, RenderContext context) {
    program.begin();
    viewProjTrans.set(camera.combined);

    program.setUniformf(u_cameraPosition, camera.position.x, camera.position.y, 
            camera.position.z, 1);
    program.setUniformf(u_worldLightDir, lightDirection.x, lightDirection.y, lightDirection.z, 0);

    context.setDepthTest(GL20.GL_LEQUAL);
    context.setCullFace(GL20.GL_BACK);
    context.setBlending(shouldFadeEnds ? true : false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    texture.bind(0);
    program.setUniformi(u_texture, 0);

    specLUT.getTexture().bind(1);
    program.setUniformi(u_specularPowerLUTTexture, 1);

}
项目:DoubleHelix    文件:ParticleGroupStrategy.java   
public ParticleGroupStrategy(final Camera camera) {
    this.camera = camera;

    cameraSorter = new Comparator<Decal>() {
        @Override
        public int compare (Decal o1, Decal o2) {
            return (int)Math.signum(((DecalPlus)o2).cameraDistance - ((DecalPlus)o1).cameraDistance);
        }
    };

    billboardCameraSorter = new Comparator<BillboardDecal>() {
        @Override
        public int compare (BillboardDecal o1, BillboardDecal o2) {
            return (int)Math.signum(o2.floatValue - o1.floatValue);
        }
    };

    loadShaders();
}
项目:Entitas-Java    文件:ActuatorEntity.java   
public ActuatorEntity replaceCameraActuator(Camera camera, short height,
        float damping, float minDistanceX, float minDistanceY,
        String followTagEntity) {
    CameraActuator component = (CameraActuator) recoverComponent(ActuatorComponentsLookup.CameraActuator);
    if (component == null) {
        component = new CameraActuator(camera, height, damping,
                minDistanceX, minDistanceY, followTagEntity);
    } else {
        component.actuator = (indexOwner) -> {
            Set<GameEntity> followEntities = Indexed
                    .getTagEntities(followTagEntity);
            for (GameEntity followEntity : followEntities) {
                RigidBody rc = followEntity.getRigidBody();
                Transform transform = rc.body.getTransform();
                Vector3 position = camera.position;
                position.x += (transform.getPosition().x + minDistanceX - position.x)
                        * damping;
                position.y += (transform.getPosition().y + minDistanceY - position.y)
                        * height;
            }
        };
    }
    replaceComponent(ActuatorComponentsLookup.CameraActuator, component);
    return this;
}
项目:Entitas-Java    文件:RendererSystem.java   
public RendererSystem(Entitas entitas, Camera cam, Batch batch, World world) {
    this.physics = world;
    this.cam = cam;
    this.batch = batch;
    this.entitas = entitas;
    _groupTextureView = entitas.game.getGroup(GameMatcher.TextureView());
    this.debugShapeRenderer = new ShapeRenderer();
    this.debugRenderer = new Box2DDebugRenderer(DRAW_BOX2D_BODIES, DRAW_BOX2D_JOINTS, DRAW_BOX2D_ABBs,
            DRAW_BOX2D_INACTIVE_BODIES, DRAW_BOX2D_VELOCITIES, DRAW_BOX2D_CONTACTS);
    debugRenderer.setDrawAABBs(DRAW_BOX2D_ABBs);
    debugRenderer.setDrawBodies(DRAW_BOX2D_BODIES);
    debugRenderer.setDrawContacts(DRAW_BOX2D_CONTACTS);
    debugRenderer.setDrawInactiveBodies(DRAW_BOX2D_INACTIVE_BODIES);
    debugRenderer.setDrawJoints(DRAW_BOX2D_JOINTS);
    debugRenderer.setDrawVelocities(DRAW_BOX2D_VELOCITIES);
    this.inputs = entitas.input.getGroup(InputMatcher.Input());
}
项目:Entitas-Java    文件:SplashState.java   
@Override
public void initialize() {
    // Input
    Camera camera = engine.getManager(BaseSceneManager.class).getDefaultCamera();
    Batch batch = engine.getManager(BaseSceneManager.class).getBatch();
    BitmapFont font = engine.getManager(BaseGUIManager.class).getDefaultFont();
    systems.add(new DelaySystem(context.core))
            .add(new RendererSystem(context.core, engine.sr, camera, batch, font));

    Texture texture = assetsManager.getTexture(splash);

    context.core.createEntity()
            .addTextureView("Pong", new TextureRegion(texture, 0, 0, texture.getWidth(), texture.getHeight()), new Vector2(),
                    0, Pong.SCREEN_HEIGHT, Pong.SCREEN_WIDTH)
            .addDelay(3);
}
项目:GdxDemo3D    文件:GameRenderer.java   
public GameRenderer(Viewport viewport, Camera camera, GameEngine engine) {
    this.viewport = viewport;
    this.camera = camera;
    this.engine = engine;

    shapeRenderer = new MyShapeRenderer();
    shapeRenderer.setAutoShapeType(true);

    spriteBatch = new SpriteBatch();
    font = new BitmapFont();
    font.setColor(Color.WHITE);
    font.setUseIntegerPositions(false);
    font.getData().setScale(0.01f);
    shadowBatch = new ModelBatch(new DepthShaderProvider());

    ShaderProgram.pedantic = false;
    final String vertUber = Gdx.files.internal("shaders/uber.vert").readString();
    final String fragUber = Gdx.files.internal("shaders/uber.frag").readString();
    modelBatch = new ModelBatch(new DefaultShaderProvider(vertUber, fragUber) {
        @Override
        protected Shader createShader(final Renderable renderable) {
            return new UberShader(renderable, config);
        }
    });
}
项目:GdxDemo3D    文件:NavMeshDebugDrawer.java   
private void drawNavMeshIndices(SpriteBatch spriteBatch, Camera camera, BitmapFont font) {
    // TODO: Get rid of all the transform matrix setting
    if (spriteBatch.isDrawing()) {
        spriteBatch.end();
    }
    spriteBatch.begin();
    spriteBatch.setProjectionMatrix(camera.combined);
    for (int i = 0; i < navMesh.graph.getNodeCount(); i++) {
        Triangle t = navMesh.graph.getTriangleFromGraphIndex(i);
        if (triangleIsVisible(t)) {
            tmpMatrix.set(camera.view).inv().getRotation(tmpQuat);
            tmpMatrix.setToTranslation(t.centroid).rotate(tmpQuat);
            spriteBatch.setTransformMatrix(tmpMatrix);
            font.draw(spriteBatch, Integer.toString(t.triIndex), 0, 0);
        }
    }
    spriteBatch.end();
}
项目:abattle    文件:TriangleMainView.java   
public void drawImmediate() {
    final Camera camera = new OrthographicCamera();
    for (int x = 0; x < 100; x++) {
        r.begin(camera.combined, GL20.GL_LINES);
        final int count = 1000;
        for (int i = 0; i < count; i++) {
            final float xs = (float) Math.sin(Math.toRadians(i * 1.0));
            final float ys = (float) Math.cos(Math.toRadians(i * 1.0));
            final float xe = (float) Math.sin(Math.toRadians((i * 1.0) + 180));
            final float ye = (float) Math.cos(Math.toRadians((i * 1.0) + 180));
            r.color(1.0f, 0.0f, 0.0f, 1.0f);
            r.vertex(xs, ys, 0);
            r.color(1.0f, 0.0f, 0.0f, 1.0f);
            r.vertex(xe, ye, 0);
        }

        // flush the renderer
        r.end();
    }
}
项目:Protoman-vs-Megaman    文件:GameUtils.java   
/**
 * checks if a game object is within the given camera's viewport.
 * 
 * @param camera game camera to check if the game object is within the view port
 * @param gameObj game object to check
 * 
 * @return <b>true</b> if game object is within camera viewport. <b>false</b> otherwise.
 */
public static boolean isWithinCameraView(Camera camera, GameObject gameObj) {
    if (cameraBounds == null) {
        // first call to this method
        // create a Rectangle instance and keep it for later use
        // it is better to keep an instance to avoid gc during update/render calls
        cameraBounds = new Rectangle();
    }

    cameraBounds.x = camera.position.x - camera.viewportWidth / 2;
    cameraBounds.y = camera.position.y - camera.viewportHeight / 2;
    cameraBounds.width = camera.viewportWidth;
    cameraBounds.height = camera.viewportHeight;

    return Intersector.overlaps(cameraBounds, gameObj.getBoundingRectangle());
}
项目:Alien-Ark    文件:ControllerPhysic.java   
public Vector3 calculateCameraPickIntersection(Camera camera, int screenX, int screenY, Vector3 out) {
    Ray pickRay = camera.getPickRay(screenX, screenY);
    rayFrom.set(pickRay.origin);
    tmpVector2.set(pickRay.direction).nor().scl(1000);
    tmpVector.set(pickRay.origin).add(tmpVector2);
    rayTo.set(tmpVector);
    callback.setCollisionObject(null);
    callback.setClosestHitFraction(1f);
    callback.setRayFromWorld(rayFrom);
    callback.setRayToWorld(rayTo);
    callback.setCollisionFilterMask((short) -1);
    callback.setCollisionFilterGroup((short) -1);
    dynamicsWorld.rayTest(rayFrom, rayTo, callback);
    if (callback.hasHit()) {
        callback.getHitPointWorld(out);
        return out;
    }
    return null;
}
项目:vrmleditor    文件:Renderer.java   
@Override
public void create() {
    Gdx.graphics.setVSync(Settings.getVSync());

    // create and configure cameras
    cameras = new Camera[Constants.CAMERAS_TOTAL];
    viewports = new Vector2[cameras.length];
    for (int i = 0; i < cameras.length; i++) {
        cameras[i] = CameraUtil.configureCamera(Settings.getCamera(i));
        viewports[i] = new Vector2();
    }

    // initialize SpriteBacth
    spriteBatch = new SpriteBatch();
    if(!Settings.isFontBold())
    {
        font = new BitmapFont(Gdx.files.internal("resources/fonts/font_regular.fnt"), false);
    }
    else
    {
        font = new BitmapFont(Gdx.files.internal("resources/fonts/font_bold.fnt"), false);
    }
}
项目: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;
}
项目:vrmleditor    文件:Editor.java   
/**
 * Clear all informations about shape
 */
public void clearAll() {
    // clear list shapes
    getListModel().clear();
    renderer.getListShapes().clear();
    Shape.reset();
    // clear history
    history.clear();
    // clear properties tab
    clearProperties();
    // reset cameras position & zoom
    Camera[] cameras = renderer.getCameras();
    for (int i = 0; i < cameras.length; i++) {
        cameras[i] = CameraUtil.configureCamera(Settings.getCamera(i));
    }
}
项目:GDX-Engine    文件:CameraManager.java   
/**
 * Add camera to collection collection of CameraManager
 * @param camera Camera to Add
 * @param key Key (ID) of camera
 */
public void addCamera(String key, Camera camera)
{
    if(collection.containsKey(key))
        throw new GdxRuntimeException("Camera key is existing in CameraManager!");

    collection.put(key, camera);
}
项目:GDX-Engine    文件:CameraManager.java   
/**
 * Set the camera is the current active camera
 * @param camera reference to the camera you want.
 */
public void setActiveCamera(Camera camera)
{
    if(!collection.containsValue(camera))
        throw new GdxRuntimeException("Camera is not existing in CameraManager!");

    activeObject = camera;
}
项目:GDX-Engine    文件:MonsterHealthyDrawer.java   
public void draw(ArrayList<Monster> monsters, Camera camera){
render.setProjectionMatrix(camera.combined);
render.begin(ShapeType.FilledRectangle);
for(Monster m : monsters){
    //draw only the damaged monster
    if(m.getHealthyRate() < 1f){
    render.setColor(Color.RED);
    render.filledRect(m.getX() + 5, m.getY() + m.getHeight() + 5, BAR_WIDTH, BAR_HEIGHT);
    render.setColor(Color.GREEN);
    render.filledRect(m.getX() + 5, m.getY() + m.getHeight() + 5, BAR_WIDTH * m.getHealthyRate(), BAR_HEIGHT);
    }
}
render.end();
   }
项目:GDX-Engine    文件:TowerDefenseGame.java   
@Override
   public void resize(int width, int height) {
super.resize(width, height);
if (activeScene == scene) {
    Camera camera = scene.getCameraUI();
    camera.viewportHeight = height;
    camera.viewportWidth = width;
    camera.update();
    scene.getBatchUI().setProjectionMatrix(camera.combined);
    scene.setupCamera();
}
   }
项目:GDX-Engine    文件:TowerRangeDrawer.java   
public void draw(Camera camera){
render.setProjectionMatrix(camera.combined);
render.setColor(new Color(0f, 1f, 0f, .1f));
render.begin(ShapeType.FilledCircle);
render.filledCircle(x, y, range, 30);
render.end();
   }
项目:projecttd    文件:RenderSystem.java   
public RenderSystem(Camera camera, int tileWidth) {
    super(Family.all(SpriteComponent.class, TransformComponent.class).get());

    this.tileWidth = tileWidth / 2f;

    this.camera = camera;
    batch = new SpriteBatch();

    spriteM = ComponentMapper.getFor(SpriteComponent.class);
    positionM = ComponentMapper.getFor(TransformComponent.class);
}
项目:Tower-Defense-Galaxy    文件:VRCamera.java   
public Camera beginCamera(Eye eye) {
    if(Eye.LEFT.equals(eye)) {
        leftBuffer.begin();
        return leftCamera;
    } else {
        rightBuffer.begin();
        return rightCamera;
    }
}
项目:Tower-Defense-Galaxy    文件:TDScreen.java   
@Override
public void render(float delta) {
    stage.act(Gdx.graphics.getDeltaTime());
    update(delta);
    camera.update();

    if(TDGalaxy.preferences.isVr() && game.getVr().isInitialized()) {
        game.getVr().update(delta);
        game.getVr().startRender();
        Camera vrCamera = game.getVr().beginCamera(Eye.LEFT);
        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
        renderForCamera(vrCamera);
        renderUI(vrCamera);
        game.getVr().endCamera(Eye.LEFT);
        vrCamera = game.getVr().beginCamera(Eye.RIGHT);
        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
        renderForCamera(vrCamera);
        renderUI(vrCamera);
        game.getVr().endCamera(Eye.RIGHT);
        game.getVr().endRender();
    } else {
        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
        renderForCamera(camera);
        renderUI(camera);
    }
}
项目:Tower-Defense-Galaxy    文件:TDScreen.java   
private void renderUI(Camera uiCamera) {
    matrix4.set(uiCamera.combined);
    matrix4.setToOrtho2D(0, 0, viewport.getWorldWidth(), viewport.getWorldHeight());
    spriteBatch.setProjectionMatrix(matrix4);
    spriteBatch.begin();
    //TDWorld.getFonts().get("ui32").draw(spriteBatch, orthographicCamera.unproject(tmp.set(Gdx.input.getX(), Gdx.input.getY(), 0)).toString(), 100, 100);
    spriteBatch.end();
    stage.draw();
}
项目:Tower-Defense-Galaxy    文件:TDScreen.java   
protected Camera createCamera() {
    Camera camera = new OrthographicCamera(2560, 1440);
    camera.position.set(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2, 0);
    camera.far = 10000;
    camera.near = 0;
    return camera;
}
项目:Tower-Defense-Galaxy    文件:LevelSelectScreen.java   
@Override
protected Camera createCamera() {
    Camera camera = new PerspectiveCamera(67, viewport.getWorldWidth(), viewport.getWorldHeight());
    camera.position.set(0, 500, 0);
    camera.lookAt(0, 0, 0);
    camera.near = 0.1f;
    camera.far = 10000;
    return camera;
}
项目:Tower-Defense-Galaxy    文件:MainScreen.java   
@Override
public void renderForCamera(Camera camera) {
    spriteBatch.begin();
    spriteBatch.draw(background, 0, 0, viewport.getWorldWidth(), viewport.getWorldHeight());
    game.getFonts().get("moonhouse64").draw(spriteBatch, "$" + TDGalaxy.preferences.getMoney(), viewport.getWorldWidth() / 2 - 4, viewport.getWorldHeight() - 30);
    spriteBatch.end();
}
项目:Tower-Defense-Galaxy    文件:CameraHandler.java   
public CameraHandler(Camera cam, TDGalaxy game, CameraType cameraType) {
    this.game = game;
    this.cam = cam;
    tmp = new Vector3(0, 0,0 );
    pivotPoint = new Vector3(0, 0, 0);
    this.cameraType = cameraType;

}
项目:Cubes_2    文件:Player.java   
public Player(Camera camera) {
    super("core:player", camera.position, camera.direction, 20);
    this.uuid = CubesClient.uuid;
    this.username = Settings.getStringSettingValue(Settings.US_NAME);
    this.clientIdentifier = null;
    this.inventory = new PlayerInventory(this);
    this.height = PLAYER_HEIGHT;
}
项目:Cubes_2    文件:WorldShaderProvider.java   
@Override
public void begin(Camera camera, RenderContext context) {
    super.begin(camera, context);
    if (Cubes.getClient() == null) {
        program.setUniformf(u_sunlight, 1f);
    } else {
        program.setUniformf(u_sunlight, Cubes.getClient().world.getWorldSunlight());
    }
    program.setUniformf(u_lightoverride, -1f);
}