Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - oetzi

#1
Support / Re: How to load textures on an OBJ model?
September 27, 2013, 04:27:11 PM
Thanks EgonOlsen for your fast response, it works!
The solution can be so easy if you know how to do it :-)

Grüße aus Köln :-)
#2
Support / [SOLVED] How to load textures on an OBJ model?
September 27, 2013, 02:19:16 PM
Hello,

I am new to this topic and have problems with loading textures correctly onto my 3D object.
What I successfully did so far was to load a 3DS model and to put the textures on it via the TextureManager.

But now I have to use a OBJ model. The background is that I did a 3D scan of my face and got the following files:
- oetzi.obj
- oetzi_MATERIAL.mat
- oetzi_TEXTURE-0.jpg
- oetzi_TEXTURE-1.jpg
- oetzi_TEXTURE-2.jpg

The MATERIAL files contains this:
Quote
newmtl material_0
map_Kd oetzi_TEXTURE-0.jpg
newmtl material_1
map_Kd oetzi_TEXTURE-1.jpg
newmtl material_2
map_Kd oetzi_TEXTURE-2.jpg

So I changed the Loader.load3DS(...) method to Loader.loadOBJ(InputStream objStream, InputStream mtlStream, float scale).
My first attemp was to set the 2nd paramter to null and to keep the approach to load the texture first into the TextureManager and then use "obj3D.setTexture("material_0")". The result was that my 3D model was displayed but the textures were a total mess.

Then I thought that there might be a reason, why loadOBJ has this second inputStream called mtl :-)
So I tried to load this .mat file as second inputStream

inputStreamMTL = masterContext.getAssets().open("3d-objects/oetzi-obj/oetzi_MATERIAL.mat");

and used it as second paramter for the loadOBJ() method.

Unfortunately, I do not know what I have to do now in order to get the textures onto the 3D model. All I tried so far, did not work.

Therefore, I would be grateful to get a brief explanation, how I have to handle the .obj, the .mat and the texture files to get my final 3D model displayed.

Greetings,
oetzi
#3
Support / Re: Unsupported texture width
August 19, 2013, 10:35:37 AM
That was a good idea!
However, unfortunately it does not work.
This is what I tried now:

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)
#4
Support / Re: Unsupported texture width
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:

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:

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
#5
Support / Re: Unsupported texture width
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.
#6
Support / Re: Unsupported texture width
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:
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?
#7
Support / Unsupported texture width
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.

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