Java 类com.badlogic.gdx.utils.UBJsonReader 实例源码

项目:libgdxcn    文件:AssetManager.java   
/** Creates a new AssetManager with all default loaders. */
public AssetManager (FileHandleResolver resolver) {
    setLoader(BitmapFont.class, new BitmapFontLoader(resolver));
    setLoader(Music.class, new MusicLoader(resolver));
    setLoader(Pixmap.class, new PixmapLoader(resolver));
    setLoader(Sound.class, new SoundLoader(resolver));
    setLoader(TextureAtlas.class, new TextureAtlasLoader(resolver));
    setLoader(Texture.class, new TextureLoader(resolver));
    setLoader(Skin.class, new SkinLoader(resolver));
    setLoader(ParticleEffect.class, new ParticleEffectLoader(resolver));
    setLoader(PolygonRegion.class, new PolygonRegionLoader(resolver));
    setLoader(I18NBundle.class, new I18NBundleLoader(resolver));
    setLoader(Model.class, ".g3dj", new G3dModelLoader(new JsonReader(), resolver));
    setLoader(Model.class, ".g3db", new G3dModelLoader(new UBJsonReader(), resolver));
    setLoader(Model.class, ".obj", new ObjLoader(resolver));
    executor = new AsyncExecutor(1);
}
项目:nhglib    文件:LightProbe.java   
private void createMeshes() {
    ModelBuilder mb = new ModelBuilder();
    cubeModel = mb.createBox(1, 1, 1, new Material(),
            VertexAttributes.Usage.Position |
                    VertexAttributes.Usage.Normal |
                    VertexAttributes.Usage.TextureCoordinates);
    cubeMesh = cubeModel.meshes.first();

    G3dModelLoader modelLoader = new G3dModelLoader(new UBJsonReader());
    quadModel = modelLoader.loadModel(Gdx.files.internal("models/quad.g3db"));
    quadMesh = quadModel.meshes.first();
}
项目:nhglib    文件:Assets.java   
public void init(Nhg nhg) {
    this.nhg = nhg;
    fsm = new DefaultStateMachine<>(this, AssetsStates.IDLE);

    assetManager = new AssetManager();
    syncAssetManager = new AssetManager();

    FileHandleResolver resolver = assetManager.getFileHandleResolver();
    FileHandleResolver syncResolver = syncAssetManager.getFileHandleResolver();

    assetManager.setLoader(Scene.class, new SceneLoader(nhg, resolver));
    assetManager.setLoader(InputProxy.class, new InputLoader(resolver));
    assetManager.setLoader(JsonValue.class, new JsonLoader(resolver));
    assetManager.setLoader(HDRData2.class, new HDRLoader(resolver));
    assetManager.setLoader(Model.class, ".g3db", new NhgG3dModelLoader(this,
            new UBJsonReader(), resolver));

    syncAssetManager.setLoader(Scene.class, new SceneLoader(nhg, syncResolver));
    syncAssetManager.setLoader(InputProxy.class, new InputLoader(syncResolver));
    syncAssetManager.setLoader(JsonValue.class, new JsonLoader(syncResolver));
    syncAssetManager.setLoader(HDRData2.class, new HDRLoader(syncResolver));
    syncAssetManager.setLoader(Model.class, ".g3db", new NhgG3dModelLoader(this,
            new UBJsonReader(), syncResolver));

    assetManager.setErrorListener(this);
    syncAssetManager.setErrorListener(this);

    assetQueue = new Array<>();
    assetCache = new ArrayMap<>();

    Texture.setAssetManager(assetManager);
}
项目:ForgE    文件:TestModelsScreen.java   
@Override
protected void onInitialize() {
  this.levelEnv          = new LevelEnv();
  this.camera            = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
  camera.near = 0.1f;
  camera.position.set(5, 5, 5);
  camera.lookAt(0.1f, 0.1f, 0.1f);

  environment = new Environment();
  environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
  environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -0.5f, -1.0f, -0.8f));


  this.modelBatch        = new ModelBatch();
  //this.voxelBatch        = new VoxelBatch(new RenderContext(new DefaultTextureBinder(DefaultTextureBinder.WEIGHTED)));
  ModelLoader g3djLoader = new G3dModelLoader(new UBJsonReader());
  model                  = g3djLoader.loadModel(ForgE.files.internal("raw/models/test.g3db"));

  modelInstance          = new ModelInstance(model);

  modelInstance.calculateBoundingBox(bounds);
  camera.position.set(1, 1, 1).nor().scl(bounds.getDimensions(tmpV1).len() * 1.75f + bounds.getCenter(tmpV2).len());
  camera.up.set(0, 1, 0);
  camera.lookAt(0, 0, 0);
  camera.far = 50f + bounds.getDimensions(tmpV1).len() * 3.0f;
  camera.update(true);
}
项目:libgdxcn    文件:UBJsonTest.java   
@Override
public void create () {
    try {

        UBJsonWriter uw = new UBJsonWriter(Gdx.files.external(fn).write(false));
        uw.object();
        uw.set(longString, longString);
        uw.set("0floats", new float[] {});
        uw.set("3floats", new float[] {1, 2, 3.456789f});
        uw.set("xfloats", new float[] {Float.MIN_VALUE, Float.MAX_VALUE, Float.NaN, Float.NEGATIVE_INFINITY});
        uw.set("double", 0.000000000000000000001);
        uw.set("long", Long.MAX_VALUE);
        uw.array("arr");
        uw.object().pop();
        uw.value(true).value(false).value(true);
        uw.value((byte)254);
        uw.value((byte)(-2));
        uw.value((short)-32000);
        uw.value((int)-123456);
        uw.value((long)(-((1 << 63) - 1)));
        uw.pop();
        uw.pop();
        uw.close();
        UBJsonReader ur = new UBJsonReader();
        ur.oldFormat = false;
        JsonValue v = ur.parse(Gdx.files.external(fn));
        Gdx.app.log("UBJsonTest", "result = \n" + v.toString());
        performanceTest();
        Gdx.app.log("UBJsonTest", "Test succeeded");
    } catch (Throwable t) {
        Gdx.app.error("UBJsonTest", "Test failed", t);
    }
}
项目:libgdxcn    文件:UBJsonTest.java   
private void performanceTest () throws Exception {
    Gdx.app.log("UBJsonTest", "--- performanceTest ---");
    long start = System.currentTimeMillis();
    UBJsonWriter uw = new UBJsonWriter(Gdx.files.external(fn).write(false, 8192));
    uw.object();
    uw.set("0floats", new float[] {});
    uw.set("3floats", new float[] {1, 2, 3.456789f});
    uw.set("xfloats", new float[] {Float.MIN_VALUE, Float.MAX_VALUE, Float.NaN, Float.NEGATIVE_INFINITY});
    uw.set("double", 0.000000000000000000001);
    uw.set("long", Long.MAX_VALUE);
    uw.array("arr");
    uw.object().pop();
    for (int i = 0; i < 50000; i++) {
        uw.value(true).value(false).value(true);
        uw.value((byte)254);
        uw.value((byte)(-2));
        uw.value((short)-32000);
        uw.value((int)-123456);
        uw.value((long)(-((1 << 63) - 1)));
        uw.value(longString);
    }
    uw.pop();
    uw.pop();
    uw.close();

    Gdx.app.log("UBJsonTest", "Writing the test file took " + (System.currentTimeMillis() - start) + "ms");
    Gdx.app.log("UBJsonTest", "File size is " + Gdx.files.external(fn).length());
    UBJsonReader ur = new UBJsonReader();
    ur.oldFormat = false;
    start = System.currentTimeMillis();
    ur.parse(Gdx.files.external(fn));
    Gdx.app.log("UBJsonTest", "Parsing the test file took " + (System.currentTimeMillis() - start) + "ms");
}
项目:BotLogic    文件:ModelManager.java   
public ModelManager() {
  G3dModelLoader modelLoader = new G3dModelLoader(new UBJsonReader());
  this.robotModel            = modelLoader.loadModel(Gdx.files.getFileHandle("models/bot.g3db", Files.FileType.Internal));
  //TextureAttribute attr = (TextureAttribute) robotModel.materials.first().get(TextureAttribute.Diffuse);
  //attr.textureDescription.minFilter = Texture.TextureFilter.Nearest;
  //attr.textureDescription.magFilter = Texture.TextureFilter.Nearest;

  this.ledModel              = modelLoader.loadModel(Gdx.files.getFileHandle("models/led.g3db", Files.FileType.Internal));
}
项目:ZombieInvadersVR    文件:AssetRepository.java   
private AssetRepository() {
    repository = new HashMap<String, Object>();
    jsonReader = new UBJsonReader();
    modelLoader = new G3dModelLoader(jsonReader);
}
项目:LibGDX-PBR    文件:PBRTestAPP.java   
@Override
public void create () {
    pbrShader=new PBRShader();
    pbrShader.init();

    pbrSadherTexture=new PBRSadherTexture();
    pbrSadherTexture.init();

    materials.put("Generic", null);
    materials.put("Rough Rock", createMaterial("roughrockface4"));
    materials.put("Bricks", createMaterial("mybricks3"));
    materials.put("Rusted Iron", createMaterial("rustediron-streaks"));
    materials.put("Carved Stone", createMaterial("carvedlimestoneground1"));
    materials.put("Grass", createMaterial("grass1"));
    materials.put("Floor", createMaterial("cavefloor1"));

    matNames = new ArrayList<String>(materials.keySet());

    actMaterial=matNames.indexOf("Generic");

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

    float w=Gdx.graphics.getWidth();
    float h=Gdx.graphics.getHeight();
    float scale=w/1600;

    cam=new PerspectiveCamera(30,w, h);
    cam.position.set(12,14,0);
    cam.lookAt(0,2,0);
    cam.up.set(0,1,0);
    cam.update();
    camController = new CameraInputController(cam);

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

    skin = new Skin(Gdx.files.internal("skin/uiskin.json"));

    CreateStage(w, h, scale);

    G3dModelLoader loader = new G3dModelLoader(new UBJsonReader());
    obj=createRenderableFromMesh(loader.loadModel(Gdx.files.internal("Mesh/teapot.g3db")).meshParts.get(0).mesh,
            new Material(ColorAttribute.createDiffuse(Color.BLUE)), pbrShader, null);
    obj.worldTransform.scl(5);
}
项目:Mundus    文件:ModelAsset.java   
@Override
public void load() {
    // TODO don't create a new loader each time
    MG3dModelLoader loader = new MG3dModelLoader(new UBJsonReader());
    model = loader.loadModel(file);
}