サンプル
マルチテクスチャ
1 つのモデルに対して 2 枚のテクスチャを重ね合わせて使用する機能で、これはオーサリングツールから出力する時点で設定を行っておく必要があります。
1. マルチテクスチャの設定
mceAppearance_setTexture( This, ix, texture ) を使用して、対象のモデルが使用する 1 つの mceAppearance に対し、2 つの mceTexture を設定します。mceTexture を外したい場合は、引数 texture に NULL を指定してください。使用する mceTexture は mceTextureTable_findTexture( This, gID ) を使用して取得します。
typedef struct tagWork
{
(中略)
mceFigure *Figure; /* Figure */
mceTextureTable *Textbl0; /* TextureTable0 */
mceTextureTable *Textbl1; /* TextureTable1 */
mceAppearance *Appe; /* Appearance */
(中略)
mceTexture *Texture0; /* Texture0 */
mceTexture *Texture1; /* Texture1 */
(中略)
} WORK;
work->Appe = (mceAppearance *)mceObject3D_findObject3D (
(mceObject3D *)work->Figure,
ClassId_Appearance,
0);
if (work->Appe == NULL)
{
return 1;
}
/* mceTextureTableからmceTextureを取得 */
work->Texture0 = mceTextureTable_findTexture (work->Textbl0, 0);
if (work->Texture0 == NULL)
{
return 1;
}
work->Texture1 = mceTextureTable_findTexture (work->Textbl1, 1);
if (work->Texture1 == NULL)
{
return 1;
}
(中略)
hi_exception exception;
(中略)
/* mceAppearanceにmceTextureを設定する */
exception = mceAppearance_setTexture (work->Appe,
0, work->Texture0);
if (exception != hi_NoException)
{
return 1;
}
exception = mceAppearance_setTexture (work->Appe,
1, work->Texture1);
if (exception != hi_NoException)
{
return 1;
}
描画結果には、mceAppearance が持っているインデックスに対して、mceTexture を設定する順序や、テクスチャブレンドモードの設定も影響します。テクスチャブレンドモードの設定に関しては、「ブレンドモード」のドキュメントページを参照してください。
hi_exception exception;
/* インデックス0: Texture0、インデックス1: Texture1 */
exception = mceAppearance_setTexture (work->Appe,
0, work->Texture0);
if (exception != hi_NoException)
{
return 1;
}
exception = mceAppearance_setTexture (work->Appe,
1, work->Texture1);
if (exception != hi_NoException)
{
return 1;
}
/* mceTextureを設定するインデックスを逆にすると、上記と描画結果が異なる */
exception = mceAppearance_setTexture (work->Appe,
0, work->Texture1);
if (exception != hi_NoException)
{
return 1;
}
exception = mceAppearance_setTexture (work->Appe,
1, work->Texture0);
if (exception != hi_NoException)
{
return 1;
}
![]() |
![]() |
| インデックス 0 にテクスチャ 1 を設定 | インデックス 0 にテクスチャ 2 を設定 |
![]() |
![]() |
| テクスチャ 2 の上にテクスチャ 1 を設定 | テクスチャ 1 の上にテクスチャ 2 を設定 |
| 描画結果 1 ( テクスチャブレンドモードは、 インデックス 0: mceAppearance_Texture_FUNC_REPLACE インデックス 1: mceAppearance_Texture_FUNC_DECAL ) |
|
![]() |
![]() |
| テクスチャ 2 の上にテクスチャ 1 を設定 | テクスチャ 1 の上にテクスチャ 2 を設定 |
| 描画結果 2 ( テクスチャブレンドモードは、 インデックス 0: mceAppearance_Texture_FUNC_REPLACE インデックス 1: mceAppearance_Texture_FUNC_BLEND ) |
|







