DrawableVertexPosition Validation

Updated: 11/07/2019

Let’s check how the values obtained by CubismModel::GetDrawableVertexPositions change as the model is exported.
Since the return value of the Cubism Core for Native’s cmGetDrawableVertexPositions function is used as it is, it is also a confirmation of the API here.
The environment is as follows.

Confirmation environment

The confirmation environment is performed by modifying the sample program of Cubism SDK for Native and using the log output function.
LAppModel::LoadAssets is modified to log the values of all ArtMesh points.

void LAppModel::LoadAssets(const csmChar* dir, const csmChar* fileName)
{
    _modelHomeDir = dir;
 
    if (_debugMode)LAppPal::PrintLog("[APP]load model setting: %s", fileName);
 
    csmSizeInt size;
    const csmString path = csmString(dir) + fileName;
 
    csmByte* buffer = CreateBuffer(path.GetRawString(), &size);
    ICubismModelSetting* setting = new CubismModelSettingJson(buffer, size);
    DeleteBuffer(buffer, path.GetRawString());
 
    SetupModel(setting);
 
    CreateRenderer();
 
    SetupTextures();
 
    LAppPal::PrintLog("\n[APP]check vertexPositions : %s",fileName);
    for (csmInt32 i = 0; i < _model->GetDrawableCount(); ++i)
    {
        LAppPal::PrintLog("[APP]\t%s",_model->GetDrawableId(i)->GetString().GetRawString());
        const Live2D::Cubism::Core::csmVector2 *xys = _model->GetDrawableVertexPositions(i);
        for (int j = 0; j < _model->GetDrawableVertexCount(i); ++j)
        {
            LAppPal::PrintLog("[APP]\t\tx:%6.3f y:%6.3f", xys[j].X,xys[j].Y);
        }
    }
    LAppPal::PrintLog("[APP]end check\n");
}

Model

The model is just a simple 4-point quadrangle placed just inside the canvas.
Here, Cubism Editor 3.2.00 is used for output.

The settings at output are compared for 6 types: 2 types of PixelsPerUnit with 3 types of center position.

PixelsPerUnit: 1 or 900
Center position: Top left or Middle or Bottom right

index 1: PPU1 upper leftindex 2: PPU1 centerindex 3: PPU1 lower right
index 4: PPU900 upper leftindex 5: PPU900 centerindex 6: PPU900 lower right

Result

[APP]model index: 1
[APP]delete model: Haru.moc3
[APP]load model setting: ppu1tl.model3.json
[APP]create buffer: ppu1tl/ppu1tl.model3.json 
[APP]delete buffer: ppu1tl/ppu1tl.model3.json
[APP]create model: ppu1tl.moc3
[APP]create buffer: ppu1tl/ppu1tl.moc3 
[APP]delete buffer: ppu1tl/ppu1tl.moc3
 
[APP]check vertexPositions : ppu1tl.model3.json
[APP]	ArtMesh
[APP]		x:895.700 y:-5.123
[APP]		x: 5.123 y:-5.123
[APP]		x:895.700 y:-1989.899
[APP]		x: 5.123 y:-1989.899
[APP]end check
 
[APP]model index: 2
[APP]delete model: ppu1tl.moc3
[APP]load model setting: ppu1cent.model3.json
[APP]create buffer: ppu1cent/ppu1cent.model3.json 
[APP]delete buffer: ppu1cent/ppu1cent.model3.json
[APP]create model: ppu1cent.moc3
[APP]create buffer: ppu1cent/ppu1cent.moc3 
[APP]delete buffer: ppu1cent/ppu1cent.moc3
 
[APP]check vertexPositions : ppu1cent.model3.json
[APP]	ArtMesh
[APP]		x:445.700 y:994.877
[APP]		x:-444.877 y:994.877
[APP]		x:445.700 y:-989.899
[APP]		x:-444.877 y:-989.899
[APP]end check
 
[APP]model index: 3
[APP]delete model: ppu1cent.moc3
[APP]load model setting: ppu1br.model3.json
[APP]create buffer: ppu1br/ppu1br.model3.json 
[APP]delete buffer: ppu1br/ppu1br.model3.json
[APP]create model: ppu1br.moc3
[APP]create buffer: ppu1br/ppu1br.moc3 
[APP]delete buffer: ppu1br/ppu1br.moc3
 
[APP]check vertexPositions : ppu1br.model3.json
[APP]	ArtMesh
[APP]		x:-4.300 y:1994.877
[APP]		x:-894.877 y:1994.877
[APP]		x:-4.300 y:10.101
[APP]		x:-894.877 y:10.101
[APP]end check
 
[APP]model index: 4
[APP]delete model: ppu1br.moc3
[APP]load model setting: ppu900tl.model3.json
[APP]create buffer: ppu900tl/ppu900tl.model3.json 
[APP]delete buffer: ppu900tl/ppu900tl.model3.json
[APP]create model: ppu900tl.moc3
[APP]create buffer: ppu900tl/ppu900tl.moc3 
[APP]delete buffer: ppu900tl/ppu900tl.moc3
 
[APP]check vertexPositions : ppu900tl.model3.json
[APP]	ArtMesh
[APP]		x: 0.995 y:-0.006
[APP]		x: 0.006 y:-0.006
[APP]		x: 0.995 y:-2.211
[APP]		x: 0.006 y:-2.211
[APP]end check
 
[APP]model index: 5
[APP]delete model: ppu900tl.moc3
[APP]load model setting: ppu900cent.model3.json
[APP]create buffer: ppu900cent/ppu900cent.model3.json 
[APP]delete buffer: ppu900cent/ppu900cent.model3.json
[APP]create model: ppu900cent.moc3
[APP]create buffer: ppu900cent/ppu900cent.moc3 
[APP]delete buffer: ppu900cent/ppu900cent.moc3
 
[APP]check vertexPositions : ppu900cent.model3.json
[APP]	ArtMesh
[APP]		x: 0.495 y: 1.105
[APP]		x:-0.494 y: 1.105
[APP]		x: 0.495 y:-1.100
[APP]		x:-0.494 y:-1.100
[APP]end check
 
[APP]model index: 6
[APP]delete model: ppu900cent.moc3
[APP]load model setting: ppu900br.model3.json
[APP]create buffer: ppu900br/ppu900br.model3.json 
[APP]delete buffer: ppu900br/ppu900br.model3.json
[APP]create model: ppu900br.moc3
[APP]create buffer: ppu900br/ppu900br.moc3 
[APP]delete buffer: ppu900br/ppu900br.moc3
 
[APP]check vertexPositions : ppu900br.model3.json
[APP]	ArtMesh
[APP]		x:-0.005 y: 2.217
[APP]		x:-0.994 y: 2.217
[APP]		x:-0.005 y: 0.011
[APP]		x:-0.994 y: 0.011
[APP]end check

Notice that the data obtained by CubismModel::GetDrawableVertexPositions is output under the influence of PixelsPerUnit while the XY ratio remains the same.

CubismModelMatrix

The range of DrawableVertexPosition varies greatly with the value of PixelsPerUnit, but when initialized using CubismModelMatrix, it appears that only the center position is specified because it is initialized to the range that fits the screen.

Was this article helpful?
YesNo
Please let us know what you think about this article.