Hi! I am struggling with binding a texture to other mesh than that of a 3D primitive. I have an FBO that I want to use as a texture. With sphere and sphere.mapTexCoords it goes fine.
However, my mesh is made of a 3d animal with 70 000 vertices. I have loaded it straight as a ply. Before going to draw, I assume I should have as similar mapping as one does with the primitives:
mesh.mapTexCoords(0, h, w, 0);
That obviously won’t work because it is not a function. Right now I don’t have any mapping for the mesh texture coordinates. How does one do that?
Here is my code that binds the fob to the sphere mesh but not to the dino mesh:
void ofApp::draw3d(){
fbo2.getTextureReference().bind();
material.begin();
ofEnableDepthTest();
cam.begin();
light.setPosition (ofGetWidth()/2, ofGetHeight()/2, 600);
light.enable();
float time = ofGetElapsedTimef();
float longitude = 10*time;
float latitude = 10*sin(time*0.8);
float radius = 600 + 50*sin(time*0.4);
//cam.orbit(longitude, latitude, radius, ofPoint(0,0,0));
ofSetColor(ofColor::white);
float rotChange = ofMap (classVal, 1, 19, -5.0, 5.0);
if (classVal > 15){
ofScale (1, -1, 1);
ofRotateYDeg(ofGetElapsedTimef() * 30);
dinomesh.draw();
}
else {
ofScale (1, -1, 1);
sphere.rotate(rotChange, 0, 1.0, 0.0);
sphere.draw();
}
cam.end();
ofDisableDepthTest();
material.end();
light.disable();
ofDisableLighting();
fbo2.getTextureReference().unbind();
UPDATE: This was solved by adding ofDisableArbTex();
before allocating FBO in setup - now the texture (image) at least seems to bind. However I am still curious if there is a recommenced way to get texCoords out of a mesh with loads of vertices so any advice is welcome.