Collision Detection of the Model

Live2D has no function of Collision Detection.
Instead, Collision Detection is possible outside using the point information of polygons.

If you want to check the point index, you need to do it with the Modeler tool. Go above link page and see "How to check the point index".

The getTransformedPoints function of the ALive2DModel class is used for Collision Detection.
This function is to get the point of the specified draw data.
NULL will be returned if unavailable. You can get the point number with the second parameter.

A point alignment may differ depending on the platform.
The offset value which starts from "x" in the sequence of points of DEF::VERTEX_OFFSET is stored.
You can generally get it with the following format;


In this case,
DEF::VERTEX_OFFSET is zero, and
DEF::VERTEX_STEP is two of x and y, so it is two.

You also need to invoke the update function once or more before using it.

Examples of getting the point
int pointCount = 0 ;
int drawIndex = live2DModel->getDrawDataIndex("D_REF.HEAD") ;//ID set in the Modeler toolModeler
float* points = live2DModel->getTransformedPoints( drawIndex , &pointCount ) ;

if( ! points )return;//Aquire failed. Because of ID mistake, or export setting mistake.

//live2d::DEF is written in DEF.h
int offset = live2d::DEF::VERTEX_OFFSET ;//offset which starts from x in sequence of points
int step = live2d::DEF::VERTEX_STEP ; //Numbers of point included in one point

for( int i = 0 ; i < pointCount ; i++ )
    int xi = i*step + offset   ;
    int yi = i*step + offset+1 ;
    printf("%5.1f ,%5.1f  " , points[xi], points[yi]) ;