LibGDX 3D

0

Witam

Pobrałem setup libgdx ze strony: http://www.aurelienribon.com/blog/2012/04/new-app-libgdx-project-setup/

Program sam pobral mi najnowszą wersję bibliotek i stworzył projekt. Wrzuciłem go do Eclipse i chcę uruchomić program pobrany z przykładów:

package com.me.skatty;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
import com.badlogic.gdx.graphics.g3d.Model;
import com.badlogic.gdx.graphics.g3d.ModelBatch;
import com.badlogic.gdx.graphics.g3d.ModelInstance;
import com.badlogic.gdx.graphics.g3d.lights.DirectionalLight;
import com.badlogic.gdx.graphics.g3d.lights.Lights;
import com.badlogic.gdx.graphics.g3d.loader.G3dModelLoader;
import com.badlogic.gdx.graphics.g3d.materials.ColorAttribute;
import com.badlogic.gdx.graphics.g3d.materials.Material;
import com.badlogic.gdx.graphics.g3d.shaders.CompositeShader;
import com.badlogic.gdx.graphics.g3d.utils.CameraInputController;
import com.badlogic.gdx.graphics.g3d.utils.CompositeShaderProvider;
import com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder;
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder;
import com.badlogic.gdx.tests.utils.GdxTest;
import com.badlogic.gdx.utils.UBJsonReader;

public class Basic3DTest extends GdxTest implements ApplicationListener {
public PerspectiveCamera cam;
public CameraInputController inputController;
public ModelBatch modelBatch;
public Model model;
public ModelInstance instance;
public Lights lights;
public CompositeShader shader;

@Override
public void create () {
modelBatch = new ModelBatch(new CompositeShaderProvider());
// modelBatch = new ModelBatch();
lights = new Lights();
lights.ambientLight.set(0.4f, 0.4f, 0.4f, 1f);
lights.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)));
}

@Override
public void render () {
inputController.update();

Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

modelBatch.begin(cam);
modelBatch.render(instance, lights, shader);
modelBatch.end();
}

@Override
public void dispose () {
modelBatch.dispose();
model.dispose();
}
public boolean needsGL20 () {
return true;
}
public void resume () {
}
public void resize (int width, int height) {
}
public void pause () {
}
}

Jednak Eclipse podkreśla wiele lini i wykazuje problemy:
Description Resource Path Location Type
The import com.badlogic.gdx.graphics.g3d.lights cannot be resolved Basic3DTest.java /skatty-desktop/src/com/me/skatty line 13 Java Problem
The import com.badlogic.gdx.graphics.g3d.lights cannot be resolved Basic3DTest.java /skatty-desktop/src/com/me/skatty line 14 Java Problem
The import com.badlogic.gdx.graphics.g3d.loader cannot be resolved Basic3DTest.java /skatty-desktop/src/com/me/skatty line 15 Java Problem
The import com.badlogic.gdx.graphics.g3d.Model cannot be resolved Basic3DTest.java /skatty-desktop/src/com/me/skatty line 10 Java Problem
The import com.badlogic.gdx.graphics.g3d.ModelBatch cannot be resolved Basic3DTest.java /skatty-desktop/src/com/me/skatty line 11 Java Problem
The import com.badlogic.gdx.graphics.g3d.ModelInstance cannot be resolved Basic3DTest.java /skatty-desktop/src/com/me/skatty line 12 Java Problem
The import com.badlogic.gdx.graphics.g3d.shaders cannot be resolved Basic3DTest.java /skatty-desktop/src/com/me/skatty line 18 Java Problem
The import com.badlogic.gdx.graphics.g3d.utils cannot be resolved Basic3DTest.java /skatty-desktop/src/com/me/skatty line 19 Java Problem
The import com.badlogic.gdx.graphics.g3d.utils cannot be resolved Basic3DTest.java /skatty-desktop/src/com/me/skatty line 20 Java Problem
The import com.badlogic.gdx.graphics.g3d.utils cannot be resolved Basic3DTest.java /skatty-desktop/src/com/me/skatty line 21 Java Problem
The import com.badlogic.gdx.graphics.g3d.utils cannot be resolved Basic3DTest.java /skatty-desktop/src/com/me/skatty line 22 Java Problem
The import com.badlogic.gdx.tests cannot be resolved Basic3DTest.java /skatty-desktop/src/com/me/skatty line 23 Java Problem
The import com.badlogic.gdx.utils.UBJsonReader cannot be resolved Basic3DTest.java /skatty-desktop/src/com/me/skatty line 24 Java Problem
Jak mogę to naprawić?

0

I don't understand Polish so I apologize in advance for that.

That being said, I had the same problem. I resolved it by overwriting the gdx.jar and gdx-sources.jar libraries in my project with the ones in the latest nightly version: http://libgdx.badlogicgames.com/nightlies/libgdx-nightly-latest.zip

1 użytkowników online, w tym zalogowanych: 0, gości: 1