예제 #1
0
void SkinController::OnFirstUpdate()
{
    // Get access to the vertex buffer positions to store the blended targets.
    Visual* visual = reinterpret_cast<Visual*>(mObject);
    VertexBuffer* vbuffer = visual->GetVertexBuffer().get();
    if (mNumVertices == static_cast<int>(vbuffer->GetNumElements()))
    {
        // Get the position data.
        VertexFormat vformat = vbuffer->GetFormat();
        int const numAttributes = vformat.GetNumAttributes();
        for (int i = 0; i < numAttributes; ++i)
        {
            VASemantic semantic;
            DFType type;
            unsigned int unit, offset;
            if (vformat.GetAttribute(i, semantic, type, unit, offset))
            {
                if (semantic == VA_POSITION && (type == DF_R32G32B32_FLOAT 
                    || type == DF_R32G32B32A32_FLOAT))
                {
                    mPosition = vbuffer->GetData() + offset;
                    mStride = vformat.GetVertexSize();
                    mCanUpdate = true;
                    break;
                }
            }
        }
    }

    mCanUpdate = (mPosition != nullptr);
}