ofSpherePrimitive and textures


#1

Hi there,
I am coming back to openFrameworks after some time, so sorry for the possibly silly question (though I have been looking through the forum, and couldn’t find an answer).
Briefly, I am having problems binding a texture to the mesh obtained from an ofSpherePrimitive object. Namely, I am able to bind a texture obtained from loading images via ofImage(), everything works in that case. On the other hand, if I get a texture via cam.getTexture(), where cam is an ofVideoGrabber object, I see the meshed sphere uniformily colored. It does react to the camera, actually, but it seems that all the vertices in the mesh have the same colour. I have also tried to add ofDisableArbTex(), hoping it was useful.
Also, just in case: I am able to texture a square mesh with textures coming from the webcam, by providing the appropriate texture coordinates. So, I suspect that there is something about texture coordinates that I am missing about the mesh obtained from an ofSpherePrimitive object…


#2

Alright, I figured it out: if sphere is an ofSpherePrimitive type, before getting the mesh it’s enough to do

sphere.mapTexCoordsFromTexture(texture);

where texture is the ofTexture obtained via a getTexture() message to an ofVideoGrabber.