- Düzenlendi
Spine-c, multiple mesh attachments
Hi! How can I get the maximum number of vertices for a slot which have multiple attachments, with some of them being mesh attachments?
attachmentVerticesCapacity and attachmentVerticesCount give me 0. Or how can I access the remaining attachments, not only the first one?
Here is one of my helper methods I use to get a list of available attachments on a slot (for the current skin).
///////////////////////////////////////
// \brief Returns a list of attachments (sprites) available for a slot position.
// \details E.g. returns {"spear", "dagger"} for "left hand item" slot
///////////////////////////////////////
bool Animation::SpineMovie::GetSlotAttachmentList( const std::string& theSlotName, std::vector<std::string>& theReturnList )
{
if(pSkeleton && pSkeleton->skin)
{
int aSlotIndex = spSkeleton_findSlotIndex(pSkeleton, theSlotName.c_str());
if(aSlotIndex >= 0)
{
theReturnList.clear();
int anAttachmentIndex = 0;
const char* anAttachmentName = spSkin_getAttachmentName(pSkeleton->skin, aSlotIndex, anAttachmentIndex);
while(anAttachmentName != 0)
{
theReturnList.push_back(anAttachmentName);
anAttachmentName = spSkin_getAttachmentName(pSkeleton->skin, aSlotIndex, ++anAttachmentIndex);
}
return true;
}
}
return false;
}
I'm not seeing anyway to get the attachment from the slot/attachment index, spSkin_getAttachment() requires the char* name of the attachment. Once you have the list of attachment names for the slot, you can iterate over it using spSkin_getAttachment/b.
the spAttachment* has an spAttachmentType field, which you can switch() and cast to the concrete type..
switch(attachment->type){
case SP_ATTACHMENT_REGION: // textured quad
{
spRegionAttachment* regionAttachment = (spRegionAttachment*)attachment; // 4 verts
}
break;
case SP_ATTACHMENT_BOUNDING_BOX:
// 0
continue;
case SP_ATTACHMENT_MESH: // textured mesh
{
spMeshAttachment* mesh = (spMeshAttachment*)attachment; // mesh->verticesCount
}
break;
case SP_ATTACHMENT_SKINNED_MESH:
{
spSkinnedMeshAttachment* mesh = (spSkinnedMeshAttachment*)attachment; // mesh->trianglesCount
}
break;
default:
break;
}
I think trianglesCount will give you the number of indices. Since spMeshAttachment doesn't have verticesCount the runtimes use uvsCount instead.
Thank you for your answers. And indeed, I use trianglesCount to get the number of indices.