分類:Ogre |
一、材質資源
//取得該腳本材質對象
Ogre::MaterialPtr mMaterial = MaterialManager::getSingleton().getByName("Examples/Mark");
//根據texture索引以及pass索引刪除紋理。並添加我們指定的新紋理圖片
mMaterial->getTechnique(0)->getPass(0)->removeTextureUnitState(0);
mMaterial->getTechnique(0)->getPass(0)->createTextureUnitState("spheremap.png");
//根據取得的材質對象,然後分別設置環境光、漫反射光;其實就是通道pass類中的成員函數
mMaterial->getTechnique(0)->getPass(0)->setAmbient(1.0, 0.0, 0.0);
mMaterial->getTechnique(0)->getPass(0)->setDiffuse(1.0, 0.0, 0.0, 1.0);
二、紋理對象
Ogre::TextureUnitState *texture;
//通過各個索引取得最後的紋理,得到該紋理對象可以通過名稱,也可以通過索引值。
texture = mMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0);
//將紋理進行旋轉
texture->setTextureRotate(Ogre::Degree(30));
其實,除了可以將紋理進行旋轉,我們還可以對其進行放縮、橫向滾動。而且u,v軸可以同時設置也可以分開設置。下面給出了其成員函數。另外還可以設置紋理邊緣顏色
TextureUnitState setTextureScale(Real uScale, Real vScale);
TextureUnitState setTextureScale(Real uScale /或者 vScale);
TextureUnitState setTextureScroll(Real u, Real v);
TextureUnitState setTextureScroll(Real u /或者Real v);
TextureUnitState setTextureBorderColour(const ColourValue& colour);