頂点インデックスの取得
Modelerで設定した描画オブジェクトの頂点位置はgetTransformedPointsで取得することができます。
それに対応するインデックスリストはgetIndexArrayで取得できます。
第一引数にgetTransformedPointsと同じ描画オブジェクトインデックスを指定します。
第二引数には三角形ポリゴンの数が返ってきます。
ポリゴン一つにつき3つの頂点インデックスが含まれます。
//サンプルコード
int drawIndex=live2DModel->getDrawDataIndex("D_REF.HEAD");//描画オブジェクトのIDを指定して、プログラム上でのインデックスを取得
if(drawIndex<0)return;// 存在しない場合
int pointCount=0;//頂点数。頂点は1つにつきx,yの情報を持つ
int polygonCount=0;//ポリゴン数
float* points=live2DModel->getTransformedPoints(drawIndex,&pointCount);
unsigned short* index=live2DModel->getIndexArray(drawIndex,&polygonCount);
for (int i = 0; i < pointCount; i++)
{
float x = points[DEF::VERTEX_OFFSET+i*DEF::VERTEX_STEP];
float y = points[DEF::VERTEX_OFFSET+i*DEF::VERTEX_STEP+1];
NN_LOG("point:%d (x:%f y:%f)\n",i,x,y);
}
for (int i = 0; i < polygonCount; i++)
{
NN_LOG("index:%d (%d %d %d)\n",i,index[i*3],index[i*3+1],index[i*3+2]);
}