Author Topic: Unsupported texture width  (Read 4021 times)

Offline oetzi

  • byte
  • *
  • Posts: 7
    • View Profile
Unsupported texture width
« on: August 16, 2013, 04:51:34 pm »
Hello,

I am very new to the general work with 3D objects as well as to jPCT.
Nevertheless, I got an app running, which displays a 3DS object, which I simply downloaded from http://archive3d.net/?a=download&id=527694d7 (I thought it might be a good idea to start with a very simple 3D object :) )

After being happy about this simple 3D object on my screen I have tried to load the related texture, but failed so far.
The error I get is "ERROR: Unsupported Texture width: 800"
I found several posts in this forum which deal with similar issues, but most of them were related to the use of drawables, which is not applicable for my case.

Code: [Select]
inputStream = masterContext.getAssets().open("3d-objects/ball/Ball N280313.3DS");
Texture texture = new Texture(masterContext.getAssets().open("3d-objects/ball/main_product_133750009413897300.jpg"));
TextureManager.getInstance().addTexture("main_product_133750009413897300.jpg", texture);

So, could anyone tell me, what I am doing wrong here?

Greetings,
oetzi





Offline Yerst

  • byte
  • *
  • Posts: 38
    • View Profile
Re: Unsupported texture width
« Reply #1 on: August 16, 2013, 06:16:27 pm »
Your texture sizes need to be a power of two. (2^n)
So just scale your texture to 512*512 for example, and it should work.

Offline oetzi

  • byte
  • *
  • Posts: 7
    • View Profile
Re: Unsupported texture width
« Reply #2 on: August 17, 2013, 10:31:09 am »
Thanks Yerst, that solved indeed the problem. Although I am now a bit confused that only square textures can be used. Anyway.

Now that the texture is loaded sucessfully, I am facing the next problem. It is a bit off-topic, but hopefully you can help me with this too.
The texture is still not displayed and I assume that it simply has to do with the fact, that I do not use the correct name here for the first parameter:
Code: [Select]
TextureManager.getInstance().addTexture("main_product_133750009413897300.jpg", texture);As mentioned before, I downloaded this 3D object from a website. That means that I do not know how the creator named the texture. I downloaded a zip file, which contains:
- Ball N280313.3DS
- Ball N280313.gsm
- main_product_133750009413897300.jpg

So the question is: How do I know which name I have to choose as first parameter in the addTexture() method?

Offline Yerst

  • byte
  • *
  • Posts: 38
    • View Profile
Re: Unsupported texture width
« Reply #3 on: August 17, 2013, 11:56:25 am »
You need to assign the texture to the Object.
It doesn't matter how you name the texture, it just needs to be the same name you called it in the TextureManager.
Code: [Select]
yourBallModel.setTexture("ballTexture");Or for your Current Name:
Code: [Select]
yourBallModel.setTexture("main_product_133750009413897300.jpg");

Offline oetzi

  • byte
  • *
  • Posts: 7
    • View Profile
Re: Unsupported texture width
« Reply #4 on: August 17, 2013, 04:11:41 pm »
Ah, now I see the logic. Thanks a lot!
And if my object consists of more than one part, I probably have to choose the correct order of the textures. I will try it now.

Offline oetzi

  • byte
  • *
  • Posts: 7
    • View Profile
Re: Unsupported texture width
« Reply #5 on: August 17, 2013, 04:32:14 pm »
mhh, I don't get it...

I took another 3DS object which contains of 3 parts.
Therefore I registered the following 3 textures:

Code: [Select]
inputStream = masterContext.getAssets().open("3d-objects/RackForFlowers/Rack for flowers N020813.3DS");
TextureManager.getInstance().addTexture("dirt", new Texture(masterContext.getAssets().open("3d-objects/RackForFlowers/textures/Archmodels66_dirt_1.jpg")));
TextureManager.getInstance().addTexture("leaf", new Texture(masterContext.getAssets().open("3d-objects/RackForFlowers/textures/Archmodels66_leaf_30.jpg")));
TextureManager.getInstance().addTexture("paper", new Texture(masterContext.getAssets().open("3d-objects/RackForFlowers/textures/PaperDecorative0011_1_L.jpg")));

What I did so far afterwards is based on an example I found in the web:

Code: [Select]
Object3D newObject;
        Object3D[] objs = Loader.load3DS(inputStream, 1f);
        Log.i("MyRenderer", "## objs.length ## " + objs.length);
 
        newObject = new Object3D(0);
        Object3D temp = null;
        for (int i = 0; i < objs.length; i++) {
            temp = objs[i];
            temp.setCenter(SimpleVector.ORIGIN);
            temp.rotateX((float)( -.5*Math.PI));
            temp.rotateMesh();
            temp.setTexture("Ball"); ##### <-- this worked for the ball object, which consists only of 1 part
            temp.setRotationMatrix(new Matrix());
            newObject = Object3D.mergeObjects(newObject, temp);
            newObject.build();
        }
       
        return newObject;

I do not see a efficient way to set all the different textures now?!

Here you can see, how the 3D object should look like:
http://archive3d.net/?a=download&id=b16a1a40

Offline Yerst

  • byte
  • *
  • Posts: 38
    • View Profile
Re: Unsupported texture width
« Reply #6 on: August 17, 2013, 10:25:28 pm »
You could change the name of the textures in the TextureManager to something like "RackForFlowers0", "RackForFlowers1",... and just call temp.setTexture("RackForFlowers" + Integer.toString(i));

Offline oetzi

  • byte
  • *
  • Posts: 7
    • View Profile
Re: Unsupported texture width
« Reply #7 on: August 19, 2013, 10:35:37 am »
That was a good idea!
However, unfortunately it does not work.
This is what I tried now:

Code: [Select]
inputStream = masterContext.getAssets().open("3d-objects/RackForFlowers/Rack for flowers N020813.3DS");
TextureManager.getInstance().addTexture("RackForFlowers0", new Texture(masterContext.getAssets().open("3d-objects/RackForFlowers/textures/Archmodels66_dirt_1.jpg")));
TextureManager.getInstance().addTexture("RackForFlowers1", new Texture(masterContext.getAssets().open("3d-objects/RackForFlowers/textures/Archmodels66_leaf_30.jpg")));
TextureManager.getInstance().addTexture("RackForFlowers2", new Texture(masterContext.getAssets().open("3d-objects/RackForFlowers/textures/PaperDecorative0011_1_L.jpg")));
TextureManager.getInstance().addTexture("RackForFlowers3", new Texture(masterContext.getAssets().open("3d-objects/RackForFlowers/textures/PaperDecorative0011_1_L.jpg")));

        Object3D newObject;
        Object3D[] objs = Loader.load3DS(inputStream, 1f);
        Log.i("MyRenderer", "## objs.length ## " + objs.length);
 
        newObject = new Object3D(0);
        Object3D temp = null;
        for (int i = 0; i < objs.length; i++) {
            temp = objs[i];
            temp.setCenter(SimpleVector.ORIGIN);
            temp.rotateX((float)( -.5*Math.PI));
            temp.rotateMesh();
            String tmpName = "RackForFlowers" + Integer.toString(i);
            Log.i("MyRenderer", "## tmpName ## " + tmpName);
            temp.setTexture(tmpName);
            temp.setRotationMatrix(new Matrix());
            newObject = Object3D.mergeObjects(newObject, temp);
            newObject.build();
        }

The output is:
Quote
08-19 10:26:48.985: I/MyRenderer(28308): ## objs.length ## 4
08-19 10:26:48.985: I/MyRenderer(28308): ## tmpName ## RackForFlowers0
08-19 10:26:49.015: E/AndroidRuntime(28308): FATAL EXCEPTION: GLThread 28178
08-19 10:26:49.015: E/AndroidRuntime(28308): java.lang.RuntimeException: [ 1376900808997 ] - ERROR: Tried to set an undefined texture!
08-19 10:26:49.015: E/AndroidRuntime(28308):    at com.threed.jpct.Logger.log(Logger.java:189)
08-19 10:26:49.015: E/AndroidRuntime(28308):    at com.threed.jpct.Object3D.setTexture(Object3D.java:3434)
08-19 10:26:49.015: E/AndroidRuntime(28308):    at de.oetzi.dreid_test.MyRenderer.loadMeshFile(MyRenderer.java:146)
08-19 10:26:49.015: E/AndroidRuntime(28308):    at de.oetzi.dreid_test.MyRenderer.onSurfaceChanged(MyRenderer.java:84)
08-19 10:26:49.015: E/AndroidRuntime(28308):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505)
08-19 10:26:49.015: E/AndroidRuntime(28308):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)