DrawableVertexPosition的验证

最終更新: 2019年11月7日

此页面适用于Cubism 4.2及更早版本的旧版本。 点击此处查看最新页面

确认通过CubismModel::GetDrawableVertexPositions得到的值是如何随着模型的输出而变化的。
由于原样使用Cubsim Core for Native的csmGetDrawableVertexPositions函数的返回值,也是对该API的确认。
环境如下。

确认环境

通过修改Cubism SDK for Native的范例程序,并使用记录输出功能进行确认环境。
正在变更LAppModel::LoadAssets,以将ArtMesh的所有点的值输出到记录中。

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");
}

模型

这是一个模型,其中简单的四点矩形置入在画布的最边缘。
在此确认中,使用Cubism Editor 3.2.00输出。

输出时的设置是2种PixelsPerUnit和3种中心位置,比较6种。

PixelsPerUnit:1 or 900
中心位置:左上or中心or右下  

index 1:PPU1左上index 2:PPU1中心index 3:PPU1右下
index 4:PPU900左上index 5:PPU900中心index 6:PPU900 右下

结果

[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

可以看出,通过CubismModel::GetDrawableVertexPositions得到的数据是在PixelsPerUnit的影响下输出的,且XY比例不变。

CubismModelMatrix

DrawableVertexPosition的范围根据PixelsPerUnit的值将出现大幅变化,
但使用CubismModelMatrix进行原始化似乎只指定了中心位置,因为它是在适合画面的范围内原始化的。

请问这篇文章对您有帮助吗?
关于本报道,敬请提出您的意见及要求。