コード例 #1
0
ファイル: MaterialTest.java プロジェクト: nayomnik/blog
  @Override
  public void create() {
    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(0f, 8f, 8f);
    cam.lookAt(0, 0, 0);
    cam.near = 0.1f;
    cam.far = 300f;
    cam.update();

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

    ModelBuilder modelBuilder = new ModelBuilder();
    model =
        modelBuilder.createSphere(
            2f,
            2f,
            2f,
            20,
            20,
            new Material(),
            Usage.Position | Usage.Normal | Usage.TextureCoordinates);

    for (int x = -5; x <= 5; x += 2) {
      for (int z = -5; z <= 5; z += 2) {
        ModelInstance instance = new ModelInstance(model, x, 0, z);
        ColorAttribute attrU =
            new TestColorAttribute(
                TestColorAttribute.DiffuseU, (x + 5f) / 10f, 1f - (z + 5f) / 10f, 0, 1);
        instance.materials.get(0).set(attrU);
        ColorAttribute attrV =
            new TestColorAttribute(
                TestColorAttribute.DiffuseV, 1f - (x + 5f) / 10f, 0, (z + 5f) / 10f, 1);
        instance.materials.get(0).set(attrV);
        instances.add(instance);
      }
    }

    shader = new TestShader();
    shader.init();

    modelBatch = new ModelBatch();
  }
コード例 #2
0
ファイル: MaterialTest.java プロジェクト: nayomnik/blog
 @Override
 public void dispose() {
   shader.dispose();
   model.dispose();
   modelBatch.dispose();
 }