Question

I'm currently learning JPCT for Android. After reading some tutorials and examples, I've noticed that everyone loads their objects and textures on the scene one by one, like this:

cube = loadModel(getAssets().open("cube.3ds"), 1);
TextureManager.getInstance().addTexture("tex", new Texture(getAssets().open("text.png")));
cube.setTexture("tex");
cube.build();
world.addObject(cube);

This should load a 3ds file (that I created on Blender), apply a texture to it and then put it on the world. If this 3ds file has multiple objects, it will apply the texture to all of them. Ok, that's fine so far.

But what if I had like hundreds of objects in the same file to create a scene for a game, each one with its own texture?

I would have to load them and their textures one by one?

Is there any way to automatize this? Maybe some file format that already holds the texture relationship or something like that?

Any help is appreciated!

Was it helpful?

Solution

Found a solution myself!

You don't really have to load your textures manually, as in

cube.setTexture("tex");

as long as you keep the texture filename the same as assigned in Blender when adding it to the TextureManager:

TextureManager.getInstance().addTexture("text.png", new Texture(getAssets().open("text.png")));

By doing so, the Load method will apply the textures by itself!

OTHER TIPS

You should this:

Texture texture = new Texture(BitmapHelper.rescale(BitmapHelper.convert(getResources().getDrawable(R.drawable.image)), 64, 64)); TextureManager.getInstance().addTexture("texture", texture);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top