2014-09-29 68 views
2

我是新來c/cinder和我試圖導入一個3ds .obj文件到煤渣和應用一個簡單的紋理。我真的無法找到關於如何做到這一點的簡單教程,它似乎與freeGLUT略有不同。Cinder如何紋理一個.obj trimesh

gl::Texture sTexture; 
    sTexture = gl::Texture(loadImage(loadAsset("texture.jpg"))); 

    cinder::TriMesh mySphere; 
    ObjLoader loader(loadFile("mySphere/sphere.obj")); 
    loader.load(&mySphere); 
    gl::draw(mySphere); 

我明白mySphere constains紋理共同ORDS作爲載體,我需要紋理綁定的對象,但我不能找到如何一個明顯的例子?我所嘗試過的每件事都給我留下了一個白色圓圈。

謝謝。

回答

1

找到我的解決方案。我正在使用sTexture.bind();但是sTexture.enableAndBind();是必要的。

gl::Texture sTexture; 
sTexture = gl::Texture(loadImage(loadAsset("texture.jpg"))); 
sTexture.enableAndBind(); 
cinder::TriMesh mySphere; 
ObjLoader loader(loadFile("mySphere/sphere.obj")); 
loader.load(&mySphere); 
gl::draw(mySphere); 
sTexture.unbind();