LibGDX 3d not working?

I am trying to follow this tutorial on LibGDX:

but whenever I put the code into the program, i get a whole bunch of errors
here is my code:


package com.me.main;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;

public class Game implements ApplicationListener {
	public PerspectiveCamera cam;
    public ModelBatch modelBatch;
    public Model model;
    public ModelInstance instance;
	@Override
	public void create() {		
		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();
        
        ModelBuilder modelBuilder = new ModelBuilder();
        model = modelBuilder.createBox(5f, 5f, 5f, 
            new Material(ColorAttribute.createDiffuse(Color.GREEN)),
            Usage.Position | Usage.Normal);
        instance = new ModelInstance(model);
	}

	@Override
	public void dispose() {
		 model.dispose();modelBatch.dispose();
	        model.dispose();

	@Override
	public void render() {		
		 Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
	 
	        modelBatch.begin(cam);
	        modelBatch.render(instance);
	        modelBatch.end();
	}

	@Override
	public void resize(int width, int height) {
	}

	@Override
	public void pause() {
	}

	@Override
	public void resume() {
	}
}


and the error:


Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
	ModelBatch cannot be resolved to a type
	Model cannot be resolved to a type
	ModelInstance cannot be resolved to a type
	ModelBuilder cannot be resolved to a type
	ModelBuilder cannot be resolved to a type
	Model cannot be resolved to a type
	Material cannot be resolved to a type
	ColorAttribute cannot be resolved
	ModelInstance cannot be resolved to a type
	ModelInstance cannot be resolved to a type
	Model cannot be resolved to a type
	Model cannot be resolved to a type
	ModelBatch cannot be resolved to a type
	Model cannot be resolved to a type
	Syntax error, insert "}" to complete MethodBody
	ModelBatch cannot be resolved to a type
	ModelBatch cannot be resolved to a type
	ModelInstance cannot be resolved to a type
	ModelBatch cannot be resolved to a type

	at com.me.main.Game.<init>(Game.java:12)
	at com.me.main.Main.main(Main.java:14)


Sorry, but I’m gonna be blunt. We’re not here to help you get simple code to compile for you. This is a game developing forum, not a Java newbie forum. If you do not know how to import classes from other packages, then you’re not ready to start making games.

EDIT: I just checked your post history. Is this post a troll post? :yawn:

EDIT2: I’m convinced. This is a troll post.

There’s something wrong with your project setup. Your libraries aren’t being included on compilation or something like that.

Edit: This is WIP games, tools & toy projects. I agree, this must be a troll post :emo:

What Slyth said; it’s a classpath issue. Make sure you have lidGDX jars and such in your Referenced Libraries (if on Eclipse).

Unless of course you’re trolling.

He also has a completely different writing style as well. Maybe he got hacked?

omg :expressionless: i was in a hurry to post this before I did something and posted it in the wrong forum. :yawn: sorry! this is not a troll post at all, just a case of rushed antics. okay if someone could move this to a correct section, that would be great! i’ll edit the first post to make it a bit more imformative

He copied the code directly from the author of the blog. https://github.com/xoppa/blog/blob/master/tutorials/src/com/xoppa/blog/libgdx/g3d/basic3d/step3/Basic3DTest.java

edit: moved

yep, after I followed the tutorial and got all of the errors, I figured that I must have typed something wrong on the way so I copied the code directly into the program to see if it would run but I still got the same errors. That github link is found in the tutorial. My account was not hacked!!!

Anyways, the errors are probably because your libgdx libraries aren’t updated (model, modelbatch etc are all newer classes), you can use the setup-ui jar provided in the libgdx download.

that’s the thing, i did use that ui. I’ll try to update libGDX in that program to check if I just have a later version.

Ah, that is probably it, it doesn’t complain about Color or Gl20 for example, just the Model-related stuff.

nothin’… Even after totally re-downloading everything and retrying. This is the tutorial that badlogic links to so I assume it’s up-to-date. I don’t know what could be wrong

Well did you at least add the imports for ModelBuilder, etc? Without the imports it won’t work for sure, and if the classes aren’t there, then the tut is out of date (likely).

Do you have the right gdx.jar’s referenced? It won’t make a difference what’s in your libs folder if you’re referencing the wrong jar on the build path.

Okay, I figured it out:

There is a new version of the libgdx launcher that downloads everything to a Gradle project which then has to be imported into eclipse. Then it worked.