因為立方體只有四個面,而我們有六個菜單項,所以在選轉菜單時必須改變紋理。
為了在立方體上使用不同的紋理,我們必須為立方體的每一個面建立一個外觀(appearance)。
Appearance []appearance = new Appearance[6];
for(int i=0; i<appearance.length; i++){
appearance[i] = new Appearance();
appearance[i].setPolygonMode(polygonMode);
mesh.setAppearance(i, appearance[i]);
}
那麼我們如下所示改變紋理:
Appearance f,t,b;
f = appearance1; // front
t = appearance3; // top
b = appearance4; // bottom
f.setTexture(0, texMenu[front]);
t.setTexture(0, texMenu[top]);
b.setTexture(0, texMenu[bottom]);