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

项目: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);



}
项目: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);
}
项目: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    文件:GdxVR.java   
/** Инициализация и загрузка ресурсов */
@Override
public void create () {
    // Размеры экрана
    scrHalfWidth = Gdx.graphics.getWidth() / 2;
    scrHeight = Gdx.graphics.getHeight();

    // Загрузка модели из файла
    modelBatch = new ModelBatch();
    assets = new  AssetManager();
    assets.load("room.g3db", Model.class);
    assets.finishLoading();
    Model roomModel = assets.get("room.g3db");
    roomInstance = new ModelInstance(roomModel);

    // Создание камеры (fov, parallax, near, far) и установка позиции
    vrCamera = new VRCamera(90, 0.4f, 0.1f, 30f);
    vrCamera.setPosition(-1.7f, 3f, 3f);

    // Разрешаем коррекцию дрифта при помощи компаса
    vrSensorManager.useDriftCorrection(true);
}
项目:GDefence    文件:LibgdxUtils.java   
@Override
public void create() {
    try {
        logger.setLevel(Logger.DEBUG);
        Gdx.app.setLogLevel(Application.LOG_DEBUG);

        Texture.setAssetManager(assets);

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

        game.create();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        Gdx.app.exit();
    }
}
项目: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();
    }
}
项目:TheEndlessCastle    文件:TheEndlessCastle.java   
@Override
public void create() {
    Box2D.init();

    _spriteBatch = new SpriteBatch();
    _modelBatch = new ModelBatch();
    _assetsHndlr = new AssetsHandler(_ASSETS_LIST_FILE_NAME);
    _settings = new Settings(_SETTINS_NAME);

    // Let shaders not use all available uniforms and attributes
    ShaderProgram.pedantic = false;
    // Disable for now bloom shader
    _settings.SetIsBloomShaderEnabled(false);

    setScreen(new LoadingScreen(this));
}
项目: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);
        }
    }
项目:ChessGDX    文件:PerspectiveRenderer.java   
/**
 * Renderer for all visible 3D components.
 * 
 * @param camera
 * @param boardController
 *            handles interactions between the behind the scenes logic and
 *            what is drawn
 * @param piecePlacement
 *            array of 64 shorts defining the contents of all 64 board
 *            locations
 */
public PerspectiveRenderer(Camera camera, BoardController boardController, short[] piecePlacement) {

    mCamera = camera;
    mBoardController = boardController;

    mShadowBatch = new ModelBatch(new DepthShaderProvider());
    mCubeMapBatch = new ModelBatch(Gdx.files.internal("shaders/cubevertex.glsl"), Gdx.files.internal("shaders/cubefragment.glsl"));
    mBackgroundBatch = new ModelBatch();
    mEnvironment = new Environment();
    mBackgroundEnvironment = new Environment();
    mDrawables = new Array<ABaseObject>();
    mGraveyard = new ChessPieceGraveyard();
    mLightDirection = new Vector3(11.0f, -9.0f, 11.0f);

    configureEnvironments();
    createGameObjects(piecePlacement);
}
项目:Mundus    文件:ToolManager.java   
public ToolManager(InputManager inputManager, ProjectManager projectManager, GameObjectPicker goPicker,
        ToolHandlePicker toolHandlePicker, ModelBatch modelBatch, ShapeRenderer shapeRenderer,
        CommandHistory history) {
    this.inputManager = inputManager;
    this.activeTool = null;

    terrainBrushes = new Array<>();
    terrainBrushes.add(new SmoothCircleBrush(projectManager, modelBatch, history));
    terrainBrushes.add(new CircleBrush(projectManager, modelBatch, history));
    terrainBrushes.add(new StarBrush(projectManager, modelBatch, history));
    terrainBrushes.add(new ConfettiBrush(projectManager, modelBatch, history));

    modelPlacementTool = new ModelPlacementTool(projectManager, modelBatch, history);
    selectionTool = new SelectionTool(projectManager, goPicker, modelBatch, history);
    translateTool = new TranslateTool(projectManager, goPicker, toolHandlePicker, modelBatch, history);
    rotateTool = new RotateTool(projectManager, goPicker, toolHandlePicker, shapeRenderer, modelBatch, history);
    scaleTool = new ScaleTool(projectManager, goPicker, toolHandlePicker, shapeRenderer, modelBatch, history);
}
项目:Mundus    文件:ScaleTool.java   
public ScaleTool(ProjectManager projectManager, GameObjectPicker goPicker, ToolHandlePicker handlePicker,
        ShapeRenderer shapeRenderer, ModelBatch batch, CommandHistory history) {
    super(projectManager, goPicker, handlePicker, batch, history);

    this.shapeRenderer = shapeRenderer;

    ModelBuilder modelBuilder = new ModelBuilder();
    Model xPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_X)),
            Vector3.Zero, new Vector3(15, 0, 0));
    Model yPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_Y)),
            Vector3.Zero, new Vector3(0, 15, 0));
    Model zPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_Z)),
            Vector3.Zero, new Vector3(0, 0, 15));
    Model xyzPlaneHandleModel = modelBuilder.createBox(3, 3, 3,
            new Material(ColorAttribute.createDiffuse(COLOR_XYZ)),
            VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);

    xHandle = new ScaleHandle(X_HANDLE_ID, xPlaneHandleModel);
    yHandle = new ScaleHandle(Y_HANDLE_ID, yPlaneHandleModel);
    zHandle = new ScaleHandle(Z_HANDLE_ID, zPlaneHandleModel);
    xyzHandle = new ScaleHandle(XYZ_HANDLE_ID, xyzPlaneHandleModel);

    handles = new ScaleHandle[] { xHandle, yHandle, zHandle, xyzHandle };
}
项目: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);
        }
    });
}
项目:Alien-Ark    文件:MiniMap.java   
public MiniMap(Rocket rocket, ControllerPlanet planetController) {
    this.rocket = rocket;
    this.planetController = planetController;

    miniMapModelBatch = new ModelBatch();
    miniMapBatch = new SpriteBatch();

    miniMapCamera = new OrthographicCamera(MINI_MAP_SIZE * MINI_ZOOM, MINI_MAP_SIZE * MINI_ZOOM);
    miniMapCamera.near = 1f;
    miniMapCamera.far = 300f;

    rocketArrow =   App.TEXTURES.findRegion("rocket_arrow");
    shieldIcon =    App.TEXTURES.findRegion("minimap_shield");
    fuelIcon =      App.TEXTURES.findRegion("minimap_fuel");
    artifactIcon =  App.TEXTURES.findRegion("minimap_artifact");
    minimapBorder = App.TEXTURES.findRegion("minimapBorder");
    planetPortal =  App.TEXTURES.findRegion("planetPortal");
    raceIcon = App.TEXTURES.findRegion("minimap_race");
}
项目: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();
    }
}
项目:teavm-libgdx    文件: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    文件: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    文件:ParticleControllerTest.java   
@Override
protected void render (ModelBatch batch, Array<ModelInstance> instances) {
    if(emitters.size > 0){
        //Update
        float delta = Gdx.graphics.getDeltaTime();
        builder.delete(0, builder.length());
        builder.append(Gdx.graphics.getFramesPerSecond());
        fpsLabel.setText(builder);
        ui.act(delta);

        billboardParticleBatch.begin();
        for (ParticleController controller : emitters){
            controller.update();
            controller.draw();
        }
        billboardParticleBatch.end();
        batch.render(billboardParticleBatch, environment);
    }
    batch.render(instances, environment);
    ui.draw();
}
项目:libgdxcn    文件:ShaderCollectionTest.java   
@Override
public void create () {
    super.create();
    lights = new Environment();
    lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.1f, 0.1f, 0.1f, 1.f));
    lights.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -0.5f, -1.0f, -0.8f));

    shaderProvider = new TestShaderProvider();
    shaderBatch = new ModelBatch(shaderProvider);

    cam.position.set(1, 1, 1);
    cam.lookAt(0, 0, 0);
    cam.update();
    showAxes = true;

    onModelClicked("g3d/shapes/teapot.g3dj");

    shaderRoot = (hotLoadFolder != null && Gdx.app.getType() == ApplicationType.Desktop) ? Gdx.files.absolute(hotLoadFolder)
        : Gdx.files.internal("data/g3d/shaders");
}
项目: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    文件:LightsTest.java   
@Override
protected void render (ModelBatch batch, Array<ModelInstance> instances) {
    final float delta = Gdx.graphics.getDeltaTime();
    dirLight.direction.rotate(Vector3.X, delta * 45f);
    dirLight.direction.rotate(Vector3.Y, delta * 25f);
    dirLight.direction.rotate(Vector3.Z, delta * 33f);

    pointLight.position.sub(transformedCenter);
    pointLight.position.rotate(Vector3.X, delta * 50f);
    pointLight.position.rotate(Vector3.Y, delta * 13f);
    pointLight.position.rotate(Vector3.Z, delta * 3f);
    pointLight.position.add(transformedCenter.set(center).mul(transform));

    pLight.worldTransform.setTranslation(pointLight.position);
    batch.render(pLight);

    super.render(batch, instances);
}
项目: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));
}
项目: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    文件: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();
}
项目:libgdxcn    文件:CullTest.java   
@Override
public void create () {
    ModelBuilder builder = new ModelBuilder();
    sphere = builder.createSphere(2f, 2f, 2f, 16, 16, new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE)),
        Usage.Position | Usage.Normal);
    // cam = new PerspectiveCamera(45, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam = new OrthographicCamera(45, 45 * (Gdx.graphics.getWidth() / (float)Gdx.graphics.getHeight()));

    cam.near = 1;
    cam.far = 200;

    Random rand = new Random();
    for (int i = 0; i < instances.length; i++) {
        pos.set(rand.nextFloat() * 100 - rand.nextFloat() * 100, rand.nextFloat() * 100 - rand.nextFloat() * 100,
            rand.nextFloat() * -100 - 3);
        instances[i] = new ModelInstance(sphere, pos);
    }
    modelBatch = new ModelBatch();

    batch = new SpriteBatch();
    font = new BitmapFont();
    // Gdx.graphics.setVSync(true);
    // Gdx.app.log("CullTest", "" + Gdx.graphics.getBufferFormat().toString());
}
项目:HelixEngine    文件:RenderingSystem.java   
@Override
protected void initialize() {
  displayableCollections = new Array<Array<? extends Displayable>>();

  modelDisplayables = new Array<ModelDisplayable>();
  displayableCollections.add(modelDisplayables);

  decalDisplayables = new Array<DecalDisplayable>();
  displayableCollections.add(decalDisplayables);

  renderContext = new RenderContext(
      new DefaultTextureBinder(DefaultTextureBinder.WEIGHTED));
  renderContext.setCullFace(GL20.GL_BACK);

  modelBatch = new ModelBatch(renderContext,
                              new DefaultShaderProvider(),
                              new HelixRenderableSorter());

  decalBatch = new DecalBatch(new CameraGroupStrategy(camera));

  spriteBatch = new SpriteBatch();
}
项目:libgdx-utils    文件:LibgdxUtils.java   
@Override
public void create() {
    try {
        logger.setLevel(Logger.DEBUG);
        Gdx.app.setLogLevel(Application.LOG_DEBUG);

        Texture.setAssetManager(assets);

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

        game.create();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        Gdx.app.exit();
    }
}
项目:gdx-vr    文件:SimpleRoom.java   
@Override
public void create() {
    assets = new AssetManager();
    String model = "Bambo_House.g3db";
    assets.load(model, Model.class);
    assets.finishLoading();
    modelInstance = new ModelInstance(assets.get(model, Model.class), new Matrix4().setToScaling(0.6f, 0.6f, 0.6f));

    DefaultShader.Config config = new Config();
    config.defaultCullFace = GL20.GL_NONE;
    ShaderProvider shaderProvider = new DefaultShaderProvider(config);
    modelBatch = new ModelBatch(shaderProvider);

    ModelBuilder builder = new ModelBuilder();
    float groundSize = 1000f;
    ground = new ModelInstance(builder.createRect(-groundSize, 0, groundSize, groundSize, 0, groundSize, groundSize, 0, -groundSize, -groundSize, 0, -groundSize, 0,
            1, 0, new Material(), Usage.Position | Usage.Normal), new Matrix4().setToTranslation(0, -0.01f, 0));
    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));

    VirtualReality.renderer.listeners.add(this);
    // VirtualReality.head.setCyclops(true);
}
项目:amatsukaze    文件: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)));
    }
项目:Scene3d    文件:Stage3d.java   
public Stage3d (float width, float height, boolean keepAspectRatio) {
    this.width = width;
    this.height = height;

    root = new Group3d();
    root.setStage3d(this);

    modelBatch = new ModelBatch();

    camera =  new Camera3d();
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.9f, 0.9f, 0.9f, 1f));
    environment.add(new DirectionalLight().set(0.8f, 0f, 0f, -1f, -0.8f, -0.2f));

    setViewport(width, height, keepAspectRatio);
}
项目:Vloxlands    文件:Structure.java   
@Override
public void render(ModelBatch batch, Environment environment, boolean minimapMode) {
    super.render(batch, environment, minimapMode);

    if ((hovered || selected) && !minimapMode && Vloxlands.wireframe) {
        Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);
        Vloxlands.shapeRenderer.setProjectionMatrix(Game.camera.combined);
        Vloxlands.shapeRenderer.identity();
        Vloxlands.shapeRenderer.translate(posCache.x, posCache.y - boundingBox.getDimensions().y / 2 + boundingBox.getCenter().y, posCache.z);
        Vloxlands.shapeRenderer.rotate(1, 0, 0, 90);
        Vloxlands.shapeRenderer.begin(ShapeType.Line);
        Vloxlands.shapeRenderer.setColor(Color.GREEN);
        Vloxlands.shapeRenderer.circle(0, 0, workRadius, 100);
        Vloxlands.shapeRenderer.line(-workRadius, 0, workRadius, 0);
        Vloxlands.shapeRenderer.line(0, -workRadius, 0, workRadius);
        Vloxlands.shapeRenderer.end();
    }
}
项目: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();
    }
}
项目: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);
}
项目:amatsukaze    文件:ShaderCollectionTest.java   
@Override
public void create () {
    super.create();
    lights = new Environment();
    lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.1f, 0.1f, 0.1f, 1.f));
    lights.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -0.5f, -1.0f, -0.8f));

    shaderProvider = new TestShaderProvider();
    shaderBatch = new ModelBatch(shaderProvider);

    cam.position.set(1, 1, 1);
    cam.lookAt(0, 0, 0);
    cam.update();
    showAxes = true;

    onModelClicked("g3d/shapes/teapot.g3dj");

    shaderRoot = (hotLoadFolder != null && Gdx.app.getType() == ApplicationType.Desktop) ? Gdx.files.absolute(hotLoadFolder)
        : Gdx.files.internal("data/g3d/shaders");
}
项目: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);
}
项目:amatsukaze    文件:LightsTest.java   
@Override
protected void render (ModelBatch batch, Array<ModelInstance> instances) {
    final float delta = Gdx.graphics.getDeltaTime();
    dirLight.direction.rotate(Vector3.X, delta * 45f);
    dirLight.direction.rotate(Vector3.Y, delta * 25f);
    dirLight.direction.rotate(Vector3.Z, delta * 33f);

    pointLight.position.sub(transformedCenter);
    pointLight.position.rotate(Vector3.X, delta * 50f);
    pointLight.position.rotate(Vector3.Y, delta * 13f);
    pointLight.position.rotate(Vector3.Z, delta * 3f);
    pointLight.position.add(transformedCenter.set(center).mul(transform));

    pLight.worldTransform.setTranslation(pointLight.position);
    batch.render(pLight);

    super.render(batch, instances);
}
项目: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)));
}
项目: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));
}
项目:Tower-Defense-Galaxy    文件:Laser.java   
@Override
public void render(float delta, ModelBatch modelBatch, ShapeRenderer shapeRenderer, Environment environment) {
    super.render(delta, modelBatch, shapeRenderer, environment);
    if(laserTime > 0) {
        laserTime -= delta;
        shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
        shapeRenderer.setColor(1, 0, 0, 1);
        shapeRenderer.line(transform.getTranslation(tempVector), laserTo);
        shapeRenderer.end();
    }
}