If you have any questions, reports, suggestions, or requests about Live2D, please send them to this forum.
※We cannot guarantee statements or answers from Live2D staff. Thank you for your understanding in advance.
@curianlord The current SDK currently doesn't provide an easy way to do this... My first comments to this question show a way to do it - although not good, currently probably the best you can do. The functions called are basically the same in the c++ based SDKs but feel free to ask questions.
for(int i=0; isize(); ++i) { PartsData* part = (*parts)[i]; int pointCount = 0; float* points = live2DModel->getTransformedPoints(live2DModel->getPartsDataIndex(part->getPartsDataID()),&pointCount);
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];
if(x < left)left=x; // Min x if(x > right)right=x; // Max x if(y < top)top=y; // Min y if(y > bottom)bottom=y; // Max y } }
My Test Program Window Size is 1024 * 768 but the calculated value is left = 744.523987, right = 1652.80640, top 199.542847, bottom = 2840.10376... This Size is bigger than window size..
If yes, the coordinates you get from that function are in Live2D's model space, so you would have to convert them back or the UI coordinates forth. Do you set the projection matrix, etc. by yourself?
Comments
thanks for using Live2D! Do you want to get the axis aligned margins of the whole model?
The current SDK currently doesn't provide an easy way to do this...
My first comments to this question show a way to do it - although not good, currently probably the best you can do. The functions called are basically the same in the c++ based SDKs but feel free to ask questions.
float right=0;
float top=live2DModel->getCanvasHeight();
float bottom=0;
for(int i=0; i
{
PartsData* part = (*parts)[i];
int pointCount = 0;
float* points = live2DModel->getTransformedPoints(live2DModel->getPartsDataIndex(part->getPartsDataID()),&pointCount);
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];
if(x < left)left=x; // Min x
if(x > right)right=x; // Max x
if(y < top)top=y; // Min y
if(y > bottom)bottom=y; // Max y
}
}
This Size is bigger than window size..
So it must offer, pixel compact scalability and hitting test for pixel coordinate