ofxAssimpModelLoader not mapping properly textures


#1

I bought a 3D model of a sweater online where each part had its own mesh, material and texture.

Any software like Rhinoceros 3D, Blender, or even the Xcode visualiser renders it properly.

However, any time I try to load it with OpenFrameworks with ofxAssimpModelLoader, it doesn’t get the texture scaling correct.

I’ve tried to exporting it to ply, 3ds, stl, etc… but non of the other formats worked.

I added “ofDisableArbTex()”, but also didn’t helped.

Any ideas where I could start?


#2

Hi imanologo, the format that I’ve had the most success with is Collada (dae). Make sure you export it with uv texture coordinates and place the texture file with it in the same folder. Also, did you uv-unwrap your mesh and map the textures correctly? That’s where I would start. Make sure you call ofDisableArtTex() before you load your model.


#3

@eulphean thanks for the tip!

I already tried with Collada (dae), unfortunately with the same result.

However, I realised that with the old ofxAddon “ofx3dmodelloader”, which only supports 3ds it mapps everything correctly. Now, I need to figure out why and how can I change on the fly each separate texture.


#4

Hello @imanolgo, it would be helpful to have a snippet of the code that it is not working with the ofxAssimpModelLoader and one that it is working with ofx3dmodelloader. ofxAssimpModelLoader is supposed to load correctly the supported formats. So I think it is a bug.


#5

Hi, so here is a snippet of the code based on the “3DModelLoaderExample” of OF 0.10.0.

void ofApp::setup(){	
	ofBackground(255,255,255);
		
	ofSetVerticalSync(true);
    ofDisableArbTex();
    model.loadModel("sweater_blender.3ds");
    
	model.setRotation(0, 180, 1, 0, 0);
	model.setScale(0.9, 0.9, 0.9);
    light.setPosition(0, 0, 500);
    light.setAmbientColor(ofColor::white);

	cameraOrbit = 0;
	cam.setDistance(700);
}
void ofApp::draw(){
	ofEnableDepthTest();
	
    light.enable();

	cam.begin();
    ofSetColor(255, 255, 255, 255);
	model.drawFaces();
	cam.end();
    
    light.disable();

	ofDisableDepthTest();
}

And here is the example using the old “ofx3DModelLoader”

void testApp::setup(){  
    ofBackground(255,255,255);
        
    ofSetVerticalSync(true);

    //some model / light stuff
    glEnable (GL_DEPTH_TEST);
    glShadeModel (GL_SMOOTH);

    /* initialize lighting */
    glLightfv (GL_LIGHT0, GL_POSITION, lightOnePosition);
    glLightfv (GL_LIGHT0, GL_DIFFUSE, lightOneColor);
    glEnable (GL_LIGHT0);
    glLightfv (GL_LIGHT1, GL_POSITION, lightTwoPosition);
    glLightfv (GL_LIGHT1, GL_DIFFUSE, lightTwoColor);
    glEnable (GL_LIGHT1);
    glEnable (GL_LIGHTING);
    glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE);
    glEnable (GL_COLOR_MATERIAL);

    //load the squirrel model - the 3ds and the texture file need to be in the same folder
    model.loadModel("sweater_blender.3ds");
}

void testApp::draw(){
    
    //lets tumble the world with the mouse
    glPushMatrix();

        //draw in middle of the screen
        glTranslatef(ofGetWidth()/2,ofGetHeight()/2,0);
        //tumble according to mouse
        glRotatef(-mouseY,1,0,0);
        glRotatef(mouseX,0,1,0);
        glTranslatef(-ofGetWidth()/2,-ofGetHeight()/2,0);

        ofSetColor(255, 255, 255, 255);
        model.draw();

    glPopMatrix();

}

That renders properly the model with its textures.

Also here’s the model if you want to check it out.

I might be missing something basic here, but I haven’t found it yet.


#6

@ edapx

Do you have new insights where I can start working on?


#7

Sorry I did not have time to look into it. I was assuming to have your same problem but at the end I am using a model without a texture for the project I am working on. I have a look at the example https://github.com/openframeworks/openFrameworks/tree/patch-release/examples/3d/3DModelLoaderExample and, except for .ply file, it is working correctly to me. So maybe it is something related to the model and not to the application?

You could try to take that example and use your model instead, and see what the behaviour is. If the texture is still wrong, you could put a debugger in the ofxAssimpModelLoader and see where the problem is. Maybe the scale value, or the UV coord. etc…


#8

Hi @edapx,

I’ve been running this example the whole time.

It doesn’t matter if I load the 3ds, obj or dae file it always happens the same.

It also matters if I Enable/DIsable ArbTex().

It also doesn’t matter if I run it with the programmable renderer or not.

The result is that two of the meshes are rendered with the texture properly, while the rest for whatever reason doesn’t.

As I said any software like Rhinoceros 3D, Blender, or even the Xcode visualiser renders it properly. Even the old ofxAddon “ofx3dmodelloader”, which only supports 3ds it maps everything correctly.

I still can’t find the bug…