ofx3DModelLoader reversed uv coords when using ofTexture.bind()

Hi all,

I’m trying out playing a video on a 3d mesh. In this case a simple plane. However when I try to bind the video the uv coords are reversed :frowning:

  
  
void testApp::setup(){  
  ofEnableNormalizedTexCoords();  
  squirrelModel.loadModel("uvplane.3ds", 30);  
  squirrelModel.setRotation(1, -90, 1, 0, 0);  
  squirrelModel.setPosition(ofGetWidth()/2, ofGetHeight()/2, 0);  
  vidPlayer.loadMovie("../../../../examples/moviePlayerExample/bin/data/movies/fingers.mov");  
  vidPlayer.play();  
  videoTexture.allocate(vidPlayer.getWidth(),vidPlayer.getHeight(), GL_RGB);  
  ofSetFrameRate(60);  
}  
  
void testApp::update(){  
    vidPlayer.idleMovie();  
}  
  
void testApp::draw(){  
    ofSetColor(255, 255, 255, 255);  
    ofTexture &tex = vidPlayer.getTextureReference();  
    tex.bind();  
    squirrelModel.draw();  
    tex.unbind();  
    ofSetColor(255, 255, 255, 255);  
    vidPlayer.draw(20,20);  
    ofSetHexColor(0x000000);  
    ofDrawBitmapString("fps: "+ofToString(ofGetFrameRate(), 2), 10, 15);  
}  

Using 007 from git on Ubuntu 10.04. See screenshot, the model is not upside down. The original texture is rendered correct.

Anybody knows what’s wrong?

Rg,

Arnaud

ofVideoPlayer flips the texture by default b/c OF uses a different co-ordinate system than the raw openGL calls so that we get the more familiar

[0,0][1,0]
[0,1][1,1]

instead of the raw openGL

[0,1] [1,1]
[0,0] [1,0]

but the movie is loading them flipped, so you need to un-flip them by inverting the UV coords or by doing:

  
tex.texData.bFlipTexture = false;  

1 Like

Thanks for that explanation. However it doesn’t help. :frowning:
If I put

  
   1. tex.texData.bFlipTexture = true;    

The whole video is flipped and so is corresponding to the video on the mesh but up side down.

I switched to the assimp addon which doesn’t have this issue…

Rg,

Arnaud

Oh weird. Hmm, can you post your uvplane.3ds? Is it really just 4 points or does it have texture points in there too? I’d love to see if I can figure out what’s going on, even if it is fixed in assimp. Thanks!

actually, someone (juliolucio) sent me some fixes for normals in ofx3DSModelLoader, dont know if it can be related, havent’ tested yet.

ofx3DModelLoader.zip