Ogre overlay實現幀動畫

2021-05-22 00:52:12 字數 898 閱讀 7612

ogre dome上有動態紋理的效果演示,這裡講的不是移動或旋轉紋理座標產生的紋理動態效果,而是由幾張更換顯示產生的動畫效果,這種效果在2d中指的是幀動畫。首先要準備好一組,如animotion1.jpg, animotion2.jpg, animotion3.jpg, animotion4.jpg. ogre的材質的texture-uint中有anim_texture這個屬性(可以參考ogre中文幫助手冊),它是專門為作幀動畫準備的。接著定義乙個簡單的overlay, 以下是我的簡單定義:

howlet/bigmapoverlay

material bigmap/player的定義:

material bigmap/player}}

}然後我們通過textureunitstate* ptexuint = overlaymanager::getsingleton().getoverlayelement(「bigmap/player」)->getmaterial()->gettechnique(0)->getpass(0)->gettextureunitstate(0);就可以得到當前的texture_unit 也就是material bigmap/player中的紋理。

接下來定義陣列名:const ogre::string animotion[4]  = ; 注意這4張代表的是不同的名字。

最後通過textureunitstate::setanimatedtexturename(const string* const names, unsigned int numframes, real duration = 0)可以直接設定動畫。在我們這裡是ptexuint->setanimatedtexturename(animotion, 4, 4*0.1);就這樣,簡單得實現了動畫效果。

setanimatedtexturename這個函式可以參考官方說明。

Ogre overlay實現幀動畫

ogre dome上有動態紋理的效果演示,這裡講的不是移動或旋轉紋理座標產生的紋理動態效果,而是由幾張更換顯示產生的動畫效果,這種效果在2d中指的是幀動畫。首先要準備好一組,如animotion1.jpg,animotion2.jpg,animotion3.jpg,animotion4.jpg.og...

Ogre overlay實現幀動畫

ogre dome上有動態紋理的效果演示,這裡講的不是移動或旋轉紋理座標產生的紋理動態效果,而是由幾張更換顯示產生的動畫效果,這種效果在2d中指的是幀動畫。首先要準備好一組,如animotion1.jpg,animotion2.jpg,animotion3.jpg,animotion4.jpg.og...

AnimationDrawable實現幀動畫

例項化animationdrawable物件 frameanimation new animationdrawable 裝載資源 for int i 1 i 15 i int id getresources getidentifier a i,drawable mcontext.getpackage...